view.html.php
88 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | /** |
| 15 | * VikAppointments appointments export view. |
| 16 | * |
| 17 | * @since 1.1 |
| 18 | */ |
| 19 | class VikAppointmentsViewexportres extends JViewVAP |
| 20 | { |
| 21 | /** |
| 22 | * VikAppointments view display method. |
| 23 | * |
| 24 | * @return void |
| 25 | */ |
| 26 | function display($tpl = null) |
| 27 | { |
| 28 | $app = JFactory::getApplication(); |
| 29 | $input = $app->input; |
| 30 | $dbo = JFactory::getDbo(); |
| 31 | |
| 32 | // get type set in request |
| 33 | $data = new stdClass; |
| 34 | $data->type = $input->get('type', 'appointment', 'string'); |
| 35 | $data->cid = $input->get('cid', array(), 'uint'); |
| 36 | $data->fromdate = $input->get('fromdate', '', 'string'); |
| 37 | $data->todate = $input->get('todate', '', 'string'); |
| 38 | $data->id_employee = $input->get('id_employee', 0, 'uint'); |
| 39 | |
| 40 | // retrieve data from user state |
| 41 | $this->injectUserStateData($data, 'vap.exportres.data'); |
| 42 | |
| 43 | // set the toolbar |
| 44 | $this->addToolBar($data->type); |
| 45 | |
| 46 | VAPLoader::import('libraries.order.export.factory'); |
| 47 | |
| 48 | // get supported drivers |
| 49 | $drivers = VAPOrderExportFactory::getSupportedDrivers($data->type); |
| 50 | |
| 51 | $this->data = $data; |
| 52 | $this->drivers = $drivers; |
| 53 | |
| 54 | // display the template |
| 55 | parent::display($tpl); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Setting the toolbar. |
| 60 | * |
| 61 | * @param string $type The export type. |
| 62 | * |
| 63 | * @return void |
| 64 | */ |
| 65 | protected function addToolBar($type) |
| 66 | { |
| 67 | JToolBarHelper::title(JText::translate('VAPMAINTITLEEXPORTRES'), 'vikappointments'); |
| 68 | |
| 69 | switch ($type) |
| 70 | { |
| 71 | case 'appointment': |
| 72 | $rule = 'core.access.reservations'; |
| 73 | break; |
| 74 | |
| 75 | default: |
| 76 | $rule = 'core.admin'; |
| 77 | } |
| 78 | |
| 79 | if (JFactory::getUser()->authorise($rule, 'com_vikappointments')) |
| 80 | { |
| 81 | JToolbarHelper::custom('exportres.save', 'download', 'download', JText::translate('VAPDOWNLOAD'), false); |
| 82 | JToolbarHelper::divider(); |
| 83 | } |
| 84 | |
| 85 | JToolbarHelper::cancel('exportres.cancel'); |
| 86 | } |
| 87 | } |
| 88 |