| 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 |
$rows = $this->rows; |
| 14 |
$lim0 = $this->lim0; |
| 15 |
$navbut = $this->navbut; |
| 16 |
$orderby = $this->orderby; |
| 17 |
$ordersort = $this->ordersort; |
| 18 |
|
| 19 |
$vbo_app = VikBooking::getVboApplication(); |
| 20 |
$vbo_app->loadSelect2(); |
| 21 |
$vbo_app->loadDatePicker(); |
| 22 |
|
| 23 |
$nowdf = VikBooking::getDateFormat(true); |
| 24 |
if ($nowdf == "%d/%m/%Y") { |
| 25 |
$df = 'd/m/Y'; |
| 26 |
} elseif ($nowdf == "%m/%d/%Y") { |
| 27 |
$df = 'm/d/Y'; |
| 28 |
} else { |
| 29 |
$df = 'Y/m/d'; |
| 30 |
} |
| 31 |
$datesep = VikBooking::getDateSeparator(true); |
| 32 |
$juidf = $nowdf == "%d/%m/%Y" ? 'dd/mm/yy' : ($nowdf == "%m/%d/%Y" ? 'mm/dd/yy' : 'yy/mm/dd'); |
| 33 |
|
| 34 |
$dates_filter = ''; |
| 35 |
$pdatefilt = $this->datefilt; |
| 36 |
$pdatefiltfrom = $this->datefiltfrom; |
| 37 |
$pdatefiltto = $this->datefiltto; |
| 38 |
if ((!empty($pdatefiltfrom) || !empty($pdatefiltto))) { |
| 39 |
$dates_filter = '&datefilt='.$pdatefilt.(!empty($pdatefiltfrom) ? '&datefiltfrom='.$pdatefiltfrom : '').(!empty($pdatefiltto) ? '&datefiltto='.$pdatefiltto : ''); |
| 40 |
} |
| 41 |
$pactive_tab = VikRequest::getString('vbo_active_tab', 'vbo-trackings-tabcont-list', 'request'); |
| 42 |
|
| 43 |
?> |
| 44 |
<script type="text/javascript"> |
| 45 |
jQuery(document).ready(function() { |
| 46 |
jQuery('.vbo-trackings-togglesubrow-cont').click(function() { |
| 47 |
var toggler = jQuery(this).find('i.vbo-trackings-togglesubrow'); |
| 48 |
var elem = toggler.closest('.vbo-trackings-table-body-row').find('.vbo-trackings-table-body-subrow'); |
| 49 |
elem.slideToggle(400, function() { |
| 50 |
if (elem.is(':visible')) { |
| 51 |
toggler.removeClass('fa-chevron-down').addClass('fa-chevron-up'); |
| 52 |
} else { |
| 53 |
toggler.removeClass('fa-chevron-up').addClass('fa-chevron-down'); |
| 54 |
} |
| 55 |
}); |
| 56 |
}); |
| 57 |
jQuery('.vbo-trackings-table-body-row').dblclick(function() { |
| 58 |
if (jQuery(this).find('.vbo-trackings-table-body-subrow').is(':visible')) { |
| 59 |
e.preventDefault(); |
| 60 |
return; |
| 61 |
} |
| 62 |
jQuery(this).find('.vbo-trackings-togglesubrow-cont').trigger('click'); |
| 63 |
}); |
| 64 |
jQuery('#vbo-date-from').datepicker({ |
| 65 |
showOn: 'focus', |
| 66 |
dateFormat: '<?php echo $juidf; ?>', |
| 67 |
<?php echo ($this->mindate > 0 ? 'minDate: "'.date(str_replace('%', '', $nowdf), $this->mindate).'", ' : '').($this->maxdate > 0 ? 'maxDate: "'.date(str_replace('%', '', $nowdf), $this->maxdate).'", ' : ''); ?> |
| 68 |
onSelect: function( selectedDate ) { |
| 69 |
jQuery('#vbo-date-to').datepicker('option', 'minDate', selectedDate); |
| 70 |
} |
| 71 |
}); |
| 72 |
jQuery('#vbo-date-to').datepicker({ |
| 73 |
showOn: 'focus', |
| 74 |
dateFormat: '<?php echo $juidf; ?>', |
| 75 |
<?php echo ($this->mindate > 0 ? 'minDate: "'.date(str_replace('%', '', $nowdf), $this->mindate).'", ' : '').($this->maxdate > 0 ? 'maxDate: "'.date(str_replace('%', '', $nowdf), $this->maxdate).'", ' : ''); ?> |
| 76 |
onSelect: function( selectedDate ) { |
| 77 |
jQuery('#vbo-date-from').datepicker('option', 'maxDate', selectedDate); |
| 78 |
} |
| 79 |
}); |
| 80 |
jQuery('#vbo-date-from-trig, #vbo-date-to-trig').click(function() { |
| 81 |
var jdp = jQuery(this).prev('input.hasDatepicker'); |
| 82 |
if (jdp.length) { |
| 83 |
jdp.focus(); |
| 84 |
} |
| 85 |
}); |
| 86 |
jQuery('.vbo-trackings-tab').click(function() { |
| 87 |
var newtabrel = jQuery(this).attr('data-vbotab'); |
| 88 |
var oldtabrel = jQuery(".vbo-trackings-tab-active").attr('data-vbotab'); |
| 89 |
if (newtabrel == oldtabrel) { |
| 90 |
return; |
| 91 |
} |
| 92 |
jQuery(".vbo-trackings-tab").removeClass("vbo-trackings-tab-active"); |
| 93 |
jQuery(this).addClass("vbo-trackings-tab-active"); |
| 94 |
jQuery("." + oldtabrel).hide(); |
| 95 |
jQuery("." + newtabrel).fadeIn(); |
| 96 |
jQuery("#vbo_active_tab").val(newtabrel); |
| 97 |
}); |
| 98 |
jQuery(".vbo-trackings-tab[data-vbotab='<?php echo $pactive_tab; ?>']").trigger('click'); |
| 99 |
}); |
| 100 |
</script> |
| 101 |
|
| 102 |
<form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm"> |
| 103 |
|
| 104 |
<div id="filter-bar" class="btn-toolbar vbo-btn-toolbar vbo-trackings-filters" style="width: 100%; display: inline-block;"> |
| 105 |
<div class="btn-group pull-right"> |
| 106 |
<a class="btn" href="index.php?option=com_vikbooking&task=trkconfig"><?php VikBookingIcons::e('cogs'); ?> <?php echo JText::translate('VBTRKSETTINGS'); ?></a> |
| 107 |
</div> |
| 108 |
<div class="btn-group pull-left input-append"> |
| 109 |
<input type="text" id="vbo-date-from" placeholder="<?php echo JText::translate('VBNEWSEASONONE'); ?>" value="<?php echo $pdatefiltfrom; ?>" size="14" name="datefiltfrom" onfocus="this.blur();" /> |
| 110 |
<button type="button" class="btn" id="vbo-date-from-trig"><i class="icon-calendar"></i></button> |
| 111 |
</div> |
| 112 |
<div class="btn-group pull-left input-append"> |
| 113 |
<input type="text" id="vbo-date-to" placeholder="<?php echo JText::translate('VBNEWSEASONTWO'); ?>" value="<?php echo $pdatefiltto; ?>" size="14" name="datefiltto" onfocus="this.blur();" /> |
| 114 |
<button type="button" class="btn" id="vbo-date-to-trig"><i class="icon-calendar"></i></button> |
| 115 |
</div> |
| 116 |
<div class="btn-group pull-left"> |
| 117 |
<?php |
| 118 |
$datesel = '<select name="datefilt">'; |
| 119 |
$datesel .= '<option value="1"'.(!empty($pdatefilt) && $pdatefilt == 1 ? ' selected="selected"' : '').'>'.JText::translate('VBTRKFILTTRKDATES').'</option>'; |
| 120 |
$datesel .= '<option value="2"'.(!empty($pdatefilt) && $pdatefilt == 2 ? ' selected="selected"' : '').'>'.JText::translate('VBTRKBOOKINGDATES').'</option>'; |
| 121 |
$datesel .= '<option value="3"'.(!empty($pdatefilt) && $pdatefilt == 3 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEIN').'</option>'; |
| 122 |
$datesel .= '<option value="4"'.(!empty($pdatefilt) && $pdatefilt == 4 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEOUT').'</option>'; |
| 123 |
$datesel .= '</select>'; |
| 124 |
echo $datesel; |
| 125 |
?> |
| 126 |
</div> |
| 127 |
<div class="btn-group pull-left"> |
| 128 |
<span style="font-size: 15px;"> </span> |
| 129 |
</div> |
| 130 |
<div class="btn-group pull-left"> |
| 131 |
<select name="countryfilt" id="countryfilt"> |
| 132 |
<option value=""><?php echo JText::translate('VBCOUNTRYFILTER'); ?></option> |
| 133 |
<?php |
| 134 |
$pcountryfilt = VikRequest::getString('countryfilt', '', 'request'); |
| 135 |
foreach ($this->countries as $c) { |
| 136 |
?> |
| 137 |
<option value="<?php echo $c['country']; ?>"<?php echo $c['country'] == $pcountryfilt ? ' selected="selected"' : ''; ?>><?php echo $c['country_name']; ?></option> |
| 138 |
<?php |
| 139 |
} |
| 140 |
?> |
| 141 |
</select> |
| 142 |
</div> |
| 143 |
<div class="btn-group pull-left"> |
| 144 |
<span style="font-size: 15px;"> </span> |
| 145 |
</div> |
| 146 |
<div class="btn-group pull-left"> |
| 147 |
<select name="referrer" style="max-width: 170px;"> |
| 148 |
<option value=""><?php echo JText::translate('VBREFERRERFILTER'); ?></option> |
| 149 |
<?php |
| 150 |
$preferrer = VikRequest::getString('referrer', '', 'request'); |
| 151 |
foreach ($this->referrers as $r) { |
| 152 |
$say_referrer = !strcasecmp($r['referrer'], 'googlehotel') ? 'Google Hotel' : $r['referrer']; |
| 153 |
$say_referrer = strpos($say_referrer, 'http') === false ? ucwords($say_referrer) : $say_referrer; |
| 154 |
?> |
| 155 |
<option value="<?php echo $r['referrer']; ?>"<?php echo $r['referrer'] == $preferrer ? ' selected="selected"' : ''; ?>><?php echo $say_referrer; ?></option> |
| 156 |
<?php |
| 157 |
} |
| 158 |
?> |
| 159 |
</select> |
| 160 |
</div> |
| 161 |
<div class="btn-group pull-left"> |
| 162 |
<span style="font-size: 15px;"> </span> |
| 163 |
</div> |
| 164 |
<div class="btn-group pull-left"> |
| 165 |
<button type="submit" class="btn"><i class="icon-search"></i> <?php echo JText::translate('VBTRKFILTRES'); ?></button> |
| 166 |
</div> |
| 167 |
<div class="btn-group pull-left"> |
| 168 |
<button type="button" class="btn" onclick="jQuery('#filter-bar').find('input, select').val('');document.adminForm.submit();"><?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?></button> |
| 169 |
</div> |
| 170 |
</div> |
| 171 |
|
| 172 |
<?php |
| 173 |
if (!(int)VikBookingTracker::loadSettings('trkenabled')) { |
| 174 |
?> |
| 175 |
<p class="err"><?php echo JText::translate('VBTRKDISABLED'); ?></p> |
| 176 |
<?php |
| 177 |
} |
| 178 |
if (empty($rows)) { |
| 179 |
?> |
| 180 |
<p class="warn"><?php echo JText::translate('VBNOTRACKINGS'); ?></p> |
| 181 |
<?php |
| 182 |
} else { |
| 183 |
// gather all the IPs with missing geo information |
| 184 |
$missing_ips = array(); |
| 185 |
foreach ($rows as $row) { |
| 186 |
if (empty($row['geo']) && !empty($row['ip'])) { |
| 187 |
$missing_ips[$row['id']] = $row['ip']; |
| 188 |
} |
| 189 |
} |
| 190 |
if (count($missing_ips)) { |
| 191 |
?> |
| 192 |
<script type="text/javascript"> |
| 193 |
jQuery(document).ready(function() { |
| 194 |
var jqxhr = jQuery.ajax({ |
| 195 |
type: "POST", |
| 196 |
url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=getgeoinfo'); ?>", |
| 197 |
data: { |
| 198 |
tmpl: "component", |
| 199 |
ips: <?php echo json_encode($missing_ips); ?> |
| 200 |
} |
| 201 |
}).done(function(res) { |
| 202 |
if (res.indexOf('e4j.error') >= 0 ) { |
| 203 |
console.log(res); |
| 204 |
} else { |
| 205 |
var obj_res = JSON.parse(res); |
| 206 |
for (var i in obj_res) { |
| 207 |
if (!obj_res.hasOwnProperty(i)) { |
| 208 |
continue; |
| 209 |
} |
| 210 |
if (obj_res[i].hasOwnProperty('geo') && jQuery('#geo-'+i).length) { |
| 211 |
jQuery('#geo-'+i).text(obj_res[i]['geo']); |
| 212 |
} |
| 213 |
if (obj_res[i].hasOwnProperty('country') && jQuery('#country-'+i).length) { |
| 214 |
jQuery('#country-'+i).text(obj_res[i]['country']); |
| 215 |
} |
| 216 |
if (obj_res[i].hasOwnProperty('country') && obj_res[i].hasOwnProperty('country3') && !vboCountryHasVal(obj_res[i]['country3'])) { |
| 217 |
jQuery('#countryfilt').append('<option value="'+obj_res[i]['country3']+'">'+obj_res[i]['country']+'</option>'); |
| 218 |
} |
| 219 |
} |
| 220 |
} |
| 221 |
}).fail(function() { |
| 222 |
console.log("getgeoinfo Request Failed"); |
| 223 |
}); |
| 224 |
}); |
| 225 |
function vboCountryHasVal(c3) { |
| 226 |
var hasval = false; |
| 227 |
jQuery('#countryfilt option').each(function(k, v) { |
| 228 |
if (jQuery(v).attr('value') == c3) { |
| 229 |
hasval = true; |
| 230 |
return false; |
| 231 |
} |
| 232 |
}); |
| 233 |
|
| 234 |
return hasval; |
| 235 |
} |
| 236 |
</script> |
| 237 |
<?php |
| 238 |
} |
| 239 |
?> |
| 240 |
|
| 241 |
<div class="vbo-trackings-outer-response"> |
| 242 |
<div class="vbo-trackings-tabs"> |
| 243 |
<div class="vbo-trackings-tab vbo-trackings-tab-active" data-vbotab="vbo-trackings-tabcont-list"><?php echo JText::translate('VBTRKVISITORS'); ?></div> |
| 244 |
<div class="vbo-trackings-tab" data-vbotab="vbo-trackings-tabcont-stats"><?php echo JText::translate('VBTRKCONVRATES'); ?></div> |
| 245 |
</div> |
| 246 |
<div class="vbo-trackings-tabcont-list" style="display: block;"> |
| 247 |
<div class="vbo-trackings-table"> |
| 248 |
<div class="vbo-trackings-table-head"> |
| 249 |
<div class="vbo-trackings-table-head-inner"> |
| 250 |
<div class="vbo-trackings-table-head-cell vbo-trackings-table-cell-chevron"></div> |
| 251 |
<div class="vbo-trackings-table-head-cell vbo-trackings-table-cell-ckb"> |
| 252 |
<input type="checkbox" onclick="Joomla.checkAll(this)" value="" name="checkall-toggle"> |
| 253 |
</div> |
| 254 |
<div class="vbo-trackings-table-head-cell vbo-trackings-table-cell-id"> |
| 255 |
<a href="index.php?option=com_vikbooking&task=trackings<?php echo $dates_filter; ?>&vborderby=id&vbordersort=<?php echo ($orderby == "id" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "id" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "id" ? "vbo-list-activesort" : "")); ?>"> |
| 256 |
ID<?php echo ($orderby == "id" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "id" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 257 |
</a> |
| 258 |
</div> |
| 259 |
<div class="vbo-trackings-table-head-cell vbo-trackings-table-cell-lastdt"> |
| 260 |
<a href="index.php?option=com_vikbooking&task=trackings<?php echo $dates_filter; ?>&vborderby=lastdt&vbordersort=<?php echo ($orderby == "lastdt" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "lastdt" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "lastdt" ? "vbo-list-activesort" : "")); ?>"> |
| 261 |
<?php echo JText::translate('VBTRKLASTDT').($orderby == "lastdt" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "lastdt" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 262 |
</a> |
| 263 |
</div> |
| 264 |
<div class="vbo-trackings-table-head-cell vbo-trackings-table-cell-customer"> |
| 265 |
<span><?php echo JText::translate( 'VBOCUSTOMER' ); ?></span> |
| 266 |
</div> |
| 267 |
<div class="vbo-trackings-table-head-cell vbo-trackings-table-cell-country"> |
| 268 |
<a href="index.php?option=com_vikbooking&task=trackings<?php echo $dates_filter; ?>&vborderby=country&vbordersort=<?php echo ($orderby == "country" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "country" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "country" ? "vbo-list-activesort" : "")); ?>"> |
| 269 |
<?php echo JText::translate('ORDER_STATE').($orderby == "country" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "country" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 270 |
</a> |
| 271 |
</div> |
| 272 |
<div class="vbo-trackings-table-head-cell vbo-trackings-table-cell-geo"> |
| 273 |
<a href="index.php?option=com_vikbooking&task=trackings<?php echo $dates_filter; ?>&vborderby=geo&vbordersort=<?php echo ($orderby == "geo" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "geo" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "geo" ? "vbo-list-activesort" : "")); ?>"> |
| 274 |
<?php echo JText::translate('VBTRKGEOINFO').($orderby == "geo" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "geo" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 275 |
</a> |
| 276 |
</div> |
| 277 |
<div class="vbo-trackings-table-head-cell vbo-trackings-table-cell-dt"> |
| 278 |
<a href="index.php?option=com_vikbooking&task=trackings<?php echo $dates_filter; ?>&vborderby=dt&vbordersort=<?php echo ($orderby == "dt" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "dt" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "dt" ? "vbo-list-activesort" : "")); ?>"> |
| 279 |
<?php echo JText::translate('VBTRKFIRSTDT').($orderby == "dt" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "dt" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 280 |
</a> |
| 281 |
</div> |
| 282 |
<div class="vbo-trackings-table-head-cell center vbo-trackings-table-cell-published"> |
| 283 |
<a href="index.php?option=com_vikbooking&task=trackings<?php echo $dates_filter; ?>&vborderby=published&vbordersort=<?php echo ($orderby == "published" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "published" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "published" ? "vbo-list-activesort" : "")); ?>"> |
| 284 |
<?php echo JText::translate('VBTRKPUBLISHED').($orderby == "published" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "published" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 285 |
</a> |
| 286 |
</div> |
| 287 |
</div> |
| 288 |
</div> |
| 289 |
|
| 290 |
<div class="vbo-trackings-table-body"> |
| 291 |
<?php |
| 292 |
$kk = 0; |
| 293 |
$i = 0; |
| 294 |
for ($i = 0, $n = count($rows); $i < $n; $i++) { |
| 295 |
$row = $rows[$i]; |
| 296 |
$customer_info = JText::translate('VBOANONYMOUS'); |
| 297 |
if (!empty($row['first_name']) || !empty($row['last_name'])) { |
| 298 |
$customer_info = $row['first_name'].' '.$row['last_name']; |
| 299 |
$check_country = $row['country']; |
| 300 |
if (empty($check_country) && !empty($row['c_country'])) { |
| 301 |
$check_country = $row['c_country']; |
| 302 |
} |
| 303 |
if (!empty($check_country)) { |
| 304 |
if (file_exists(VBO_ADMIN_PATH.DS.'resources'.DS.'countries'.DS.$check_country.'.png')) { |
| 305 |
$customer_info .= '<img src="'.VBO_ADMIN_URI.'resources/countries/'.$check_country.'.png'.'" title="'.$check_country.'" class="vbo-country-flag vbo-country-flag-left"/>'; |
| 306 |
} |
| 307 |
} |
| 308 |
} |
| 309 |
$dt_info = getdate(strtotime($row['dt'])); |
| 310 |
$lastdt_info = getdate(strtotime($row['lastdt'])); |
| 311 |
?> |
| 312 |
<div class="vbo-trackings-table-body-row"> |
| 313 |
<div class="vbo-trackings-table-head-cell vbo-trackings-table-cell-chevron vbo-trackings-togglesubrow-cont"> |
| 314 |
<?php VikBookingIcons::e('chevron-down', 'vbo-trackings-togglesubrow'); ?> |
| 315 |
</div> |
| 316 |
<div class="vbo-trackings-table-body-cell vbo-trackings-table-cell-ckb"> |
| 317 |
<input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onclick="Joomla.isChecked(this.checked);"> |
| 318 |
</div> |
| 319 |
<div class="vbo-trackings-table-body-cell vbo-trackings-table-cell-id"> |
| 320 |
<div class="vbo-trackings-table-body-hidden-lbl">ID</div> |
| 321 |
<?php echo $row['id']; ?> |
| 322 |
</div> |
| 323 |
<div class="vbo-trackings-table-body-cell vbo-trackings-table-cell-lastdt"> |
| 324 |
<div class="vbo-trackings-table-body-hidden-lbl"><?php echo JText::translate('VBTRKLASTDT'); ?></div> |
| 325 |
<div class="vbo-trackings-dtonly"> |
| 326 |
<?php echo date(str_replace("/", $datesep, $df), strtotime($row['lastdt'])); ?> |
| 327 |
</div> |
| 328 |
<div class="vbo-trackings-timeonly"> |
| 329 |
<span class="vbo-trackings-wday"><?php echo JText::translate('VB'.strtoupper(substr($lastdt_info['weekday'], 0, 3))); ?></span> |
| 330 |
<span class="vbo-trackings-time"><?php echo date('H:i', strtotime($row['lastdt'])); ?></span> |
| 331 |
</div> |
| 332 |
</div> |
| 333 |
<div class="vbo-trackings-table-body-cell vbo-trackings-table-cell-customer"> |
| 334 |
<div class="vbo-trackings-table-body-hidden-lbl"><?php echo JText::translate('VBOCUSTOMER'); ?></div> |
| 335 |
<?php echo $customer_info; ?> |
| 336 |
</div> |
| 337 |
<div class="vbo-trackings-table-body-cell vbo-trackings-table-cell-country" id="country-<?php echo $row['id']; ?>"> |
| 338 |
<div class="vbo-trackings-table-body-hidden-lbl"><?php echo JText::translate('ORDER_STATE'); ?></div> |
| 339 |
<?php echo !empty($row['country_name']) ? $row['country_name'] : '-----'; ?> |
| 340 |
</div> |
| 341 |
<div class="vbo-trackings-table-body-cell vbo-trackings-table-cell-geo" id="geo-<?php echo $row['id']; ?>"> |
| 342 |
<div class="vbo-trackings-table-body-hidden-lbl"><?php echo JText::translate('VBTRKGEOINFO'); ?></div> |
| 343 |
<?php echo !empty($row['geo']) ? $row['geo'] : '-----'; ?> |
| 344 |
</div> |
| 345 |
<div class="vbo-trackings-table-body-cell vbo-trackings-table-cell-dt"> |
| 346 |
<div class="vbo-trackings-table-body-hidden-lbl"><?php echo JText::translate('VBTRKFIRSTDT'); ?></div> |
| 347 |
<div class="vbo-trackings-dtonly"> |
| 348 |
<?php echo date(str_replace("/", $datesep, $df), strtotime($row['dt'])); ?> |
| 349 |
</div> |
| 350 |
<div class="vbo-trackings-timeonly"> |
| 351 |
<span class="vbo-trackings-wday"><?php echo JText::translate('VB'.strtoupper(substr($dt_info['weekday'], 0, 3))); ?></span> |
| 352 |
<span class="vbo-trackings-time"><?php echo date('H:i', strtotime($row['dt'])); ?></span> |
| 353 |
</div> |
| 354 |
</div> |
| 355 |
<div class="vbo-trackings-table-body-cell center vbo-trackings-table-cell-published"> |
| 356 |
<div class="vbo-trackings-table-body-hidden-lbl"><?php echo JText::translate('VBTRKPUBLISHED'); ?></div> |
| 357 |
<a href="index.php?option=com_vikbooking&task=modtracking&cid[]=<?php echo $row['id']; ?>"><?php echo ($row['published'] ? "<i class=\"".VikBookingIcons::i('check', 'vbo-icn-img')."\" style=\"color: #099909;\" title=\"".JText::translate('VBTRKMAKENOTAVAIL')."\"></i>" : "<i class=\"".VikBookingIcons::i('times-circle', 'vbo-icn-img')."\" style=\"color: #ff0000;\" title=\"".JText::translate('VBTRKMAKEAVAIL')."\"></i>"); ?></a> |
| 358 |
</div> |
| 359 |
|
| 360 |
<div class="vbo-trackings-table-body-subrow"> |
| 361 |
<div class="vbo-tracking-info-container"> |
| 362 |
<?php |
| 363 |
$tot_infos = count($row['infos']); |
| 364 |
foreach ($row['infos'] as $k => $info) { |
| 365 |
$trkdata = json_decode($info['trkdata']); |
| 366 |
$trkdata = !is_object($trkdata) ? (new stdClass) : $trkdata; |
| 367 |
$is_subidentifier = false; |
| 368 |
$is_opening = false; |
| 369 |
if (!isset($row['infos'][($k - 1)]) || $info['identifier'] != $row['infos'][($k - 1)]['identifier']) { |
| 370 |
// open identifier because previous is different or not set (this is the first record) |
| 371 |
$is_opening = true; |
| 372 |
echo '<div class="vbo-tracking-identifier-container">'."\n"; |
| 373 |
} elseif (isset($row['infos'][($k - 1)]) && $info['identifier'] == $row['infos'][($k - 1)]['identifier']) { |
| 374 |
$is_subidentifier = true; |
| 375 |
} |
| 376 |
?> |
| 377 |
<div class="vbo-tracking-info-details<?php echo $is_subidentifier ? ' vbo-tracking-info-details-continue' : ''; ?><?php echo !empty($info['idorder']) ? ' vbo-tracking-info-hasconversion' : ''; ?>"> |
| 378 |
<?php |
| 379 |
$device = ''; |
| 380 |
if ($is_opening) { |
| 381 |
if ($info['device'] == 'C') { |
| 382 |
// computer |
| 383 |
$device = '<i class="'.VikBookingIcons::i('desktop', 'vbo-tracking-i-desktop').'"></i>'; |
| 384 |
} elseif ($info['device'] == 'S') { |
| 385 |
// smartphone |
| 386 |
$device = '<i class="'.VikBookingIcons::i('mobile', 'vbo-tracking-i-mobile').'"></i>'; |
| 387 |
} elseif ($info['device'] == 'T') { |
| 388 |
// tablet |
| 389 |
$device = '<i class="'.VikBookingIcons::i('tablet', 'vbo-tracking-i-tablet').'"></i>'; |
| 390 |
} |
| 391 |
} |
| 392 |
if (!empty($device)) { |
| 393 |
?> |
| 394 |
<div class="vbo-tracking-info-device-cont"> |
| 395 |
<div class="vbo-tracking-info-subrow-lbl"><?php echo JText::translate('VBTRKDEVICE'); ?></div> |
| 396 |
<span class="vbo-tracking-info-device"><?php echo $device; ?></span> |
| 397 |
</div> |
| 398 |
<?php |
| 399 |
} else { |
| 400 |
?> |
| 401 |
<div class="vbo-tracking-info-device-cont"></div> |
| 402 |
<?php |
| 403 |
} |
| 404 |
?> |
| 405 |
<div class="vbo-tracking-info-dt-cont"> |
| 406 |
<div class="vbo-tracking-info-subrow-lbl"><?php echo JText::translate('VBTRKTRACKTIME'); ?></div> |
| 407 |
<?php |
| 408 |
if (!$is_subidentifier) { |
| 409 |
$subdt_info = getdate(strtotime($info['trackingdt'])); |
| 410 |
?> |
| 411 |
<div class="vbo-tracking-info-dtonly"> |
| 412 |
<?php echo date(str_replace("/", $datesep, $df), strtotime($info['trackingdt'])); ?> |
| 413 |
</div> |
| 414 |
<div class="vbo-tracking-info-timeonly"> |
| 415 |
<span class="vbo-tracking-info-wday"><?php echo JText::translate('VB'.strtoupper(substr($subdt_info['weekday'], 0, 3))); ?></span> |
| 416 |
<span class="vbo-tracking-info-time"><?php echo date('H:i', strtotime($info['trackingdt'])); ?></span> |
| 417 |
</div> |
| 418 |
<?php |
| 419 |
} else { |
| 420 |
$diff_info = VikBookingTracker::datesDiff($info['trackingdt'], $row['infos'][($k - 1)]['trackingdt']); |
| 421 |
$diff_type = JText::translate('VBTRKDIFFSECS'); |
| 422 |
if ($diff_info['type'] == 'minutes') { |
| 423 |
$diff_type = JText::translate('VBTRKDIFFMINS'); |
| 424 |
} elseif ($diff_info['type'] == 'hours') { |
| 425 |
$diff_type = JText::translate('VBCONFIGONETENEIGHT'); |
| 426 |
} |
| 427 |
?> |
| 428 |
<span class="vbo-tracking-info-aftertime" title="<?php echo date(str_replace("/", $datesep, $df).' H:i:s', strtotime($info['trackingdt'])); ?>">+ <?php echo $diff_info['diff'] . ' ' . $diff_type; ?></span> |
| 429 |
<?php |
| 430 |
} |
| 431 |
?> |
| 432 |
</div> |
| 433 |
<div class="vbo-tracking-info-dates-cont"> |
| 434 |
<div class="vbo-tracking-info-subrow-lbl"><?php echo JText::translate('VBTRKBOOKINGDATES'); ?></div> |
| 435 |
<div class="vbo-tracking-info-dates-in"> |
| 436 |
<span class="vbo-tracking-info-lbl"> |
| 437 |
<?php echo JText::translate('VBPICKUPAT'); ?> |
| 438 |
</span> |
| 439 |
<span class="vbo-tracking-info-val"> |
| 440 |
<?php |
| 441 |
$tsdt = strtotime($trkdata->checkin); |
| 442 |
$time_info = getdate($tsdt); |
| 443 |
echo JText::translate('VB'.strtoupper(substr($time_info['weekday'], 0, 3))) . ', ' . date(str_replace("/", $datesep, $df), $tsdt); |
| 444 |
?> |
| 445 |
</span> |
| 446 |
</div> |
| 447 |
<div class="vbo-tracking-info-dates-out"> |
| 448 |
<span class="vbo-tracking-info-lbl"> |
| 449 |
<?php echo JText::translate('VBRELEASEAT'); ?> |
| 450 |
</span> |
| 451 |
<span class="vbo-tracking-info-val"> |
| 452 |
<?php |
| 453 |
$tsdt = strtotime($trkdata->checkout); |
| 454 |
$time_info = getdate($tsdt); |
| 455 |
echo JText::translate('VB'.strtoupper(substr($time_info['weekday'], 0, 3))) . ', ' . date(str_replace("/", $datesep, $df), $tsdt); |
| 456 |
?> |
| 457 |
</span> |
| 458 |
</div> |
| 459 |
<?php |
| 460 |
if (isset($trkdata->nights)) { |
| 461 |
?> |
| 462 |
<div class="vbo-tracking-info-dates-out"> |
| 463 |
<span class="vbo-tracking-info-lbl"> |
| 464 |
<?php echo JText::translate('VBPVIEWORDERSSIX'); ?> |
| 465 |
</span> |
| 466 |
<span class="vbo-tracking-info-val"> |
| 467 |
<?php echo $trkdata->nights; ?> |
| 468 |
</span> |
| 469 |
</div> |
| 470 |
<?php |
| 471 |
} |
| 472 |
?> |
| 473 |
</div> |
| 474 |
<?php |
| 475 |
if (isset($trkdata->party)) { |
| 476 |
?> |
| 477 |
<div class="vbo-tracking-info-party-cont"> |
| 478 |
<div class="vbo-tracking-info-subrow-lbl"><?php echo JText::translate('VBQUICKRESGUESTS'); ?></div> |
| 479 |
<?php |
| 480 |
foreach ($trkdata->party as $numroom => $guests) { |
| 481 |
?> |
| 482 |
<div class="vbo-tracking-info-party-room"> |
| 483 |
<span class="vbo-tracking-info-lbl"> |
| 484 |
<?php echo JText::translate('VBMAILROOMNUM').$numroom; ?> |
| 485 |
</span> |
| 486 |
<span class="vbo-tracking-info-val"> |
| 487 |
<?php echo $guests->adults." ".($guests->adults > 1 ? JText::translate('VBMAILADULTS') : JText::translate('VBMAILADULT')).($guests->children > 0 ? ", ".$guests->children." ".($guests->children > 1 ? JText::translate('VBMAILCHILDREN') : JText::translate('VBMAILCHILD')) : ""); ?> |
| 488 |
</span> |
| 489 |
</div> |
| 490 |
<?php |
| 491 |
} |
| 492 |
?> |
| 493 |
</div> |
| 494 |
<?php |
| 495 |
} |
| 496 |
if (isset($trkdata->rooms) || isset($trkdata->rplans)) { |
| 497 |
?> |
| 498 |
<div class="vbo-tracking-info-roomsrates-cont"> |
| 499 |
<div class="vbo-tracking-info-subrow-lbl"><?php echo JText::translate('VBTRKROOMSRATES'); ?></div> |
| 500 |
<?php |
| 501 |
if (isset($trkdata->rooms)) { |
| 502 |
?> |
| 503 |
<div class="vbo-tracking-info-rooms"> |
| 504 |
<?php |
| 505 |
if (isset($trkdata->rindex) && is_array($trkdata->rindex)) { |
| 506 |
$rindexes = array_filter($trkdata->rindex); |
| 507 |
if (count($rindexes)) { |
| 508 |
// display all indexes booked, even the empty ones |
| 509 |
?> |
| 510 |
<div class="vbo-tracking-info-rooms-room"> |
| 511 |
<span class="vbo-tracking-info-lbl"> |
| 512 |
<?php echo JText::translate('VBODISTFEATURERUNIT') . ' ' . implode(', ', $trkdata->rindex); ?> |
| 513 |
</span> |
| 514 |
</div> |
| 515 |
<?php |
| 516 |
} |
| 517 |
} |
| 518 |
foreach ($trkdata->rooms as $idroom => $units) { |
| 519 |
?> |
| 520 |
<div class="vbo-tracking-info-rooms-room"> |
| 521 |
<span class="vbo-tracking-info-lbl"> |
| 522 |
<?php echo (isset($this->rooms[$idroom]) ? $this->rooms[$idroom] : '?').($units > 1 ? ' (x'.$units.')' : ''); ?> |
| 523 |
</span> |
| 524 |
</div> |
| 525 |
<?php |
| 526 |
} |
| 527 |
?> |
| 528 |
</div> |
| 529 |
<?php |
| 530 |
} |
| 531 |
if (isset($trkdata->rplans)) { |
| 532 |
?> |
| 533 |
<div class="vbo-tracking-info-rplans"> |
| 534 |
<?php |
| 535 |
foreach ($trkdata->rplans as $idprice => $units) { |
| 536 |
?> |
| 537 |
<div class="vbo-tracking-info-rplans-room"> |
| 538 |
<span class="vbo-tracking-info-lbl"> |
| 539 |
<?php echo (isset($this->prices[$idprice]) ? $this->prices[$idprice] : '?').($units > 1 ? ' (x'.$units.')' : ''); ?> |
| 540 |
</span> |
| 541 |
</div> |
| 542 |
<?php |
| 543 |
} |
| 544 |
?> |
| 545 |
</div> |
| 546 |
<?php |
| 547 |
} |
| 548 |
?> |
| 549 |
</div> |
| 550 |
<?php |
| 551 |
} |
| 552 |
if (!empty($info['idorder'])) { |
| 553 |
if ($info['status'] == "confirmed") { |
| 554 |
$saystaus = '<span class="label label-success vbo-status-label">'.JText::translate('VBCONFIRMED').'</span>'; |
| 555 |
} elseif ($info['status'] == "standby") { |
| 556 |
$saystaus = '<span class="label label-warning vbo-status-label">'.JText::translate('VBSTANDBY').'</span>'; |
| 557 |
} else { |
| 558 |
$saystaus = '<span class="label label-error vbo-status-label">'.JText::translate('VBCANCELLED').'</span>'; |
| 559 |
} |
| 560 |
?> |
| 561 |
<div class="vbo-tracking-info-booking-cont"> |
| 562 |
<div class="vbo-tracking-info-subrow-lbl"><?php echo JText::translate('VBTRKBOOKCONV'); ?></div> |
| 563 |
<?php echo $saystaus; ?> |
| 564 |
<a href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $info['idorder']; ?>" target="_blank"><?php VikBookingIcons::e('external-link'); ?> <?php echo $info['idorder']; ?></a> |
| 565 |
</div> |
| 566 |
<?php |
| 567 |
} else { |
| 568 |
/** |
| 569 |
* Check if some extra tracking data for special referres (set by VCM) should be displayed. |
| 570 |
* |
| 571 |
* @since 1.15.0 (J) - 1.5.0 (WP) |
| 572 |
*/ |
| 573 |
$extra_trk_props = array(); |
| 574 |
$common_props = VikBookingTracker::$common_trk_props; |
| 575 |
foreach ($trkdata as $trk_prop => $trk_val) { |
| 576 |
if (!is_string($trk_prop) || !is_scalar($trk_val) || in_array($trk_prop, $common_props)) { |
| 577 |
continue; |
| 578 |
} |
| 579 |
$say_trk_prop = ucwords(str_replace('_', ' ', $trk_prop)); |
| 580 |
$extra_trk_props[$say_trk_prop] = $trk_val; |
| 581 |
} |
| 582 |
if (count($extra_trk_props)) { |
| 583 |
// display the extra tracking properties |
| 584 |
?> |
| 585 |
<div class="vbo-tracking-info-booking-cont"> |
| 586 |
<div class="vbo-tracking-info-subrow-lbl"><?php echo JText::translate('VBOGUESTEXTRANOTES'); ?></div> |
| 587 |
<div class="vbo-tracking-info-extra-props"> |
| 588 |
<?php |
| 589 |
foreach ($extra_trk_props as $trk_prop => $trk_val) { |
| 590 |
?> |
| 591 |
<div class="vbo-tracking-info-extra-prop"> |
| 592 |
<span class="vbo-tracking-info-extra-prop-name"><strong><?php echo $trk_prop; ?></strong></span> |
| 593 |
<span class="vbo-tracking-info-extra-prop-val"><?php echo $trk_val; ?></span> |
| 594 |
</div> |
| 595 |
<?php |
| 596 |
} |
| 597 |
?> |
| 598 |
</div> |
| 599 |
</div> |
| 600 |
<?php |
| 601 |
} |
| 602 |
} |
| 603 |
if (!empty($info['referrer'])) { |
| 604 |
/** |
| 605 |
* The tracking referrer may be equal to a channel available in VCM. Try to get its logo. |
| 606 |
* |
| 607 |
* @since 1.15.0 (J) - 1.5.0 (WP) |
| 608 |
*/ |
| 609 |
$referrer_logo = VikBooking::getVcmChannelsLogo($info['referrer']); |
| 610 |
if ($referrer_logo === false) { |
| 611 |
$say_referrer = strpos($info['referrer'], 'http') === false ? ucwords($info['referrer']) : $info['referrer']; |
| 612 |
$referrer_logo = '<span><i class="' . VikBookingIcons::i('globe') . '"></i> ' . $say_referrer . '</span>'; |
| 613 |
} else { |
| 614 |
$referrer_logo = '<span class="vbo-tracking-info-referrer-logo"><img src="' . $referrer_logo . '"/></span>'; |
| 615 |
} |
| 616 |
?> |
| 617 |
<div class="vbo-tracking-info-booking-referrer"> |
| 618 |
<div class="vbo-tracking-info-subrow-lbl"><?php echo JText::translate('VBTRKREFERRER'); ?></div> |
| 619 |
<?php echo $referrer_logo; ?> |
| 620 |
</div> |
| 621 |
<?php |
| 622 |
} |
| 623 |
if (isset($trkdata->msg)) { |
| 624 |
?> |
| 625 |
<div class="vbo-tracking-info-search-results"> |
| 626 |
<?php |
| 627 |
foreach ($trkdata->msg as $msg) { |
| 628 |
$msg_type = strtolower($msg->type); |
| 629 |
$msg_icon = '<i class="'.VikBookingIcons::i('info-circle').'"></i>'; |
| 630 |
if ($msg_type == 'success') { |
| 631 |
$msg_icon = '<i class="'.VikBookingIcons::i('check-circle').'"></i>'; |
| 632 |
} elseif ($msg_type == 'warning') { |
| 633 |
$msg_icon = '<i class="'.VikBookingIcons::i('exclamation-triangle').'"></i>'; |
| 634 |
} elseif ($msg_type == 'error') { |
| 635 |
$msg_icon = '<i class="'.VikBookingIcons::i('times-circle').'"></i>'; |
| 636 |
} |
| 637 |
?> |
| 638 |
<div class="vbo-tracking-info-search-result vbo-tracking-info-search-result-<?php echo $msg_type; ?>"> |
| 639 |
<p><?php echo $msg_icon . ' ' . $msg->text; ?></p> |
| 640 |
</div> |
| 641 |
<?php |
| 642 |
} |
| 643 |
?> |
| 644 |
</div> |
| 645 |
<?php |
| 646 |
} |
| 647 |
?> |
| 648 |
</div> |
| 649 |
<?php |
| 650 |
if (!isset($row['infos'][($k + 1)]) || $info['identifier'] != $row['infos'][($k + 1)]['identifier']) { |
| 651 |
// close current identifier because next is different |
| 652 |
echo '</div>'."\n"; |
| 653 |
} |
| 654 |
} |
| 655 |
?> |
| 656 |
</div> |
| 657 |
</div> |
| 658 |
</div> |
| 659 |
<?php |
| 660 |
$kk = 1 - $kk; |
| 661 |
} |
| 662 |
?> |
| 663 |
</div> |
| 664 |
</div> |
| 665 |
</div> |
| 666 |
<?php |
| 667 |
// calculate most demanded nights, conversion rates, best referrers, average LOS |
| 668 |
$demands_nights = array(); |
| 669 |
$demands_count = array(); |
| 670 |
$referrer_count = array(); |
| 671 |
$totidentifiers = array(); |
| 672 |
$totbookings = array(); |
| 673 |
$los_pool = array(); |
| 674 |
foreach ($this->stats_data as $stat) { |
| 675 |
if (!empty($stat['referrer'])) { |
| 676 |
if (!isset($referrer_count[$stat['referrer']])) { |
| 677 |
$referrer_count[$stat['referrer']] = 0; |
| 678 |
} |
| 679 |
$referrer_count[$stat['referrer']]++; |
| 680 |
} |
| 681 |
if (!isset($totidentifiers[$stat['identifier']])) { |
| 682 |
// total identifiers |
| 683 |
$totidentifiers[$stat['identifier']] = 1; |
| 684 |
} |
| 685 |
if (!empty($stat['idorder']) && !isset($totbookings[$stat['identifier']])) { |
| 686 |
// one conversion per tracking identifier |
| 687 |
$totbookings[$stat['identifier']] = $stat['idorder']; |
| 688 |
} |
| 689 |
// loop through the nights of this tracking info record |
| 690 |
$in_ts = strtotime($stat['checkin']); |
| 691 |
$in_info = getdate($in_ts); |
| 692 |
$out_ts = strtotime($stat['checkout']); |
| 693 |
$out_dt = date('Y-m-d', $out_ts); |
| 694 |
$in_dt = date('Y-m-d', $in_info[0]); |
| 695 |
$now_los = 0; |
| 696 |
while ($in_dt != $out_dt) { |
| 697 |
if (!($in_ts < $out_ts)) { |
| 698 |
// prevent any possible loop in case of records with invalid data |
| 699 |
break; |
| 700 |
} |
| 701 |
$now_los++; |
| 702 |
if (!isset($demands_nights[$in_dt])) { |
| 703 |
$demands_nights[$in_dt] = 0; |
| 704 |
} |
| 705 |
// increase the requests for this night |
| 706 |
$demands_nights[$in_dt]++; |
| 707 |
if (!isset($demands_count[$in_dt])) { |
| 708 |
$demands_count[$in_dt] = array(); |
| 709 |
} |
| 710 |
if (!in_array($stat['idtracking'], $demands_count[$in_dt])) { |
| 711 |
// push this visitor (tracking) ID to the counter for this night |
| 712 |
array_push($demands_count[$in_dt], $stat['idtracking']); |
| 713 |
} |
| 714 |
// update next loop |
| 715 |
$in_info = getdate(mktime(0, 0, 0, $in_info['mon'], ($in_info['mday'] + 1), $in_info['year'])); |
| 716 |
$in_dt = date('Y-m-d', $in_info[0]); |
| 717 |
} |
| 718 |
array_push($los_pool, $now_los); |
| 719 |
} |
| 720 |
|
| 721 |
// sort most demanded nights and best referrers |
| 722 |
arsort($demands_nights); |
| 723 |
arsort($referrer_count); |
| 724 |
|
| 725 |
// count values that could be 0 |
| 726 |
$cnt_tot_idfs = count($totidentifiers); |
| 727 |
$cnt_tot_idfs = $cnt_tot_idfs > 0 ? $cnt_tot_idfs : 1; |
| 728 |
$cnt_los_pool = count($los_pool); |
| 729 |
$cnt_los_pool = $cnt_los_pool > 0 ? $cnt_los_pool : 1; |
| 730 |
|
| 731 |
// average conversion rate: 100 : totidentifiers = x : totbookings |
| 732 |
$avg_conv_rate = 100 * count($totbookings) / $cnt_tot_idfs; |
| 733 |
$avg_conv_rate = round($avg_conv_rate, 2); |
| 734 |
$avg_conv_colr = '#550000'; //black-red |
| 735 |
if ($avg_conv_rate > 33 && $avg_conv_rate <= 66) { |
| 736 |
$avg_conv_colr = '#ff4d4d'; //red |
| 737 |
} elseif ($avg_conv_rate > 66 && $avg_conv_rate < 100) { |
| 738 |
$avg_conv_colr = '#ffa64d'; //orange |
| 739 |
} elseif ($avg_conv_rate >= 100) { |
| 740 |
$avg_conv_colr = '#2a762c'; //green |
| 741 |
} |
| 742 |
|
| 743 |
// average length of stay |
| 744 |
$avg_los = array_sum($los_pool) / $cnt_los_pool; |
| 745 |
$avg_los = round($avg_los, 1); |
| 746 |
?> |
| 747 |
<div class="vbo-trackings-tabcont-stats" style="display: none;"> |
| 748 |
<div class="vbo-trackings-chart-bestnights"> |
| 749 |
<h4><?php echo JText::translate('VBTRKMOSTDEMNIGHTS'); ?></h4> |
| 750 |
<?php |
| 751 |
// the 14 most demanded nights |
| 752 |
$max = 14; |
| 753 |
$ind = 0; |
| 754 |
foreach ($demands_nights as $dt => $tot) { |
| 755 |
$dt_info = getdate(strtotime($dt)); |
| 756 |
?> |
| 757 |
<div class="vbo-trackings-chart-container" id="vbo-trackings-chart-container-<?php echo $dt; ?>"> |
| 758 |
<span class="vbo-trackings-chart-date"><?php echo JText::translate('VB'.strtoupper(substr($dt_info['weekday'], 0, 3))); ?>, <?php echo date(str_replace("/", $datesep, $df), $dt_info[0]); ?></span> |
| 759 |
<div class="vbo-trackings-chart-cont"> |
| 760 |
<div class="vbo-trackings-chart-totreqs"> |
| 761 |
<span class="vbo-trackings-chart-tot"><?php echo $tot; ?></span> |
| 762 |
<span class="vbo-trackings-chart-txt"><?php echo JText::translate('VBTRKREQSNUM'); ?></span> |
| 763 |
</div> |
| 764 |
<div class="vbo-trackings-chart-totviss"> |
| 765 |
<span class="vbo-trackings-chart-tot"><?php echo count($demands_count[$dt]); ?></span> |
| 766 |
<span class="vbo-trackings-chart-txt"><?php echo JText::translate('VBTRKVISSNUM'); ?></span> |
| 767 |
</div> |
| 768 |
</div> |
| 769 |
</div> |
| 770 |
<?php |
| 771 |
$ind++; |
| 772 |
if ($ind >= $max) { |
| 773 |
break; |
| 774 |
} |
| 775 |
} |
| 776 |
?> |
| 777 |
</div> |
| 778 |
|
| 779 |
<div class="vbo-trackings-chart-middle"> |
| 780 |
|
| 781 |
<div class="vbo-trackings-chart-avgvals"> |
| 782 |
<div class="vbo-trackings-chart-avgval-container"> |
| 783 |
<h4><?php echo JText::translate('VBTRKAVGVALS'); ?></h4> |
| 784 |
<div class="vbo-trackings-chart-avgval-listcont"> |
| 785 |
<div class="vbo-trackings-avgval"> |
| 786 |
<div class="vbo-trackings-avgval-det"> |
| 787 |
<h5><?php echo JText::translate('VBTRKTOTVISS'); ?></h5> |
| 788 |
<div class="vbo-trackings-chart-avgviss"> |
| 789 |
<span class="vbo-trackings-chart-tot"><?php echo count($totidentifiers); ?></span> |
| 790 |
</div> |
| 791 |
</div> |
| 792 |
</div> |
| 793 |
<div class="vbo-trackings-avgval"> |
| 794 |
<div class="vbo-trackings-avgval-det"> |
| 795 |
<h5><?php echo JText::translate('VBCUSTOMERTOTBOOKINGS'); ?></h5> |
| 796 |
<div class="vbo-trackings-chart-totres"> |
| 797 |
<span class="vbo-trackings-chart-tot"><?php echo count($totbookings); ?></span> |
| 798 |
</div> |
| 799 |
</div> |
| 800 |
</div> |
| 801 |
<div class="vbo-trackings-avgval"> |
| 802 |
<div class="vbo-trackings-avgval-det"> |
| 803 |
<h5><?php echo JText::translate('VBTRKAVGLOS'); ?></h5> |
| 804 |
<div class="vbo-trackings-chart-avglos"> |
| 805 |
<span class="vbo-trackings-chart-tot"><?php echo $avg_los; ?></span> |
| 806 |
</div> |
| 807 |
</div> |
| 808 |
</div> |
| 809 |
<div class="vbo-trackings-avgval"> |
| 810 |
<div class="vbo-trackings-avgval-det"> |
| 811 |
<h5><?php echo JText::translate('VBTRKAVGCONVRATE'); ?> <?php echo $vbo_app->createPopover(array('title' => JText::translate('VBTRKAVGCONVRATE'), 'content' => JText::translate('VBTRKAVGCONVRATEHELP'))); ?></h5> |
| 812 |
<div class="vbo-trackings-chart-avgconvrate"> |
| 813 |
<span class="vbo-trackings-chart-tot" style="color: <?php echo $avg_conv_colr; ?>;"><?php echo $avg_conv_rate; ?></span> |
| 814 |
<span class="vbo-trackings-chart-pcent">%</span> |
| 815 |
</div> |
| 816 |
</div> |
| 817 |
</div> |
| 818 |
</div> |
| 819 |
</div> |
| 820 |
</div> |
| 821 |
<?php |
| 822 |
if (count($referrer_count)) { |
| 823 |
?> |
| 824 |
<div class="vbo-trackings-chart-referrers"> |
| 825 |
<h4><?php echo JText::translate('VBTRKBESTREFERRERS'); ?></h4> |
| 826 |
<?php |
| 827 |
// the 5 best referrers |
| 828 |
$max = 5; |
| 829 |
$ind = 0; |
| 830 |
foreach ($referrer_count as $name => $tot) { |
| 831 |
?> |
| 832 |
<div class="vbo-trackings-chart-referrer"> |
| 833 |
<span class="vbo-trackings-chart-date"><?php echo $name; ?></span> |
| 834 |
<div class="vbo-trackings-chart-cont"> |
| 835 |
<div class="vbo-trackings-chart-totreqs"> |
| 836 |
<span class="vbo-trackings-chart-tot"><?php echo $tot; ?></span> |
| 837 |
<span class="vbo-trackings-chart-txt"><?php echo JText::translate('VBTRKVISSNUM'); ?></span> |
| 838 |
</div> |
| 839 |
</div> |
| 840 |
</div> |
| 841 |
<?php |
| 842 |
$ind++; |
| 843 |
if ($ind >= $max) { |
| 844 |
break; |
| 845 |
} |
| 846 |
} |
| 847 |
?> |
| 848 |
</div> |
| 849 |
<?php |
| 850 |
} |
| 851 |
?> |
| 852 |
</div> |
| 853 |
|
| 854 |
</div> |
| 855 |
</div> |
| 856 |
<?php |
| 857 |
} |
| 858 |
?> |
| 859 |
<input type="hidden" name="vbo_active_tab" id="vbo_active_tab" value=""> |
| 860 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 861 |
<input type="hidden" name="task" value="trackings" /> |
| 862 |
<input type="hidden" name="boxchecked" value="0" /> |
| 863 |
<?php echo JHtml::fetch('form.token'); ?> |
| 864 |
<?php echo $navbut; ?> |
| 865 |
</form> |
| 866 |
|