| 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 |
$document = JFactory::getDocument(); |
| 14 |
// load jQuery lib e jQuery UI |
| 15 |
if (VikBooking::loadJquery()) { |
| 16 |
// JHtml::fetch('jquery.framework', true, true); |
| 17 |
JHtml::fetch('script', VBO_SITE_URI.'resources/jquery-1.12.4.min.js'); |
| 18 |
} |
| 19 |
$document->addStyleSheet(VBO_SITE_URI.'resources/jquery-ui.min.css'); |
| 20 |
JHtml::fetch('script', VBO_SITE_URI.'resources/jquery-ui.min.js'); |
| 21 |
|
| 22 |
$datesep = VikBooking::getDateSeparator(); |
| 23 |
$nowdf = VikBooking::getDateFormat(); |
| 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 |
|
| 32 |
$pitemid = VikRequest::getInt('Itemid', '', 'request'); |
| 33 |
$bestitemid = VikBooking::findProperItemIdType(array('booking')); |
| 34 |
$rev_minchars = VikBooking::guestReviewMinChars(); |
| 35 |
$rev_type = VikBooking::guestReviewsType(); |
| 36 |
$rev_services = $this->grev_services; |
| 37 |
$rev_services = $rev_type == 'global' ? array(array('global')) : $rev_services; |
| 38 |
$ts_info = getdate($this->order['ts']); |
| 39 |
$checkin_info = getdate($this->order['checkin']); |
| 40 |
$checkout_info = getdate($this->order['checkout']); |
| 41 |
$wdays_map = array( |
| 42 |
JText::translate('VBWEEKDAYZERO'), |
| 43 |
JText::translate('VBWEEKDAYONE'), |
| 44 |
JText::translate('VBWEEKDAYTWO'), |
| 45 |
JText::translate('VBWEEKDAYTHREE'), |
| 46 |
JText::translate('VBWEEKDAYFOUR'), |
| 47 |
JText::translate('VBWEEKDAYFIVE'), |
| 48 |
JText::translate('VBWEEKDAYSIX') |
| 49 |
); |
| 50 |
|
| 51 |
// lang vars for JS |
| 52 |
JText::script('VBOREVIEWMESSLIM'); |
| 53 |
|
| 54 |
?> |
| 55 |
<h3 class="vbo-booking-details-intro"><?php echo JText::translate('VBOLEAVEAREVIEWSTAY'); ?></h3> |
| 56 |
|
| 57 |
<div class="vbo-booking-leavereview-wrap"> |
| 58 |
|
| 59 |
<div class="vbo-booking-details-topcontainer"> |
| 60 |
<div class="vbo-booking-details-midcontainer"> |
| 61 |
<div class="vbo-booking-details-bookinfos"> |
| 62 |
<span class="vbvordudatatitle"><?php echo JText::translate('VBORDERDETAILS'); ?></span> |
| 63 |
<div class="vbo-booking-details-bookinfo"> |
| 64 |
<span class="vbo-booking-details-bookinfo-lbl"><?php echo JText::translate('VBORDEREDON'); ?></span> |
| 65 |
<span class="vbo-booking-details-bookinfo-val"><?php echo $wdays_map[$ts_info['wday']].', '.date(str_replace("/", $datesep, $df).' H:i', $this->order['ts']); ?></span> |
| 66 |
</div> |
| 67 |
<?php |
| 68 |
if (!empty($this->order['idorderota']) && !empty($this->order['channel'])) { |
| 69 |
?> |
| 70 |
<div class="vbo-booking-details-bookinfo"> |
| 71 |
<span class="vbo-booking-details-bookinfo-lbl"><?php echo JText::translate('VBORDERNUMBER'); ?></span> |
| 72 |
<span class="vbo-booking-details-bookinfo-val"><?php echo $this->order['idorderota']; ?></span> |
| 73 |
</div> |
| 74 |
<?php |
| 75 |
} |
| 76 |
?> |
| 77 |
<div class="vbo-booking-details-bookinfo"> |
| 78 |
<span class="vbo-booking-details-bookinfo-lbl"><?php echo JText::translate('VBDAL'); ?></span> |
| 79 |
<span class="vbo-booking-details-bookinfo-val"><?php echo $wdays_map[$checkin_info['wday']].', '.date(str_replace("/", $datesep, $df).' H:i', $this->order['checkin']); ?></span> |
| 80 |
</div> |
| 81 |
<div class="vbo-booking-details-bookinfo"> |
| 82 |
<span class="vbo-booking-details-bookinfo-lbl"><?php echo JText::translate('VBAL'); ?></span> |
| 83 |
<span class="vbo-booking-details-bookinfo-val"><?php echo $wdays_map[$checkout_info['wday']].', '.date(str_replace("/", $datesep, $df).' H:i', $this->order['checkout']); ?></span> |
| 84 |
</div> |
| 85 |
<div class="vbo-booking-details-bookinfo"> |
| 86 |
<span class="vbo-booking-details-bookinfo-lbl"><?php echo JText::translate('VBDAYS'); ?></span> |
| 87 |
<span class="vbo-booking-details-bookinfo-val"><?php echo $this->order['days']; ?></span> |
| 88 |
</div> |
| 89 |
</div> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
|
| 93 |
<div class="vbo-booking-leavereview-content"> |
| 94 |
<div class="vbo-booking-leavereview-inner"> |
| 95 |
<form action="<?php echo JRoute::rewrite('index.php?option=com_vikbooking&task=sendreview'); ?>" method="post" onsubmit="return vboValidateReview();"> |
| 96 |
<div class="vbo-booking-starrating-wrap"> |
| 97 |
<?php |
| 98 |
foreach ($rev_services as $k => $v) { |
| 99 |
?> |
| 100 |
<div class="vbo-booking-starrating-cont"> |
| 101 |
<?php |
| 102 |
if (isset($v['service_name']) && !empty($v['service_name'])) { |
| 103 |
?> |
| 104 |
<h5 class="vbo-booking-review-servicename"><?php echo $v['service_name']; ?></h5> |
| 105 |
<?php |
| 106 |
} elseif (is_array($v) && in_array('global', $v)) { |
| 107 |
?> |
| 108 |
<h5 class="vbo-booking-review-servicename vbo-booking-review-global"><?php echo JText::translate('VBOREVIEWRATEEXP'); ?></h5> |
| 109 |
<?php |
| 110 |
} |
| 111 |
?> |
| 112 |
<div class="vbo-booking-starrating-stars" data-starlocked="0"> |
| 113 |
<?php |
| 114 |
for ($i = 1; $i <= 5; $i++) { |
| 115 |
?> |
| 116 |
<i class="<?php echo VikBookingIcons::i('star', 'vbo-review-star vbo-review-star-full'); ?>" data-starid="<?php echo $i; ?>" onclick="vboSetStarRating(<?php echo $k; ?>, <?php echo $i; ?>, this);"></i> |
| 117 |
<?php |
| 118 |
} |
| 119 |
?> |
| 120 |
<input type="hidden" name="rating[]" value="5" class="vbo-review-ratinginp" id="vbo-review-ratinginp<?php echo $k; ?>" /> |
| 121 |
</div> |
| 122 |
</div> |
| 123 |
<?php |
| 124 |
} |
| 125 |
?> |
| 126 |
</div> |
| 127 |
<?php |
| 128 |
if ($rev_minchars >= 0) { |
| 129 |
// review message is requested |
| 130 |
?> |
| 131 |
<div class="vbo-booking-review-message"> |
| 132 |
<label for="vbo-review-message"><?php echo JText::translate('VBOREVIEWLEAVEMESS'); ?></label> |
| 133 |
<div class="vbo-booking-review-message-inner"> |
| 134 |
<textarea name="ratingmess" id="vbo-review-message"></textarea> |
| 135 |
<div class="vbo-booking-review-message-privacy"><?php echo JText::translate('VBOREVIEWMESSPRIVACY'); ?></div> |
| 136 |
</div> |
| 137 |
</div> |
| 138 |
<?php |
| 139 |
} |
| 140 |
?> |
| 141 |
<div class="vbo-booking-review-cmds"> |
| 142 |
<div class="vbo-booking-review-cmd"> |
| 143 |
<a class="btn vbo-pref-color-btn-secondary" href="<?php echo JRoute::rewrite('index.php?option=com_vikbooking&view=booking&sid=' . (!empty($this->order['idorderota']) && !empty($this->order['channel']) ? $this->order['idorderota'] : $this->order['sid']) . '&ts=' . $this->order['ts'] . (!empty($bestitemid) ? '&Itemid='.$bestitemid : (!empty($pitemid) ? '&Itemid='.$pitemid : ''))); ?>"><?php echo JText::translate('VBDIALOGBTNCANCEL'); ?></a> |
| 144 |
</div> |
| 145 |
<div class="vbo-booking-review-cmd"> |
| 146 |
<button type="submit" class="btn vbo-pref-color-btn"><?php echo JText::translate('VBOREVIEWSUBMIT'); ?></button> |
| 147 |
</div> |
| 148 |
</div> |
| 149 |
<input type="hidden" name="task" value="sendreview" /> |
| 150 |
<input type="hidden" name="Itemid" value="<?php echo (!empty($bestitemid) ? $bestitemid : $pitemid); ?>" /> |
| 151 |
<input type="hidden" name="sid" value="<?php echo (!empty($this->order['idorderota']) && !empty($this->order['channel']) ? $this->order['idorderota'] : $this->order['sid']); ?>" /> |
| 152 |
<input type="hidden" name="ts" value="<?php echo $this->order['ts']; ?>" /> |
| 153 |
</form> |
| 154 |
</div> |
| 155 |
</div> |
| 156 |
|
| 157 |
</div> |
| 158 |
|
| 159 |
<script type="text/javascript"> |
| 160 |
function vboSetStarRating(service_ind, rating, elem) { |
| 161 |
// update input value |
| 162 |
document.getElementById('vbo-review-ratinginp' + service_ind).value = elem.getAttribute('data-starid'); |
| 163 |
// toggle lock/unlock parent node from hovering |
| 164 |
var service = jQuery(elem).closest('.vbo-booking-starrating-stars'); |
| 165 |
var islocked = service.attr('data-starlocked'); |
| 166 |
service.attr('data-starlocked', (islocked == '1' ? '0' : '1')); |
| 167 |
// unset full class |
| 168 |
service.find('.vbo-review-star').removeClass('vbo-review-star-full'); |
| 169 |
// add full class where necessary |
| 170 |
for (var i = 1; i <= rating; i++) { |
| 171 |
service.find('.vbo-review-star[data-starid="' + i + '"]').addClass('vbo-review-star-full'); |
| 172 |
} |
| 173 |
} |
| 174 |
function vboValidateReview() { |
| 175 |
if (jQuery('#vbo-review-message').length) { |
| 176 |
var chars = jQuery('#vbo-review-message').val().length; |
| 177 |
if (chars < <?php echo $rev_minchars; ?>) { |
| 178 |
alert(Joomla.JText._('VBOREVIEWMESSLIM').replace('%d', '<?php echo $rev_minchars; ?>')); |
| 179 |
return false; |
| 180 |
} |
| 181 |
} |
| 182 |
return true; |
| 183 |
} |
| 184 |
jQuery(function() { |
| 185 |
jQuery('.vbo-review-star').hover( |
| 186 |
function() { |
| 187 |
var rating = parseInt(jQuery(this).attr('data-starid')); |
| 188 |
var service = jQuery(this).closest('.vbo-booking-starrating-stars'); |
| 189 |
if (service.attr('data-starlocked') == '1') { |
| 190 |
// only click is allowed |
| 191 |
return; |
| 192 |
} |
| 193 |
// update input value |
| 194 |
service.find('.vbo-review-ratinginp').val(rating); |
| 195 |
// unset full class |
| 196 |
service.find('.vbo-review-star').removeClass('vbo-review-star-full'); |
| 197 |
// add full class where necessary |
| 198 |
for (var i = 1; i <= rating; i++) { |
| 199 |
service.find('.vbo-review-star[data-starid="' + i + '"]').addClass('vbo-review-star-full'); |
| 200 |
} |
| 201 |
}, function() { |
| 202 |
// do nothing when hovering out |
| 203 |
} |
| 204 |
); |
| 205 |
}); |
| 206 |
</script> |
| 207 |
|