cities.php
3 days ago
coupons.php
3 days ago
customers.php
3 days ago
empgroups.php
3 days ago
employees.php
3 days ago
groups.php
3 days ago
index.html
3 days ago
locations.php
3 days ago
optiongroups.php
3 days ago
options.php
3 days ago
reviews.php
3 days ago
services.php
3 days ago
states.php
3 days ago
employees.php
95 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.import.object'); |
| 15 | |
| 16 | /** |
| 17 | * Class used to handle an import event for the EMPLOYEES. |
| 18 | * |
| 19 | * @see ImportObject |
| 20 | * @since 1.7.3 |
| 21 | */ |
| 22 | class ImportObjectEmployees extends ImportObject |
| 23 | { |
| 24 | /** |
| 25 | * Builds the base query to export all the records. |
| 26 | * @since 1.7 $app and $dbo are now included within the $options argument. |
| 27 | * |
| 28 | * @param JObject $options A registry of export options. |
| 29 | * @param string $alias The table alias. |
| 30 | * |
| 31 | * @return mixed The query builder object. |
| 32 | * |
| 33 | * @uses getColumns() |
| 34 | * @uses getTable() |
| 35 | * @uses getPrimaryKey() |
| 36 | */ |
| 37 | protected function buildExportQuery($options, $alias = 'e') |
| 38 | { |
| 39 | $app = $options->get('app'); |
| 40 | $dbo = $options->get('dbo'); |
| 41 | |
| 42 | $filters = array(); |
| 43 | $filters['keys'] = $app->getUserStateFromRequest('vapemployees.keys', 'keys', '', 'string'); |
| 44 | $filters['status'] = $app->getUserStateFromRequest('vapemployees.status', 'status', '', 'string'); |
| 45 | $filters['id_group'] = $app->getUserStateFromRequest('vapemployees.group', 'id_group', -1, 'int'); |
| 46 | |
| 47 | $q = parent::buildExportQuery($options, $alias); |
| 48 | |
| 49 | // init where to prevent errors with andWhere search |
| 50 | $q->where(1); |
| 51 | |
| 52 | /** |
| 53 | * Added status filter. |
| 54 | * |
| 55 | * @since 1.7 |
| 56 | */ |
| 57 | if (strlen($filters['status'])) |
| 58 | { |
| 59 | $q->where($dbo->qn('e.listable') . ' = ' . (int) $filters['status']); |
| 60 | } |
| 61 | |
| 62 | if ($filters['id_group'] != -1) |
| 63 | { |
| 64 | $cmp = $filters['id_group'] == 0 ? '<=' : '='; |
| 65 | |
| 66 | $q->where($dbo->qn('e.id_group') . ' ' . $cmp . ' ' . $filters['id_group']); |
| 67 | } |
| 68 | |
| 69 | if (strlen($filters['keys'])) |
| 70 | { |
| 71 | $key = $dbo->q("%{$filters['keys']}%"); |
| 72 | |
| 73 | $where = array( |
| 74 | $dbo->qn('e.firstname') . ' LIKE ' . $key, |
| 75 | $dbo->qn('e.lastname') . ' LIKE ' . $key, |
| 76 | $dbo->qn('e.email') . ' LIKE ' . $key, |
| 77 | ); |
| 78 | |
| 79 | $sprintf = 'CONCAT_WS(\' \', %s, %s) LIKE %s'; |
| 80 | |
| 81 | /** |
| 82 | * Search also by full name (first + last and last + first). |
| 83 | * |
| 84 | * @since 1.7 |
| 85 | */ |
| 86 | $where[] = sprintf($sprintf, $dbo->qn('e.firstname'), $dbo->qn('e.lastname'), $key); |
| 87 | $where[] = sprintf($sprintf, $dbo->qn('e.lastname'), $dbo->qn('e.firstname'), $key); |
| 88 | |
| 89 | $q->andWhere($where, 'OR'); |
| 90 | } |
| 91 | |
| 92 | return $q; |
| 93 | } |
| 94 | } |
| 95 |