diff --git a/admin/language/en-GB/com_depot.ini b/admin/language/en-GB/com_depot.ini index 79236bb..446d2c9 100644 --- a/admin/language/en-GB/com_depot.ini +++ b/admin/language/en-GB/com_depot.ini @@ -24,4 +24,6 @@ COM_DEPOT_SELECT_YOUR_OPTION="Select your option" COM_DEPOT_TAB_NEW_PART="New Component" COM_DEPOT_TAB_EDIT_PART="Component Details" COM_DEPOT_TAB_STATISTICS="Component Statistics" +COM_DEPOT_TABLE_HEAD_ID="ID" +COM_DEPOT_TABLE_HEAD_NAME="Component Name" COM_DEPOT_XML_DESCRIPTION="Depot, the component warehouse" diff --git a/admin/src/Model/PartsModel.php b/admin/src/Model/PartsModel.php new file mode 100644 index 0000000..ac148ba --- /dev/null +++ b/admin/src/Model/PartsModel.php @@ -0,0 +1,82 @@ + + * @copyright (C) 2023 KW4NZ, + * @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; + +\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.short_name', 'manufacturer'), + $db->quoteName('m.long_name', '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 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)'); + } + + return $query; + } +} \ No newline at end of file diff --git a/admin/src/View/Parts/HtmlView.php b/admin/src/View/Parts/HtmlView.php index dbdb46a..dc8ac8d 100644 --- a/admin/src/View/Parts/HtmlView.php +++ b/admin/src/View/Parts/HtmlView.php @@ -1,23 +1,30 @@ -* @copyright (C) 2023 KW4NZ, -* @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 + * @copyright (C) 2023 KW4NZ, + * @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\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Factory; -class HtmlView extends BaseHtmlView + +class HtmlView extends BaseHtmlView { - public function display($tpl = null) + public function display($tpl = null) { + // Get application + $app = Factory::getApplication(); + + $this->items = $this->get('Items'); + parent::display($tpl); } -} +} \ No newline at end of file diff --git a/admin/tmpl/parts/default.php b/admin/tmpl/parts/default.php index a0189e1..6925bc5 100644 --- a/admin/tmpl/parts/default.php +++ b/admin/tmpl/parts/default.php @@ -10,4 +10,23 @@ ?>

Welcome to my Depot Component!

-

Link: Part

\ No newline at end of file +

Link: Part

+ + + + + + + + + + items as $i => $item): ?> + + + + +
COM_DEPOT_TABLE_HEAD_IDCOM_DEPOT_TABLE_HEAD_NAME
+ id ?> + + component_name ?> +
\ No newline at end of file