Adding views of stacks, manufacturers lists
This commit is contained in:
19
admin/src/Controller/ManufacturerController.php
Normal file
19
admin/src/Controller/ManufacturerController.php
Normal 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
|
||||
{
|
||||
}
|
19
admin/src/Controller/StockController.php
Normal file
19
admin/src/Controller/StockController.php
Normal 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
|
||||
{
|
||||
}
|
64
admin/src/Model/ManufacturerModel.php
Normal file
64
admin/src/Model/ManufacturerModel.php
Normal 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;
|
||||
}
|
||||
}
|
75
admin/src/Model/ManufacturersModel.php
Normal file
75
admin/src/Model/ManufacturersModel.php
Normal 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;
|
||||
}
|
||||
}
|
64
admin/src/Model/StockModel.php
Normal file
64
admin/src/Model/StockModel.php
Normal 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;
|
||||
}
|
||||
}
|
74
admin/src/Model/StocksModel.php
Normal file
74
admin/src/Model/StocksModel.php
Normal 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;
|
||||
}
|
||||
}
|
74
admin/src/Table/ManufacturerTable.php
Normal file
74
admin/src/Table/ManufacturerTable.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
74
admin/src/Table/StockTable.php
Normal file
74
admin/src/Table/StockTable.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
75
admin/src/View/Manufacturer/HtmlView.php
Normal file
75
admin/src/View/Manufacturer/HtmlView.php
Normal 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');
|
||||
}
|
||||
}
|
47
admin/src/View/Manufacturers/HtmlView.php
Normal file
47
admin/src/View/Manufacturers/HtmlView.php
Normal 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);
|
||||
}
|
||||
}
|
74
admin/src/View/Stock/HtmlView.php
Normal file
74
admin/src/View/Stock/HtmlView.php
Normal 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');
|
||||
}
|
||||
}
|
47
admin/src/View/Stocks/HtmlView.php
Normal file
47
admin/src/View/Stocks/HtmlView.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user