| @@ -1,0 +1,335 @@ | ||
| 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 | +$roomrows = $this->roomrows; | |
| 14 | +$rows = $this->rows; | |
| 15 | +$prices = $this->prices; | |
| 16 | +$allc = $this->allc; | |
| 17 | + | |
| 18 | +$vbo_app = VikBooking::getVboApplication(); | |
| 19 | +$vbo_app->loadSelect2(); | |
| 20 | + | |
| 21 | +// access room helper to detect LOS rates | |
| 22 | +$room_helper = VBORoomHelper::getInstance(); | |
| 23 | + | |
| 24 | +$currencysymb = VikBooking::getCurrencySymb(); | |
| 25 | +$idroom = $roomrows['id']; | |
| 26 | +$name = $roomrows['name']; | |
| 27 | +if (is_file(VBO_SITE_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$roomrows['img']) && getimagesize(VBO_SITE_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$roomrows['img'])) { | |
| 28 | + $img = '<img align="middle" class="maxninety" alt="Room Image" src="' . VBO_SITE_URI . 'resources/uploads/'.$roomrows['img'].'" />'; | |
| 29 | +} else { | |
| 30 | + $img = '<i class="' . VikBookingIcons::i('image', 'vbo-enormous-icn') . '"></i>'; | |
| 31 | +} | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * We add the names of the categories next to the name of the room for better identification. | |
| 35 | + * | |
| 36 | + * @since 1.13.5 | |
| 37 | + */ | |
| 38 | +if (!empty($roomrows['idcat'])) { | |
| 39 | + $parts = explode(';', rtrim($roomrows['idcat'], ';')); | |
| 40 | + $cat_names = array(); | |
| 41 | + foreach ($parts as $cat_id) { | |
| 42 | + if (empty($cat_id)) { | |
| 43 | + continue; | |
| 44 | + } | |
| 45 | + $cat_name = VikBooking::getCategoryName($cat_id); | |
| 46 | + if (empty($cat_name)) { | |
| 47 | + continue; | |
| 48 | + } | |
| 49 | + array_push($cat_names, $cat_name); | |
| 50 | + } | |
| 51 | + $name = count($cat_names) ? $name . ' (' . implode(', ', $cat_names) . ')' : $name; | |
| 52 | +} | |
| 53 | + | |
| 54 | +if (!empty($prices)) { | |
| 55 | +?> | |
| 56 | +<div class="vbo-admin-wizard-container"> | |
| 57 | + <div class="vbo-admin-wizard-inner"> | |
| 58 | + <?php | |
| 59 | + if (!empty($this->rows)) { | |
| 60 | + ?> | |
| 61 | + <a class="btn vbo-wizard-btn" href="index.php?option=com_vikbooking"><?php VikBookingIcons::e('home'); ?> <?php echo JText::translate('VBMENUDASHBOARD'); ?></a> | |
| 62 | + <?php | |
| 63 | + } | |
| 64 | + ?> | |
| 65 | + <a class="btn vbo-wizard-btn" href="javascript: void(0);" onclick="showVboWizard();"><?php VikBookingIcons::e('magic'); ?> <?php echo JText::translate('VBOTOGGLEWIZARD'); ?></a> | |
| 66 | + </div> | |
| 67 | +</div> | |
| 68 | +<?php | |
| 69 | +} | |
| 70 | +?> | |
| 71 | + | |
| 72 | +<div class="vbo-admin-container"> | |
| 73 | + <div class="vbo-config-maintab-left"> | |
| 74 | + <fieldset class="adminform"> | |
| 75 | + <div class="vbo-params-wrap"> | |
| 76 | + <legend class="adminlegend"> | |
| 77 | + <div class="vbo-quickres-head"> | |
| 78 | + <span><?php echo $name . " - " . JText::translate('VBINSERTFEE'); ?></span> | |
| 79 | + <div class="vbo-quickres-head-right"> | |
| 80 | + <form name="vbchroom" method="post" action="index.php?option=com_vikbooking"> | |
| 81 | + <input type="hidden" name="task" value="tariffs"/> | |
| 82 | + <select name="cid[]" id="roomsel" onchange="javascript: document.vbchroom.submit();"> | |
| 83 | + <?php | |
| 84 | + foreach ($allc as $cc) { | |
| 85 | + ?> | |
| 86 | + <option value="<?php echo $cc['id']; ?>"<?php echo $cc['id'] == $idroom ? ' selected="selected"' : ''; ?>><?php echo $cc['name']; ?></option> | |
| 87 | + <?php | |
| 88 | + } | |
| 89 | + ?> | |
| 90 | + </select> | |
| 91 | + </form> | |
| 92 | + </div> | |
| 93 | + </div> | |
| 94 | + </legend> | |
| 95 | + <div class="vbo-params-container vbo-tariffs-params-container"> | |
| 96 | + <div class="vbo-param-container"> | |
| 97 | + <div class="vbo-param-label"> | |
| 98 | + <div class="vbo-center"> | |
| 99 | + <?php echo $img; ?> | |
| 100 | + </div> | |
| 101 | + </div> | |
| 102 | + <div class="vbo-param-setting"> | |
| 103 | + <h4><?php echo JText::translate('VBDAILYFARES'); ?></h4> | |
| 104 | + <?php | |
| 105 | + if (empty($prices)) { | |
| 106 | + ?> | |
| 107 | + <p class="err"> | |
| 108 | + <span><?php echo JText::translate('VBMSGONE'); ?></span> | |
| 109 | + <a href="index.php?option=com_vikbooking&task=newprice"><?php echo JText::translate('VBHERE'); ?></a> | |
| 110 | + </p> | |
| 111 | + <?php | |
| 112 | + } | |
| 113 | + ?> | |
| 114 | + <form name="newd" method="post" action="index.php?option=com_vikbooking" onsubmit="javascript: if (!document.newd.ddaysfrom.value.match(/\S/)){alert('<?php echo addslashes(JText::translate('VBMSGTWO')); ?>'); return false;} else {return true;}"> | |
| 115 | + <div class="vbo-insertrates-cont"> | |
| 116 | + <div class="vbo-insertrates-top"> | |
| 117 | + <div class="vbo-ratestable-lbl"><?php echo JText::translate('VBDAYS'); ?></div> | |
| 118 | + <div class="vbo-ratestable-nights"> | |
| 119 | + <div class="vbo-ratestable-night-from"> | |
| 120 | + <span><?php echo JText::translate('VBDAYSFROM'); ?></span> | |
| 121 | + <input type="number" name="ddaysfrom" id="ddaysfrom" value="<?php echo !is_array($prices) ? '1' : ''; ?>" min="1" /> | |
| 122 | + </div> | |
| 123 | + <div class="vbo-ratestable-night-to"> | |
| 124 | + <span><?php echo JText::translate('VBDAYSTO'); ?></span> | |
| 125 | + <input type="number" name="ddaysto" id="ddaysto" value="<?php echo !is_array($prices) ? '30' : ''; ?>" min="1" max="999" /> | |
| 126 | + </div> | |
| 127 | + </div> | |
| 128 | + </div> | |
| 129 | + <div class="vbo-insertrates-bottom"> | |
| 130 | + <div class="vbo-ratestable-lbl"><?php echo JText::translate('VBDAILYPRICES'); ?></div> | |
| 131 | + <div class="vbo-ratestable-newprices"> | |
| 132 | + <?php | |
| 133 | + if (is_array($prices)) { | |
| 134 | + foreach ($prices as $pr) { | |
| 135 | + ?> | |
| 136 | + <div class="vbo-ratestable-newprice"> | |
| 137 | + <span class="vbo-ratestable-newprice-name"><?php echo $pr['name']; ?></span> | |
| 138 | + <span class="vbo-ratestable-newprice-cost"> | |
| 139 | + <span class="vbo-ratestable-newprice-cost-currency"><?php echo $currencysymb; ?></span> | |
| 140 | + <span class="vbo-ratestable-newprice-cost-amount"> | |
| 141 | + <input type="number" min="0" step="any" name="dprice<?php echo $pr['id']; ?>" value=""/> | |
| 142 | + </span> | |
| 143 | + </span> | |
| 144 | + <?php | |
| 145 | + if (!empty($pr['attr'])) { | |
| 146 | + ?> | |
| 147 | + <div class="vbo-ratestable-newprice-attribute"> | |
| 148 | + <span class="vbo-ratestable-newprice-name"><?php echo $pr['attr']; ?></span> | |
| 149 | + <span class="vbo-ratestable-newprice-cost"> | |
| 150 | + <input type="text" name="dattr<?php echo $pr['id']; ?>" value="" size="10"/> | |
| 151 | + </span> | |
| 152 | + </div> | |
| 153 | + <?php | |
| 154 | + } | |
| 155 | + ?> | |
| 156 | + </div> | |
| 157 | + <?php | |
| 158 | + } | |
| 159 | + } | |
| 160 | + ?> | |
| 161 | + </div> | |
| 162 | + </div> | |
| 163 | + </div> | |
| 164 | + <div class="vbo-insertrates-save"> | |
| 165 | + <input type="submit" class="btn vbo-config-btn" name="newdispcost" value="<?php echo JText::translate('VBINSERT'); ?>"/> | |
| 166 | + <input type="hidden" name="cid[]" value="<?php echo $idroom; ?>"/> | |
| 167 | + <input type="hidden" name="task" value="tariffs"/> | |
| 168 | + </div> | |
| 169 | + </form> | |
| 170 | + | |
| 171 | + </div> | |
| 172 | + </div> | |
| 173 | + </div> | |
| 174 | + </div> | |
| 175 | + </fieldset> | |
| 176 | + </div> | |
| 177 | + | |
| 178 | + <div class="vbo-config-maintab-right"> | |
| 179 | + <fieldset class="adminform"> | |
| 180 | + <div class="vbo-params-wrap"> | |
| 181 | + <div class="vbo-params-container vbo-list-table-container"> | |
| 182 | + <?php | |
| 183 | + if (empty($rows)) { | |
| 184 | + ?> | |
| 185 | + <p class="warn"><?php echo JText::translate('VBNOTARFOUND'); ?></p> | |
| 186 | + <form name="adminForm" id="adminForm" action="index.php" method="post"> | |
| 187 | + <input type="hidden" name="task" value=""> | |
| 188 | + <input type="hidden" name="option" value="com_vikbooking"> | |
| 189 | + </form> | |
| 190 | + <?php | |
| 191 | + } else { | |
| 192 | + $mainframe = JFactory::getApplication(); | |
| 193 | + $lim = $mainframe->getUserStateFromRequest("com_vikbooking.limit", 'limit', 15, 'int'); | |
| 194 | + $lim0 = VikRequest::getVar('limitstart', 0, '', 'int'); | |
| 195 | + $allpr = array(); | |
| 196 | + $tottar = array(); | |
| 197 | + foreach ($rows as $r) { | |
| 198 | + if (!array_key_exists($r['idprice'], $allpr)) { | |
| 199 | + $allpr[$r['idprice']] = VikBooking::getPriceAttr($r['idprice']); | |
| 200 | + } | |
| 201 | + $tottar[$r['days']][] = $r; | |
| 202 | + } | |
| 203 | + $prord = array(); | |
| 204 | + $prvar = ''; | |
| 205 | + foreach ($allpr as $kap => $ap) { | |
| 206 | + $prord[] = $kap; | |
| 207 | + | |
| 208 | + // detect if this rate plan has got LOS rates | |
| 209 | + $los_descr = ''; | |
| 210 | + $rplan_haslos = $room_helper->hasLosRecords($idroom, $kap, true); | |
| 211 | + if ($rplan_haslos) { | |
| 212 | + $los_descr .= "\n<div class=\"vbo-tariffs-los-info\">\n"; | |
| 213 | + $los_descr .= "<span class=\"badge badge-info vbo-tariffs-los-badge\">LOS >= $rplan_haslos " . JText::translate('VBDAYS') . "</span>\n"; | |
| 214 | + $los_descr .= "</div>\n"; | |
| 215 | + } | |
| 216 | + | |
| 217 | + $prvar .= "<th class=\"title center\" width=\"150\"><span class=\"vbo-tariffs-rplan-name\">" . VikBooking::getPriceName($kap) . "</span>" . (!empty($ap) ? '<span class="vbo-tariffs-rplan-attr" title="' . $this->escape($ap) . '">' . $ap . '</span>' : '') . $los_descr . "</th>\n"; | |
| 218 | + } | |
| 219 | + $totrows = count($tottar); | |
| 220 | + $tottar = array_slice($tottar, $lim0, $lim, true); | |
| 221 | + ?> | |
| 222 | + <form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm" class="vbo-list-form"> | |
| 223 | + <div class="vbo-tariffs-updaterates-cont"> | |
| 224 | + <input type="submit" name="modtar" value="<?php echo JText::translate( 'VBPVIEWTARTWO' ); ?>" onclick="vbRateSetTask(event);" class="btn vbo-config-btn" /> | |
| 225 | + </div> | |
| 226 | + <div class="table-responsive"> | |
| 227 | + <table cellpadding="4" cellspacing="0" border="0" width="100%" class="table table-striped vbo-list-table"> | |
| 228 | + <thead> | |
| 229 | + <tr> | |
| 230 | + <th width="20" class="title left"> | |
| 231 | + <input type="checkbox" onclick="Joomla.checkAll(this)" value="" name="checkall-toggle"> | |
| 232 | + </th> | |
| 233 | + <th class="title left" width="100" style="text-align: left;"><?php echo JText::translate( 'VBPVIEWTARONE' ); ?></th> | |
| 234 | + <?php echo $prvar; ?> | |
| 235 | + </tr> | |
| 236 | + </thead> | |
| 237 | + <?php | |
| 238 | + $k = 0; | |
| 239 | + $i = 0; | |
| 240 | + foreach ($tottar as $kt => $vt) { | |
| 241 | + $multiid = ""; | |
| 242 | + foreach ($prord as $ord) { | |
| 243 | + foreach ($vt as $kkkt => $vvv) { | |
| 244 | + if ($vvv['idprice'] == $ord) { | |
| 245 | + $multiid .= $vvv['id'].";"; | |
| 246 | + break; | |
| 247 | + } | |
| 248 | + } | |
| 249 | + } | |
| 250 | + ?> | |
| 251 | + <tr class="row<?php echo $k; ?>"> | |
| 252 | + <td class="left"> | |
| 253 | + <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $multiid; ?>" onclick="Joomla.isChecked(this.checked);"> | |
| 254 | + </td> | |
| 255 | + <td class="left"><?php echo $kt; ?></td> | |
| 256 | + <?php | |
| 257 | + foreach ($prord as $ord) { | |
| 258 | + $thereis = false; | |
| 259 | + foreach ($vt as $kkkt => $vvv) { | |
| 260 | + if ($vvv['idprice'] == $ord) { | |
| 261 | + echo "<td class=\"center\"><input type=\"number\" min=\"0\" step=\"any\" name=\"cost".$vvv['id']."\" value=\"".$vvv['cost']."\" />".(!empty($vvv['attrdata'])? " - <input type=\"text\" name=\"attr".$vvv['id']."\" value=\"".$vvv['attrdata']."\" size=\"10\"/>" : "")."</td>\n"; | |
| 262 | + $thereis = true; | |
| 263 | + break; | |
| 264 | + } | |
| 265 | + } | |
| 266 | + if (!$thereis) { | |
| 267 | + echo "<td></td>\n"; | |
| 268 | + } | |
| 269 | + unset($thereis); | |
| 270 | + } | |
| 271 | + ?> | |
| 272 | + </tr> | |
| 273 | + <?php | |
| 274 | + unset($multiid); | |
| 275 | + $k = 1 - $k; | |
| 276 | + $i++; | |
| 277 | + } | |
| 278 | + ?> | |
| 279 | + </table> | |
| 280 | + </div> | |
| 281 | + <input type="hidden" name="roomid" value="<?php echo $roomrows['id']; ?>" /> | |
| 282 | + <input type="hidden" name="cid[]" value="<?php echo $roomrows['id']; ?>" /> | |
| 283 | + <input type="hidden" name="option" value="com_vikbooking" /> | |
| 284 | + <input type="hidden" name="task" id="vbtask" value="tariffs" /> | |
| 285 | + <input type="hidden" name="tarmod" id="vbtarmod" value="" /> | |
| 286 | + <input type="hidden" name="boxchecked" value="0" /> | |
| 287 | + <?php echo JHtml::fetch('form.token'); ?> | |
| 288 | + <?php | |
| 289 | + jimport('joomla.html.pagination'); | |
| 290 | + $pageNav = new JPagination( $totrows, $lim0, $lim ); | |
| 291 | + $navbut = "<table align=\"center\"><tr><td>".$pageNav->getListFooter()."</td></tr></table>"; | |
| 292 | + echo $navbut; | |
| 293 | + ?> | |
| 294 | + </form> | |
| 295 | + <?php | |
| 296 | + } | |
| 297 | + ?> | |
| 298 | + </div> | |
| 299 | + </div> | |
| 300 | + </fieldset> | |
| 301 | + </div> | |
| 302 | +</div> | |
| 303 | + | |
| 304 | +<?php | |
| 305 | +if (!empty($prices)) { | |
| 306 | + // load wizard template | |
| 307 | + echo $this->loadTemplate('wizard'); | |
| 308 | +} | |
| 309 | +?> | |
| 310 | + | |
| 311 | +<script type="text/javascript"> | |
| 312 | +jQuery(function() { | |
| 313 | + jQuery('#ddaysfrom').change(function() { | |
| 314 | + var fnights = parseInt(jQuery(this).val()); | |
| 315 | + if (!isNaN(fnights)) { | |
| 316 | + jQuery('#ddaysto').attr('min', fnights); | |
| 317 | + var tnights = jQuery('#ddaysto').val(); | |
| 318 | + if (!(tnights.length > 0)) { | |
| 319 | + jQuery('#ddaysto').val(fnights); | |
| 320 | + } else { | |
| 321 | + if (parseInt(tnights) < fnights) { | |
| 322 | + jQuery('#ddaysto').val(fnights); | |
| 323 | + } | |
| 324 | + } | |
| 325 | + } | |
| 326 | + }); | |
| 327 | + jQuery("#roomsel").select2(); | |
| 328 | +}); | |
| 329 | +function vbRateSetTask(event) { | |
| 330 | + event.preventDefault(); | |
| 331 | + document.getElementById('vbtarmod').value = '1'; | |
| 332 | + document.getElementById('vbtask').value = 'rooms'; | |
| 333 | + document.adminForm.submit(); | |
| 334 | +} | |
| 335 | +</script> | |