Ejemplo n.º 1
0
 public function editAction()
 {
     $this->view->title = "Region - Edit";
     $this->view->headTitle($this->view->title);
     $id = $this->_getParam('id');
     $model1 = new Application_Model_Region();
     $model = $model1->find($id);
     $options['name'] = $model->getName();
     $options['countryId'] = $model->getCountryId();
     $options['continentId'] = $model->getContinentId();
     $request = $this->getRequest();
     $form = new Admin_Form_Region();
     $form->populate($options);
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($form->isValid($options)) {
             $model->setOptions($options);
             $model->save($model);
             $this->view->successMsg = "Region Id : {$model->getId()}' has been updated successfully!";
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
Ejemplo n.º 2
0
 public function init()
 {
     $this->addElement('text', 'name', array('label' => 'State Name :', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the state name')))), 'decorators' => $this->elementDecorators));
     $region = new Application_Model_Region();
     $arrRegion = $region->getRegion("--select---");
     $this->addElement('select', 'regionId', array('label' => 'Region :', 'style' => 'width: 100%;', 'TABINDEX' => '6', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select region')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrRegion));
     $this->addElement('submit', 'cmdSubmit', array('required' => false, 'ignore' => true, 'label' => 'Save', 'decorators' => $this->buttonDecorators));
 }
Ejemplo n.º 3
0
 public function getCampaign($camId)
 {
     try {
         $result = array();
         $descform = $this->getEditCampImageForm();
         $planform = $this->getEditCampPlanDetailsForm();
         $locationform = $this->getEditCampPlanLocationForm();
         $scid = $camId;
         $spoDetails = $this->GetCampaignById($scid);
         $formValues = array('campId' => $scid, 'campaignName' => $scid, 'priceId' => $spoDetails->sppid, 'campName' => $spoDetails->scad_name, 'campaignDesc' => $spoDetails->scdesc, 'campaignWebsite' => $spoDetails->scweb_link, 'campImage' => $spoDetails->scimage);
         $descform->populate($formValues);
         //			$descform->campaignDesc->setValue($spoDetails->scad_name);
         $result['descForm'] = $descform;
         $formValues = array('campId' => $scid, 'campaignStartDate' => date('m-d-Y', strtotime($spoDetails->sppstart_date)), 'campaignEndDate' => date('m-d-Y', strtotime($spoDetails->sppend_date)), 'campPricePlan' => $spoDetails->sppplan_name, 'priceId' => $spoDetails->sppid, 'campaignTime' => $spoDetails->timecode, 'amount' => substr($spoDetails->sppamount, 1));
         $planform->populate($formValues);
         $result['planForm'] = $planform;
         $formValues = array('campId' => $scid, 'priceId' => $spoDetails->sppid, 'state' => $spoDetails->sppstate_id, 'region' => $spoDetails->sppregion_id, 'city' => $spoDetails->sppcity_id);
         $locationform->populate($formValues);
         $cityBd = array();
         $regionBd = array();
         if ($spoDetails->sppstate_id) {
             $regionmapper = new Application_Model_RegionDataMapper();
             $regionObj = new Application_Model_Region();
             $regionObj->setStateId($spoDetails->sppstate_id);
             $region = $regionmapper->getRegionByStateId($regionObj);
             $regionBd = $region->getRegionList();
             $locationform->region->addMultiOptions($regionBd);
         }
         if ($spoDetails->sppregion_id) {
             $citymapper = new Application_Model_CityDataMapper();
             $cityObj = new Application_Model_City();
             $cityObj->setRegionId($spoDetails->sppregion_id);
             $city = $citymapper->getCityByRegionId($cityObj);
             $cityBd = $city->getCityList();
             $locationform->city->addMultiOptions($cityBd);
         }
         $result['locationForm'] = $locationform;
         //$form->region->addMultioptions($regionBd);
         //$form->city->addMultioptions($cityBd);
         return $result;
     } catch (Exception $ex) {
         Rdine_Logger_FileLogger::info($ex->getMessage());
         throw new Exception($ex->getMessage());
     }
 }
Ejemplo n.º 4
0
 public function xmlAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     echo "<pre>";
     $filename = "data/sample - Chiang Mai.xml";
     $xml_parser = new Base_Xml_Parser(null, $filename);
     $continentName = $xml_parser->Data['identification']['geoTag1'];
     $countryName = $xml_parser->Data['identification']['geoTag2'];
     $cityName = $xml_parser->Data['identification']['geoTag3'];
     $regionName = $cityName;
     $stateName = $cityName;
     //----insert into continent
     $continent_id = 0;
     $continentM = new Application_Model_Continent();
     $continent = $continentM->fetchRow("name='{$continentName}'");
     if (false === $continent) {
         $continentM->setName($continentName);
         $continent_id = $continentM->save();
     } else {
         $continent_id = $continent->getId();
     }
     //--------------------------
     //----insert into country
     $country_id = 0;
     $countryM = new Application_Model_Country();
     $country = $countryM->fetchRow("name='{$countryName}' and continent_id='{$continent_id}'");
     if (false === $country) {
         $countryM->setName($countryName);
         $countryM->setContinentId($continent_id);
         $country_id = $countryM->save();
     } else {
         $country_id = $country->getId();
     }
     //-------------------------------
     ///------insert into region
     $region_id = 0;
     $regionM = new Application_Model_Region();
     $region = $regionM->fetchRow("name='{$regionName}' and country_id='{$country_id}'");
     if (false === $region) {
         $regionM->setName($regionName);
         $regionM->setCountryId($country_id);
         $region_id = $regionM->save();
     } else {
         $region_id = $region->getId();
     }
     //------------------------
     ///------insert into state
     $state_id = 0;
     $stateM = new Application_Model_State();
     $state = $stateM->fetchRow("name='{$stateName}' and region_id='{$region_id}'");
     if (false === $state) {
         $stateM->setName($stateName);
         $stateM->setRegionId($region_id);
         $state_id = $stateM->save();
     } else {
         $state_id = $state->getId();
     }
     //------------------------
     ///------insert into city
     $city_id = 0;
     $cityM = new Application_Model_City();
     $city = $cityM->fetchRow("name='{$cityName}' and country_id='{$state_id}'");
     if (false === $city) {
         $cityM->setName($cityName);
         $cityM->setCountryId($country_id);
         $city_id = $cityM->save();
     } else {
         $city_id = $city->getId();
     }
     //------------------------
     if ($continent_id > 0 && $country_id > 0 && $city_id > 0) {
         //it is city
         $locationType = "city";
         $locationId = $city_id;
     } else {
         if ($continent_id > 0 && $country_id > 0) {
             //it is country
             $locationType = "country";
             $locationId = $country_id;
         } else {
             if ($continent_id > 0) {
                 //it is continent
                 $locationType = "continent";
                 $locationId = $continent_id;
             }
         }
     }
     ///////////Remove/////////
     $destinationM = new Application_Model_Destination();
     $destinationM->delete();
     $experiencesM = new Application_Model_Experiences();
     $experiencesM->delete();
     $practicalitiesM = new Application_Model_Practicalities();
     $practicalitiesM->delete();
     //------------------------------
     $title = $xml_parser->Data['content']['title'];
     $introduction = $xml_parser->Data['content']['introduction'];
     $destinationM = new Application_Model_Destination();
     $destinationM->setTitle($title);
     $destinationM->setIntroduction($introduction);
     $destinationM->setLocationId($locationId);
     $destinationM->setLocationType($locationType);
     $destination_id = $destinationM->save();
     foreach ($xml_parser->Data['content']['experiences'] as $experiences) {
         foreach ($experiences as $_item) {
             $experiencesM = new Application_Model_Experiences();
             $experiencesM->setTitle($_item['title']);
             $experiencesM->setDestinationId($destination_id);
             $experiencesM->setCopy($_item['copy']);
             $experiencesM->save();
         }
     }
     foreach ($xml_parser->Data['content']['practicalities'] as $practicalities) {
         foreach ($practicalities as $_item) {
             $practicalitiesM = new Application_Model_Practicalities();
             $practicalitiesM->setTitle($_item['title']);
             $practicalitiesM->setDestinationId($destination_id);
             $practicalitiesM->setCopy($_item['copy']);
             $practicalitiesM->save();
         }
     }
     //print_r($xml_parser->Data);
 }
Ejemplo n.º 5
0
 public function getRegion($option = null)
 {
     $obj = new Application_Model_Region();
     $entries = $obj->fetchAll();
     $arrRegion = array();
     if (!is_null($option)) {
         $arrRegion[''] = $option;
     }
     foreach ($entries as $entry) {
         $arrRegion[$entry->getId()] = $entry->getName();
     }
     return $arrRegion;
 }
Ejemplo n.º 6
0
 public function xmlAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $db = Zend_Registry::get("db");
     $sanitizeM = new Base_Sanitize();
     $directory = "data/zone/XML/";
     if (!($dp = opendir($directory))) {
         die("Cannot open {$directory}.");
     }
     $ctr = 0;
     //truncate tables
     $db->query("TRUNCATE TABLE destination");
     $db->query("TRUNCATE TABLE experiences");
     $db->query("TRUNCATE TABLE practicalities");
     $db->query("TRUNCATE TABLE dont_leave_without");
     $db->query("TRUNCATE TABLE lonely_planet_country");
     $db->query("TRUNCATE TABLE eat_sleep_drink");
     $db->query("TRUNCATE TABLE log");
     $db->query("TRUNCATE TABLE error_log");
     $db->query("TRUNCATE TABLE area");
     $db->query("TRUNCATE TABLE region");
     $db->query("TRUNCATE TABLE continent");
     $db->query("TRUNCATE TABLE country");
     $db->query("TRUNCATE TABLE city");
     $db->query("TRUNCATE TABLE seo_url");
     //------------------------------
     while ($filename = readdir($dp)) {
         $res = $db->fetchAll("select * from log where message='{$filename}'");
         if (is_dir($filename)) {
             continue;
         } else {
             if ($filename != '.' && $filename != '..' && empty($res)) {
                 $file_path = $directory . $filename;
                 $data['message'] = $filename;
                 $data['log_start'] = date("Y-m-d H:i:s");
                 $log_id = $db->insert("log", $data);
                 $xml_parser = new Base_Xml_Parser(null, $file_path);
                 $continentName = "";
                 if (isset($xml_parser->Data['identification']['geoTag1'])) {
                     $continentName = $sanitizeM->clearInputs($xml_parser->Data['identification']['geoTag1']);
                 }
                 $countryName = "";
                 if (isset($xml_parser->Data['identification']['geoTag2'])) {
                     $countryName = $sanitizeM->clearInputs($xml_parser->Data['identification']['geoTag2']);
                 }
                 $cityName = "";
                 if (isset($xml_parser->Data['identification']['geoTag3'])) {
                     $cityName = $sanitizeM->clearInputs($xml_parser->Data['identification']['geoTag3']);
                 }
                 $regionName = $cityName;
                 $areaName = $cityName;
                 //----insert into continent
                 $continent_id = 0;
                 if ($continentName != "") {
                     $continentM = new Application_Model_Continent();
                     $continent = $continentM->fetchRow("name='{$continentName}'");
                     if (false === $continent) {
                         $continentM->setName($continentName);
                         $continent_id = $continentM->save();
                     } else {
                         $continent_id = $continent->getId();
                     }
                 }
                 //--------------------------
                 //----insert into country
                 $country_id = 0;
                 if ($countryName != "") {
                     //if not exists
                     if (!$this->duplicateCountries($countryName)) {
                         $countryM = new Application_Model_Country();
                         $country = $countryM->fetchRow("name='{$countryName}' and continent_id='{$continent_id}'");
                         if (false === $country) {
                             $countryM->setName($countryName);
                             $countryM->setContinentId($continent_id);
                             $country_id = $countryM->save();
                         } else {
                             $country_id = $country->getId();
                         }
                     }
                 }
                 //-------------------------------
                 //------insert into region
                 $region_id = 0;
                 $regionM = new Application_Model_Region();
                 $region = $regionM->fetchRow("name='{$regionName}' and country_id='{$country_id}' AND continent_id='{$continent_id}'");
                 if (false === $region) {
                     $regionM->setName($regionName);
                     $regionM->setCountryId($country_id);
                     $regionM->setContinentId($continent_id);
                     $region_id = $regionM->save();
                 } else {
                     $region_id = $region->getId();
                 }
                 //------insert into city
                 $city_id = 0;
                 if ($cityName != "") {
                     $cityM = new Application_Model_City();
                     $city = $cityM->fetchRow("name='{$cityName}' and region_id='{$region_id}' AND country_id='{$country_id}' AND continent_id='{$continent_id}'");
                     if (false === $city) {
                         if ($country_id != 0) {
                             //echo "<br />File name=".$file_path;
                             $cityM->setName($cityName);
                             $cityM->setRegionId($region_id);
                             $cityM->setCountryId($country_id);
                             $cityM->setContinentId($continent_id);
                             $cityM->setFeaturedTop(0);
                             $cityM->setFeaturedOther(0);
                             $city_id = $cityM->save();
                         }
                     } else {
                         $city_id = $city->getId();
                     }
                 }
                 //------------------------
                 //------insert into area
                 $area_id = 0;
                 $areaM = new Application_Model_Area();
                 $area = $areaM->fetchRow("name='{$areaName}' and city_id='{$city_id}' and region_id='{$region_id}' AND country_id='{$country_id}' AND continent_id='{$continent_id}' ");
                 if (false === $area) {
                     $areaM->setName($areaName);
                     $areaM->setRegionId($region_id);
                     $areaM->setCountryId($country_id);
                     $areaM->setContinentId($continent_id);
                     $areaM->setCityId($city_id);
                     $area_id = $areaM->save();
                 } else {
                     $area_id = $area->getId();
                 }
                 //------------------------
                 if ($continent_id > 0 && $country_id > 0 && $city_id > 0) {
                     //it is city
                     $locationType = "city";
                     $locationId = $city_id;
                 } else {
                     if ($continent_id > 0 && $country_id > 0) {
                         //it is country
                         $locationType = "country";
                         $locationId = $country_id;
                     } else {
                         if ($continent_id > 0) {
                             //it is continent
                             $locationType = "continent";
                             $locationId = $continent_id;
                         }
                     }
                 }
                 if (isset($xml_parser->Data['content'])) {
                     $title = $sanitizeM->clearInputs($xml_parser->Data['content']['title']);
                     $introduction = "";
                     if (isset($xml_parser->Data['content']['introduction'])) {
                         $introduction = $xml_parser->Data['content']['introduction'];
                     }
                     $destinationM = new Application_Model_Destination();
                     $bankBreakerPincher = "";
                     $knowledgeArr = "";
                     //set bank breaker array to save
                     if (isset($xml_parser->Data['content']['costs'])) {
                         $bank_breaker = array();
                         $bankBreaker = array();
                         foreach ($xml_parser->Data['content']['costs'] as $breaker) {
                             $bank_breaker[] = $breaker;
                         }
                         //break into two array
                         $costItem = $bank_breaker[0];
                         $dailyBudget = $bank_breaker[1];
                         for ($cntBr = 0; $cntBr < count($costItem); $cntBr++) {
                             $bankBreaker[$costItem[$cntBr]['name']] = substr($costItem[$cntBr]['rating'], 0, strlen($costItem[$cntBr]['rating']) - 1);
                         }
                         //keep in one array
                         $bankBreakerPincher = array("bankBreaker" => $bankBreaker, "dailyBudget" => $dailyBudget);
                     }
                     if (isset($xml_parser->Data['content']['knowledge'])) {
                         $knowledgeArr = array();
                         $knowledge = $xml_parser->Data['content']['knowledge'];
                         $knowledgeArr = $knowledge['item'];
                     }
                     $destinationM->setTitle($title);
                     $destinationM->setIntroduction($introduction);
                     $destinationM->setLocationId($locationId);
                     $destinationM->setLocationType($locationType);
                     $destinationM->setBankBreaker(serialize($bankBreakerPincher));
                     $destinationM->setKnowledge(serialize($knowledgeArr));
                     $destination_id = $destinationM->save();
                     if (isset($xml_parser->Data['content']['experiences'])) {
                         foreach ($xml_parser->Data['content']['experiences'] as $experiences) {
                             foreach ($experiences as $_item) {
                                 $experiencesM = new Application_Model_Experiences();
                                 $experiencesM->setTitle($_item['title']);
                                 $experiencesM->setDestinationId($destination_id);
                                 $experiencesM->setCopy($_item['copy']);
                                 $experiencesM->save();
                             }
                         }
                     }
                     if (isset($xml_parser->Data['content']['dontLeaveWithout'])) {
                         foreach ($xml_parser->Data['content']['dontLeaveWithout'] as $dontLeaveWithout) {
                             foreach ($dontLeaveWithout as $_item) {
                                 $dontLeaveWithoutM = new Application_Model_DontLeaveWithout();
                                 $dontLeaveWithoutM->setTitle($_item['title']);
                                 $dontLeaveWithoutM->setDestinationId($destination_id);
                                 $dontLeaveWithoutM->setCopy($_item['copy']);
                                 $dontLeaveWithoutM->save();
                             }
                         }
                     }
                     if (isset($xml_parser->Data['content']['practicalities'])) {
                         foreach ($xml_parser->Data['content']['practicalities'] as $practicalities) {
                             foreach ($practicalities as $_item) {
                                 $practicalitiesM = new Application_Model_Practicalities();
                                 $practicalitiesM->setTitle($_item['title']);
                                 $practicalitiesM->setDestinationId($destination_id);
                                 $practicalitiesM->setCopy($_item['copy']);
                                 $practicalitiesM->save();
                             }
                         }
                     }
                     if (isset($xml_parser->Data['content']['eatSleepDrink'])) {
                         foreach ($xml_parser->Data['content']['eatSleepDrink'] as $eatsleepdrink) {
                             foreach ($eatsleepdrink as $_item) {
                                 $EatSleepDrinkM = new Application_Model_EatSleepDrink();
                                 $EatSleepDrinkM->setTitle($_item['title']);
                                 $EatSleepDrinkM->setDestinationId($destination_id);
                                 $EatSleepDrinkM->setBackPackerCopy($_item['backpackerCopy']);
                                 $EatSleepDrinkM->setLocalCopy($_item['localCopy']);
                                 $EatSleepDrinkM->save();
                             }
                         }
                     }
                     $data['log_end'] = date("Y-m-d H:i:s");
                     $res = $db->update("log", $data, "id='{$log_id}'");
                 }
             }
         }
     }
     //end of main while loop
 }