UPD edit form

This commit is contained in:
Thomas Kuschel 2023-10-15 11:40:55 +02:00
parent d122312ddd
commit 6845e087f2
7 changed files with 220 additions and 40 deletions

View File

@ -28,14 +28,6 @@
description="COM_DEPOT_FIELD_QUANTITY_EXP_DESC" description="COM_DEPOT_FIELD_QUANTITY_EXP_DESC"
default="0" default="0"
/> />
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
class="readonly"
default="0"
readonly="true"
/>
<field <field
name="alias" name="alias"
type="text" type="text"
@ -69,4 +61,51 @@
<option value="-2">JTRASHED</option> <option value="-2">JTRASHED</option>
</field> </field>
</fieldset> </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> </form>

View File

@ -8,13 +8,19 @@
COM_DEPOT_FIELD_ALIAS_PLACEHOLDER="Auto-generate from component name" COM_DEPOT_FIELD_ALIAS_PLACEHOLDER="Auto-generate from component 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_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_COMPONENT_NAME_LABEL="Component Name"
COM_DEPOT_FIELD_CREATED_LABEL="Created"
COM_DEPOT_FIELD_CREATED_BY_LABEL="Created by"
COM_DEPOT_FIELD_MODIFIED_LABEL="Modified"
COM_DEPOT_FIELD_MODIFIED_BY_LABEL="Modified by"
COM_DEPOT_FIELD_QUANTITY_LABEL="Quantity" COM_DEPOT_FIELD_QUANTITY_LABEL="Quantity"
COM_DEPOT_FIELD_QUANTITY_DESC="Enter here the current number of components" COM_DEPOT_FIELD_QUANTITY_DESC="Enter here the current number of components"
COM_DEPOT_FIELD_QUANTITY_EXP_LABEL="Quantity Exponent" 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_LEGEND_DETAILS="Component Details" COM_DEPOT_LEGEND_DETAILS="Component Details"
COM_DEPOT_LEGEND_STATISTICS="Component Statistics"
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_EDIT_PART="Component Details" COM_DEPOT_TAB_EDIT_PART="Component Details"
COM_DEPOT_TAB_STATISTICS="Component Statistics"
COM_DEPOT_XML_DESCRIPTION="Depot, the component warehouse" COM_DEPOT_XML_DESCRIPTION="Depot, the component warehouse"

View File

@ -79,3 +79,41 @@ INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`,
'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified',''), 'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified',''),
('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.','');
DROP TABLE IF EXISTS `#__jron_stock`;
CREATE TABLE `#__jron_stock` (
`id` SERIAL,
`name` VARCHAR(1024) NOT NULL DEFAULT '',
-- `alias` VARCHAR(1024) NOT NULL DEFAULT '',
`owner` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`checked_out` INT(11) NOT NULL DEFAULT 0,
`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,
`description` VARCHAR(4000) NOT NULL DEFAULT '',
`params` VARCHAR(1024) NOT NULL DEFAULT '',
`location` VARCHAR(1024) NOT NULL DEFAULT '',
`latitude` DECIMAL(9,7) NOT NULL DEFAULT 48.31738798930856,
`longitude` DECIMAL(10,7) NOT NULL DEFAULT 16.313504251028924,
`state` TINYINT(4) NOT NULL DEFAULT 0,
`access` TINYINT(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `nameindex` (`name`,`owner`)
)
ENGINE=InnoDB
AUTO_INCREMENT=0
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__jron_stock`(`name`, `location`, `description`, `state`, `access`) VALUES
('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),
('Resistors workshop cabinet depot', 'Tom''s office, Martinstr. 58a, 3400 Klosterneuburg',
'MARS Svratka Workshop Depot 2x5x12 + 1x5x7+3 (158) compartments à 54 x 35 x 140 mm',1,0),
('Capacitors/Inductors 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),
('Plugs/Sockets/other 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),
('SMD cabinet', 'Tom''s office, Martinstr. 58a, 3400 Klosterneuburg',
'SMD cabinet, conductive, 6-times cabinet with inlays, 6 x 7*6 (252) round boxes, each ø 27 x 13 mm',1,0);

View File

@ -0,0 +1,42 @@
-- @package Depot.SQL MariaDB -- UPDATE to 0.9.0
-- @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.0
CREATE TABLE IF NOT EXISTS `#__depot_stock` (
`id` SERIAL,
`name` VARCHAR(1024) NOT NULL DEFAULT '',
-- `alias` VARCHAR(1024) NOT NULL DEFAULT '',
`owner` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`checked_out` INT(11) NOT NULL DEFAULT 0,
`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,
`description` VARCHAR(4000) NOT NULL DEFAULT '',
`params` VARCHAR(1024) NOT NULL DEFAULT '',
`location` VARCHAR(1024) NOT NULL DEFAULT '',
`latitude` DECIMAL(9,7) NOT NULL DEFAULT 48.31738798930856,
`longitude` DECIMAL(10,7) NOT NULL DEFAULT 16.313504251028924,
`state` TINYINT(4) NOT NULL DEFAULT 0,
`access` TINYINT(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `nameindex` (`name`,`owner`)
) ENGINE=InnoDB
AUTO_INCREMENT=0
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__depot_stock` (`name`, `location`, `description`, `state`, `access`) VALUES
('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),
('Resistors workshop cabinet depot', 'Tom''s office, Martinstr. 58a, 3400 Klosterneuburg',
'MARS Svratka Workshop Depot 2x5x12 + 1x5x7+3 (158) compartments à 54 x 35 x 140 mm',1,0),
('Capacitors/Inductors 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),
('Plugs/Sockets/other 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),
('SMD cabinet', 'Tom''s office, Martinstr. 58a, 3400 Klosterneuburg',
'SMD cabinet, conductive, 6-times cabinet with inlays, 6 x 7*6 (252) round boxes, each ø 27 x 13 mm',1,0);

View File

@ -10,6 +10,7 @@
namespace KW4NZ\Component\Depot\Administrator\Table; namespace KW4NZ\Component\Depot\Administrator\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Table;
use Joomla\Database\DatabaseDriver; use Joomla\Database\DatabaseDriver;
@ -21,4 +22,50 @@ class PartTable extends Table
{ {
parent::__construct('#__depot', 'id', $db); parent::__construct('#__depot', 'id', $db);
} }
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('Part', '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

@ -19,36 +19,44 @@ $wa->useScript('form.validate')
?> ?>
<form action="<?= Route::_('index.php?option=com_depot&view=part&layout=edit&id=' . (int) $this->item->id); ?>" <form action="<?= Route::_('index.php?option=com_depot&view=part&layout=edit&id=' . (int) $this->item->id); ?>"
method="post" name="adminForm" id="item-form" class="form-validate"> method="post" name="adminForm" id="item-form" class="form-validate">
<?= HtmlHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details']); ?>
<div class="form-horizontal">
<?= HtmlHelper::_(
'bootstrap.startTabSet',
'myTab',
['active' => 'details']
); ?>
<?= HTMLHelper::_( <?= HTMLHelper::_(
'bootstrap.addTab', 'uitab.addTab',
'myTab', 'myTab',
'details', 'details',
empty($this->item->id) ? Text::_('COM_DEPOT_TAB_NEW_PART') : empty($this->item->id) ? Text::_('COM_DEPOT_TAB_NEW_PART') :
Text::_('COM_DEPOT_TAB_EDIT_PART') Text::_('COM_DEPOT_TAB_EDIT_PART')
); ?> ); ?>
<fieldset class="adminform"> <fieldset id="fieldset-details" class="options-form">
<legend> <legend>
<?= Text::_('COM_DEPOT_LEGEND_DETAILS') ?> <?= Text::_('COM_DEPOT_LEGEND_DETAILS') ?>
</legend> </legend>
<div class="row"> <div class="row">
<div class="col-12 col-lg-3"> <div class="col-12 col-lg-6">
<?= $this->form->renderFieldset('details'); ?> <?= $this->form->renderFieldset('details'); ?>
</div> </div>
<div class="col-12 col-lg-9"> <div class="col-12 col-lg-6">
<?= $this->form->getInput('description'); ?> <?= $this->form->getInput('description'); ?>
</div> </div>
</div> </div>
</fieldset> </fieldset>
<?= HtmlHelper::_('bootstrap.endTab'); ?> <?= HtmlHelper::_('uitab.endTab'); ?>
<?= HtmlHelper::_('bootstrap.endTabSet'); ?>
<?= 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>
</div>
</fieldset>
<?= HTMLHelper::_('uitab.endTab'); ?>
<?= HtmlHelper::_('uitab.endTabSet'); ?>
<input type="hidden" name="task" value="part.edit" /> <input type="hidden" name="task" value="part.edit" />
<?= HTMLHelper::_('form.token'); ?> <?= HTMLHelper::_('form.token'); ?>
</form> </form>

View File

@ -2,12 +2,12 @@
<extension type="component" method="upgrade"> <extension type="component" method="upgrade">
<name>Depot</name> <name>Depot</name>
<author>KW4NZ</author> <author>KW4NZ</author>
<creationDate>2023-10-06</creationDate> <creationDate>2023-10-15</creationDate>
<copyright>(C) KW4NZ Thomas Kuschel</copyright> <copyright>(C) KW4NZ Thomas Kuschel</copyright>
<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.0.5</version> <version>0.9.0</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 -->