コード例 #1
0
 public function actionAddPeopleAbonement()
 {
     $session = Yii::$app->session;
     $name = $_REQUEST["name"];
     $surname = $_REQUEST["surname"];
     $father_name = $_REQUEST["father_name"];
     $date_birthday = strtotime($_REQUEST["date_birthday"]);
     $phone = $_REQUEST["phone"];
     $kids = Kids::find()->where("LOWER(`name`)='" . mb_strtolower($name) . "' AND LOWER(`surname`) = '" . mb_strtolower($surname) . "' AND \n                LOWER(`father_name`) = '" . mb_strtolower($father_name) . "' AND `birthday` = " . $date_birthday)->all();
     if (count($kids) != 0) {
         $id_people = $kids[0]->id;
     } else {
         $kids = new Kids();
         $kids->name = $name;
         $kids->surname = $surname;
         $kids->father_name = $father_name;
         $kids->birthday = $date_birthday;
         $kids->phone = $phone;
         $kids->save();
         $id_people = $kids->id;
     }
     $price = PriceAbonements::findOne(1);
     $result["price"] = $price->price;
     if (isset($_REQUEST["pitanie"])) {
         if ($_REQUEST["pitanie"] == "true") {
             $pitanie = DopPrice::find()->where(["name" => "pitanie"])->all();
             $result["price"] += $pitanie[0]->price;
         }
     }
     if ($_REQUEST["id_rel"] == "") {
         $RelOrderPeople = new RelOrderPeople();
     } else {
         $RelOrderPeople = RelOrderPeople::findOne($_REQUEST["id_rel"]);
     }
     $result["id_people"] = $id_people;
     $RelOrderPeople->id_order = $session["order_id"];
     $RelOrderPeople->id_people = $id_people;
     $RelOrderPeople->type_people = 2;
     $RelOrderPeople->id_ticket = 7;
     $RelOrderPeople->qr = md5(time() . $id_people . $session["order_id"]);
     if (isset($_REQUEST["pitanie"])) {
         if ($_REQUEST["pitanie"] == "true") {
             $RelOrderPeople->pitanie = 1;
         }
     }
     $RelOrderPeople->summ = $result["price"] * 100;
     $RelOrderPeople->save();
     $result["id_rel"] = $RelOrderPeople->id;
     $result["status"] = 'ok';
     return json_encode($result);
 }
コード例 #2
0
 /**
  * Finds the PriceAbonements model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PriceAbonements the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PriceAbonements::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }