Example #1
0
/**
 * Mail cancel booking to customer
 * Type = 0: Cancel o list don dat moi
 * Type = 1: Cancel o list da thanh cong
 */
function mail_cancel_booking($booking_id)
{
    global $footer_of_email;
    $email_reply = "*****@*****.**";
    global $table_hotel_description;
    global $var_domain;
    global $fs_path_domain;
    $lang_time_format = "d/m/Y";
    $db_select = new db_query("SELECT booking_hotel.*, hot_name, hot_email, hot_address, hot_phone\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM booking_hotel\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t STRAIGHT_JOIN hotels ON(boo_hotel = hot_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t STRAIGHT_JOIN " . $table_hotel_description . " ON(boo_hotel = hot_hotel_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE boo_id = " . $booking_id);
    if ($booking_info = mysqli_fetch_assoc($db_select->result)) {
        //Thong tin dat phong
        $content_booking = '<table width="100%" cellspacing="0" cellpadding="1" style="border: 2px solid #C8D6FF; padding: 10px;" border="0">';
        $content_booking .= '<tr>';
        $content_booking .= '<td colspan="2"><h3 style="color: #FD7000; margin-top: 5px; border-bottom: 2px solid #C8D6FF; padding-bottom: 5px;">' . translate("Thông tin đặt phòng") . '</h3></td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Họ tên") . ':</td>';
        $content_booking .= '<td><b>' . $booking_info["boo_customer_name"] . '</b></td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Địa chỉ") . ':</td>';
        $content_booking .= '<td>' . $booking_info["boo_customer_address"] . '</td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Điện thoại") . ':</td>';
        $content_booking .= '<td>' . $booking_info["boo_customer_phone"] . '</td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Email") . ':</td>';
        $content_booking .= '<td>' . $booking_info["boo_customer_email"] . '</td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Khách sạn") . ':</td>';
        $content_booking .= '<td><a style="font-weight: bold;" href="' . $fs_path_domain . url_hotel_detail(array('hot_id' => $booking_info['boo_hotel'], 'hot_name' => $booking_info['hot_name'])) . '">' . $booking_info["hot_name"] . '</a></td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Địa chỉ") . ':</td>';
        $content_booking .= '<td>' . $booking_info["hot_address"] . '</td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Thông tin phòng") . ':</td>';
        $content_booking .= '<td>';
        //decode thong tin dat phong
        $array_room = json_decode($booking_info['boo_book_info'], true);
        if (count($array_room) > 0) {
            $style = ' style="border-color: #AAAAAA;"';
            $content_booking .= '<table border="1" cellpadding="3" cellspacing="2" bordercolor="#E2E2E2" style="border-collapse: collapse; margin: 10px 0px; border-color: #AAAAAA;">';
            foreach ($array_room as $rom_id => $info) {
                if (isset($info['numroom']) && isset($info['adults']) && isset($info['children']) && isset($info['money']) && isset($info['extra'])) {
                    $db_select = new db_query("SELECT rom_id, rom_name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM rooms\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE rom_id = " . intval($rom_id));
                    if ($row = mysqli_fetch_assoc($db_select->result)) {
                        $content_booking .= '<tr>
																 <td rowspan="4" width="120" align="center"' . $style . '><b>' . $row['rom_name'] . '</b></td>
																 <td' . $style . '>' . translate("Số lượng") . '</td>
																 <td' . $style . '><b>' . $info['numroom'] . '</b></td>
															</tr>
															<tr>
																 <td' . $style . '>' . translate("Số người") . '</td>
																 <td' . $style . '><b>' . $info['adults'] . '</b> ' . translate("người lớn") . ', <b>' . $info['children'] . '</b> ' . translate("trẻ em") . '</td>
															</tr>
															<tr>
																 <td' . $style . '>' . translate("Số tiền") . '</td>
																 <td' . $style . '><b style="color: #FF0000;">' . format_number($info['money']) . ' VNĐ</b></td>
															</tr>
															<tr>
																 <td' . $style . '>' . translate("Thêm giường") . '</td>
																 <td' . $style . '>
																		<p style="margin: 0;">' . ($info['extra'] == 0 ? '<b>' . translate("Không") . '</b>' : '<b>' . $info['extra'] . '</b> ' . translate("giường") . '') . '</p>
																 </td>
															</tr>';
                    }
                    unset($db_select);
                }
            }
            $content_booking .= '</table>';
        }
        $content_booking .= '</td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Ngày nhận phòng") . ':</td>';
        $content_booking .= '<td>' . date($lang_time_format, $booking_info["boo_time_start"]) . '</td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Ngày trả phòng") . ':</td>';
        $content_booking .= '<td>' . date($lang_time_format, $booking_info["boo_time_finish"]) . '</td>';
        $content_booking .= '</tr>';
        $content_booking .= '<tr>';
        $content_booking .= '<td>' . translate("Yêu cầu riêng") . ':</td>';
        $content_booking .= '<td>' . $booking_info["boo_customer_comment"] . '</td>';
        $content_booking .= '</tr>';
        $content_booking .= '</table>';
        //Gui cho KH
        $content = '<div style="border:3px double #94C7FF; padding: 10px; line-height: 19px; color: #444444">
												<p>Thân gửi Quý khách ' . $booking_info['boo_customer_name'] . ',</p>
												<p>Cảm ơn Quý khách đã đặt phòng trên website Mytour</p>';
        //Noi dung gui Mail cho KS
        $content_hotel = '<div style="border:3px double #94C7FF; padding: 10px; line-height: 19px; color: #444444">
																<p>Thân gửi Quý khách sạn ' . $booking_info['hot_name'] . ',</p>';
        //Neu don phongn chua duco duyet
        if ($booking_info['boo_view'] != 3) {
            $content .= '<p>
														Chúng tôi rất tiếc phải thông báo rằng thời gian từ ' . date("d/m/Y", $booking_info['boo_time_start']) . ' đến ' . date("d/m/Y", $booking_info['boo_time_finish']) . '
														không còn phòng trống nào tại khách sạn ' . $booking_info['hot_name'] . '.
												</p>';
        } else {
            //Neu don phong da duoc check thanh cong
            $content .= '<p>
														Mytour xin thông báo đơn phòng mã ' . $booking_info['boo_bill_code'] . ' có các thông tin đặt phòng như dưới đây đã bị hủy.
												Voucher Mytour đã gửi cho Khách hàng và Khách sạn hiện không còn giá trị sử dụng.
												</p>';
            $content_hotel .= '<p>
																Mytour xin thông báo khách hàng đã hủy đơn phòng có mã ' . $booking_info['boo_bill_code'] . ' với các thông tin đặt phòng chi tiết dưới đây.
													 Voucher Mytour đã gửi cho Khách hàng và Khách sạn hiện không còn giá trị sử dụng.
														</p>';
            $content .= $content_booking;
            $content_hotel .= $content_booking;
        }
        $content .= '<p>
														Hi vọng rằng Mytour có thể hỗ trợ Quý khách vào một dịp khác trong tương lai.
												</p>
										 <p>Chân thành cảm ơn Quý khách!</p>
												' . $footer_of_email . '
										</div>';
        $content_hotel .= $footer_of_email . '
														</div>';
        if ($booking_info['boo_view'] != 3) {
            if (send_mailer($booking_info['boo_customer_email'], "Thông báo hết phòng tại " . $booking_info['hot_name'] . " từ Mytour", $content, $email_reply, "Đặt phòng Mytour")) {
                return true;
            }
        } else {
            $check = 0;
            if (send_mailer($booking_info['boo_customer_email'], "Thông báo hủy đơn phòng tại " . $booking_info['hot_name'] . " từ Mytour", $content, $email_reply, "Đặt phòng Mytour")) {
                $check++;
            }
            if ($booking_info['hot_email'] != "" && send_mailer($booking_info['hot_email'], "Thông báo hủy đơn phòng từ Mytour", $content_hotel, $email_reply, "Đặt phòng Mytour")) {
                $check++;
            }
            if ($check > 0) {
                return true;
            }
        }
    }
    return false;
}
Example #2
0
function mail_cancel_booking($kk)
{
    global $ll;
    $bbb = "*****@*****.**";
    global $oo;
    global $pp;
    global $zz;
    $mm = "d/m/Y";
    $yy = new db_query("SELECT booking_hotel.*, hot_name, hot_email, hot_address, hot_phone\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM booking_hotel\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t STRAIGHT_JOIN hotels ON(boo_hotel = hot_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t STRAIGHT_JOIN " . $oo . " ON(boo_hotel = hot_hotel_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE boo_id = " . $kk);
    if ($rr = mysqli_fetch_assoc($yy->result)) {
        $jjj = '<table width="100%" cellspacing="0" cellpadding="1" style="border: 2px solid #C8D6FF; padding: 10px;" border="0">';
        $jjj .= '<tr>';
        $jjj .= '<td colspan="2"><h3 style="color: #FD7000; margin-top: 5px; border-bottom: 2px solid #C8D6FF; padding-bottom: 5px;">' . translate("Thông tin &#273;&#7863;t phòng") . '</h3></td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("H&#7885; tên") . ':</td>';
        $jjj .= '<td><b>' . $rr["boo_customer_name"] . '</b></td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("&#272;&#7883;a ch&#7881;") . ':</td>';
        $jjj .= '<td>' . $rr["boo_customer_address"] . '</td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("&#272;i&#7879;n tho&#7841;i") . ':</td>';
        $jjj .= '<td>' . $rr["boo_customer_phone"] . '</td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("Email") . ':</td>';
        $jjj .= '<td>' . $rr["boo_customer_email"] . '</td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("Khách s&#7841;n") . ':</td>';
        $jjj .= '<td><a style="font-weight: bold;" href="' . $zz . url_hotel_detail(array('hot_id' => $rr['boo_hotel'], 'hot_name' => $rr['hot_name'])) . '">' . $rr["hot_name"] . '</a></td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("&#272;&#7883;a ch&#7881;") . ':</td>';
        $jjj .= '<td>' . $rr["hot_address"] . '</td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("Thông tin phòng") . ':</td>';
        $jjj .= '<td>';
        $uu = json_decode($rr['boo_book_info'], true);
        if (count($uu) > 0) {
            $vv = ' style="border-color: #AAAAAA;"';
            $jjj .= '<table border="1" cellpadding="3" cellspacing="2" bordercolor="#E2E2E2" style="border-collapse: collapse; margin: 10px 0px; border-color: #AAAAAA;">';
            foreach ($uu as $ww => $xx) {
                if (isset($xx['numroom']) && isset($xx['adults']) && isset($xx['children']) && isset($xx['money']) && isset($xx['extra'])) {
                    $yy = new db_query("SELECT rom_id, rom_name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM rooms\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE rom_id = " . intval($ww));
                    if ($tt = mysqli_fetch_assoc($yy->result)) {
                        $jjj .= '<tr>
																 <td rowspan="4" width="120" align="center"' . $vv . '><b>' . $tt['rom_name'] . '</b></td>
																 <td' . $vv . '>' . translate("S&#7889; l&#432;&#7907;ng") . '</td>
																 <td' . $vv . '><b>' . $xx['numroom'] . '</b></td>
															</tr>
															<tr>
																 <td' . $vv . '>' . translate("S&#7889; ng&#432;&#7901;i") . '</td>
																 <td' . $vv . '><b>' . $xx['adults'] . '</b> ' . translate("ng&#432;&#7901;i l&#7899;n") . ', <b>' . $xx['children'] . '</b> ' . translate("tr&#7867; em") . '</td>
															</tr>
															<tr>
																 <td' . $vv . '>' . translate("S&#7889; ti&#7873;n") . '</td>
																 <td' . $vv . '><b style="color: #FF0000;">' . format_number($xx['money']) . ' VN&#272;</b></td>
															</tr>
															<tr>
																 <td' . $vv . '>' . translate("Thêm gi&#432;&#7901;ng") . '</td>
																 <td' . $vv . '>
																		<p style="margin: 0;">' . ($xx['extra'] == 0 ? '<b>' . translate("Không") . '</b>' : '<b>' . $xx['extra'] . '</b> ' . translate("gi&#432;&#7901;ng") . '') . '</p>
																 </td>
															</tr>';
                    }
                    unset($yy);
                }
            }
            $jjj .= '</table>';
        }
        $jjj .= '</td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("Ngày nh&#7853;n phòng") . ':</td>';
        $jjj .= '<td>' . date($mm, $rr["boo_time_start"]) . '</td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("Ngày tr&#7843; phòng") . ':</td>';
        $jjj .= '<td>' . date($mm, $rr["boo_time_finish"]) . '</td>';
        $jjj .= '</tr>';
        $jjj .= '<tr>';
        $jjj .= '<td>' . translate("Yêu c&#7847;u riêng") . ':</td>';
        $jjj .= '<td>' . $rr["boo_customer_comment"] . '</td>';
        $jjj .= '</tr>';
        $jjj .= '</table>';
        $c = '<div style="border:3px double #94C7FF; padding: 10px; line-height: 19px; color: #444444">
												<p>Thân g&#7917;i Quý khách ' . $rr['boo_customer_name'] . ',</p>
												<p>C&#7843;m &#417;n Quý khách &#273;ã &#273;&#7863;t phòng trên website Mytour</p>';
        $kkk = '<div style="border:3px double #94C7FF; padding: 10px; line-height: 19px; color: #444444">
																<p>Thân g&#7917;i Quý khách s&#7841;n ' . $rr['hot_name'] . ',</p>';
        if ($rr['boo_view'] != 3) {
            $c .= '<p>
														Chúng tôi r&#7845;t ti&#7871;c ph&#7843;i thông báo r&#7857;ng th&#7901;i gian t&#7915; ' . date("d/m/Y", $rr['boo_time_start']) . ' &#273;&#7871;n ' . date("d/m/Y", $rr['boo_time_finish']) . '
														không còn phòng tr&#7889;ng nào t&#7841;i khách s&#7841;n ' . $rr['hot_name'] . '.
												</p>';
        } else {
            $c .= '<p>
														Mytour xin thông báo &#273;&#417;n phòng mã ' . $rr['boo_bill_code'] . ' có các thông tin &#273;&#7863;t phòng nh&#432; d&#432;&#7899;i &#273;ây &#273;ã b&#7883; h&#7911;y.
												Voucher Mytour &#273;ã g&#7917;i cho Khách hàng và Khách s&#7841;n hi&#7879;n không còn giá tr&#7883; s&#7917; d&#7909;ng.
												</p>';
            $kkk .= '<p>
																Mytour xin thông báo khách hàng &#273;ã h&#7911;y &#273;&#417;n phòng có mã ' . $rr['boo_bill_code'] . ' v&#7899;i các thông tin &#273;&#7863;t phòng chi ti&#7871;t d&#432;&#7899;i &#273;ây.
													 Voucher Mytour &#273;ã g&#7917;i cho Khách hàng và Khách s&#7841;n hi&#7879;n không còn giá tr&#7883; s&#7917; d&#7909;ng.
														</p>';
            $c .= $jjj;
            $kkk .= $jjj;
        }
        $c .= '<p>
														Hi v&#7885;ng r&#7857;ng Mytour có th&#7875; h&#7895; tr&#7907; Quý khách vào m&#7897;t d&#7883;p khác trong t&#432;&#417;ng lai.
												</p>
										 <p>Chân thành c&#7843;m &#417;n Quý khách!</p>
												' . $ll . '
										</div>';
        $kkk .= $ll . '
														</div>';
        if ($rr['boo_view'] != 3) {
            if (send_mailer($rr['boo_customer_email'], "Thông báo h&#7871;t phòng t&#7841;i " . $rr['hot_name'] . " t&#7915; Mytour", $c, $bbb, "&#272;&#7863;t phòng Mytour")) {
                return true;
            }
        } else {
            $lll = 0;
            if (send_mailer($rr['boo_customer_email'], "Thông báo h&#7911;y &#273;&#417;n phòng t&#7841;i " . $rr['hot_name'] . " t&#7915; Mytour", $c, $bbb, "&#272;&#7863;t phòng Mytour")) {
                $lll++;
            }
            if ($rr['hot_email'] != "" && send_mailer($rr['hot_email'], "Thông báo h&#7911;y &#273;&#417;n phòng t&#7915; Mytour", $kkk, $bbb, "&#272;&#7863;t phòng Mytour")) {
                $lll++;
            }
            if ($lll > 0) {
                return true;
            }
        }
    }
    return false;
}