| 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 VikBookingViewManagestate extends JViewVikBooking |
| 17 |
{ |
| 18 |
public function display($tpl = null) |
| 19 |
{ |
| 20 |
// Set the toolbar |
| 21 |
$this->addToolBar(); |
| 22 |
|
| 23 |
$dbo = JFactory::getDbo(); |
| 24 |
$app = JFactory::getApplication(); |
| 25 |
|
| 26 |
$id = VikRequest::getInt('id', 0); |
| 27 |
|
| 28 |
$row = []; |
| 29 |
if (!empty($id)) { |
| 30 |
$q = "SELECT * FROM `#__vikbooking_states` WHERE `id`=" . $id; |
| 31 |
$dbo->setQuery($q); |
| 32 |
$dbo->execute(); |
| 33 |
if (!$dbo->getNumRows()) { |
| 34 |
$app->enqueueMessage(JText::translate('JGLOBAL_NO_MATCHING_RESULTS'), 'error'); |
| 35 |
$this->cancel(); |
| 36 |
$app->close(); |
| 37 |
} |
| 38 |
$row = $dbo->loadAssoc(); |
| 39 |
} |
| 40 |
|
| 41 |
$countries = VikBooking::getCountriesArray($tn = true, $no_id = false); |
| 42 |
|
| 43 |
$this->row = $row; |
| 44 |
$this->countries = $countries; |
| 45 |
|
| 46 |
// Display the template |
| 47 |
parent::display($tpl); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Sets the toolbar |
| 52 |
*/ |
| 53 |
protected function addToolBar() { |
| 54 |
$id = VikRequest::getInt('id', 0); |
| 55 |
|
| 56 |
if (!empty($id)) { |
| 57 |
// edit |
| 58 |
JToolBarHelper::title(JText::translate('VBMAINSTATESTITLE') . ' - ' . JText::translate('VBMAINPAYMENTSEDIT'), 'vikbooking'); |
| 59 |
if (JFactory::getUser()->authorise('core.edit', 'com_vikbooking')) { |
| 60 |
JToolBarHelper::apply('states.update_stay', JText::translate('VBSAVE')); |
| 61 |
JToolBarHelper::spacer(); |
| 62 |
JToolBarHelper::save('states.update', JText::translate('VBSAVECLOSE')); |
| 63 |
JToolBarHelper::spacer(); |
| 64 |
} |
| 65 |
JToolBarHelper::cancel('states.cancel', JText::translate('VBANNULLA')); |
| 66 |
JToolBarHelper::spacer(); |
| 67 |
} else { |
| 68 |
// new |
| 69 |
JToolBarHelper::title(JText::translate('VBMAINSTATESTITLE') . ' - ' . JText::translate('VBMAINPAYMENTSNEW'), 'vikbooking'); |
| 70 |
if (JFactory::getUser()->authorise('core.create', 'com_vikbooking')) { |
| 71 |
JToolBarHelper::save('states.save', JText::translate('VBSAVE')); |
| 72 |
JToolBarHelper::spacer(); |
| 73 |
} |
| 74 |
JToolBarHelper::cancel('states.cancel', JText::translate('VBANNULLA')); |
| 75 |
JToolBarHelper::spacer(); |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
|