Adding views of stacks, manufacturers lists

This commit is contained in:
Thomas Kuschel 2023-10-23 21:55:15 +02:00
parent 577a9f680a
commit e4a1d2c078
25 changed files with 1234 additions and 23 deletions

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset
name="details"
label="COM_DEPOT_DETAILS"
addruleprefix="KW4NZ\Component\Depot\Administrator\Rule"
addfieldprefix="KW4NZ\Component\Depot\Administrator\Field"
>
<field
name="name_short"
type="text"
label="COM_DEPOT_FIELD_COMPONENT_NAME_LABEL"
description="COM_DEPOT_FIELD_COMPONENT_NAME_DESC"
required="true"
autofocus="1"
/>
<field
name="name_long"
type="text"
label="COM_DEPOT_FIELD_COMPONENT_NAME_LABEL"
description="COM_DEPOT_FIELD_COMPONENT_NAME_DESC"
required="true"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="COM_DEPOT_FIELD_ALIAS_PLACEHOLDER"
size="40"
/>
<field
name="state"
type="list"
label="JSTATUS"
class="form-select-color-state"
default="1"
validate="options"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
</fieldset>
<fieldset
name="statistics"
label="COM_DEPOT_FIELD_STATISTICS"
>
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
class="readonly"
default="0"
readonly="true"
/>
<field
name="created"
type="calendar"
label="COM_DEPOT_FIELD_CREATED_LABEL"
class="readonly"
translateformat="true"
showtime="true"
readonly="true"
filter="user_utc"
/>
<field
name="created_by"
type="user"
label="COM_DEPOT_FIELD_CREATED_BY_LABEL"
class="readonly"
readonly="true"
/>
<field
name="modified"
type="calendar"
label="COM_DEPOT_FIELD_MODIFIED_LABEL"
class="readonly"
translateformat="true"
showtime="true"
readonly="true"
filter="user_utc"
/>
<field
name="modified_by"
type="user"
label="COM_DEPOT_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
/>
</fieldset>
</form>

93
admin/forms/stock.xml Normal file
View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset
name="details"
label="COM_DEPOT_DETAILS"
addruleprefix="KW4NZ\Component\Depot\Administrator\Rule"
addfieldprefix="KW4NZ\Component\Depot\Administrator\Field"
>
<field
name="name"
type="text"
label="COM_DEPOT_FIELD_COMPONENT_NAME_LABEL"
description="COM_DEPOT_FIELD_COMPONENT_NAME_DESC"
required="true"
autofocus="1"
/>
<field
name="description"
type="text"
label="COM_DEPOT_FIELD_COMPONENT_NAME_LABEL"
description="COM_DEPOT_FIELD_COMPONENT_NAME_DESC"
required="true"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="COM_DEPOT_FIELD_ALIAS_PLACEHOLDER"
size="40"
/>
<field
name="state"
type="list"
label="JSTATUS"
class="form-select-color-state"
default="1"
validate="options"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
</fieldset>
<fieldset
name="statistics"
label="COM_DEPOT_FIELD_STATISTICS"
>
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
class="readonly"
default="0"
readonly="true"
/>
<field
name="created"
type="calendar"
label="COM_DEPOT_FIELD_CREATED_LABEL"
class="readonly"
translateformat="true"
showtime="true"
readonly="true"
filter="user_utc"
/>
<field
name="created_by"
type="user"
label="COM_DEPOT_FIELD_CREATED_BY_LABEL"
class="readonly"
readonly="true"
/>
<field
name="modified"
type="calendar"
label="COM_DEPOT_FIELD_MODIFIED_LABEL"
class="readonly"
translateformat="true"
showtime="true"
readonly="true"
filter="user_utc"
/>
<field
name="modified_by"
type="user"
label="COM_DEPOT_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
/>
</fieldset>
</form>

View File

@ -18,8 +18,13 @@ COM_DEPOT_FIELD_QUANTITY_EXP_LABEL="Quantity Exponent"
COM_DEPOT_FIELD_QUANTITY_EXP_DESC="Exponent (10^x of the number, usually 0, i.e. 10⁰)" COM_DEPOT_FIELD_QUANTITY_EXP_DESC="Exponent (10^x of the number, usually 0, i.e. 10⁰)"
COM_DEPOT_FIELD_SELECT_MANUFACTURER="Manufacturer" COM_DEPOT_FIELD_SELECT_MANUFACTURER="Manufacturer"
COM_DEPOT_FIELD_SELECT_STOCK="Stock Location" COM_DEPOT_FIELD_SELECT_STOCK="Stock Location"
COM_DEPOT_LEGEND_DETAILS="Component Details" COM_DEPOT_LEGEND_MANUFACTURER_DETAILS="Manufacturer Details"
COM_DEPOT_LEGEND_STATISTICS="Component Statistics" COM_DEPOT_LEGEND_PART_DETAILS="Component Details"
COM_DEPOT_LEGEND_STOCK_DETAILS="Stock Location Details"
COM_DEPOT_LEGEND_STATISTICS="Statistics"
COM_DEPOT_MANAGER_MANUFACTURERS="Manager Manufacturers"
COM_DEPOT_MANAGER_PARTS="Manager Components"
COM_DEPOT_MANAGER_STOCKS="Manager Stock Locations"
COM_DEPOT_N_ITEMS_DELETED_1="One component deleted" COM_DEPOT_N_ITEMS_DELETED_1="One component deleted"
COM_DEPOT_N_ITEMS_DELETED_MORE="%d components deleted" COM_DEPOT_N_ITEMS_DELETED_MORE="%d components deleted"
COM_DEPOT_N_ITEMS_PUBLISHED_1="One component published" COM_DEPOT_N_ITEMS_PUBLISHED_1="One component published"
@ -28,8 +33,16 @@ COM_DEPOT_N_ITEMS_UNPUBLISHED_1="One component unpublished"
COM_DEPOT_N_ITEMS_UNPUBLISHED_MORE="%d components unpublished" COM_DEPOT_N_ITEMS_UNPUBLISHED_MORE="%d components unpublished"
COM_DEPOT_SELECT_YOUR_OPTION="Select your option" COM_DEPOT_SELECT_YOUR_OPTION="Select your option"
COM_DEPOT_TAB_NEW_PART="New Component" COM_DEPOT_TAB_NEW_PART="New Component"
COM_DEPOT_TAB_NEW_MANUFACTURER="New Manufacturer"
COM_DEPOT_TAB_EDIT_PART="Component Details" COM_DEPOT_TAB_EDIT_PART="Component Details"
COM_DEPOT_TAB_STATISTICS="Component Statistics" COM_DEPOT_TAB_EDIT_MANUFACTURER="Manufacturer Details"
COM_DEPOT_TAB_STATISTICS="Statistics"
COM_DEPOT_TABLE_HEAD_ID="ID" COM_DEPOT_TABLE_HEAD_ID="ID"
COM_DEPOT_TABLE_HEAD_NAME="Component Name" COM_DEPOT_TABLE_HEAD_NAME="Component Name"
COM_DEPOT_TABLE_HEAD_MANUFACTURER="Manufacturer"
COM_DEPOT_TABLE_HEAD_MANUFACTURER_ACRONYM="Acronym"
COM_DEPOT_TABLE_HEAD_STOCK="Stock Location"
COM_DEPOT_TABLE_HEAD_QUANTITY="Quantity"
COM_DEPOT_TABLE_HEAD_QUANTITY_EXP="Exponent"
COM_DEPOT_TABLE_HEAD_DESCRIPTION="Description"
COM_DEPOT_XML_DESCRIPTION="Depot, the component warehouse" COM_DEPOT_XML_DESCRIPTION="Depot, the component warehouse"

View File

@ -46,15 +46,16 @@ CREATE TABLE `#__depot` (
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`, INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`,
`ordering`,`state`,`manufacturer_id`) VALUES `ordering`,`state`,`manufacturer_id`,`stock_id`) VALUES
('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1), ('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1,1),
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2); ('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2,1);
DROP TABLE IF EXISTS `#__depot_manufacturer`; DROP TABLE IF EXISTS `#__depot_manufacturer`;
CREATE TABLE `#__depot_manufacturer` ( CREATE TABLE `#__depot_manufacturer` (
`id` SERIAL, `id` SERIAL,
`name_short` CHAR(25) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL `name_short` CHAR(25) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
COMMENT 'unique manufacturer name or abbriviation', COMMENT 'unique manufacturer name or abbriviation',
`alias` VARCHAR(127) NOT NULL DEFAULT '',
`name_long` VARCHAR(1024) NOT NULL DEFAULT '', `name_long` VARCHAR(1024) NOT NULL DEFAULT '',
`url` VARCHAR(1024) NOT NULL DEFAULT '', `url` VARCHAR(1024) NOT NULL DEFAULT '',
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
@ -74,17 +75,17 @@ CREATE TABLE `#__depot_manufacturer` (
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`, INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`,
`description`, `image`) VALUES `description`, `image`, `state`) VALUES
('TSC','Taiwan Semiconductor','https://www.taiwansemi.com', ('TSC','Taiwan Semiconductor','https://www.taiwansemi.com',
'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified',''), 'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified','',1),
('ST','STMicroelectronics','https://www.st.com', ('ST','STMicroelectronics','https://www.st.com',
'Microprocessors, Audio ICs, OPamps, Diodes, Memories, MEMS, NFCs, Transistors, Wireless, Automotive electronics, etc.',''); 'Microprocessors, Audio ICs, OPamps, Diodes, Memories, MEMS, NFCs, Transistors, Wireless, Automotive electronics, etc.','',1);
DROP TABLE IF EXISTS `#__jron_stock`; DROP TABLE IF EXISTS `#__depot_stock`;
CREATE TABLE `#__jron_stock` ( CREATE TABLE `#__depot_stock` (
`id` SERIAL, `id` SERIAL,
`name` VARCHAR(1024) NOT NULL DEFAULT '', `name` VARCHAR(1024) NOT NULL DEFAULT '',
-- `alias` VARCHAR(1024) NOT NULL DEFAULT '', `alias` VARCHAR(1024) NOT NULL DEFAULT '',
`owner` INT(10) UNSIGNED NOT NULL DEFAULT 0, `owner` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0, `created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
@ -106,7 +107,7 @@ CREATE TABLE `#__jron_stock` (
AUTO_INCREMENT=0 AUTO_INCREMENT=0
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__jron_stock`(`name`, `location`, `description`, `state`, `access`) VALUES INSERT INTO `#__depot_stock`(`name`, `location`, `description`, `state`, `access`) VALUES
('Semiconductors workshop cabinet depot', 'Tom''s office, Martinstr. 58a, 3400 Klosterneuburg', ('Semiconductors workshop cabinet depot', 'Tom''s office, Martinstr. 58a, 3400 Klosterneuburg',
'MARS Svratka Workshop Depot 5x12 (60) compartments à 54 x 35 x 140 mm',1,0), 'MARS Svratka Workshop Depot 5x12 (60) compartments à 54 x 35 x 140 mm',1,0),
('Resistors workshop cabinet depot', 'Tom''s office, Martinstr. 58a, 3400 Klosterneuburg', ('Resistors workshop cabinet depot', 'Tom''s office, Martinstr. 58a, 3400 Klosterneuburg',

View File

@ -28,8 +28,8 @@ CREATE TABLE IF NOT EXISTS `#__depot_manufacturer` (
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`, INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`,
`description`, `image`) VALUES `description`, `image`, `state`) VALUES
('TSC','Taiwan Semiconductor','https://www.taiwansemi.com', ('TSC','Taiwan Semiconductor','https://www.taiwansemi.com',
'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified',''), 'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified','',1),
('ST','STMicroelectronics','https://www.st.com', ('ST','STMicroelectronics','https://www.st.com',
'Microprocessors, Audio ICs, OPamps, Diodes, Memories, MEMS, NFCs, Transistors, Wireless, Automotive electronics, etc.',''); 'Microprocessors, Audio ICs, OPamps, Diodes, Memories, MEMS, NFCs, Transistors, Wireless, Automotive electronics, etc.','',1);

View File

@ -8,7 +8,7 @@
CREATE TABLE IF NOT EXISTS `#__depot_stock` ( CREATE TABLE IF NOT EXISTS `#__depot_stock` (
`id` SERIAL, `id` SERIAL,
`name` VARCHAR(1024) NOT NULL DEFAULT '', `name` VARCHAR(1024) NOT NULL DEFAULT '',
-- `alias` VARCHAR(1024) NOT NULL DEFAULT '', `alias` VARCHAR(1024) NOT NULL DEFAULT '',
`owner` INT(10) UNSIGNED NOT NULL DEFAULT 0, `owner` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0, `created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,

View File

@ -0,0 +1,19 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.1
*/
namespace KW4NZ\Component\Depot\Administrator\Controller;
use Joomla\CMS\MVC\Controller\FormController;
defined('_JEXEC') or die;
class ManufacturerController extends FormController
{
}

View File

@ -0,0 +1,19 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.2
*/
namespace KW4NZ\Component\Depot\Administrator\Controller;
use Joomla\CMS\MVC\Controller\FormController;
defined('_JEXEC') or die;
class StockController extends FormController
{
}

View File

@ -0,0 +1,64 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.1
*/
namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\AdminModel;
\defined('_JEXEC') or die;
class ManufacturerModel extends AdminModel
{
public function getForm($data = [], $loadData = true)
{
$form = $this->loadForm('com_depot.manufacturer', 'manufacturer', ['control' => 'jform', 'load_data' => $loadData]);
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
$app = Factory::getApplication();
$data = $app->getUserState('com_depot.edit.manufacturer.data', []);
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
public function save($data)
{
/* Add code to modify data before saving */
// if (Factory::getConfig()->get('unicodeslugs') == 1) {
// $data['alias'] = OutputFilter::stringURLUnicodeSlug($data['component_name']);
// } else {
// $data['alias'] = OutputFilter::stringURLSafe($data['component_name']);
// }
/* replaced by: */
if (empty($data['alias'])) {
$data['alias'] = ApplicationHelper::stringURLSafe($data['name_short']);
}
$result = parent::save($data);
// if ($result) {
// $this->getTable('', 'Administrator')->rebuild(1);
// }
return $result;
}
}

View File

@ -0,0 +1,75 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.3
*/
namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Table\Table;
\defined('_JEXEC') or die;
class ManufacturersModel extends ListModel
{
/**
* Build an SQL query to load the list data.
*
* @return \Joomla\Database\DatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
$db = $this->getDatabase();
$query = $db->getQuery(true);
// $query->select('*')
// ->from($db->quoteName('#__depot', 'd'));
// order by
// $query->order('d.id ASC');
// if (true) {
// return $query;
// }
// select the required fields from the table
$query->select(
$this->getState(
'list.select',
[
$db->quoteName('m.id'),
$db->quoteName('m.name_short'),
$db->quoteName('m.name_long'),
$db->quoteName('m.alias'),
$db->quoteName('m.description'),
]
)
)
->select(
[
$db->quoteName('u.name', 'creator'),
]
)
->from($db->quoteName('#__depot_manufacturer', 'm'))
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('m.checked_out'));
// Filter by published state
$published = (string) $this->getState('filter.published');
if (is_numeric($published)) {
$published = (int) $published;
$query->where($db->quoteName('m.state') . ' = :published')
->bind(':published', $published, ParameterType::INTEGER);
} elseif ($published === '') {
$query->where($db->quoteName('m.state') . ' IN (0, 1)');
}
return $query;
}
}

View File

@ -0,0 +1,64 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.2
*/
namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\AdminModel;
\defined('_JEXEC') or die;
class StockModel extends AdminModel
{
public function getForm($data = [], $loadData = true)
{
$form = $this->loadForm('com_depot.stock', 'stock', ['control' => 'jform', 'load_data' => $loadData]);
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
$app = Factory::getApplication();
$data = $app->getUserState('com_depot.edit.stock.data', []);
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
public function save($data)
{
/* Add code to modify data before saving */
// if (Factory::getConfig()->get('unicodeslugs') == 1) {
// $data['alias'] = OutputFilter::stringURLUnicodeSlug($data['component_name']);
// } else {
// $data['alias'] = OutputFilter::stringURLSafe($data['component_name']);
// }
/* replaced by: */
if (empty($data['alias'])) {
$data['alias'] = ApplicationHelper::stringURLSafe($data['name_short']);
}
$result = parent::save($data);
// if ($result) {
// $this->getTable('', 'Administrator')->rebuild(1);
// }
return $result;
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.3
*/
namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Table\Table;
\defined('_JEXEC') or die;
class StocksModel extends ListModel
{
/**
* Build an SQL query to load the list data.
*
* @return \Joomla\Database\DatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
$db = $this->getDatabase();
$query = $db->getQuery(true);
// $query->select('*')
// ->from($db->quoteName('#__depot', 'd'));
// order by
// $query->order('d.id ASC');
// if (true) {
// return $query;
// }
// select the required fields from the table
$query->select(
$this->getState(
'list.select',
[
$db->quoteName('s.id'),
$db->quoteName('s.name'),
$db->quoteName('s.alias'),
$db->quoteName('s.description'),
]
)
)
->select(
[
$db->quoteName('u.name', 'creator'),
]
)
->from($db->quoteName('#__depot_stock', 's'))
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('s.checked_out'));
// Filter by published state
$published = (string) $this->getState('filter.published');
if (is_numeric($published)) {
$published = (int) $published;
$query->where($db->quoteName('s.state') . ' = :published')
->bind(':published', $published, ParameterType::INTEGER);
} elseif ($published === '') {
$query->where($db->quoteName('s.state') . ' IN (0, 1)');
}
return $query;
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.1
*/
namespace KW4NZ\Component\Depot\Administrator\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\Database\DatabaseDriver;
\defined('_JEXEC') or die;
class ManufacturerTable extends Table
{
function __construct(DatabaseDriver $db)
{
parent::__construct('#__depot_manufacturer', 'id', $db);
// add an alias for published:
$this->setColumnAlias('published', 'state');
}
public function store($updateNulls = true)
{
$app = Factory::getApplication();
$date = Factory::getDate()->toSql();
// $user = Factory::getUser();
// $user = $this->getCurrentUser();
$user = $app->getIdentity();
if (!$this->created) {
$this->created = $date;
}
if (!$this->created_by) {
$this->created_by = $user->get('id');
}
if ($this->id) {
// existing item
$this->modified_by = $user->get('id');
$this->modified = $date;
} else {
// set modified to created date if not set
if (!$this->modified) {
$this->modified = $this->created;
}
if (empty($this->modified_by)) {
$this->modified_by = $this->created_by;
}
}
// Verify that the alias is unique
$table = $app->bootComponent('com_depot')->getMVCFactory()->createTable('Manufacturer', 'Administrator');
if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) {
$this->setError('Alias is not unique.');
if ($table->state == -2) {
$this->setError('Alias is not unique. The item is in Trash.');
}
return false;
}
return parent::store($updateNulls);
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.2
*/
namespace KW4NZ\Component\Depot\Administrator\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\Database\DatabaseDriver;
\defined('_JEXEC') or die;
class StockTable extends Table
{
function __construct(DatabaseDriver $db)
{
parent::__construct('#__depot_stock', 'id', $db);
// add an alias for published:
$this->setColumnAlias('published', 'state');
}
public function store($updateNulls = true)
{
$app = Factory::getApplication();
$date = Factory::getDate()->toSql();
// $user = Factory::getUser();
// $user = $this->getCurrentUser();
$user = $app->getIdentity();
if (!$this->created) {
$this->created = $date;
}
if (!$this->created_by) {
$this->created_by = $user->get('id');
}
if ($this->id) {
// existing item
$this->modified_by = $user->get('id');
$this->modified = $date;
} else {
// set modified to created date if not set
if (!$this->modified) {
$this->modified = $this->created;
}
if (empty($this->modified_by)) {
$this->modified_by = $this->created_by;
}
}
// Verify that the alias is unique
$table = $app->bootComponent('com_depot')->getMVCFactory()->createTable('Stock', 'Administrator');
if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) {
$this->setError('Alias is not unique.');
if ($table->state == -2) {
$this->setError('Alias is not unique. The item is in Trash.');
}
return false;
}
return parent::store($updateNulls);
}
}

View File

@ -0,0 +1,75 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.1
*/
namespace KW4NZ\Component\Depot\Administrator\View\Manufacturer;
use Joomla\CMS\Factory;
// use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
\defined('_JEXEC') or die;
/**
* View to edit an article.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The \JForm object
*
* @var \JForm
*/
protected $form;
/**
* The active item
*
* @var object
*/
protected $item;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @throws \Exception
* @since 1.6
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
// if (count($errors = $this->get('Errors'))) {
// throw new GenericDataException(implode("\n", $errors), 500);
// }
$this->addToolbar();
return parent::display($tpl);
}
protected function addToolbar()
{
Factory::getApplication()->getInput()->set('hidemainmenu', true);
ToolbarHelper::title('Manufacturer: Add');
ToolbarHelper::apply('manufacturer.apply');
ToolbarHelper::save('manufacturer.save');
ToolbarHelper::cancel('manufacturer.cancel', 'JTOOLBAR_CLOSE');
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.3
*/
namespace KW4NZ\Component\Depot\Administrator\View\Manufacturers;
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;
class HtmlView extends BaseHtmlView
{
public function display($tpl = null)
{
// Get application
$app = Factory::getApplication();
$this->items = $this->get('Items');
// set the toolbar
$this->addToolbar();
parent::display($tpl);
}
protected function addToolbar()
{
ToolbarHelper::title(Text::_('COM_DEPOT_MANAGER_MANUFACTURERS'));
ToolbarHelper::addNew('manufacturer.add');
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'manufacturers.delete');
ToolbarHelper::publish('manufacturers.publish', 'JTOOLBAR_PUBLISH', true);
ToolbarHelper::unpublish('manufacturers.unpublish', 'JTOOLBAR_UNPUBLISH', true);
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.2
*/
namespace KW4NZ\Component\Depot\Administrator\View\Stock;
use Joomla\CMS\Factory;
// use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
\defined('_JEXEC') or die;
/**
* View to edit an article.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The \JForm object
*
* @var \JForm
*/
protected $form;
/**
* The active item
*
* @var object
*/
protected $item;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @throws \Exception
* @since 1.6
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
// if (count($errors = $this->get('Errors'))) {
// throw new GenericDataException(implode("\n", $errors), 500);
// }
$this->addToolbar();
return parent::display($tpl);
}
protected function addToolbar()
{
Factory::getApplication()->getInput()->set('hidemainmenu', true);
ToolbarHelper::title('Stock: Add');
ToolbarHelper::apply('stock.apply');
ToolbarHelper::save('stock.save');
ToolbarHelper::cancel('stock.cancel', 'JTOOLBAR_CLOSE');
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.3
*/
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;
class HtmlView extends BaseHtmlView
{
public function display($tpl = null)
{
// Get application
$app = Factory::getApplication();
$this->items = $this->get('Items');
// set the toolbar
$this->addToolbar();
parent::display($tpl);
}
protected function addToolbar()
{
ToolbarHelper::title(Text::_('COM_DEPOT_MANAGER_STOCKS'));
ToolbarHelper::addNew('stock.add');
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'stocks.delete');
ToolbarHelper::publish('stocks.publish', 'JTOOLBAR_PUBLISH', true);
ToolbarHelper::unpublish('stocks.unpublish', 'JTOOLBAR_UNPUBLISH', true);
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.0.3
*/
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('form.validate')
->useScript('keepalive');
?>
<form action="<?= Route::_('index.php?option=com_depot&view=manufactuerer&layout=edit&id=' . (int) $this->item->id); ?>"
method="post" name="adminForm" id="item-form" class="form-validate">
<?= HtmlHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details']); ?>
<?= HTMLHelper::_(
'uitab.addTab',
'myTab',
'details',
empty($this->item->id) ? Text::_('COM_DEPOT_TAB_NEW_MANUFACTURER') :
Text::_('COM_DEPOT_TAB_EDIT_MANUFACTURER')
); ?>
<fieldset id="fieldset-details" class="options-form">
<legend>
<?= Text::_('COM_DEPOT_LEGEND_MANUFACTURER_DETAILS') ?>
</legend>
<div class="row">
<div class="col-12 col-lg-6">
<?= $this->form->renderFieldset('details'); ?>
</div>
<div class="col-12 col-lg-6">
<?= $this->form->getInput('description'); ?>
</div>
</div>
</fieldset>
<?= HtmlHelper::_('uitab.endTab'); ?>
<?= HTMLHelper::_('uitab.addTab', 'myTab', 'statistics', Text::_('COM_DEPOT_TAB_STATISTICS')); ?>
<fieldset class="options-form">
<legend>
<?= Text::_('COM_DEPOT_LEGEND_STATISTICS') ?>
</legend>
<div class="row">
<div class="col-12 col-lg-9">
<?= $this->form->renderFieldset('statistics'); ?>
</div>
</div>
</fieldset>
<?= HTMLHelper::_('uitab.endTab'); ?>
<?= HtmlHelper::_('uitab.endTabSet'); ?>
<input type="hidden" name="task" value="manufacturer.edit" />
<?= HTMLHelper::_('form.token'); ?>
</form>

View File

@ -0,0 +1,73 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.3
*/
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
?>
<form action="<?= Route::_('index.php?option=com_depot&view=manufacturers'); ?>" method="post" name="adminForm"
id="adminForm">
<?php if (empty($this->items)): ?>
<div class="alert alert-info">
<span class="icon-info-circle" aria-hidden="true">
</span>
<?= Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else: ?>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>
<?= HTMLHelper::_('grid.checkall'); ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_ID') ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_MANUFACTURER_ACRONYM') ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_MANUFACTURER') ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items as $i => $item): ?>
<tr>
<td>
<?= HTMLHelper::_('grid.id', $i, $item->id); ?>
</td>
<td>
<?= $item->id ?>
</td>
<td>
<a href="<?= Route::_('index.php?option=com_depot&task=manufacturer.edit&id=' .
(int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>">
<?= $this->escape($item->name_short); ?>
</a>
</td>
<td>
<?= $this->escape($item->name_long); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task" value="">
<input type="hidden" name="boxchecked" value="0">
<?= HTMLHelper::_('form.token'); ?>
</form>

View File

@ -5,7 +5,7 @@
* @author Thomas Kuschel <thomas@kuschel.at> * @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at> * @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md * @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.0.3 * @since 0.9.2
*/ */
use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
@ -29,7 +29,7 @@ $wa->useScript('form.validate')
); ?> ); ?>
<fieldset id="fieldset-details" class="options-form"> <fieldset id="fieldset-details" class="options-form">
<legend> <legend>
<?= Text::_('COM_DEPOT_LEGEND_DETAILS') ?> <?= Text::_('COM_DEPOT_LEGEND_PART_DETAILS') ?>
</legend> </legend>
<div class="row"> <div class="row">
<div class="col-12 col-lg-6"> <div class="col-12 col-lg-6">

View File

@ -13,7 +13,6 @@ use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route; use Joomla\CMS\Router\Route;
?> ?>
<h2>Welcome to my Depot Component!</h2>
<form action="<?= Route::_('index.php?option=com_depot&view=parts'); ?>" method="post" name="adminForm" id="adminForm"> <form action="<?= Route::_('index.php?option=com_depot&view=parts'); ?>" method="post" name="adminForm" id="adminForm">
@ -37,6 +36,18 @@ use Joomla\CMS\Router\Route;
<th> <th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_NAME') ?> <?= Text::_('COM_DEPOT_TABLE_HEAD_NAME') ?>
</th> </th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_QUANTITY') ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_QUANTITY_EXP') ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_MANUFACTURER') ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_STOCK') ?>
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -54,6 +65,24 @@ use Joomla\CMS\Router\Route;
<?= $this->escape($item->component_name); ?> <?= $this->escape($item->component_name); ?>
</a> </a>
</td> </td>
<td>
<?= $this->escape($item->quantity); ?>
</td>
<td>
<?= "10^" . $item->quantity_exp; ?>
</td>
<td>
<a href="<?= Route::_('index.php?option=com_depot&task=manufacturer.edit&id=' .
(int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>">
<?= $this->escape($item->manufacturer); ?>
</a>
</td>
<td>
<a href="<?= Route::_('index.php?option=com_depot&task=stock.edit&id=' .
(int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>">
<?= $this->escape($item->stock_name); ?>
</a>
</td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>

62
admin/tmpl/stock/edit.php Normal file
View File

@ -0,0 +1,62 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.0.3
*/
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('form.validate')
->useScript('keepalive');
?>
<form action="<?= Route::_('index.php?option=com_depot&view=stock&layout=edit&id=' . (int) $this->item->id); ?>"
method="post" name="adminForm" id="item-form" class="form-validate">
<?= HtmlHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details']); ?>
<?= HTMLHelper::_(
'uitab.addTab',
'myTab',
'details',
empty($this->item->id) ? Text::_('COM_DEPOT_TAB_NEW_STOCK') :
Text::_('COM_DEPOT_TAB_EDIT_STOCK')
); ?>
<fieldset id="fieldset-details" class="options-form">
<legend>
<?= Text::_('COM_DEPOT_LEGEND_STOCK_DETAILS') ?>
</legend>
<div class="row">
<div class="col-12 col-lg-6">
<?= $this->form->renderFieldset('details'); ?>
</div>
<div class="col-12 col-lg-6">
<?= $this->form->getInput('description'); ?>
</div>
</div>
</fieldset>
<?= HtmlHelper::_('uitab.endTab'); ?>
<?= HTMLHelper::_('uitab.addTab', 'myTab', 'statistics', Text::_('COM_DEPOT_TAB_STATISTICS')); ?>
<fieldset class="options-form">
<legend>
<?= Text::_('COM_DEPOT_LEGEND_STATISTICS') ?>
</legend>
<div class="row">
<div class="col-12 col-lg-9">
<?= $this->form->renderFieldset('statistics'); ?>
</div>
</div>
</fieldset>
<?= HTMLHelper::_('uitab.endTab'); ?>
<?= HtmlHelper::_('uitab.endTabSet'); ?>
<input type="hidden" name="task" value="stock.edit" />
<?= HTMLHelper::_('form.token'); ?>
</form>

View File

@ -0,0 +1,71 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.3
*/
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
?>
<form action="<?= Route::_('index.php?option=com_depot&view=stocks'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (empty($this->items)): ?>
<div class="alert alert-info">
<span class="icon-info-circle" aria-hidden="true">
</span>
<?= Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else: ?>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>
<?= HTMLHelper::_('grid.checkall'); ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_ID') ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_STOCK') ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_DESCRIPTION') ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items as $i => $item): ?>
<tr>
<td>
<?= HTMLHelper::_('grid.id', $i, $item->id); ?>
</td>
<td>
<?= $item->id ?>
</td>
<td>
<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>
<td>
<?= $this->escape($item->description); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task" value="">
<input type="hidden" name="boxchecked" value="0">
<?= HTMLHelper::_('form.token'); ?>
</form>

View File

@ -7,7 +7,7 @@
<license>GPL v2 +; see LICENSE.md</license> <license>GPL v2 +; see LICENSE.md</license>
<authorEmail>thomas@kuschel.at</authorEmail> <authorEmail>thomas@kuschel.at</authorEmail>
<authorUrl>https://kuschel.at</authorUrl> <authorUrl>https://kuschel.at</authorUrl>
<version>0.9.0</version> <version>0.9.3</version>
<description>COM_DEPOT_XML_DESCRIPTION</description> <description>COM_DEPOT_XML_DESCRIPTION</description>
<namespace path="src/">KW4NZ\Component\Depot</namespace> <namespace path="src/">KW4NZ\Component\Depot</namespace>
<install> <!-- Runs on install --> <install> <!-- Runs on install -->
@ -46,9 +46,17 @@
COM_DEPOT_MENU COM_DEPOT_MENU
</menu> </menu>
<menu <menu
link="option=com_depot" link="option=com_depot&amp;view=manufacturers"
view="manufacturers"
img="class:depot-manufacturer"
alt="Depot/Manufacturers"
>
COM_DEPOT_MENU_MANUFACTURERS
</menu>
<menu
link="option=com_depot&amp;view=stocks"
view="stocks" view="stocks"
img="class:depot-stocks" img="class:depot-stock"
alt="Depot/Stocks" alt="Depot/Stocks"
> >
COM_DEPOT_MENU_STOCKS COM_DEPOT_MENU_STOCKS