| 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 |
// import Joomla view library |
| 14 |
jimport('joomla.application.component.view'); |
| 15 |
|
| 16 |
class VikBookingViewGencheckindoc extends JViewVikBooking { |
| 17 |
|
| 18 |
function display($tpl = null) { |
| 19 |
// This view is usually called within a modal box, so it does not require the toolbar or page title |
| 20 |
|
| 21 |
/** |
| 22 |
* @wponly - if we fall here because of a redirect after the generation of the check-in doc, and we are not doing Ajax, |
| 23 |
* we need to print a button in the toolbar to go back to the booking details page. |
| 24 |
*/ |
| 25 |
$ptmpl = VikRequest::getString('tmpl', '', 'request'); |
| 26 |
if (empty($ptmpl) && !wp_doing_ajax()) { |
| 27 |
JToolBarHelper::cancel( 'editorder', JText::translate('VBBACK')); |
| 28 |
JToolBarHelper::spacer(); |
| 29 |
} |
| 30 |
// |
| 31 |
|
| 32 |
$cid = VikRequest::getVar('cid', array(0)); |
| 33 |
$id = $cid[0]; |
| 34 |
|
| 35 |
$dbo = JFactory::getDBO(); |
| 36 |
$mainframe = JFactory::getApplication(); |
| 37 |
$ptmpl = VikRequest::getString('tmpl', '', 'request'); |
| 38 |
$q = "SELECT * FROM `#__vikbooking_orders` WHERE `id`=".(int)$id." AND `status`='confirmed' AND `checked` > 0;"; |
| 39 |
$dbo->setQuery($q); |
| 40 |
$dbo->execute(); |
| 41 |
if ($dbo->getNumRows() < 1) { |
| 42 |
$mainframe->redirect('index.php'); |
| 43 |
exit; |
| 44 |
} |
| 45 |
$row = $dbo->loadAssoc(); |
| 46 |
$customer = array(); |
| 47 |
$q = "SELECT `c`.*,`co`.`idorder`,`co`.`signature`,`co`.`pax_data`,`co`.`comments`,`co`.`checkindoc` FROM `#__vikbooking_customers` AS `c` LEFT JOIN `#__vikbooking_customers_orders` `co` ON `c`.`id`=`co`.`idcustomer` WHERE `co`.`idorder`=".$row['id'].";"; |
| 48 |
$dbo->setQuery($q); |
| 49 |
$dbo->execute(); |
| 50 |
if ($dbo->getNumRows() > 0) { |
| 51 |
$customer = $dbo->loadAssoc(); |
| 52 |
if (!empty($customer['country'])) { |
| 53 |
if (file_exists(VBO_ADMIN_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'countries'.DIRECTORY_SEPARATOR.$customer['country'].'.png')) { |
| 54 |
$customer['country_img'] = '<img src="'.VBO_ADMIN_URI.'resources/countries/'.$customer['country'].'.png'.'" title="'.$customer['country'].'" class="vbo-country-flag vbo-country-flag-left"/>'; |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
if (!(count($customer) > 0)) { |
| 59 |
VikError::raiseWarning('', JText::translate('VBOCHECKINERRNOCUSTOMER')); |
| 60 |
$mainframe->redirect('index.php?option=com_vikbooking&task=newcustomer&checkin=1&bid='.$row['id'].($ptmpl == 'component' ? '&tmpl=component' : '')); |
| 61 |
exit; |
| 62 |
} |
| 63 |
|
| 64 |
$this->row = $row; |
| 65 |
$this->customer = $customer; |
| 66 |
|
| 67 |
// Display the template |
| 68 |
parent::display($tpl); |
| 69 |
} |
| 70 |
|
| 71 |
} |
| 72 |
|