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 / emplocations.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
emplocations.php
94 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 locations list view model.
18 *
19 * @since 1.7
20 */
21 class VikAppointmentsModelEmplocations extends JModelVAP
22 {
23 /**
24 * Loads a list of locations to be displayed within the
25 * employees area view.
26 *
27 * @param array &$filters An array of filters.
28 * @param array &$options An array of options, such as the ordering mode.
29 *
30 * @return array A list of locations.
31 */
32 public function getItems(array &$filters = array(), array &$options = array())
33 {
34 $auth = VAPEmployeeAuth::getInstance();
35
36 if (!$auth->isEmployee())
37 {
38 // raise error in case of no employee
39 throw new Exception(JText::translate('JERROR_ALERTNOAUTHOR'), 403);
40 }
41
42 $dbo = JFactory::getDbo();
43
44 $rows = array();
45
46 $q = $dbo->getQuery(true)
47 ->select('l.*')
48 ->select($dbo->qn(array('c.country_name', 'c.country_2_code', 's.state_name', 's.state_2_code', 'ci.city_name')))
49 ->from($dbo->qn('#__vikappointments_employee_location', 'l'))
50 ->leftjoin($dbo->qn('#__vikappointments_countries', 'c') . ' ON ' . $dbo->qn('c.id') . ' = ' . $dbo->qn('l.id_country'))
51 ->leftjoin($dbo->qn('#__vikappointments_states', 's') . ' ON ' . $dbo->qn('s.id') . ' = ' . $dbo->qn('l.id_state'))
52 ->leftjoin($dbo->qn('#__vikappointments_cities', 'ci') . ' ON ' . $dbo->qn('ci.id') . ' = ' . $dbo->qn('l.id_city'))
53 ->where(array(
54 $dbo->qn('id_employee') . ' = ' . $auth->id,
55 $dbo->qn('id_employee') . ' <= 0',
56 ), 'OR')
57 ->order($dbo->qn('id_employee') . ' DESC');
58
59 $dbo->setQuery($q);
60
61 foreach ($dbo->loadObjectList() as $location)
62 {
63 $components = array();
64
65 // register address first
66 $components[] = $location->address;
67
68 $block = array();
69
70 // register ZIP within 2nd block
71 $block[] = $location->zip;
72
73 // register city within 2nd block
74 $block[] = $location->city_name;
75
76 // register state/province code within 2nd block
77 $block[] = $location->state_2_code;
78
79 // register 2nd block
80 $components[] = implode(' ', array_filter($block));
81
82 // register country code (2 letters)
83 $components[] = $location->country_2_code;
84
85 // join string components
86 $location->text = implode(', ', array_filter($components));
87
88 $rows[] = $location;
89 }
90
91 return $rows;
92 }
93 }
94