public function actionPersonnel()
 {
     if (isset($_GET['id'])) {
         $model = $this->loadPersonnelModel($_GET['id']);
         $this->render('personnel_detail', array('model' => $model));
     } else {
         if (isset($_GET['type_id'])) {
             $type_id = $_GET['type_id'];
             $type = PersonnelType::model()->findByPk($_GET['type_id']);
             $criteria = new CDbCriteria();
             $criteria->condition = 'status = 1 AND personnel_type_id =' . $type_id;
             $criteria->order = 'sort_order';
             $total = Personnel::model()->count($criteria);
             $pages = new CPagination($total);
             $pages->setPageSize(10);
             $pages->applyLimit($criteria);
             $model = Personnel::model()->findAll($criteria);
             $this->render('personnel', array('model' => $model, 'type' => $type, 'pages' => $pages));
         } else {
             $criteria = new CDbCriteria();
             $criteria->select = '*';
             $criteria->condition = 'status = 1';
             $criteria->order = 'sort_order';
             $total = Personnel::model()->count($criteria);
             $pages = new CPagination($total);
             $pages->setPageSize(10);
             $pages->applyLimit($criteria);
             $model = Personnel::model()->findAll($criteria);
             $this->render('personnel', array('model' => $model, 'pages' => $pages));
         }
     }
 }
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     if ($this->menu_use[1]) {
         $personnel_type_list = array();
         $criteria = new CDbCriteria();
         $criteria->condition = 'status=:status';
         $criteria->params = array(':status' => 1);
         $criteria->order = 'sort_order';
         $types = PersonnelType::model()->findAll($criteria);
         foreach ($types as $type) {
             $personnel_type_list[$type->personnel_type_id] = $type->name_th;
         }
         $model = new Personnel('search');
         $model->unsetAttributes();
         // clear any default values
         if (isset($_GET['Personnel'])) {
             $model->attributes = $_GET['Personnel'];
         }
         $this->render('admin', array('model' => $model, 'personnel_type_list' => $personnel_type_list));
     } else {
         $this->redirect(array('site/index'));
     }
 }
    echo Yii::app()->createUrl('about/executive');
    ?>
">ทำเนียบผู้บริหาร</a></h6></li>
        <li><h6><a href="<?php 
    echo Yii::app()->createUrl('about/structure');
    ?>
">โครงสร้างหน่วยงาน</a></h6></li>
        <li><h6><a href="<?php 
    echo Yii::app()->createUrl('about/personnel');
    ?>
">บุคลากร</a></h6></li>
        <?php 
    $criteria = new CDbCriteria();
    $criteria->condition = 'status = 1';
    $criteria->order = 'sort_order';
    $co_type = PersonnelType::model()->findAll($criteria);
    foreach ($co_type as $type) {
        ?>
        <li><a href="<?php 
        echo Yii::app()->createUrl('about/personnel', array('type_id' => $type->personnel_type_id));
        ?>
"><img src="<?php 
        echo Yii::app()->request->baseUrl;
        ?>
/images/front/marker_2.gif" border="0" style="padding-top: 7px"/>&nbsp;<?php 
        echo $type->name_th;
        ?>
</a></li>        
        <?php 
    }
    ?>
Exemple #4
0
<?php

/* @var $this PersonnelController */
/* @var $model Personnel */
$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\$('#personnel-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, 'personnel_type_list' => $personnel_type_list));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'personnel-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'personnel_id', 'header' => 'รหัส', 'htmlOptions' => array('style' => 'text-align: center;width: 30px;')), array('name' => 'image', 'htmlOptions' => array('style' => 'text-align: center;width: 100px;'), 'type' => 'html', 'value' => 'CHtml::image(Yii::app()->request->baseUrl ."/uploads/personnel/".$data->image, "รูปประจำตัว",array(\'height\'=>100))'), array('name' => 'personnel_type_id', 'header' => 'ประเภทบุคลากร', 'value' => '$data->personnelType->name_th', 'htmlOptions' => array('style' => 'text-align: left;width: 100px;'), 'filter' => CHtml::listData(PersonnelType::model()->findAll(), 'personnel_type_id', 'name_th')), 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')))));
 /**
  * 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 PersonnelType the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = PersonnelType::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }