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 / helpers / libraries / import / forms / columns / employee.php
vikappointments / site / helpers / libraries / import / forms / columns Last commit date
city.php 5 days ago country.php 5 days ago currency.php 5 days ago date.php 5 days ago empgroup.php 5 days ago employee.php 5 days ago group.php 5 days ago index.html 5 days ago optiongroup.php 5 days ago service.php 5 days ago state.php 5 days ago user.php 5 days ago
employee.php
75 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 /**
15 * Populate the options array with the existing employees,
16 * in order to support the correct placeholders while
17 * importing and exporting the records.
18 *
19 * @since 1.7
20 */
21 class ImportColumnEmployee extends ImportColumn
22 {
23 /**
24 * Employees cache.
25 *
26 * @var array
27 */
28 private static $employees = null;
29
30 /**
31 * Binds the internal properties with the given array/object.
32 *
33 * @param mixed $data Either an array or an object.
34 *
35 * @return void
36 */
37 protected function setup($data)
38 {
39 // use parent to set up data
40 parent::setup($data);
41
42 foreach (static::getEmployees() as $employee)
43 {
44 // register employee as option
45 $this->options[$employee->id] = $employee->nickname;
46 }
47 }
48
49 /**
50 * Loads a list of available employees.
51 *
52 * @return array
53 */
54 protected static function getEmployees()
55 {
56 // load employees only once
57 if (is_null(static::$employees))
58 {
59 $dbo = JFactory::getDbo();
60
61 $q = $dbo->getQuery(true)
62 ->select($dbo->qn(array('id', 'nickname')))
63 ->from($dbo->qn('#__vikappointments_employee'))
64 ->order($dbo->qn('id') . ' ASC');
65
66 $dbo->setQuery($q);
67
68 // cache employees found
69 static::$employees = $dbo->loadObjectList();
70 }
71
72 return static::$employees;
73 }
74 }
75