PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.8
VikBooking Hotel Booking Engine & PMS v1.8.8
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / admin / helpers / conditionalrules / days_to_arrival.php

days_to_arrival.php in VikBooking Hotel Booking Engine & PMS 1.8.8, at admin/helpers/conditionalrules/days_to_arrival.php

75 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage com_vikbooking
5 * @author Alessio Gaggii - e4j - Extensionsforjoomla.com
6 * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 * @link https://vikwp.com
9 */
10
11 defined('ABSPATH') or die('No script kiddies please!');
12
13 /**
14 * Class handler for conditional rule "days to arrival".
15 *
16 * @since 1.4.0
17 */
18 class VikBookingConditionalRuleDaysToArrival extends VikBookingConditionalRule
19 {
20 /**
21 * Class constructor will define the rule name, description and identifier.
22 */
23 public function __construct()
24 {
25 // call parent constructor
26 parent::__construct();
27
28 $this->ruleName = JText::translate('VBO_CONDTEXT_RULE_DTA');
29 $this->ruleDescr = JText::translate('VBO_CONDTEXT_RULE_DTA_DESCR');
30 $this->ruleId = basename(__FILE__);
31 }
32
33 /**
34 * Displays the rule parameters.
35 *
36 * @return void
37 */
38 public function renderParams()
39 {
40 ?>
41 <div class="vbo-param-container">
42 <div class="vbo-param-label"><?php echo JText::translate('VBCONFIGSEARCHPMAXDATEDAYS'); ?></div>
43 <div class="vbo-param-setting">
44 <input type="number" name="<?php echo $this->inputName('days'); ?>" value="<?php echo $this->getParam('days', ''); ?>" min="0" />
45 </div>
46 </div>
47 <?php
48 }
49
50 /**
51 * Tells whether the rule is compliant.
52 *
53 * @return bool True on success, false otherwise.
54 */
55 public function isCompliant()
56 {
57 $book_ts = $this->getPropVal('booking', 'ts', 0);
58 $book_in = $this->getPropVal('booking', 'checkin', 0);
59
60 $dta = (int)$this->getParam('days', 0);
61
62 $from_dt = new DateTime(date('Y-m-d H:i:s', $book_ts));
63 $to_dt = new DateTime(date('Y-m-d H:i:s', $book_in));
64
65 $dates_diff = $from_dt->diff($to_dt);
66 if (!$dates_diff || $dates_diff->days === false) {
67 return false;
68 }
69
70 return ($dta <= $dates_diff->days);
71
72 }
73
74 }
75