PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.4
VikBooking Hotel Booking Engine & PMS v1.6.4
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 / modules / mod_vikbooking_currencyconverter / tmpl / default.php

default.php in VikBooking Hotel Booking Engine & PMS 1.6.4, at modules/mod_vikbooking_currencyconverter/tmpl/default.php

151 lines 5.0 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 mod_vikbooking_currencyconverter
5 * @author Alessio Gaggii - E4J s.r.l
6 * @copyright Copyright (C) 2018 E4J s.r.l. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 $session = JFactory::getSession();
15 $last_lang = $session->get('vboLastCurrency', '');
16
17 /**
18 * The currency to convert to, can also be injected via query string.
19 *
20 * @since 1.15.0 (J) - 1.5.0 (WP)
21 */
22 $req_currency = JFactory::getApplication()->input->getString('user_currency', '');
23 if (!empty($req_currency) && empty($last_lang)) {
24 foreach ($currencies as $cur) {
25 $three_code = substr($cur, 0, 3);
26 if ($req_currency == $three_code) {
27 // user currency is supported, force it to be used for conversion
28 $last_lang = $req_currency;
29 break;
30 }
31 }
32 }
33
34 $document = JFactory::getDocument();
35 $document->addStyleSheet($baseurl.'modules/mod_vikbooking_currencyconverter/mod_vikbooking_currencyconverter.css');
36
37 $active_suff = empty($last_lang) ? $def_currency : $last_lang;
38
39 ?>
40 <script type="text/javascript">
41 var sendprices = new Array();
42 var vbcurconvbasepath = '<?php echo $baseurl.'modules/mod_vikbooking_currencyconverter/images/flags/'; ?>';
43 var vbcurconvbaseflag = '<?php echo $baseurl.'modules/mod_vikbooking_currencyconverter/images/flags/'.$active_suff.'.png'; ?>';
44 var fromCurrency = '<?php echo $def_currency; ?>';
45 var fromSymbol;
46 var pricestaken = 0;
47 jQuery(document).ready(function() {
48 if (jQuery(".vbo_price").length > 0) {
49 jQuery(".vbo_price").each(function() {
50 sendprices.push(jQuery(this).text());
51 });
52 pricestaken = 1;
53 }
54 if (jQuery(".vbo_currency").length > 0) {
55 fromSymbol = jQuery(".vbo_currency").first().html();
56 }
57 <?php
58 if (!empty($last_lang) && $last_lang != $def_currency) {
59 ?>
60 if (jQuery(".vbo_price").length > 0) {
61 vboConvertCurrency('<?php echo $last_lang; ?>');
62 }
63 <?php
64 }
65 ?>
66 });
67 function vboConvertCurrency(toCurrency) {
68 if (sendprices.length > 0) {
69 jQuery(".vbo_currency").text(toCurrency);
70 jQuery(".vbo_price").text("").addClass("vbo_converting");
71 var modvbocurconvax = jQuery.ajax({
72 type: "POST",
73 url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=currencyconverter', false); ?>",
74 data: {prices: sendprices, fromsymbol: fromSymbol, fromcurrency: fromCurrency, tocurrency: toCurrency, tmpl: "component"}
75 }).done(function(resp) {
76 jQuery(".vbo_price").removeClass("vbo_converting");
77 var convobj = JSON.parse(resp);
78 if (convobj.hasOwnProperty("error")) {
79 alert(convobj.error);
80 vboUndoConversion();
81 } else {
82 jQuery(".vbo_currency").html(convobj[0].symbol);
83 jQuery(".vbo_price").each(function(i) {
84 jQuery(this).text(convobj[i].price);
85 });
86 if (jQuery('.vbcurconv-flag').length) {
87 jQuery(".vbcurconv-flag-img").attr("src", vbcurconvbasepath+toCurrency+".png");
88 jQuery(".vbcurconv-flag-img").attr("alt", toCurrency);
89 jQuery(".vbcurconv-flag-img").attr("title", toCurrency);
90 jQuery(".vbcurconv-flag-symb").html(convobj[0].symbol);
91 }
92 }
93 }).fail(function(){
94 jQuery(".vbo_price").removeClass("vbo_converting");
95 vboUndoConversion();
96 });
97 } else {
98 jQuery(".modcurconvsel").val("<?php echo $active_suff; ?>");
99 }
100 }
101 function vboUndoConversion() {
102 jQuery(".vbo_currency").text(fromSymbol);
103 jQuery(".vbo_price").each(function(i) {
104 jQuery(this).text(sendprices[i]);
105 });
106 if (jQuery('.vbcurconv-flag').length) {
107 jQuery(".vbcurconv-flag-symb").text(fromSymbol);
108 jQuery(".vbcurconv-flag-img").attr("src", vbcurconvbaseflag);
109 jQuery(".vbcurconv-flag-img").attr("alt", fromCurrency);
110 jQuery(".vbcurconv-flag-img").attr("title", fromCurrency);
111 }
112 jQuery(".modcurconvsel").val(fromCurrency);
113 }
114 </script>
115
116 <div class="vbcurconvcontainer">
117 <?php
118 if ((int)$params->get('showflag', '0')) {
119 ?>
120 <div class="vbcurconv-flag">
121 <?php
122 echo '<img class="vbcurconv-flag-img" alt="'.$active_suff.'" title="'.$active_suff.'" src="'.$baseurl.'modules/mod_vikbooking_currencyconverter/images/flags/'.$active_suff.'.png'.'"/>';
123 $active_symb = array_key_exists($active_suff, $currencymap) && isset($currencymap[$active_suff]['symbol']) ? '&#'.$currencymap[$active_suff]['symbol'].';' : '';
124 ?>
125 <span class="vbcurconv-flag-symb"><?php echo $active_symb; ?></span>
126 </div>
127 <?php
128 }
129 ?>
130 <div class="vbcurconv-menu">
131 <select class="modcurconvsel" name="mod_vikbooking_currencyconverter" onchange="vboConvertCurrency(this.value);">
132 <?php
133 foreach ($currencies as $cur) {
134 $three_code = substr($cur, 0, 3);
135 $curparts = explode(':', $cur);
136 if ($currencynameformat == 1) {
137 $curname = $three_code;
138 } elseif ($currencynameformat == 2) {
139 $curname = trim($curparts[1]);
140 } else {
141 $curname = trim($curparts[1]).' ('.$three_code.')';
142 }
143 ?>
144 <option value="<?php echo $three_code; ?>"<?php echo ((empty($last_lang) && $three_code == $def_currency) || (!empty($last_lang) && $three_code == $last_lang) ? ' selected="selected"' : ''); ?>><?php echo $curname; ?></option>
145 <?php
146 }
147 ?>
148 </select>
149 </div>
150 </div>
151