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
cities.php
90 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 CITIES. |
| 18 | * |
| 19 | * @see ImportObject |
| 20 | * @since 1.6 |
| 21 | */ |
| 22 | class ImportObjectCities extends ImportObject |
| 23 | { |
| 24 | /** |
| 25 | * Overloaded bind function. |
| 26 | * |
| 27 | * @param object &$data The object of the record to import. |
| 28 | * @param array $args Associative list of additional parameters. |
| 29 | * |
| 30 | * @return boolean True if the record should be imported, otherwise false. |
| 31 | */ |
| 32 | protected function bind(&$data, array $args = array()) |
| 33 | { |
| 34 | // make sure the state ID is set in the arguments |
| 35 | if (!isset($args['id_state'])) |
| 36 | { |
| 37 | return false; |
| 38 | } |
| 39 | |
| 40 | $data->id_state = $args['id_state']; |
| 41 | |
| 42 | // call parent method to check the data integrity |
| 43 | return parent::bind($data); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Builds the base query to export all the records. |
| 48 | * @since 1.7 $app and $dbo are now included within the $options argument. |
| 49 | * |
| 50 | * @param JObject $options A registry of export options. |
| 51 | * @param string $alias The table alias. |
| 52 | * |
| 53 | * @return mixed The query builder object. |
| 54 | * |
| 55 | * @uses getColumns() |
| 56 | * @uses getTable() |
| 57 | * @uses getPrimaryKey() |
| 58 | */ |
| 59 | protected function buildExportQuery($options, $alias = 'c') |
| 60 | { |
| 61 | $app = $options->get('app'); |
| 62 | $dbo = $options->get('dbo'); |
| 63 | |
| 64 | // recover state ID from the request |
| 65 | $id_state = $app->input->getUint('id_state', 0); |
| 66 | |
| 67 | $filters = array(); |
| 68 | $filters['keys'] = $app->getUserStateFromRequest('vapcities[' . $id_state . '].keys', 'keys', '', 'string'); |
| 69 | $filters['status'] = $app->getUserStateFromRequest('vapcities[' . $id_state . '].status', 'status', '', 'string'); |
| 70 | |
| 71 | $q = parent::buildExportQuery($options, $alias); |
| 72 | |
| 73 | $q->where($dbo->qn('c.id_state') . ' = ' . $id_state); |
| 74 | |
| 75 | // search filter |
| 76 | if (strlen($filters['keys'])) |
| 77 | { |
| 78 | $q->where($dbo->qn('c.city_name') . ' LIKE ' . $dbo->q("%{$filters['keys']}%")); |
| 79 | } |
| 80 | |
| 81 | // status filter |
| 82 | if (strlen($filters['status'])) |
| 83 | { |
| 84 | $q->where($dbo->qn('c.published') . ' = ' . (int) $filters['status']); |
| 85 | } |
| 86 | |
| 87 | return $q; |
| 88 | } |
| 89 | } |
| 90 |