public function actionEnterPeopleProgramms() { $session = Yii::$app->session; $order = Order::findOne($session["order_id"]); if (!isset($order->count_adult)) { $count_adult = 0; } else { $count_adult = $order->count_adult; } $count_kids = $order->count_kids; $parents = ""; if ($count_adult >= 1) { for ($i = 1; $i <= $count_adult; $i++) { $parents[$i] = new Parents(); } } $kids = ""; if ($count_kids >= 1) { for ($i = 1; $i <= $count_kids; $i++) { $kids[$i] = new Kids(); } } if (isset($order->date)) { $date_enter = date("d.m.Y", $order->date); } if (isset($order->count_hours)) { $count_hours = $order->count_hours; } $TypeHours = TypeDayProgramms::find()->all(); foreach ($TypeHours as $val) { $type_hours[$val->id] = $val->name; } if (isset($_REQUEST["pay"])) { if ($ch = @curl_init()) { $url = Url::base("http") . "/index.php?r=online-pay/finish&orderId=" . $order->id; $id_order = $order->id; $amount = (int) $_REQUEST["sum_pay"] * 100; @curl_setopt($ch, CURLOPT_URL, 'https://3dsec.sberbank.ru/payment/rest/register.do?userName=masterslavl-api&password=masterslavl&orderNumber=' . $id_order . '&amount=' . $amount . '&returnUrl=' . $url); @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 (isset($dt->orderId)) { if (isset($_REQUEST["date_enter"])) { $order->date = strtotime($_REQUEST["date_enter"]); $order->save(); } $order->summ = $amount; $order->bankOrderId = $dt->orderId; $order->bankFormUrl = $dt->formUrl; $order->save(); $this->redirect($dt->formUrl); } elseif ($order->bankFormUrl != "") { $this->redirect($order->bankFormUrl); } } } return $this->render("enter-people-programms", ['count_kids' => $count_kids, 'count_adult' => $count_adult, "parents" => $parents, "kids" => $kids, "date_enter" => $date_enter, "type_hours" => $type_hours, "count_hours" => $count_hours]); }
public function actionIndex() { $TypeTicket = TypeTicket::find()->all(); $model = new PriceTicket(); $model2 = new PriceTicket2(); $model3 = new PriceTicket3(); $model_programms = new PriceProgramms(); $dt = Yii::$app->getRequest()->post('PriceTicket'); $dt2 = Yii::$app->getRequest()->post('PriceTicket2'); $dt3 = Yii::$app->getRequest()->post('PriceTicket3'); $dt_dop_price = Yii::$app->getRequest()->post("DopPrice"); if ($dt["price"]) { foreach ($dt["price"] as $type_day => $value) { foreach ($value as $type_ticket => $val) { foreach ($val as $hours => $price) { $res = PriceTicket::find()->where("type_day={$type_day} AND type_ticket={$type_ticket} AND hours={$hours}")->all(); if ($res) { $id = $res[0]->id; $record = PriceTicket::findOne($id); $record->price = $price; $record->update(); } else { $record = new PriceTicket(); $record->type_day = $type_day; $record->type_ticket = $type_ticket; $record->hours = $hours; $record->price = $price; $record->insert(); } } } } } if ($dt2["price"]) { foreach ($dt2["price"] as $type_day => $value) { foreach ($value as $type_ticket => $val) { foreach ($val as $hours => $price) { $res = PriceTicket2::find()->where("type_day={$type_day} AND type_ticket={$type_ticket} AND hours={$hours}")->all(); if ($res) { $id = $res[0]->id; $record = PriceTicket2::findOne($id); $record->price = $price; $record->update(); } else { $record = new PriceTicket2(); $record->type_day = $type_day; $record->type_ticket = $type_ticket; $record->hours = $hours; $record->price = $price; $record->insert(); } } } } } if ($dt3["price"]) { foreach ($dt3["price"] as $type_day => $value) { foreach ($value as $type_ticket => $val) { foreach ($val as $hours => $price) { $res = PriceTicket3::find()->where("type_day={$type_day} AND type_ticket={$type_ticket} AND hours={$hours}")->all(); if ($res) { $id = $res[0]->id; $record = PriceTicket3::findOne($id); $record->price = $price; $record->update(); } else { $record = new PriceTicket3(); $record->type_day = $type_day; $record->type_ticket = $type_ticket; $record->hours = $hours; $record->price = $price; $record->insert(); } } } } } $dt_programms = Yii::$app->getRequest()->post('PriceProgramms'); if ($dt_programms["programms"]) { foreach ($dt_programms["programms"] as $id_programm => $programm) { foreach ($programm as $id_type_day => $price) { $res = PriceProgramms::findOne(["id_programm" => $id_programm, "id_time" => $id_type_day]); if ($res) { $res->price = $price; $res->save(); } else { $res = new PriceProgramms(); $res->id_programm = $id_programm; $res->id_time = $id_type_day; $res->price = $price; $res->save(); } } } } $data = PriceTicket::find()->all(); $data2 = PriceTicket2::find()->all(); $data3 = PriceTicket3::find()->all(); foreach ($data as $key => $val) { $dt_val[$val["type_day"]][$val["type_ticket"]][$val["hours"]] = $val["price"]; } foreach ($data2 as $key => $val) { $dt_val2[$val["type_day"]][$val["type_ticket"]][$val["hours"]] = $val["price"]; } foreach ($data3 as $key => $val) { $dt_val3[$val["type_day"]][$val["type_ticket"]][$val["hours"]] = $val["price"]; } $TypeHours = TypeHours::find()->all(); foreach ($TypeHours as $val) { $dt_type_hours[$val->id] = $val->value; } $programms = Programms::find()->all(); $programms_type_day = TypeDayProgramms::find()->all(); $data_programms = PriceProgramms::find()->all(); $dt_programms_val = ""; foreach ($data_programms as $val) { $dt_programms_val[$val["id_programm"]][$val["id_time"]] = $val["price"]; } $model_dop_price = new DopPrice(); if (count($dt_dop_price) > 0) { foreach ($dt_dop_price as $key => $value) { $res = DopPrice::find()->where(["name" => $key])->all(); $res[0]->price = $value; $res[0]->update(); } } $DopPrice = DopPrice::find()->all(); return $this->render('index', ['TypeTicket' => $TypeTicket, 'model' => $model, 'model2' => $model2, 'model3' => $model3, 'dt' => $dt, 'dt2' => $dt2, 'dt3' => $dt3, 'dt_val' => $dt_val, 'dt_val2' => $dt_val2, 'dt_val3' => $dt_val3, 'dt_type_hours' => $dt_type_hours, 'DopPrice' => $DopPrice, 'model_dop_price' => $model_dop_price, 'programms' => $programms, 'programms_type_day' => $programms_type_day, 'model_programms' => $model_programms, 'dt_val_programms' => $dt_programms_val]); }
/** * Lists all TypeDayProgramms models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => TypeDayProgramms::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }