Beispiel #1
0
 public function actionDelete($id = null)
 {
     $model = Visitors::findOne($id);
     $model2 = Apteki::findOne($model['apteki_id']);
     $model->delete();
     return $this->redirect(["/visitors/?user={$model2['pi_id']}&scroll={$model2['id']}"]);
 }
Beispiel #2
0
 public function actionCoordinates()
 {
     $apteki = Apteki::find()->where('updated_at>= now() - INTERVAL 3 DAY')->orderBy(['updated_at' => 'ASC'])->limit(100)->all();
     foreach ($apteki as $apteka) {
         $url = "https://geocode-maps.yandex.ru/1.x/?format=json&geocode=Россия, " . $apteka['address'];
         $getUrl = json_decode(file_get_contents($url), true);
         $coordinates = $getUrl['response']['GeoObjectCollection']['featureMember']['0']['GeoObject']['Point']['pos'];
         print $apteka['address'];
         print $coordinates;
         print "<br>";
         $model = $apteki = Apteki::findOne($apteka['id']);
         $model->coordinates = $coordinates;
         $model->save();
         usleep(500000);
         //0.5 сек
     }
 }
Beispiel #3
0
 /**
  * Finds the Apteki model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Apteki the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Apteki::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Updates an existing ValidationReport model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $model2 = ValidationReportViolation::find()->select('violation_id')->where(['report_id' => $id])->column();
     $model->user_id = \Yii::$app->user->identity->id;
     $UrRecords = Ur::find()->orderBy('name');
     if (\Yii::$app->user->identity->status == 2) {
         $UrRecords = $UrRecords->Where(['regional_id' => \Yii::$app->user->identity->id]);
     }
     if (\Yii::$app->user->identity->status == 3) {
         $UrRecords = $UrRecords->Where(['pi_id' => \Yii::$app->user->identity->id]);
     }
     $UrRecords = $UrRecords->all();
     if ($model->load(Yii::$app->request->post())) {
         // ValidationReportViolation::deleteAll("report_id = $model->report_id");
     }
     $ur_l = Apteki::findOne($model->apteka_id);
     $ur_l_id = $ur_l['ur_l_id'];
     $apteki = Apteki::find()->where(['ur_l_id' => $ur_l_id])->orderBy(['address' => 'desc'])->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         ValidationReportViolation::deleteAll(['report_id' => $model->id]);
         $post = Yii::$app->request->post();
         if ($post['v']) {
             foreach ($post['v'] as $key => $item) {
                 Yii::$app->db->createCommand()->insert('validation_report_violation', ['report_id' => $model->id, 'violation_id' => (int) $key])->execute();
             }
         }
         return $this->redirect(['index', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'UrRecords' => $UrRecords, 'model2' => $model2, 'ur_l_id' => $ur_l_id, 'apteki' => $apteki]);
     }
 }
Beispiel #5
0
 /**
  * Deletes an existing Ur model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $this->findModel($id)->delete();
     //  Apteki::deleteAll(['ur_l_id' => $id]); // Не логируется
     //Удаляем аптеки
     $aprdel = Apteki::find()->where(['ur_l_id' => $id])->all();
     foreach ($aprdel as $apt) {
         $customer = Apteki::findOne($apt['id']);
         $customer->delete();
     }
     //Удаляем регоны
     $regiondel = RegionUrL::find()->where(['id_ur' => $id])->all();
     foreach ($regiondel as $reg) {
         $customer2 = RegionUrL::findOne($reg['id']);
         $customer2->delete();
     }
     return $this->redirect(['/']);
 }
Beispiel #6
0
 /**
  * пароль для аптеки
  */
 public function actionUpdate($id)
 {
     //   $this->layout = 'modal';
     //   $this->layout = 'modal';
     $model = SbSiteUsers::findOne(['apteki_id' => $id]);
     if ($model == null) {
         $model = new SbSiteUsers();
         $save = 1;
     }
     if (Yii::$app->request->isAjax) {
         $model->load($_POST);
         Yii::$app->response->format = 'json';
         return ActiveForm::validate($model);
     } elseif ($model->load($_POST)) {
         $model->apteki_id = $id;
         $model->su_domains = "sojuzpharma.ru";
         $model->su_pass = md5($model->password_simple);
         //Получаеи информацию об аптеки
         $apt = Apteki::findOne(['id' => $id]);
         $model->su_name = $apt['address'];
         $model->su_email = $apt['contact_mail'];
         if ($_POST['sendMail']) {
             \Yii::$app->mail->compose('apteki_pass', ['login' => $model->su_id, 'pass' => $model->password_simple, 'address' => $apt['address'], 'contact_face' => $apt['contact_face']])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo($apt['contact_mail'])->setSubject('Для вашей аптеки заведена учетная запись')->send();
         }
         if ($model->save()) {
             if ($save) {
                 $model3 = SbSiteUsers::findOne(['apteki_id' => $id]);
                 $model3->su_login = $model->su_id;
                 $model3->save();
                 $model2 = new SbCatlinks();
                 $model2->link_cat_id = '21';
                 $model2->link_el_id = $model->su_id;
                 $model2->save();
             }
             return $this->redirect(['/apteki/update', 'id' => $model->apteki_id]);
             //  $row_id=(mysql_fetch_assoc(mysql_query('SELECT max(LAST_INSERT_ID(su_id)) AS id FROM sb_site_users ')));
             //  mysql_query("INSERT INTO sbuilder.sb_catlinks  (link_cat_id,link_el_id) values ('21','$id')");
         }
     } else {
         return $this->render('update', ['model' => $model, 'id' => $id]);
     }
 }