| 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 |
$reservs = $this->reservs; |
| 14 |
$totres = $this->totres; |
| 15 |
$pts = $this->pts; |
| 16 |
$lim0 = $this->lim0; |
| 17 |
$navbut = $this->navbut; |
| 18 |
|
| 19 |
$dbo = JFactory::getDBO(); |
| 20 |
if (is_file(VBO_SITE_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$reservs[0]['img']) && getimagesize(VBO_SITE_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$reservs[0]['img'])) { |
| 21 |
$img = '<img align="middle" class="maxninety" style="border-radius: 5px;" alt="Room Image" src="' . VBO_SITE_URI . 'resources/uploads/'.$reservs[0]['img'].'" />'; |
| 22 |
} else { |
| 23 |
$img = '<img align="middle" alt="vikbooking logo" src="' . VBO_ADMIN_URI . 'vikbooking.png' . '" />'; |
| 24 |
} |
| 25 |
$unitsdisp = $reservs[0]['units'] - $totres; |
| 26 |
$unitsdisp = ($unitsdisp < 0 ? "0" : $unitsdisp); |
| 27 |
$pvcm = VikRequest::getInt('vcm', '', 'request'); |
| 28 |
$pgoto = VikRequest::getString('goto', '', 'request'); |
| 29 |
?> |
| 30 |
<table class="vbo-choosebusy-table"> |
| 31 |
<tr class="vbo-choosebusy-tr1"> |
| 32 |
<td><div class="vbadminfaresctitle-chbusy"><?php echo JText::translate('VBMAINCHOOSEBUSY'); ?> <?php echo $reservs[0]['name']; ?></div></td> |
| 33 |
</tr> |
| 34 |
<tr class="vbo-choosebusy-tr2"> |
| 35 |
<td><?php echo $img; ?></td> |
| 36 |
</tr> |
| 37 |
<tr class="vbo-choosebusy-tr3"> |
| 38 |
<td> |
| 39 |
<div class="vbadminfaresctitle-chbusy"> |
| 40 |
<span class="label label-success"><?php echo JText::translate('VBPCHOOSEBUSYCAVAIL'); ?>:</span> |
| 41 |
<span class="badge badge-warning"><?php echo $unitsdisp; ?> / <?php echo $reservs[0]['units']; ?></span> |
| 42 |
</div> |
| 43 |
</td> |
| 44 |
</tr> |
| 45 |
</table> |
| 46 |
|
| 47 |
<form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm" class="vbo-list-form"> |
| 48 |
<div class="table-responsive"> |
| 49 |
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="table table-striped vbo-list-table"> |
| 50 |
<thead> |
| 51 |
<tr> |
| 52 |
<th class="title left" width="50">ID</th> |
| 53 |
<th class="title left" width="150"><?php echo JText::translate( 'VBPVIEWORDERSFOUR' ); ?></th> |
| 54 |
<th class="title left" width="150"><?php echo JText::translate( 'VBPVIEWORDERSFIVE' ); ?></th> |
| 55 |
<th class="title left" width="250"><?php echo JText::translate( 'VBPVIEWORDERSTWO' ); ?></th> |
| 56 |
<th class="title center" width="150"><?php echo JText::translate( 'VBOFEATUNITASSIGNED' ); ?></th> |
| 57 |
<th class="title left" width="150"><?php echo JText::translate( 'VBPCHOOSEBUSYORDATE' ); ?></th> |
| 58 |
</tr> |
| 59 |
</thead> |
| 60 |
<?php |
| 61 |
$nowdf = VikBooking::getDateFormat(true); |
| 62 |
if ($nowdf == "%d/%m/%Y") { |
| 63 |
$df = 'd/m/Y'; |
| 64 |
} elseif ($nowdf == "%m/%d/%Y") { |
| 65 |
$df = 'm/d/Y'; |
| 66 |
} else { |
| 67 |
$df = 'Y/m/d'; |
| 68 |
} |
| 69 |
$datesep = VikBooking::getDateSeparator(true); |
| 70 |
$k = 0; |
| 71 |
$i = 0; |
| 72 |
$room_params = json_decode($reservs[0]['params'], true); |
| 73 |
$or_map = array(); |
| 74 |
for ($i = 0, $n = count($reservs); $i < $n; $i++) { |
| 75 |
$row = $reservs[$i]; |
| 76 |
//Room specific unit |
| 77 |
$room_first_feature = '----'; |
| 78 |
$q = "SELECT `id`,`roomindex` FROM `#__vikbooking_ordersrooms` WHERE `idorder`=".(int)$row['idorder']." AND `idroom`=".(int)$row['idroom'].";"; |
| 79 |
$dbo->setQuery($q); |
| 80 |
$dbo->execute(); |
| 81 |
if ($dbo->getNumRows() > 0) { |
| 82 |
$roomindexes = $dbo->loadAssocList(); |
| 83 |
$usekey = 0; |
| 84 |
if (array_key_exists($row['idorder'], $or_map)) { |
| 85 |
$usekey = count($or_map[$row['idorder']]); |
| 86 |
$or_map[$row['idorder']][] = $row['id']; |
| 87 |
} else { |
| 88 |
$or_map[$row['idorder']] = array($row['id']); |
| 89 |
} |
| 90 |
if (array_key_exists($usekey, $roomindexes) && is_array($room_params) && array_key_exists('features', $room_params) && count($room_params['features']) > 0) { |
| 91 |
foreach ($room_params['features'] as $rind => $rfeatures) { |
| 92 |
if ($rind != $roomindexes[$usekey]['roomindex']) { |
| 93 |
continue; |
| 94 |
} |
| 95 |
foreach ($rfeatures as $fname => $fval) { |
| 96 |
if (strlen($fval)) { |
| 97 |
$room_first_feature = '#'.$rind.' - '.JText::translate($fname).': '.$fval; |
| 98 |
break 2; |
| 99 |
} |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
// |
| 105 |
//Customer Details |
| 106 |
$custdata = $row['custdata']; |
| 107 |
$custdata_parts = explode("\n", $row['custdata']); |
| 108 |
if (count($custdata_parts) > 2 && strpos($custdata_parts[0], ':') !== false && strpos($custdata_parts[1], ':') !== false) { |
| 109 |
//get the first two fields |
| 110 |
$custvalues = array(); |
| 111 |
foreach ($custdata_parts as $custdet) { |
| 112 |
if (strlen($custdet) < 1) { |
| 113 |
continue; |
| 114 |
} |
| 115 |
$custdet_parts = explode(':', $custdet); |
| 116 |
if (count($custdet_parts) >= 2) { |
| 117 |
unset($custdet_parts[0]); |
| 118 |
array_push($custvalues, trim(implode(':', $custdet_parts))); |
| 119 |
} |
| 120 |
if (count($custvalues) > 1) { |
| 121 |
break; |
| 122 |
} |
| 123 |
} |
| 124 |
if (count($custvalues) > 1) { |
| 125 |
$custdata = implode(' ', $custvalues); |
| 126 |
} |
| 127 |
} |
| 128 |
if (strlen($custdata) > 45) { |
| 129 |
$custdata = substr($custdata, 0, 45)." ..."; |
| 130 |
} |
| 131 |
$q = "SELECT `c`.*,`co`.`idorder` FROM `#__vikbooking_customers` AS `c` LEFT JOIN `#__vikbooking_customers_orders` `co` ON `c`.`id`=`co`.`idcustomer` WHERE `co`.`idorder`=".$row['idorder'].";"; |
| 132 |
$dbo->setQuery($q); |
| 133 |
$dbo->execute(); |
| 134 |
if ($dbo->getNumRows() > 0) { |
| 135 |
$cust_country = $dbo->loadAssocList(); |
| 136 |
$cust_country = $cust_country[0]; |
| 137 |
if (!empty($cust_country['first_name'])) { |
| 138 |
$custdata = $cust_country['first_name'].' '.$cust_country['last_name']; |
| 139 |
if (!empty($cust_country['country'])) { |
| 140 |
if (file_exists(VBO_ADMIN_PATH.DS.'resources'.DS.'countries'.DS.$cust_country['country'].'.png')) { |
| 141 |
$custdata .= '<img src="'.VBO_ADMIN_URI.'resources/countries/'.$cust_country['country'].'.png'.'" title="'.$cust_country['country'].'" class="vbo-country-flag vbo-country-flag-left"/>'; |
| 142 |
} |
| 143 |
} |
| 144 |
} |
| 145 |
} |
| 146 |
$custdata = $row['closure'] > 0 || JText::translate('VBDBTEXTROOMCLOSED') == $row['custdata'] ? '<span class="vbordersroomclosed">'.JText::translate('VBDBTEXTROOMCLOSED').'</span>' : $custdata; |
| 147 |
?> |
| 148 |
<tr class="row<?php echo $k; ?>"> |
| 149 |
<td> |
| 150 |
<a class="vbo-bookingid" href="index.php?option=com_vikbooking&task=editbusy<?php echo ($pvcm == 1 ? '&vcm=1' : '').(!empty($pgoto) ? '&goto='.$pgoto : ''); ?>&cid[]=<?php echo $row['idorder']; ?>"><?php echo $row['idorder']; ?></a> |
| 151 |
</td> |
| 152 |
<td> |
| 153 |
<a href="index.php?option=com_vikbooking&task=editbusy<?php echo ($pvcm == 1 ? '&vcm=1' : '').(!empty($pgoto) ? '&goto='.$pgoto : ''); ?>&cid[]=<?php echo $row['idorder']; ?>"><?php echo date(str_replace("/", $datesep, $df).' H:i', $row['checkin']); ?></a> |
| 154 |
</td> |
| 155 |
<td><?php echo date(str_replace("/", $datesep, $df).' H:i', $row['checkout']); ?></td> |
| 156 |
<td><?php echo $custdata; ?></td> |
| 157 |
<td style="text-align: center;"><?php echo $room_first_feature; ?></td> |
| 158 |
<td><?php echo date(str_replace("/", $datesep, $df).' H:i', $row['ts']); ?></td> |
| 159 |
</tr> |
| 160 |
<?php |
| 161 |
$k = 1 - $k; |
| 162 |
} |
| 163 |
?> |
| 164 |
</table> |
| 165 |
</div> |
| 166 |
<input type="hidden" name="idroom" value="<?php echo $reservs[0]['idroom']; ?>" /> |
| 167 |
<input type="hidden" name="ts" value="<?php echo $pts; ?>" /> |
| 168 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 169 |
<input type="hidden" name="task" value="choosebusy" /> |
| 170 |
<input type="hidden" name="boxchecked" value="0" /> |
| 171 |
<?php echo JHtml::fetch('form.token'); ?> |
| 172 |
<?php echo $navbut; ?> |
| 173 |
</form> |