| 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 |
$room = $this->room; |
| 14 |
$allc = $this->allc; |
| 15 |
$payments = $this->payments; |
| 16 |
$busy = $this->busy; |
| 17 |
$vmode = $this->vmode; |
| 18 |
|
| 19 |
$dbo = JFactory::getDbo(); |
| 20 |
$vbo_app = VikBooking::getVboApplication(); |
| 21 |
$vbo_app->loadSelect2(); |
| 22 |
$vbo_app->loadDatePicker(); |
| 23 |
|
| 24 |
$document = JFactory::getDocument(); |
| 25 |
$document->addStyleSheet(VBO_ADMIN_URI.'resources/jquery.highlighttextarea.min.css'); |
| 26 |
JHtml::fetch('script', VBO_ADMIN_URI.'resources/jquery.highlighttextarea.min.js'); |
| 27 |
|
| 28 |
// JS lang def |
| 29 |
JText::script('VBFILLCUSTFIELDS'); |
| 30 |
JText::script('VBMSGTHREE'); |
| 31 |
JText::script('VBMSGFOUR'); |
| 32 |
JText::script('VBDBTEXTROOMCLOSED'); |
| 33 |
JText::script('ORDER_NOTES'); |
| 34 |
JText::script('VBSUBMCLOSEROOM'); |
| 35 |
JText::script('VBCUSTINFO'); |
| 36 |
JText::script('VBMAKERESERV'); |
| 37 |
JText::script('VBDAY'); |
| 38 |
JText::script('VBOCALCLOSEOTHERROOMS'); |
| 39 |
JText::script('VBERRCUSTOMEREMAILEXISTS'); |
| 40 |
JText::script('VBAPPLY'); |
| 41 |
JText::script('VBANNULLA'); |
| 42 |
|
| 43 |
$vbo_df = VikBooking::getDateFormat(true); |
| 44 |
if ($vbo_df == "%d/%m/%Y") { |
| 45 |
$df = 'd/m/Y'; |
| 46 |
$juidf = 'dd/mm/yy'; |
| 47 |
} elseif ($vbo_df == "%m/%d/%Y") { |
| 48 |
$df = 'm/d/Y'; |
| 49 |
$juidf = 'mm/dd/yy'; |
| 50 |
} else { |
| 51 |
$df = 'Y/m/d'; |
| 52 |
$juidf = 'yy/mm/dd'; |
| 53 |
} |
| 54 |
$datesep = VikBooking::getDateSeparator(true); |
| 55 |
$prices_vat_included = (int)VikBooking::ivaInclusa(); |
| 56 |
|
| 57 |
$pcheckin = VikRequest::getString('checkin', '', 'request'); |
| 58 |
$pcheckin_ymd = $pcheckin; |
| 59 |
if (!empty($pcheckin)) { |
| 60 |
$pcheckin = date(str_replace('%', '', $vbo_df), strtotime($pcheckin)); |
| 61 |
} |
| 62 |
$pcheckout = VikRequest::getString('checkout', '', 'request'); |
| 63 |
$pcheckout_ymd = $pcheckout; |
| 64 |
if (!empty($pcheckout)) { |
| 65 |
$pcheckout = date(str_replace('%', '', $vbo_df), strtotime($pcheckout)); |
| 66 |
} |
| 67 |
|
| 68 |
$ptmpl = VikRequest::getString('tmpl', '', 'request'); |
| 69 |
$poverview = VikRequest::getInt('overv', '', 'request'); |
| 70 |
$poverview_change = VikRequest::getInt('overview_change', 0, 'request'); |
| 71 |
$padults = VikRequest::getInt('adults', 0, 'request'); |
| 72 |
$pchildren = VikRequest::getInt('children', 0, 'request'); |
| 73 |
$pidprice = VikRequest::getInt('idprice', 0, 'request'); |
| 74 |
$pbooknow = VikRequest::getInt('booknow', 0, 'request'); |
| 75 |
|
| 76 |
/** |
| 77 |
* Split stay data for booking. |
| 78 |
* |
| 79 |
* @since 1.16.0 (J) - 1.6.0 (WP) |
| 80 |
*/ |
| 81 |
$split_stay = VikRequest::getVar('split_stay', array()); |
| 82 |
$rooms_data = []; |
| 83 |
foreach ($allc as $room_info) { |
| 84 |
$rooms_data[$room_info['id']] = $room_info['name']; |
| 85 |
} |
| 86 |
|
| 87 |
if ($this->new_res_id) { |
| 88 |
?> |
| 89 |
<p class="successmade"><?php echo JText::translate('VBBOOKMADE'); ?> <a href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $this->new_res_id; ?>" target="_blank" class="btn"><i class="vboicn-eye"></i> <?php echo JText::translate('VBOVIEWBOOKINGDET'); ?></a></p> |
| 90 |
<?php |
| 91 |
if ($poverview > 0 && $ptmpl == 'component') { |
| 92 |
$poverview_change = 1; |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
$timeopst = VikBooking::getTimeOpenStore(); |
| 97 |
if (is_array($timeopst)) { |
| 98 |
$opent = VikBooking::getHoursMinutes($timeopst[0]); |
| 99 |
$closet = VikBooking::getHoursMinutes($timeopst[1]); |
| 100 |
$hcheckin = $opent[0]; |
| 101 |
$mcheckin = $opent[1]; |
| 102 |
$hcheckout = $closet[0]; |
| 103 |
$mcheckout = $closet[1]; |
| 104 |
} else { |
| 105 |
$hcheckin = 0; |
| 106 |
$mcheckin = 0; |
| 107 |
$hcheckout = 0; |
| 108 |
$mcheckout = 0; |
| 109 |
} |
| 110 |
$formatparts = explode(':', VikBooking::getNumberFormatData()); |
| 111 |
$currencysymb = VikBooking::getCurrencySymb(true); |
| 112 |
$globnumadults = VikBooking::getSearchNumAdults(true); |
| 113 |
$adultsparts = explode('-', $globnumadults); |
| 114 |
$seladults = "<select name=\"adults\" id=\"vbo-sel-adults\">\n"; |
| 115 |
for ($i = $adultsparts[0]; $i <= ((int)$adultsparts[1] * $room['units']); $i++) { |
| 116 |
$seladults .= "<option value=\"".$i."\"".((intval($adultsparts[0]) < 1 && $i == 1 && $padults < 1) || ($padults > 0 && $i == $padults) ? " selected=\"selected\"" : "").">".$i."</option>\n"; |
| 117 |
} |
| 118 |
$seladults .= "</select>\n"; |
| 119 |
$globnumchildren = VikBooking::getSearchNumChildren(true); |
| 120 |
$childrenparts = explode('-', $globnumchildren); |
| 121 |
$selchildren = "<select name=\"children\" id=\"vbo-sel-children\">\n"; |
| 122 |
for ($i = $childrenparts[0]; $i <= ((int)$childrenparts[1] * $room['units']); $i++) { |
| 123 |
$selchildren .= "<option value=\"".$i."\"" . ($pchildren > 0 && $i == $pchildren ? ' selected="selected"' : '') . ">".$i."</option>\n"; |
| 124 |
} |
| 125 |
$selchildren .= "</select>\n"; |
| 126 |
$selpayments = '<select name="payment"><option value="">'.JText::translate('VBPAYMUNDEFINED').'</option>'; |
| 127 |
if (is_array($payments) && $payments) { |
| 128 |
foreach ($payments as $pay) { |
| 129 |
$selpayments .= '<option value="'.$pay['id'].'">'.$pay['name'].'</option>'; |
| 130 |
} |
| 131 |
} |
| 132 |
$selpayments .= '</select>'; |
| 133 |
// custom fields |
| 134 |
$all_countries = array(); |
| 135 |
$q = "SELECT * FROM `#__vikbooking_custfields` ORDER BY `#__vikbooking_custfields`.`ordering` ASC;"; |
| 136 |
$dbo->setQuery($q); |
| 137 |
$all_cfields = $dbo->loadAssocList(); |
| 138 |
if ($all_cfields) { |
| 139 |
$q = "SELECT * FROM `#__vikbooking_countries` ORDER BY `#__vikbooking_countries`.`country_name` ASC;"; |
| 140 |
$dbo->setQuery($q); |
| 141 |
$all_countries = $dbo->loadAssocList(); |
| 142 |
} |
| 143 |
|
| 144 |
$wiva = ""; |
| 145 |
$q = "SELECT * FROM `#__vikbooking_iva`;"; |
| 146 |
$dbo->setQuery($q); |
| 147 |
$ivas = $dbo->loadAssocList(); |
| 148 |
if ($ivas) { |
| 149 |
foreach ($ivas as $kiv => $iv) { |
| 150 |
$wiva .= "<option value=\"".$iv['id']."\" data-aliqid=\"".$iv['id']."\"".($kiv < 1 ? ' selected="selected"' : '').">".(empty($iv['name']) ? $iv['aliq']."%" : $iv['name']." - ".$iv['aliq']."%")."</option>\n"; |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
// close other rooms select |
| 155 |
$closeotherrooms = ''; |
| 156 |
if (count($allc) > 1) { |
| 157 |
$closeotherrooms = "<select id=\"vbo-calendar-closeall\" multiple=\"multiple\" name=\"closeothers[]\" onchange=\"vboCheckCloseOthers();\">\n"; |
| 158 |
$closeotherrooms .= "<option></option>\n"; |
| 159 |
$closeotherrooms .= "<option value=\"".$room['id']."\" data-currentr=\"true\" disabled=\"disabled\">".$room['name']."</option>\n"; |
| 160 |
$closeotherrooms .= "<option value=\"-1\">- ".JText::translate('VBOCALCLOSEALLROOMSDT')."</option>\n"; |
| 161 |
foreach ($allc as $cc) { |
| 162 |
if ($cc['id'] == $room['id']) { |
| 163 |
continue; |
| 164 |
} |
| 165 |
$closeotherrooms .= "<option value=\"".$cc['id']."\">".$cc['name']."</option>\n"; |
| 166 |
} |
| 167 |
$closeotherrooms .= "</select>\n"; |
| 168 |
} |
| 169 |
|
| 170 |
?> |
| 171 |
|
| 172 |
<div class="vbo-admin-container"> |
| 173 |
|
| 174 |
<div class="vbo-config-maintab-left"> |
| 175 |
|
| 176 |
<fieldset class="adminform"> |
| 177 |
<div class="vbo-params-wrap"> |
| 178 |
<legend class="adminlegend"> |
| 179 |
<div class="vbo-quickres-head"> |
| 180 |
<span><?php echo $room['name'] . " - " . JText::translate('VBQUICKBOOK') . (!empty($split_stay) ? ' (' . JText::translate('VBO_SPLIT_STAY') . ')' : ''); ?></span> |
| 181 |
<div class="vbo-quickres-head-right"> |
| 182 |
<form name="vbchroom" id="vbchroom" method="post" action="index.php?option=com_vikbooking"> |
| 183 |
<input type="hidden" name="task" value="calendar"/> |
| 184 |
<input type="hidden" name="option" value="com_vikbooking"/> |
| 185 |
<select id="vbo-calendar-changeroom" name="cid[]" onchange="jQuery('#vbchroom').submit();"> |
| 186 |
<?php |
| 187 |
foreach ($allc as $cc) { |
| 188 |
echo "<option value=\"".$cc['id']."\"".($cc['id'] == $room['id'] ? " selected=\"selected\"" : "").">".$cc['name']."</option>\n"; |
| 189 |
} |
| 190 |
?> |
| 191 |
</select> |
| 192 |
<?php |
| 193 |
if ($ptmpl == 'component') { |
| 194 |
echo "<input type=\"hidden\" name=\"tmpl\" value=\"component\" />\n"; |
| 195 |
} |
| 196 |
?> |
| 197 |
</form> |
| 198 |
</div> |
| 199 |
</div> |
| 200 |
</legend> |
| 201 |
<form name="newb" method="post" action="index.php?option=com_vikbooking" onsubmit="javascript: if (!document.newb.checkindate.value.match(/\S/)){alert(Joomla.JText._('VBMSGTHREE')); return false;} if (!document.newb.checkoutdate.value.match(/\S/)){alert(Joomla.JText._('VBMSGFOUR')); return false;} return true;"> |
| 202 |
<div class="vbo-params-container"> |
| 203 |
<div class="vbo-param-container"> |
| 204 |
<div class="vbo-param-label"><?php echo JText::translate('VBDATEPICKUP'); ?></div> |
| 205 |
<div class="vbo-param-setting"> |
| 206 |
<div class="input-append"> |
| 207 |
<input type="text" autocomplete="off" name="checkindate" id="checkindate" size="10" /> |
| 208 |
<button type="button" class="btn vbodatepicker-trig-icon"><span class="icon-calendar"></span></button> |
| 209 |
</div> |
| 210 |
<span class="vbo-calendar-time-inline"><?php echo JText::translate('VBAT')." ".($hcheckin < 10 ? '0'.$hcheckin : $hcheckin).":".($mcheckin < 10 ? '0'.$mcheckin : $mcheckin); ?></span> |
| 211 |
<input type="hidden" name="checkinh" value="<?php echo $hcheckin; ?>"/> |
| 212 |
<input type="hidden" name="checkinm" value="<?php echo $mcheckin; ?>"/> |
| 213 |
</div> |
| 214 |
</div> |
| 215 |
<div class="vbo-param-container"> |
| 216 |
<div class="vbo-param-label"><?php echo JText::translate('VBDATERELEASE'); ?></div> |
| 217 |
<div class="vbo-param-setting"> |
| 218 |
<div class="input-append"> |
| 219 |
<input type="text" autocomplete="off" name="checkoutdate" id="checkoutdate" size="10" /> |
| 220 |
<button type="button" class="btn vbodatepicker-trig-icon"><span class="icon-calendar"></span></button> |
| 221 |
</div> |
| 222 |
<span class="vbo-calendar-time-inline"><?php echo JText::translate('VBAT')." ".($hcheckout < 10 ? '0'.$hcheckout : $hcheckout).":".($mcheckout < 10 ? '0'.$mcheckout : $mcheckout); ?></span> |
| 223 |
<span style="display: none; margin-left: 25px; vertical-align: top;" id="vbjstotnights"> |
| 224 |
<span style="font-weight: bold;"><?php echo JText::translate('VBDAYS'); ?></span> |
| 225 |
<input type="number" min="1" step="1" value="1" id="vbo-numnights" style="margin: 0;" /> |
| 226 |
</span> |
| 227 |
<input type="hidden" name="checkouth" value="<?php echo $hcheckout; ?>"/> |
| 228 |
<input type="hidden" name="checkoutm" value="<?php echo $mcheckout; ?>"/> |
| 229 |
</div> |
| 230 |
</div> |
| 231 |
<div class="vbo-param-container" style="<?php echo !empty($split_stay) ? 'display: none;' : ''; ?>"> |
| 232 |
<div class="vbo-param-label"> |
| 233 |
<span class="vbcloseroomsp"> |
| 234 |
<label for="setclosed-on"><?php echo JText::translate('VBCLOSEROOM'); ?> <i class="<?php echo VikBookingIcons::i('ban'); ?>" style="float: none;"></i></label> |
| 235 |
</span> |
| 236 |
</div> |
| 237 |
<div class="vbo-param-setting"> |
| 238 |
<?php echo $vbo_app->printYesNoButtons('setclosed', JText::translate('VBYES'), JText::translate('VBNO'), 0, 1, 0, 'vbCloseRoom();'); ?> |
| 239 |
<div class="vbo-close-all-rooms-sel" id="vbo-close-all-rooms-sel" style="display: none;"><?php echo $closeotherrooms; ?></div> |
| 240 |
</div> |
| 241 |
</div> |
| 242 |
<?php |
| 243 |
if ($room['units'] > 1 && empty($split_stay)) { |
| 244 |
$num_rooms_vals = range(1, $room['units']); |
| 245 |
$num_rooms_opts = ''; |
| 246 |
foreach ($num_rooms_vals as $nrv) { |
| 247 |
$num_rooms_opts .= '<option value="'.$nrv.'">'.$nrv.'</option>'."\n"; |
| 248 |
} |
| 249 |
?> |
| 250 |
<div class="vbo-param-container" id="vbo-row-numrooms"> |
| 251 |
<div class="vbo-param-label"><?php echo JText::translate('VBPVIEWROOMSEVEN'); ?></div> |
| 252 |
<div class="vbo-param-setting"> |
| 253 |
<select name="num_rooms" id="vbo-sel-numrooms"> |
| 254 |
<?php echo $num_rooms_opts; ?> |
| 255 |
</select> |
| 256 |
</div> |
| 257 |
</div> |
| 258 |
<?php |
| 259 |
} else { |
| 260 |
?> |
| 261 |
<input type="hidden" name="num_rooms" value="1"/> |
| 262 |
<?php |
| 263 |
} |
| 264 |
?> |
| 265 |
<div class="vbo-param-container" id="vbo-row-people"> |
| 266 |
<div class="vbo-param-label"><?php echo JText::translate('VBQUICKRESGUESTS'); ?></div> |
| 267 |
<div class="vbo-param-setting"> |
| 268 |
<span class="vbo-quickres-aduchi-wrap"> |
| 269 |
<span class="vbo-quickres-aduchi-inlbl"><?php echo JText::translate('VBQUICKADULTS'); ?></span> |
| 270 |
<?php echo $seladults; ?> |
| 271 |
</span> |
| 272 |
<span class="vbo-quickres-aduchi-wrap"> |
| 273 |
<span class="vbo-quickres-aduchi-inlbl"><?php echo JText::translate('VBQUICKCHILDREN'); ?></span> |
| 274 |
<?php echo $selchildren; ?> |
| 275 |
</span> |
| 276 |
</div> |
| 277 |
</div> |
| 278 |
<?php |
| 279 |
if (!empty($split_stay)) { |
| 280 |
foreach ($split_stay as $sps_k => $sps_v) { |
| 281 |
?> |
| 282 |
<div class="vbo-param-container"> |
| 283 |
<div class="vbo-param-label"><?php echo $sps_k < 1 ? '<i class="' . VikBookingIcons::i('random') . '"></i> ' . JText::translate('VBO_SPLIT_STAY') : ' '; ?></div> |
| 284 |
<div class="vbo-param-setting"> |
| 285 |
<div class="vbo-cal-splitstay-details"> |
| 286 |
<div class="vbo-cal-splitstay-room"> |
| 287 |
<span class="vbo-cal-splitstay-room-name"><?php VikBookingIcons::e('bed'); ?> <?php echo $rooms_data[$sps_v['idroom']]; ?></span> |
| 288 |
<span class="vbo-cal-splitstay-room-nights"><?php VikBookingIcons::e('moon'); ?> <?php echo $sps_v['nights']; ?> <?php echo $sps_v['nights'] > 1 ? JText::translate('VBDAYS') : JText::translate('VBDAY'); ?></span> |
| 289 |
</div> |
| 290 |
<div class="vbo-cal-splitstay-dates"> |
| 291 |
<span class="vbo-cal-splitstay-dates-in"><?php VikBookingIcons::e('plane-arrival'); ?> <?php echo date(str_replace("/", $datesep, $df), strtotime($sps_v['checkin'])); ?></span> |
| 292 |
<span class="vbo-cal-splitstay-dates-out"><?php VikBookingIcons::e('plane-departure'); ?> <?php echo date(str_replace("/", $datesep, $df), strtotime($sps_v['checkout'])); ?></span> |
| 293 |
</div> |
| 294 |
</div> |
| 295 |
</div> |
| 296 |
</div> |
| 297 |
<?php |
| 298 |
} |
| 299 |
} |
| 300 |
?> |
| 301 |
<div class="vbo-param-container"<?php echo ($poverview > 0 ? ' style="display: none;"' : ''); ?> id="vbo-row-bstat"> |
| 302 |
<div class="vbo-param-label"><?php echo JText::translate('VBCALBOOKINGSTATUS'); ?></div> |
| 303 |
<div class="vbo-param-setting"> |
| 304 |
<select name="newstatus"> |
| 305 |
<option value="confirmed"><?php echo JText::translate('VBCONFIRMED'); ?></option> |
| 306 |
<option value="standby"><?php echo JText::translate('VBSTANDBY'); ?></option> |
| 307 |
</select> |
| 308 |
</div> |
| 309 |
</div> |
| 310 |
<div class="vbo-param-container" id="vbo-row-bpay"> |
| 311 |
<div class="vbo-param-label"><?php echo JText::translate('VBCALBOOKINGPAYMENT'); ?></div> |
| 312 |
<div class="vbo-param-setting"> |
| 313 |
<?php echo $selpayments; ?> |
| 314 |
</div> |
| 315 |
</div> |
| 316 |
<div class="vbo-param-container" id="vbo-row-fillcustfields"> |
| 317 |
<div class="vbo-param-label"> </div> |
| 318 |
<div class="vbo-param-setting"> |
| 319 |
<span class="vbo-assign-customer" id="vbfillcustfields"> |
| 320 |
<i class="<?php echo VikBookingIcons::i('user-circle'); ?>"></i> |
| 321 |
<span><?php echo JText::translate('VBFILLCUSTFIELDS'); ?></span> |
| 322 |
</span> |
| 323 |
</div> |
| 324 |
</div> |
| 325 |
<div class="vbo-param-container" id="vbo-row-cmail"> |
| 326 |
<div class="vbo-param-label"><?php echo JText::translate('VBCUSTEMAIL'); ?></div> |
| 327 |
<div class="vbo-param-setting"> |
| 328 |
<input type="text" name="custmail" id="custmailfield" value="" size="25"/> |
| 329 |
</div> |
| 330 |
</div> |
| 331 |
<div class="vbo-param-container"> |
| 332 |
<div class="vbo-param-label" id="vbcustdatalbl"><?php echo JText::translate('VBCUSTINFO'); ?></div> |
| 333 |
<div class="vbo-param-setting"> |
| 334 |
<textarea name="custdata" id="vbcustdatatxtarea" rows="5" cols="70" style="min-width: 300px;"></textarea> |
| 335 |
</div> |
| 336 |
</div> |
| 337 |
<div class="vbo-param-container" id="vbo-website-rates-row" style="display: none;"> |
| 338 |
<div class="vbo-param-label"><?php echo JText::translate('VBOWEBSITERATES'); ?></div> |
| 339 |
<div class="vbo-param-setting" id="vbo-website-rates-cont"></div> |
| 340 |
</div> |
| 341 |
<div class="vbo-param-container" id="vbo-row-custcost"> |
| 342 |
<div class="vbo-param-label"><?php echo JText::translate('VBOROOMCUSTRATEPLANADD'); ?></div> |
| 343 |
<div class="vbo-param-setting"> |
| 344 |
<div class="vbo-calendar-costs-wrapper"> |
| 345 |
<?php echo $currencysymb; ?> <input name="cust_cost" id="cust_cost" value="" onfocus="document.getElementById('taxid').style.display = 'inline-block';" onkeyup="vbCalcDailyCost(this.value);" onchange="vbCalcDailyCost(this.value);" type="number" step="any" min="0"> |
| 346 |
<select class="vbo-calendar-taxid" name="taxid" id="taxid" style="display: none;"> |
| 347 |
<option value=""><?php echo JText::translate('VBNEWOPTFOUR'); ?></option> |
| 348 |
<?php echo $wiva; ?> |
| 349 |
</select> |
| 350 |
<div id="avg-daycost" class="vbo-calendar-avg-daycost" style="display: none;"> |
| 351 |
<select name="totalpnight"> |
| 352 |
<option value="total"></option> |
| 353 |
<option value="pnight"></option> |
| 354 |
</select> |
| 355 |
</div> |
| 356 |
</div> |
| 357 |
</div> |
| 358 |
</div> |
| 359 |
<div id="vbo-force-bookingdates" class="vbo-param-container" style="display: none;"> |
| 360 |
<div class="vbo-param-label"><?php echo $vbo_app->createPopover(array('title' => JText::translate('VBO_FORCE_BOOKDATES'), 'content' => JText::translate('VBO_FORCE_BOOKDATES_HELP'))); ?> <?php echo JText::translate('VBO_FORCE_BOOKDATES'); ?></div> |
| 361 |
<div class="vbo-param-setting"> |
| 362 |
<?php echo $vbo_app->printYesNoButtons('forcebooking', JText::translate('VBYES'), JText::translate('VBNO'), 0, 1, 0); ?> |
| 363 |
<div class="vbo-param-setting-comment"></div> |
| 364 |
</div> |
| 365 |
</div> |
| 366 |
<div class="vbo-param-container"> |
| 367 |
<div class="vbo-param-label"> </div> |
| 368 |
<div class="vbo-param-setting"> |
| 369 |
<button type="submit" id="quickbsubmit" class="btn btn-success btn-large"><i class="icon-save"></i> <span><?php echo JText::translate('VBMAKERESERV'); ?></span></button> |
| 370 |
</div> |
| 371 |
</div> |
| 372 |
</div> |
| 373 |
<?php |
| 374 |
if ($poverview > 0) { |
| 375 |
?> |
| 376 |
<input type="hidden" name="overv" value="<?php echo $poverview; ?>" /> |
| 377 |
<?php |
| 378 |
} |
| 379 |
if ($ptmpl == 'component') { |
| 380 |
?> |
| 381 |
<input type="hidden" name="tmpl" value="component" /> |
| 382 |
<?php |
| 383 |
} |
| 384 |
if (!empty($split_stay)) { |
| 385 |
// add hidden fields for the split stay booking |
| 386 |
foreach ($split_stay as $spsk => $sps_room) { |
| 387 |
foreach ($sps_room as $sps_room_k => $sps_room_v) { |
| 388 |
?> |
| 389 |
<input type="hidden" name="split_stay_data[<?php echo $spsk; ?>][<?php echo $sps_room_k; ?>]" value="<?php echo JHtml::fetch('esc_attr', $sps_room_v); ?>" /> |
| 390 |
<?php |
| 391 |
} |
| 392 |
} |
| 393 |
} |
| 394 |
?> |
| 395 |
<input type="hidden" name="customer_id" value="" id="customer_id_inpfield"/> |
| 396 |
<input type="hidden" name="countrycode" value="" id="ccode_inpfield"/> |
| 397 |
<input type="hidden" name="state" value="" id="state_inpfield"/> |
| 398 |
<input type="hidden" name="t_first_name" value="" id="t_first_name_inpfield"/> |
| 399 |
<input type="hidden" name="t_last_name" value="" id="t_last_name_inpfield"/> |
| 400 |
<input type="hidden" name="phone" value="" id="phonefield"/> |
| 401 |
<input type="hidden" name="idprice" value="" id="booking-idprice"/> |
| 402 |
<input type="hidden" name="roomcost" value="" id="booking-roomcost"/> |
| 403 |
<input type="hidden" name="task" value="calendar"/> |
| 404 |
<input type="hidden" name="cid[]" value="<?php echo $room['id']; ?>"/> |
| 405 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 406 |
</form> |
| 407 |
</div> |
| 408 |
</fieldset> |
| 409 |
|
| 410 |
</div> |
| 411 |
|
| 412 |
<div class="vbo-config-maintab-right"> |
| 413 |
<div class="vbo-avcalendars-wrapper"> |
| 414 |
<div class="vbo-avcalendars-roomphoto"> |
| 415 |
<?php |
| 416 |
if (is_file(VBO_SITE_PATH . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $room['img'])) { |
| 417 |
?> |
| 418 |
<img alt="Room Image" src="<?php echo VBO_SITE_URI; ?>resources/uploads/<?php echo $room['img']; ?>" /> |
| 419 |
<?php |
| 420 |
} else { |
| 421 |
VikBookingIcons::e('image', 'vbo-enormous-icn'); |
| 422 |
} |
| 423 |
?> |
| 424 |
</div> |
| 425 |
<?php |
| 426 |
$check = false; |
| 427 |
if (empty($busy)) { |
| 428 |
?> |
| 429 |
<p class="warn"><?php echo JText::translate('VBNOFUTURERES'); ?></p> |
| 430 |
<?php |
| 431 |
} else { |
| 432 |
$check = true; |
| 433 |
// build URL for each number of calendar months |
| 434 |
$base_uri_data = [ |
| 435 |
'option' => 'com_vikbooking', |
| 436 |
'task' => 'calendar', |
| 437 |
'cid' => [ |
| 438 |
$room['id'] |
| 439 |
], |
| 440 |
'split_stay' => $split_stay, |
| 441 |
]; |
| 442 |
if (!empty($pcheckin_ymd) && !empty($pcheckout_ymd)) { |
| 443 |
$base_uri_data['checkin'] = $pcheckin_ymd; |
| 444 |
$base_uri_data['checkout'] = $pcheckout_ymd; |
| 445 |
} |
| 446 |
if ($padults > 0) { |
| 447 |
$base_uri_data['adults'] = $padults; |
| 448 |
$base_uri_data['children'] = $pchildren; |
| 449 |
} |
| 450 |
if (!empty($pidprice)) { |
| 451 |
$base_uri_data['idprice'] = $pidprice; |
| 452 |
} |
| 453 |
if (!empty($pbooknow)) { |
| 454 |
$base_uri_data['booknow'] = $pbooknow; |
| 455 |
} |
| 456 |
if ($ptmpl == 'component') { |
| 457 |
$base_uri_data['tmpl'] = 'component'; |
| 458 |
} |
| 459 |
?> |
| 460 |
<div> |
| 461 |
<a class="vbmodelink<?php echo $vmode == 3 ? ' vbmodelink-active' : ''; ?>" href="index.php?<?php echo http_build_query(array_merge($base_uri_data, ['vmode' => 3])); ?>"><?php VikBookingIcons::e('calendar'); ?> <span><?php echo JText::translate('VBTHREEMONTHS'); ?></span></a> |
| 462 |
<a class="vbmodelink<?php echo $vmode == 6 ? ' vbmodelink-active' : ''; ?>" href="index.php?<?php echo http_build_query(array_merge($base_uri_data, ['vmode' => 6])); ?>"><?php VikBookingIcons::e('calendar'); ?> <span><?php echo JText::translate('VBSIXMONTHS'); ?></span></a> |
| 463 |
<a class="vbmodelink<?php echo $vmode == 12 ? ' vbmodelink-active' : ''; ?>" href="index.php?<?php echo http_build_query(array_merge($base_uri_data, ['vmode' => 12])); ?>"><?php VikBookingIcons::e('calendar'); ?> <span><?php echo JText::translate('VBTWELVEMONTHS'); ?></span></a> |
| 464 |
<a class="vbmodelink<?php echo $vmode == 24 ? ' vbmodelink-active' : ''; ?>" href="index.php?<?php echo http_build_query(array_merge($base_uri_data, ['vmode' => 24])); ?>"><?php VikBookingIcons::e('calendar'); ?> <span><?php echo JText::translate('VBTWOYEARS'); ?></span></a> |
| 465 |
</div> |
| 466 |
<?php |
| 467 |
} |
| 468 |
?> |
| 469 |
<div class="vbo-calendar-cals-container"> |
| 470 |
<?php |
| 471 |
$arr = getdate(); |
| 472 |
$mon = $arr['mon']; |
| 473 |
$year = $arr['year']; |
| 474 |
$dayts = mktime(0, 0, 0, $mon, 1, $year); |
| 475 |
$newarr = getdate($dayts); |
| 476 |
|
| 477 |
$firstwday = (int)VikBooking::getFirstWeekDay(true); |
| 478 |
$days_labels = array( |
| 479 |
JText::translate('VBSUN'), |
| 480 |
JText::translate('VBMON'), |
| 481 |
JText::translate('VBTUE'), |
| 482 |
JText::translate('VBWED'), |
| 483 |
JText::translate('VBTHU'), |
| 484 |
JText::translate('VBFRI'), |
| 485 |
JText::translate('VBSAT') |
| 486 |
); |
| 487 |
$days_indexes = array(); |
| 488 |
for ($i = 0; $i < 7; $i++) { |
| 489 |
$days_indexes[$i] = (6-($firstwday-$i)+1)%7; |
| 490 |
} |
| 491 |
|
| 492 |
for ($jj = 1; $jj <= $vmode; $jj++) { |
| 493 |
$d_count = 0; |
| 494 |
echo '<div class="vbo-calendar-cal-container">'; |
| 495 |
$cal = ""; |
| 496 |
?> |
| 497 |
<table class="vbadmincaltable"> |
| 498 |
<tr class="vbadmincaltrmon"> |
| 499 |
<td colspan="7" align="center"><?php echo VikBooking::sayMonth($newarr['mon'])." ".$newarr['year']; ?></td> |
| 500 |
</tr> |
| 501 |
<tr class="vbadmincaltrmdays"> |
| 502 |
<?php |
| 503 |
for ($i = 0; $i < 7; $i++) { |
| 504 |
$d_ind = ($i + $firstwday) < 7 ? ($i + $firstwday) : ($i + $firstwday - 7); |
| 505 |
echo '<td>'.$days_labels[$d_ind].'</td>'; |
| 506 |
} |
| 507 |
?> |
| 508 |
</tr> |
| 509 |
<tr> |
| 510 |
<?php |
| 511 |
for ($i=0, $n = $days_indexes[$newarr['wday']]; $i < $n; $i++, $d_count++) { |
| 512 |
$cal .= "<td align=\"center\"> </td>"; |
| 513 |
} |
| 514 |
while ($newarr['mon'] == $mon) { |
| 515 |
if ($d_count > 6) { |
| 516 |
$d_count = 0; |
| 517 |
$cal .= "</tr>\n<tr>"; |
| 518 |
} |
| 519 |
$dclass = "free"; |
| 520 |
$dalt = ""; |
| 521 |
$bid = ""; |
| 522 |
$totfound = 0; |
| 523 |
if ($check) { |
| 524 |
foreach ($busy as $b) { |
| 525 |
$tmpone = getdate($b['checkin']); |
| 526 |
$ritts = mktime(0, 0, 0, $tmpone['mon'], $tmpone['mday'], $tmpone['year']); |
| 527 |
$tmptwo = getdate($b['checkout']); |
| 528 |
$conts = mktime(0, 0, 0, $tmptwo['mon'], $tmptwo['mday'], $tmptwo['year']); |
| 529 |
if ($newarr[0] >= $ritts && $newarr[0] < $conts) { |
| 530 |
$dclass = "busy"; |
| 531 |
$bid = $b['idorder']; |
| 532 |
if ((int)$b['closure']) { |
| 533 |
$dclass .= " busy-closure"; |
| 534 |
$dalt = JText::translate('VBDBTEXTROOMCLOSED'); |
| 535 |
} elseif ($newarr[0] == $ritts) { |
| 536 |
$dalt = JText::translate('VBPICKUPAT')." ".date('H:i', $b['checkin']); |
| 537 |
} elseif ($newarr[0] == $conts) { |
| 538 |
$dalt = JText::translate('VBRELEASEAT')." ".date('H:i', $b['checkout']); |
| 539 |
} |
| 540 |
$totfound++; |
| 541 |
} |
| 542 |
} |
| 543 |
} |
| 544 |
$useday = ($newarr['mday'] < 10 ? "0".$newarr['mday'] : $newarr['mday']); |
| 545 |
if ($totfound > 0 && $totfound < $room['units']) { |
| 546 |
$dclass .= " vbo-partially"; |
| 547 |
} |
| 548 |
if ($totfound == 1) { |
| 549 |
$dlnk = "<a href=\"index.php?option=com_vikbooking&task=editbusy&cid[]=".$bid."\"".($ptmpl == 'component' ? ' target="_blank"' : '').">".$useday."</a>"; |
| 550 |
$cal .= "<td align=\"center\" data-daydate=\"".date($df, $newarr[0])."\" class=\"".$dclass."\"".(!empty($dalt) ? " title=\"".$dalt."\"" : "").">".$dlnk."</td>\n"; |
| 551 |
} elseif ($totfound > 1) { |
| 552 |
$dlnk = "<a href=\"index.php?option=com_vikbooking&task=choosebusy&idroom=".$room['id']."&ts=".$newarr[0]."\"".($ptmpl == 'component' ? ' target="_blank"' : '').">".$useday."</a>"; |
| 553 |
$cal .= "<td align=\"center\" data-daydate=\"".date($df, $newarr[0])."\" class=\"".$dclass."\">".$dlnk."</td>\n"; |
| 554 |
} else { |
| 555 |
$dlnk = $useday; |
| 556 |
$cal .= "<td align=\"center\" data-daydate=\"".date($df, $newarr[0])."\" class=\"".$dclass."\">".$dlnk."</td>\n"; |
| 557 |
} |
| 558 |
$next = $newarr['mday'] + 1; |
| 559 |
$dayts = mktime(0, 0, 0, $newarr['mon'], $next, $newarr['year']); |
| 560 |
$newarr = getdate($dayts); |
| 561 |
$d_count++; |
| 562 |
} |
| 563 |
|
| 564 |
for ($i = $d_count; $i <= 6; $i++) { |
| 565 |
$cal .= "<td align=\"center\"> </td>"; |
| 566 |
} |
| 567 |
|
| 568 |
echo $cal; |
| 569 |
?> |
| 570 |
</tr> |
| 571 |
</table> |
| 572 |
<?php |
| 573 |
echo "</div>"; |
| 574 |
if ($mon == 12) { |
| 575 |
$mon = 1; |
| 576 |
$year += 1; |
| 577 |
$dayts = mktime(0, 0, 0, $mon, 01, $year); |
| 578 |
} else { |
| 579 |
$mon += 1; |
| 580 |
$dayts = mktime(0, 0, 0, $mon, 01, $year); |
| 581 |
} |
| 582 |
$newarr = getdate($dayts); |
| 583 |
} |
| 584 |
?> |
| 585 |
</div> |
| 586 |
</div> |
| 587 |
</div> |
| 588 |
|
| 589 |
</div> |
| 590 |
|
| 591 |
<div class="vbo-calendar-modal-helper" style="display: none;"> |
| 592 |
<div class="vbo-calendar-cfields-filler"> |
| 593 |
<div class="vbo-calendar-cfields-topcont"> |
| 594 |
<div class="vbo-calendar-cfields-search"> |
| 595 |
<label for="vbo-searchcust"><?php echo JText::translate('VBOSEARCHEXISTCUST'); ?></label> |
| 596 |
<span id="vbo-searchcust-loading"> |
| 597 |
<i class="vboicn-hour-glass"></i> |
| 598 |
</span> |
| 599 |
<input type="text" id="vbo-searchcust" autocomplete="off" value="" placeholder="<?php echo htmlspecialchars(JText::translate('VBOSEARCHCUSTBY')); ?>" size="35" /> |
| 600 |
<div id="vbo-searchcust-res"></div> |
| 601 |
</div> |
| 602 |
</div> |
| 603 |
<div class="vbo-calendar-cfields-inner"> |
| 604 |
<?php |
| 605 |
foreach ($all_cfields as $cfield) { |
| 606 |
if ($cfield['type'] == 'text' && $cfield['isphone'] == 1) { |
| 607 |
?> |
| 608 |
<div class="vbo-calendar-cfield-entry"> |
| 609 |
<label for="cfield<?php echo $cfield['id']; ?>" data-fieldid="<?php echo $cfield['id']; ?>"><?php echo JText::translate($cfield['name']); ?></label> |
| 610 |
<span> |
| 611 |
<?php |
| 612 |
echo $vbo_app->printPhoneInputField([ |
| 613 |
'id' => 'cfield' . $cfield['id'], |
| 614 |
'class' => 'vbo-calendar-cfield-phone', |
| 615 |
'data-isemail' => '0', |
| 616 |
'data-isnominative' => '0', |
| 617 |
'data-isphone' => '1' |
| 618 |
], [ |
| 619 |
'fullNumberOnBlur' => true |
| 620 |
]); |
| 621 |
?> |
| 622 |
</span> |
| 623 |
</div> |
| 624 |
<?php |
| 625 |
} elseif ($cfield['type'] == 'text') { |
| 626 |
?> |
| 627 |
<div class="vbo-calendar-cfield-entry"> |
| 628 |
<label for="cfield<?php echo $cfield['id']; ?>" data-fieldid="<?php echo $cfield['id']; ?>"><?php echo JText::translate($cfield['name']); ?></label> |
| 629 |
<span> |
| 630 |
<input type="text" id="cfield<?php echo $cfield['id']; ?>" data-isemail="<?php echo ($cfield['isemail'] == 1 ? '1' : '0'); ?>" data-isnominative="<?php echo ($cfield['isnominative'] == 1 ? '1' : '0'); ?>" data-isphone="0" value="" size="35"/> |
| 631 |
</span> |
| 632 |
</div> |
| 633 |
<?php |
| 634 |
} elseif ($cfield['type'] == 'textarea') { |
| 635 |
?> |
| 636 |
<div class="vbo-calendar-cfield-entry"> |
| 637 |
<label for="cfield<?php echo $cfield['id']; ?>" data-fieldid="<?php echo $cfield['id']; ?>"><?php echo JText::translate($cfield['name']); ?></label> |
| 638 |
<span> |
| 639 |
<textarea id="cfield<?php echo $cfield['id']; ?>" rows="4" cols="35"></textarea> |
| 640 |
</span> |
| 641 |
</div> |
| 642 |
<?php |
| 643 |
} elseif ($cfield['type'] == 'country') { |
| 644 |
?> |
| 645 |
<div class="vbo-calendar-cfield-entry"> |
| 646 |
<label for="cfield<?php echo $cfield['id']; ?>" data-fieldid="<?php echo $cfield['id']; ?>"><?php echo JText::translate($cfield['name']); ?></label> |
| 647 |
<span> |
| 648 |
<select id="cfield<?php echo $cfield['id']; ?>" class="vbo-calendar-cfield-country"> |
| 649 |
<option value=""> </option> |
| 650 |
<?php |
| 651 |
foreach ($all_countries as $country) { |
| 652 |
?> |
| 653 |
<option value="<?php echo $country['country_name']; ?>" data-ccode="<?php echo $country['country_3_code']; ?>" data-c2code="<?php echo $country['country_2_code']; ?>"><?php echo $country['country_name']; ?></option> |
| 654 |
<?php |
| 655 |
} |
| 656 |
?> |
| 657 |
</select> |
| 658 |
</span> |
| 659 |
</div> |
| 660 |
<?php |
| 661 |
} elseif ($cfield['type'] == 'state') { |
| 662 |
?> |
| 663 |
<div class="vbo-calendar-cfield-entry"> |
| 664 |
<label for="cfield<?php echo $cfield['id']; ?>" data-fieldid="<?php echo $cfield['id']; ?>"><?php echo JText::translate($cfield['name']); ?></label> |
| 665 |
<span> |
| 666 |
<select id="cfield<?php echo $cfield['id']; ?>" class="vbo-calendar-cfield-state"> |
| 667 |
<option value="">-----</option> |
| 668 |
</select> |
| 669 |
</span> |
| 670 |
</div> |
| 671 |
<?php |
| 672 |
} |
| 673 |
} |
| 674 |
?> |
| 675 |
</div> |
| 676 |
</div> |
| 677 |
</div> |
| 678 |
|
| 679 |
<form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm"> |
| 680 |
<input type="hidden" name="task" value="" /> |
| 681 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 682 |
</form> |
| 683 |
|
| 684 |
<script type="text/javascript"> |
| 685 |
<?php echo ($poverview_change > 0 ? 'window.parent.hasNewBooking = true;' . "\n" : ''); ?> |
| 686 |
var vbo_glob_sel_nights = 0; |
| 687 |
var customers_search_vals = ""; |
| 688 |
var prev_tareat = null; |
| 689 |
var booknowmade = false; |
| 690 |
|
| 691 |
function vbCloseRoom() { |
| 692 |
var ckbox = jQuery('input[name="setclosed"]'); |
| 693 |
if (ckbox.length && ckbox.prop('checked')) { |
| 694 |
jQuery('#vbo-close-all-rooms-sel').show(); |
| 695 |
jQuery('#vbo-row-people').hide(); |
| 696 |
if (jQuery('#vbo-row-numrooms').length) { |
| 697 |
jQuery('#vbo-row-numrooms').hide(); |
| 698 |
} |
| 699 |
jQuery('#vbo-row-bstat').hide(); |
| 700 |
jQuery('#vbo-row-custcost').hide(); |
| 701 |
jQuery('#vbo-row-cmail').hide(); |
| 702 |
jQuery('#vbo-row-fillcustfields').hide(); |
| 703 |
jQuery('#vbo-row-bpay').hide(); |
| 704 |
jQuery("#vbo-website-rates-row").hide(); |
| 705 |
if (prev_tareat === null) { |
| 706 |
// save the previous customer information |
| 707 |
prev_tareat = jQuery('#vbcustdatatxtarea').val(); |
| 708 |
} |
| 709 |
jQuery('#vbcustdatatxtarea').val(Joomla.JText._('VBDBTEXTROOMCLOSED')); |
| 710 |
jQuery('#vbcustdatalbl').text(Joomla.JText._('ORDER_NOTES')); |
| 711 |
jQuery("#quickbsubmit").removeClass("btn-success").addClass("btn-danger").find("span").text(Joomla.JText._('VBSUBMCLOSEROOM')); |
| 712 |
// hide force booking and untick checkbox |
| 713 |
jQuery('#vbo-force-bookingdates').hide(); |
| 714 |
jQuery('input[name="forcebooking"]').prop('checked', false); |
| 715 |
} else { |
| 716 |
jQuery('#vbo-close-all-rooms-sel').hide(); |
| 717 |
jQuery('#vbo-row-people').show(); |
| 718 |
if (jQuery('#vbo-row-numrooms').length) { |
| 719 |
jQuery('#vbo-row-numrooms').show(); |
| 720 |
} |
| 721 |
jQuery('#vbo-row-bstat').show(); |
| 722 |
jQuery('#vbo-row-custcost').show(); |
| 723 |
jQuery('#vbo-row-cmail').show(); |
| 724 |
jQuery('#vbo-row-fillcustfields').show(); |
| 725 |
jQuery('#vbo-row-bpay').show(); |
| 726 |
jQuery('#vbcustdatatxtarea').val(prev_tareat + ""); |
| 727 |
jQuery('#vbcustdatalbl').text(Joomla.JText._('VBCUSTINFO')); |
| 728 |
jQuery("#quickbsubmit").removeClass("btn-danger").addClass("btn-success").find("span").text(Joomla.JText._('VBMAKERESERV')); |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
function showCustomFields() { |
| 733 |
let modal_body = VBOCore.displayModal({ |
| 734 |
suffix: 'calendar-cfields', |
| 735 |
extra_class: 'vbo-modal-tall', |
| 736 |
title: Joomla.JText._('VBFILLCUSTFIELDS'), |
| 737 |
body_prepend: true, |
| 738 |
footer_left: '<button type="button" class="btn" onclick="hideCustomFields();">' + Joomla.JText._('VBANNULLA') + '</button>', |
| 739 |
footer_right: '<button type="button" class="btn btn-success" onclick="applyCustomFieldsContent();"><i class="icon-edit"></i> ' + Joomla.JText._('VBAPPLY') + '</button>', |
| 740 |
dismiss_event: 'vbo-calendar-cfields-dismiss', |
| 741 |
onDismiss: () => { |
| 742 |
jQuery('.vbo-calendar-cfields-filler').appendTo('.vbo-calendar-modal-helper'); |
| 743 |
}, |
| 744 |
}); |
| 745 |
|
| 746 |
jQuery('.vbo-calendar-cfields-filler').appendTo(modal_body); |
| 747 |
|
| 748 |
setTimeout(function() { |
| 749 |
jQuery('#vbo-searchcust').focus(); |
| 750 |
}, 500); |
| 751 |
} |
| 752 |
|
| 753 |
function hideCustomFields() { |
| 754 |
VBOCore.emitEvent('vbo-calendar-cfields-dismiss'); |
| 755 |
} |
| 756 |
|
| 757 |
function applyCustomFieldsContent() { |
| 758 |
var cfields_cont = ""; |
| 759 |
var cfields_labels = new Array; |
| 760 |
var nominatives = new Array; |
| 761 |
var tot_rows = 1; |
| 762 |
jQuery(".vbo-calendar-cfields-inner .vbo-calendar-cfield-entry").each(function() { |
| 763 |
var cfield_name = jQuery(this).find("label").text(); |
| 764 |
var cfield_input = jQuery(this).find("span").find("input"); |
| 765 |
var cfield_textarea = jQuery(this).find("span").find("textarea"); |
| 766 |
var cfield_select = jQuery(this).find("span").find("select.vbo-calendar-cfield-country"); |
| 767 |
var cfield_state = jQuery(this).find("span").find("select.vbo-calendar-cfield-state"); |
| 768 |
var cfield_cont = ""; |
| 769 |
if (cfield_input.length) { |
| 770 |
cfield_cont = cfield_input.val(); |
| 771 |
if (cfield_input.attr("data-isemail") == "1" && cfield_cont && cfield_cont.length) { |
| 772 |
jQuery("#custmailfield").val(cfield_cont); |
| 773 |
} |
| 774 |
if (cfield_input.attr("data-isphone") == "1") { |
| 775 |
jQuery("#phonefield").val(cfield_cont); |
| 776 |
} |
| 777 |
if (cfield_input.attr("data-isnominative") == "1") { |
| 778 |
nominatives.push(cfield_cont); |
| 779 |
} |
| 780 |
} else if (cfield_textarea.length) { |
| 781 |
cfield_cont = cfield_textarea.val(); |
| 782 |
} else if (cfield_select.length) { |
| 783 |
cfield_cont = cfield_select.val(); |
| 784 |
if (cfield_cont && cfield_cont.length) { |
| 785 |
var country_code = jQuery("option:selected", cfield_select).attr("data-ccode"); |
| 786 |
if (country_code.length) { |
| 787 |
jQuery("#ccode_inpfield").val(country_code); |
| 788 |
} |
| 789 |
} |
| 790 |
} else if (cfield_state.length) { |
| 791 |
cfield_cont = cfield_state.val(); |
| 792 |
jQuery("#state_inpfield").val(cfield_cont); |
| 793 |
} |
| 794 |
if (cfield_cont && cfield_cont.length) { |
| 795 |
cfields_cont += cfield_name + ": " + cfield_cont + "\r\n"; |
| 796 |
tot_rows++; |
| 797 |
cfields_labels.push(cfield_name + ":"); |
| 798 |
} |
| 799 |
}); |
| 800 |
if (cfields_cont.length) { |
| 801 |
cfields_cont = cfields_cont.replace(/\r\n+$/, ""); |
| 802 |
} |
| 803 |
if (nominatives.length > 1) { |
| 804 |
jQuery("#t_first_name_inpfield").val(nominatives[0]); |
| 805 |
jQuery("#t_last_name_inpfield").val(nominatives[1]); |
| 806 |
} |
| 807 |
jQuery("#vbcustdatatxtarea").val(cfields_cont); |
| 808 |
jQuery("#vbcustdatatxtarea").attr("rows", tot_rows); |
| 809 |
// highlight custom fields labels |
| 810 |
if (jQuery('#vbo-highlight-cfields').length) { |
| 811 |
jQuery("#vbcustdatatxtarea").highlightTextarea('destroy'); |
| 812 |
} |
| 813 |
jQuery("#vbcustdatatxtarea").highlightTextarea({ |
| 814 |
words: cfields_labels, |
| 815 |
color: "#ddd", |
| 816 |
id: "vbo-highlight-cfields" |
| 817 |
}); |
| 818 |
// end highlight |
| 819 |
hideCustomFields(); |
| 820 |
} |
| 821 |
|
| 822 |
function vbCalcNights() { |
| 823 |
vbo_glob_sel_nights = 0; |
| 824 |
var vbcheckin = document.getElementById("checkindate").value; |
| 825 |
var vbcheckout = document.getElementById("checkoutdate").value; |
| 826 |
if (vbcheckin.length > 0 && vbcheckout.length > 0) { |
| 827 |
var vbcheckinp = vbcheckin.split("/"); |
| 828 |
var vbcheckoutp = vbcheckout.split("/"); |
| 829 |
var vbo_df = "<?php echo $vbo_df; ?>"; |
| 830 |
if (vbo_df == "%d/%m/%Y") { |
| 831 |
var vbinmonth = parseInt(vbcheckinp[1]); |
| 832 |
vbinmonth = vbinmonth - 1; |
| 833 |
var vbinday = parseInt(vbcheckinp[0], 10); |
| 834 |
var vbcheckind = new Date(vbcheckinp[2], vbinmonth, vbinday); |
| 835 |
var vboutmonth = parseInt(vbcheckoutp[1]); |
| 836 |
vboutmonth = vboutmonth - 1; |
| 837 |
var vboutday = parseInt(vbcheckoutp[0], 10); |
| 838 |
var vbcheckoutd = new Date(vbcheckoutp[2], vboutmonth, vboutday); |
| 839 |
}else if (vbo_df == "%m/%d/%Y") { |
| 840 |
var vbinmonth = parseInt(vbcheckinp[0]); |
| 841 |
vbinmonth = vbinmonth - 1; |
| 842 |
var vbinday = parseInt(vbcheckinp[1], 10); |
| 843 |
var vbcheckind = new Date(vbcheckinp[2], vbinmonth, vbinday); |
| 844 |
var vboutmonth = parseInt(vbcheckoutp[0]); |
| 845 |
vboutmonth = vboutmonth - 1; |
| 846 |
var vboutday = parseInt(vbcheckoutp[1], 10); |
| 847 |
var vbcheckoutd = new Date(vbcheckoutp[2], vboutmonth, vboutday); |
| 848 |
} else { |
| 849 |
var vbinmonth = parseInt(vbcheckinp[1]); |
| 850 |
vbinmonth = vbinmonth - 1; |
| 851 |
var vbinday = parseInt(vbcheckinp[2], 10); |
| 852 |
var vbcheckind = new Date(vbcheckinp[0], vbinmonth, vbinday); |
| 853 |
var vboutmonth = parseInt(vbcheckoutp[1]); |
| 854 |
vboutmonth = vboutmonth - 1; |
| 855 |
var vboutday = parseInt(vbcheckoutp[2], 10); |
| 856 |
var vbcheckoutd = new Date(vbcheckoutp[0], vboutmonth, vboutday); |
| 857 |
} |
| 858 |
var vbdivider = 1000 * 60 * 60 * 24; |
| 859 |
var vbints = vbcheckind.getTime(); |
| 860 |
var vboutts = vbcheckoutd.getTime(); |
| 861 |
if (vboutts > vbints) { |
| 862 |
//var vbnights = Math.ceil((vboutts - vbints) / (vbdivider)); |
| 863 |
var utc1 = Date.UTC(vbcheckind.getFullYear(), vbcheckind.getMonth(), vbcheckind.getDate()); |
| 864 |
var utc2 = Date.UTC(vbcheckoutd.getFullYear(), vbcheckoutd.getMonth(), vbcheckoutd.getDate()); |
| 865 |
var vbnights = Math.ceil((utc2 - utc1) / vbdivider); |
| 866 |
if (vbnights > 0) { |
| 867 |
vbo_glob_sel_nights = vbnights; |
| 868 |
jQuery('#vbjstotnights').show(); |
| 869 |
jQuery("#vbo-numnights").val(vbnights); |
| 870 |
// update average cost per night |
| 871 |
vbCalcDailyCost(document.getElementById("cust_cost").value); |
| 872 |
} else { |
| 873 |
jQuery('#vbjstotnights').hide(); |
| 874 |
} |
| 875 |
} else { |
| 876 |
jQuery('#vbjstotnights').hide(); |
| 877 |
} |
| 878 |
} else { |
| 879 |
jQuery('#vbjstotnights').hide(); |
| 880 |
} |
| 881 |
} |
| 882 |
|
| 883 |
function vbCalcDailyCost(cur_val) { |
| 884 |
// trigger calculation of website rates |
| 885 |
vboCalcWebsiteRates(); |
| 886 |
// |
| 887 |
if (cur_val.length && !isNaN(cur_val) && vbo_glob_sel_nights > 0) { |
| 888 |
var cur_float = parseFloat(cur_val); |
| 889 |
var selopts = jQuery("#avg-daycost").find("select").find("option"); |
| 890 |
// total cost with average cost per night |
| 891 |
var avg_cost = (cur_float / vbo_glob_sel_nights).toFixed(<?php echo (int)$formatparts[0]; ?>); |
| 892 |
var avg_cost_str = "<?php echo $currencysymb; ?> " + avg_cost + "/" + Joomla.JText._('VBDAY') + " = <?php echo $currencysymb; ?> " + cur_float.toFixed(<?php echo (int)$formatparts[0]; ?>); |
| 893 |
selopts.first().text(avg_cost_str); |
| 894 |
// cost multiplied by number of nights |
| 895 |
var final_cost = (cur_float * vbo_glob_sel_nights).toFixed(<?php echo (int)$formatparts[0]; ?>); |
| 896 |
var final_cost_str = "<?php echo $currencysymb; ?> " + cur_float.toFixed(<?php echo (int)$formatparts[0]; ?>) + "/" + Joomla.JText._('VBDAY') + " = <?php echo $currencysymb; ?> " + final_cost; |
| 897 |
selopts.last().text(final_cost_str); |
| 898 |
// show drop down |
| 899 |
jQuery("#avg-daycost").show(); |
| 900 |
} else { |
| 901 |
jQuery("#avg-daycost").hide(); |
| 902 |
} |
| 903 |
} |
| 904 |
|
| 905 |
function vboCalcWebsiteRates() { |
| 906 |
// unset previously selected rates, if any |
| 907 |
vboUnsetWebsiteRate(); |
| 908 |
// hide force booking and untick checkbox |
| 909 |
jQuery('#vbo-force-bookingdates').hide(); |
| 910 |
jQuery('input[name="forcebooking"]').prop('checked', false); |
| 911 |
// |
| 912 |
var checkinfdate = jQuery("#checkindate").val(); |
| 913 |
var adults = jQuery("#vbo-sel-adults").val(); |
| 914 |
var children = jQuery("#vbo-sel-children").val(); |
| 915 |
var units = jQuery("#vbo-sel-numrooms").val(); |
| 916 |
if (!checkinfdate.length || vbo_glob_sel_nights < 1 || jQuery("input[name=\"setclosed\"]").is(":checked") || <?php echo !empty($split_stay) ? 'true' : 'false'; ?>) { |
| 917 |
jQuery("#vbo-website-rates-row").hide(); |
| 918 |
return false; |
| 919 |
} |
| 920 |
var jqxhr = jQuery.ajax({ |
| 921 |
type: "POST", |
| 922 |
url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=calc_rates'); ?>", |
| 923 |
data: { |
| 924 |
id_room: <?php echo $room['id']; ?>, |
| 925 |
checkinfdate: checkinfdate, |
| 926 |
num_nights: vbo_glob_sel_nights, |
| 927 |
num_adults: adults, |
| 928 |
num_children: children, |
| 929 |
units: units, |
| 930 |
only_rates: 1, |
| 931 |
tmpl: "component" |
| 932 |
} |
| 933 |
}).done(function(resp) { |
| 934 |
var obj_res = null; |
| 935 |
try { |
| 936 |
obj_res = typeof resp === 'string' ? JSON.parse(resp) : resp; |
| 937 |
} catch(err) { |
| 938 |
console.error("could not parse JSON response", resp); |
| 939 |
} |
| 940 |
if (obj_res === null || !Array.isArray(obj_res)) { |
| 941 |
jQuery("#vbo-website-rates-row").hide(); |
| 942 |
console.info("invalid JSON response", resp); |
| 943 |
return false; |
| 944 |
} |
| 945 |
if (jQuery("input[name=\"setclosed\"]").is(":checked")) { |
| 946 |
jQuery("#vbo-website-rates-row").hide(); |
| 947 |
return false; |
| 948 |
} |
| 949 |
if (obj_res.hasOwnProperty(1) && obj_res[1] == -1 && !jQuery('input[name="setclosed"]').prop('checked')) { |
| 950 |
// the room is not available or has no rates, display force booking toggle |
| 951 |
jQuery('#vbo-force-bookingdates').show(); |
| 952 |
if (typeof obj_res[0] == 'string' && obj_res[0].indexOf('e4j.error') >= 0) { |
| 953 |
jQuery('#vbo-force-bookingdates').find('.vbo-param-setting-comment').text(obj_res[0].replace('e4j.error.', '')); |
| 954 |
} else { |
| 955 |
jQuery('#vbo-force-bookingdates').find('.vbo-param-setting-comment').text(''); |
| 956 |
} |
| 957 |
} |
| 958 |
if (!obj_res[0].hasOwnProperty("idprice")) { |
| 959 |
jQuery("#vbo-website-rates-row").hide(); |
| 960 |
console.log("error in response", resp); |
| 961 |
return false; |
| 962 |
} |
| 963 |
// check whether rates are inclusive of taxes |
| 964 |
var vbo_tax_included = <?php echo $prices_vat_included; ?>; |
| 965 |
// display the rates obtained |
| 966 |
var wrhtml = ""; |
| 967 |
for (var i in obj_res) { |
| 968 |
if (!obj_res.hasOwnProperty(i)) { |
| 969 |
continue; |
| 970 |
} |
| 971 |
if (!vbo_tax_included && obj_res[i].hasOwnProperty('net') && obj_res[i].hasOwnProperty('fnet')) { |
| 972 |
obj_res[i]['tot'] = obj_res[i]['net']; |
| 973 |
obj_res[i]['ftot'] = obj_res[i]['fnet']; |
| 974 |
} |
| 975 |
wrhtml += "<div class=\"vbo-cal-wbrate-wrap\" onclick=\"vboSelWebsiteRate(this);\">"; |
| 976 |
wrhtml += "<div class=\"vbo-cal-wbrate-inner\">"; |
| 977 |
wrhtml += "<span class=\"vbo-cal-wbrate-name\" data-idprice=\"" + obj_res[i]['idprice'] + "\">" + obj_res[i]['name'] + "</span>"; |
| 978 |
wrhtml += "<span class=\"vbo-cal-wbrate-cost\" data-cost=\"" + obj_res[i]['tot'] + "\">" + obj_res[i]['ftot'] + "</span>"; |
| 979 |
wrhtml += "</div>"; |
| 980 |
wrhtml += "</div>"; |
| 981 |
} |
| 982 |
jQuery("#vbo-website-rates-cont").html(wrhtml); |
| 983 |
jQuery("#vbo-website-rates-row").fadeIn(); |
| 984 |
if (<?php echo $pidprice > 0 && $pbooknow > 0 ? 'true' : 'false'; ?> && !booknowmade) { |
| 985 |
// we get here by clicking the book-now button from the rates calculator only once |
| 986 |
booknowmade = true; |
| 987 |
// trigger the click for the requested rate plan ID |
| 988 |
jQuery('.vbo-cal-wbrate-name[data-idprice="<?php echo $pidprice; ?>"]').closest('.vbo-cal-wbrate-wrap').trigger('click'); |
| 989 |
} |
| 990 |
}).fail(function() { |
| 991 |
jQuery("#vbo-website-rates-row").hide(); |
| 992 |
console.error("Error calculating the rates"); |
| 993 |
}); |
| 994 |
} |
| 995 |
|
| 996 |
function vboSelWebsiteRate(elem) { |
| 997 |
var rate = jQuery(elem); |
| 998 |
var idprice = rate.find('.vbo-cal-wbrate-name').attr('data-idprice'); |
| 999 |
var cost = rate.find('.vbo-cal-wbrate-cost').attr('data-cost'); |
| 1000 |
var prev_idprice = jQuery('#booking-idprice').val(); |
| 1001 |
// reset all selected classes |
| 1002 |
jQuery('.vbo-cal-wbrate-wrap').removeClass('vbo-cal-wbrate-wrap-selected'); |
| 1003 |
if (prev_idprice.length && prev_idprice == idprice) { |
| 1004 |
// rate plan has been de-selected |
| 1005 |
jQuery('#booking-idprice').val(""); |
| 1006 |
jQuery('#booking-roomcost').val(""); |
| 1007 |
jQuery('#cust_cost').attr('readonly', false); |
| 1008 |
} else { |
| 1009 |
// rate plan has been selected |
| 1010 |
rate.addClass('vbo-cal-wbrate-wrap-selected'); |
| 1011 |
jQuery('#booking-idprice').val(idprice); |
| 1012 |
jQuery('#booking-roomcost').val(cost); |
| 1013 |
jQuery('#cust_cost').attr('readonly', true); |
| 1014 |
} |
| 1015 |
} |
| 1016 |
|
| 1017 |
function vboUnsetWebsiteRate() { |
| 1018 |
jQuery('#booking-idprice').val(""); |
| 1019 |
jQuery('#booking-roomcost').val(""); |
| 1020 |
jQuery('.vbo-cal-wbrate-wrap').removeClass('vbo-cal-wbrate-wrap-selected'); |
| 1021 |
jQuery('#cust_cost').attr('readonly', false); |
| 1022 |
} |
| 1023 |
|
| 1024 |
function vboReloadStates(country_3_code) { |
| 1025 |
var states_elem = jQuery('select.vbo-calendar-cfield-state'); |
| 1026 |
|
| 1027 |
// unset the current states/provinces |
| 1028 |
states_elem.html(''); |
| 1029 |
|
| 1030 |
if (!country_3_code || !country_3_code.length) { |
| 1031 |
return; |
| 1032 |
} |
| 1033 |
|
| 1034 |
// make a request to load the states/provinces of the selected country |
| 1035 |
VBOCore.doAjax( |
| 1036 |
"<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=states.load_from_country'); ?>", |
| 1037 |
{ |
| 1038 |
country_3_code: country_3_code, |
| 1039 |
tmpl: "component" |
| 1040 |
}, |
| 1041 |
(response) => { |
| 1042 |
try { |
| 1043 |
var obj_res = typeof response === 'string' ? JSON.parse(response) : response; |
| 1044 |
if (!obj_res) { |
| 1045 |
console.error('Unexpected JSON response', obj_res); |
| 1046 |
return false; |
| 1047 |
} |
| 1048 |
|
| 1049 |
// append empty value |
| 1050 |
states_elem.append('<option value="">-----</option>'); |
| 1051 |
|
| 1052 |
for (var i = 0; i < obj_res.length; i++) { |
| 1053 |
// append state |
| 1054 |
states_elem.append('<option value="' + obj_res[i]['state_2_code'] + '">' + obj_res[i]['state_name'] + '</option>'); |
| 1055 |
} |
| 1056 |
} catch(err) { |
| 1057 |
console.error('could not parse JSON response', err, response); |
| 1058 |
} |
| 1059 |
}, |
| 1060 |
(error) => { |
| 1061 |
console.error(error); |
| 1062 |
} |
| 1063 |
); |
| 1064 |
} |
| 1065 |
|
| 1066 |
jQuery(function() { |
| 1067 |
|
| 1068 |
jQuery('.vbo-calendar-cfield-country').on('change', function() { |
| 1069 |
// trigger event for phone number |
| 1070 |
jQuery('.vbo-calendar-cfield-phone').trigger('vboupdatephonenumber', jQuery(this).find('option:selected').attr('data-c2code')); |
| 1071 |
// reload state/province |
| 1072 |
vboReloadStates(jQuery(this).find('option:selected').attr('data-ccode')); |
| 1073 |
}); |
| 1074 |
|
| 1075 |
jQuery('td.free').click(function() { |
| 1076 |
var indate = jQuery('#checkindate').val(); |
| 1077 |
var outdate = jQuery('#checkoutdate').val(); |
| 1078 |
var clickdate = jQuery(this).attr('data-daydate'); |
| 1079 |
if (!(indate.length > 0)) { |
| 1080 |
jQuery('#checkindate').datepicker("setDate", clickdate); |
| 1081 |
} else if (!(outdate.length > 0) && clickdate != indate) { |
| 1082 |
jQuery('#checkoutdate').datepicker("setDate", clickdate); |
| 1083 |
} else { |
| 1084 |
jQuery('#checkoutdate').datepicker("setDate", ''); |
| 1085 |
jQuery('#checkindate').datepicker("setDate", clickdate); |
| 1086 |
} |
| 1087 |
jQuery(".ui-datepicker-current-day").click(); |
| 1088 |
}); |
| 1089 |
|
| 1090 |
jQuery("#quickbsubmit").click(function() { |
| 1091 |
setTimeout(function() { |
| 1092 |
jQuery(this).prop('disabled', true); |
| 1093 |
}, 200); |
| 1094 |
}); |
| 1095 |
|
| 1096 |
jQuery("#vbo-calendar-changeroom").select2(); |
| 1097 |
if (jQuery("#vbo-calendar-closeall").length) { |
| 1098 |
jQuery("#vbo-calendar-closeall").select2({placeholder: "- " + Joomla.JText._('VBOCALCLOSEOTHERROOMS') + " -", width: "300px"}); |
| 1099 |
} |
| 1100 |
|
| 1101 |
jQuery("#vbo-sel-numrooms, #vbo-sel-adults").change(function() { |
| 1102 |
vboCalcWebsiteRates(); |
| 1103 |
}); |
| 1104 |
|
| 1105 |
jQuery('.vbo-calendar-cfield-entry input[data-isemail="1"]').first().blur(function() { |
| 1106 |
var curemail = jQuery(this).val(); |
| 1107 |
if (curemail.length) { |
| 1108 |
var jqxhr = jQuery.ajax({ |
| 1109 |
type: "POST", |
| 1110 |
url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=searchcustomer'); ?>", |
| 1111 |
data: { |
| 1112 |
kw: curemail, |
| 1113 |
email: 1, |
| 1114 |
tmpl: "component" |
| 1115 |
} |
| 1116 |
}).done(function(cont) { |
| 1117 |
try { |
| 1118 |
var obj_res = typeof cont === 'string' ? JSON.parse(cont) : cont; |
| 1119 |
alert(Joomla.JText._('VBERRCUSTOMEREMAILEXISTS') + " (" + obj_res['first_name'] + " " + obj_res['last_name'] + ")"); |
| 1120 |
} catch(e) { |
| 1121 |
console.error(e); |
| 1122 |
} |
| 1123 |
}).fail(function() { |
| 1124 |
console.log("Error searching for existing email"); |
| 1125 |
}); |
| 1126 |
} |
| 1127 |
}); |
| 1128 |
|
| 1129 |
jQuery("#vbfillcustfields").click(function() { |
| 1130 |
showCustomFields(); |
| 1131 |
}); |
| 1132 |
|
| 1133 |
// search customer - start |
| 1134 |
var vbocustsdelay = (function() { |
| 1135 |
var timer = 0; |
| 1136 |
return function(callback, ms) { |
| 1137 |
clearTimeout (timer); |
| 1138 |
timer = setTimeout(callback, ms); |
| 1139 |
}; |
| 1140 |
})(); |
| 1141 |
|
| 1142 |
function vboCustomerSearch(words) { |
| 1143 |
jQuery("#vbo-searchcust-res").hide().html(""); |
| 1144 |
jQuery("#vbo-searchcust-loading").show(); |
| 1145 |
var jqxhr = jQuery.ajax({ |
| 1146 |
type: "POST", |
| 1147 |
url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=searchcustomer'); ?>", |
| 1148 |
data: { |
| 1149 |
kw: words, |
| 1150 |
tmpl: "component" |
| 1151 |
} |
| 1152 |
}).done(function(cont) { |
| 1153 |
if (cont) { |
| 1154 |
var obj_res = typeof cont === 'string' ? JSON.parse(cont) : cont; |
| 1155 |
customers_search_vals = obj_res[0]; |
| 1156 |
jQuery("#vbo-searchcust-res").html(obj_res[1]); |
| 1157 |
} else { |
| 1158 |
customers_search_vals = ""; |
| 1159 |
jQuery("#vbo-searchcust-res").html("----"); |
| 1160 |
} |
| 1161 |
jQuery("#vbo-searchcust-res").show(); |
| 1162 |
jQuery("#vbo-searchcust-loading").hide(); |
| 1163 |
}).fail(function() { |
| 1164 |
jQuery("#vbo-searchcust-loading").hide(); |
| 1165 |
alert("Error searching"); |
| 1166 |
}); |
| 1167 |
} |
| 1168 |
|
| 1169 |
jQuery("#vbo-searchcust").keyup(function(event) { |
| 1170 |
vbocustsdelay(function() { |
| 1171 |
var keywords = jQuery("#vbo-searchcust").val(); |
| 1172 |
var chars = keywords.length; |
| 1173 |
if (chars > 1) { |
| 1174 |
if ((event.which > 96 && event.which < 123) || (event.which > 64 && event.which < 91) || event.which == 13) { |
| 1175 |
vboCustomerSearch(keywords); |
| 1176 |
} |
| 1177 |
} else { |
| 1178 |
if (jQuery("#vbo-searchcust-res").is(":visible")) { |
| 1179 |
jQuery("#vbo-searchcust-res").hide(); |
| 1180 |
} |
| 1181 |
} |
| 1182 |
}, 600); |
| 1183 |
}); |
| 1184 |
// search customer - end |
| 1185 |
|
| 1186 |
// datepickers - start |
| 1187 |
jQuery("#checkindate").datepicker({ |
| 1188 |
showOn: "focus", |
| 1189 |
dateFormat: "<?php echo $juidf; ?>", |
| 1190 |
numberOfMonths: 1, |
| 1191 |
onSelect: function(selectedDate) { |
| 1192 |
var nownights = parseInt(jQuery("#vbo-numnights").val()); |
| 1193 |
var nowcheckin = jQuery("#checkindate").datepicker("getDate"); |
| 1194 |
var nowcheckindate = new Date(nowcheckin.getTime()); |
| 1195 |
nowcheckindate.setDate(nowcheckindate.getDate() + nownights); |
| 1196 |
jQuery("#checkoutdate").datepicker("option", "minDate", nowcheckindate); |
| 1197 |
jQuery("#checkoutdate").datepicker("setDate", nowcheckindate); |
| 1198 |
vbCalcNights(); |
| 1199 |
} |
| 1200 |
}); |
| 1201 |
jQuery("#checkoutdate").datepicker({ |
| 1202 |
showOn: "focus", |
| 1203 |
dateFormat: "<?php echo $juidf; ?>", |
| 1204 |
numberOfMonths: 1, |
| 1205 |
onSelect: function(selectedDate) { |
| 1206 |
vbCalcNights(); |
| 1207 |
} |
| 1208 |
}); |
| 1209 |
jQuery(".vbodatepicker-trig-icon").click(function(){ |
| 1210 |
var jdp = jQuery(this).prev("input.hasDatepicker"); |
| 1211 |
if (jdp.length) { |
| 1212 |
jdp.focus(); |
| 1213 |
} |
| 1214 |
}); |
| 1215 |
jQuery("#vbo-numnights").on("change keyup", function() { |
| 1216 |
if (!jQuery("#checkindate").length) { |
| 1217 |
return; |
| 1218 |
} |
| 1219 |
var nownights = parseInt(jQuery(this).val()); |
| 1220 |
var nowcheckin = jQuery("#checkindate").datepicker("getDate"); |
| 1221 |
var nowcheckindate = new Date(nowcheckin.getTime()); |
| 1222 |
nowcheckindate.setDate(nowcheckindate.getDate() + nownights); |
| 1223 |
jQuery("#checkoutdate").datepicker("option", "minDate", nowcheckindate); |
| 1224 |
jQuery("#checkoutdate").datepicker("setDate", nowcheckindate); |
| 1225 |
vbo_glob_sel_nights = nownights; |
| 1226 |
// update average cost per night |
| 1227 |
vbCalcDailyCost(document.getElementById("cust_cost").value); |
| 1228 |
}); |
| 1229 |
// datepickers - end |
| 1230 |
<?php echo (!empty($pcheckin) ? 'jQuery("#checkindate").datepicker("setDate", "'.$pcheckin.'");'."\n" : ''); ?> |
| 1231 |
<?php echo (!empty($pcheckout) ? 'jQuery("#checkoutdate").datepicker("setDate", "'.$pcheckout.'");'."\n" : ''); ?> |
| 1232 |
<?php echo (!empty($pcheckin) || !empty($pcheckout) ? 'jQuery(".ui-datepicker-current-day").click();'."\n" : ''); ?> |
| 1233 |
}); |
| 1234 |
|
| 1235 |
jQuery(document).on("click", ".vbo-custsearchres-entry", function() { |
| 1236 |
var custid = jQuery(this).attr("data-custid"); |
| 1237 |
var custemail = jQuery(this).attr("data-email"); |
| 1238 |
var custphone = jQuery(this).attr("data-phone"); |
| 1239 |
var custcountry = jQuery(this).attr("data-country"); |
| 1240 |
var custfirstname = jQuery(this).attr("data-firstname"); |
| 1241 |
var custlastname = jQuery(this).attr("data-lastname"); |
| 1242 |
jQuery("#customer_id_inpfield").val(custid); |
| 1243 |
if (customers_search_vals.hasOwnProperty(custid)) { |
| 1244 |
jQuery.each(customers_search_vals[custid], function(cfid, cfval) { |
| 1245 |
var fill_field = jQuery("#cfield"+cfid); |
| 1246 |
if (fill_field.length) { |
| 1247 |
fill_field.val(cfval); |
| 1248 |
} |
| 1249 |
}); |
| 1250 |
} else { |
| 1251 |
jQuery("input[data-isnominative=\"1\"]").each(function(k, v) { |
| 1252 |
if (k == 0) { |
| 1253 |
jQuery(this).val(custfirstname); |
| 1254 |
return true; |
| 1255 |
} |
| 1256 |
if (k == 1) { |
| 1257 |
jQuery(this).val(custlastname); |
| 1258 |
return true; |
| 1259 |
} |
| 1260 |
return false; |
| 1261 |
}); |
| 1262 |
jQuery("input[data-isemail=\"1\"]").val(custemail); |
| 1263 |
jQuery("input[data-isphone=\"1\"]").val(custphone).trigger('vboupdatephonenumber'); |
| 1264 |
// populate main calendar form |
| 1265 |
jQuery("#custmailfield").val(custemail); |
| 1266 |
jQuery("#t_first_name_inpfield").val(custfirstname); |
| 1267 |
jQuery("#t_last_name_inpfield").val(custlastname); |
| 1268 |
// |
| 1269 |
} |
| 1270 |
applyCustomFieldsContent(); |
| 1271 |
if (custcountry.length) { |
| 1272 |
jQuery("#ccode_inpfield").val(custcountry); |
| 1273 |
} |
| 1274 |
if (custphone.length) { |
| 1275 |
jQuery("#phonefield").val(custphone); |
| 1276 |
} |
| 1277 |
}); |
| 1278 |
|
| 1279 |
var vborefreshingsel = false; |
| 1280 |
function vboCheckCloseOthers() { |
| 1281 |
if (!jQuery("#vbo-calendar-closeall").length || vborefreshingsel) { |
| 1282 |
// avoid recursion loop by triggering the change event for select2 |
| 1283 |
return; |
| 1284 |
} |
| 1285 |
var selall = jQuery('#vbo-calendar-closeall option[value="-1"]').is(':selected'); |
| 1286 |
// always select the current room unless all get de-selected |
| 1287 |
var optselected = jQuery('#vbo-calendar-closeall option:selected'); |
| 1288 |
var none_sel = !optselected.length ? true : false; |
| 1289 |
if (optselected.length === 1 && optselected.first().attr('data-currentr')) { |
| 1290 |
none_sel = true; |
| 1291 |
} |
| 1292 |
var curropt = jQuery('#vbo-calendar-closeall option[data-currentr="true"]'); |
| 1293 |
if (!none_sel) { |
| 1294 |
curropt.prop('selected', true); |
| 1295 |
curropt.prop('disabled', true); |
| 1296 |
} else { |
| 1297 |
curropt.prop('selected', false); |
| 1298 |
curropt.prop('disabled', true); |
| 1299 |
} |
| 1300 |
// |
| 1301 |
jQuery('#vbo-calendar-closeall').find('option').each(function() { |
| 1302 |
var curval = jQuery(this).val(); |
| 1303 |
var curroom = jQuery(this).attr('data-currentr'); |
| 1304 |
if (!curval.length || curval == '-1' || curroom) { |
| 1305 |
return true; |
| 1306 |
} |
| 1307 |
if (selall) { |
| 1308 |
jQuery(this).prop('disabled', true); |
| 1309 |
jQuery(this).prop('selected', false); |
| 1310 |
} else { |
| 1311 |
jQuery(this).prop('disabled', false); |
| 1312 |
} |
| 1313 |
}); |
| 1314 |
vboRefreshCloseOthers(); |
| 1315 |
} |
| 1316 |
|
| 1317 |
function vboRefreshCloseOthers() { |
| 1318 |
// prevent recursion loop |
| 1319 |
vborefreshingsel = true; |
| 1320 |
jQuery("#vbo-calendar-closeall").trigger('change'); |
| 1321 |
setTimeout(function() { |
| 1322 |
vborefreshingsel = false; |
| 1323 |
}, 200); |
| 1324 |
} |
| 1325 |
</script> |
| 1326 |
|