/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Acts(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_GET['byorder']) and is_numeric($_GET['byorder'])) { $model->order_id = (int) $_GET['byorder']; if (isset($_POST['Acts'])) { $model->attributes = $_POST['Acts']; if ($model->save()) { $works_num = 0; if (key_exists('Works', $_POST)) { $works_num = $model->setWorks($_POST['Works']); } // $c = Works::model()->updateByPk($_POST['Works'], array('act_id' => (int) $model->id), array('condition' => 'order_id=' . (int) $model->order_id)); $msg = 'Акт #' . $model->id . ' для Заказа #' . $model->order_id . ' — ' . $model->order->name . ' создан. Работ/услуг по акту: ' . $works_num; Yii::app()->user->setFlash('success', $msg); Yii::app()->logger->write($msg); if (isset($model->order_id)) { $this->redirect(array('orders/view', 'id' => $model->order_id)); } else { $this->redirect(array('view', 'id' => $model->id)); } } } if ($model->order->fixpay !== null) { $model->sum = $model->order->fixpay; } $model->date = date('Y-m-d'); $model->client_id = $model->order->client->id; $model->num = $model->getLastNum() + 1; $this->render('create', array('model' => $model)); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Acts(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Acts'])) { $model->attributes = $_POST['Acts']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }