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 / empcustfields.php
vikappointments / site / models Last commit date
allorders.php 1 day ago calendarweek.php 1 day ago cart.php 1 day ago confirmapp.php 1 day ago empaccountstat.php 1 day ago empattachser.php 1 day ago empcoupons.php 1 day ago empcustfields.php 1 day ago empeditcoupon.php 1 day ago empeditcustfield.php 1 day ago empeditlocation.php 1 day ago empeditpay.php 1 day ago empeditprofile.php 1 day ago empeditservice.php 1 day ago empeditwdays.php 1 day ago emplocations.php 1 day ago emplocwdays.php 1 day ago emplogin.php 1 day ago employeesearch.php 1 day ago employeeslist.php 1 day ago empmanres.php 1 day ago emppaylist.php 1 day ago empserviceslist.php 1 day ago empsettingsman.php 1 day ago empsubscrcart.php 1 day ago empsubscrhistory.php 1 day ago empsubscrorder.php 1 day ago empwdays.php 1 day ago index.html 1 day ago packages.php 1 day ago packagescart.php 1 day ago packagesconfirm.php 1 day ago packorders.php 1 day ago servicesearch.php 1 day ago serviceslist.php 1 day ago subscrcart.php 1 day ago subscrhistory.php 1 day ago subscrpayment.php 1 day ago
empcustfields.php
123 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 custom fields list view model.
18 *
19 * @since 1.7
20 */
21 class VikAppointmentsModelEmpcustfields 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 fields 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 fields.
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 $q = $dbo->getQuery(true)
63 ->select('SQL_CALC_FOUND_ROWS f.*')
64 ->from($dbo->qn('#__vikappointments_custfields', 'f'))
65 ->where($dbo->qn('f.id_employee') . ' = ' . $auth->id)
66 ->order($dbo->qn('f.ordering') . ' ASC');
67
68 $dbo->setQuery($q, $options['start'], $options['limit']);
69 $rows = $dbo->loadObjectList();
70
71 if ($rows)
72 {
73 // fetch pagination
74 $this->getPagination($filters, $options);
75 }
76
77 return $rows;
78 }
79
80 /**
81 * Returns the list pagination.
82 *
83 * @param array $filters An array of filters.
84 * @param array $options An array of options.
85 *
86 * @return JPagination
87 */
88 public function getPagination(array $filters = array(), array $options = array())
89 {
90 if (!$this->pagination)
91 {
92 jimport('joomla.html.pagination');
93 $dbo = JFactory::getDbo();
94 $dbo->setQuery('SELECT FOUND_ROWS();');
95 $this->total = (int) $dbo->loadResult();
96
97 $this->pagination = new JPagination($this->total, $options['start'], $options['limit']);
98
99 foreach ($filters as $k => $v)
100 {
101 // append only filters that own a value as it doesn't
102 // make sense to populate the URL using empty variables
103 if ($v)
104 {
105 $this->pagination->setAdditionalUrlParam($k, $v);
106 }
107 }
108 }
109
110 return $this->pagination;
111 }
112
113 /**
114 * Returns the total number of employees matching the search query.
115 *
116 * @return integer
117 */
118 public function getTotal()
119 {
120 return $this->total;
121 }
122 }
123