Example #1
0
 public static function ordermail($orderid)
 {
     $year = date('Y');
     $month = date('m');
     $day = date('d');
     $hour = date('H');
     $minute = date('i');
     $second = date('s');
     $apm = date('A');
     $bookingInfo = Booking::getBookingOrder($orderid);
     //获取BookingNo, CheckIn, CheckOut
     $BookingNo = $bookingInfo['BookingNo'];
     $CheckIn = $bookingInfo['checkin'];
     $CheckOut = $bookingInfo['checkout'];
     $hotelid = $bookingInfo['hotel_id'];
     $orderStatus = $bookingInfo['OrderStatusId'];
     //获取订单状态
     $paymentMethod = $bookingInfo['paymentMethod'];
     //获取支付方式
     $RoomType = RoomPlan::getRoomTypeListByOrderId($orderid);
     //获取RoomTypeList
     $userid = $bookingInfo['OrderUserId'];
     //获取AgentName, GuestName, to
     $userinfo = Member::getUserInfoById($userid);
     $GuestName = $userinfo['Name'];
     $to = $userinfo['Email'];
     $languageid = $userinfo['LanguageID'];
     $roleId = $userinfo['RoleID'];
     $iso = $userinfo['LanguageShortName'];
     $hotelinfo = HotelDetail::getHotelDescription($hotelid, $iso);
     $HotelName = $hotelinfo['HotelName'];
     $AgentName = '';
     if ($roleId == 2 || $roleId == 3) {
         $AgentName = $userinfo['CompanyName'];
     }
     $CustomerName = Member::getCustomerList($orderid);
     $CustomerName = $CustomerName[0]['CustomerFamilyName'] . ' ' . $CustomerName[0]['CustomerGivenName'];
     include_once substr(dirname(__FILE__), 0, -8) . '/config/mail.config.php';
     global $from, $message, $subject;
     $Url = "http://tas-agent.com/booking_order.php?booking=edit&oid=" . $orderid;
     $search = array('{#year}', '{#month}', '{#day}', '{#hour}', '{#minute}', '{#second}', '{#apm}', '{#Url}', '{#AgentName}', '{#BookingNo}', '{#HotelName}', '{#GuestName}', '{#CheckIn}', '{#CheckOut}', '{#RoomType}', '{#CustomerName}');
     $replace = array($year, $month, $day, $hour, $minute, $second, $apm, $Url, $AgentName, $BookingNo, $HotelName, $GuestName, $CheckIn, $CheckOut, $RoomType, $CustomerName);
     if ($orderStatus == 9 && $paymentMethod == 1) {
         $orderStatus = 3;
     }
     $headers = "From: {$from}" . "\r\n";
     $headers .= 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-Type: text/html; charset=utf-8' . "\r\n";
     if ($orderStatus == 3 && $paymentMethod == 1) {
         $msg = str_replace($search, $replace, $message[$orderStatus][4][$languageid]);
         $sub = str_replace('{#BookingNo}', $BookingNo, $subject[$orderStatus][4][$languageid]);
         if ($sub != '' && $msg != '') {
             //@mail($to, $sub, $msg, $headers);
             self::sendEmail($to, $sub, $msg);
             $msg = htmlentities($msg);
             $sql = 'insert into `HT_Mail`(MailTo, MailFrom, SubjectName, Body) value("' . $to . '", "' . $from . '", "' . $sub . '", "' . $msg . '")';
             Db::getInstance()->ExecuteS($sql);
         }
     } else {
         $msg = str_replace($search, $replace, $message[$orderStatus][3][$languageid]);
         $sub = str_replace('{#BookingNo}', $BookingNo, $subject[$orderStatus][3][$languageid]);
         if ($sub != '' && $msg != '') {
             //@mail($to, $sub, $msg, $headers);
             self::sendEmail($to, $sub, $msg);
             $msg = htmlentities($msg);
             $sql = 'insert into `HT_Mail`(MailTo, MailFrom, SubjectName, Body) value("' . $to . '", "' . $from . '", "' . $sub . '", "' . $msg . '")';
             Db::getInstance()->ExecuteS($sql);
         }
     }
     if ($orderStatus != 3) {
         global $toemail;
         $msg = str_replace($search, $replace, $message[$orderStatus][4][4]);
         $sub = str_replace('{#BookingNo}', $BookingNo, $subject[$orderStatus][4][4]);
         if ($sub != '' && $msg != '') {
             //@mail($toemail, $sub, $msg, $headers);
             self::sendEmail($toemail, $sub, $msg);
             $msg = htmlentities($msg);
             $sql = 'insert into `HT_Mail`(MailTo, MailFrom, SubjectName, Body) value("' . $toemail . '", "' . $from . '", "' . $sub . '", "' . $msg . '")';
             Db::getInstance()->ExecuteS($sql);
         }
     }
 }