public function addProductRental($data) { $db = $this->getAdapter(); $db->beginTransaction(); try { $session = new Zend_Session_Namespace('stuffbooking'); $row = $session->products; $db_globle = new Application_Model_DbTable_DbGlobal(); $booking_code = $db_globle->getNewBookingCode(); $customer_session = new Zend_Session_Namespace('customer'); $customer_id = $customer_session->customer_id; $pickup_time = $session->pickup_time; $return_time = $session->return_time; $pickup_date = new DateTime($session->pickup_date); $return_date = new DateTime($session->return_date); $diff = date_diff(date_create($session->pickup_date), date_create($session->return_date)); $total_day = $diff->format("%a%") + 1; $total = 0; foreach ($row as $rs) { $total += $rs["pro_price"] * $rs["amount_rent"] * $total_day; } $arr = array('customer_id' => $customer_id, 'booking_no' => $booking_code, 'date_book' => new Zend_Date(), 'pickup_date' => $pickup_date->format('Y-m-d'), 'pickup_time' => $pickup_time, 'return_date' => $return_date->format('Y-m-d'), 'return_time' => $return_time, 'total_fee' => $total, 'total_paymented' => $total, 'item_type' => 4); if ($data["payment_type"] == 1) { $arr['visa_name'] = $data["card_name"]; $arr['card_id'] = $data["card_id"]; $arr['secu_code'] = $data["secu_code"]; $arr['card_exp_date'] = $data["card_exp_date"]; $arr['card_id'] = $data["card_id"]; $arr['payment_type'] = 1; $arr['status'] = 1; } elseif ($data["payment_type"] == 2) { $arr['card_id'] = $data["code_num"]; $arr['payment_type'] = 2; $arr['status'] = 2; } elseif ($data["payment_type"] == 3) { $arr['payment_type'] = 3; $arr['status'] = 2; } $this->_name = "ldc_booking"; $book_id = $this->insert($arr); foreach ($row as $rs) { $arr_deatail = array('book_id' => $book_id, 'item_id' => $rs["product_id"], 'item_name' => $rs["product_name"], 'rent_num' => $rs["amount_rent"], 'price' => $rs["pro_price"], 'total' => $total, 'total_paymented' => $total, 'status' => 1, 'item_type' => 3); $this->_name = "ldc_booking_detail"; $this->insert($arr_deatail); } $db->commit(); return $book_id; } catch (Exception $e) { $db->rollBack(); echo $e->getMessage(); } }
function addBooking($user_ip) { $db = $this->getAdapter(); $db->beginTransaction(); try { $row_booking = $this->getAllVisualBooking($user_ip, 1); $row_booking_detail = $this->getAllVisualBooking($user_ip, 2); $db_globle = new Application_Model_DbTable_DbGlobal(); $booking_code = $db_globle->getNewBookingCode(); $customer_session = new Zend_Session_Namespace('customer'); $customer_id = $customer_session->customer_id; $pickup_date = date_create($row_booking["pickup_date"]); $return_date = date_create($row_booking["return_date"]); $diff = date_diff($pickup_date, $return_date); $total_day = $diff->format("%a%") + 1; $total = 0; $total_payment = 0; $deposit = 0; $total_vat = 0; foreach ($row_booking_detail as $rs) { $total += $rs["price"] * $total_day; $total_vat += $rs["price"] * $total_day * $rs["VAT"] / 100; $deposit += $rs["deposite"]; } $arr_booking = array('customer_id' => $customer_id, 'booking_no' => $booking_code, 'pickup_location' => $row_booking["pickup_location"], 'dropoff_location' => $row_booking["dropoff_location"], 'date_book' => new Zend_Date(), 'pickup_date' => $row_booking["pickup_date"], 'pickup_time' => $row_booking["pickup_time"], 'return_date' => $row_booking["return_date"], 'return_time' => $row_booking["return_time"], 'total_fee' => $total, 'deposite_fee' => $deposit, 'total_vat' => $total_vat, 'total_paymented' => $deposit, 'status' => 1, 'visa_name' => $row_booking["visa_name"], 'card_id' => $row_booking["visa_number"], 'secu_code' => $row_booking["secu_code"], 'card_exp_date' => $row_booking["exp_date"], 'payment_type' => $row_booking["payment_type"], 'status' => $row_booking["status"], 'item_type' => 1, 'fly_no' => $row_booking["fly_no"], 'fly_date' => $row_booking["fly_date"], 'fly_time_of_arrival' => $row_booking["fly_time_of_arrival"], 'fly_destination' => $row_booking["fly_destination"]); $this->_name = "ldc_booking"; $book_id = $this->insert($arr_booking); // print_r($book_id);exit(); foreach ($row_booking_detail as $rs) { $arr_booking_detail = array('book_id' => $book_id, 'item_id' => $rs["item_id"], 'item_name' => $rs["item_name"], 'rent_num' => $rs["number_of_rent"], 'price' => $rs["price"], 'VAT' => $rs["VAT"], 'discount' => $rs["discount"], 'deposite' => $rs["deposite"], 'refund_deposit' => $rs["refund_deposit"], 'total' => $rs["total"], 'total_paymented' => $rs["deposite"], 'item_type' => $rs["item_type"], 'status' => 1); $this->_name = "ldc_booking_detail"; $this->insert($arr_booking_detail); } $sql = "DELETE FROM ldc_visurl_booking WHERE user_ip='{$user_ip}'"; $db->query($sql); $sqls = "DELETE FROM ldc_visurl_booking_detail WHERE user_id='{$user_ip}'"; $db->query($sqls); $db->commit(); return $book_id; } catch (Exception $e) { $db->rollBack(); echo $e->getMessage(); } }
function addCityTourBooking($data) { $db = $this->getAdapter(); $db->beginTransaction(); try { $session_user = new Zend_Session_Namespace('customer'); $user_id = $session_user->customer_id; $session = new Zend_Session_Namespace('bookcitytour'); $db_globle = new Application_Model_DbTable_DbGlobal(); $booking_code = $db_globle->getNewBookingCode(); $vehicle_fee = $session->price; $guide_fee = $session->guideprice; $total_fee = $vehicle_fee + $guide_fee; //$deposit = $total_fee*(30/100); $pickup_date = new DateTime($session->pickup_date); //$return_date = new DateTime($data["return_date"]); $arr = array('customer_id' => $user_id, 'booking_no' => $booking_code, 'package_id' => $session->package_id, 'date_book' => new Zend_Date(), 'pickup_date' => $pickup_date->format("Y-m-d"), 'pickup_time' => $session->pickup_time . ":" . $session->pickup_mins, 'total_fee' => $total_fee, 'total_paymented' => $total_fee, 'item_type' => 3); if ($data["payment_type"] == 1) { $arr['visa_name'] = $data["card_name"]; $arr['card_id'] = $data["card_id"]; $arr['secu_code'] = $data["secu_code"]; $arr['card_exp_date'] = $data["card_exp_date"]; $arr['card_id'] = $data["card_id"]; $arr['payment_type'] = 1; $arr['status'] = 1; } elseif ($data["payment_type"] == 2) { $arr['card_id'] = $data["code_num"]; $arr['payment_type'] = 2; $arr['status'] = 2; } elseif ($data["payment_type"] == 3) { $arr['payment_type'] = 3; $arr['status'] = 2; } $this->_name = "ldc_booking"; $book_id = $this->insert($arr); $arr_deatail = array('book_id' => $book_id, 'item_id' => $session->vehicle_id, 'item_name' => $session->vehicle_name, 'rent_num' => 1, 'price' => $session->price, 'total' => $session->price, 'total_paymented' => $session->price, 'status' => 1, 'item_type' => 1); $this->_name = "ldc_booking_detail"; $this->insert($arr_deatail); if ($session->guideid != "None") { $arr_deatail = array('book_id' => $book_id, 'item_id' => $session->guideid, 'item_name' => $session->guidename, 'rent_num' => 1, 'price' => $session->guideprice, 'total' => $session->guideprice, 'total_paymented' => $session->guideprice, 'status' => 1, 'item_type' => 4); $this->_name = "ldc_booking_detail"; $this->insert($arr_deatail); } // exit(); $db->commit(); return $book_id; } catch (Exception $e) { $db->rollBack(); $e->getMessage(); } }
function addTaxiBooking($data) { $db = $this->getAdapter(); $db->beginTransaction(); try { $session_user = new Zend_Session_Namespace('customer'); $user_id = $session_user->customer_id; $session = new Zend_Session_Namespace('taxibooking'); $db_globle = new Application_Model_DbTable_DbGlobal(); $booking_code = $db_globle->getNewBookingCode(); $trip_type = $session->trip_way == 1 ? "One-Way" : "Round Trip"; $pickup_date = new DateTime($session->pickup_date); //$return_date = new DateTime($data["return_date"]); $pickupdate = $pickup_date->format('Y-m-d'); // 2003-10-16 //$returndate = $return_date->format('Y-m-d'); $arr = array('customer_id' => $user_id, 'trip_type' => $trip_type, 'booking_no' => $booking_code, 'pickup_location' => $session->from_locationname, 'dropoff_location' => $session->to_locationname, 'date_book' => new Zend_Date(), 'pickup_date' => $pickupdate, 'pickup_time' => $session->pickup_time . ":" . $session->pickup_mins, 'total_fee' => $session->taxi_price, 'total_paymented' => $session->taxi_price, 'item_type' => 2); if ($data["payment_type"] == 1) { $arr['visa_name'] = $data["card_name"]; $arr['card_id'] = $data["card_id"]; $arr['secu_code'] = $data["secu_code"]; $arr['card_exp_date'] = $data["card_exp_date"]; $arr['card_id'] = $data["card_id"]; $arr['payment_type'] = 1; $arr['status'] = 1; } elseif ($data["payment_type"] == 2) { $arr['card_id'] = $data["code_num"]; $arr['payment_type'] = 2; $arr['status'] = 2; } elseif ($data["payment_type"] == 3) { $arr['payment_type'] = 3; $arr['status'] = 2; } $this->_name = "ldc_booking"; $book_id = $this->insert($arr); $arr_deatail = array('book_id' => $book_id, 'item_id' => $session->vehicle_id, 'item_name' => $session->vehicle_name, 'rent_num' => 1, 'price' => $session->taxi_price, 'total' => $session->taxi_price, 'total_paymented' => $session->taxi_price, 'status' => 1, 'item_type' => 1); $this->_name = "ldc_booking_detail"; $this->insert($arr_deatail); $db->commit(); return $book_id; } catch (Exception $e) { $db->rollBack(); $e->getMessage(); } }