| 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 |
jimport('joomla.application.component.view'); |
| 14 |
|
| 15 |
class VikbookingViewSignature extends JViewVikBooking |
| 16 |
{ |
| 17 |
public function display($tpl = null) |
| 18 |
{ |
| 19 |
//set noindex instruction for robots |
| 20 |
$document = JFactory::getDocument(); |
| 21 |
$document->setMetaData('robots', 'noindex,follow'); |
| 22 |
|
| 23 |
$sid = VikRequest::getString('sid', '', 'request'); |
| 24 |
$ts = VikRequest::getString('ts', '', 'request'); |
| 25 |
|
| 26 |
$dbo = JFactory::getDbo(); |
| 27 |
$mainframe = JFactory::getApplication(); |
| 28 |
$vbo_tn = VikBooking::getTranslator(); |
| 29 |
|
| 30 |
$q = "SELECT * FROM `#__vikbooking_orders` WHERE `ts`=" . $dbo->quote($ts) . " AND (`sid`=" . $dbo->quote($sid) . " OR `idorderota`=" . $dbo->quote($sid) . ") AND `status`='confirmed';"; |
| 31 |
$dbo->setQuery($q); |
| 32 |
$row = $dbo->loadAssoc(); |
| 33 |
if (!$row) { |
| 34 |
VikError::raiseWarning('', 'Booking not found'); |
| 35 |
$mainframe->redirect('index.php'); |
| 36 |
exit; |
| 37 |
} |
| 38 |
|
| 39 |
$tonight = mktime(23, 59, 59, date('n'), date('j'), date('Y')); |
| 40 |
if ($tonight > $row['checkout']) { |
| 41 |
VikError::raiseWarning('', 'Check-out date is in the past'); |
| 42 |
$mainframe->redirect('index.php'); |
| 43 |
exit; |
| 44 |
} |
| 45 |
|
| 46 |
$q = "SELECT `c`.*,`co`.`idorder`,`co`.`signature`,`co`.`pax_data`,`co`.`comments` FROM `#__vikbooking_customers` AS `c` LEFT JOIN `#__vikbooking_customers_orders` `co` ON `c`.`id`=`co`.`idcustomer` WHERE `co`.`idorder`=".(int)$row['id'].";"; |
| 47 |
$dbo->setQuery($q); |
| 48 |
$customer = $dbo->loadAssoc(); |
| 49 |
if (!$customer) { |
| 50 |
VikError::raiseWarning('', 'Customer not found'); |
| 51 |
$mainframe->redirect('index.php'); |
| 52 |
exit; |
| 53 |
} |
| 54 |
|
| 55 |
$orderrooms = array(); |
| 56 |
$q = "SELECT `or`.`idroom`,`or`.`adults`,`or`.`children`,`or`.`idtar`,`or`.`optionals`,`or`.`roomindex`,`or`.`pkg_id`,`or`.`pkg_name`,`or`.`cust_cost`,`or`.`cust_idiva`,`or`.`extracosts`,`or`.`room_cost`,`r`.`id` AS `r_reference_id`,`r`.`name`,`r`.`img`,`r`.`idcarat`,`r`.`fromadult`,`r`.`toadult` FROM `#__vikbooking_ordersrooms` AS `or`,`#__vikbooking_rooms` AS `r` WHERE `or`.`idorder`=".(int)$row['id']." AND `or`.`idroom`=`r`.`id` ORDER BY `or`.`id` ASC;"; |
| 57 |
$dbo->setQuery($q); |
| 58 |
$orderrooms = $dbo->loadAssocList(); |
| 59 |
if (!$orderrooms) { |
| 60 |
VikError::raiseWarning('', 'No rooms found'); |
| 61 |
$mainframe->redirect('index.php'); |
| 62 |
exit; |
| 63 |
} |
| 64 |
|
| 65 |
$vbo_tn->translateContents($orderrooms, '#__vikbooking_rooms', array('id' => 'r_reference_id')); |
| 66 |
|
| 67 |
// load assets |
| 68 |
if (VikBooking::loadJquery()) { |
| 69 |
JHtml::fetch('jquery.framework', true, true); |
| 70 |
} |
| 71 |
$document->addScript(VBO_SITE_URI.'resources/signature_pad.js'); |
| 72 |
$document->addStyleSheet(VBO_ADMIN_URI.'resources/fonts/vboicomoon.css'); |
| 73 |
|
| 74 |
$this->ord = $row; |
| 75 |
$this->orderrooms = $orderrooms; |
| 76 |
$this->customer = $customer; |
| 77 |
$this->vbo_tn = $vbo_tn; |
| 78 |
|
| 79 |
// theme |
| 80 |
$theme = VikBooking::getTheme(); |
| 81 |
if ($theme != 'default') { |
| 82 |
$thdir = VBO_SITE_PATH . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . 'signature'; |
| 83 |
if (is_dir($thdir)) { |
| 84 |
$this->_setPath('template', $thdir . DIRECTORY_SEPARATOR); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
parent::display($tpl); |
| 89 |
} |
| 90 |
} |
| 91 |
|