| 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 VikbookingViewOrderslist extends JViewVikBooking |
| 16 |
{ |
| 17 |
public function display($tpl = null) |
| 18 |
{ |
| 19 |
VikBooking::prepareViewContent(); |
| 20 |
|
| 21 |
$app = JFactory::getApplication(); |
| 22 |
$dbo = JFactory::getDbo(); |
| 23 |
|
| 24 |
$islogged = VikBooking::userIsLogged(); |
| 25 |
$cpin = VikBooking::getCPinInstance(); |
| 26 |
|
| 27 |
$pconfirmnumber = VikRequest::getString('confirmnumber', '', 'request'); |
| 28 |
$pitemid = VikRequest::getInt('Itemid', 0, 'request'); |
| 29 |
|
| 30 |
if (!empty($pconfirmnumber)) { |
| 31 |
$q = "SELECT `id`,`ts`,`sid`,`idorderota` FROM `#__vikbooking_orders` WHERE `confirmnumber`=" . $dbo->quote($pconfirmnumber) . " OR `idorderota`=" . $dbo->quote($pconfirmnumber) . ";"; |
| 32 |
$dbo->setQuery($q); |
| 33 |
$odata = $dbo->loadAssocList(); |
| 34 |
if ($odata) { |
| 35 |
$app->redirect(JRoute::rewrite('index.php?option=com_vikbooking&view=booking&sid='.(!empty($odata[0]['sid']) ? $odata[0]['sid'] : $odata[0]['idorderota']).'&ts='.$odata[0]['ts'].(!empty($pitemid) ? '&Itemid='.$pitemid : ''), false)); |
| 36 |
$app->close(); |
| 37 |
} |
| 38 |
if ($cpin->pinExists($pconfirmnumber)) { |
| 39 |
$cpin->setNewPin($pconfirmnumber); |
| 40 |
} else { |
| 41 |
VikError::raiseWarning('', JText::translate('VBINVALIDCONFIRMNUMBER')); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
$customer_details = $cpin->loadCustomerDetails(); |
| 46 |
$userorders = []; |
| 47 |
$navig = ''; |
| 48 |
if ($islogged || $customer_details) { |
| 49 |
$currentUser = JFactory::getUser(); |
| 50 |
$lim = 10; |
| 51 |
$lim0 = VikRequest::getVar('limitstart', 0, '', 'int'); |
| 52 |
$q = "SELECT SQL_CALC_FOUND_ROWS `o`.*,`co`.`idcustomer` FROM `#__vikbooking_orders` AS `o` LEFT JOIN `#__vikbooking_customers_orders` `co` ON `co`.`idorder`=`o`.`id` WHERE ".($islogged ? "`o`.`ujid`='".$currentUser->id."'".(count($customer_details) > 0 ? " OR " : "") : "").(count($customer_details) > 0 ? "`co`.`idcustomer`=".(int)$customer_details['id'] : "")." ORDER BY `o`.`checkin` DESC"; |
| 53 |
$dbo->setQuery($q, $lim0, $lim); |
| 54 |
$userorders = $dbo->loadAssocList(); |
| 55 |
if ($userorders) { |
| 56 |
$dbo->setQuery('SELECT FOUND_ROWS();'); |
| 57 |
jimport('joomla.html.pagination'); |
| 58 |
$pageNav = new JPagination( $dbo->loadResult(), $lim0, $lim ); |
| 59 |
$navig = $pageNav->getPagesLinks(); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
$this->userorders = $userorders; |
| 64 |
$this->customer_details = $customer_details; |
| 65 |
$this->navig = $navig; |
| 66 |
|
| 67 |
//theme |
| 68 |
$theme = VikBooking::getTheme(); |
| 69 |
if ($theme != 'default') { |
| 70 |
$thdir = VBO_SITE_PATH . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . 'orderslist'; |
| 71 |
if (is_dir($thdir)) { |
| 72 |
$this->_setPath('template', $thdir . DIRECTORY_SEPARATOR); |
| 73 |
} |
| 74 |
} |
| 75 |
// |
| 76 |
parent::display($tpl); |
| 77 |
} |
| 78 |
} |
| 79 |
|