| 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 |
$order = $this->row; |
| 14 |
$customer = $this->customer; |
| 15 |
|
| 16 |
$document = JFactory::getDocument(); |
| 17 |
$document->addScript(VBO_SITE_URI.'resources/signature_pad.js'); |
| 18 |
$currencysymb = VikBooking::getCurrencySymb(); |
| 19 |
$nowdf = VikBooking::getDateFormat(true); |
| 20 |
if ($nowdf == "%d/%m/%Y") { |
| 21 |
$df = 'd/m/Y'; |
| 22 |
} elseif ($nowdf == "%m/%d/%Y") { |
| 23 |
$df = 'm/d/Y'; |
| 24 |
} else { |
| 25 |
$df = 'Y/m/d'; |
| 26 |
} |
| 27 |
$datesep = VikBooking::getDateSeparator(true); |
| 28 |
$tmpl = VikRequest::getVar('tmpl'); |
| 29 |
$prefreshing = VikRequest::getInt('refreshing', '', 'request'); |
| 30 |
if (count($customer) && !empty($customer['signature'])) { |
| 31 |
//the signature exists, stop any kind of refresh |
| 32 |
$prefreshing = 0; |
| 33 |
} |
| 34 |
$now_info = getdate(); |
| 35 |
$today_midnight = mktime(0, 0, 0, $now_info['mon'], $now_info['mday'], $now_info['year']); |
| 36 |
$colortags = VikBooking::loadBookingsColorTags(); |
| 37 |
$otachannel = ''; |
| 38 |
$otachannel_name = ''; |
| 39 |
$otachannel_bid = ''; |
| 40 |
$otacurrency = ''; |
| 41 |
if (!empty($order['channel'])) { |
| 42 |
$channelparts = explode('_', $order['channel']); |
| 43 |
$otachannel = array_key_exists(1, $channelparts) && strlen($channelparts[1]) > 0 ? $channelparts[1] : ucwords($channelparts[0]); |
| 44 |
$otachannel_name = $otachannel; |
| 45 |
$otachannel_bid = $order['idorderota']; |
| 46 |
if (strstr($otachannel, '.') !== false) { |
| 47 |
$otaccparts = explode('.', $otachannel); |
| 48 |
$otachannel = $otaccparts[0]; |
| 49 |
} |
| 50 |
$otacurrency = strlen($order['chcurrency']) > 0 ? $order['chcurrency'] : ''; |
| 51 |
} |
| 52 |
?> |
| 53 |
<div class="vbo-info-overlay-block"> |
| 54 |
<a class="vbo-info-overlay-close" href="javascript: void(0);"></a> |
| 55 |
<div class="vbo-info-overlay-content"> |
| 56 |
<h3 id="vbo-overlay-title"></h3> |
| 57 |
<div class="vbo-overlay-checkin-body"></div> |
| 58 |
</div> |
| 59 |
</div> |
| 60 |
|
| 61 |
<form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm"> |
| 62 |
<?php |
| 63 |
if ($tmpl == 'component') { |
| 64 |
//back button |
| 65 |
?> |
| 66 |
<a class="btn pull-left" href="index.php?option=com_vikbooking&task=bookingcheckin&cid[]=<?php echo $order['id']; ?>&tmpl=component"><i class="vboicn-undo"></i> <?php echo JText::translate('VBBACK'); ?></a> |
| 67 |
<?php |
| 68 |
} |
| 69 |
?> |
| 70 |
<div class="vbo-bookdet-container"> |
| 71 |
<div class="vbo-bookdet-wrap"> |
| 72 |
<div class="vbo-bookdet-head"> |
| 73 |
<span>ID</span> |
| 74 |
<?php |
| 75 |
if (!empty($order['adminnotes'])) { |
| 76 |
?> |
| 77 |
<i class="vboicn-info icn-bigger icn-nomargin icn-float-left icn-clickable" onclick="vboUpdateModal('<?php echo addslashes(JText::translate('VBADMINNOTESTOGGLE')); ?>', '.adminnotes', true);"></i> |
| 78 |
<?php |
| 79 |
} |
| 80 |
?> |
| 81 |
</div> |
| 82 |
<div class="vbo-bookdet-foot"> |
| 83 |
<span><a href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $order['id']; ?>" target="_blank"><?php echo $order['id']; ?></a></span> |
| 84 |
</div> |
| 85 |
</div> |
| 86 |
<?php |
| 87 |
if (!empty($order['channel'])) { |
| 88 |
?> |
| 89 |
<div class="vbo-bookdet-wrap"> |
| 90 |
<div class="vbo-bookdet-head"> |
| 91 |
<?php echo $otachannel; ?> |
| 92 |
</div> |
| 93 |
<div class="vbo-bookdet-foot"> |
| 94 |
<span>ID <?php echo $otachannel_bid; ?></span> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
<?php |
| 98 |
} |
| 99 |
?> |
| 100 |
<div class="vbo-bookdet-wrap"> |
| 101 |
<div class="vbo-bookdet-head"> |
| 102 |
<span><?php echo JText::translate('VBEDITORDERONE'); ?></span> |
| 103 |
</div> |
| 104 |
<div class="vbo-bookdet-foot"> |
| 105 |
<?php echo date(str_replace("/", $datesep, $df).' H:i', $order['ts']); ?> |
| 106 |
</div> |
| 107 |
</div> |
| 108 |
<?php |
| 109 |
if (count($customer)) { |
| 110 |
?> |
| 111 |
<div class="vbo-bookdet-wrap"> |
| 112 |
<div class="vbo-bookdet-head"> |
| 113 |
<span><?php echo JText::translate('VBCUSTOMERNOMINATIVE'); ?></span> |
| 114 |
<?php |
| 115 |
if (!empty($customer['notes'])) { |
| 116 |
?> |
| 117 |
<i class="vboicn-info icn-bigger icn-nomargin icn-float-left icn-clickable" onclick="vboUpdateModal('<?php echo addslashes(JText::translate('VBCUSTOMERNOTES')); ?>', '.customer_notes', true);"></i> |
| 118 |
<?php |
| 119 |
} |
| 120 |
?> |
| 121 |
</div> |
| 122 |
<div class="vbo-bookdet-foot"> |
| 123 |
<?php echo (isset($customer['country_img']) ? $customer['country_img'].' ' : '').ltrim($customer['first_name'].' '.$customer['last_name']); ?> |
| 124 |
</div> |
| 125 |
</div> |
| 126 |
<?php |
| 127 |
} |
| 128 |
?> |
| 129 |
<div class="vbo-bookdet-wrap"> |
| 130 |
<div class="vbo-bookdet-head"> |
| 131 |
<span><?php echo JText::translate('VBEDITORDERROOMSNUM'); ?></span> |
| 132 |
</div> |
| 133 |
<div class="vbo-bookdet-foot"> |
| 134 |
<?php echo $order['roomsnum']; ?> |
| 135 |
</div> |
| 136 |
</div> |
| 137 |
<div class="vbo-bookdet-wrap"> |
| 138 |
<div class="vbo-bookdet-head"> |
| 139 |
<span><?php echo JText::translate('VBEDITORDERFOUR'); ?></span> |
| 140 |
</div> |
| 141 |
<div class="vbo-bookdet-foot"> |
| 142 |
<?php echo $order['days']; ?> |
| 143 |
</div> |
| 144 |
</div> |
| 145 |
<div class="vbo-bookdet-wrap"> |
| 146 |
<div class="vbo-bookdet-head"> |
| 147 |
<span><?php echo JText::translate('VBEDITORDERFIVE'); ?></span> |
| 148 |
<?php |
| 149 |
if (!empty($customer['comments'])) { |
| 150 |
?> |
| 151 |
<i class="vboicn-info icn-bigger icn-nomargin icn-float-left icn-clickable" onclick="vboUpdateModal('<?php echo addslashes(JText::translate('VBOTOGGLECHECKINNOTES')); ?>', '.comments', true);"></i> |
| 152 |
<?php |
| 153 |
} |
| 154 |
?> |
| 155 |
</div> |
| 156 |
<div class="vbo-bookdet-foot"> |
| 157 |
<?php |
| 158 |
$checkin_info = getdate($order['checkin']); |
| 159 |
$short_wday = JText::translate('VB'.strtoupper(substr($checkin_info['weekday'], 0, 3))); |
| 160 |
?> |
| 161 |
<?php echo $short_wday.', '.date(str_replace("/", $datesep, $df).' H:i', $order['checkin']); ?> |
| 162 |
</div> |
| 163 |
</div> |
| 164 |
<div class="vbo-bookdet-wrap"> |
| 165 |
<div class="vbo-bookdet-head"> |
| 166 |
<span><?php echo JText::translate('VBEDITORDERSIX'); ?></span> |
| 167 |
</div> |
| 168 |
<div class="vbo-bookdet-foot"> |
| 169 |
<?php |
| 170 |
$checkout_info = getdate($order['checkout']); |
| 171 |
$short_wday = JText::translate('VB'.strtoupper(substr($checkout_info['weekday'], 0, 3))); |
| 172 |
?> |
| 173 |
<?php echo $short_wday.', '.date(str_replace("/", $datesep, $df).' H:i', $order['checkout']); ?> |
| 174 |
</div> |
| 175 |
</div> |
| 176 |
<div class="vbo-bookdet-wrap"> |
| 177 |
<div class="vbo-bookdet-head"> |
| 178 |
<span><?php echo JText::translate('VBEDITORDERNINE'); ?></span> |
| 179 |
</div> |
| 180 |
<div class="vbo-bookdet-foot"> |
| 181 |
<?php |
| 182 |
$bcolortag = VikBooking::applyBookingColorTag($order, $colortags); |
| 183 |
$usectag = ''; |
| 184 |
if (count($bcolortag) > 0) { |
| 185 |
$bcolortag['name'] = JText::translate($bcolortag['name']); |
| 186 |
$usectag = '<span class="vbo-colortag-circle hasTooltip" style="background-color: '.$bcolortag['color'].';" title="'.htmlspecialchars($bcolortag['name']).'"></span> '; |
| 187 |
} |
| 188 |
?> |
| 189 |
<?php echo $usectag.(strlen($otacurrency) > 0 ? '('.$otacurrency.') '.$currencysymb : $currencysymb); ?> <?php echo VikBooking::numberFormat($order['total']); ?> |
| 190 |
</div> |
| 191 |
</div> |
| 192 |
<div class="vbo-bookdet-wrap vbo-bookdet-wrap-special"> |
| 193 |
<div class="vbo-bookdet-head"> |
| 194 |
<span><?php echo JText::translate('VBOCHECKEDSTATUS'); ?></span> |
| 195 |
</div> |
| 196 |
<div class="vbo-bookdet-foot"> |
| 197 |
<?php |
| 198 |
if ($order['checked'] < 0) { |
| 199 |
//no show |
| 200 |
$checked_status = '<span class="label label-error">'.JText::translate('VBOCHECKEDSTATUSNOS').'</span>'; |
| 201 |
} elseif ($order['checked'] == 1) { |
| 202 |
//checked in |
| 203 |
$checked_status = '<span class="label label-success">'.JText::translate('VBOCHECKEDSTATUSIN').'</span>'; |
| 204 |
} elseif ($order['checked'] == 2) { |
| 205 |
//checked out |
| 206 |
$checked_status = '<span class="label label-info">'.JText::translate('VBOCHECKEDSTATUSOUT').'</span>'; |
| 207 |
} else { |
| 208 |
//none (0) |
| 209 |
$checked_status = '<span class="label">'.JText::translate('VBOCHECKEDSTATUSZERO').'</span>'; |
| 210 |
} |
| 211 |
?> |
| 212 |
<?php echo $checked_status; ?> |
| 213 |
</div> |
| 214 |
</div> |
| 215 |
</div> |
| 216 |
<?php |
| 217 |
$signpad_style = 'display: flex;'; |
| 218 |
if (count($customer) && !empty($customer['signature'])) { |
| 219 |
$signpad_style = 'display: none;'; |
| 220 |
?> |
| 221 |
<div class="vbo-signature-container" id="fake-signature-container"> |
| 222 |
<div class="vbo-signature-pad"> |
| 223 |
<div class="vbo-signature-pad-head"> |
| 224 |
<p class="vbo-current-signature-p"><?php echo JText::translate('VBOCURRENTSIGNATURE'); ?></p> |
| 225 |
</div> |
| 226 |
<div class="vbo-signature-pad-body"> |
| 227 |
<div class="vbo-signature-currentimg"><img src="<?php echo VBO_ADMIN_URI; ?>resources/idscans/<?php echo $customer['signature'].'?'.time(); ?>"></div> |
| 228 |
</div> |
| 229 |
<div class="vbo-signature-pad-footer"> |
| 230 |
<div class="vbo-signature-signabove"></div> |
| 231 |
<div class="vbo-signature-cmds"> |
| 232 |
<div class="vbo-signature-cmd"> |
| 233 |
<button type="button" class="btn btn-large btn-success" onclick="vboConfirmGenerate(-1);"><i class="vboicn-checkmark"></i> <?php echo JText::translate('VBOGENCHECKINDOC'); ?></button> |
| 234 |
</div> |
| 235 |
<div class="vbo-signature-cmd"> |
| 236 |
<button type="button" class="btn btn-large btn-success" onclick="vboShowSignPad();"><i class="vboicn-quill"></i> <?php echo JText::translate('VBOSIGNATUREAGAIN'); ?></button> |
| 237 |
</div> |
| 238 |
</div> |
| 239 |
</div> |
| 240 |
</div> |
| 241 |
</div> |
| 242 |
<?php |
| 243 |
} |
| 244 |
$termsconds = VikBooking::getTermsConditions(); |
| 245 |
$empty_termsconds = !(strlen(trim(strip_tags($termsconds))) > 0); |
| 246 |
?> |
| 247 |
<div class="vbo-signature-container" id="real-signature-container" style="<?php echo $signpad_style; ?>"> |
| 248 |
<div id="vbo-signature-pad" class="vbo-signature-pad"> |
| 249 |
<div class="vbo-signature-pad-head"> |
| 250 |
<div class="pull-left"> |
| 251 |
<button type="button" id="signature_link" class="btn <?php echo $prefreshing > 0 ? 'btn-success' : 'btn-primary'; ?>" onclick="vboStopRefresh();vboUpdateModal('<?php echo addslashes(JText::translate('VBOSIGNATURESHARE')); ?>', '.signature_link', true);"><i class="vboicn-link"></i> <?php echo JText::translate('VBOSIGNATURESHARE'); ?></button> |
| 252 |
</div> |
| 253 |
<div class="pull-right"> |
| 254 |
<button type="button" class="btn" onclick="vboConfirmGenerate(0);"><i class="vboicn-cross"></i> <?php echo JText::translate('VBOSIGNATURESKIP'); ?></button> |
| 255 |
</div> |
| 256 |
<?php |
| 257 |
if (!$empty_termsconds) { |
| 258 |
?> |
| 259 |
<div class="vbo-signature-pad-head-terms"> |
| 260 |
<a href="javascript: void(0);" onclick="vboUpdateModal('<?php echo addslashes(JText::translate('VBOTERMSCONDS')); ?>', '.termsconds', true);"><i class="vboicn-link"></i> <?php echo JText::translate('VBOTERMSCONDSIACCEPT'); ?></a> |
| 261 |
<span><input type="checkbox" name="termsconds" id="termsconds" checked="checked"></span> |
| 262 |
</div> |
| 263 |
<?php |
| 264 |
} |
| 265 |
?> |
| 266 |
</div> |
| 267 |
<div class="vbo-signature-pad-body"> |
| 268 |
<canvas></canvas> |
| 269 |
</div> |
| 270 |
<div class="vbo-signature-pad-footer"> |
| 271 |
<div class="vbo-signature-signabove"> |
| 272 |
<span><i class="vboicn-quill"></i> <?php echo JText::translate('VBOSIGNATURESIGNABOVE'); ?></span> |
| 273 |
</div> |
| 274 |
<div class="vbo-signature-cmds"> |
| 275 |
<div class="vbo-signature-cmd"> |
| 276 |
<button type="button" class="btn btn-large btn-success" onclick="vboConfirmGenerate(1);"><i class="vboicn-checkmark"></i> <?php echo JText::translate('VBOSIGNATURESAVE'); ?></button> |
| 277 |
</div> |
| 278 |
<div class="vbo-signature-cmd"> |
| 279 |
<button type="button" class="btn btn-large btn-danger" onclick="vboClearSignPad();"><i class="vboicn-bin"></i> <?php echo JText::translate('VBOSIGNATURECLEAR'); ?></button> |
| 280 |
</div> |
| 281 |
</div> |
| 282 |
</div> |
| 283 |
</div> |
| 284 |
</div> |
| 285 |
<input type="hidden" name="cid[]" value="<?php echo $order['id']; ?>"> |
| 286 |
<input type="hidden" name="signature" id="signature-data" value=""> |
| 287 |
<input type="hidden" name="pad_width" id="pad_width" value=""> |
| 288 |
<input type="hidden" name="pad_ratio" id="pad_ratio" value=""> |
| 289 |
<input type="hidden" name="task" value="createcheckindoc" /> |
| 290 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 291 |
<?php |
| 292 |
if ($tmpl == 'component') { |
| 293 |
?> |
| 294 |
<input type="hidden" name="tmpl" value="component" /> |
| 295 |
<?php |
| 296 |
} |
| 297 |
?> |
| 298 |
</form> |
| 299 |
<script type="text/javascript"> |
| 300 |
var refreshing = null; |
| 301 |
var vbo_overlay_data = {}; |
| 302 |
<?php |
| 303 |
if (!empty($order['adminnotes'])) { |
| 304 |
$order['adminnotes'] = VikBooking::strTrimLiteral(nl2br(htmlspecialchars($order['adminnotes']))); |
| 305 |
?> |
| 306 |
vbo_overlay_data['adminnotes'] = '<pre><?php echo addslashes($order['adminnotes']); ?></pre>'; |
| 307 |
<?php |
| 308 |
} |
| 309 |
if (count($customer) && !empty($customer['notes'])) { |
| 310 |
$customer['notes'] = VikBooking::strTrimLiteral(nl2br(htmlspecialchars($customer['notes']))); |
| 311 |
?> |
| 312 |
vbo_overlay_data['customer_notes'] = '<pre><?php echo addslashes($customer['notes']); ?></pre>'; |
| 313 |
<?php |
| 314 |
} |
| 315 |
if (count($customer) && !empty($customer['comments'])) { |
| 316 |
$customer['comments'] = VikBooking::strTrimLiteral(nl2br(htmlspecialchars($customer['comments']))); |
| 317 |
?> |
| 318 |
vbo_overlay_data['comments'] = '<pre><?php echo addslashes($customer['comments']); ?></pre>'; |
| 319 |
<?php |
| 320 |
} |
| 321 |
|
| 322 |
// attempt to rewrite the share signature URL |
| 323 |
$share_link = JUri::root() . 'index.php?option=com_vikbooking&task=signature&sid=' . (!empty($order['idorderota']) && !empty($order['channel']) ? $order['idorderota'] : $order['sid']) . '&ts=' . $order['ts']; |
| 324 |
if (VBOPlatformDetection::isWordPress()) { |
| 325 |
/** |
| 326 |
* @wponly Rewrite URI for front-end signature |
| 327 |
*/ |
| 328 |
$share_link = str_replace(JUri::root(), '', $share_link); |
| 329 |
$model = JModel::getInstance('vikbooking', 'shortcodes'); |
| 330 |
$itemid = $model->all('post_id', $full = true); |
| 331 |
if (count($itemid)) { |
| 332 |
$share_link = JRoute::rewrite($share_link . "&Itemid={$itemid[0]->post_id}", false); |
| 333 |
} |
| 334 |
} else { |
| 335 |
/** |
| 336 |
* @joomlaonly |
| 337 |
*/ |
| 338 |
$best_menuitem_id = VikBooking::findProperItemIdType(['vikbooking', 'booking'], $order['lang']); |
| 339 |
if ($best_menuitem_id) { |
| 340 |
$lang_link = !empty($order['lang']) ? "&lang={$order['lang']}" : ''; |
| 341 |
$share_base = str_replace(JUri::root(), '', $share_link); |
| 342 |
$share_base .= $lang_link; |
| 343 |
$share_link = VikBooking::externalroute($share_base, $xhtml = false, $best_menuitem_id); |
| 344 |
} |
| 345 |
} |
| 346 |
|
| 347 |
?> |
| 348 |
vbo_overlay_data['signature_link'] = '<div class="vbo-sign-share-meth-cont">'+ |
| 349 |
'<div class="vbo-sign-share-meth">'+ |
| 350 |
'<label for="vbo-share-email"><?php echo addslashes(JText::translate('VBOSIGNSHAREEMAIL')); ?></label>'+ |
| 351 |
'<input type="text" id="vbo-share-email" value="<?php echo addslashes((count($customer) && !empty($customer['email']) ? $customer['email'] : $order['custmail'])); ?>" size="35" />'+ |
| 352 |
'<button type="button" class="btn btn-primary" onclick="vboSendSignLink(\'email\');"><i class="vboicn-envelop"></i> <?php echo addslashes(JText::translate('VBOSIGNSENDLINK')); ?></button>'+ |
| 353 |
'</div>'+ |
| 354 |
'<div class="vbo-sign-share-meth">'+ |
| 355 |
'<label for="vbo-share-sms"><?php echo addslashes(JText::translate('VBOSIGNSHARESMS')); ?></label>'+ |
| 356 |
'<input type="text" id="vbo-share-sms" value="<?php echo addslashes((count($customer) && !empty($customer['phone']) ? $customer['phone'] : $order['phone'])); ?>" size="35" />'+ |
| 357 |
'<button type="button" class="btn btn-primary" onclick="vboSendSignLink(\'sms\');"><i class="vboicn-mobile"></i> <?php echo addslashes(JText::translate('VBOSIGNSENDLINK')); ?></button>'+ |
| 358 |
'</div>'+ |
| 359 |
'<div class="vbo-sign-share-meth">'+ |
| 360 |
'<span><a href="<?php echo $share_link; ?>" target="_blank"><i class="vboicn-link"></i> <?php echo $share_link; ?></a></span>'+ |
| 361 |
'</div>'+ |
| 362 |
'<div class="vbo-sign-share-meth vbo-sign-share-meth-close">'+ |
| 363 |
'<span><button type="button" class="btn btn-secondary" onclick="vboCloseModal();"><?php echo addslashes(JText::translate('VBANNULLA')); ?></button></span>'+ |
| 364 |
'</div>'+ |
| 365 |
'</div>'; |
| 366 |
<?php |
| 367 |
if (!$empty_termsconds) { |
| 368 |
$termsconds = VikBooking::strTrimLiteral($termsconds); |
| 369 |
$terms_acc_close = VikBooking::strTrimLiteral(JText::translate('VBOTERMSCONDSACCCLOSE')); |
| 370 |
?> |
| 371 |
vbo_overlay_data['termsconds'] = '<div><?php echo addslashes($termsconds); ?></div><div class="vbo-center"><br /><button type="button" class="btn btn-large btn-success" onclick="jQuery(\'#termsconds\').prop(\'checked\', true);vboCloseModal();"><?php echo addslashes($terms_acc_close); ?></button></div>'; |
| 372 |
<?php |
| 373 |
} |
| 374 |
if ($prefreshing > 0) { |
| 375 |
?> |
| 376 |
refreshing = setInterval(function() { |
| 377 |
jQuery('#signature_link').html(jQuery('#signature_link').html().replace('<?php echo addslashes(JText::translate('VBOSIGNATURESHARE')); ?>', '<?php echo addslashes(JText::translate('VBORELOADING')); ?>')); |
| 378 |
setTimeout(function() { |
| 379 |
document.location.href = 'index.php?option=com_vikbooking&task=gencheckindoc&cid[]=<?php echo $order['id'].'&refreshing=1'.($tmpl == 'component' ? '&tmpl=component' : ''); ?>'; |
| 380 |
}, 1000); |
| 381 |
}, 8000); |
| 382 |
<?php |
| 383 |
} |
| 384 |
?> |
| 385 |
</script> |
| 386 |
<script type="text/javascript"> |
| 387 |
/* Global Variables and Functions */ |
| 388 |
var vbo_overlay_on = false; |
| 389 |
var booking_total = <?php echo (float)$order['total']; ?>; |
| 390 |
var tot_rooms = <?php echo (int)$order['roomsnum']; ?>; |
| 391 |
var current_checked = <?php echo (int)$order['checked']; ?>; |
| 392 |
function vboOpenModal() { |
| 393 |
/** |
| 394 |
* @wponly - we are inside the same parent page as the modal is loaded via Ajax. |
| 395 |
* We need to select the values from the modal container. |
| 396 |
*/ |
| 397 |
jQuery('.modal-body').find(".vbo-info-overlay-block").fadeIn(400, function() { |
| 398 |
if (jQuery('.modal-body').find(".vbo-info-overlay-block").is(":visible")) { |
| 399 |
vbo_overlay_on = true; |
| 400 |
} else { |
| 401 |
vbo_overlay_on = false; |
| 402 |
jQuery('.modal-body').find('.vbo-overlay-checkin-body').html(''); |
| 403 |
} |
| 404 |
}); |
| 405 |
} |
| 406 |
function vboCloseModal() { |
| 407 |
/** |
| 408 |
* @wponly - we are inside the same parent page as the modal is loaded via Ajax. |
| 409 |
* We need to select the values from the modal container. |
| 410 |
*/ |
| 411 |
jQuery('.modal-body').find(".vbo-info-overlay-block").fadeOut(); |
| 412 |
vbo_overlay_on = false; |
| 413 |
} |
| 414 |
function vboUpdateModal(title, body, call_toggle) { |
| 415 |
/** |
| 416 |
* @wponly - we are inside the same parent page as the modal is loaded via Ajax. |
| 417 |
* We need to select the values from the modal container. |
| 418 |
*/ |
| 419 |
jQuery('.modal-body').find('#vbo-overlay-title').text(title); |
| 420 |
if (body.substr(0, 1) == '.') { |
| 421 |
//look for this value inside the global array |
| 422 |
body = body.substr(1, (body.length - 1)); |
| 423 |
if (vbo_overlay_data.hasOwnProperty(body)) { |
| 424 |
body = vbo_overlay_data[body]; |
| 425 |
} |
| 426 |
} |
| 427 |
jQuery('.modal-body').find('.vbo-overlay-checkin-body').html(body); |
| 428 |
if (call_toggle) { |
| 429 |
vboOpenModal(); |
| 430 |
} |
| 431 |
} |
| 432 |
function vboShowSignPad() { |
| 433 |
jQuery('#fake-signature-container').remove(); |
| 434 |
document.getElementById('real-signature-container').style.display = 'flex'; |
| 435 |
vboResizeCanvas(); |
| 436 |
} |
| 437 |
function vboSendSignLink(method) { |
| 438 |
var sendto = document.getElementById('vbo-share-'+method); |
| 439 |
if (!sendto || !sendto.value.length) { |
| 440 |
alert('<?php echo addslashes(JText::translate('VBOSIGNSHAREEMPTY')); ?>'); |
| 441 |
return false; |
| 442 |
} |
| 443 |
jQuery.ajax({ |
| 444 |
type: 'POST', |
| 445 |
url: 'index.php?option=com_vikbooking&task=sharesignaturelink&tmpl=component', |
| 446 |
data: {bid: '<?php echo $order['id']; ?>', how: method, to: sendto.value, customer: '<?php echo $customer['id']; ?>'} |
| 447 |
}).done(function(resp){ |
| 448 |
var obj = JSON.parse(resp); |
| 449 |
if (obj.status > 0) { |
| 450 |
jQuery('#signature_link').addClass('btn-success').removeClass('btn-primary'); |
| 451 |
/** |
| 452 |
* @wponly - We cannot set intervals or timeouts to reload the page as we are loaded via Ajax inside a Modal |
| 453 |
*/ |
| 454 |
vboCloseModal(); |
| 455 |
} else { |
| 456 |
alert(obj.error); |
| 457 |
} |
| 458 |
}).fail(function(resp){ |
| 459 |
console.log(resp); |
| 460 |
alert('Error.'); |
| 461 |
}); |
| 462 |
} |
| 463 |
function vboStopRefresh() { |
| 464 |
jQuery('#signature_link').addClass('btn-primary').removeClass('btn-success'); |
| 465 |
if (refreshing != null) { |
| 466 |
clearInterval(refreshing); |
| 467 |
refreshing = null; |
| 468 |
} |
| 469 |
} |
| 470 |
if (jQuery.isFunction(jQuery.fn.tooltip)) { |
| 471 |
jQuery(".hasTooltip").tooltip(); |
| 472 |
} else { |
| 473 |
jQuery.fn.tooltip = function(){}; |
| 474 |
} |
| 475 |
|
| 476 |
/* Canvas global vars */ |
| 477 |
var canvas, signaturePad; |
| 478 |
|
| 479 |
function vboResizeCanvas() { |
| 480 |
var ratio = Math.max(window.devicePixelRatio || 1, 1); |
| 481 |
canvas.width = canvas.offsetWidth * ratio; |
| 482 |
canvas.height = canvas.offsetHeight * ratio; |
| 483 |
canvas.getContext("2d").scale(ratio, ratio); |
| 484 |
signaturePad.clear(); |
| 485 |
document.getElementById('pad_width').value = canvas.width; |
| 486 |
document.getElementById('pad_ratio').value = ratio; |
| 487 |
} |
| 488 |
|
| 489 |
function vboClearSignPad() { |
| 490 |
signaturePad.clear(); |
| 491 |
} |
| 492 |
|
| 493 |
function vboConfirmGenerate(action) { |
| 494 |
if (action > 0) { |
| 495 |
if (signaturePad.isEmpty()) { |
| 496 |
alert('<?php echo addslashes(JText::translate('VBOSIGNATUREISEMPTY')); ?>'); |
| 497 |
return false; |
| 498 |
} |
| 499 |
if (document.getElementById('termsconds') && !document.getElementById('termsconds').checked) { |
| 500 |
alert('<?php echo addslashes(JText::translate('VBOSIGNMUSTACCEPT')); ?>'); |
| 501 |
return false; |
| 502 |
} |
| 503 |
//var dataURL = signaturePad.toDataURL("image/jpeg"); |
| 504 |
//var dataURL = signaturePad.toDataURL('image/svg+xml'); |
| 505 |
var dataURL = signaturePad.toDataURL(); |
| 506 |
document.getElementById('signature-data').value = dataURL; |
| 507 |
document.getElementById('adminForm').submit(); |
| 508 |
} else if (action < 0) { |
| 509 |
document.getElementById('adminForm').submit(); |
| 510 |
} else { |
| 511 |
var proceed_txt = '<?php echo addslashes(JText::translate('VBONOSIGNATURECONF')); ?>'; |
| 512 |
if (confirm(proceed_txt)) { |
| 513 |
document.getElementById('adminForm').submit(); |
| 514 |
} |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
// On mobile devices it might make more sense to listen to orientation change, rather than window resize events. |
| 519 |
window.onresize = vboResizeCanvas; |
| 520 |
|
| 521 |
jQuery(function() { |
| 522 |
/* Overlay for Customer Notes, Booking Notes, Checkin Comments - Start */ |
| 523 |
jQuery(document).mouseup(function(e) { |
| 524 |
if (!vbo_overlay_on) { |
| 525 |
return false; |
| 526 |
} |
| 527 |
var vbo_overlay_cont = jQuery(".vbo-info-overlay-content"); |
| 528 |
if (!vbo_overlay_cont.is(e.target) && vbo_overlay_cont.has(e.target).length === 0) { |
| 529 |
vboCloseModal(); |
| 530 |
} |
| 531 |
}); |
| 532 |
|
| 533 |
jQuery(document).keyup(function(e) { |
| 534 |
if (e.keyCode == 27 && vbo_overlay_on) { |
| 535 |
vboCloseModal(); |
| 536 |
} |
| 537 |
}); |
| 538 |
|
| 539 |
/* Canvas initialization */ |
| 540 |
var sign_wrapper = document.getElementById("vbo-signature-pad"); |
| 541 |
// set global vars |
| 542 |
canvas = sign_wrapper.querySelector("canvas"); |
| 543 |
signaturePad = new SignaturePad(canvas, { |
| 544 |
// opaque color only needed when saving image as JPEG (rgb(255, 255, 255)) |
| 545 |
backgroundColor: 'rgba(0, 0, 0, 0)' |
| 546 |
}); |
| 547 |
|
| 548 |
/* Canvas adjust rendering */ |
| 549 |
setTimeout(() => { |
| 550 |
vboResizeCanvas(); |
| 551 |
}, 200); |
| 552 |
}); |
| 553 |
</script> |