/** * Отправка заказа из истории (с проверкой на изменение переменных сессии) * @param type $id - ИД заказа */ public function actionSendOrderFromHistoryPage($id) { $session = Yii::$app->session; $order = Orders::findOne(['id' => $id]); if ($session->get('idOrder') == $id) { $order->status = Orders::STATUS_SENDED; $session->set('creatingOrder', false); $session->set('idOrder', 0); } else { if ($order->status == Orders::STATUS_SENDED) { $countRepeat = $order->count_repeat; $order->count_repeat = $countRepeat + 1; } else { $order->status = Orders::STATUS_SENDED; } } $order->save(); $order->createDbf(); $session->setFlash('success', 'Заказ отправлен'); $this->redirect(['/main/orders/history']); }
/** * Finds the Orders model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Orders the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Orders::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }