Exemplo n.º 1
0
 public function bookingAction()
 {
     $db = new Application_Model_DbTable_DbGlobal();
     $step_one = 0;
     $step_two = 0;
     $step_three = 0;
     $step_five = 0;
     //$step_four=0;
     $customer_user_session = "";
     $session_step_one = new Zend_Session_Namespace('booking');
     $step_booking = $session_step_one->step_one;
     $user_ip = $session_step_one->user_ip;
     $step_4 = new Zend_Session_Namespace('step_four');
     $session_step_four = $step_4->step4;
     $customer_session = new Zend_Session_Namespace('customer');
     $user_session = $customer_session->customer_session;
     if (!empty($session_step_four)) {
         $step_four = $session_step_four;
     } else {
         $step_four = 0;
     }
     if (!empty($user_session)) {
         $customer_user_session = $user_session;
         $customer_user = $customer_session->customer_id;
         $this->view->user_name = $customer_session->customer_name;
         $this->view->user_info = $customer_session->user_info;
     } else {
         $customer_user_session = 0;
     }
     if ($step_booking == "") {
         $step_one = 0;
     } else {
         $step_one = $step_booking;
     }
     $data_first_step = array();
     $row_vehicle = array();
     $row_vehicle_price = array();
     $row_equipment_price = array();
     $row_driver_price = array();
     $row_equipment = array();
     $row_driver = array();
     if ($step_one != 0) {
         $post = $this->getRequest()->getPost();
         if (isset($post["search_vehicle"])) {
             $db->deleteVisaulBooking($user_ip, 2);
             $row = $db->getAllAvailableVehicle($post);
             if (!empty($row)) {
                 $db->updateVisualBookingStepOne($post, $user_ip);
             }
             $session_step_two = new Zend_Session_Namespace('step_two');
             $session_step_two->unsetAll();
             $session_step_three = new Zend_Session_Namespace('step_three');
             $session_step_three->unsetAll();
             $session_step_four = new Zend_Session_Namespace('step_four');
             $session_step_four->unsetAll();
             $session_step_five = new Zend_Session_Namespace('step_five');
             $session_step_five->unsetAll();
             //Application_Form_FrmMessage::redirectUrl("/index/booking");
         }
         $data_first_step = $db->getFirstStepData($user_ip);
         $row_driver = $db->getAvailableDriver($data_first_step);
         $row_equipment = $db->getEquipment($data_first_step);
         $row_vehicle = $db->getAllAvailableVehicle($data_first_step);
         $session_step_two = new Zend_Session_Namespace('step_two');
         if ($session_step_two->step_two == "") {
             $step_two = 0;
         } else {
             $step_two = $session_step_two->step_two;
         }
         if ($step_two != 0) {
             $row_vehicle_price = $db->getVehiclePriceSelected($user_ip);
             $session_step_three = new Zend_Session_Namespace('step_three');
             if ($session_step_three->step_three == "") {
                 $step_three = 0;
             } else {
                 $step_three = $session_step_three->step_three;
             }
             if ($step_three != 0) {
                 if ($this->getRequest()->isPost()) {
                     $data = $this->getRequest()->getPost();
                     if (isset($data["pro_equip"])) {
                         if ($data["identity_equipment"] != "" or $data["identity_driver"] != "") {
                             $db->updateVisualBookingStebthree($user_ip, $data);
                         }
                     }
                 }
                 $row_equipment_price = $db->getProductAndServicesSelected($user_ip, 3);
                 $row_driver_price = $db->getProductAndServicesSelected($user_ip, 2);
                 if ($step_four != 0) {
                     if ($this->getRequest()->isPost()) {
                         $data = $this->getRequest()->getPost();
                         if (isset($data["confirm_book"])) {
                             $session_step_five = new Zend_Session_Namespace('step_five');
                             $step_five = $session_step_five->step_five = 1;
                         } elseif (isset($data["term_condiction"])) {
                             $db->addCuFlight($data, $user_ip);
                         }
                     }
                 } else {
                     if ($this->getRequest()->isPost()) {
                         $data = $this->getRequest()->getPost();
                         if (isset($data["term_condiction"])) {
                             $db->addCuFlight($data, $user_ip);
                             $session_step_four = new Zend_Session_Namespace('step_four');
                             $step_four = $session_step_four->step4 = 1;
                         }
                     }
                 }
             } else {
                 if ($this->getRequest()->isPost()) {
                     $data = $this->getRequest()->getPost();
                     if (isset($data["pro_equip"])) {
                         $session_step_three = new Zend_Session_Namespace('step_three');
                         $session_step_three->step_three = 1;
                         if ($data["identity_equipment"] != "" or $data["identity_driver"] != "") {
                             $db->addVisualBookingStebthree($user_ip, $data);
                         }
                         Application_Form_FrmMessage::redirectUrl("/index/booking");
                     }
                 }
                 $row_equipment_price = $db->getProductAndServicesSelected($user_ip, 3);
                 $row_driver_price = $db->getProductAndServicesSelected($user_ip, 2);
             }
         }
     } else {
         if ($this->getRequest()->isPost()) {
             $post = $this->getRequest()->getPost();
             if (isset($post["search_vehicle"])) {
                 $row = $db->getAllAvailableVehicle($post);
                 if (!empty($row)) {
                     $session_booking = new Zend_Session_Namespace('booking');
                     $session_booking->step_one = 1;
                     $session_booking->user_ip = $post["public_ip"] . "-" . $post["ip_address"];
                     $user_ip = $session_booking->user_ip;
                     $db->addVisualBookingStepOne($post);
                     $data_first_step = $db->getFirstStepData($user_ip);
                     $row_driver = $db->getAvailableDriver($data_first_step);
                     $row_equipment = $db->getEquipment($data_first_step);
                     $row_vehicle = $db->getAllAvailableVehicle($data_first_step);
                     Application_Form_FrmMessage::redirectUrl("/index/booking");
                 } else {
                     $session_booking = new Zend_Session_Namespace('booking');
                     $session_booking->step_one = 0;
                 }
             }
         }
     }
     $this->view->user_session = $customer_user_session;
     $this->view->step_five = $step_five;
     $this->view->step_four = $step_four;
     $this->view->step_one = $step_one;
     $this->view->step_two = $step_two;
     $this->view->step_three = $step_three;
     $this->view->equipment_price = $row_equipment_price;
     $this->view->driver_price = $row_driver_price;
     $this->view->vehicle_price = $row_vehicle_price;
     $this->view->equipment = $row_equipment;
     $this->view->vehicle = $row_vehicle;
     $this->view->driver = $row_driver;
     $this->view->data_first_step = $data_first_step;
     $frmbooks = new Application_Form_FrmBooking();
     $frmbooking = $frmbooks->FromBooking();
     Application_Model_Decorator::removeAllDecorator($frmbooking);
     $this->view->frmbooking = $frmbooking;
 }
Exemplo n.º 2
0
 public function updateVisualBookingStepTwo($user_ip, $vehicle_id)
 {
     $db = $this->getAdapter();
     $db_globle = new Application_Model_DbTable_DbGlobal();
     $data_first_step = $this->getFirstStepData($user_ip);
     $pickup_date = date_create($data_first_step["pickup_date"]);
     $return_date = date_create($data_first_step["return_date"]);
     $row_vehicle = $db_globle->getVehiclePriceSelected($user_ip);
     $diff = date_diff($pickup_date, $return_date);
     $total_day = $diff->format("%a%") + 1;
     $sql = "SELECT v.`price`,v.`extraprice`,v.`vat_value`  FROM `ldc_vehiclefee_detail` AS v WHERE v.`packageday_id`=(SELECT r.id FROM `ldc_rankday` AS r WHERE r.`from_amountday`<={$total_day} AND r.`to_amountday`>={$total_day} LIMIT 1) AND v.`vehicle_id` = {$vehicle_id}";
     $row = $db->fetchRow($sql);
     if (empty($row)) {
         $sql = "SELECT v.`price`,v.`extraprice`,v.`vat_value`  FROM `ldc_vehiclefee_detail` AS v WHERE v.`packageday_id`=(SELECT r.id FROM `ldc_rankday` AS r WHERE r.`is_morethen`=1 LIMIT 1) AND v.`vehicle_id` = {$vehicle_id}";
         $row_data = $db->fetchRow($sql);
     } else {
         $row_data = $row;
     }
     $sqlv = "SELECT (SELECT m.`title` FROM `ldc_make` AS m WHERE m.id = v.`make_id`) AS make,(SELECT m.`title` FROM `ldc_model` AS m WHERE m.id = v.`model_id`) AS model,(SELECT s.`title` FROM `ldc_submodel`AS s WHERE s.id = v.`sub_model`) AS sub_model,(SELECT v.`title` FROM `ldc_vechicletye` AS v WHERE v.`id`=v.`car_type`) AS car_type,(SELECT t.`tran_name` FROM `ldc_transmission` AS t WHERE t.`id`=v.`transmission`) AS transation,v.`reffer`,v.ordering FROM `ldc_vehicle` AS v WHERE v.`id`={$vehicle_id}";
     $row_vehicle = $db->fetchRow($sqlv);
     //print_r($sql);
     $total_price = $row_data["price"] * $total_day;
     $total_vat = $total_price * ($row_data["vat_value"] / 100);
     $bank_charge = ($total_price + $total_vat) * (3 / 100);
     $deposite = ($total_price + $total_vat) * (50 / 100) + $bank_charge;
     $arr = array('item_id' => $vehicle_id, 'item_name' => $row_vehicle["make"] . " " . $row_vehicle["model"] . " " . $row_vehicle["sub_model"] . " " . $row_vehicle["car_type"] . " " . $row_vehicle["transation"] . "(" . $row_vehicle["reffer"] . ")", 'price' => $row_data["price"], 'VAT' => $row_data["vat_value"], 'item_type' => 1, 'number_of_rent' => 1, 'deposite' => $deposite, 'refund_deposit' => $row_vehicle["ordering"], 'total' => $total_price + $total_vat, 'total_paymented' => $deposite);
     $this->_name = "ldc_visurl_booking_detail";
     $where = array("user_id=?" => $user_ip, "item_type=?" => 1);
     $this->update($arr, $where);
 }