Пример #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;
 }
Пример #2
0
 public function synchronizebulkAction()
 {
     global $mySession;
     $db = new Db();
     set_time_limit(0);
     $post = $this->getRequest()->getPost();
     $this->debug = false;
     if ($this->getRequest()->isPost()) {
         foreach ($post['xml_property_id'] as $key => $postValue) {
             $property_id = $post["ref_property_id"][$key];
             $xml_property_id = $postValue;
             $caption = $post['ref_property_caption'][$key];
             //get data of suppliers from database
             $supplierData = $db->runQuery("select * from  subscriber ");
             $_supplierData = array();
             foreach ($supplierData as $supKey => $supVal) {
                 $_supplierData[$supVal['subscriber_key']]['subscriber_name'] = $supVal['subscriber_name'];
                 $_supplierData[$supVal['subscriber_key']]['subscriber_id'] = $supVal['subscriber_id'];
                 $_supplierData[$supVal['subscriber_key']]['subscriber_url'] = $supVal['subscriber_url'];
                 $_supplierData[$supVal['subscriber_key']]['subscriber_secondary_url'] = $supVal['subscriber_secondary_url'];
                 $_supplierData[$supVal['subscriber_key']]['subscriber_base_url'] = $supVal['subscriber_base_url'];
                 $_supplierData[$supVal['subscriber_key']]['subscriber_image_url'] = $supVal['subscriber_image_url'];
                 $_supplierData[$supVal['subscriber_key']]['subscriber_image_secondary_url'] = $supVal['subscriber_image_secondary_url'];
                 if (!empty($supVal['subscriber_api_username'])) {
                     $_supplierData[$supVal['subscriber_key']]['subscriber_api_username'] = $supVal['subscriber_api_username'];
                     $_supplierData[$supVal['subscriber_key']]['subscriber_api_password'] = $supVal['subscriber_api_password'];
                 }
             }
             //prd($_supplierData['ciirus']['subscriber_api_username']);
             //prd($post['xml_subscriber_id']);
             switch ($post['xml_subscriber_id']) {
                 //ciirus subscriber synchronization code
                 case 1:
                     $res = new Ciirus($_supplierData['ciirus']['subscriber_api_username'], $_supplierData['ciirus']['subscriber_api_password']);
                     //filter parameters
                     $arr['propertyId'] = $xml_property_id;
                     $res->getProperties($arr, 0, true, true, true);
                     //subscriber name
                     $data['xml_subscriber_id'] = $post['xml_subscriber_id'];
                     //get heading
                     $heading = $res->getHeading($xml_property_id);
                     $data['xml_heading'] = $heading;
                     //get description part
                     $description = $res->getDescription($xml_property_id);
                     $data['xml_description'] = $description;
                     //get features
                     $features = $res->getFeatures($xml_property_id);
                     $data['xml_features'] = $features;
                     //get community
                     $community = $res->getCommunity($xml_property_id);
                     $data['xml_community'] = $community;
                     //get rates
                     $rates = $res->getStructuredPropertyRates($xml_property_id, $markUp);
                     $data['xml_rating'] = $rates;
                     $markUp = $post['xml_rate_markup'][$key];
                     //saving rates
                     $rateArr = $res->getCalendarPropertyRates($xml_property_id, $markUp);
                     if (!empty($rateArr) && count($rateArr) > 0 && !$this->debug) {
                         $db->delete(CAL_RATE, "property_id = " . $property_id);
                     }
                     foreach ($rateArr as $rateK => $rateV) {
                         $rateData = array();
                         $rateData['property_id'] = $property_id;
                         $rateData['date_from'] = $rateV['date_from'];
                         $rateData['date_to'] = $rateV['date_to'];
                         $rateData['nights'] = $rateV['nights'];
                         $rateData['prate'] = $rateV['prate'];
                         if (!$this->debug) {
                             $db->save(CAL_RATE, $rateData);
                         }
                     }
                     //get  extras
                     $extra = $res->getExtras1($xml_property_id);
                     //poool heating extra
                     $poolExtra = $res->getExtras($xml_property_id);
                     $poolC = count($extra);
                     if ($extra['PoolHeatIncludedInPrice']) {
                         //                            $extra[$poolC]['FlatFeeAmount'] = 'Flat amount';
                         //                            $extra[$poolC]['FlatFee'] = true;
                         //                            $extra[$poolC]['DailyFee'] = false;
                     } else {
                         $extra[$poolC]['DailyFeeAmount'] = $poolExtra['DailyCharge'];
                         $extra[$poolC]['DailyFee'] = true;
                         $extra[$poolC]['FlatFee'] = false;
                         $extra[$poolC]['ItemDescription'] = 'Pool Heating';
                         $extra[$poolC]['Mandatory'] = false;
                     }
                     if (!empty($extra)) {
                         $data['xml_extras'] = serialize($extra);
                         //delete older entries if exist
                         //                            if(!$this->debug)
                         //                            $db->delete(EXTRAS, "property_id = " . $property_id);
                         //
                         //older method commented
                         //                            $dataExtra = array();
                         //                            $dataExtra['property_id'] = $property_id;
                         //                            $dataExtra['ename'] = "Pool Heating";
                         //                            $dataExtra['eprice'] = $extra['DailyCharge'];
                         //                            $dataExtra['etype'] = '0';
                         //                            $dataExtra['stay_type'] = '0';
                         //
                         //                            $db->save(EXTRAS, $dataExtra);
                         //saving extras
                         //                            foreach ($extra as $exKey => $exVal)
                         //                            {
                         //                                $dataExtra = array();
                         //                                $dataExtra['property_id'] = $property_id;
                         //                                $dataExtra['ename'] = $exVal["ItemDescription"];
                         //                                $dataExtra['eprice'] = $exVal['FlatFee']=='true'?$exVal['FlatFeeAmount']:$exVal['DailyFeeAmount'];
                         //                                $dataExtra['etype'] = $exVal['Mandatory']=='true'?'1':'0';
                         //                                $dataExtra['stay_type'] = $exVal['DailyFee']=='false'?'1':'0';
                         //
                         //                                if(!$this->debug)
                         //                                $db->save(EXTRAS, $dataExtra);
                         //                            }
                     }
                     $data['xml_property_id'] = $xml_property_id;
                     $condition = " id= " . $property_id;
                     if (!$this->debug) {
                         $result = $db->modify(PROPERTY, $data, $condition);
                     }
                     //grab images functionality
                     $images = $res->getImageList($xml_property_id);
                     //prd($images);
                     if (count($images) > 0 && is_array($images)) {
                         //delete older images
                         $galleryArr = $db->runQuery("select * from " . GALLERY . " where property_id='" . $property_id . "' ");
                         foreach ($galleryArr as $galKey => $galVal) {
                             @unlink(SITE_ROOT . "images/property/" . $galVal['image_name']);
                             $db->delete(GALLERY, 'gallery_id = ' . $galVal['gallery_id']);
                         }
                     }
                     foreach ($images as $iKey => $iVal) {
                         //pr($iVal);
                         $file_name = explode("/", $iVal);
                         $file_name = urldecode(time() . "_" . end($file_name));
                         $file_name = str_replace(' ', '_', $file_name);
                         if (!$this->debug) {
                             $contentOrFalseOnFailure = file_get_contents($iVal);
                         }
                         if (!$this->debug) {
                             $byteCountOrFalseOnFailure = file_put_contents(SITE_ROOT . "images/property/" . $file_name, $contentOrFalseOnFailure);
                         }
                         //saving data in database
                         $data_image = array();
                         $data_image['image_name'] = $file_name;
                         $data_image['property_id'] = $property_id;
                         //image caption for all location - bedroom - type
                         //                            if ($iKey == 0)
                         $data_image['image_title'] = $caption;
                         if (!$this->debug) {
                             $db->save(GALLERY, $data_image);
                         }
                     }
                     //prd($images);
                     //save the list of booked dates
                     $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);
                         }
                     }
                     break;
                     // global resort home subscriber synchronization code
                 // global resort home subscriber synchronization code
                 case 2:
                     $res = new Globalresorthomes($_supplierData['globalresorthomes']['subscriber_url']);
                     $res->getWebsite($xml_property_id);
                     //grab images functionality
                     $images = $res->getImageList($xml_property_id);
                     $url = $_supplierData['globalresorthomes']['subscriber_secondary_url'];
                     $data = array();
                     $data['xml_subscriber_id'] = $post['xml_subscriber_id'];
                     $data['xml_property_id'] = $post['xml_property_id'];
                     //get heading of the property
                     $heading = $res->getHeading($xml_property_id);
                     $data['xml_heading'] = $heading;
                     //get description part of the website
                     $description = $res->getDescription($xml_property_id);
                     $data['xml_description'] = $description;
                     //get features of the property
                     $features = $res->getFeatures($xml_property_id);
                     $data['xml_features'] = $features;
                     $data['xml_extras'] = '';
                     $data['xml_community'] = '';
                     //get rates
                     $rate = $res->getRates($xml_property_id, $url);
                     $data['xml_rating'] = $rate;
                     //get booked dates
                     $reservation = $res->getReservations($xml_property_id, $url);
                     //                        $data['xml_property_id'] = $post['xml_property_id'];
                     $data['xml_property_id'] = $xml_property_id;
                     $condition = " id= " . $property_id;
                     if (!$this->debug) {
                         $result = $db->modify(PROPERTY, $data, $condition);
                     }
                     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);
                             }
                         }
                     }
                     if (count($images) > 0 && is_array($images)) {
                         //delete older images
                         $galleryArr = $db->runQuery("select * from " . GALLERY . " where property_id='" . $property_id . "' ");
                         foreach ($galleryArr as $galKey => $galVal) {
                             @unlink(SITE_ROOT . "images/property/" . $galVal['image_name']);
                             $db->delete(GALLERY, 'gallery_id = ' . $galVal['gallery_id']);
                         }
                     }
                     foreach ($images as $iKey => $iVal) {
                         //pr($iVal);
                         //$file_name = explode("/", $iVal);
                         $file_name = urldecode(time() . "_" . $iVal);
                         $file_name = str_replace(' ', '_', $file_name);
                         if (!$this->debug) {
                             $validImage = getimagesize($_supplierData['globalresorthomes']['subscriber_image_url'] . '/' . $iVal);
                             if (count($validImage) && is_array($validImage) && !empty($validImage)) {
                                 $contentOrFalseOnFailure = file_get_contents($_supplierData['globalresorthomes']['subscriber_image_url'] . '/' . $iVal);
                             } else {
                                 $VAR = explode("_", $iVal);
                                 $VAR = $VAR[0];
                                 $secondary_img_url = str_replace('[VAR]', $VAR, $_supplierData['globalresorthomes']['subscriber_image_secondary_url']);
                                 $contentOrFalseOnFailure = file_get_contents($secondary_img_url . '/' . $iVal);
                             }
                         }
                         if (!$this->debug) {
                             $byteCountOrFalseOnFailure = file_put_contents(SITE_ROOT . "images/property/" . $file_name, $contentOrFalseOnFailure);
                         }
                         //saving data in database
                         $data_image = array();
                         $data_image['image_name'] = $file_name;
                         $data_image['property_id'] = $property_id;
                         //                            if ($iKey == 0)
                         $data_image['image_title'] = $caption;
                         if (!$this->debug) {
                             $db->save(GALLERY, $data_image);
                         }
                     }
                     break;
                 case 3:
                     $res = new Contempovacation($_supplierData['contempovacation']['subscriber_url']);
                     $res->getWebsite($xml_property_id);
                     //
                     $data = array();
                     $data['xml_subscriber_id'] = $post['xml_subscriber_id'];
                     //                        $data['xml_property_id'] = $post['xml_property_id'];
                     $data['xml_property_id'] = $xml_property_id;
                     //get heading of the property
                     $heading = $res->getHeading($xml_property_id);
                     $data['xml_heading'] = $heading;
                     //get description part of the website
                     $description = $res->getDescription($xml_property_id);
                     $data['xml_description'] = $description;
                     //get features of the property
                     $features = $res->getFeatures($xml_property_id);
                     $data['xml_features'] = $features;
                     $data['xml_extras'] = '';
                     $data['xml_community'] = '';
                     $data['xml_rating'] = '';
                     $data['xml_property_id'] = $post['xml_property_id'];
                     $condition = " id= " . $property_id;
                     if (!$this->debug) {
                         $result = $db->modify(PROPERTY, $data, $condition);
                     }
                     $images = $res->getImageList($xml_property_id);
                     if (count($images) > 0 && is_array($images) && !$this->debug) {
                         //delete older images
                         $galleryArr = $db->runQuery("select * from " . GALLERY . " where property_id='" . $property_id . "' ");
                         foreach ($galleryArr as $galKey => $galVal) {
                             @unlink(SITE_ROOT . "images/property/" . $galVal['image_name']);
                             $db->delete(GALLERY, 'gallery_id = ' . $galVal['gallery_id']);
                         }
                     }
                     foreach ($images as $iKey => $iVal) {
                         //$file_name = explode("/", $iVal);
                         $endfile = explode("/", $iVal);
                         $endfile = array_pop($endfile);
                         $file_name = urldecode(time() . "_" . $endfile);
                         $file_name = str_replace(' ', '_', $file_name);
                         if (!$this->debug) {
                             //$validImage = getimagesize($iVal);
                             $contentOrFalseOnFailure = file_get_contents("{$iVal}");
                         }
                         if (!$this->debug) {
                             $byteCountOrFalseOnFailure = file_put_contents(SITE_ROOT . "images/property/" . $file_name, $contentOrFalseOnFailure);
                         }
                         //saving data in database
                         $data_image = array();
                         $data_image['image_name'] = $file_name;
                         $data_image['property_id'] = $property_id;
                         //                            if ($iKey == 0)
                         $data_image['image_title'] = $caption;
                         if (!$this->debug) {
                             $db->save(GALLERY, $data_image);
                         }
                     }
                     //get booked dates
                     $reservation = $res->getReservations($xml_property_id, $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);
                             }
                         }
                     }
                     break;
                 case 4:
                     $res = new Fairwaysflorida($_supplierData['fairwaysflorida']['subscriber_url']);
                     $res->getWebsite($xml_property_id);
                     //
                     $data = array();
                     $data['xml_subscriber_id'] = $post['xml_subscriber_id'];
                     $data['xml_property_id'] = $post['xml_property_id'];
                     //get heading of the property
                     $heading = $res->getHeading($xml_property_id);
                     $data['xml_heading'] = $heading;
                     //get description part of the website
                     $description = $res->getDescription($xml_property_id);
                     $data['xml_description'] = $description;
                     //get features of the property
                     $features = $res->getFeatures($xml_property_id);
                     $data['xml_features'] = $features;
                     $data['xml_extras'] = '';
                     $data['xml_community'] = '';
                     $data['xml_rating'] = '';
                     $data['xml_property_id'] = $post['xml_property_id'];
                     $condition = " id= " . $property_id;
                     if (!$this->debug) {
                         $result = $db->modify(PROPERTY, $data, $condition);
                     }
                     //=== images process ====
                     $images = $res->getImageList($xml_property_id);
                     if (count($images) > 0 && is_array($images) && !$this->debug) {
                         //delete older images
                         $galleryArr = $db->runQuery("select * from " . GALLERY . " where property_id='" . $property_id . "' ");
                         foreach ($galleryArr as $galKey => $galVal) {
                             @unlink(SITE_ROOT . "images/property/" . $galVal['image_name']);
                             $db->delete(GALLERY, 'gallery_id = ' . $galVal['gallery_id']);
                         }
                     }
                     foreach ($images as $iKey => $iVal) {
                         //$file_name = explode("/", $iVal);
                         $endfile = explode("/", $iVal);
                         $endfile = array_pop($endfile);
                         $file_name = urldecode(time() . "_" . $endfile);
                         $file_name = str_replace(' ', '_', $file_name);
                         if (!$this->debug) {
                             //$validImage = getimagesize($iVal);
                             $contentOrFalseOnFailure = file_get_contents("http:{$iVal}");
                         }
                         if (!$this->debug) {
                             $byteCountOrFalseOnFailure = file_put_contents(SITE_ROOT . "images/property/" . $file_name, $contentOrFalseOnFailure);
                         }
                         //saving data in database
                         $data_image = array();
                         $data_image['image_name'] = $file_name;
                         $data_image['property_id'] = $property_id;
                         //                        if ($iKey == 0)
                         //                            $data_image['image_title'] = $heading;
                         $data_image['image_title'] = $caption;
                         if (!$this->debug) {
                             $db->save(GALLERY, $data_image);
                         }
                     }
                     //===== availability dates
                     $reservation = $res->getBookedDates($post['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) {
                         $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);
                         }
                     }
                     break;
                 case 5:
                     $res = new Casiola($_supplierData['casiola']['subscriber_url']);
                     $res->getWebsite($xml_property_id);
                     //grab images functionality
                     $images = $res->getImageList($xml_property_id);
                     //echo "<pre>"; print_r($images); echo "</pre>";
                     $url = $_supplierData['casiola']['subscriber_secondary_url'];
                     $data = array();
                     $data['xml_subscriber_id'] = $post['xml_subscriber_id'];
                     $data['xml_property_id'] = $post['xml_property_id'];
                     //get heading of the property
                     $heading = $res->getHeading($xml_property_id);
                     $data['xml_heading'] = $heading;
                     //get description part of the website
                     $description = $res->getDescription($xml_property_id);
                     $data['xml_description'] = $description;
                     //get features of the property
                     $features = $res->getFeatures($xml_property_id);
                     $data['xml_features'] = $features;
                     $data['xml_extras'] = '';
                     $data['xml_community'] = '';
                     //get rates
                     $rate = $res->getRates($xml_property_id, $url);
                     $data['xml_rating'] = $rate;
                     //get booked dates
                     $reservation = $res->getReservations($xml_property_id, $url);
                     $data['xml_property_id'] = $post['xml_property_id'];
                     $condition = " id= " . $property_id;
                     if (!$this->debug) {
                         $result = $db->modify(PROPERTY, $data, $condition);
                     }
                     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($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['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                     }
                     if (count($images) > 0 && is_array($images)) {
                         //delete older images
                         $galleryArr = $db->runQuery("select * from " . GALLERY . " where property_id='" . $property_id . "' ");
                         foreach ($galleryArr as $galKey => $galVal) {
                             @unlink(SITE_ROOT . "images/property/" . $galVal['image_name']);
                             $db->delete(GALLERY, 'gallery_id = ' . $galVal['gallery_id']);
                         }
                     }
                     foreach ($images as $iKey => $iVal) {
                         //pr($iVal);
                         //$file_name = explode("/", $iVal);
                         $file_name = urldecode(time() . "_" . $iVal);
                         $file_name = str_replace(' ', '_', $file_name);
                         if (!$this->debug) {
                             $validImage = getimagesize($_supplierData['casiola']['subscriber_image_url'] . '/' . $iVal);
                             if (count($validImage) && is_array($validImage) && !empty($validImage)) {
                                 $contentOrFalseOnFailure = file_get_contents($_supplierData['casiola']['subscriber_image_url'] . '/' . $iVal);
                             } else {
                                 $VAR = explode("_", $iVal);
                                 $VAR = $VAR[0];
                                 $secondary_img_url = str_replace('[VAR]', $VAR, $_supplierData['casiola']['subscriber_image_secondary_url']);
                                 $contentOrFalseOnFailure = file_get_contents($secondary_img_url . '/' . $iVal);
                             }
                         }
                         if (!$this->debug) {
                             $byteCountOrFalseOnFailure = file_put_contents(SITE_ROOT . "images/property/" . $file_name, $contentOrFalseOnFailure);
                         }
                         //saving data in database
                         $data_image = array();
                         $data_image['image_name'] = $file_name;
                         $data_image['property_id'] = $property_id;
                         //                        if ($iKey == 0)
                         //                            $data_image['image_title'] = $heading;
                         $data_image['image_title'] = $caption;
                         if (!$this->debug) {
                             $db->save(GALLERY, $data_image);
                         }
                     }
                     break;
                 case 6:
                     $res = new Resorthomesofflorida($_supplierData['resorthomesofflorida']['subscriber_url']);
                     $res->getWebsite($xml_property_id);
                     //grab images functionality
                     $images = $res->getImageList($xml_property_id);
                     $url = $_supplierData['resorthomesofflorida']['subscriber_secondary_url'];
                     $data = array();
                     $data['xml_subscriber_id'] = $post['xml_subscriber_id'];
                     $data['xml_property_id'] = $post['xml_property_id'];
                     //get heading of the property
                     $heading = $res->getHeading($xml_property_id);
                     $data['xml_heading'] = $heading;
                     //get description part of the website
                     $description = $res->getDescription($xml_property_id);
                     $data['xml_description'] = $description;
                     //get features of the property
                     $features = $res->getFeatures($xml_property_id);
                     $data['xml_features'] = $features;
                     $data['xml_extras'] = '';
                     $data['xml_community'] = '';
                     //get rates
                     $rate = $res->getRates($xml_property_id, $url);
                     $data['xml_rating'] = $rate;
                     //get booked dates
                     $reservation = $res->getReservations($xml_property_id, $url);
                     $data['xml_property_id'] = $post['xml_property_id'];
                     $condition = " id= " . $property_id;
                     if (!$this->debug) {
                         $result = $db->modify(PROPERTY, $data, $condition);
                     }
                     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($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['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                     }
                     if (count($images) > 0 && is_array($images)) {
                         //delete older images
                         $galleryArr = $db->runQuery("select * from " . GALLERY . " where property_id='" . $property_id . "' ");
                         foreach ($galleryArr as $galKey => $galVal) {
                             @unlink(SITE_ROOT . "images/property/" . $galVal['image_name']);
                             $db->delete(GALLERY, 'gallery_id = ' . $galVal['gallery_id']);
                         }
                     }
                     foreach ($images as $iKey => $iVals) {
                         $file_names = explode("/", $iVals);
                         $iVal = end($file_names);
                         $path = '/' . $file_names[0] . '/' . $file_names[1] . '/';
                         $file_name = urldecode(time() . "_" . $iVal);
                         $file_name = str_replace(' ', '_', $file_name);
                         if (!$this->debug) {
                             $validImage = getimagesize($_supplierData['resorthomesofflorida']['subscriber_image_url'] . $path . $iVal);
                             if (count($validImage) && is_array($validImage) && !empty($validImage)) {
                                 $contentOrFalseOnFailure = file_get_contents($_supplierData['resorthomesofflorida']['subscriber_image_url'] . $path . $iVal);
                             } else {
                                 $VAR = explode("_", $iVal);
                                 $VAR = $VAR[0];
                                 $secondary_img_url = str_replace('[VAR]', $VAR, $_supplierData['resorthomesofflorida']['subscriber_image_secondary_url']);
                                 $contentOrFalseOnFailure = file_get_contents($secondary_img_url . $path . $iVal);
                             }
                         }
                         if (!$this->debug) {
                             $byteCountOrFalseOnFailure = file_put_contents(SITE_ROOT . "images/property/" . $file_name, $contentOrFalseOnFailure);
                         }
                         //saving data in database
                         $data_image = array();
                         $data_image['image_name'] = $file_name;
                         $data_image['property_id'] = $property_id;
                         $data_image['image_title'] = $caption;
                         if (!$this->debug) {
                             $db->save(GALLERY, $data_image);
                         }
                     }
                     break;
                 case 7:
                     $res = new Ellisexclusivevillas($_supplierData['ellisexclusivevillas']['subscriber_url']);
                     $res->getWebsite($xml_property_id);
                     //grab images functionality
                     $images = $res->getImageList($xml_property_id);
                     //echo "<pre>"; print_r($images); echo "</pre>";
                     $url = $_supplierData['ellisexclusivevillas']['subscriber_secondary_url'];
                     $data = array();
                     $data['xml_subscriber_id'] = $post['xml_subscriber_id'];
                     $data['xml_property_id'] = $post['xml_property_id'];
                     //get heading of the property
                     $heading = $res->getHeading($xml_property_id);
                     $data['xml_heading'] = $heading;
                     //get description part of the website
                     $description = $res->getDescription($xml_property_id);
                     $data['xml_description'] = $description;
                     //get features of the property
                     $features = $res->getFeatures($xml_property_id);
                     $data['xml_features'] = $features;
                     $data['xml_extras'] = '';
                     $data['xml_community'] = '';
                     //get rates
                     $rate = $res->getRates($xml_property_id, $url);
                     $data['xml_rating'] = $rate;
                     //get booked dates
                     $reservation = $res->getReservations($xml_property_id, $url);
                     $data['xml_property_id'] = $post['xml_property_id'];
                     $condition = " id= " . $property_id;
                     if (!$this->debug) {
                         $result = $db->modify(PROPERTY, $data, $condition);
                     }
                     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($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['cal_status'] = '0';
                             if (!$this->debug) {
                                 $db->save(CAL_AVAIL, $data_cal);
                             }
                         }
                     }
                     if (count($images) > 0 && is_array($images)) {
                         //delete older images
                         $galleryArr = $db->runQuery("select * from " . GALLERY . " where property_id='" . $property_id . "' ");
                         foreach ($galleryArr as $galKey => $galVal) {
                             @unlink(SITE_ROOT . "images/property/" . $galVal['image_name']);
                             $db->delete(GALLERY, 'gallery_id = ' . $galVal['gallery_id']);
                         }
                     }
                     foreach ($images as $iKey => $iVal) {
                         //pr($iVal);
                         //$file_name = explode("/", $iVal);
                         $file_name = urldecode(time() . "_" . $iVal);
                         $file_name = str_replace(' ', '_', $file_name);
                         if (!$this->debug) {
                             $validImage = getimagesize($_supplierData['ellisexclusivevillas']['subscriber_image_url'] . '/' . $iVal);
                             if (count($validImage) && is_array($validImage) && !empty($validImage)) {
                                 $contentOrFalseOnFailure = file_get_contents($_supplierData['ellisexclusivevillas']['subscriber_image_url'] . '/' . $iVal);
                             } else {
                                 $VAR = explode("_", $iVal);
                                 $VAR = $VAR[0];
                                 $secondary_img_url = str_replace('[VAR]', $VAR, $_supplierData['ellisexclusivevillas']['subscriber_image_secondary_url']);
                                 $contentOrFalseOnFailure = file_get_contents($secondary_img_url . '/' . $iVal);
                             }
                         }
                         if (!$this->debug) {
                             $byteCountOrFalseOnFailure = file_put_contents(SITE_ROOT . "images/property/" . $file_name, $contentOrFalseOnFailure);
                         }
                         //saving data in database
                         $data_image = array();
                         $data_image['image_name'] = $file_name;
                         $data_image['property_id'] = $property_id;
                         //                        if ($iKey == 0)
                         //                            $data_image['image_title'] = $heading;
                         $data_image['image_title'] = $caption;
                         if (!$this->debug) {
                             $db->save(GALLERY, $data_image);
                         }
                     }
                     break;
                 default:
                     echo "Please choose proper subscriber first!!";
                     die;
             }
         }
         $this->_redirect("property/editproperty/pptyId/" . $property_id . "/step/10");
     }
     echo "Please enter property id";
     die;
 }