Exemple #1
0
 public function checkAvailablity($dataForm, $pptyId)
 {
     global $mySession;
     $db = new Db();
     if ($dataForm['partySize'] < $dataForm['Adults'] + $dataForm['Children']) {
         return array("message" => "Members area greater than the property size", "output" => false);
     }
     $arrivalDate = explode("/", $dataForm['date_from']);
     $narrivalDate = $arrivalDate[2] . "-" . $arrivalDate[1] . "-" . $arrivalDate[0];
     $dataForm['date_to'] = $dataForm['date_to'] - 1;
     //echo "select * from  ".CAL_AVAIL." where ((date_from <= '".$narrivalDate."' and  date_to >= '".$narrivalDate."') or  (date_to >= adddate('".$narrivalDate."',$dataForm[date_to]) and date_from <= adddate('".$narrivalDate."',$dataForm[date_to])))  and cal_status = '0'  and property_id = '".$pptyId."'  "; exit;
     $chkQuery = $db->runQuery("select * from  " . CAL_AVAIL . " where ((date_from <= '" . $narrivalDate . "' and  date_to >= '" . $narrivalDate . "') or  (date_to >= adddate('" . $narrivalDate . "','" . $dataForm['date_to'] . "') and date_from <= adddate('" . $narrivalDate . "','" . $dataForm['date_to'] . "')))  and cal_status = '0'  and property_id = '" . $pptyId . "'  ");
     $dateTo = date('Y-m-d', strtotime($narrivalDate . " + " . $dataForm['date_to'] . " day"));
     if (count($chkQuery) > 0) {
         return array("message" => "The dates/nights you selected are not available, please try again", "output" => false);
     } else {
         //checking if a supplier property
         $supplierpptyArr = $db->runQuery("select * from property where id = '" . $pptyId . "' ");
         if ($supplierpptyArr[0]['xml_subscriber_id'] > 0 && !empty($supplierpptyArr[0]['xml_property_id']) && $supplierpptyArr[0]['xml_subscriber_id'] == '1') {
             //xml api checking if a property is available
             $res = new Ciirus("c346aeb90de54a3", "ff3a6f4e60ab4ec");
             $arrivalDate = date('d-M-Y', strtotime($narrivalDate));
             //prd($arrivalDate);
             $departureDate = date('d-M-Y', strtotime($narrivalDate . " + " . ($dataForm['date_to'] + 1) . " day"));
             $dd = $res->isPropertyAvailable($supplierpptyArr[0]['xml_property_id'], $arrivalDate, $departureDate);
             //prd($dd);
             if (!$dd) {
                 return array("message" => "The dates/nights you selected are not available, please try again", "output" => false);
             }
         }
     }
     if ($this->checkAmount($narrivalDate, $dateTo, $dataForm['date_to'] + 1, $pptyId) === 0) {
         return array("message" => "Allowed Minimum Nights failed", "output" => false);
     }
     $mySession->Adults = $dataForm['Adults'];
     $mySession->Children = $dataForm['Children'];
     $mySession->Infants = $dataForm['Infants'];
     $mySession->noOfNights = $dataForm['date_to'] + 1;
     $mySession->arrivalDate = $dataForm['date_from'];
     $mySession->departureDate = date('d-m-Y', strtotime($dataForm['date_from'] . " + " . ($dataForm['date_to'] + 1) . " day"));
     $mySession->partySize = $dataForm['Adults'] + $dataForm['Children'];
     $mySession->pptyId = $pptyId;
     //code to find the amount
     $mySession->totalCost = $this->checkAmount($narrivalDate, $dateTo, $dataForm['date_to'] + 1, $pptyId);
     //                if(empty($mySession->totalCost)){
     //                    return array("output"=>false,"message"=>"cost not available");
     //                }
     $mySession->steps = '2';
     //		return 1;
     return array("cost" => $mySession->totalCost, "output" => true);
 }