PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
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 1.7.3 All 36 releases
vikbooking / admin / helpers / conditionalrules / request_payment.php

request_payment.php in VikBooking Hotel Booking Engine & PMS trunk, at admin/helpers/conditionalrules/request_payment.php

105 lines 3.2 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 "request payment".
15 *
16 * @since 1.17.2 (J) - 1.7.2 (WP)
17 */
18 class VikBookingConditionalRuleRequestPayment 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_AMOUNT_PAYABLE_RQ');
29 $this->ruleDescr = sprintf('%s (%s)', JText::translate('VBO_AMOUNT_PAYABLE_RQ'), JText::translate('VBO_AMOUNT_PAYABLE'));
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('VBO_AMOUNT_PAYABLE_RQ'); ?></div>
43 <div class="vbo-param-setting">
44 <?php echo $this->vbo_app->printYesNoButtons($this->inputName('has_amount_payable'), JText::translate('VBYES'), JText::translate('VBNO'), (int)$this->getParam('has_amount_payable', 0), 1, 0); ?>
45 <span class="vbo-param-setting-comment">Use the tag <strong onclick="vboCtrRequestPaymentAddContentEditor('{payment_requested_amount}');" style="cursor: pointer;">{payment_requested_amount}</strong> if you would like to display the actual <i>amount payable</i> in your text.</span>
46 </div>
47 </div>
48
49 <script type="text/javascript">
50 function vboCtrRequestPaymentAddContentEditor(str) {
51 if (!str) {
52 return;
53 }
54
55 try {
56 // "msg" is the name of the WYSIWYG editor of the conditional text
57 Joomla.editors.instances.msg.replaceSelection(str);
58 } catch(e) {
59 // do nothing
60 }
61 }
62 </script>
63 <?php
64 }
65
66 /**
67 * Tells whether the rule is compliant.
68 *
69 * @return bool True on success, false otherwise.
70 */
71 public function isCompliant()
72 {
73 $has_amount_payable = (bool)$this->getParam('has_amount_payable', 0);
74 if (!$has_amount_payable) {
75 return true;
76 }
77
78 return $this->getPropVal('booking', 'payable', 0) > 0;
79 }
80
81 /**
82 * Allows to manipulate the message of the conditional text with dynamic contents.
83 *
84 * @override
85 *
86 * @param string $msg the current conditional text message.
87 *
88 * @return string the manipulated conditional text message.
89 */
90 public function manipulateMessage($msg)
91 {
92 // check if the special and internal tag was used
93 if (strpos($msg, '{payment_requested_amount}') !== false) {
94 // build the amount payable string
95 $amout_payable_str = sprintf('%s %s', VikBooking::getCurrencySymb(), VikBooking::numberFormat($this->getPropVal('booking', 'payable', 0)));
96
97 // exact placeholder tag found, so use the plain mark string
98 $msg = str_replace('{payment_requested_amount}', $amout_payable_str, $msg);
99 }
100
101 // return the eventually manipulated message
102 return $msg;
103 }
104 }
105