public function actionPopover($id, $attr) { $model = Orders::findOne($id); if ($model->status == Orders::STATUS_REGISTERED && Yii::$app->user->identity->role != 10) { if ($model->status == Orders::STATUS_REGISTERED && Yii::$app->user->identity->role == 0) { $model->scenario = 'registered'; $scenario = $model->scenarios(); if (!in_array($attr, $scenario['registered'])) { throw new \yii\web\HttpException(403, 'У вас нет доступа для редактирования'); } } else { throw new \yii\web\HttpException(403, 'У вас нет доступа для редактирования'); } } if (Yii::$app->request->post('popup')) { $post = Yii::$app->request->post(); $model = Orders::findOne($post['id']); return $this->renderAjax('popover', ['attr' => $post['attr'], 'model' => $model]); } if ($model->load(Yii::$app->request->post())) { $model->editTimestamp = date('Y-m-d H:i:s'); $model->editName = Yii::$app->user->identity->full_name; $model->history .= $model->history($model); $model->save(); } }
public function actionUpdateOrders($id) { $order = ModelOrders::findOne($id); $order->part = $_POST['part']; $order->article = $_POST['article']; $order->OE = $_POST['oe']; $order->provider = $_POST['provider']; $order->quantity = $_POST['quantity']; $order->price = $_POST['price']; $order->update(); header("Location: http://" . $_SERVER['SERVER_NAME'] . "/orders/AllShowOrders?id=" . $order->cars_id); }
/** * Finds the Orders model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $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.'); } }
public function actionChangesmsstatus($id) { $model = Orders::findOne($id); if ($model->status == 'enabled') { $model->status = 'disabled'; } else { $model->status = 'enabled'; } $model->save(); return true; }