/**
  * 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 StructureType the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = StructureType::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 2
0
 public function getAllStructureType()
 {
     $Criteria = new CDbCriteria();
     $Criteria->condition = 'status = 1';
     $Criteria->order = 'sort_order';
     $model = StructureType::model()->findAll($Criteria);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 3
0
<?php

/* @var $this StructureController */
/* @var $model Structure */
$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\$('#structure-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, 'str_type_list' => $str_type_list));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'structure-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'str_id', 'header' => 'รหัส', 'htmlOptions' => array('style' => 'text-align: center;width: 30px;')), array('name' => 'str_type_id', 'header' => 'ประเภท', 'value' => '$data->structureType->name_th', 'htmlOptions' => array('style' => 'text-align: left;width: 100px;'), 'filter' => CHtml::listData(StructureType::model()->findAll(), 'str_type_id', 'name_th')), array('name' => 'image', 'htmlOptions' => array('style' => 'text-align: center;width: 100px;'), 'type' => 'html', 'value' => 'CHtml::image(Yii::app()->request->baseUrl ."/uploads/structures/".$data->image, "รูปประจำตัว",array(\'height\'=>80))'), array('name' => 'name_th', 'header' => 'ชื่อ-นามสกุล'), array('name' => 'position_th', 'header' => 'ตำแหน่ง', 'htmlOptions' => array('style' => 'text-align: left;width: 150px;')), array('class' => 'CButtonColumn', 'template' => '{update}&nbsp;&nbsp;{delete}', 'headerHtmlOptions' => array('style' => 'width:40px;'), 'htmlOptions' => array('style' => 'width:40px; text-align:center')))));
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     if ($this->menu_use[1]) {
         $str_type_list = array();
         $criteria = new CDbCriteria();
         $criteria->condition = 'status=:status';
         $criteria->params = array(':status' => 1);
         $criteria->order = 'sort_order';
         $str_type = StructureType::model()->findAll($criteria);
         foreach ($str_type as $type) {
             $str_type_list[$type->str_type_id] = $type->name_th;
         }
         $model = new Structure('search');
         $model->unsetAttributes();
         // clear any default values
         if (isset($_GET['Structure'])) {
             $model->attributes = $_GET['Structure'];
         }
         $this->render('admin', array('model' => $model, 'str_type_list' => $str_type_list));
     } else {
         $this->redirect(array('site/index'));
     }
 }