| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 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 |
* Wizard report OTRS help instruction. |
| 16 |
* |
| 17 |
* @since 1.18.3 (J) - 1.8.3 (WP) |
| 18 |
*/ |
| 19 |
class VBOHelpWizardDriverReportsItalyOtrs extends VBOHelpWizardInstructionaware |
| 20 |
{ |
| 21 |
use VBOHelpWizardTraitReportConfigurable; |
| 22 |
|
| 23 |
/** |
| 24 |
* Class contructor. |
| 25 |
*/ |
| 26 |
public function __construct() |
| 27 |
{ |
| 28 |
/** |
| 29 |
* @see VBOHelpWizardTraitReportConfigurable::$reportId |
| 30 |
*/ |
| 31 |
$this->reportId = 'istat_sicilia_otrs'; |
| 32 |
|
| 33 |
/** |
| 34 |
* @see VBOHelpWizardTraitReportConfigurable::$autoExportFormat |
| 35 |
*/ |
| 36 |
$this->autoExportFormat = 'registerCheckins'; |
| 37 |
|
| 38 |
/** |
| 39 |
* @see VBOHelpWizardTraitReportConfigurable::$autoExportPayload |
| 40 |
*/ |
| 41 |
$this->autoExportPayload = [ |
| 42 |
'fromdate' => '{Y-m-d}', |
| 43 |
'listings' => [], |
| 44 |
'_reportAction' => 'registerCheckins', |
| 45 |
]; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* @inheritDoc |
| 50 |
*/ |
| 51 |
public function getID() |
| 52 |
{ |
| 53 |
return 'reports.italy.otrs'; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* @inheritDoc |
| 58 |
*/ |
| 59 |
public function getTitle() |
| 60 |
{ |
| 61 |
return 'Osservatorio Turistico Regione Sicilia (OTRS)'; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* @inheritDoc |
| 66 |
*/ |
| 67 |
public function getIcon() |
| 68 |
{ |
| 69 |
return VikBookingIcons::i('id-card'); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* @inheritDoc |
| 74 |
*/ |
| 75 |
public function getPriority() |
| 76 |
{ |
| 77 |
return 998; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* @inheritDoc |
| 82 |
*/ |
| 83 |
public function isSupported() |
| 84 |
{ |
| 85 |
$config = VBOFactory::getConfig(); |
| 86 |
|
| 87 |
// check whether the main country is Italy and the main province belongs to Sicily |
| 88 |
return $config->get('maincountry') === 'IT' && in_array($config->get('mainstate'), [ |
| 89 |
'AG', // Agrigento |
| 90 |
'CL', // Caltanissetta |
| 91 |
'CT', // Catania |
| 92 |
'EN', // Enna |
| 93 |
'ME', // Messina |
| 94 |
'PA', // Palermo |
| 95 |
'RG', // Ragusa |
| 96 |
'SR', // Siracusa |
| 97 |
'TP', // Trapani |
| 98 |
]); |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* @inheritDoc |
| 103 |
* |
| 104 |
* @see VBOHelpWizardTraitReportConfigurable::checkSettingsConfigured() |
| 105 |
*/ |
| 106 |
protected function checkSettingsConfigured() |
| 107 |
{ |
| 108 |
$settings = VBOFactory::getConfig()->getArray('report_settings_istat_sicilia_otrs', []); |
| 109 |
|
| 110 |
return !empty($settings['hotelcode']) && !empty($settings['userid']) && !empty($settings['password']); |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* @inheritDoc |
| 115 |
* |
| 116 |
* @see VBOHelpWizardTraitReportConfigurable::postflight() |
| 117 |
*/ |
| 118 |
protected function postflight() |
| 119 |
{ |
| 120 |
$payload = $this->autoExportPayload; |
| 121 |
$payload['_reportAction'] = 'registerCheckouts'; |
| 122 |
|
| 123 |
$this->saveAutoExport($payload['_reportAction'], $payload); |
| 124 |
|
| 125 |
$payload = $this->autoExportPayload; |
| 126 |
$payload['_reportAction'] = 'registerEndDay'; |
| 127 |
$payload['_reportData'] = [ |
| 128 |
'end_date' => '{Y-m-d}', |
| 129 |
]; |
| 130 |
|
| 131 |
$this->saveAutoExport($payload['_reportAction'], $payload); |
| 132 |
} |
| 133 |
} |
| 134 |
|