public function bookATable() { $merchant_id = isset($this->data['merchant-id']) ? $this->data['merchant-id'] : ''; $full_booking_time = $this->data['date_booking'] . " " . $this->data['booking_time']; $full_booking_day = strtolower(date("D", strtotime($full_booking_time))); $booking_time = date('h:i A', strtotime($full_booking_time)); if (!Yii::app()->functions->isMerchantOpenTimes($merchant_id, $full_booking_day, $booking_time)) { $this->msg = t("Sorry but we are closed on" . " " . date("F,d Y h:ia", strtotime($full_booking_time))) . "<br/>" . t("Please check merchant opening hours"); return; } $now = isset($this->data['date_booking']) ? $this->data['date_booking'] : ''; $merchant_close_msg_holiday = ''; $is_holiday = false; if ($m_holiday = Yii::app()->functions->getMerchantHoliday($merchant_id)) { if (in_array($now, (array) $m_holiday)) { $is_holiday = true; } } if ($is_holiday == true) { $merchant_close_msg_holiday = !empty($merchant_close_msg_holiday) ? $merchant_close_msg_holiday : t("Sorry but we are on holiday on") . " " . date("F d Y", strtotime($now)); $this->msg = $merchant_close_msg_holiday; return; } $fully_booked_msg = Yii::app()->functions->getOption("fully_booked_msg", $merchant_id); if (!Yii::app()->functions->bookedAvailable($merchant_id)) { if (!empty($fully_booked_msg)) { $this->msg = t($fully_booked_msg); } else { $this->msg = t("Sorry we are fully booked for that day"); } return; } $db_ext = new DbExt(); $params = array('merchant_id' => isset($this->data['merchant-id']) ? $this->data['merchant-id'] : '', 'number_guest' => isset($this->data['number_guest']) ? $this->data['number_guest'] : '', 'date_booking' => isset($this->data['date_booking']) ? $this->data['date_booking'] : '', 'booking_time' => isset($this->data['booking_time']) ? $this->data['booking_time'] : '', 'booking_name' => isset($this->data['booking_name']) ? $this->data['booking_name'] : '', 'email' => isset($this->data['email']) ? $this->data['email'] : '', 'mobile' => isset($this->data['mobile']) ? $this->data['mobile'] : '', 'booking_notes' => isset($this->data['booking_notes']) ? $this->data['booking_notes'] : '', 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR']); $merchant_booking_receiver = Yii::app()->functions->getOption("merchant_booking_receiver", $merchant_id); $merchant_booking_tpl = Yii::app()->functions->getOption("merchant_booking_tpl", $merchant_id); if (empty($merchant_booking_tpl)) { $merchant_booking_tpl = EmailTPL::bookingTPL(); } $merchant_booking_receive_subject = Yii::app()->functions->getOption("merchant_booking_receive_subject", $merchant_id); $sender = 'no-reply@' . $_SERVER['HTTP_HOST']; if (!($merchant_info = Yii::app()->functions->getMerchant($merchant_id))) { $merchant_info['restaurant_name'] = t("None"); } $h = ''; $h .= '<table border="0">'; $h .= '<tr>'; $h .= '<td>' . Yii::t("default", "Restaurant name") . '</td>'; $h .= '<td>: ' . ucwords($merchant_info['restaurant_name']) . '</td>'; $h .= '</tr>'; $h .= '<tr>'; $h .= '<td>' . Yii::t("default", "Number Of Guests") . '</td>'; $h .= '<td>: ' . $params['number_guest'] . '</td>'; $h .= '</tr>'; $h .= '<tr>'; $h .= '<td>' . Yii::t("default", "Date Of Booking") . '</td>'; $h .= '<td>: ' . $params['date_booking'] . '</td>'; $h .= '</tr>'; $h .= '<tr>'; $h .= '<td>' . Yii::t("default", "Time") . '</td>'; $h .= '<td>: ' . $params['booking_time'] . '</td>'; $h .= '</tr>'; $h .= '<tr>'; $h .= '<td>' . Yii::t("default", "Name") . '</td>'; $h .= '<td>: ' . $params['booking_name'] . '</td>'; $h .= '</tr>'; $h .= '<tr>'; $h .= '<td>' . Yii::t("default", "Email") . '</td>'; $h .= '<td>: ' . $params['email'] . '</td>'; $h .= '</tr>'; $h .= '<tr>'; $h .= '<td>' . Yii::t("default", "Mobile") . '</td>'; $h .= '<td>: ' . $params['mobile'] . '</td>'; $h .= '</tr>'; $h .= '<tr>'; $h .= '<td>' . Yii::t("default", "Message") . '</td>'; $h .= '<td>: ' . $params['booking_notes'] . '</td>'; $h .= '</tr>'; $h .= '</table>'; $template = Yii::app()->functions->smarty("booking-information", $h, $merchant_booking_tpl); if ($db_ext->insertData('{{bookingtable}}', $params)) { $this->code = 1; $this->msg = Yii::t("default", "Thank you your booking has been received"); if (!empty($merchant_booking_receiver) && !empty($template)) { if (!sendEmail($merchant_booking_receiver, $sender, $merchant_booking_receive_subject, $template)) { } } } else { $this->msg = Yii::t("default", "Something went wrong during processing your request. Please try again later."); } }
$merchant_id = Yii::app()->functions->getMerchantID(); $merchant_booking_alert = Yii::app()->functions->getOption("merchant_booking_alert", $merchant_id); $tp1 = Yii::app()->functions->getOption("merchant_booking_approved_tpl", $merchant_id); $tp2 = Yii::app()->functions->getOption("merchant_booking_denied_tpl", $merchant_id); if (empty($tp1)) { $tp1 = EmailTPL::bookingApproved(); } if (empty($tp2)) { $tp2 = EmailTPL::bookingDenied(); } $subject = Yii::app()->functions->getOption("merchant_booking_subject", $merchant_id); $sender = Yii::app()->functions->getOption("merchant_booking_sender", $merchant_id); $merchant_booking_receiver = Yii::app()->functions->getOption("merchant_booking_receiver", $merchant_id); $merchant_booking_tpl = Yii::app()->functions->getOption("merchant_booking_tpl", $merchant_id); if (empty($merchant_booking_tpl)) { $merchant_booking_tpl = EmailTPL::bookingTPL(); } $merchant_booking_receive_subject = Yii::app()->functions->getOption("merchant_booking_receive_subject", $merchant_id); $days = Yii::app()->functions->getDays(); $max_booked = Yii::app()->functions->getOption("max_booked", $merchant_id); if (!empty($max_booked)) { $max_booked = json_decode($max_booked, true); } $fully_booked_msg = Yii::app()->functions->getOption("fully_booked_msg", $merchant_id); ?> <form class="uk-form uk-form-horizontal forms" id="forms"> <?php echo CHtml::hiddenField('action', 'bookingAlertSettings'); ?>