public function actionIndex() { if (isset($_GET['id'])) { $model = StudentService::model()->findByPk($_GET['id']); $this->render('detail', array('model' => $model)); } else { if ($_GET['type_id']) { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1 AND ser_type_id=' . $_GET['type_id']; $criteria->order = 'sort_order'; $total = StudentService::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(20); $pages->applyLimit($criteria); $model = StudentService::model()->findAll($criteria); $type = StudentServiceType::model()->findByPk($_GET['type_id']); $this->render('index', array('model' => $model, 'type' => $type, 'pages' => $pages)); } else { if ($_GET['group']) { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1 AND ser_group=' . $_GET['group']; $criteria->order = 'sort_order'; $total = StudentService::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(20); $pages->applyLimit($criteria); $model = StudentService::model()->findAll($criteria); $group = StudentServiceGroup::model()->findByPk($_GET['group']); $this->render('index', array('model' => $model, 'group' => $group, 'pages' => $pages)); } else { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1'; $criteria->order = 'sort_order'; $total = Knowledge::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(20); $pages->applyLimit($criteria); $model = StudentService::model()->findAll($criteria); $this->render('index', array('model' => $model, 'pages' => $pages)); } } } }
?> class="active" <?php } ?> href="<?php echo Yii::app()->createUrl('student'); ?> "><?php echo $service_student; ?> </a> <ul> <?php $criteria = new CDbCriteria(); $criteria->order = 'sort_order'; $ServiceGroup = StudentServiceGroup::model()->findAll($criteria); foreach ($ServiceGroup as $group) { ?> <li><a href="<?php echo Yii::app()->createUrl('student', array('group' => $group->ser_group)); ?> "><?php echo $group->ser_name; ?> </a></li> <?php } ?> </ul> </li> <li><a <?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 StudentServiceGroup the loaded model * @throws CHttpException */ public function loadModel($id) { $model = StudentServiceGroup::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php /* @var $this StudentServiceController */ /* @var $model StudentService */ $this->breadcrumbs = array('บริการนิสิต' => array('index'), 'จัดการข้อมูล'); $this->menu = array(array('label' => 'เพิ่มข้อมูล', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$('#student-service-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>จัดการข้อมูลบริการนิสิต</h1> <?php echo CHtml::link('ค้นหาแบบละเอียด', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model, 'ser_group_list' => $ser_group_list, 'ser_type_list' => $ser_type_list)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'student-service-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'ser_id', 'htmlOptions' => array('style' => 'text-align: center;width: 30px;')), array('name' => 'name_th', 'header' => 'บริการ'), array('name' => 'ser_type_id', 'header' => 'ประเภทย่อย', 'value' => '$data->serType->name_th', 'htmlOptions' => array('style' => 'text-align: left;width: 100px;'), 'filter' => CHtml::listData(StudentServiceType::model()->findAll('status=1'), 'ser_type_id', 'name_th')), array('name' => 'ser_group', 'header' => 'ประเภทหลัก', 'value' => '$data->serGroup->ser_name', 'htmlOptions' => array('style' => 'text-align: left;width: 100px;'), 'filter' => CHtml::listData(StudentServiceGroup::model()->findAll(), 'ser_group', 'ser_name')), array('name' => 'last_update', 'header' => 'วันที่ปรับปรุง', 'value' => 'Controller::getThaiDate($data->last_update,"dmY")', 'htmlOptions' => array('style' => 'text-align: center;width: 80px;')), array('name' => 'status', 'value' => '($data->status)? \'แสดง\' : \'ไม่แสดง\'', 'htmlOptions' => array('style' => 'text-align: center;width: 50px;'), 'filter' => array('1' => 'แสดง', '0' => 'ไม่แสดง')), array('class' => 'CButtonColumn', 'template' => '{update} {delete}', 'headerHtmlOptions' => array('style' => 'width:40px;'), 'htmlOptions' => array('style' => 'width:40px; text-align:center')))));
/** * Manages all models. */ public function actionAdmin() { if ($this->menu_use[10]) { $model = new StudentService('search'); $ser_group_list = array(); $criteria = new CDbCriteria(); $criteria->order = 'ser_group'; $ser_group = StudentServiceGroup::model()->findAll($criteria); foreach ($ser_group as $type) { $ser_group_list[$type->ser_group] = $type->ser_name; } $group = $model->ser_group; $ser_type_list = array(); $criteria1 = new CDbCriteria(); $criteria1->condition = 'status=:status AND t.ser_group=:ser_group'; $criteria1->params = array(':status' => 1, ':ser_group' => $group); $criteria1->order = 'name_th'; $ser_group = StudentServiceType::model()->findAll($criteria1); foreach ($ser_group as $type) { $ser_type_list[$type->ser_type_id] = $type->name_th; } $model->unsetAttributes(); // clear any default values if (isset($_GET['StudentService'])) { $model->attributes = $_GET['StudentService']; } $this->render('admin', array('model' => $model, 'ser_group_list' => $ser_group_list, 'ser_type_list' => $ser_type_list)); } else { $this->redirect(array('site/index')); } }
/** * Manages all models. */ public function actionAdmin() { if ($this->menu_use[10]) { $model = new StudentServiceType('search'); $ser_group_list = array(); $criteria = new CDbCriteria(); $criteria->order = 'ser_group'; $ser_group = StudentServiceGroup::model()->findAll($criteria); foreach ($ser_group as $type) { $ser_group_list[$type->ser_group] = $type->ser_name; } $model->unsetAttributes(); // clear any default values if (isset($_GET['StudentServiceType'])) { $model->attributes = $_GET['StudentServiceType']; } $this->render('admin', array('model' => $model, 'ser_group_list' => $ser_group_list)); } else { $this->redirect(array('site/index')); } }
<?php /* @var $this StudentServiceTypeController */ /* @var $model StudentServiceType */ $this->breadcrumbs = array('ประเภทย่อยบริการนิสิต' => array('index'), 'จัดการประเภทย่อ'); $this->menu = array(array('label' => 'เพิ่มประเภทย่อย', 'url' => array('create')), array('label' => 'เรียงลำดับประเภทย่อย', 'url' => array('order'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$('#student-service-type-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>จัดการประเภทย่อยบริการนิสิต</h1> <?php echo CHtml::link('ค้นหาแบบละเอียด', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model, 'ser_group_list' => $ser_group_list)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'student-service-type-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'ser_type_id', 'htmlOptions' => array('style' => 'text-align: center;width: 30px;')), array('name' => 'name_th', 'header' => 'ชื่อประเภท'), array('name' => 'ser_group', 'header' => 'กลุ่มประเภท', 'value' => '$data->serGroup->ser_name', 'htmlOptions' => array('style' => 'text-align: left;width: 120px;'), 'filter' => CHtml::listData(StudentServiceGroup::model()->findAll(), 'ser_group', 'ser_name')), array('name' => 'status', 'value' => '($data->status)? \'แสดง\' : \'ไม่แสดง\'', 'htmlOptions' => array('style' => 'text-align: center;width: 60px;'), 'filter' => array('1' => 'แสดง', '0' => 'ไม่แสดง')), array('class' => 'CButtonColumn', 'template' => '{update} {delete}', 'headerHtmlOptions' => array('style' => 'width:40px;'), 'htmlOptions' => array('style' => 'width:40px; text-align:center')))));