diff --git a/protected/controllers/StateController.php b/protected/controllers/StateController.php new file mode 100644 index 0000000..73150fc --- /dev/null +++ b/protected/controllers/StateController.php @@ -0,0 +1,173 @@ +array('index','view'), + 'users'=>array('*'), + ), + array('allow', // allow authenticated user to perform 'create' and 'update' actions + 'actions'=>array('create','update'), + 'users'=>array('@'), + ), + array('allow', // allow admin user to perform 'admin' and 'delete' actions + 'actions'=>array('admin','delete'), + 'users'=>array('admin'), + ), + array('deny', // deny all users + 'users'=>array('*'), + ), + ); + } + + /** + * Displays a particular model. + * @param integer $id the ID of the model to be displayed + */ + public function actionView($id) + { + $this->render('view',array( + 'model'=>$this->loadModel($id), + )); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + */ + public function actionCreate() + { + $model=new State; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['State'])) + { + $model->attributes=$_POST['State']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id_state)); + } + + $this->render('create',array( + 'model'=>$model, + )); + } + + /** + * Updates a particular model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id the ID of the model to be updated + */ + public function actionUpdate($id) + { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['State'])) + { + $model->attributes=$_POST['State']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id_state)); + } + + $this->render('update',array( + 'model'=>$model, + )); + } + + /** + * Deletes a particular model. + * If deletion is successful, the browser will be redirected to the 'admin' page. + * @param integer $id the ID of the model to be deleted + */ + public function actionDelete($id) + { + $this->loadModel($id)->delete(); + + // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser + if(!isset($_GET['ajax'])) + $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); + } + + /** + * Lists all models. + */ + public function actionIndex() + { + $dataProvider=new CActiveDataProvider('State'); + $this->render('index',array( + 'dataProvider'=>$dataProvider, + )); + } + + /** + * Manages all models. + */ + public function actionAdmin() + { + $model=new State('search'); + $model->unsetAttributes(); // clear any default values + if(isset($_GET['State'])) + $model->attributes=$_GET['State']; + + $this->render('admin',array( + 'model'=>$model, + )); + } + + /** + * 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 State the loaded model + * @throws CHttpException + */ + public function loadModel($id) + { + $model=State::model()->findByPk($id); + if($model===null) + throw new CHttpException(404,'The requested page does not exist.'); + return $model; + } + + /** + * Performs the AJAX validation. + * @param State $model the model to be validated + */ + protected function performAjaxValidation($model) + { + if(isset($_POST['ajax']) && $_POST['ajax']==='state-form') + { + echo CActiveForm::validate($model); + Yii::app()->end(); + } + } +} diff --git a/protected/views/state/_form.php b/protected/views/state/_form.php new file mode 100644 index 0000000..6c2b73c --- /dev/null +++ b/protected/views/state/_form.php @@ -0,0 +1,130 @@ + + +
+ +beginWidget('CActiveForm', array( + 'id'=>'state-form', + // Please note: When you enable ajax validation, make sure the corresponding + // controller action is handling ajax validation correctly. + // There is a call to performAjaxValidation() commented in generated controller code. + // See class documentation of CActiveForm for details on this. + 'enableAjaxValidation'=>false, +)); ?> + +

Fields with * are required.

+ + errorSummary($model); ?> + +
+ labelEx($model,'ST_CODE'); ?> + textField($model,'ST_CODE'); ?> + error($model,'ST_CODE'); ?> +
+ +
+ labelEx($model,'name'); ?> + textField($model,'name',array('size'=>50,'maxlength'=>50)); ?> + error($model,'name'); ?> +
+ +
+ labelEx($model,'ias_short_code'); ?> + textField($model,'ias_short_code',array('size'=>2,'maxlength'=>2)); ?> + error($model,'ias_short_code'); ?> +
+ +
+ labelEx($model,'id_census'); ?> + textField($model,'id_census'); ?> + error($model,'id_census'); ?> +
+ +
+ labelEx($model,'eci_ref'); ?> + textField($model,'eci_ref',array('size'=>3,'maxlength'=>3)); ?> + error($model,'eci_ref'); ?> +
+ +
+ labelEx($model,'session_from'); ?> + textField($model,'session_from'); ?> + error($model,'session_from'); ?> +
+ +
+ labelEx($model,'session_to'); ?> + textField($model,'session_to'); ?> + error($model,'session_to'); ?> +
+ +
+ labelEx($model,'lok_parl_seats'); ?> + textField($model,'lok_parl_seats'); ?> + error($model,'lok_parl_seats'); ?> +
+ +
+ labelEx($model,'amly_seats'); ?> + textField($model,'amly_seats'); ?> + error($model,'amly_seats'); ?> +
+ +
+ labelEx($model,'raj_parl_seats'); ?> + textField($model,'raj_parl_seats'); ?> + error($model,'raj_parl_seats'); ?> +
+ +
+ labelEx($model,'updated'); ?> + textField($model,'updated'); ?> + error($model,'updated'); ?> +
+ +
+ labelEx($model,'iso3166'); ?> + textField($model,'iso3166',array('size'=>3,'maxlength'=>3)); ?> + error($model,'iso3166'); ?> +
+ +
+ labelEx($model,'psloc'); ?> + textField($model,'psloc'); ?> + error($model,'psloc'); ?> +
+ +
+ labelEx($model,'eci_dist_count'); ?> + textField($model,'eci_dist_count'); ?> + error($model,'eci_dist_count'); ?> +
+ +
+ labelEx($model,'eci_amly_count'); ?> + textField($model,'eci_amly_count'); ?> + error($model,'eci_amly_count'); ?> +
+ +
+ labelEx($model,'slug'); ?> + textField($model,'slug',array('size'=>60,'maxlength'=>255)); ?> + error($model,'slug'); ?> +
+ +
+ labelEx($model,'mcorp_count'); ?> + textField($model,'mcorp_count'); ?> + error($model,'mcorp_count'); ?> +
+ +
+ isNewRecord ? 'Create' : 'Save'); ?> +
+ +endWidget(); ?> + +
\ No newline at end of file diff --git a/protected/views/state/_search.php b/protected/views/state/_search.php new file mode 100644 index 0000000..fccc678 --- /dev/null +++ b/protected/views/state/_search.php @@ -0,0 +1,110 @@ + + +
+ +beginWidget('CActiveForm', array( + 'action'=>Yii::app()->createUrl($this->route), + 'method'=>'get', +)); ?> + +
+ label($model,'id_state'); ?> + textField($model,'id_state'); ?> +
+ +
+ label($model,'ST_CODE'); ?> + textField($model,'ST_CODE'); ?> +
+ +
+ label($model,'name'); ?> + textField($model,'name',array('size'=>50,'maxlength'=>50)); ?> +
+ +
+ label($model,'ias_short_code'); ?> + textField($model,'ias_short_code',array('size'=>2,'maxlength'=>2)); ?> +
+ +
+ label($model,'id_census'); ?> + textField($model,'id_census'); ?> +
+ +
+ label($model,'eci_ref'); ?> + textField($model,'eci_ref',array('size'=>3,'maxlength'=>3)); ?> +
+ +
+ label($model,'session_from'); ?> + textField($model,'session_from'); ?> +
+ +
+ label($model,'session_to'); ?> + textField($model,'session_to'); ?> +
+ +
+ label($model,'lok_parl_seats'); ?> + textField($model,'lok_parl_seats'); ?> +
+ +
+ label($model,'amly_seats'); ?> + textField($model,'amly_seats'); ?> +
+ +
+ label($model,'raj_parl_seats'); ?> + textField($model,'raj_parl_seats'); ?> +
+ +
+ label($model,'updated'); ?> + textField($model,'updated'); ?> +
+ +
+ label($model,'iso3166'); ?> + textField($model,'iso3166',array('size'=>3,'maxlength'=>3)); ?> +
+ +
+ label($model,'psloc'); ?> + textField($model,'psloc'); ?> +
+ +
+ label($model,'eci_dist_count'); ?> + textField($model,'eci_dist_count'); ?> +
+ +
+ label($model,'eci_amly_count'); ?> + textField($model,'eci_amly_count'); ?> +
+ +
+ label($model,'slug'); ?> + textField($model,'slug',array('size'=>60,'maxlength'=>255)); ?> +
+ +
+ label($model,'mcorp_count'); ?> + textField($model,'mcorp_count'); ?> +
+ +
+ +
+ +endWidget(); ?> + +
\ No newline at end of file diff --git a/protected/views/state/_view.php b/protected/views/state/_view.php new file mode 100644 index 0000000..4a5aae8 --- /dev/null +++ b/protected/views/state/_view.php @@ -0,0 +1,83 @@ + + +
+ + getAttributeLabel('id_state')); ?>: + id_state), array('view', 'id'=>$data->id_state)); ?> +
+ + getAttributeLabel('ST_CODE')); ?>: + ST_CODE); ?> +
+ + getAttributeLabel('name')); ?>: + name); ?> +
+ + getAttributeLabel('ias_short_code')); ?>: + ias_short_code); ?> +
+ + getAttributeLabel('id_census')); ?>: + id_census); ?> +
+ + getAttributeLabel('eci_ref')); ?>: + eci_ref); ?> +
+ + getAttributeLabel('session_from')); ?>: + session_from); ?> +
+ + getAttributeLabel('session_to')); ?>: + session_to); ?> +
+ + getAttributeLabel('lok_parl_seats')); ?>: + lok_parl_seats); ?> +
+ + getAttributeLabel('amly_seats')); ?>: + amly_seats); ?> +
+ + getAttributeLabel('raj_parl_seats')); ?>: + raj_parl_seats); ?> +
+ + getAttributeLabel('updated')); ?>: + updated); ?> +
+ + getAttributeLabel('iso3166')); ?>: + iso3166); ?> +
+ + getAttributeLabel('psloc')); ?>: + psloc); ?> +
+ + getAttributeLabel('eci_dist_count')); ?>: + eci_dist_count); ?> +
+ + getAttributeLabel('eci_amly_count')); ?>: + eci_amly_count); ?> +
+ + getAttributeLabel('slug')); ?>: + slug); ?> +
+ + getAttributeLabel('mcorp_count')); ?>: + mcorp_count); ?> +
+ + */ ?> + +
\ No newline at end of file diff --git a/protected/views/state/admin.php b/protected/views/state/admin.php new file mode 100644 index 0000000..cfb2eda --- /dev/null +++ b/protected/views/state/admin.php @@ -0,0 +1,72 @@ +breadcrumbs=array( + 'States'=>array('index'), + 'Manage', +); + +$this->menu=array( + array('label'=>'List State', 'url'=>array('index')), + array('label'=>'Create State', 'url'=>array('create')), +); + +Yii::app()->clientScript->registerScript('search', " +$('.search-button').click(function(){ + $('.search-form').toggle(); + return false; +}); +$('.search-form form').submit(function(){ + $('#state-grid').yiiGridView('update', { + data: $(this).serialize() + }); + return false; +}); +"); +?> + +

Manage States

+ +

+You may optionally enter a comparison operator (<, <=, >, >=, <> +or =) at the beginning of each of your search values to specify how the comparison should be done. +

+ +'search-button')); ?> + + +widget('zii.widgets.grid.CGridView', array( + 'id'=>'state-grid', + 'dataProvider'=>$model->search(), + 'filter'=>$model, + 'columns'=>array( + 'id_state', + 'ST_CODE', + 'name', + 'ias_short_code', + 'id_census', + 'eci_ref', + /* + 'session_from', + 'session_to', + 'lok_parl_seats', + 'amly_seats', + 'raj_parl_seats', + 'updated', + 'iso3166', + 'psloc', + 'eci_dist_count', + 'eci_amly_count', + 'slug', + 'mcorp_count', + */ + array( + 'class'=>'CButtonColumn', + ), + ), +)); ?> diff --git a/protected/views/state/create.php b/protected/views/state/create.php new file mode 100644 index 0000000..f403bd4 --- /dev/null +++ b/protected/views/state/create.php @@ -0,0 +1,18 @@ +breadcrumbs=array( + 'States'=>array('index'), + 'Create', +); + +$this->menu=array( + array('label'=>'List State', 'url'=>array('index')), + array('label'=>'Manage State', 'url'=>array('admin')), +); +?> + +

Create State

+ +renderPartial('_form', array('model'=>$model)); ?> \ No newline at end of file diff --git a/protected/views/state/index.php b/protected/views/state/index.php new file mode 100644 index 0000000..cfe4bdd --- /dev/null +++ b/protected/views/state/index.php @@ -0,0 +1,20 @@ +breadcrumbs=array( + 'States', +); + +$this->menu=array( + array('label'=>'Create State', 'url'=>array('create')), + array('label'=>'Manage State', 'url'=>array('admin')), +); +?> + +

States

+ +widget('zii.widgets.CListView', array( + 'dataProvider'=>$dataProvider, + 'itemView'=>'_view', +)); ?> diff --git a/protected/views/state/update.php b/protected/views/state/update.php new file mode 100644 index 0000000..5a23828 --- /dev/null +++ b/protected/views/state/update.php @@ -0,0 +1,21 @@ +breadcrumbs=array( + 'States'=>array('index'), + $model->name=>array('view','id'=>$model->id_state), + 'Update', +); + +$this->menu=array( + array('label'=>'List State', 'url'=>array('index')), + array('label'=>'Create State', 'url'=>array('create')), + array('label'=>'View State', 'url'=>array('view', 'id'=>$model->id_state)), + array('label'=>'Manage State', 'url'=>array('admin')), +); +?> + +

Update State id_state; ?>

+ +renderPartial('_form', array('model'=>$model)); ?> \ No newline at end of file diff --git a/protected/views/state/view.php b/protected/views/state/view.php new file mode 100644 index 0000000..734b7a9 --- /dev/null +++ b/protected/views/state/view.php @@ -0,0 +1,43 @@ +breadcrumbs=array( + 'States'=>array('index'), + $model->name, +); + +$this->menu=array( + array('label'=>'List State', 'url'=>array('index')), + array('label'=>'Create State', 'url'=>array('create')), + array('label'=>'Update State', 'url'=>array('update', 'id'=>$model->id_state)), + array('label'=>'Delete State', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id_state),'confirm'=>'Are you sure you want to delete this item?')), + array('label'=>'Manage State', 'url'=>array('admin')), +); +?> + +

View State #id_state; ?>

+ +widget('zii.widgets.CDetailView', array( + 'data'=>$model, + 'attributes'=>array( + 'id_state', + 'ST_CODE', + 'name', + 'ias_short_code', + 'id_census', + 'eci_ref', + 'session_from', + 'session_to', + 'lok_parl_seats', + 'amly_seats', + 'raj_parl_seats', + 'updated', + 'iso3166', + 'psloc', + 'eci_dist_count', + 'eci_amly_count', + 'slug', + 'mcorp_count', + ), +)); ?>