Example #1
0
 function cleanSameReservationWaiting($email, $datas, $datae)
 {
     $query = " \tSELECT \r\n\t\t\t\t\t\tc.confirmation_id,\r\n\t\t\t\t\t\tc.email,\r\n\t\t\t\t\t\thp.paymentprocessor_type \tAS type\r\n\t\t\t\t\tFROM #__hotelreservation_confirmations c\r\n\t\t\t\t\tINNER JOIN #__hotelreservation_confirmations_payments\tcp USING( confirmation_id )\r\n\t\t\t\t\tINNER JOIN #__hotelreservation_paymentprocessors\t\thp USING( paymentprocessor_id )\r\n\t\t\t\t\tWHERE \r\n\t\t\t\t\t\tc.datas='{$datas}'\r\n\t\t\t\t\t\tAND\r\n\t\t\t\t\t\tc.datae='{$datae}'\r\n\t\t\t\t\t\tAND\r\n\t\t\t\t\t\tc.email='{$email}'\r\n\t\t\t\t\t\tAND\t\t\t\t\t\t\r\n\t\t\t\t\t\thp.paymentprocessor_type ='" . PROCESSOR_BANK_ORDER . "'\r\n\t\t\t\t\t\tAND\t\t\t\t\t\t\r\n\t\t\t\t\t\tcp.payment_status ='" . PAYMENT_STATUS_WAITING . "'\r\n\t\t\t\t\tGROUP BY c.confirmation_id\r\n\t\t\t\t\tORDER BY hp.paymentprocessor_name\r\n\t\t\t\t\t";
     $this->_db->setQuery($query);
     $reservations_unwanted =& $this->_getList($query);
     foreach ($reservations_unwanted as $res) {
         // dbg($res);
         JHotelReservationModelVariables::deleteWaitingConfirmation($res->confirmation_id, $res->email, $res->type, false, false);
     }
 }
 function cancelPayment($confirmationId)
 {
     JHotelReservationModelVariables::writeMessage('processing cancelPayment() function');
     try {
         JRequest::setVar('tip_oper', 4);
         $modelVariables = new JHotelReservationModelVariables();
         if (!$modelVariables->load($confirmationId, null, null)) {
             JHotelReservationModelVariables::writeMessage('processErr');
             exit;
         }
         //canceled, sending email
         if ($modelVariables->itemAppSettings->is_email_notify_canceled_pending == true) {
             $modelVariables->sendCancelPendingEmail($confirmationId, CANCELED_PENDING_ID);
         }
         //~canceled, sending email
         JHotelReservationModelVariables::deletePendingConfirmation($confirmationId, null, null, false, false);
     } catch (Exception $e) {
         JHotelReservationModelVariables::writeMessage("Error accured processing cancelPayment() function. ");
     }
     die;
 }
 /**
  * save a record (and redirect to main page)
  * @return void
  */
 function save()
 {
     $bRet = 0;
     $post = JRequest::get('post');
     $model = $this->getModel('managereservations');
     $tsk = 'edit';
     if (isset($post['is_assign_number_rooms']) && $post['is_assign_number_rooms'] == 1) {
         $tsk = 'assign_number_rooms';
     }
     if (isset($post['is_status']) && $post['is_status'] == 1) {
         $ret = $this->changeStatus();
         return $ret;
     } else {
         if (isset($post['change_confirmation_payment_status']) && $post['change_confirmation_payment_status'] > 0) {
             $ret = $this->changeConfirmationPaymentStatus($post['change_confirmation_payment_status']);
             return $ret;
         } else {
             if ($tsk == 'edit') {
                 // if( strtotime($post['datas']) < strtotime( date('Y-m-d') ) )
                 // $bRet = -1;
                 // if( strtotime($post['datae']) < strtotime($post['datas'] ) )
                 // $bRet = -2;
                 // if( count($post['room_ids']) == 0)
                 // $bRet = -3;
             }
             if ($bRet == 0) {
                 $modelVariables = $this->getModel('Variables');
                 $modelConfirmations = $this->getModel('Confirmations');
                 //$modelConfirmations = $this->getModel('Confirmations');
                 if (isset($post['is_assign_number_rooms']) && $post['is_assign_number_rooms'] == 1) {
                     JRequest::setVar('tip_oper', 5);
                     $modelVariables->load($post['confirmation_id'], $post['email'], $modelVariables->itemCurrency, array('itemRoomsNumbers' => $post['itemRoomsNumbers']));
                     $tsk = 'assign_number_rooms';
                     // dmp($modelVariables->itemRoomsNumbers);
                     // exit;
                     foreach ($modelVariables->itemRoomsNumbers as $key => $valueNumber) {
                         if ($valueNumber == 0) {
                             JError::raiseWarning(500, JText::_('LNG_PLEASE_SELECT_ROOM_NUMBER', true));
                             $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managereservations&view=managereservations&confirmation_id[]=' . $post['confirmation_id'] . '&task=' . $tsk);
                             return false;
                         }
                     }
                     //$post['itemRoomsNumbers'] 	= $str;
                 } else {
                     if ($tsk == 'edit') {
                         $start_date = JHotelUtil::convertToMysqlFormat($post["datas"]);
                         $end_date = JHotelUtil::convertToMysqlFormat($post["datae"]);
                         //dmp($start_date);
                         //dmp($end_date);
                         //dmp($post);
                         JRequest::setVar('tip_oper', 5);
                         $modelVariables = new JHotelReservationModelVariables($post['hotel_id']);
                         $modelVariables->load($post['confirmation_id'], $post['email'], $modelVariables->itemCurrency, $post);
                         $modelVariables->store($post);
                         //dmp($modelVariables);
                     }
                 }
                 //dmp($modelVariables);
                 //exit;
                 if ($modelVariables->checkAvalability(true)) {
                     // $str 						= $modelVariables->getStringRoomsCapacity( $modelVariables->itemRoomsCapacity );
                     // $post['itemRoomsCapacity'] 	= $str;
                     // $modelVariables->store($post);
                     $check_totals = true;
                     if (isset($post['is_assign_number_rooms']) && $post['is_assign_number_rooms'] == 1) {
                         $check_totals = false;
                     } else {
                         $modelVariables->status_reservation_id = RESERVED_ID;
                     }
                     //$modelVariables->itemRoomsDiscounts 	= $modelVariables->getRoomsDiscounts();
                     /*
                     					//numbers
                     					if( isset( $post['is_assign_number_rooms']) && $post['is_assign_number_rooms'] == 1 )
                     					{
                     						$modelVariables->getRoomsAvailable($modelVariables->room_ids, true );
                     						foreach($modelVariables->itemRoomsNumbers as $key=> $nr )
                     						{
                     							foreach( $modelVariables->itemRoomsAvailable as $k => $v )
                     							{
                     								if($v->room_id == $key )
                     								{
                     									foreach( $modelVariables->itemRoomsAvailable[$k]->daily as $d => $vd  )
                     									{
                     										// dmp($modelVariables->itemRoomsNumbers);
                     										$modelVariables->itemRoomsAvailable[$k]->daily['numbers'][] = array(
                     																										'data'			=>	$vd['numbers'],
                     																										'id'			=>  -1,
                     																										'nr'			=>	$nr,
                     																										'price'			=> 	$vd['price_final'],
                     																										'discounts'		=>  $vd[ 'discounts' ]
                     																									);
                     									}
                     								}						
                     							}
                     						}
                     						echo 3;
                     					}
                     					dmp($modelVariables->itemRoomsAvailable);
                     					exit;*/
                     if ($modelVariables->total > $modelVariables->total_payed) {
                         $modelVariables->confirmation_payment_status = PAYMENT_STATUS_NOTPAYED;
                     }
                     //check is allready payed on website
                     /*if( !$modelVariables->comparePayedValues() && $check_totals == true ){
                     			$bRet = -5;
                     		
                     		}*/
                     if ($modelConfirmations->store($modelVariables, true, false)) {
                         $bRet = 1;
                     }
                     //exit;
                 } else {
                     $bRet = -4;
                 }
             }
             //exit;
             switch ($bRet) {
                 case 1:
                     $msg = JText::_('LNG_RESERVATION_SAVED', true);
                     $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managereservations&view=managereservations', $msg);
                     break;
                 case 0:
                     JError::raiseWarning(500, JText::_('LNG_ERROR_SAVING_RESERVATION', true));
                     $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managereservations&view=managereservations&confirmation_id[]=' . $post['confirmation_id']);
                     break;
                 case -1:
                     JError::raiseWarning(500, JText::_('LNG_DATA_START_DATA_CURRENT', true));
                     //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managereservations&view=managereservations', $msg );
                     $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managereservations&view=managereservations&task=' . $tsk . '&confirmation_id[]=' . $post['confirmation_id']);
                     break;
                 case -2:
                     JError::raiseWarning(500, JText::_('LNG_DATA_STOP_LOWER_DATA_START', true));
                     $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managereservations&view=managereservations&task=' . $tsk . '&confirmation_id[]=' . $post['confirmation_id']);
                     //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managereservations&view=managereservations', $msg );
                     break;
                 case -3:
                     JError::raiseWarning(500, JText::_('LNG_PLEASE_SELECT_AT_LEAST_ONE_ROOM', true));
                     $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managereservations&view=managereservations&task=' . $tsk . '&confirmation_id[]=' . $post['confirmation_id']);
                     //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managereservations&view=managereservations', $msg );
                     break;
                 case -4:
                     JError::raiseWarning(500, JText::_('LNG_CURRENTLY_THERE_ARE_NO_ENOUGH_ROOMS_AVAILABLE', true));
                     $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managereservations&view=managereservations&task=' . $tsk . '&confirmation_id[]=' . $post['confirmation_id']);
                     //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managereservations&view=managereservations', $msg );
                     break;
                 case -5:
                     JError::raiseWarning(500, JText::_('LNG_WEBSITE_PAYED_FINAL_LOWER_PRICE', true));
                     $this->setRedirect('index.php?option=' . getBookingExtName() . '&controller=managereservations&view=managereservations&task=' . $tsk . '&confirmation_id[]=' . $post['confirmation_id']);
                     //$this->setRedirect( 'index.php?option='.getBookingExtName().'&controller=managereservations&view=managereservations', $msg );
                     break;
             }
         }
     }
 }
 /**
  * Parse response
  */
 public function parseResponse($params)
 {
     foreach ($params as $k => $v) {
         JHotelReservationModelVariables::writeMessage("Response param: " . $k . ' ' . $v);
     }
     $this->amount = $params["brq_amount"];
     $this->currencyCode = $params["brq_currency"];
     $this->transactions = $params["brq_transactions"];
     $this->invoiceNumber = $params["brq_invoicenumber"];
     $this->responseCode = $params["brq_statuscode"];
     $this->responseMessage = $params["brq_statusmessage"];
     $this->transactionTime = $params["brq_timestamp"];
     if (isset($params["brq_payment"])) {
         $this->paymentId = $params["brq_payment"];
     }
     if (isset($params["brq_payment_method"])) {
         $this->paymentMethod = $params["brq_payment_method"];
     }
 }
 private function showPaymentResult($confirmationId, $success)
 {
     JHotelReservationModelVariables::writeMessage(" call function showPaymentResult() - confirmationId: " . $confirmationId);
     $tipOper = 5;
     $view = "confirmation";
     if ($success == 'false') {
         $tipOper = 4;
         $view = "guestinformation";
     }
     JRequest::setVar('tip_oper', $tipOper);
     try {
         $modelVariables = new JHotelReservationModelVariables();
         if (!$modelVariables->load($confirmationId, null, null)) {
             throw new Exception(JText::_('LNG_CANNOT_LOAD_MODEL', true));
         }
         $view = $this->getView($view);
         $view->setModel($modelVariables, true);
         $view->display();
     } catch (Exception $e) {
         JHotelReservationModelVariables::writeMessage("Error accured processing showPaymentResult()- 4B Spain function.");
         JHotelReservationModelVariables::writeMessage("Error: " . $e);
         JRequest::setVar('tip_oper', 0);
         $this->display();
         return;
     }
 }
 function &getData()
 {
     // Load the data
     if (empty($this->_data)) {
         $query = " SELECT \r\n\t\t\t\t\t\t\t\tc.*\r\n\t\t\t\t\t\t\tFROM #__hotelreservation_confirmations c\r\n\t\t\t\t\t\t" . " WHERE c.confirmation_id = " . $this->_confirmation_id;
         $this->_db->setQuery($query);
         // dmp($this->_db);
         $this->_data = $this->_db->loadObject();
         //dmp($this->_data);
         $modelVariables = new JHotelReservationModelVariables($this->_data->hotel_id);
         $modelVariables->edit_mode = 1;
         JRequest::setVar('tip_oper', 5);
         $post = JRequest::get('post');
         $params = array();
         if (isset($post["room_guests"])) {
             $params["room_guests"] = $post["room_guests"];
         }
         $modelVariables->load($this->_data->confirmation_id, $this->_data->email, $modelVariables->itemCurrency, $params);
         $modelVariables->checkAvalability();
         return $modelVariables;
     }
     return $this->_data;
 }