ADD filter/search to manufacturers and stocks
This commit is contained in:
parent
e69f2af6b0
commit
add4b362ac
49
admin/forms/filter_manufacturers.xml
Normal file
49
admin/forms/filter_manufacturers.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form addfieldprefix="Joomla\Component\Depot\Administrator\Field">
|
||||
<fields name="filter">
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_DEPOT_PARTS_FILTER_SEARCH_LABEL"
|
||||
description="COM_DEPOT_PARTS_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
<field
|
||||
name="published"
|
||||
type="status"
|
||||
label="JSTATUS"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_PUBLISHED</option>
|
||||
</field>
|
||||
</fields>
|
||||
<fields name="list">
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
statuses="*,0,1,2,-2"
|
||||
class="js-select-submit-on-change"
|
||||
default="m.name_long ASC"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="m.state ASC">JSTATUS_ASC</option>
|
||||
<option value="m.state DESC">JSTATUS_DESC</option>
|
||||
<option value="m.name_long ASC">JGLOBAL_NAME_ASC</option>
|
||||
<option value="m.name_long DESC">JGLOBAL_NAME_DESC</option>
|
||||
<option value="m.name_short ASC">COM_DEPOT_ACRONYM_ASC</option>
|
||||
<option value="m.name_short DESC">COM_DEPOT_ACRONYM_DESC</option>
|
||||
<option value="m.id ASC">JGRID_HEADING_ID_ASC</option>
|
||||
<option value="m.id DESC">JGRID_HEADING_ID_DESC</option>
|
||||
</field>
|
||||
<field
|
||||
name="limit"
|
||||
type="limitbox"
|
||||
label="JGLOBAL_LIST_LIMIT"
|
||||
default="25"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
49
admin/forms/filter_stocks.xml
Normal file
49
admin/forms/filter_stocks.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form addfieldprefix="Joomla\Component\Depot\Administrator\Field">
|
||||
<fields name="filter">
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_DEPOT_PARTS_FILTER_SEARCH_LABEL"
|
||||
description="COM_DEPOT_PARTS_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
<field
|
||||
name="published"
|
||||
type="status"
|
||||
label="JSTATUS"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_PUBLISHED</option>
|
||||
</field>
|
||||
</fields>
|
||||
<fields name="list">
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
statuses="*,0,1,2,-2"
|
||||
class="js-select-submit-on-change"
|
||||
default="s.name ASC"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="s.state ASC">JSTATUS_ASC</option>
|
||||
<option value="s.state DESC">JSTATUS_DESC</option>
|
||||
<option value="s.name ASC">JGLOBAL_NAME_ASC</option>
|
||||
<option value="s.name DESC">JGLOBAL_NAME_DESC</option>
|
||||
<option value="s.description ASC">COM_DEPOT_DESCRIPTION_ASC</option>
|
||||
<option value="s.description DESC">COM_DEPOT_DESCRIPTION_DESC</option>
|
||||
<option value="s.id ASC">JGRID_HEADING_ID_ASC</option>
|
||||
<option value="s.id DESC">JGRID_HEADING_ID_DESC</option>
|
||||
</field>
|
||||
<field
|
||||
name="limit"
|
||||
type="limitbox"
|
||||
label="JGLOBAL_LIST_LIMIT"
|
||||
default="25"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
@ -11,7 +11,8 @@
|
||||
namespace KW4NZ\Component\Depot\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
// use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
@ -60,6 +61,14 @@ class ManufacturersModel extends ListModel
|
||||
->from($db->quoteName('#__depot_manufacturer', 'm'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('m.checked_out'));
|
||||
|
||||
// filter: like / search
|
||||
$search = $this->getState('filter.search');
|
||||
if (!empty($search)) {
|
||||
$like = $db->quote('%' . $search . '%');
|
||||
$query->where('(' . $db->quoteName('m.name_long') . ' LIKE ' . $like . ' OR ' .
|
||||
$db->quoteName('m.name_short') . ' LIKE ' . $like . ')');
|
||||
}
|
||||
|
||||
// Filter by published state
|
||||
$published = (string) $this->getState('filter.published');
|
||||
if (is_numeric($published)) {
|
||||
|
@ -11,7 +11,8 @@
|
||||
namespace KW4NZ\Component\Depot\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
// use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
@ -58,6 +59,13 @@ class StocksModel extends ListModel
|
||||
)
|
||||
->from($db->quoteName('#__depot_stock', 's'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('s.checked_out'));
|
||||
// filter: like / search
|
||||
$search = $this->getState('filter.search');
|
||||
if (!empty($search)) {
|
||||
$like = $db->quote('%' . $search . '%');
|
||||
$query->where('(' . $db->quoteName('s.name') . ' LIKE ' . $like . ' OR ' .
|
||||
$db->quoteName('s.description') . ' LIKE ' . $like . ')');
|
||||
}
|
||||
|
||||
// Filter by published state
|
||||
$published = (string) $this->getState('filter.published');
|
||||
|
@ -30,6 +30,10 @@ class HtmlView extends BaseHtmlView
|
||||
|
||||
$this->items = $this->get('Items');
|
||||
|
||||
// adding filters
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
|
||||
// set the toolbar
|
||||
$this->addToolbar();
|
||||
|
||||
|
@ -30,6 +30,10 @@ class HtmlView extends BaseHtmlView
|
||||
|
||||
$this->items = $this->get('Items');
|
||||
|
||||
// adding filters
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
|
||||
// set the toolbar
|
||||
$this->addToolbar();
|
||||
|
||||
|
@ -11,11 +11,14 @@
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
?>
|
||||
<form action="<?= Route::_('index.php?option=com_depot&view=manufacturers'); ?>" method="post" name="adminForm"
|
||||
id="adminForm">
|
||||
|
||||
<?= LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
|
||||
<?php if (empty($this->items)): ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true">
|
||||
@ -39,7 +42,6 @@ use Joomla\CMS\Router\Route;
|
||||
<th>
|
||||
<?= Text::_('COM_DEPOT_TABLE_HEAD_MANUFACTURER') ?>
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -11,10 +11,13 @@
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
?>
|
||||
<form action="<?= Route::_('index.php?option=com_depot&view=stocks'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
|
||||
<?= LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
|
||||
<?php if (empty($this->items)): ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true">
|
||||
|
@ -7,7 +7,7 @@
|
||||
<license>GPL v2 +; see LICENSE.md</license>
|
||||
<authorEmail>thomas@kuschel.at</authorEmail>
|
||||
<authorUrl>https://kuschel.at</authorUrl>
|
||||
<version>0.9.4</version>
|
||||
<version>0.9.5</version>
|
||||
<description>COM_DEPOT_XML_DESCRIPTION</description>
|
||||
<namespace path="src/">KW4NZ\Component\Depot</namespace>
|
||||
<install> <!-- Runs on install -->
|
||||
|
Loading…
Reference in New Issue
Block a user