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 5 days ago calendarweek.php 5 days ago cart.php 5 days ago confirmapp.php 5 days ago empaccountstat.php 5 days ago empattachser.php 5 days ago empcoupons.php 5 days ago empcustfields.php 5 days ago empeditcoupon.php 5 days ago empeditcustfield.php 5 days ago empeditlocation.php 5 days ago empeditpay.php 5 days ago empeditprofile.php 5 days ago empeditservice.php 5 days ago empeditwdays.php 5 days ago emplocations.php 5 days ago emplocwdays.php 5 days ago emplogin.php 5 days ago employeesearch.php 5 days ago employeeslist.php 5 days ago empmanres.php 5 days ago emppaylist.php 5 days ago empserviceslist.php 5 days ago empsettingsman.php 5 days ago empsubscrcart.php 5 days ago empsubscrhistory.php 5 days ago empsubscrorder.php 5 days ago empwdays.php 5 days ago index.html 5 days ago packages.php 5 days ago packagescart.php 5 days ago packagesconfirm.php 5 days ago packorders.php 5 days ago servicesearch.php 5 days ago serviceslist.php 5 days ago subscrcart.php 5 days ago subscrhistory.php 5 days ago subscrpayment.php 5 days 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