PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | admin/views/states/view.html.php +114 -0 1.6.0 → 1.8.16 View file →
@@ -1,0 +1,114 @@
1 +<?php
2 +/**
3 + * @package VikBooking
4 + * @subpackage com_vikbooking
5 + * @author Alessio Gaggii - e4j - Extensionsforjoomla.com
6 + * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved.
7 + * @license GNU General Public License version 2 or later; see LICENSE
8 + * @link https://vikwp.com
9 + */
10 +
11 +defined('ABSPATH') or die('No script kiddies please!');
12 +
13 +// import Joomla view library
14 +jimport('joomla.application.component.view');
15 +
16 +class VikBookingViewStates extends JViewVikBooking
17 +{
18 + public function display($tpl = null)
19 + {
20 + // Set the toolbar
21 + $this->addToolBar();
22 +
23 + $rows = [];
24 + $navbut = "";
25 + $dbo = JFactory::getDbo();
26 + $app = JFactory::getApplication();
27 + $session = JFactory::getSession();
28 +
29 + $pidcountry = $app->getUserStateFromRequest("vbo.states.idcountry", 'idcountry', 0, 'int');
30 + $pstatename = $app->getUserStateFromRequest("vbo.states.statename", 'statename', '', 'string');
31 +
32 + $lim = $app->getUserStateFromRequest("com_vikbooking.limit", 'limit', $app->get('list_limit'), 'int');
33 +
34 + $lim0 = VikRequest::getVar('limitstart', 0, '', 'int');
35 +
36 + $pvborderby = VikRequest::getString('vborderby', '', 'request');
37 + $pvbordersort = VikRequest::getString('vbordersort', '', 'request');
38 +
39 + $validorderby = [
40 + 'state_name',
41 + 'state_2_code',
42 + 'state_3_code',
43 + 'published',
44 + ];
45 +
46 + $orderby = $session->get('vbShowStatesOrderby', 'state_name');
47 + $ordersort = $session->get('vbShowStatesOrdersort', 'ASC');
48 + if (!empty($pvborderby) && in_array($pvborderby, $validorderby)) {
49 + $orderby = $pvborderby;
50 + $session->set('vbShowStatesOrderby', $orderby);
51 + if (!empty($pvbordersort) && in_array($pvbordersort, ['ASC', 'DESC'])) {
52 + $ordersort = $pvbordersort;
53 + $session->set('vbShowStatesOrdersort', $ordersort);
54 + }
55 + }
56 +
57 + $clauses = [];
58 + if (!empty($pidcountry)) {
59 + $clauses[] = "`s`.`id_country`={$pidcountry}";
60 + }
61 + if (!empty($pstatename)) {
62 + $clauses[] = "(`s`.`state_name`=" . $dbo->quote($pstatename) . (strlen($pstatename) == 3 ? " OR `state_3_code`=" . $dbo->quote($pstatename) : "") . (strlen($pstatename) == 2 ? " OR `state_2_code`=" . $dbo->quote($pstatename) : "") . ")";
63 + }
64 + $q = "SELECT SQL_CALC_FOUND_ROWS `s`.*, `c`.`country_name`
65 + FROM `#__vikbooking_states` AS `s`
66 + LEFT JOIN `#__vikbooking_countries` AS `c` ON `s`.`id_country`=`c`.`id`" . (count($clauses) ? " WHERE " . implode(" AND ", $clauses) : "") . " ORDER BY `s`.`{$orderby}` {$ordersort}";
67 + $dbo->setQuery($q, $lim0, $lim);
68 + $dbo->execute();
69 +
70 + /**
71 + * Call assertListQuery() from the View class to make sure the filters set
72 + * do not produce an empty result. This would reset the page in this case.
73 + */
74 + $this->assertListQuery($lim0, $lim);
75 + //
76 +
77 + if ($dbo->getNumRows() > 0) {
78 + $rows = $dbo->loadAssocList();
79 + $dbo->setQuery('SELECT FOUND_ROWS();');
80 + jimport('joomla.html.pagination');
81 + $pageNav = new JPagination( $dbo->loadResult(), $lim0, $lim );
82 + $navbut = "<table align=\"center\"><tr><td>".$pageNav->getListFooter()."</td></tr></table>";
83 + }
84 +
85 + $this->rows = $rows;
86 + $this->lim0 = $lim0;
87 + $this->navbut = $navbut;
88 + $this->orderby = $orderby;
89 + $this->ordersort = $ordersort;
90 +
91 + // Display the template
92 + parent::display($tpl);
93 + }
94 +
95 + /**
96 + * Sets the toolbar
97 + */
98 + protected function addToolBar()
99 + {
100 + JToolBarHelper::title(JText::translate('VBMAINSTATESTITLE'), 'vikbooking');
101 + if (JFactory::getUser()->authorise('core.create', 'com_vikbooking')) {
102 + JToolBarHelper::addNew('states.add', JText::translate('VBMAINPAYMENTSNEW'));
103 + JToolBarHelper::spacer();
104 + }
105 + if (JFactory::getUser()->authorise('core.edit', 'com_vikbooking')) {
106 + JToolBarHelper::editList('states.edit', JText::translate('VBMAINPAYMENTSEDIT'));
107 + JToolBarHelper::spacer();
108 + }
109 + if (JFactory::getUser()->authorise('core.delete', 'com_vikbooking')) {
110 + JToolBarHelper::deleteList(JText::translate('VBDELCONFIRM'), 'states.remove', JText::translate('VBMAINPAYMENTSDEL'));
111 + JToolBarHelper::spacer();
112 + }
113 + }
114 +}