/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Challan(); $list = new OffenceList(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); //print_r($_POST);exit; if (isset($_POST['Challan'])) { $model->attributes = $_POST['Challan']; $model->user_id = Yii::app()->User->Id; $model->created = date("Y-m-d H:i:s", time()); $model->modified = date("Y-m-d H:i:s", time()); $model->apperance_date = date("Y-m-d H:i:s", strtotime($model->apperance_date)); $model->date_fixed = date("Y-m-d H:i:s", strtotime($model->date_fixed)); $model->date_time_offence = date("Y-m-d H:i:s", strtotime($model->date_time_offence)); $model->vehicle_impounded = $_POST['Challan']['vehicle_impounded']; $model->gender = $_POST['Challan']['gender']; $model->age = $_POST['Challan']['age']; if (!empty($_POST['Challan']['offence_ids'])) { $model->offence_ids = implode(",", $_POST['Challan']['offence_ids']); } if (!empty($_POST['Challan']['docs_conf'])) { $model->document_impounded = implode(",", $_POST['Challan']['docs_conf']); } if (!empty($_POST['Challan']['district_id'])) { $model->district_id = $_POST['Challan']['district_id']; } if (!empty($_POST['Challan']['challan_district_id'])) { $model->challan_district_id = $_POST['Challan']['challan_district_id']; } //$model->number_of_offence = implode(",",$_POST['Challan']['number_of_offence']); if ($model->save()) { //$this->redirect(array('view','id'=>$model->id)); Yii::app()->user->setFlash('success1 message1', "Challan was uploaded successfully"); $this->redirect(array('create')); } else { Yii::app()->user->setFlash('error1 message1', "Challan could not be upload at this time. Please correct the errors and try again"); } } return $this->render('create', array('model' => $model, 'list' => $list)); }