| @@ -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 | } |