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/helpers/src/reminders/helper.php +69 -0 1.6.5 → 1.8.16 View file →
@@ -337,8 +337,46 @@
337 337 return ($dbo->getAffectedRows() > 0);
338 338 }
339 339
340 340 /**
341 + * Searches for a reminder according to the provided criteria.
342 + *
343 + * @param array $criteria Associative list of data to look for.
344 + *
345 + * @return object|null
346 + *
347 + * @since 1.16.10 (J) - 1.6.10 (WP)
348 + */
349 + public function searchReminder(array $criteria)
350 + {
351 + if (!$criteria) {
352 + return null;
353 + }
354 +
355 + $dbo = JFactory::getDbo();
356 +
357 + $q = $dbo->getQuery(true)
358 + ->select('*')
359 + ->from($dbo->qn('#__vikbooking_reminders'));
360 +
361 + foreach ($criteria as $col => $val) {
362 + if (is_array($val) || is_object($val)) {
363 + $val = json_encode($val);
364 + }
365 +
366 + if (is_null($val)) {
367 + $q->where($dbo->qn($col) . ' IS NULL');
368 + } else {
369 + $q->where($dbo->qn($col) . ' = ' . $dbo->q($val));
370 + }
371 + }
372 +
373 + $dbo->setQuery($q);
374 +
375 + return $dbo->loadObject();
376 + }
377 +
378 + /**
341 379 * Removes the reminders with a due date in the past.
342 380 *
343 381 * @return void
344 382 */
@@ -517,6 +555,37 @@
517 555
518 556 $dbo->setQuery($q);
519 557
520 558 return $dbo->loadAssocList();
559 + }
560 +
561 + /**
562 + * Completes the reminder(s) of a specific booking with an optional payload type.
563 + *
564 + * @param int $booking_id The reservation ID to check.
565 + * @param array $payload Optional payload to compare.
566 + * @param int $lim Query update limit.
567 + *
568 + * @return bool
569 + *
570 + * @since 1.16.10 (J) - 1.6.10 (WP)
571 + */
572 + public function completeBookingReminders($booking_id, array $payload = [], $lim = 0)
573 + {
574 + $dbo = JFactory::getDbo();
575 +
576 + $q = $dbo->getQuery(true);
577 +
578 + $q->update($dbo->qn('#__vikbooking_reminders'))
579 + ->set($dbo->qn('completed') . ' = 1')
580 + ->where($dbo->qn('idorder') . ' = ' . (int) $booking_id);
581 +
582 + if ($payload) {
583 + $q->where($dbo->qn('payload') . ' = ' . $dbo->q(json_encode($payload)));
584 + }
585 +
586 + $dbo->setQuery($q, 0, $lim);
587 + $dbo->execute();
588 +
589 + return (bool) $dbo->getAffectedRows();
521 590 }
522 591 }