Exemplo n.º 1
0
 public function getTiketContent()
 {
     $get = Yii::$app->request->get();
     $user = Yii::$app->user;
     if (isset($get["id"])) {
         $id = $get["id"];
         $RelOrderPeople = RelOrderPeople::findOne($id);
         $mOrderID = $RelOrderPeople->id_order;
         $order = Order::findOne($RelOrderPeople->id_order);
         $type_ticket = $order->type_ticket;
         if ($order->id_user != $user->id) {
             exit;
         }
         if ($ch = @curl_init()) {
             $id_order = $order->bankOrderId;
             $order = Order::findOne(["bankOrderId" => $id_order]);
             if ($order->type_ticket == 1) {
                 $host = "https://securepayments.sberbank.ru";
                 $password = "******";
             } else {
                 if ($order->type_ticket == 2) {
                     $host = "https://securepayments.sberbank.ru";
                     $password = "******";
                 } else {
                     $host = "https://3dsec.sberbank.ru";
                     $password = "******";
                 }
             }
             @curl_setopt($ch, CURLOPT_URL, $host . '/payment/rest/getOrderStatus.do?userName=masterslavl-api&password='******'&orderId=' . $id_order);
             @curl_setopt($ch, CURLOPT_HEADER, false);
             @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
             @curl_setopt($ch, CURLOPT_USERAGENT, 'Masterslavl');
             $data = @curl_exec($ch);
             $dt = json_decode($data);
             @curl_close($ch);
             if ($dt->OrderStatus != 2) {
                 return "Ошибка! Заказ не оплачен";
             }
         }
         if ($RelOrderPeople->type_people == 2) {
             $people = Kids::findOne($RelOrderPeople->id_people);
         } elseif ($RelOrderPeople->type_people == 1) {
             $people = Parents::findOne($RelOrderPeople->id_people);
         }
         $name = $people->name;
         $surname = $people->surname;
         $old = $this->getyeardiff($people->birthday, $mOrderID);
         if ($RelOrderPeople->type_tiket != 2) {
             if ($RelOrderPeople->type_tiket != 0) {
                 $TypeTicket = TypeTicket::findOne($RelOrderPeople->type_tiket);
                 $name_tiket = $TypeTicket->name;
                 $tm_name = TypeHours::findOne($order->count_hours);
                 $time = $tm_name->value;
             } elseif ($RelOrderPeople->id_programm != 0) {
                 $programm = Programms::findOne($RelOrderPeople->id_programm);
                 $name_tiket = $programm->name;
                 $tm_name = TypeDayProgramms::findOne($order->count_hours);
                 $time = $tm_name->name;
             }
         } else {
             $name_tiket = "";
             $time = "";
         }
         $date = date("d.m.Y", $order->date);
         $price = $RelOrderPeople->summ / 100;
         $pitanie = $RelOrderPeople->pitanie;
         $qr = $RelOrderPeople->qr;
         $money = 0;
         if ($RelOrderPeople->type_people == "2") {
             $money = 50;
         }
         if ($RelOrderPeople->type_tiket == "1") {
             $money = 0;
         }
         $d = $order->date;
         $date2 = date("d.m.Y", mktime(0, 0, 0, date("m", $d) + 6, date("d", $d), date("Y", $d)));
         $date1 = $date;
         if ($order->type_ticket == 2) {
             if ($RelOrderPeople->type_people == 1) {
                 $old = "Взрослый";
             } else {
                 $old = "Детский";
             }
             $name_tiket = "Подарочный сертификат";
             $time = "Активировать до:";
             $date = date("d.m.Y", mktime(0, 0, 0, date("m", $d), date("d", $d), date("Y", $d) + 1));
             $money = "0";
             $date2 = "";
             $date1 = "";
         }
         if ($order->id_ticket == 7) {
             $name_tiket = "Абонемент на 5 пос.";
             $time = "Действителен до:";
             $date = date("d.m.Y", mktime(0, 0, 0, date("m", $d) + 6, date("d", $d), date("Y", $d)));
             $money = "5*50";
             $date2 = "";
             $date1 = "";
             $type_ticket = 7;
         }
     }
     $myview = $this->renderPartial("test_t", ["name" => $name, "surname" => $surname, "old" => $old, "name_tiket" => $name_tiket, "time" => $time, "date" => $date, "price" => $price, "pitanie" => $pitanie, "qr" => $qr, "date2" => $date2, "money" => $money, 'type_ticket' => $type_ticket, 'date1' => $date1]);
     return $myview;
 }
 /**
  * Finds the TypeDayProgramms model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TypeDayProgramms the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TypeDayProgramms::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }