view.html.php
99 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 weekly calendar view. |
| 16 | * |
| 17 | * @since 1.6 |
| 18 | */ |
| 19 | class VikAppointmentsViewcaldays 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 view model |
| 33 | $model = JModelVAP::getInstance('caldays'); |
| 34 | |
| 35 | $filters = array(); |
| 36 | |
| 37 | $filters['layout'] = $input->getString('mode'); |
| 38 | |
| 39 | if ($filters['layout'] == 'day') |
| 40 | { |
| 41 | // do not cache date in the user state and avoid employee filter |
| 42 | $filters['date'] = $input->getString('date', ''); |
| 43 | $filters['employee'] = 0; |
| 44 | } |
| 45 | else |
| 46 | { |
| 47 | $filters['date'] = $app->getUserStateFromRequest('caldays.date', 'date', '', 'string'); |
| 48 | $filters['employee'] = $app->getUserStateFromRequest('caldays.employee', 'employee', 0, 'uint'); |
| 49 | } |
| 50 | |
| 51 | $filters['services'] = $input->get('services', array(), 'uint'); |
| 52 | |
| 53 | if ($input->getBool('employee_changed')) |
| 54 | { |
| 55 | // unset selected services every time the employee changes |
| 56 | $filters['services'] = array(); |
| 57 | } |
| 58 | |
| 59 | // register filters |
| 60 | $this->filters = $filters; |
| 61 | |
| 62 | // let the model prepares the calendar structure |
| 63 | $this->calendar = $model->getCalendar($filters); |
| 64 | |
| 65 | // register services |
| 66 | $this->services = $model->getServices($filters); |
| 67 | |
| 68 | // setup toolbar |
| 69 | $this->addToolBar(); |
| 70 | |
| 71 | // display the template |
| 72 | parent::display($tpl); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Setting the toolbar. |
| 77 | */ |
| 78 | protected function addToolBar() |
| 79 | { |
| 80 | // Add menu title and some buttons to the page |
| 81 | JToolBarHelper::title(JText::translate('VAPMAINTITLEVIEWCALENDAR'), 'vikappointments'); |
| 82 | |
| 83 | if ($this->filters['layout'] == 'day') |
| 84 | { |
| 85 | JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_vikappointments&view=caldays'); |
| 86 | } |
| 87 | |
| 88 | if (JFactory::getUser()->authorise('core.edit', 'com_vikappointments')) |
| 89 | { |
| 90 | if ($this->filters['employee']) |
| 91 | { |
| 92 | JToolBarHelper::custom('reportsemp', 'bars', 'bars', JText::translate('VAPREPORTS'), false); |
| 93 | } |
| 94 | |
| 95 | JToolBarHelper::divider(); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 |