| 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 VikBookingViewEditbusy extends JViewVikBooking |
| 17 |
{ |
| 18 |
public function display($tpl = null) |
| 19 |
{ |
| 20 |
// Set the toolbar |
| 21 |
$this->addToolBar(); |
| 22 |
|
| 23 |
if (!JFactory::getUser()->authorise('core.vbo.bookings', 'com_vikbooking')) { |
| 24 |
VBOHttpDocument::getInstance()->close(403, JText::translate('JERROR_ALERTNOAUTHOR')); |
| 25 |
} |
| 26 |
|
| 27 |
$cid = VikRequest::getVar('cid', array(0)); |
| 28 |
$oid = $cid[0]; |
| 29 |
|
| 30 |
$dbo = JFactory::getDbo(); |
| 31 |
$app = JFactory::getApplication(); |
| 32 |
|
| 33 |
if (empty($oid)) { |
| 34 |
VikError::raiseWarning('', 'Not Found'); |
| 35 |
$app->redirect("index.php?option=com_vikbooking&task=rooms"); |
| 36 |
exit; |
| 37 |
} |
| 38 |
|
| 39 |
$q = "SELECT * FROM `#__vikbooking_orders` WHERE `id`=" . (int)$oid; |
| 40 |
$dbo->setQuery($q, 0, 1); |
| 41 |
$ord = $dbo->loadAssoc(); |
| 42 |
if (!$ord) { |
| 43 |
VikError::raiseWarning('', JText::translate('VBPEDITBUSYONE')); |
| 44 |
$app->redirect("index.php?option=com_vikbooking&task=rooms"); |
| 45 |
exit; |
| 46 |
} |
| 47 |
|
| 48 |
$q = "SELECT `or`.*,`r`.`name`,`r`.`img`,`r`.`idopt`,`r`.`fromadult`,`r`.`toadult`,`r`.`fromchild`,`r`.`tochild` FROM `#__vikbooking_ordersrooms` AS `or`,`#__vikbooking_rooms` AS `r` WHERE `or`.`idorder`=" . (int)$ord['id'] . " AND `or`.`idroom`=`r`.`id` ORDER BY `or`.`id` ASC;"; |
| 49 |
$dbo->setQuery($q); |
| 50 |
$ordersrooms = $dbo->loadAssocList(); |
| 51 |
|
| 52 |
$q = "SELECT * FROM `#__vikbooking_rooms` ORDER BY `avail` DESC, `name` ASC;"; |
| 53 |
$dbo->setQuery($q); |
| 54 |
$all_rooms = $dbo->loadAssocList(); |
| 55 |
|
| 56 |
$cpin = VikBooking::getCPinIstance(); |
| 57 |
$customer = $cpin->getCustomerFromBooking($ord['id']); |
| 58 |
if ($customer && !empty($customer['country'])) { |
| 59 |
if (is_file(VBO_ADMIN_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'countries'.DIRECTORY_SEPARATOR.$customer['country'].'.png')) { |
| 60 |
$customer['country_img'] = '<img src="'.VBO_ADMIN_URI.'resources/countries/'.$customer['country'].'.png'.'" title="'.$customer['country'].'" class="vbo-country-flag vbo-country-flag-left"/>'; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
$this->ordersrooms = $ordersrooms; |
| 65 |
$this->ord = $ord; |
| 66 |
$this->all_rooms = $all_rooms; |
| 67 |
$this->customer = $customer; |
| 68 |
|
| 69 |
// Display the template |
| 70 |
parent::display($tpl); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Sets the toolbar |
| 75 |
*/ |
| 76 |
protected function addToolBar() |
| 77 |
{ |
| 78 |
JToolBarHelper::title(JText::translate('VBMAINEBUSYTITLE'), 'vikbooking'); |
| 79 |
$pfrominv = VikRequest::getInt('frominv', '', 'request'); |
| 80 |
if ($pfrominv > 0 && JFactory::getUser()->authorise('core.edit', 'com_vikbooking')) { |
| 81 |
JToolBarHelper::apply( 'updatebusydoinv', JText::translate('VBSAVEANDDOINV')); |
| 82 |
JToolBarHelper::spacer(); |
| 83 |
} |
| 84 |
if (JFactory::getUser()->authorise('core.edit', 'com_vikbooking')) { |
| 85 |
JToolBarHelper::apply( 'updatebusy', JText::translate('VBSAVE')); |
| 86 |
JToolBarHelper::spacer(); |
| 87 |
} |
| 88 |
if (JFactory::getUser()->authorise('core.delete', 'com_vikbooking')) { |
| 89 |
JToolBarHelper::custom( 'removebusy', 'delete', 'delete', JText::translate('VBMAINEBUSYDEL'), false, false); |
| 90 |
JToolBarHelper::spacer(); |
| 91 |
} |
| 92 |
$pgoto = VikRequest::getString('goto', '', 'request'); |
| 93 |
if ($pgoto == 'overv') { |
| 94 |
JToolBarHelper::custom( 'cancelbusy', 'back', 'back', JText::translate('VBOVIEWBOOKINGDET'), false, false); |
| 95 |
} |
| 96 |
if ($pgoto == 'tableaux') { |
| 97 |
JToolBarHelper::custom( 'canceltableaux', 'back', 'back', JText::translate('VBMENUTABLEAUX'), false, false); |
| 98 |
} |
| 99 |
JToolBarHelper::cancel( ($pgoto == 'overv' ? 'canceloverv' : 'cancelbusy'), JText::translate('VBBACK')); |
| 100 |
$pvcm = VikRequest::getInt('vcm', '', 'request'); |
| 101 |
if ($pvcm == 1) { |
| 102 |
JToolBarHelper::custom( 'cancelbusyvcm', 'back', 'back', JText::translate('VBBACKVCM'), false, false); |
| 103 |
} |
| 104 |
JToolBarHelper::spacer(); |
| 105 |
} |
| 106 |
} |
| 107 |
|