11 Commits

37 changed files with 2373 additions and 46 deletions

279
README.md
View File

@ -17,7 +17,7 @@ developing our project. The first run with simply renaming entries from a
copy of the component **com_banners** did not work as expected.
So let us start at the very beginning:
### Adding basic files for component (b1_basic_backend)
## Adding basic files for component (b1_basic_backend)
With the git branch **b1_basic_backend**
Add the following basic six files:
@ -124,7 +124,7 @@ the directory /admin/language/en-GB/ naming it
---
### Creating and managing Joomla database (b2_database)
## Creating and managing Joomla database (b2_database)
With the new git branch **b2_database** we continue our workflow.
@ -295,7 +295,7 @@ Methods in the table objects are:
---
### Get a Form in Joomla component
## Get a Form in Joomla component (b3_form)
The **Form** class of Joomla is used to create complex forms with flexible
layouts and dynamic properties. First, the form fields are defined in the
@ -439,3 +439,276 @@ just a line before `<folder>services</folder>` :
```
---
## Adding administrator's actions (Back-end) - Save and Cancel (b4_actions)
In the form View, you can add action buttons like "Save" and "Cancel" to submit the form
or cancel the editing respectively. These buttons are added to the toolbar.
These buttons require compound tasks (controller and method). For example,
- Save and Edit: part.apply
- Save and Close: part.save
- Cancel: part.cancel
#### View file
**admin/src/View/Part/HtmlView.php**
In the View file, we create a new method to add a toolbar: `addToolbar()`. The
toolbar hides the sidebar menu on forms, sets the title and adds action buttons.
```php
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
protected function addToolbar()
{
Factory::getApplication()->getInput()->set('hidemainmenu', true);
ToolbarHelper::title('Part: Add');
ToolbarHelper::apply('part.apply');
ToolbarHelper::save('part.save');
ToolbarHelper::cancel('part.cancel', 'JTOOLBAR_CLOSE');
}
```
The display() calls this method to include the toolbar.
```php
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->addToolbar();
parent::display($tpl);
}
```
#### Controller file
**admin/src/Controller/PartController.php***
Now, when these action buttons are clicked, Joomla will look for apply(), save() or cancel()
methods in the Part controller. So, create a controller clss that will extend FormController.
These methods are already defined in the parent class.
```php
use Joomla\CMS\MVC\Controller\FormController;
class PartController extends FormController
{
}
```
#### Model file
**admin/src/model/PartModel.php**
If you click on Save button, it will save the data and redirect to the editing screen. However, the data will not be present in the form. Though, we have set `$loadData` to true, we also need to create a method `loadFormData()` to get the data for the form.
```php
protected function loadFormData()
{
$app = Factory::getApplication();
$data = $app->getUserState('com_depot.edit.part.data', []);
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
```
First, this method tries to get the data from the session. If it fails to get data from the
session, then it gets data from the database. The `getItem()` method is defined in the
parent class.
Suppose the user has filled out the form to add a new item but has some invalid data in the
form. In this case, the save will not be successful, so the data is not saved in the
database. It would be very frustrating if the user hat to reenter all the fields to fix a
single error. To handle this scenario, you save the entered data in the user's session.
Only after the save is successful, you clear this out of the session.
So, you either have data from the database, which you can get with `getItem()`, or you have
data from the session, which you can get with `getUserSate()`.
---
## Automatic handling of fields (b5_field_manipulation)
Values of some fields in the form can be automatically handled. There is no need to fill in
the values while creating or editing a record.
For example, `alias` can be generated from the `title` (or here, from the component's name),
dates can be set to the current date or to `null`, user id can be obtained from current
logged in user. Further may you also need to check validity of some fields like "should not
be empty", `alias` should be unique, etc.
The data submitted by the form needs to be modified before saving. This can be done at
various places:
- in the **Model class** by oeverriding the `save()` method or `preparetable()` method.
- in the **Table class** by overriding the `bind()`, `check()`, or `store()` methods.
#### 1. Model file
**admin/src/Model/PartModel.php
```php
public function save($data)
{
/* Add code to modify data before saving */
return parent:save($data);
}
```
It is better to perform automatic handling of fields in the Table class as the data can be
saved not only from administration, but also from frontend, API or by any other means.
##### Example generating Alias
Alias is generated from the `component_name` (or any other field) using **OutputFilter** class
method.
```php
if (empty($data['alias']))
{
if (Factory::getConfig()->get('unicodeslugs') == 1) {
$data['alias'] = OutputFilter::stringURLUnicodeSlug($data['component_name']);
} else {
$data['alias'] = OutputFilter::stringURLSafe($data['component_name']);
}
}
```
##### Ordering
The ordering value is calculated by finding the maximum value in the column and then
incrementing it.
```php
/* if it is 0 -> get the max + 1 value */
if (!$data['ordering']) {
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from('#__depot');
$db->setQuery($query);
$max = $db->loadResult();
$data['ordering'] = $max + 1;
}
```
#### 2. bind()
The `bind()` splits the article text or description into intro text and full text based on read
more tag in the content. This method also converts fields data from arrays to JSON for
saving into the database.
```php
public function bind($array, $ignore = '')
{
if (isset($array['attribs']) && \is_array($array['attribs'])) {
$registry = new Registry($array['attribs']);
$array['attribs'] = (string) $registry;
}
return parent::bind($array, $ignore);
}
```
#### 3. check()
The check() checks whether title of the article is not empty. This method also sets the alias,
hits, publishing dates.
```php
public function check()
{
try {
parent::check();
}
catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
if (trim($this->title) == '') {
$this->setError('Title (title) is not set.');
return false;
}
if (trim($this->alias) == '') {
$this->alias = $this->title;
}
$this->alias = ApplicationHelper::stringURLSave($this->alias, $this->language);
// Ensure any new items have compulsory fields set
if (!$this->id) {
// Hits must be zero on a new item
$this-hits = 0;
}
// Set publish_up to null if not set
if (!$this->publish_up) {
$this->publish_up = null;
}
// Set publish_down to null if not set
if (!$this->publish_down) {
$this->publish_down = null;
}
// Check the publish down date is not earlier than publish up.
if (!is_null($this->publish_up) &&
!is_null($this->publish_down) &&
$this->publish_down < $this->publish_up) {
// swap the dates
$temp = $this->publish_up;
$this->publish_up = $this->publish_down;
$this->publish_down = $temp;
}
return true;
}
```
#### 4. store()
The `store()` sets created and modified dates, created by and modified by users, and also
checks for unique alias.
```php
public function store($updateNulls = true)
{
$app = Factory::getApplication();
$date = Factory::getDate()->toSql();
$user = Factory::getUser();
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;
}
// Set modified_by to created_by user if not set
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

@ -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>

View File

@ -0,0 +1,78 @@
<?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>
<field
name="manufacturer_id"
type="depotmanufacturer"
label="COM_DEPOT_HEADING_MANUFACTURER"
extension="com_depot"
class="js-select-submit-on-change"
>
<option value="">COM_DEPOT_SELECT_MANUFACTURER</option>
</field>
<field
name="stock_id"
type="depotstock"
label="COM_DEPOT_HEADING_STOCK"
extension="com_depot"
class="js-select-submit-on-change"
>
<option value="">COM_DEPOT_SELECT_STOCK</option>
</field>
</fields>
<!-- ('d.id'),
$db->quoteName('d.component_name'),
$db->quoteName('d.alias'),
$db->quoteName('d.description'),
$db->quoteName('d.quantity'),
$db->quoteName('d.quantity_exp'),
$db->quoteName('d.ordering'),
-->
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
statuses="*,0,1,2,-2"
class="js-select-submit-on-change"
default="d.component_name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="d.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="d.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="d.state ASC">JSTATUS_ASC</option>
<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.quantity ASC">COM_DEPOT_QUANTITY_ASC</option>
<option value="d.quantity DESC">COM_DEPOT_QUANTITY_DESC</option>
<option value="d.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="d.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>

View 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>

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_MANUFACTURER_ACRONYM_LABEL"
description="COM_DEPOT_FIELD_MANUFACTURER_ACRONYM_DESC"
required="true"
autofocus="1"
/>
<field
name="name_long"
type="text"
label="COM_DEPOT_FIELD_MANUFACTURER_LONG_NAME_LABEL"
description="COM_DEPOT_FIELD_MANUFACTURER_LONG_NAME_DESC"
required="true"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="COM_DEPOT_FIELD_ALIAS_MANUFACTURER_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

@ -1,18 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<field
name="component_name"
type="text"
label="COM_DEPOT_FIELD_COMPONENT_NAME_LABEL"
description="COM_DEPOT_FIELD_COMPONENT_NAME_DESC"
required="true"
/>
<field
name="id"
type="text"
label="JGLOBAL_FIELD_ID_LABEL"
class="readonly"
default="0"
readonly="true"
/>
<fieldset
name="details"
label="COM_DEPOT_DETAILS"
addruleprefix="KW4NZ\Component\Depot\Administrator\Rule"
addfieldprefix="KW4NZ\Component\Depot\Administrator\Field"
>
<field
name="component_name"
type="text"
label="COM_DEPOT_FIELD_COMPONENT_NAME_LABEL"
description="COM_DEPOT_FIELD_COMPONENT_NAME_DESC"
required="true"
autofocus="1"
/>
<field
name="quantity"
type="number"
label="COM_DEPOT_FIELD_QUANTITY_LABEL"
description="COM_DEPOT_FIELD_QUANTITY_DESC"
default="0"
/>
<field
name="quantity_exp"
type="number"
label="COM_DEPOT_FIELD_QUANTITY_EXP_LABEL"
description="COM_DEPOT_FIELD_QUANTITY_EXP_DESC"
default="0"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="COM_DEPOT_FIELD_ALIAS_PART_PLACEHOLDER"
size="40"
/>
<field
name="manufacturer_id"
type="sql"
label="COM_DEPOT_FIELD_SELECT_MANUFACTURER"
query="SELECT id, CONCAT( name_short, ' (', name_long, ')') AS title FROM #__depot_manufacturer ORDER BY title"
key_field="id"
value_field="title"
required="true"
>
<option value="">COM_DEPOT_SELECT_YOUR_OPTION</option>
</field>
<field
name="stock_id"
type="sql"
label="COM_DEPOT_FIELD_SELECT_STOCK"
query="SELECT id, name FROM #__depot_stock ORDER BY name"
key_field="id"
value_field="name"
required="true"
>
<option value="">COM_DEPOT_SELECT_YOUR_OPTION</option>
</field>
<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_STOCK_NAME_LABEL"
description="COM_DEPOT_FIELD_STOCK_NAME_DESC"
required="true"
autofocus="1"
/>
<field
name="description"
type="text"
label="COM_DEPOT_FIELD_STOCK_DESCRIPTION_LABEL"
description="COM_DEPOT_FIELD_STOCK_DESCRIPTION_DESC"
required="true"
/>
<field
name="alias"
type="text"
label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC"
hint="COM_DEPOT_FIELD_ALIAS_STOCK_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

@ -5,6 +5,55 @@
; @license GNU General Public License version 2 or later; see LICENSE.md
; @since 0.0.1
;
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_ALIAS_MANUFACTURER_PLACEHOLDER="Auto-generate from manufacturer acronym"
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_CREATED_LABEL="Created"
COM_DEPOT_FIELD_CREATED_BY_LABEL="Created by"
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"
COM_DEPOT_FIELD_MANUFACTURER_LONG_NAME_LABEL="Manufacturer (long name)"
COM_DEPOT_FIELD_MODIFIED_LABEL="Modified"
COM_DEPOT_FIELD_MODIFIED_BY_LABEL="Modified by"
COM_DEPOT_FIELD_QUANTITY_LABEL="Quantity"
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_DESC="Exponent (10^x of the number, usually 0, i.e. 10⁰)"
COM_DEPOT_FIELD_SELECT_MANUFACTURER="Manufacturer"
COM_DEPOT_FIELD_SELECT_STOCK="Stock Location"
COM_DEPOT_FIELD_STOCK_NAME_DESC="Enter here the short stock location"
COM_DEPOT_FIELD_STOCK_NAME_LABEL="Stock Location"
COM_DEPOT_FIELD_STOCK_DESCRIPTION_DESC="Enter here the exact location/description"
COM_DEPOT_FIELD_STOCK_DESCRIPTION_LABEL="Description"
COM_DEPOT_LEGEND_MANUFACTURER_DETAILS="Manufacturer Details"
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_MORE="%d components deleted"
COM_DEPOT_N_ITEMS_PUBLISHED_1="One component published"
COM_DEPOT_N_ITEMS_PUBLISHED_MORE="%d components published"
COM_DEPOT_N_ITEMS_UNPUBLISHED_1="One component unpublished"
COM_DEPOT_N_ITEMS_UNPUBLISHED_MORE="%d components unpublished"
COM_DEPOT_SELECT_YOUR_OPTION="Select your option"
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_MANUFACTURER="Manufacturer Details"
COM_DEPOT_TAB_EDIT_STOCK="Stock Details"
COM_DEPOT_TAB_STATISTICS="Statistics"
COM_DEPOT_TABLE_HEAD_ID="ID"
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"

View File

@ -46,6 +46,75 @@ CREATE TABLE `#__depot` (
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`,
`ordering`,`state`,`manufacturer_id`) VALUES
('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1),
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2);
`ordering`,`state`,`manufacturer_id`,`stock_id`) VALUES
('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,1);
DROP TABLE IF EXISTS `#__depot_manufacturer`;
CREATE TABLE `#__depot_manufacturer` (
`id` SERIAL,
`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 '',
`name_long` VARCHAR(1024) NOT NULL DEFAULT '',
`url` VARCHAR(1024) NOT NULL DEFAULT '',
`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 '',
`state` TINYINT(4) NOT NULL DEFAULT 0,
`image` VARCHAR(1024) NOT NULL DEFAULT '',
`access` TINYINT(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name_short` (`name_short`)
) ENGINE=InnoDB
AUTO_INCREMENT=0
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`,
`description`, `image`, `state`) VALUES
('TSC','Taiwan Semiconductor','https://www.taiwansemi.com',
'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified','',1),
('ST','STMicroelectronics','https://www.st.com',
'Microprocessors, Audio ICs, OPamps, Diodes, Memories, MEMS, NFCs, Transistors, Wireless, Automotive electronics, etc.','',1);
DROP TABLE IF EXISTS `#__depot_stock`;
CREATE TABLE `#__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

@ -0,0 +1,35 @@
-- @package Depot.SQL MariaDB -- UPDATE to 0.0.5
-- @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.5
CREATE TABLE IF NOT EXISTS `#__depot_manufacturer` (
`id` SERIAL,
`name_short` CHAR(25) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
COMMENT 'unique manufacturer name or abbriviation',
`name_long` VARCHAR(1024) NOT NULL DEFAULT '',
`url` VARCHAR(1024) NOT NULL DEFAULT '',
`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 '',
`state` TINYINT(4) NOT NULL DEFAULT 0,
`image` VARCHAR(1024) NOT NULL DEFAULT '',
`access` TINYINT(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name_short` (`name_short`)
) ENGINE=InnoDB
AUTO_INCREMENT=0
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`,
`description`, `image`, `state`) VALUES
('TSC','Taiwan Semiconductor','https://www.taiwansemi.com',
'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified','',1),
('ST','STMicroelectronics','https://www.st.com',
'Microprocessors, Audio ICs, OPamps, Diodes, Memories, MEMS, NFCs, Transistors, Wireless, Automotive electronics, etc.','',1);

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

@ -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.0.4
*/
namespace KW4NZ\Component\Depot\Administrator\Controller;
use Joomla\CMS\MVC\Controller\FormController;
defined('_JEXEC') or die;
class PartController extends FormController
{
}

View File

@ -0,0 +1,23 @@
<?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.6
*/
namespace KW4NZ\Component\Depot\Administrator\Controller;
use Joomla\CMS\MVC\Controller\AdminController;
defined('_JEXEC') or die;
class PartsController extends AdminController
{
public function getModel($name = 'Part', $prefix = 'Administrator', $config = ['ignore_request' => true])
{
return parent::getModel($name, $prefix, $config);
}
}

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,84 @@
<?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;
use Joomla\Database\ParameterType;
\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: 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)) {
$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

@ -10,6 +10,8 @@
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;
@ -26,4 +28,37 @@ class PartModel extends AdminModel
return $form;
}
protected function loadFormData()
{
$app = Factory::getApplication();
$data = $app->getUserState('com_depot.edit.part.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['component_name']);
}
$result = parent::save($data);
// if ($result) {
// $this->getTable('', 'Administrator')->rebuild(1);
// }
return $result;
}
}

View File

@ -0,0 +1,90 @@
<?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\MVC\Model\ListModel;
// use Joomla\CMS\Table\Table;
use Joomla\Database\ParameterType;
\defined('_JEXEC') or die;
class PartsModel 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('d.id'),
$db->quoteName('d.component_name'),
$db->quoteName('d.alias'),
$db->quoteName('d.description'),
$db->quoteName('d.quantity'),
$db->quoteName('d.quantity_exp'),
$db->quoteName('d.ordering'),
]
)
)
->select(
[
$db->quoteName('u.name', 'creator'),
$db->quoteName('m.name_short', 'manufacturer'),
$db->quoteName('m.name_long', 'manufacturer_long'),
$db->quoteName('s.name', 'stock_name'),
]
)
->from($db->quoteName('#__depot', 'd'))
->join('LEFT', $db->quoteName('#__depot_manufacturer', 'm'), $db->quoteName('m.id') . ' = ' . $db->quoteName('d.manufacturer_id'))
->join('LEFT', $db->quoteName('#__depot_stock', 's'), $db->quoteName('s.id') . ' = ' . $db->quoteName('d.stock_id'))
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('d.checked_out'));
// filter: like / search
$search = $this->getState('filter.search');
if (!empty($search)) {
$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)) {
$published = (int) $published;
$query->where($db->quoteName('d.state') . ' = :published')
->bind(':published', $published, ParameterType::INTEGER);
} elseif ($published === '') {
//$query->where($db->quoteName('d.state') . ' IN (0, 1)');
$query->whereIn($db->quoteName('d.state'), [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,82 @@
<?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;
use Joomla\Database\ParameterType;
\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: 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');
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

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

@ -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,51 @@
<?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');
// adding filters
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// 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

@ -10,10 +10,13 @@
namespace KW4NZ\Component\Depot\Administrator\View\Part;
defined('_JEXEC') or die;
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.
@ -43,8 +46,8 @@ class HtmlView extends BaseHtmlView
*
* @return mixed A string if successful, otherwise an Error object.
*
* @throws \Exception
* @since 1.6
* @throws \Exception
* @since 1.6
*/
public function display($tpl = null)
{
@ -54,7 +57,19 @@ class HtmlView extends BaseHtmlView
// 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('Part: Add');
ToolbarHelper::apply('part.apply');
ToolbarHelper::save('part.save');
ToolbarHelper::cancel('part.cancel', 'JTOOLBAR_CLOSE');
}
}

View File

@ -1,23 +1,51 @@
<?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.1
*/
* @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.1
*/
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;
class HtmlView extends BaseHtmlView
// use Joomla\CMS\Language\Text;
class HtmlView extends BaseHtmlView
{
public function display($tpl = null)
public function display($tpl = null)
{
// Get application
$app = Factory::getApplication();
$this->items = $this->get('Items');
// adding filters
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// set the toolbar
$this->addToolbar();
parent::display($tpl);
}
}
protected function addToolbar()
{
ToolbarHelper::title(Text::_('COM_DEPOT_MANAGER_PARTS'));
ToolbarHelper::addNew('part.add');
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'parts.delete');
ToolbarHelper::publish('parts.publish', 'JTOOLBAR_PUBLISH', true);
ToolbarHelper::unpublish('parts.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,51 @@
<?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');
// adding filters
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// 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,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
*/
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">
</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,9 +5,10 @@
* @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
* @since 0.9.2
*/
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
@ -16,11 +17,46 @@ $wa->useScript('form.validate')
->useScript('keepalive');
?>
<form action="<?php echo 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">
<?= HtmlHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details']); ?>
<?= HTMLHelper::_(
'uitab.addTab',
'myTab',
'details',
empty($this->item->id) ? Text::_('COM_DEPOT_TAB_NEW_PART') :
Text::_('COM_DEPOT_TAB_EDIT_PART')
); ?>
<fieldset id="fieldset-details" class="options-form">
<legend>
<?= Text::_('COM_DEPOT_LEGEND_PART_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'); ?>
<?php echo $this->form->renderField('component_name'); ?>
<?= 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="part.edit" />
<?php echo HTMLHelper::_('form.token'); ?>
<?= HTMLHelper::_('form.token'); ?>
</form>

View File

@ -7,7 +7,92 @@
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.0.1
*/
?>
<h2>Welcome to my Depot Component!</h2>
<p>Link: <a href="index.php?option=com_depot&view=part&layout=edit">Part</a></p>
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=parts'); ?>" 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">
</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_NAME') ?>
</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>
</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=part.edit&id=' .
(int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>">
<?= $this->escape($item->component_name); ?>
</a>
</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>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task" value="">
<input type="hidden" name="boxchecked" value="0">
<?= HTMLHelper::_('form.token'); ?>
</form>

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,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
*/
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">
</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

@ -2,12 +2,12 @@
<extension type="component" method="upgrade">
<name>Depot</name>
<author>KW4NZ</author>
<creationDate>2023-10-06</creationDate>
<creationDate>2023-10-24</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.0.3</version>
<version>0.9.5</version>
<description>COM_DEPOT_XML_DESCRIPTION</description>
<namespace path="src/">KW4NZ\Component\Depot</namespace>
<install> <!-- Runs on install -->
@ -46,9 +46,17 @@
COM_DEPOT_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"
img="class:depot-stocks"
img="class:depot-stock"
alt="Depot/Stocks"
>
COM_DEPOT_MENU_STOCKS