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 / site / models / empserviceslist.php
vikappointments / site / models Last commit date
allorders.php 2 days ago calendarweek.php 2 days ago cart.php 2 days ago confirmapp.php 2 days ago empaccountstat.php 2 days ago empattachser.php 2 days ago empcoupons.php 2 days ago empcustfields.php 2 days ago empeditcoupon.php 2 days ago empeditcustfield.php 2 days ago empeditlocation.php 2 days ago empeditpay.php 2 days ago empeditprofile.php 2 days ago empeditservice.php 2 days ago empeditwdays.php 2 days ago emplocations.php 2 days ago emplocwdays.php 2 days ago emplogin.php 2 days ago employeesearch.php 2 days ago employeeslist.php 2 days ago empmanres.php 2 days ago emppaylist.php 2 days ago empserviceslist.php 2 days ago empsettingsman.php 2 days ago empsubscrcart.php 2 days ago empsubscrhistory.php 2 days ago empsubscrorder.php 2 days ago empwdays.php 2 days ago index.html 2 days ago packages.php 2 days ago packagescart.php 2 days ago packagesconfirm.php 2 days ago packorders.php 2 days ago servicesearch.php 2 days ago serviceslist.php 2 days ago subscrcart.php 2 days ago subscrhistory.php 2 days ago subscrpayment.php 2 days ago
empserviceslist.php
133 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 VAPLoader::import('libraries.mvc.model');
15
16 /**
17 * VikAppointments employee area services list view model.
18 *
19 * @since 1.7
20 */
21 class VikAppointmentsModelEmpserviceslist extends JModelVAP
22 {
23 /**
24 * The list view pagination object.
25 *
26 * @var JPagination
27 */
28 protected $pagination = null;
29
30 /**
31 * The total number of fetched rows.
32 *
33 * @var integer
34 */
35 protected $total = 0;
36
37 /**
38 * Loads a list of services to be displayed within the
39 * employees area view.
40 *
41 * @param array &$filters An array of filters.
42 * @param array &$options An array of options, such as the ordering mode.
43 *
44 * @return array A list of services.
45 */
46 public function getItems(array &$filters = array(), array &$options = array())
47 {
48 // always reset pagination and total count
49 $this->pagination = null;
50 $this->total = 0;
51
52 $auth = VAPEmployeeAuth::getInstance();
53
54 if (!$auth->isEmployee())
55 {
56 // raise error in case of no employee
57 throw new Exception(JText::translate('JERROR_ALERTNOAUTHOR'), 403);
58 }
59
60 $dbo = JFactory::getDbo();
61
62 $rows = array();
63
64 $q = $dbo->getQuery(true)
65 ->select('SQL_CALC_FOUND_ROWS s.*')
66 ->select(array(
67 $dbo->qn('a.rate'),
68 $dbo->qn('a.duration', 'override_duration'),
69 $dbo->qn('a.sleep', 'override_sleep'),
70 $dbo->qn('g.name', 'group_name'),
71 ))
72 ->from($dbo->qn('#__vikappointments_service', 's'))
73 ->leftjoin($dbo->qn('#__vikappointments_ser_emp_assoc', 'a') . ' ON ' . $dbo->qn('s.id') . ' = ' . $dbo->qn('a.id_service'))
74 ->leftjoin($dbo->qn('#__vikappointments_group', 'g') . ' ON ' . $dbo->qn('g.id') . ' = ' . $dbo->qn('s.id_group'))
75 ->where($dbo->qn('a.id_employee') . ' = ' . $auth->id)
76 ->order($dbo->qn('s.ordering') . ' ASC');
77
78 $dbo->setQuery($q, $options['start'], $options['limit']);
79 $rows = $dbo->loadObjectList();
80
81 if ($rows)
82 {
83 // fetch pagination
84 $this->getPagination($filters, $options);
85 }
86
87 return $rows;
88 }
89
90 /**
91 * Returns the list pagination.
92 *
93 * @param array $filters An array of filters.
94 * @param array $options An array of options.
95 *
96 * @return JPagination
97 */
98 public function getPagination(array $filters = array(), array $options = array())
99 {
100 if (!$this->pagination)
101 {
102 jimport('joomla.html.pagination');
103 $dbo = JFactory::getDbo();
104 $dbo->setQuery('SELECT FOUND_ROWS();');
105 $this->total = (int) $dbo->loadResult();
106
107 $this->pagination = new JPagination($this->total, $options['start'], $options['limit']);
108
109 foreach ($filters as $k => $v)
110 {
111 // append only filters that own a value as it doesn't
112 // make sense to populate the URL using empty variables
113 if ($v)
114 {
115 $this->pagination->setAdditionalUrlParam($k, $v);
116 }
117 }
118 }
119
120 return $this->pagination;
121 }
122
123 /**
124 * Returns the total number of employees matching the search query.
125 *
126 * @return integer
127 */
128 public function getTotal()
129 {
130 return $this->total;
131 }
132 }
133