예제 #1
0
 public function editAction()
 {
     $this->view->title = "State - Edit";
     $this->view->headTitle($this->view->title);
     $id = $this->_getParam('id');
     $model1 = new Application_Model_State();
     $model = $model1->find($id);
     $options['name'] = $model->getName();
     $options['regionId'] = $model->getRegionId();
     $request = $this->getRequest();
     $form = new Admin_Form_State();
     $form->populate($options);
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($form->isValid($options)) {
             $model->setOptions($options);
             $model->save($model);
             $this->view->successMsg = "State Id : {$model->getId()}' has been updated successfully!";
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
예제 #2
0
 public function EditState(array $data)
 {
     try {
         $form = $this->getEditStateForm();
         if ($form->isValid($data)) {
             $mapper = new Application_Model_StateDataMapper();
             $stateObj = new Application_Model_State();
             //				$countryflag = $form->getValue('countryflag');
             if ($form->countryflag) {
                 $flagadapter = $form->countryflag->getTransferAdapter();
                 $countryname = trim($data['editcode']);
                 $paths = $this->UploadCountryflag($flagadapter, $countryname);
                 $flagpath = null;
             }
             if ($paths) {
                 $flagpath .= '<img src=' . $paths['flagpath'] . ' height="16">&nbsp;&nbsp;' . $data['editdesc'];
             }
             $formData = $form->getValues($data);
             $dialcode = "+" . $formData['editdialcode'];
             $stateObj->setId($formData['editstateid']);
             $stateObj->setCode($formData['editcode']);
             $stateObj->setDescription($formData['editdesc']);
             $stateObj->setCurrency_code($formData['editcurrency']);
             $stateObj->setTimezone($formData['edittimezone']);
             $stateObj->setCountry_dial_code($dialcode);
             if ($flagpath) {
                 $stateObj->setCountry_flag($flagpath);
             }
             $statestatus = $mapper->EditState($stateObj);
             return $statestatus;
         } else {
             $formData = $form->getValues();
             $form->populate($data);
             return false;
         }
     } catch (Exception $ex) {
         Rdine_Logger_FileLogger::info($ex->getMessage());
         throw new Exception($ex->getMessage());
     }
 }
예제 #3
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);
 }
예제 #4
0
파일: State.php 프로젝트: riteshsahu1981/we
 private function setModel($row)
 {
     $parent = $row->findParentRow('Application_Model_DbTable_Region', 'Region');
     $model = new Application_Model_State();
     $model->setId($row->id)->setName($row->name)->setRegionId($row->region_id)->setRegionName($parent->name);
     return $model;
 }