PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / models / empcustfields.php
vikappointments / site / models Last commit date
allorders.php 2 years ago calendarweek.php 1 month ago cart.php 1 month ago confirmapp.php 1 month ago empaccountstat.php 2 years ago empattachser.php 2 years ago empcoupons.php 2 years ago empcustfields.php 2 years ago empeditcoupon.php 3 years ago empeditcustfield.php 3 years ago empeditlocation.php 3 years ago empeditpay.php 3 years ago empeditprofile.php 4 months ago empeditservice.php 3 years ago empeditwdays.php 3 years ago emplocations.php 2 years ago emplocwdays.php 4 years ago emplogin.php 1 month ago employeesearch.php 1 month ago employeeslist.php 1 month ago empmanres.php 2 years ago emppaylist.php 2 years ago empserviceslist.php 2 years ago empsettingsman.php 4 years ago empsubscrcart.php 4 years ago empsubscrhistory.php 2 years ago empsubscrorder.php 4 months ago empwdays.php 2 years ago index.html 4 years ago packages.php 2 years ago packagescart.php 4 years ago packagesconfirm.php 4 months ago packorders.php 2 years ago servicesearch.php 2 years ago serviceslist.php 2 years ago subscrcart.php 2 years ago subscrhistory.php 2 years ago subscrpayment.php 4 months 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