| @@ -13,25 +13,28 @@ | ||
| 13 | 13 | jimport('joomla.application.component.view'); |
| 14 | 14 | |
| 15 | 15 | class VikbookingViewOrderslist extends JViewVikBooking |
| 16 | 16 | { |
| 17 | - function display($tpl = null) | |
| 17 | + public function display($tpl = null) | |
| 18 | 18 | { |
| 19 | 19 | VikBooking::prepareViewContent(); |
| 20 | + | |
| 20 | 21 | $app = JFactory::getApplication(); |
| 21 | 22 | $dbo = JFactory::getDbo(); |
| 23 | + | |
| 22 | 24 | $islogged = VikBooking::userIsLogged(); |
| 23 | - $cpin = VikBooking::getCPinIstance(); | |
| 25 | + $cpin = VikBooking::getCPinInstance(); | |
| 26 | + | |
| 24 | 27 | $pconfirmnumber = VikRequest::getString('confirmnumber', '', 'request'); |
| 25 | 28 | $pitemid = VikRequest::getInt('Itemid', 0, 'request'); |
| 29 | + | |
| 26 | 30 | if (!empty($pconfirmnumber)) { |
| 27 | 31 | $q = "SELECT `id`,`ts`,`sid`,`idorderota` FROM `#__vikbooking_orders` WHERE `confirmnumber`=" . $dbo->quote($pconfirmnumber) . " OR `idorderota`=" . $dbo->quote($pconfirmnumber) . ";"; |
| 28 | 32 | $dbo->setQuery($q); |
| 29 | - $dbo->execute(); | |
| 30 | - if ($dbo->getNumRows() > 0) { | |
| 31 | - $odata = $dbo->loadAssocList(); | |
| 33 | + $odata = $dbo->loadAssocList(); | |
| 34 | + if ($odata) { | |
| 32 | 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)); |
| 33 | - exit; | |
| 36 | + $app->close(); | |
| 34 | 37 | } |
| 35 | 38 | if ($cpin->pinExists($pconfirmnumber)) { |
| 36 | 39 | $cpin->setNewPin($pconfirmnumber); |
| 37 | 40 | } else { |
| @@ -37,20 +40,20 @@ | ||
| 37 | 40 | } else { |
| 38 | 41 | VikError::raiseWarning('', JText::translate('VBINVALIDCONFIRMNUMBER')); |
| 39 | 42 | } |
| 40 | 43 | } |
| 44 | + | |
| 41 | 45 | $customer_details = $cpin->loadCustomerDetails(); |
| 42 | 46 | $userorders = []; |
| 43 | 47 | $navig = ''; |
| 44 | - if ($islogged || count($customer_details) > 0) { | |
| 48 | + if ($islogged || $customer_details) { | |
| 45 | 49 | $currentUser = JFactory::getUser(); |
| 46 | 50 | $lim = 10; |
| 47 | 51 | $lim0 = VikRequest::getVar('limitstart', 0, '', 'int'); |
| 48 | 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"; |
| 49 | 53 | $dbo->setQuery($q, $lim0, $lim); |
| 50 | - $dbo->execute(); | |
| 51 | - if ($dbo->getNumRows() > 0) { | |
| 52 | - $userorders = $dbo->loadAssocList(); | |
| 54 | + $userorders = $dbo->loadAssocList(); | |
| 55 | + if ($userorders) { | |
| 53 | 56 | $dbo->setQuery('SELECT FOUND_ROWS();'); |
| 54 | 57 | jimport('joomla.html.pagination'); |
| 55 | 58 | $pageNav = new JPagination( $dbo->loadResult(), $lim0, $lim ); |
| 56 | 59 | $navig = $pageNav->getPagesLinks(); |
| @@ -55,11 +58,13 @@ | ||
| 55 | 58 | $pageNav = new JPagination( $dbo->loadResult(), $lim0, $lim ); |
| 56 | 59 | $navig = $pageNav->getPagesLinks(); |
| 57 | 60 | } |
| 58 | 61 | } |
| 62 | + | |
| 59 | 63 | $this->userorders = $userorders; |
| 60 | 64 | $this->customer_details = $customer_details; |
| 61 | 65 | $this->navig = $navig; |
| 66 | + | |
| 62 | 67 | //theme |
| 63 | 68 | $theme = VikBooking::getTheme(); |
| 64 | 69 | if ($theme != 'default') { |
| 65 | 70 | $thdir = VBO_SITE_PATH . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . 'orderslist'; |