Example #1
0
 public function actionGetRegionPolygons()
 {
     //Попытка грузить границы регионов из mif файла
     die;
     set_time_limit(0);
     $file = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/regions2010_wgs.mif');
     preg_match_all('/REGION 1\\s+(\\d+)\\s+([-\\d\\s\\.]*)\\s+PEN/ism', $file, $matches, PREG_SET_ORDER);
     echo count($matches) . '<br/>';
     //print_r($matches);
     foreach ($matches as $i => $match) {
         echo $match[1] . '<br/>';
         if ($match[1] && $match[2]) {
             $subj = RfSubjects::model()->find('region_num=' . $match[1]);
             if ($subj && $subj->gibdd) {
                 //foreach ($subj->gibdd->areas as $item) $item->delete();
                 $areamodel = new GibddAreas();
                 $areamodel->gibdd_id = $subj->gibdd->id;
                 $lines = explode("\n", $match[2]);
                 if ($lines && $areamodel->save()) {
                     foreach ($lines as $ii => $line) {
                         $coord = explode(" ", $line);
                         if (isset($coord[0]) && isset($coord[1]) && $coord[0] && $coord[1]) {
                             $pointmodel = new GibddAreaPoints();
                             $pointmodel->lat = $coord[1];
                             $pointmodel->lng = $coord[0];
                             $pointmodel->area_id = $areamodel->id;
                             $pointmodel->point_num = $ii;
                             $pointmodel->save();
                         }
                     }
                 }
             }
         }
     }
 }
Example #2
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $this->layout = '//layouts/header_user';
     $model = $this->loadChangeModel($id);
     if ($model->STATE != 'fresh') {
         throw new CHttpException(403, 'Доступ запрещен.');
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $cs = Yii::app()->getClientScript();
     $cs->registerCssFile('/css/add_form.css');
     if (isset($_POST['Holes'])) {
         $model->attributes = $_POST['Holes'];
         if ($model->gibdd_id) {
             $subj = $model->gibdd->subject->id;
             if ($subj) {
                 $model->ADR_SUBJECTRF = $subj;
             }
         } else {
             if ($model->STR_SUBJECTRF) {
                 $subj = RfSubjects::model()->SearchID(trim($model->STR_SUBJECTRF));
                 if ($subj) {
                     $model->ADR_SUBJECTRF = $subj;
                 }
             }
         }
         if ($model->save() && $model->savePictures()) {
             $this->redirect(array('view', 'id' => $model->ID));
         }
     }
     $this->flushUploadDir();
     $this->render('update', array('model' => $model));
 }
Example #3
0
 public function actionGetgibddheadbyregion()
 {
     $user = $this->auth();
     $region_id = (int) Yii::app()->request->getParam('region_id');
     $model = RfSubjects::model()->findByPk($region_id);
     if (!$model) {
         $this->error('NOT_FOUND');
     }
     $tags = array();
     if ($model->gibdd) {
         $tags[] = CHtml::tag('gibdd', array('type' => 'regional', 'subjectid' => $model->id, 'id' => $model->gibdd->id), false, false);
         $tags[] = CHtml::tag('gibdditem', array('address' => $model->gibdd->address, 'tel' => $model->gibdd->tel_degurn), CHtml::encode($model->gibdd->gibdd_name), true);
         $tags[] = CHtml::tag('nominative', array('post' => $model->gibdd->post, 'gibdd' => $model->gibdd->gibdd_name), CHtml::encode($model->gibdd->fio), true);
         $tags[] = CHtml::tag('nominative', array('dative' => $model->gibdd->post_dative), CHtml::encode($model->gibdd->fio_dative), true);
         $tags[] = CHtml::closeTag('gibdd');
     }
     foreach ($model->gibdd_local as $gibdd) {
         $tags[] = CHtml::tag('gibdd', array('type' => 'local', 'subjectid' => $model->id, 'id' => $gibdd->id), false, false);
         $tags[] = CHtml::tag('gibdditem', array('address' => $gibdd->address, 'tel' => $gibdd->tel_degurn, 'lat' => $gibdd->lat, 'lng' => $gibdd->lng), CHtml::encode($gibdd->gibdd_name), true);
         $tags[] = CHtml::tag('nominative', array('post' => $gibdd->post, 'gibdd' => $gibdd->gibdd_name), CHtml::encode($gibdd->fio), true);
         $tags[] = CHtml::tag('nominative', array('dative' => $gibdd->post_dative), CHtml::encode($gibdd->fio_dative), true);
         $tags[] = CHtml::closeTag('gibdd');
     }
     $this->renderXml($tags);
 }
Example #4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = RfSubjects::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }