/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new CourtT(); $dist1 = User::model()->findByPk(Yii::app()->User->Id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['CourtT'])) { $model->attributes = $_POST['CourtT']; //print_r($model);exit; $jname = JudgeName::model()->findByPk($_POST['CourtT']['judge_id']); $model->judge = $jname->judge_name; $model->judge_id = $_POST['CourtT']['judge_id']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $model->dist = $dist1->distcode; $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 User(); $dist1 = User::model()->findByPk(Yii::app()->User->Id); // collect user input data if (isset($_POST['User'])) { $model->attributes = $_POST['User']; $model->password = md5($_POST['User']['password']); $model->created = date("Y-m-d H:i:s", time()); $model->super_user_id = Yii::app()->User->Id; $role = key((array) Yii::app()->authManager->getRoles(Yii::app()->User->Id)); if ($role == "Admin") { $model->judge = "All Judge"; $model->est_id = 0; } if ($role == "District User") { $model->statecode = $dist1->statecode; $model->distcode = $dist1->distcode; $judge = JudgeName::model()->findByPk($_POST['User']['judge_id']); $model->judge = $judge->judge_name; $model->judge_id = $_POST['User']['judge_id']; $model->complex = $_POST['User']['complex']; } // validate user input and redirect to the previous page if valid if ($model->save()) { $authorizer = Yii::app()->getModule("rights")->getAuthorizer(); $role = key((array) Yii::app()->authManager->getRoles(Yii::app()->User->Id)); if ($role == "Admin") { $assign = "District User"; } if ($role == "District User") { $assign = "Ahlmad"; } $authorizer->authManager->assign($assign, $model->id); $this->redirect(array('view', 'id' => $model->id)); } } // display the login form $model->password = ''; $model->dist = $dist1->distcode; $this->render('create', array('model' => $model)); }
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'court-t-form', 'enableAjaxValidation' => false)); ?> <p class="help-block">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <?php // echo $form->dropDownListControlGroup($model,'judge',CHtml::listData(JudgeName::model()->findAllByAttributes(array('district' => $model->dist),array('order' => 'judge_name ASC')), 'judge_name', 'judge_name'),array('span'=>5)); ?> <?php $judge = JudgeName::model()->findAllByAttributes(array('district' => $model->dist), array('order' => 'judge_name ASC')); //print_r($model->distcode);exit; $array = array(); foreach ($judge as $j) { $array[$j['id']] = $j['judge_code'] . "-" . $j['judge_name'] . "-" . $j['desg_code']; } ?> <?php echo $form->dropDownListControlGroup($model, 'judge_id', $array); ?> <?php echo $form->textFieldControlGroup($model, 'court_no', array('span' => 5)); ?> <?php
/** * 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 JudgeName the loaded model * @throws CHttpException */ public function loadModel($id) { $model = JudgeName::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
?> <p class="help-block">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <?php echo $form->textFieldControlGroup($model, 'judge_name', array('span' => 5, 'maxlength' => 99)); ?> <?php echo $form->dropDownListControlGroup($model, 'state', CHtml::listData(State::model()->findAll(array('order' => 'statecode ASC')), 'statecode', 'statename'), array('ajax' => array('type' => 'POST', 'url' => CController::createUrl('site/dynamicdistrict2'), 'update' => '#JudgeName_district'), 'empty' => 'Select State'), array('span' => 5)); // $dist = array('Already Select') $dist = CHtml::listData(District::model()->findAllByAttributes(array('statecode' => $model->state), array('order' => 'distname ASC')), 'distcode', 'distname'); $judge = JudgeName::model()->findAll(array('order' => 'judge_name ASC')); foreach ($judge as $j) { $array[$j['judge_code'] . "-" . $j['judge_name'] . "-" . $j['desg_code']] = $j['judge_code'] . "-" . $j['judge_name'] . "-" . $j['desg_code']; } ?> <?php echo $form->dropDownListControlGroup($model, 'district', $dist, array()); ?> <?php //echo $form->textFieldControlGroup($model,'salutation',array('span'=>5,'maxlength'=>5)); ?> <?php echo $form->dropDownListControlGroup($model, 'salutation', array('Dr.' => 'Dr.', 'Sh.' => 'Sh.', 'Smt.' => 'Smt.', 'Ms.' => 'Ms.'), array()); ?>