PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.20
VikAppointments Services Booking Calendar v1.2.20
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / controllers / emplocwdays.php
vikappointments / site / controllers Last commit date
calendarweek.php 1 month ago cart.php 1 month ago confirmapp.php 1 month ago empattachser.php 1 month ago empeditcoupon.php 1 month ago empeditcustfield.php 1 month ago empeditlocation.php 1 month ago empeditpay.php 1 month ago empeditprofile.php 1 month ago empeditservice.php 1 month ago empeditwdays.php 1 month ago emplocwdays.php 1 month ago emplogin.php 1 month ago employeesearch.php 1 month ago employeeslist.php 1 month ago empmakerecur.php 1 month ago empmanres.php 1 month ago empsettings.php 1 month ago empsubscr.php 1 month ago empsubscrorder.php 1 month ago index.html 1 month ago modules.php 1 month ago order.php 1 month ago packages.php 1 month ago packagesconfirm.php 1 month ago packagesorder.php 1 month ago servicesearch.php 1 month ago subscriptions.php 1 month ago subscrpayment.php 1 month ago userprofile.php 1 month ago waitinglist.php 1 month 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