| @@ -1,0 +1,90 @@ | ||
| 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 VikBookingViewPrices extends JViewVikBooking | |
| 17 | +{ | |
| 18 | + public function display($tpl = null) | |
| 19 | + { | |
| 20 | + // Set the toolbar | |
| 21 | + $this->addToolBar(); | |
| 22 | + | |
| 23 | + $navbut = ""; | |
| 24 | + $app = JFactory::getApplication(); | |
| 25 | + $dbo = JFactory::getDbo(); | |
| 26 | + | |
| 27 | + // wizard | |
| 28 | + $wizard = VikRequest::getInt('wizard', 0, 'request'); | |
| 29 | + $rplanpub1 = VikRequest::getInt('rplanpub1', 0, 'request'); | |
| 30 | + $rplanpub2 = VikRequest::getInt('rplanpub2', 0, 'request'); | |
| 31 | + $rplanbk1 = VikRequest::getInt('rplanbk1', 0, 'request'); | |
| 32 | + $rplanbk2 = VikRequest::getInt('rplanbk2', 0, 'request'); | |
| 33 | + if ($wizard) { | |
| 34 | + if (!JSession::checkToken()) { | |
| 35 | + throw new Exception(JText::translate('JINVALID_TOKEN'), 403); | |
| 36 | + } | |
| 37 | + if ($rplanpub1) { | |
| 38 | + $q = "INSERT INTO `#__vikbooking_prices` (`name`, `idiva`, `breakfast_included`, `free_cancellation`, `minlos`) VALUES (" . $dbo->quote(JText::translate('VBOSTANDARDRATE')) . ", 0, $rplanbk1, 1, 0);"; | |
| 39 | + $dbo->setQuery($q); | |
| 40 | + $dbo->execute(); | |
| 41 | + } | |
| 42 | + if ($rplanpub2) { | |
| 43 | + $q = "INSERT INTO `#__vikbooking_prices` (`name`, `idiva`, `breakfast_included`, `free_cancellation`, `canc_deadline`, `minlos`) VALUES (" . $dbo->quote(JText::translate('VBONONREFRATE')) . ", 0, $rplanbk2, 0, 7, 0);"; | |
| 44 | + $dbo->setQuery($q); | |
| 45 | + $dbo->execute(); | |
| 46 | + } | |
| 47 | + $app->redirect('index.php?option=com_vikbooking&wizard=1'); | |
| 48 | + exit; | |
| 49 | + } | |
| 50 | + | |
| 51 | + $lim = $app->getUserStateFromRequest("com_vikbooking.limit", 'limit', $app->get('list_limit'), 'int'); | |
| 52 | + $lim0 = VikRequest::getVar('limitstart', 0, '', 'int'); | |
| 53 | + $q = "SELECT SQL_CALC_FOUND_ROWS * FROM `#__vikbooking_prices` ORDER BY `derived_id` ASC, `id` ASC"; | |
| 54 | + $dbo->setQuery($q, $lim0, $lim); | |
| 55 | + $rows = $dbo->loadAssocList(); | |
| 56 | + if ($rows) { | |
| 57 | + $dbo->setQuery('SELECT FOUND_ROWS();'); | |
| 58 | + jimport('joomla.html.pagination'); | |
| 59 | + $pageNav = new JPagination( $dbo->loadResult(), $lim0, $lim ); | |
| 60 | + $navbut="<table align=\"center\"><tr><td>".$pageNav->getListFooter()."</td></tr></table>"; | |
| 61 | + } | |
| 62 | + | |
| 63 | + $this->rows = $rows; | |
| 64 | + $this->lim0 = $lim0; | |
| 65 | + $this->navbut = $navbut; | |
| 66 | + | |
| 67 | + // Display the template | |
| 68 | + parent::display($tpl); | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Sets the toolbar | |
| 73 | + */ | |
| 74 | + protected function addToolBar() | |
| 75 | + { | |
| 76 | + JToolBarHelper::title(JText::translate('VBMAINPRICETITLE'), 'vikbooking'); | |
| 77 | + if (JFactory::getUser()->authorise('core.create', 'com_vikbooking')) { | |
| 78 | + JToolBarHelper::addNew('newprice', JText::translate('VBMAINPRICENEW')); | |
| 79 | + JToolBarHelper::spacer(); | |
| 80 | + } | |
| 81 | + if (JFactory::getUser()->authorise('core.edit', 'com_vikbooking')) { | |
| 82 | + JToolBarHelper::editList('editprice', JText::translate('VBMAINPRICEEDIT')); | |
| 83 | + JToolBarHelper::spacer(); | |
| 84 | + } | |
| 85 | + if (JFactory::getUser()->authorise('core.delete', 'com_vikbooking')) { | |
| 86 | + JToolBarHelper::deleteList(JText::translate('VBDELCONFIRM'), 'removeprice', JText::translate('VBMAINPRICEDEL')); | |
| 87 | + JToolBarHelper::spacer(); | |
| 88 | + } | |
| 89 | + } | |
| 90 | +} | |