| @@ -136,8 +136,9 @@ | ||
| 136 | 136 | $length = VikRequest::getInt('length', $this->reminders_per_page, 'request'); |
| 137 | 137 | $completed = VikRequest::getInt('completed', 0, 'request'); |
| 138 | 138 | $expired = VikRequest::getInt('expired', 0, 'request'); |
| 139 | 139 | $bid = VikRequest::getInt('bid', 0, 'request'); |
| 140 | + $reminder_id = VikRequest::getInt('reminder_id', 0, 'request'); | |
| 140 | 141 | $wrapper = VikRequest::getString('wrapper', '', 'request'); |
| 141 | 142 | |
| 142 | 143 | // load reminders starting from today at 00:00:00 |
| 143 | 144 | $now_info = getdate(); |
| @@ -160,8 +161,30 @@ | ||
| 160 | 161 | |
| 161 | 162 | // compose bookings base URI |
| 162 | 163 | $bookings_base_uri = VBOFactory::getPlatform()->getUri()->admin('index.php?option=com_vikbooking&task=editorder&cid[]=%d', $xhtml = false); |
| 163 | 164 | |
| 165 | + // check if a specific reminder ID was requested | |
| 166 | + if ($reminder_id) { | |
| 167 | + // check if the requested ID was found among the most recent ones | |
| 168 | + $reminder_found = false; | |
| 169 | + foreach ($reminders as $reminder) { | |
| 170 | + if ($reminder->id == $reminder_id) { | |
| 171 | + $reminder_found = true; | |
| 172 | + break; | |
| 173 | + } | |
| 174 | + } | |
| 175 | + | |
| 176 | + if (!$reminder_found) { | |
| 177 | + // fetch the record by ID | |
| 178 | + $reminder_record = $helper->getReminder($reminder_id); | |
| 179 | + | |
| 180 | + if ($reminder_record) { | |
| 181 | + // prepend element to the list | |
| 182 | + array_unshift($reminders, $reminder_record); | |
| 183 | + } | |
| 184 | + } | |
| 185 | + } | |
| 186 | + | |
| 164 | 187 | // start output buffering |
| 165 | 188 | ob_start(); |
| 166 | 189 | |
| 167 | 190 | if (!$reminders) { |
| @@ -300,8 +323,18 @@ | ||
| 300 | 323 | </div> |
| 301 | 324 | </div> |
| 302 | 325 | <?php |
| 303 | 326 | |
| 327 | + if ($reminder_id) { | |
| 328 | + ?> | |
| 329 | + <script type="text/javascript"> | |
| 330 | + setTimeout(() => { | |
| 331 | + vboWidgetRemindersEdit('<?php echo $wrapper; ?>', '<?php echo $reminder_id; ?>'); | |
| 332 | + }, 200); | |
| 333 | + </script> | |
| 334 | + <?php | |
| 335 | + } | |
| 336 | + | |
| 304 | 337 | // get the HTML buffer |
| 305 | 338 | $html_content = ob_get_contents(); |
| 306 | 339 | ob_end_clean(); |
| 307 | 340 | |
| @@ -486,13 +519,13 @@ | ||
| 486 | 519 | /** |
| 487 | 520 | * Main method to invoke the widget. Contents will be loaded |
| 488 | 521 | * through AJAX requests, not via PHP when the page loads. |
| 489 | 522 | * |
| 490 | - * @param VBOMultitaskData $data multitask data object. | |
| 523 | + * @param ?VBOMultitaskData $data multitask data object. | |
| 491 | 524 | * |
| 492 | 525 | * @return void |
| 493 | 526 | */ |
| 494 | - public function render(VBOMultitaskData $data = null) | |
| 527 | + public function render(?VBOMultitaskData $data = null) | |
| 495 | 528 | { |
| 496 | 529 | // increase widget's instance counter |
| 497 | 530 | static::$instance_counter++; |
| 498 | 531 | |
| @@ -503,8 +536,9 @@ | ||
| 503 | 536 | $wrapper_instance = !$is_ajax ? static::$instance_counter : rand(); |
| 504 | 537 | $wrapper_id = 'vbo-widget-reminders-' . $wrapper_instance; |
| 505 | 538 | |
| 506 | 539 | // default filters |
| 540 | + $reminder_id = 0; | |
| 507 | 541 | $def_completed = 0; |
| 508 | 542 | $def_expired = 0; |
| 509 | 543 | $def_duedate = time(); |
| 510 | 544 | $def_duehours = -1; |
| @@ -525,11 +559,12 @@ | ||
| 525 | 559 | // we allow the page booking ID to be passed as an option as well |
| 526 | 560 | $page_bid = !$page_bid ? $this->options()->fetchBookingId() : $page_bid; |
| 527 | 561 | |
| 528 | 562 | // check for options |
| 563 | + $reminder_id = (int) $this->getOption('reminder_id', 0); | |
| 529 | 564 | $auto_action = $this->getOption('action', ''); |
| 530 | - $def_completed = (int)$this->getOption('completed', $def_completed); | |
| 531 | - $def_expired = (int)$this->getOption('expired', $def_expired); | |
| 565 | + $def_completed = (int) $this->getOption('completed', $def_completed); | |
| 566 | + $def_expired = (int) $this->getOption('expired', $def_expired); | |
| 532 | 567 | |
| 533 | 568 | // attempt to define values for this precise booking |
| 534 | 569 | $booking_info = $page_bid ? VikBooking::getBookingInfoFromID($page_bid) : []; |
| 535 | 570 | if ($booking_info) { |
| @@ -1016,9 +1051,9 @@ | ||
| 1016 | 1051 | |
| 1017 | 1052 | /** |
| 1018 | 1053 | * Perform the request to load the reminders. |
| 1019 | 1054 | */ |
| 1020 | - function vboWidgetRemindersLoad(wrapper) { | |
| 1055 | + function vboWidgetRemindersLoad(wrapper, reminder_id) { | |
| 1021 | 1056 | var widget_instance = jQuery('#' + wrapper); |
| 1022 | 1057 | if (!widget_instance.length) { |
| 1023 | 1058 | return false; |
| 1024 | 1059 | } |
| @@ -1046,8 +1081,9 @@ | ||
| 1046 | 1081 | length: length_per_page, |
| 1047 | 1082 | completed: show_completed, |
| 1048 | 1083 | expired: show_expired, |
| 1049 | 1084 | bid: page_bid, |
| 1085 | + reminder_id: reminder_id, | |
| 1050 | 1086 | wrapper: wrapper, |
| 1051 | 1087 | tmpl: "component" |
| 1052 | 1088 | }, |
| 1053 | 1089 | (response) => { |
| @@ -1311,9 +1347,9 @@ | ||
| 1311 | 1347 | } |
| 1312 | 1348 | }); |
| 1313 | 1349 | |
| 1314 | 1350 | // when document is ready, load reminders for this widget's instance |
| 1315 | - vboWidgetRemindersLoad('<?php echo $wrapper_id; ?>'); | |
| 1351 | + vboWidgetRemindersLoad('<?php echo $wrapper_id; ?>', <?php echo $reminder_id; ?>); | |
| 1316 | 1352 | |
| 1317 | 1353 | // subscribe to the multitask-panel-close event to emit the event for the reminders changed |
| 1318 | 1354 | document.addEventListener(VBOCore.multitask_close_event, function() { |
| 1319 | 1355 | if (vbo_reminders_changed) { |