Version 0.9.13

This commit is contained in:
Thomas Kuschel 2023-11-18 21:05:43 +01:00
parent f656fb70fa
commit bedb36c136
24 changed files with 383 additions and 136 deletions

View File

@ -574,7 +574,9 @@ incrementing it.
/* if it is 0 -> get the max + 1 value */
if (!$data['ordering']) {
$db = Factory::getDbo();
$query = $db->getQuery(true)
// $query = $db->getQuery(true) // is deprecated,
// using createQuery() instead:
$query = $db->createQuery()
->select('MAX(ordering)')
->from('#__depot');

View File

@ -35,6 +35,8 @@
<option value="p.state DESC">JSTATUS_DESC</option>
<option value="p.name ASC">JGLOBAL_NAME_ASC</option>
<option value="p.name DESC">JGLOBAL_NAME_DESC</option>
<option value="p.description ASC">COM_DEPOT_SORT_BY_DESCRIPTION_ASC</option>
<option value="p.description DESC">COM_DEPOT_SORT_BY_DESCRIPTION_DESC</option>
<option value="p.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="p.id DESC">JGRID_HEADING_ID_DESC</option>
</field>

View File

@ -35,6 +35,8 @@
<option value="d.state DESC">JSTATUS_DESC</option>
<option value="d.component_name ASC">JGLOBAL_NAME_ASC</option>
<option value="d.component_name DESC">JGLOBAL_NAME_DESC</option>
<option value="d.description ASC">COM_DEPOT_SORT_BY_DESCRIPTION_ASC</option>
<option value="d.description DESC">COM_DEPOT_SORT_BY_DESCRIPTION_DESC</option>
<option value="d.quantity ASC">COM_DEPOT_SORT_BY_QUANTITY_ASC</option>
<option value="d.quantity DESC">COM_DEPOT_SORT_BY_QUANTITY_DESC</option>
<option value="manufacturer ASC">COM_DEPOT_SORT_BY_MANUFACTURER_ASC</option>

View File

@ -25,10 +25,12 @@
label="JGLOBAL_SORT_BY"
statuses="*,0,1,2,-2"
class="js-select-submit-on-change"
default="s.name ASC"
default=""
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="s.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="s.ordering DESC">JGRID_HEADING_ORDERING_DESC</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>

View File

@ -36,6 +36,12 @@
hint="COM_DEPOT_FIELD_ALIAS_PART_PLACEHOLDER"
size="40"
/>
<field
name="description"
type="text"
label="COM_DEPOT_FIELD_DESCRIPTION_LABEL"
description="COM_DEPOT_FIELD_DESCRIPTION_DESC"
/>
<field
name="package_id"
type="sql"

View File

@ -95,5 +95,13 @@
class="readonly"
readonly="true"
/>
<field
name="ordering"
type="text"
label="JFIELD_ORDERING_LABEL"
class="readonly"
default="0"
readonly="true"
/>
</fieldset>
</form>

View File

@ -11,6 +11,8 @@ COM_DEPOT_FIELD_ALIAS_PART_PLACEHOLDER="Auto-generate from component name"
COM_DEPOT_FIELD_ALIAS_STOCK_PLACEHOLDER="Auto-generate from stock name"
COM_DEPOT_FIELD_COMPONENT_NAME_DESC="The name of the component is unique. Please do not enter special characters or umlauts."
COM_DEPOT_FIELD_COMPONENT_NAME_LABEL="Component Name"
COM_DEPOT_FIELD_DESCRIPTION_DESC="Enter here the description of the component"
COM_DEPOT_FIELD_DESCRIPTION_LABEL="Description"
COM_DEPOT_FIELD_MANUFACTURER_ACRONYM_DESC="Enter here the acronym of the manufacturer or short name"
COM_DEPOT_FIELD_MANUFACTURER_ACRONYM_LABEL="Manufacturer Acronym"
COM_DEPOT_FIELD_MANUFACTURER_LONG_NAME_DESC="Enter here the long name of the manufacturer"

View File

@ -8,6 +8,7 @@
DROP TABLE IF EXISTS `#__depot`;
CREATE TABLE `#__depot` (
`id` SERIAL,
`ordering` INT(11) NOT NULL DEFAULT 0,
`component_name` VARCHAR(1024) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
COMMENT 'unique component name (ASCII characters only)',
`alias` VARCHAR(1024) NOT NULL DEFAULT '',
@ -28,7 +29,6 @@ CREATE TABLE `#__depot` (
`access` TINYINT(4) NOT NULL DEFAULT 0,
`params` VARCHAR(1024) NOT NULL DEFAULT '',
`image` VARCHAR(1024) NOT NULL DEFAULT '',
`ordering` INT(11) NOT NULL DEFAULT 0,
`version` int unsigned NOT NULL DEFAULT 1,
-- references to other tables:
`category_id` INT(11) NOT NULL DEFAULT 0,
@ -49,11 +49,13 @@ CREATE TABLE `#__depot` (
INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`,
`ordering`,`state`,`manufacturer_id`,`stock_id`,`package_id`) VALUES
('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1,1,9),
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2,1,8);
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2,1,8)
('R_120R','r_120r','resistor, metalic',46,'2023-11-15 23:40:00',3,1,1,2,11);
DROP TABLE IF EXISTS `#__depot_manufacturer`;
CREATE TABLE `#__depot_manufacturer` (
`id` SERIAL,
`ordering` INT(11) NOT NULL DEFAULT 0,
`name_short` CHAR(25) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
COMMENT 'unique manufacturer name or abbriviation',
`alias` VARCHAR(127) NOT NULL DEFAULT '',
@ -85,6 +87,7 @@ INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`,
DROP TABLE IF EXISTS `#__depot_stock`;
CREATE TABLE `#__depot_stock` (
`id` SERIAL,
`ordering` INT(11) NOT NULL DEFAULT 0,
`name` VARCHAR(1024) NOT NULL DEFAULT '',
`alias` VARCHAR(1024) NOT NULL DEFAULT '',
`owner_id` INT(10) UNSIGNED NOT NULL DEFAULT 0,
@ -123,6 +126,7 @@ INSERT INTO `#__depot_stock`(`name`, `location`, `description`, `state`, `access
DROP TABLE IF EXISTS `#__depot_package`;
CREATE TABLE `#__depot_package` (
`id` SERIAL,
`ordering` INT(11) NOT NULL DEFAULT 0,
`name` VARCHAR(400) NOT NULL DEFAULT '',
`description` VARCHAR(4000) NOT NULL DEFAULT '',
`alias` VARCHAR(400) NOT NULL DEFAULT '',
@ -137,7 +141,6 @@ CREATE TABLE `#__depot_package` (
`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`ordering` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE = InnoDB
AUTO_INCREMENT=0
@ -163,8 +166,8 @@ INSERT INTO `#__depot_package` (`name`,`description`,`state`,`mounting_style_id`
DROP TABLE IF EXISTS `#__depot_mounting_style`;
CREATE TABLE `#__depot_mounting_style` (
`id` SERIAL,
`title` VARCHAR(100) NOT NULL DEFAULT '',
`ordering` INT(11) NOT NULL DEFAULT 0,
`title` VARCHAR(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE = InnoDB
AUTO_INCREMENT=0

View File

@ -41,6 +41,37 @@ class PackageModel extends AdminModel
return $data;
}
protected function prepareTable($table)
{
$date = Factory::getDate();
$user = $this->getCurrentUser();
if (empty($table->id)) {
// Set the values
$table->created = $date->toSql();
$table->created_by = $user->id;
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = $this->getDatabase();
$query = $db->createQuery()
->select('MAX(' . $db->quoteName('ordering') . ')')
->from($db->quoteName('#__depot_package'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = ++$max;
}
} else {
// Set the values
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
}
public function save($data)
{
/* Add code to modify data before saving */

View File

@ -10,7 +10,6 @@
namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Table\Table;
use Joomla\Database\ParameterType;
@ -124,8 +123,9 @@ class PackagesModel extends ListModel
return $query;
}
/**
* Returns a reference to the a Table object, always creating it.
* Returns a reference to the Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
@ -139,5 +139,4 @@ class PackagesModel extends ListModel
{
return parent::getTable($type, $prefix, $config);
}
}

View File

@ -11,10 +11,11 @@
namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\MVC\Model\ListModel;
// use Joomla\CMS\Table\Table;
use Joomla\Database\ParameterType;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
class PartsModel extends ListModel
{
@ -31,6 +32,10 @@ class PartsModel extends ListModel
'd.alias',
'quantity',
'd.quantity',
'ordering',
'd.ordering',
'description',
'd.description',
'published',
'd.published',
'package',
@ -75,6 +80,8 @@ class PartsModel extends ListModel
$db->quoteName('d.quantity_exp'),
$db->quoteName('d.ordering'),
$db->quoteName('d.package_id'),
$db->quoteName('d.checked_out'),
$db->quoteName('d.checked_out_time'),
]
)
)
@ -103,6 +110,7 @@ class PartsModel extends ListModel
$like = $db->quote('%' . $search . '%');
$query->where($db->quoteName('d.component_name') . ' LIKE ' . $like);
}
// Filter by published state
$published = (string) $this->getState('filter.published');
if (is_numeric($published)) {
@ -114,9 +122,10 @@ class PartsModel extends ListModel
}
// add list ordering clause
$orderCol = $this->state->get('list.ordering', 'id');
$orderDirn = $this->state->get('list.direction', 'desc');
$query->order($db->escape($orderCol) . ' ' . $db->escape($orderDirn));
$query->order(
$db->quoteName($db->escape($this->getState('list.ordering', 'd.ordering'))) . ' ' .
$db->escape($this->getState('list.direction', 'ASC'))
);
return $query;
}

View File

@ -11,10 +11,12 @@
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;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
class StocksModel extends ListModel
{
@ -23,18 +25,25 @@ class StocksModel extends ListModel
$config['filter_fields'] = [
'id',
's.id',
's.name',
'name',
's.name',
'alias',
's.alias',
's.description',
'description',
'state',
's.state',
'published',
'd.published',
's.published',
'description',
's.description',
'ordering',
's.ordering',
'checked_out',
's.checked_out',
'owner',
];
parent::__construct($config);
}
/**
* Build an SQL query to load the list data.
*
@ -66,6 +75,10 @@ class StocksModel extends ListModel
$db->quoteName('s.name'),
$db->quoteName('s.alias'),
$db->quoteName('s.description'),
$db->quoteName('s.state'),
$db->quoteName('s.ordering'),
$db->quoteName('s.checked_out'),
$db->quoteName('s.checked_out_time'),
]
)
)
@ -99,9 +112,27 @@ class StocksModel extends ListModel
// Add the list ordering clause.
$query->order(
$db->quoteName($db->escape($this->getState('list.ordering', 'id'))) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))
$db->quoteName($db->escape($this->getState('list.ordering', 's.ordering'))) . ' ' .
$db->escape($this->getState('list.direction', 'ASC'))
);
return $query;
}
/**
* Returns a reference to the Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return Table A Table object
*
* @since 1.6
*/
public function getTable($type = 'Stock', $prefix = 'Administrator', $config = [])
{
return parent::getTable($type, $prefix, $config);
}
}

View File

@ -32,6 +32,7 @@ class PackageTable extends Table
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
@ -50,7 +51,7 @@ class PackageTable extends Table
}
// Set modified to created if not set
if ($this->modified) {
if (!$this->modified) {
$this->modified = $this->created;
}
// Set modified_by to created_by if not set

View File

@ -26,6 +26,42 @@ class PartTable extends Table
$this->setColumnAlias('published', 'state');
}
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Set created date if not set.
if (!(int) $this->created) {
$this->created = Factory::getDate()->toSql();
}
// Set ordering
if ($this->state < 0) {
// Set ordering to 0 if state is archived or trashed
$this->ordering = 0;
} elseif (empty($this->ordering)) {
// Set ordering to last if ordering was 0
$this->ordering = self::getNextOrder($this->_db->quoteName('state') . ' >= 0');
}
// Set modified to created if not set
if (!$this->modified) {
$this->modified = $this->created;
}
// Set modified_by to created_by if not set
if (empty($this->modified_by)) {
$this->modified_by = $this->created_by;
}
return true;
}
public function store($updateNulls = true)
{
$app = Factory::getApplication();

View File

@ -26,6 +26,40 @@ class StockTable extends Table
$this->setColumnAlias('published', 'state');
}
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Set created date if not set.
if (!(int) $this->created) {
$this->created = Factory::getDate()->toSql();
}
// Set ordering
if ($this->state < 0) {
// Set ordering to 0 if state is archived or trashed
$this->ordering = 0;
} elseif (empty($this->ordering)) {
// Set ordering to last if ordering was 0
$this->ordering = self::getNextOrder($this->_db->quoteName('state') . ' >= 0');
}
// Set modified to created if not set
if (!$this->modified) {
$this->modified = $this->created;
}
// Set modified_by to created_by if not set
if (empty($this->modified_by)) {
$this->modified_by = $this->created_by;
}
}
public function store($updateNulls = true)
{
$app = Factory::getApplication();

View File

@ -10,10 +10,8 @@
namespace KW4NZ\Component\Depot\Administrator\View\Packages;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
// use Joomla\CMS\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
@ -37,7 +35,7 @@ class HtmlView extends BaseHtmlView
$this->setLayout('emptystate');
}
// set the toolbar
// Set the toolbar
$this->addToolbar();
parent::display($tpl);

View File

@ -10,15 +10,13 @@
namespace KW4NZ\Component\Depot\Administrator\View\Parts;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
// use Joomla\CMS\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// use Joomla\CMS\Language\Text;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
class HtmlView extends BaseHtmlView
@ -33,7 +31,11 @@ class HtmlView extends BaseHtmlView
$this->filterForm = $model->getFilterForm();
$this->activeFilters = $model->getActiveFilters();
// set the toolbar
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
$this->setLayout('emptystate');
}
// Set the toolbar
$this->addToolbar();
parent::display($tpl);

View File

@ -10,36 +10,33 @@
namespace KW4NZ\Component\Depot\Administrator\View\Stocks;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
// use Joomla\CMS\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// use Joomla\CMS\Language\Text;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
class HtmlView extends BaseHtmlView
{
public function display($tpl = null)
{
// Get application
$app = Factory::getApplication();
/**@var StocksModel $model */
$model = $this->getModel();
$this->items = $this->get('Items');
$this->state = $this->get('State');
// list order
$this->listOrder = $this->escape($this->state->get('list.ordering'));
$this->listDirn = $this->escape($this->state->get('list.direction'));
// add pagination
$this->pagination = $this->get('Pagination');
// adding filters
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->items = $model->getItems();
$this->pagination = $model->getPagination();
$this->state = $model->getState();
$this->filterForm = $model->getFilterForm();
$this->activeFilters = $model->getActiveFilters();
// set the toolbar
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
$this->setLayout('emptystate');
}
// Set the toolbar
$this->addToolbar();
parent::display($tpl);

View File

@ -84,7 +84,7 @@ use Joomla\CMS\Layout\LayoutHelper;
<?php endforeach; ?>
</tbody>
</table>
<?php echo $this->pagination->getListFooter(); ?>
<?= $this->pagination->getListFooter(); ?>
<?php endif; ?>
<input type="hidden" name="task" value="">

View File

@ -10,9 +10,8 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Router\Route;
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
@ -44,12 +43,12 @@ if ($saveOrder && !empty($this->items)) {
<?php else: ?>
<table class="table table-striped table-hover" id="packageList">
<caption class="visually-hidden">
<?php echo Text::_('COM_DEPOT_PACKAGES_TABLE_CAPTION'); ?>,
<?= Text::_('COM_DEPOT_PACKAGES_TABLE_CAPTION'); ?>,
<span id="orderedBy">
<?php echo Text::_('JGLOBAL_SORTED_BY'); ?>
<?= Text::_('JGLOBAL_SORTED_BY'); ?>
</span>,
<span id="filteredBy">
<?php echo Text::_('JGLOBAL_FILTERED_BY'); ?>
<?= Text::_('JGLOBAL_FILTERED_BY'); ?>
</span>
</caption>
<thead>
@ -58,10 +57,10 @@ if ($saveOrder && !empty($this->items)) {
<?= HTMLHelper::_('grid.checkall'); ?>
</td>
<th scope="col" class="w-1 text-center">
<?php echo HTMLHelper::_('searchtools.sort', '', 'p.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
<?= HTMLHelper::_('searchtools.sort', '', 'p.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
</th>
<th scope="col" class="w-1 text-center">
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'p.state', $listDirn, $listOrder); ?>
<?= HTMLHelper::_('searchtools.sort', 'JSTATUS', 'p.state', $listDirn, $listOrder); ?>
</th>
<th>
<?= HTMLHelper::_(
@ -109,7 +108,7 @@ if ($saveOrder && !empty($this->items)) {
$ordering = ($listOrder == 'ordering');
$canChange = true;
?>
<tr class="row<?= $i % 2; ?>" data-draggable-group="0" item-id="<?php echo $item->id; ?>">
<tr class="row<?= $i % 2; ?>" data-draggable-group="0" item-id="<?= $item->id; ?>">
<th>
<?= HTMLHelper::_('grid.id', $i, $item->id); ?>
</th>
@ -123,11 +122,11 @@ if ($saveOrder && !empty($this->items)) {
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
}
?>
<span class="sortable-handler <?php echo $iconClass ?>">
<span class="sortable-handler <?= $iconClass ?>">
<span class="icon-ellipsis-v" aria-hidden="true"></span>
</span>
<?php if ($saveOrder): ?>
<input type="text" name="order[]" size="5" value="<?php echo $item->ordering; ?>"
<input type="text" name="order[]" size="5" value="<?= $item->ordering; ?>"
class="width-20 text-area-order hidden">
<?php endif; ?>
<div class="small">
@ -135,7 +134,7 @@ if ($saveOrder && !empty($this->items)) {
</div>
</td>
<td class="text-center">
<?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'packages.', $canChange); ?>
<?= HTMLHelper::_('jgrid.published', $item->state, $i, 'packages.', $canChange); ?>
</td>
<th>
<a href="<?= Route::_('index.php?option=com_depot&task=package.edit&id=' .
@ -156,7 +155,7 @@ if ($saveOrder && !empty($this->items)) {
<?php endforeach; ?>
</tbody>
</table>
<?php echo $this->pagination->getListFooter(); ?>
<?= $this->pagination->getListFooter(); ?>
<?php endif; ?>
<input type="hidden" name="task" value="">

View File

@ -32,12 +32,9 @@ $wa->useScript('form.validate')
<?= Text::_('COM_DEPOT_LEGEND_PART_DETAILS') ?>
</legend>
<div class="row">
<div class="col-12 col-lg-6">
<div class="col-12 col-lg-9">
<?= $this->form->renderFieldset('details'); ?>
</div>
<div class="col-12 col-lg-6">
<?= $this->form->getInput('description'); ?>
</div>
</div>
</fieldset>
<?= HtmlHelper::_('uitab.endTab'); ?>

View File

@ -39,14 +39,14 @@ if ($saveOrder && !empty($this->items)) {
<?= Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else: ?>
<table class="table table-striped table-hover" id="partsList">
<table class="table table-striped table-hover" id="partList">
<caption class="visually-hidden">
<?php echo Text::_('COM_BANNERS_CLIENTS_TABLE_CAPTION'); ?>,
<?= Text::_('COM_DEPOT_PARTS_TABLE_CAPTION'); ?>,
<span id="orderedBy">
<?php echo Text::_('JGLOBAL_SORTED_BY'); ?>
<?= Text::_('JGLOBAL_SORTED_BY'); ?>
</span>,
<span id="filteredBy">
<?php echo Text::_('JGLOBAL_FILTERED_BY'); ?>
<?= Text::_('JGLOBAL_FILTERED_BY'); ?>
</span>
</caption>
<thead>
@ -55,7 +55,10 @@ if ($saveOrder && !empty($this->items)) {
<?= HTMLHelper::_('grid.checkall'); ?>
</td>
<th scope="col" class="w-1 text-center">
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'd.state', $listDirn, $listOrder); ?>
<?= HTMLHelper::_('searchtools.sort', '', 'd.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
</th>
<th scope="col" class="w-1 text-center">
<?= HTMLHelper::_('searchtools.sort', 'JSTATUS', 'd.state', $listDirn, $listOrder); ?>
</th>
<th scope="col">
<?= HTMLHelper::_(
@ -78,6 +81,15 @@ if ($saveOrder && !empty($this->items)) {
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_QUANTITY_EXP') ?>
</th>
<th>
<?= HTMLHelper::_(
'searchtools.sort',
'COM_DEPOT_TABLE_HEAD_DESCRIPTION',
'd.description',
$listDirn,
$listOrder
); ?>
</th>
<th>
<?= HTMLHelper::_(
'searchtools.sort',
@ -107,14 +119,39 @@ if ($saveOrder && !empty($this->items)) {
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items as $i => $item): ?>
<tr>
<td class="text-center">
<tbody <?php if ($saveOrder): ?> class="js-draggable" data-url="<?= $saveOrderingUrl; ?>"
data-direction="<?= strtolower($listDirn); ?>" data-nested="true" <?php endif; ?>>
<?php foreach ($this->items as $i => $item):
$ordering = ($listOrder == 'ordering');
$canChange = true;
?>
<tr class="row<?= $i % 2; ?>" data-draggable-group="0" item-id="<?= $item->id; ?>">
<th>
<?= HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->component_name); ?>
</th>
<td class="text-center d-none d-md-table-cell">
<?php
$iconClass = '';
if (!$canChange) {
$iconClass = ' inactive';
} elseif (!$saveOrder) {
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
}
?>
<span class="sortable-handler <?= $iconClass ?>">
<span class="icon-ellipsis-v" aria-hidden="true"></span>
</span>
<?php if ($saveOrder): ?>
<input type="text" name="order[]" size="5" value="<?= $item->ordering; ?>"
class="width-20 text-area-order hidden">
<?php endif; ?>
<div class="small">
<?= $item->ordering; ?>
</div>
</td>
<td class="text-center">
<?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'parts.', $canChange); ?>
<?= HTMLHelper::_('jgrid.published', $item->state, $i, 'parts.', $canChange); ?>
</td>
<th>
<div class="break-word">
@ -142,6 +179,11 @@ if ($saveOrder && !empty($this->items)) {
<td>
<?= "10^" . $item->quantity_exp; ?>
</td>
<td>
<div class="break-word">
<?= $this->escape($item->description); ?>
</div>
</td>
<td>
<a href="<?= Route::_('index.php?option=com_depot&task=manufacturer.edit&id=' .
(int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>">
@ -164,7 +206,7 @@ if ($saveOrder && !empty($this->items)) {
<?php endforeach; ?>
</tbody>
</table>
<?php echo $this->pagination->getListFooter(); ?>
<?= $this->pagination->getListFooter(); ?>
<?php endif; ?>
<input type="hidden" name="task" value="">

View File

@ -13,6 +13,20 @@ use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Layout\LayoutHelper;
$wa = $this->document->getWebAssetManager();
$wa->useScript('table.columns')
->useScript('multiselect');
$user = $this->getCurrentUser();
$userID = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 's.ordering';
if ($saveOrder && !empty($this->items)) {
$saveOrderingUrl = 'index.php?option=com_depot&task=stocks.saveOrderAjax&tmpl=component';
HTMLHelper::_('draggablelist.draggable');
}
?>
<form action="<?= Route::_('index.php?option=com_depot&view=stocks'); ?>" method="post" name="adminForm" id="adminForm">
@ -26,59 +40,86 @@ use Joomla\CMS\Layout\LayoutHelper;
</div>
<?php else: ?>
<table class="table table-striped table-hover">
<table class="table table-striped table-hover" id="stockList">
<thead>
<tr>
<th>
<td>
<?= HTMLHelper::_('grid.checkall'); ?>
</th>
<th>
<?= HTMLHelper::_(
'searchtools.sort',
'JGRID_HEADING_ID',
's.id',
$this->listDirn,
$this->listOrder
); ?>
</td>
<th scope="col" class="w-1 text-center">
<?= HTMLHelper::_('searchtools.sort', '', 's.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
</th>
<th>
<?= HTMLHelper::_(
'searchtools.sort',
'COM_DEPOT_TABLE_HEAD_STOCK',
's.name',
$this->listDirn,
$this->listOrder
$listDirn,
$listOrder
); ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_DESCRIPTION') ?>
<?= HTMLHelper::_(
'searchtools.sort',
'COM_DEPOT_TABLE_HEAD_DESCRIPTION',
's.description',
$listDirn,
$listOrder
); ?>
</th>
<th>
<?= HTMLHelper::_(
'searchtools.sort',
'COM_DEPOT_TABLE_HEAD_OWNER',
'owner',
$this->listDirn,
$this->listOrder
$listDirn,
$listOrder
); ?>
</th>
<th>
<?= HTMLHelper::_(
'searchtools.sort',
'JGRID_HEADING_ID',
's.id',
$listDirn,
$listOrder
); ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items as $i => $item): ?>
<tr>
<td>
<tbody <?php if ($saveOrder): ?> class="js-draggable" data-url="<?= $saveOrderingUrl; ?>"
data-direction="<?= strtolower($listDirn); ?>" data-nested="true" <?php endif; ?> <?php foreach ($this->items as $i => $item):
$ordering = ($listOrder == 'ordering');
$canChange = true;
?> <tr
class="row<?= $i % 2; ?>" data-draggable-group="0" item-id="<?= $item->id; ?>">
<th>
<?= HTMLHelper::_('grid.id', $i, $item->id); ?>
</th>
<td class="text-center d-none d-md-table-cell">
<?php
$iconClass = '';
if (!$canChange) {
$iconClass = ' inactive';
} elseif (!$saveOrder) {
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
}
?>
<span class="sortable-handler <?= $iconClass ?>">
<span class="icon-ellipsis-v" aria-hidden="true"></span>
</span>
<?php if ($saveOrder): ?>
<input type="text" name="order[]" size="5" value="<?= $item->ordering; ?>"
class="width-20 text-area-order hidden">
<?php endif; ?>
</td>
<td>
<?= $item->id ?>
</td>
<td>
<th>
<a href="<?= Route::_('index.php?option=com_depot&task=stock.edit&id=' .
(int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>">
<?= $this->escape($item->name); ?>
</a>
</td>
</th>
<td>
<?= $this->escape($item->description); ?>
</td>
@ -94,11 +135,14 @@ use Joomla\CMS\Layout\LayoutHelper;
<?php endif; ?>
</div>
</td>
<td>
<?= $item->id ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php echo $this->pagination->getListFooter(); ?>
<?= $this->pagination->getListFooter(); ?>
<?php endif; ?>
<input type="hidden" name="task" value="">

View File

@ -2,12 +2,12 @@
<extension type="component" method="upgrade">
<name>Depot</name>
<author>KW4NZ</author>
<creationDate>2023-11-02</creationDate>
<creationDate>2023-11-18</creationDate>
<copyright>(C) KW4NZ Thomas Kuschel</copyright>
<license>GPL v2 +; see LICENSE.md</license>
<authorEmail>thomas@kuschel.at</authorEmail>
<authorUrl>https://kuschel.at</authorUrl>
<version>0.9.12</version>
<version>0.9.13</version>
<description>COM_DEPOT_XML_DESCRIPTION</description>
<namespace path="src/">KW4NZ\Component\Depot</namespace>
<install> <!-- Runs on install -->