public function actionIndex() { if (isset($_GET['id'])) { $model = Alumni::model()->findByPk($_GET['id']); $this->render('detail', array('model' => $model)); } else { if (isset($_GET['type_id'])) { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1 AND alumni_no_id=' . $_GET['type_id']; $criteria->order = 'sort_order'; $total = Alumni::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(10); $pages->applyLimit($criteria); $model = Alumni::model()->findAll($criteria); $type = AlumniNo::model()->findByPk($_GET['type_id']); $this->render('index', array('model' => $model, 'type' => $type, 'pages' => $pages)); } else { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1'; $criteria->order = 'sort_order'; $total = Alumni::model()->count($criteria); $pages = new CPagination($total); $pages->setPageSize(10); $pages->applyLimit($criteria); $model = Alumni::model()->findAll($criteria); $this->render('index', array('model' => $model, 'pages' => $pages)); } } }
"><?php echo $type->name_th; ?> </a></li> <?php } ?> <li><h6><a href="<?php echo Yii::app()->createUrl('alumni/doctor'); ?> ">ปริญญาเอก</a></h6></li> <?php $criteria = new CDbCriteria(); $criteria->condition = 'status = 1 AND alumni_group=\'Doctor\''; $criteria->order = 'sort_order'; $co_type = AlumniNo::model()->findAll($criteria); foreach ($co_type as $type) { ?> <li> <img src="<?php echo Yii::app()->request->baseUrl; ?> /images/front/marker_2.gif" border="0" style="padding-top: 7px"/> <a href="<?php echo Yii::app()->createUrl('alumni', array('type_id' => $type->alumni_no_id)); ?> "><?php echo $type->name_th; ?> </a></li> <?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 AlumniNo the loaded model * @throws CHttpException */ public function loadModel($id) { $model = AlumniNo::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php /* @var $this AlumniController */ /* @var $model Alumni */ $this->breadcrumbs = array('ทำเนียบนิสิต' => array('index'), 'จัดการข้อมูล'); $this->menu = array(array('label' => 'เพิ่มข้อมูล', 'url' => array('create')), array('label' => 'Export Excel', 'url' => array('excel'))); 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\$('#alumni-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)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'alumni-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'alumni_id', '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/alumni/".$data->image, "รูปศิษย์เก่า")'), array('name' => 'name_th', 'header' => 'ชื่อ-นามสกุล', 'htmlOptions' => array('style' => 'text-align: left;width: 160px;')), array('name' => 'alumni_group', 'header' => 'ระดับ', 'value' => '($data->alumni_group==\'Master\')? \'ปริญญาโท\' : \'ปริญญาเอก\'', 'htmlOptions' => array('style' => 'text-align: left;width: 90px;'), 'filter' => array('Master' => 'ปริญญาโท', 'Doctor' => 'ปริญญาเอก')), array('name' => 'alumni_no_id', 'header' => 'รุ่นที่จบ', 'value' => '$data->alumniType->name_th', 'htmlOptions' => array('style' => 'text-align: left;width: 70px;'), 'filter' => CHtml::listData(AlumniNo::model()->findAll('status=1'), 'alumni_no_id', 'name_th')), 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')))));