calendarweek.php
2 days ago
cart.php
2 days ago
confirmapp.php
2 days ago
empattachser.php
2 days ago
empeditcoupon.php
2 days ago
empeditcustfield.php
2 days ago
empeditlocation.php
2 days ago
empeditpay.php
2 days ago
empeditprofile.php
2 days ago
empeditservice.php
2 days ago
empeditwdays.php
2 days ago
emplocwdays.php
2 days ago
emplogin.php
2 days ago
employeesearch.php
2 days ago
employeeslist.php
2 days ago
empmakerecur.php
2 days ago
empmanres.php
2 days ago
empsettings.php
2 days ago
empsubscr.php
2 days ago
empsubscrorder.php
2 days ago
index.html
2 days ago
modules.php
2 days ago
order.php
2 days ago
packages.php
2 days ago
packagesconfirm.php
2 days ago
packagesorder.php
2 days ago
servicesearch.php
2 days ago
subscriptions.php
2 days ago
subscrpayment.php
2 days ago
userprofile.php
2 days ago
waitinglist.php
2 days ago
emplocwdays.php
123 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 | VAPLoader::import('libraries.employee.area.controller'); |
| 15 | |
| 16 | /** |
| 17 | * Employee area edit working days - locations controller. |
| 18 | * |
| 19 | * @since 1.6 |
| 20 | */ |
| 21 | class VikAppointmentsControllerEmplocwdays extends VAPEmployeeAreaController |
| 22 | { |
| 23 | /** |
| 24 | * Task used to save the record data set in the request. |
| 25 | * After saving, the user is redirected to the main list. |
| 26 | * |
| 27 | * @return void |
| 28 | * |
| 29 | * @since 1.7 |
| 30 | */ |
| 31 | public function saveclose() |
| 32 | { |
| 33 | if ($this->save()) |
| 34 | { |
| 35 | $this->setRedirect('index.php?option=com_vikappointments&view=emplogin'); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Save employee working days - locations relationships. |
| 41 | * |
| 42 | * @return void |
| 43 | */ |
| 44 | public function save() |
| 45 | { |
| 46 | $app = JFactory::getApplication(); |
| 47 | $input = $app->input; |
| 48 | $auth = VAPEmployeeAuth::getInstance(); |
| 49 | |
| 50 | // always redirect to edit page |
| 51 | $this->cancel(); |
| 52 | |
| 53 | /** |
| 54 | * Added token validation. |
| 55 | * |
| 56 | * @since 1.7 |
| 57 | */ |
| 58 | if (!JSession::checkToken()) |
| 59 | { |
| 60 | // back to main list, missing CSRF-proof token |
| 61 | $app->enqueueMessage(JText::translate('JINVALID_TOKEN'), 'error'); |
| 62 | |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | // check user permissions |
| 67 | if (!$auth->manageWorkDays()) |
| 68 | { |
| 69 | // back to main list, not authorised to edit records |
| 70 | $app->enqueueMessage(JText::translate('JERROR_ALERTNOAUTHOR'), 'error'); |
| 71 | |
| 72 | return false; |
| 73 | } |
| 74 | |
| 75 | // get args |
| 76 | $args = array(); |
| 77 | $args['locations'] = $input->get('location', array(), 'array'); |
| 78 | |
| 79 | // get working day model |
| 80 | $model = $this->getModel(); |
| 81 | |
| 82 | // try to save arguments |
| 83 | $id = $model->save($args); |
| 84 | |
| 85 | if (!$id) |
| 86 | { |
| 87 | // get string error |
| 88 | $error = $model->getError(null, true); |
| 89 | |
| 90 | // display error message |
| 91 | $app->enqueueMessage(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $error), 'error'); |
| 92 | |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | // display generic successful message |
| 97 | $app->enqueueMessage(JText::translate('JLIB_APPLICATION_SAVE_SUCCESS')); |
| 98 | |
| 99 | return true; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Redirects the users to the main records list. |
| 104 | * |
| 105 | * @param array $query An array of query arguments. |
| 106 | * |
| 107 | * @return void |
| 108 | * |
| 109 | * @since 1.7 |
| 110 | */ |
| 111 | public function cancel(array $query = array()) |
| 112 | { |
| 113 | $url = 'index.php?option=com_vikappointments&view=emplocwdays'; |
| 114 | |
| 115 | if ($query) |
| 116 | { |
| 117 | $url .= '&' . http_build_query($query); |
| 118 | } |
| 119 | |
| 120 | $this->setRedirect($url); |
| 121 | } |
| 122 | } |
| 123 |