コード例 #1
0
ファイル: view.html.php プロジェクト: vCodeTech/ivivu
 function step4()
 {
     global $option, $mainframe;
     $mainframe->setPageTitle(JTEXT::_("THANK YOU"));
     $currentSession = JSession::getInstance('none', array());
     $currentSession->set('multi_post_book', '0');
     //echo $currentSession->get('multi_post', 'err');
     if ($currentSession->get('multi_post', 'err') == 'err') {
         $link = 'index.php?option=com_hotel';
         echo "<script> \r\n\t\t\twindow.location = 'index.php?option=com_vnffhotel'; </script>\n";
         echo JTEXT::_("INVALID SESSION");
         return;
     }
     $model =& $this->getModel();
     $currentSession = JSession::getInstance('none', array());
     //get controller
     $controller = new VnffhotelController();
     $customer = $model->getCustomer($currentSession->get('customer_id', ''));
     //echo $customer->first_Name;
     $item_count = $currentSession->get('item_count', '0');
     $days_count = $currentSession->get('days_count', '0');
     $total_amount = $currentSession->get('total_amount', '0');
     for ($i = 0; $i < $item_count; $i++) {
         $prices[$i] = $model->getPriceById($currentSession->get('price_id_' . $i, ''));
         //echo $prices[$i]->hotel_Name;
         $quantities[$i] = $currentSession->get('quantity_' . $i, '');
         //echo $quantities[$i];
         $sub_totals[$i] = $currentSession->get('subtotal_' . $i, '');
         //echo $quantities[$i];
     }
     $checkin_date = $currentSession->get('checkin_date', '');
     $checkout_date = $currentSession->get('checkout_date', '');
     $booking_requests = $currentSession->get('booking_requests', '');
     $book =& JTable::getInstance('books', 'Table');
     if (!$book->bind(JRequest::get('post'))) {
         echo "<script> alert('" . $book->getError() . "'); \r\n\t\t\t\t\t\t   window.history.go(-1); </script>\n";
         exit;
     }
     $checkin_date_r = explode('/', $checkin_date);
     $checkout_date_r = explode('/', $checkout_date);
     $book->from_Date = date('Y-m-d H:i:s', mktime(0, 0, 0, $checkin_date_r[1], $checkin_date_r[0], $checkin_date_r[2]));
     $book->des_Date = date('Y-m-d H:i:s', mktime(0, 0, 0, $checkout_date_r[1], $checkout_date_r[0], $checkout_date_r[2]));
     //echo $book->from_Date . $book->des_Date;
     $book->customer_ID = $customer->customer_ID;
     $book->status = "no";
     $book->book_Requests = $booking_requests;
     if ($currentSession->get('multi_post_book', '0') == '0') {
         if (!$book->store()) {
             echo $book->getError();
             echo "<script> alert('" . $book->getError() . "'); \r\n\t\t\t\t\t  window.history.go(-1); </script>\n";
             exit;
         }
         for ($i = 0; $i < $item_count; $i++) {
             $book_details =& JTable::getInstance('bookdetails', 'Table');
             if (!$book_details->bind(JRequest::get('post'))) {
                 echo "<script> alert('" . $book_details->getError() . "'); \r\n\t\t\t\t\t\t\t   window.history.go(-1); </script>\n";
                 exit;
             }
             $book_details->book_ID = $book->book_ID;
             $book_details->price_ID = $currentSession->get('price_id_' . $i, '');
             $book_details->quantity = $quantities[$i];
             if (!$book_details->store()) {
                 echo $book_details->getError();
                 echo "<script> alert('" . $book_details->getError() . "'); \r\n\t\t\t\t\t  \twindow.history.go(-1); </script>\n";
                 exit;
             }
         }
         //$currentSession->set('customer_id', $row->customer_ID);
         $currentSession->set('multi_post_book', '1');
     }
     JSession::destroy();
     //echo "hehehehe";
     $this->assignRef('controller', $controller);
     parent::display("step4");
 }