PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | admin/controllers/report.php +95 -6 1.7.1 → 1.8.16 View file →
@@ -43,17 +43,14 @@
43 43
44 44 // fetch the report form settings
45 45 $layout_data = [
46 46 'report' => $report,
47 - 'fields' => $report_obj->getSettingFields(),
47 + 'fields' => $report_obj->getProfileSettingFields(),
48 48 'settings' => $report_obj->loadSettings(),
49 49 'instance' => $report_obj,
50 50 ];
51 51
52 - $form_html = JLayoutHelper::render('reports.report.settings', $layout_data, null, [
53 - 'component' => 'com_vikbooking',
54 - 'client' => 'administrator',
55 - ]);
52 + $form_html = JLayoutHelper::render('reports.report.settings', $layout_data);
56 53
57 54 // send the response to output
58 55 VBOHttpDocument::getInstance($app)->json([
59 56 'html' => $form_html,
@@ -76,8 +73,11 @@
76 73
77 74 $report = $app->input->getString('report', '');
78 75 $data = $app->input->get('data', [], 'array');
79 76
77 + $profile = $app->input->getString('_profile', '');
78 + $profile_name = $app->input->getString('_newprofile', '');
79 +
80 80 $report_obj = VikBooking::getReportInstance($report);
81 81
82 82 if (!$report_obj) {
83 83 // invalid report requested
@@ -83,13 +83,35 @@
83 83 // invalid report requested
84 84 VBOHttpDocument::getInstance($app)->close(404, sprintf('Could not find the report [%s] to save the settings for.', $report));
85 85 }
86 86
87 - $report_obj->saveSettings($data, $merge = true);
87 + // check for settings profile identifier
88 + $use_profile_id = null;
89 + if ($report_obj->allowsProfileSettings() && !empty($profile)) {
90 + if ($profile == '_new' && empty($profile_name)) {
91 + VBOHttpDocument::getInstance($app)->close(500, 'Please specify the name for the new settings profile.');
92 + }
88 93
94 + // set active profile
95 + $use_profile_id = $profile;
96 +
97 + if (!empty($profile_name)) {
98 + // add the new profile
99 + list($use_profile_id, $profile_name) = $report_obj->setSettingProfile($profile_name);
100 + }
101 +
102 + // update active profile
103 + $report_obj->setActiveProfile($use_profile_id);
104 + }
105 +
106 + // save report settings
107 + $report_obj->saveSettings($data, $merge = true, (string) $use_profile_id);
108 +
89 109 // send the response to output
90 110 VBOHttpDocument::getInstance($app)->json([
91 111 'success' => 1,
112 + 'profiles' => $report_obj->getSettingProfiles(),
113 + 'active_profile' => $use_profile_id,
92 114 ]);
93 115 }
94 116
95 117 /**
@@ -132,6 +154,73 @@
132 154 }
133 155
134 156 // send the response to output
135 157 VBOHttpDocument::getInstance($app)->json($result);
158 + }
159 +
160 + /**
161 + * AJAX endpoint to set the report active profile settings identifier.
162 + *
163 + * @return void
164 + *
165 + * @since 1.17.7 (J) - 1.7.7 (WP)
166 + */
167 + public function setActiveProfile()
168 + {
169 + $app = JFactory::getApplication();
170 +
171 + if (!JSession::checkToken()) {
172 + // missing CSRF-proof token
173 + VBOHttpDocument::getInstance($app)->close(403, JText::translate('JINVALID_TOKEN'));
174 + }
175 +
176 + $report = $app->input->getString('report_file', '');
177 + $profile = $app->input->getString('report_profile', '');
178 +
179 + $report_obj = VikBooking::getReportInstance($report);
180 +
181 + if (!$report_obj) {
182 + // invalid report requested
183 + VBOHttpDocument::getInstance($app)->close(404, sprintf('Could not find the report [%s].', $report));
184 + }
185 +
186 + $report_obj->setActiveProfile($profile);
187 +
188 + // send response to output
189 + VBOHttpDocument::getInstance($app)->json([
190 + 'profile' => $profile,
191 + ]);
192 + }
193 +
194 + /**
195 + * AJAX endpoint to clear all report profile settings.
196 + *
197 + * @return void
198 + *
199 + * @since 1.17.7 (J) - 1.7.7 (WP)
200 + */
201 + public function clearProfiles()
202 + {
203 + $app = JFactory::getApplication();
204 +
205 + if (!JSession::checkToken()) {
206 + // missing CSRF-proof token
207 + VBOHttpDocument::getInstance($app)->close(403, JText::translate('JINVALID_TOKEN'));
208 + }
209 +
210 + $report = $app->input->getString('report_file', '');
211 +
212 + $report_obj = VikBooking::getReportInstance($report);
213 +
214 + if (!$report_obj) {
215 + // invalid report requested
216 + VBOHttpDocument::getInstance($app)->close(404, sprintf('Could not find the report [%s].', $report));
217 + }
218 +
219 + $report_obj->clearProfiles();
220 +
221 + // send response to output
222 + VBOHttpDocument::getInstance($app)->json([
223 + 'success' => true,
224 + ]);
136 225 }
137 226 }