/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new ChallanAssignments(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['ChallanAssignments'])) { $model->attributes = $_POST['ChallanAssignments']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Manages all models. */ public function actionAdmin() { $model = new Challan('search'); if (!empty($_POST)) { foreach ($_POST['chk'] as $k => $v) { $modelA = new ChallanAssignments(); $modelA->user_id = $_POST['Challan']['user_id']; $modelA->created = date("Y-m-d H:i:s", time()); $modelA->modified = date("Y-m-d H:i:s", time()); $modelA->challan_id = $v; $modelA->assigned_by_user_id = Yii::app()->User->Id; $exist = ChallanAssignments::model()->findAllByAttributes(array("challan_id" => $v)); if (count($exist) == 0) { if ($modelA->save()) { Yii::app()->user->setFlash('success1 message1', "Challan(s) has been assigned successfully"); } else { Yii::app()->user->setFlash('error1 message1', "There was a problem in assignment."); } } // else // { // Yii::app()->user->setFlash('error1 message1', "Challan is already assined."); // } } } $model->unsetAttributes(); // clear any default values if (isset($_GET['Challan'])) { $model->attributes = $_GET['Challan']; } $this->render('admin', array('model' => $model)); }