Example #1
0
 function updatecalendarAction()
 {
     __autoloadPlugin('Ciirus');
     __autoloadPlugin('Globalresorthomes');
     __autoloadPlugin('Contempovacation');
     __autoloadPlugin('Fairwaysflorida');
     __autoloadPlugin('Casiola');
     __autoloadPlugin('Resorthomesofflorida');
     __autoloadPlugin('Ellisexclusivevillas');
     global $mySession;
     $db = new Db();
     $this->debug = false;
     $pptyArr = $db->runQuery("select *, subscriber_id AS supplier_id, \n                                    (\n                                        SELECT count( subscriber_key ) AS count\n                                        FROM `subscriber`\n                                        INNER JOIN property ON property.xml_subscriber_id = subscriber.subscriber_id\n                                        WHERE subscriber.subscriber_id = supplier_id\n                                    ) AS count  from " . PROPERTY . "\n                                      inner join subscriber on subscriber.subscriber_id = " . PROPERTY . ".xml_subscriber_id  \n                                      where xml_subscriber_id > 0 and status != '4' and status != '0'\n                                      order by subscriber.subscriber_id asc");
     //prd($pptyArr);
     $res = new Ciirus("c346aeb90de54a3", "ff3a6f4e60ab4ec");
     $_counter = array();
     $_counter['ciirus'] = 0;
     $_counter['globalresorthomes'] = 0;
     $_counter['contempovacation'] = 0;
     $_counter['fairwaysflorida'] = 0;
     $_counter['casiola'] = 0;
     $_counter['ellisexclusivevillas'] = 0;
     //$reservation = $res->getReservations(50644);
     //$arr['propertyId'] = 50644; //property which is not available
     //$arr['propertyId'] = 52196;
     foreach ($pptyArr as $pKey => $pVal) {
         $property_id = $pVal['id'];
         $xml_property_id = $pVal["xml_property_id"];
         switch ($pVal['xml_subscriber_id']) {
             //ciirus
             case '1':
                 if (!empty($xml_property_id)) {
                     //check if property is available or not
                     $arr['propertyId'] = $xml_property_id;
                     $av = $res->getProperties($arr, 0, true, true, true);
                     if (!preg_match('/No rows returned/', $av)) {
                         //update availability calendar
                         $reservation = $res->getReservations($xml_property_id);
                         //delete the older entries
                         if (!empty($reservation) && count($reservation)) {
                             $db->delete(CAL_AVAIL, "property_id = " . $property_id);
                         }
                         foreach ($reservation as $rKey => $rVal) {
                             if ($rKey === 'ArrivalDate') {
                                 break;
                             }
                             $data_cal = array();
                             $data_cal['property_id'] = $property_id;
                             $date_from = explode('T', $rVal['ArrivalDate']);
                             $data_cal['date_from'] = $date_from[0];
                             $date_to = explode('T', $rVal['DepartureDate']);
                             $data_cal['date_to'] = date('Y-m-d', strtotime($date_to[0] . ' -1 day'));
                             //$data_cal['date_to'] = $date_to[0];
                             $data_cal['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                         if ($rKey === 'ArrivalDate') {
                             $data_cal = array();
                             $data_cal['property_id'] = $property_id;
                             $date_from = explode('T', $reservation['ArrivalDate']);
                             $data_cal['date_from'] = $date_from[0];
                             $date_to = explode('T', $reservation['DepartureDate']);
                             $data_cal['date_to'] = date('Y-m-d', strtotime($date_to[0] . ' -1 day'));
                             //$data_cal['date_to'] = $date_to[0];
                             $data_cal['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                         echo $pKey + 1 . ". Successfully Updated property no - " . $pVal['xml_property_id'] . "<br>";
                     } else {
                         echo $pKey + 1 . ". Failed Updating property no - " . $pVal['xml_property_id'] . "<br>";
                     }
                 }
                 //code for checking if the supplier data is empty
                 if ($pVal['count'] == $_counter['ciirus'] + 1) {
                     echo "<strong>" . $pVal['subscriber_key'] . " cron job completed!! </strong><br>";
                 }
                 $_counter['ciirus']++;
                 break;
             case '2':
                 $res = new Globalresorthomes($pVal['subscriber_url']);
                 $res->getWebsite($xml_property_id);
                 if (!empty($xml_property_id)) {
                     //get booked dates
                     $reservation = $res->getReservations($xml_property_id, $pVal['subscriber_secondary_url']);
                     if (!empty($reservation) && count($reservation)) {
                         $db->delete(CAL_AVAIL, "property_id = " . $property_id);
                         foreach ($reservation as $rKey => $rVal) {
                             $data_cal = array();
                             $data_cal['property_id'] = $property_id;
                             $date_from = explode('-', $rVal);
                             // prd($date_from);
                             $data_cal['date_from'] = date('Y-m-d', strtotime($date_from[0]));
                             if (count($date_from) > 1) {
                                 $data_cal['date_to'] = date('Y-m-d', strtotime($date_from[1]));
                             } else {
                                 $data_cal['date_to'] = date('Y-m-d', strtotime($date_from[0]));
                             }
                             //$data_cal['date_to'] = $date_to[0];
                             $data_cal['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                         echo $pKey + 1 . ". Successfully Updated property no - " . $pVal['xml_property_id'] . "<br>";
                     }
                 }
                 //code for checking if the supplier data is empty
                 if ($pVal['count'] == $_counter['globalresorthomes'] + 1) {
                     echo "<strong>" . $pVal['subscriber_key'] . " cron job completed!! </strong><br>";
                 }
                 $_counter['globalresorthomes']++;
                 break;
             case '3':
                 $res = new Contempovacation($pVal['subscriber_url']);
                 $res->getWebsite($xml_property_id);
                 if (!empty($xml_property_id)) {
                     $reservation = $res->getReservations($xml_property_id, $pVal['subscriber_url']);
                     if (!empty($reservation) && count($reservation)) {
                         $db->delete(CAL_AVAIL, "property_id = " . $property_id);
                         foreach ($reservation as $rKey => $rVal) {
                             $data_cal = array();
                             $data_cal['property_id'] = $property_id;
                             $date_from = explode('|||', $rVal);
                             $data_cal['date_from'] = date('Y-m-d', strtotime(str_replace('/', '-', $date_from[0])));
                             $data_cal['date_to'] = date('Y-m-d', strtotime(str_replace('/', '-', $date_from[1])));
                             //$data_cal['date_to'] = $date_to[0];
                             $data_cal['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                         echo $pKey + 1 . ". Successfully Updated property no - " . $pVal['xml_property_id'] . "<br>";
                     }
                 }
                 if ($pVal['count'] == $_counter['contempovacation'] + 1) {
                     echo "<strong>" . $pVal['subscriber_key'] . " cron job completed!! </strong><br>";
                 }
                 $_counter['contempovacation']++;
                 break;
             case 4:
                 $res = new Fairwaysflorida($pVal['subscriber_url']);
                 $res->getWebsite($xml_property_id);
                 if (!empty($xml_property_id)) {
                     $reservation = $res->getBookedDates($pVal['xml_property_id']);
                     if (!empty($reservation) && count($reservation)) {
                         $db->delete(CAL_AVAIL, "property_id = " . $property_id);
                         foreach ($reservation as $rKey => $rVal) {
                             $data_cal = array();
                             $data_cal['property_id'] = $property_id;
                             $data_cal['date_from'] = $rVal['checkin'];
                             $data_cal['date_to'] = $rVal['checkout'];
                             $data_cal['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                         echo $pKey + 1 . ". Successfully Updated property no - " . $pVal['xml_property_id'] . "<br>";
                     }
                 }
                 if ($pVal['count'] == $_counter['fairwaysflorida'] + 1) {
                     echo "<strong>" . $pVal['subscriber_key'] . " cron job completed!! </strong><br>";
                 }
                 $_counter['fairwaysflorida']++;
                 break;
             case 5:
                 $res = new Casiola($pVal['subscriber_url']);
                 $res->getWebsite($xml_property_id);
                 if (!empty($xml_property_id)) {
                     //get booked dates
                     $reservation = $res->getReservations($xml_property_id, $pVal['subscriber_secondary_url']);
                     if (!empty($reservation) && count($reservation)) {
                         $db->delete(CAL_AVAIL, "property_id = " . $property_id);
                         foreach ($reservation as $rKey => $rVal) {
                             $data_cal = array();
                             $data_cal['property_id'] = $property_id;
                             $date_from = explode('-', $rVal);
                             // prd($date_from);
                             $data_cal['date_from'] = date('Y-m-d', strtotime($date_from[0]));
                             if (count($date_from) > 1) {
                                 $data_cal['date_to'] = date('Y-m-d', strtotime($date_from[1]));
                             } else {
                                 $data_cal['date_to'] = date('Y-m-d', strtotime($date_from[0]));
                             }
                             //$data_cal['date_to'] = $date_to[0];
                             $data_cal['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                         echo $pKey + 1 . ". Successfully Updated property no - " . $pVal['xml_property_id'] . "<br>";
                     }
                 }
                 //code for checking if the supplier data is empty
                 if ($pVal['count'] == $_counter['casiola'] + 1) {
                     echo "<strong>" . $pVal['subscriber_key'] . " cron job completed!! </strong><br>";
                 }
                 $_counter['casiola']++;
                 break;
             case 6:
                 $res = new Globalresorthomes($pVal['subscriber_url']);
                 $res->getWebsite($xml_property_id);
                 if (!empty($xml_property_id)) {
                     //get booked dates
                     $reservation = $res->getReservations($xml_property_id, $pVal['subscriber_secondary_url']);
                     if (!empty($reservation) && count($reservation)) {
                         $db->delete(CAL_AVAIL, "property_id = " . $property_id);
                         foreach ($reservation as $rKey => $rVal) {
                             $data_cal = array();
                             $data_cal['property_id'] = $property_id;
                             $date_from = explode('-', $rVal);
                             // prd($date_from);
                             $data_cal['date_from'] = date('Y-m-d', strtotime($date_from[0]));
                             if (count($date_from) > 1) {
                                 $data_cal['date_to'] = date('Y-m-d', strtotime($date_from[1]));
                             } else {
                                 $data_cal['date_to'] = date('Y-m-d', strtotime($date_from[0]));
                             }
                             //$data_cal['date_to'] = $date_to[0];
                             $data_cal['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                         echo $pKey + 1 . ". Successfully Updated property no - " . $pVal['xml_property_id'] . "<br>";
                     }
                 }
                 //code for checking if the supplier data is empty
                 if ($pVal['count'] == $_counter['resorthomesofflorida'] + 1) {
                     echo "<strong>" . $pVal['subscriber_key'] . " cron job completed!! </strong><br>";
                 }
                 $_counter['resorthomesofflorida']++;
                 break;
             case 7:
                 $res = new Ellisexclusivevillas($pVal['subscriber_url']);
                 $res->getWebsite($xml_property_id);
                 if (!empty($xml_property_id)) {
                     //get booked dates
                     $reservation = $res->getReservations($xml_property_id, $pVal['subscriber_secondary_url']);
                     if (!empty($reservation) && count($reservation)) {
                         $db->delete(CAL_AVAIL, "property_id = " . $property_id);
                         foreach ($reservation as $rKey => $rVal) {
                             $data_cal = array();
                             $data_cal['property_id'] = $property_id;
                             $date_from = explode('-', $rVal);
                             // prd($date_from);
                             $data_cal['date_from'] = date('Y-m-d', strtotime($date_from[0]));
                             if (count($date_from) > 1) {
                                 $data_cal['date_to'] = date('Y-m-d', strtotime($date_from[1]));
                             } else {
                                 $data_cal['date_to'] = date('Y-m-d', strtotime($date_from[0]));
                             }
                             //$data_cal['date_to'] = $date_to[0];
                             $data_cal['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                         echo $pKey + 1 . ". Successfully Updated property no - " . $pVal['xml_property_id'] . "<br>";
                     }
                 }
                 //code for checking if the supplier data is empty
                 if ($pVal['count'] == $_counter['ellisexclusivevillas'] + 1) {
                     echo "<strong>" . $pVal['subscriber_key'] . " cron job completed!! </strong><br>";
                 }
                 $_counter['ellisexclusivevillas']++;
                 break;
         }
         //switch case ends
     }
     echo "perfect!!";
     die;
 }
<?php

__autoloadDB('Db');
__autoloadPlugin('Ciirus');
__autoloadPlugin('Globalresorthomes');
__autoloadPlugin('Contempovacation');
__autoloadPlugin('Fairwaysflorida');
__autoloadPlugin('Casiola');
__autoloadPlugin('Resorthomesofflorida');
__autoloadPlugin('Ellisexclusivevillas');
__autoloadPlugin('Oceanbeds');
__autoloadPlugin('Floridatravelnetwork');
class LibraryController extends AppController
{
    public function indexAction()
    {
        global $mySession;
        $this->view->pageHeading = "Manage Property List";
        $db = new Db();
        $qry = "select * from " . PROPERTY . " as p\n\t\t\t  inner join " . PROPERTY_TYPE . " as pt on pt.ptyle_id = p.property_type\n                          inner join " . COUNTRIES . " on " . COUNTRIES . ".country_id = p.country_id\n                          inner join " . STATE . " on " . STATE . ".state_id = p.state_id\n                          inner join " . CITIES . " on " . CITIES . ".city_id = p.city_id\n                          left join " . SUB_AREA . " on " . SUB_AREA . ".sub_area_id = p.sub_area_id\n                          left join " . LOCAL_AREA . " on " . LOCAL_AREA . ".local_area_id = p.local_area_id\n\t\t\t  inner join " . USERS . "  as u on u.user_id = p.user_id where p.status = '5'\n\t\t\t  order by p.property_title  ";
        $resData = $db->runQuery("{$qry}");
        $this->view->ResData = $db->runQuery("{$qry}");
    }
    public function propertyAction()
    {
        $res = new Ciirus("c346aeb90de54a3", "ff3a6f4e60ab4ec");
        $res->getProperties();
        die;
    }
    public function synchronizeAction()
    {
Example #3
0
<?php

__autoloadDB('Db');
__autoloadPlugin('Ciirus');
class Booking extends Db
{
    public function checkAvailablity($dataForm, $pptyId)
    {
        global $mySession;
        $db = new Db();
        if ($dataForm['partySize'] < $dataForm['Adults'] + $dataForm['Children']) {
            return "Members area greater than the property size";
        }
        $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 "The dates/nights you selected are not available, please try again";
        } 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"));
 public function ciirusbooking($xml_property_id, $arrivalDate, $departureDate, $guestArr)
 {
     __autoloadPlugin('Ciirus');
     global $mySession;
     $db = new Db();
     $this->debug = false;
     //            $pptyArr = $db->runQuery("select * from " . PROPERTY . "
     //                                      inner join subscriber on subscriber.subscriber_id = " . PROPERTY . ".xml_subscriber_id
     //                                        where xml_subscriber_id > 0 ");
     $res = new Ciirus("c346aeb90de54a3", "ff3a6f4e60ab4ec");
     $reservation = $res->makeBooking($xml_property_id, $arrivalDate, $departureDate, $guestArr);
     return $reservation;
 }