PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / taxes / view.html.php
vikappointments / admin / views / taxes Last commit date
tmpl 3 years ago index.html 4 years ago view.html.php 2 years ago
view.html.php
144 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * VikAppointments taxes view.
16 *
17 * @since 1.7
18 */
19 class VikAppointmentsViewtaxes extends JViewVAP
20 {
21 /**
22 * VikAppointments view display method.
23 *
24 * @return void
25 */
26 function display($tpl = null)
27 {
28 $app = JFactory::getApplication();
29 $input = $app->input;
30 $dbo = JFactory::getDbo();
31
32 // set the toolbar
33 $this->addToolBar();
34
35 $filters = array();
36 $filters['keys'] = $app->getUserStateFromRequest($this->getPoolName() . '.keys', 'keys', '', 'string');
37
38 $this->filters = $filters;
39
40 $this->ordering = $app->getUserStateFromRequest($this->getPoolName() . '.ordering', 'filter_order', 't.createdon', 'string');
41 $this->orderDir = $app->getUserStateFromRequest($this->getPoolName() . '.orderdir', 'filter_order_Dir', 'ASC', 'string');
42
43 // db object
44 $lim = $app->getUserStateFromRequest('com_vikappointments.limit', 'limit', $app->get('list_limit'), 'uint');
45 $lim0 = $this->getListLimitStart($filters);
46 $navbut = "";
47
48 $rows = array();
49
50 $q = $dbo->getQuery(true);
51
52 $q->select('SQL_CALC_FOUND_ROWS t.*')
53 ->from($dbo->qn('#__vikappointments_tax', 't'))
54 ->where(1)
55 ->order($dbo->qn($this->ordering) . ' ' . $this->orderDir);
56
57 if (strlen($filters['keys']))
58 {
59 $q->andWhere(array(
60 $dbo->qn('t.name') . ' LIKE ' . $dbo->q("%{$filters['keys']}%"),
61 $dbo->qn('t.description') . ' LIKE ' . $dbo->q("%{$filters['keys']}%"),
62 ), 'OR');
63 }
64
65 /**
66 * Add support for manipulating query through the plugins.
67 *
68 * @see /site/helpers/libraries/mvc/view.php @ JViewVAP::onBeforeListQuery()
69 *
70 * @since 1.7
71 */
72 $this->onBeforeListQuery($q);
73
74 $dbo->setQuery($q, $lim0, $lim);
75 $dbo->execute();
76
77 // assert limit used for list query
78 $this->assertListQuery($lim0, $lim);
79
80 if ($dbo->getNumRows())
81 {
82 $rows = $dbo->loadAssocList();
83 $dbo->setQuery('SELECT FOUND_ROWS();');
84 jimport('joomla.html.pagination');
85 $pageNav = new JPagination($dbo->loadResult(), $lim0, $lim);
86 $navbut = JLayoutHelper::render('blocks.pagination', ['pageNav' => $pageNav]);
87 }
88
89 if (VikAppointments::isMultilanguage())
90 {
91 $translator = VAPFactory::getTranslator();
92
93 // find available translations
94 $lang = $translator->getAvailableLang(
95 'tax',
96 array_map(function($row) {
97 return $row['id'];
98 }, $rows)
99 );
100
101 // assign languages found to the related elements
102 foreach ($rows as $k => $row)
103 {
104 $rows[$k]['languages'] = isset($lang[$row['id']]) ? $lang[$row['id']] : array();
105 }
106 }
107
108 $this->rows = $rows;
109 $this->navbut = $navbut;
110
111 // display the template (default.php)
112 parent::display($tpl);
113 }
114
115 /**
116 * Setting the toolbar.
117 *
118 * @return void
119 */
120 protected function addToolBar()
121 {
122 // add menu title and some buttons to the page
123 JToolBarHelper::title(JText::translate('VAPMAINTITLEVIEWTAXES'), 'vikappointments');
124
125 $user = JFactory::getUser();
126
127 if ($user->authorise('core.create', 'com_vikappointments'))
128 {
129 JToolBarHelper::addNew('tax.add');
130 JToolBarHelper::custom('tax.duplicate', 'copy', 'copy', JText::translate('VAPCLONE'), true);
131 }
132
133 if ($user->authorise('core.edit', 'com_vikappointments'))
134 {
135 JToolBarHelper::editList('tax.edit');
136 }
137
138 if ($user->authorise('core.delete', 'com_vikappointments'))
139 {
140 JToolBarHelper::deleteList(VikAppointments::getConfirmSystemMessage(), 'tax.delete');
141 }
142 }
143 }
144