/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Notices(); $model->setScenario('create'); //int_r($_FILES);exit; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $path = Yii::app()->basePath . '/../uploads'; if (!is_dir($path)) { mkdir($path); } if (isset($_POST['Notices'])) { $model->attributes = $_POST['Notices']; $model->user_id = Yii::app()->User->Id; $user = User::model()->findByPk(Yii::app()->User->Id); $state = State::model()->findByAttributes(array('statecode' => $user->statecode)); $dist = District::model()->findByAttributes(array('distcode' => $user->distcode)); $est = Establishments::model()->findByAttributes(array('id' => $user->est_id)); $model->state = $state->statename; $model->district_court_complex = $dist->distname; $model->establishment = $est->est_name; $model->notice_date = date("Y-m-d H:i:s", time()); $user = User::model()->findByPk(Yii::app()->User->Id); $model->judge_name = $user->judge; $court_no = CourtT::model()->findAllByAttributes(array('judge_id' => $user->judge_id)); $court = ''; foreach ($court_no as $i) { $court = $i['court_no']; break; } $model->court = $court; if ($model->validate($_POST['Notices'])) { //exit("ASd"); if (@(!empty($_FILES['Notices']['name']['pdf_file']))) { $model->pdf_file = $_POST['Notices']['pdf_file']; $model->pdf_file = CUploadedFile::getInstance($model, 'pdf_file'); //$filename = time() . '_' . str_replace(' ', '_', strtolower($model->pdf_file)); if ($_POST['Notices']['notice_type'] == "Advertisment") { $type = 1; } elseif ($_POST['Notices']['notice_type'] == "Sale Notices") { $type = 2; } else { $type = 3; } $filename = $type . "-" . str_replace(' ', '_', $_POST['Notices']['case_type']) . "-" . date("d-m-Y_H:i:s", time()) . ".pdf"; $model->pdf_file->saveAs($path . '/' . $filename); $model->pdf_file = $filename; $model->created = date("Y-m-d H:i:s", time()); $model->notice_date = date("Y-m-d H:i:s", strtotime($model->notice_date)); $model->appear_date = date("Y-m-d H:i:s", strtotime($model->appear_date)); } } if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
// $dist = array('Already Select') $dist = CHtml::listData(District::model()->findAllByAttributes(array('statecode' => $model->statecode), array('order' => 'distname ASC')), 'distcode', 'distname'); ?> <?php echo $form->dropDownListControlGroup($model, 'distcode', $dist, array()); } ?> <?php if ($role == "District User") { $judge = JudgeName::model()->findAllByAttributes(array('district' => $model->dist), array('order' => 'judge_name ASC')); //print_r($model->distcode);exit; $array = array(); foreach ($judge as $j) { $court_no = CourtT::model()->findAllByAttributes(array('judge_id' => $j['id'])); $court = ''; foreach ($court_no as $i) { $court = $i['court_no']; break; } $array[$j['id']] = $court . "-" . $j['judge_name'] . "-" . $j['desg_code'] . "-" . $j['judge_code']; } ?> <?php echo $form->dropDownListControlGroup($model, 'judge_id', $array, array()); ?> <?php echo $form->dropDownListControlGroup($model, 'est_id', CHtml::listData(Establishments::model()->findAll(array('order' => 'est_name ASC')), 'id', 'est_name'), array('span' => 5));
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return CourtT the loaded model * @throws CHttpException */ public function loadModel($id) { $model = CourtT::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }