本文整理匯總了PHP中Booking::insertNewBooking方法的典型用法代碼示例。如果您正苦於以下問題:PHP Booking::insertNewBooking方法的具體用法?PHP Booking::insertNewBooking怎麽用?PHP Booking::insertNewBooking使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Booking
的用法示例。
在下文中一共展示了Booking::insertNewBooking方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: preProcess
public function preProcess()
{
parent::preProcess();
// if (!Tools::hasFunction('room_plan_edit')) Tools::redirect('index.php');
if ($_GET['action'] == 'customer') {
$customer_info_list = array();
for ($i = 0; $i < $_GET['count']; $i++) {
// default value
$customer_info['customer_fnames'] = '';
$customer_info['customer_gnames'] = '';
$customer_info['customer_sex'] = 1;
// male
$customer_info['customer_country'] = 109;
// japan
$customer_info_list[] = $customer_info;
}
self::$smarty->assign("count", $_GET['count']);
self::$smarty->assign("id", $_GET['id']);
self::$smarty->assign("countries", Tools::getCountries());
self::$smarty->assign("customers", $customer_info_list);
self::$smarty->display(_TAS_THEME_DIR_ . 'booking_sub_customer.tpl');
exit;
}
if ($_POST['booking'] == 'edit') {
// check that user has privilege editing this order
$orderId = $_GET['oid'];
if ($orderId == '') {
return;
}
$error = Booking::checkUserCanEditOrder(self::$cookie->UserID, self::$cookie->RoleID, $orderId);
if ($error['no'] > 0) {
self::$smarty->assign("error", $error);
self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl');
exit;
}
}
$booking_info = array();
if ($_POST['booking'] == 'order') {
// new booking order rooms
$param_id_amounts = $_POST['plan_id_amount'];
// the array in formated [planid]_[count]
$_POST['ids'] = array();
// $_POST['roomplan_ids'] = array();
$id = 0;
foreach ($param_id_amounts as $id_amount) {
// $chars = preg_split('/_/', $param_plan_id); // split [room plan id]_[count]
$chars = explode("_", $id_amount);
$rpid = $chars[0];
for ($i = 0; $i < $chars[1]; $i++) {
$_POST['ids'][] = $id;
$_POST['or_ids_' . $id] = 0;
// new order roomplan
$_POST['roomplan_ids_' . $id] = $rpid;
$id++;
}
// $_POST['roomplan_counts_'.$rpid] = $chars[1];
}
$booking_info = Booking::buildBookingInfoFromPost(self::$cookie->CompanyID);
$booking_info['OrderUserId'] = self::$cookie->UserID;
//獲取用戶ID
$booking_info['paymentMethod'] = Member::getPaymentMethod(self::$cookie->CompanyID);
$order_id = Booking::insertNewBooking($booking_info);
$booking_info = Booking::getBookingInfo($order_id);
// echo 'order_id = '.$order_id;
// print_r($booking_info);
// print_r(self::$cookie->CompanyID);
self::$smarty->assign("language", "order");
self::$smarty->assign("method", "order");
} else {
$this->brandNavi[] = array("name" => "Booking List", "url" => 'booking_list.php');
// edit
$booking_info = Booking::getBookingInfo($_GET['oid']);
//print_r($booking_info);
if ($booking_info) {
$this->brandNavi[] = array("name" => "Booking No:" . $booking_info['BookingNo'], "url" => 'booking_order.php?booking=edit&oid=' . $booking_info['order_id'], "nolang" => 1);
}
if (!$booking_info) {
$booking_info = Booking::getBookingInfo_del($_GET['oid']);
$this->brandNavi[] = array("name" => "Booking No:" . $booking_info['BookingNo'], "url" => 'booking_order.php?booking=edit&oid=' . $booking_info['order_id'], "nolang" => 1);
if (!$booking_info) {
// redirect
Tools::redirect('index.php');
}
}
self::$smarty->assign("method", "edit");
}
self::$smarty->assign("booking_info", $booking_info);
// $this->booking_info = $booking_info;
// $roomtype_list = RoomPlan::getRoomTypeList();
//
}
示例2: process
//.........這裏部分代碼省略.........
self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl');
exit;
}
$checkin = $_POST['checkin'];
//獲取checkin的值
$checkout = $_POST['checkout'];
//獲取checkout的值
//獲取roomPlanId
$ids = $_POST['ids'];
$rpid_list = array();
foreach ($ids as $id) {
$rpid_list[] = $_POST['roomplan_ids_' . $id];
}
//計算房間數量是否滿足條件,如果有一條不滿足則發出錯誤報告
$roomplan_list = RoomPlan::getRoomPlanListForBooking($rpid_list, $checkin, $checkout);
$plan_list = array();
foreach ($roomplan_list as $record) {
$plan_list[$record['RoomPlanId']] = $record;
}
//查看是否有房間不滿足條件
$isOk = true;
foreach ($rpid_list as $rpid) {
if (empty($plan_list[$rpid])) {
$isOk = false;
break;
}
}
if (!$isOk) {
$error['message'] = "There is not any room as requested";
self::$smarty->assign("error", $error);
self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl');
exit;
}
$booking_info['paymentMethod'] = Member::getPaymentMethod(self::$cookie->CompanyID);
//獲取支付方式,是前支付還是後支付
$order_id = Booking::modifyBooking($booking_info);
if (empty($order_id)) {
$error['message'] = "修改失敗, 您修訂的房間信息不存在。";
self::$smarty->assign("error", $error);
self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl');
} else {
//下訂單成功,此時需要發送郵件
Tools::ordermail($order_id);
Tools::emailHotel($order_id, 11);
Tools::redirect('booking_list.php');
}
exit;
}
if ($_POST["booking"] == 'finish') {
// $_POST ["booking"] == 'save'
if ($booking_info['order_id'] == 0) {
$booking_info['OrderUserId'] = self::$cookie->UserID;
}
//獲取用戶ID
$booking_info['paymentMethod'] = Member::getPaymentMethod(self::$cookie->CompanyID);
$order_id = Booking::insertNewBooking($booking_info);
if ($order_id) {
$booking_info = Booking::getBookingInfo($order_id);
//下訂單成功,此時需要發送郵件
Tools::ordermail($order_id);
Tools::emailHotel($order_id, 10);
} else {
$error['message'] = "Booking has time out!";
self::$smarty->assign("error", $error);
self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl');
exit;
}
//$booking_info = Booking::getBookingInfo ( $order_id );
self::$smarty->assign("booking_info", $booking_info);
//if ($_POST ["booking"] == 'save')
// Tools::redirect ( 'booking_list.php' );
}
if ($_POST['booking'] == 'payment') {
//支付接口調用
$url = "http://localhost/payment.php";
//支付站點網址
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_exec($ch);
//$content =
$response = curl_getinfo($ch);
curl_close($ch);
if ($response['http_code'] == 200) {
//判斷是否支付成功,此處隻是模擬使用
Booking::changeBookingStatus($booking_info['order_id'], 4);
Booking::changePayStatus($booking_info['order_id'], 2);
Booking::payment($booking_info['order_id'], $_POST['money']);
//下訂單成功,此時需要發送郵件
Tools::ordermail($order_id);
} else {
//模擬支付失敗的情況
$error = array();
$error['message'] = 'sorroy charge fail';
self::$smarty->assign("error", $error);
self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl');
exit;
}
}
parent::process();
}