PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / coupongroups / view.html.php
vikappointments / admin / views / coupongroups Last commit date
tmpl 2 days ago index.html 2 days ago view.html.php 2 days ago
view.html.php
125 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 coupon groups view.
16 *
17 * @since 1.6
18 */
19 class VikAppointmentsViewcoupongroups 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['keysearch'] = $app->getUserStateFromRequest($this->getPoolName() . '.keysearch', 'keysearch', '', 'string');
37
38 $this->filters = $filters;
39
40 $this->ordering = $app->getUserStateFromRequest($this->getPoolName() . '.ordering', 'filter_order', 'g.ordering', '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 g.*, COUNT(c.id) AS `count`')
53 ->select($dbo->qn('c.id', 'coupon_id'))
54 ->from($dbo->qn('#__vikappointments_coupon_group', 'g'))
55 ->leftjoin($dbo->qn('#__vikappointments_coupon', 'c') . ' ON ' . $dbo->qn('g.id') . ' = ' . $dbo->qn('c.id_group'))
56 ->group($dbo->qn('g.id'))
57 ->order($dbo->qn($this->ordering) . ' ' . $this->orderDir);
58
59 if (strlen($filters['keysearch']))
60 {
61 $q->where($dbo->qn('g.name') . ' LIKE ' . $dbo->q("%{$filters['keysearch']}%"));
62 }
63
64 /**
65 * Add support for manipulating query through the plugins.
66 *
67 * @see /site/helpers/libraries/mvc/view.php @ JViewVAP::onBeforeListQuery()
68 *
69 * @since 1.7
70 */
71 $this->onBeforeListQuery($q);
72
73 $dbo->setQuery($q, $lim0, $lim);
74 $dbo->execute();
75
76 // assert limit used for list query
77 $this->assertListQuery($lim0, $lim);
78
79 if ($dbo->getNumRows())
80 {
81 $rows = $dbo->loadAssocList();
82 $dbo->setQuery('SELECT FOUND_ROWS();');
83 jimport('joomla.html.pagination');
84 $pageNav = new JPagination($dbo->loadResult(), $lim0, $lim);
85 $navbut = JLayoutHelper::render('blocks.pagination', ['pageNav' => $pageNav]);
86 }
87
88 $this->rows = $rows;
89 $this->navbut = $navbut;
90
91 // display the template (default.php)
92 parent::display($tpl);
93 }
94
95 /**
96 * Setting the toolbar.
97 *
98 * @return void
99 */
100 protected function addToolBar()
101 {
102 // add menu title and some buttons to the page
103 JToolBarHelper::title(JText::translate('VAPMAINTITLEVIEWCOUPONGROUPS'), 'vikappointments');
104
105 $user = JFactory::getUser();
106
107 JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_vikappointments&view=coupons');
108
109 if ($user->authorise('core.create', 'com_vikappointments'))
110 {
111 JToolBarHelper::addNew('coupongroup.add');
112 }
113
114 if ($user->authorise('core.edit', 'com_vikappointments'))
115 {
116 JToolBarHelper::editList('coupongroup.edit');
117 }
118
119 if ($user->authorise('core.delete', 'com_vikappointments'))
120 {
121 JToolBarHelper::deleteList(VikAppointments::getConfirmSystemMessage(), 'coupongroup.delete');
122 }
123 }
124 }
125