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/mail.php +20 -9 1.6.4 → 1.8.16 View file →
@@ -41,20 +41,26 @@
41 41 return $match[2];
42 42 }, $content);
43 43
44 44 // grab the latest confirmed reservation
45 - $clauses = [
46 - "`status`='confirmed'",
47 - "`closure`=0",
48 - ];
45 + $q = $dbo->getQuery(true)
46 + ->select('*')
47 + ->from($dbo->qn('#__vikbooking_orders'))
48 + ->where($dbo->qn('status') . ' = ' . $dbo->q('confirmed'))
49 + ->where($dbo->qn('closure') . ' = 0');
50 +
49 51 if (!empty($bid)) {
50 - $clauses[] = "`id`=" . $bid;
52 + $q->clear('where');
53 + $q->where($dbo->qn('id') . ' = ' . $bid);
51 54 }
52 - $q = "SELECT * FROM `#__vikbooking_orders` WHERE " . implode(' AND ', $clauses) . " ORDER BY `id` DESC";
55 +
56 + $q->order($dbo->qn('id') . ' DESC');
57 +
53 58 $dbo->setQuery($q, 0, 1);
54 - $dbo->execute();
55 - if ($dbo->getNumRows()) {
56 - $booking = $dbo->loadAssoc();
59 + $booking = $dbo->loadAssoc();
60 +
61 + $booking_rooms = [];
62 + if ($booking) {
57 63 $booking_rooms = VikBooking::loadOrdersRoomsData($booking['id']);
58 64 // inject properties for parsing the conditional text rules later
59 65 VikBooking::getConditionalRulesInstance()->set(['booking', 'rooms'], [$booking, $booking_rooms]);
60 66 }
@@ -71,8 +77,13 @@
71 77 ]);
72 78
73 79 // prepare the final email content
74 80 $mail_content = VBOFactory::getPlatform()->getMailer()->prepare($mail_data);
81 +
82 + if ($booking) {
83 + // apply a common replacement method for the special tags
84 + $mail_content = VBOMailParser::replaceSpecialTags($mail_content, $booking, $booking_rooms);
85 + }
75 86
76 87 // send JSON response to output
77 88 VBOHttpDocument::getInstance($app)->json([$mail_content]);
78 89 }