Hi all, I have table
Status
id
kode
status
Punish
id
id_punish <-- FK
nilai
berlaku_punish
I have query like this :
SELECT status.kode, status.status, m1.berlaku_punish, m1.nilai
FROM STATUS
LEFT JOIN punish m1 ON status.id = m1.id_status
AND m1.id = (
SELECT MAX( m2.id )
FROM punish m2
WHERE m2.id_status = status.id )
I was googling… for custom column cgridview with this condition, but not solved.
And my view for admin is : (this show data berlaku_punish and nilai but not with condition for max id)
<?php $this->widget('bootstrap.widgets.TbGridView', array(
'id' => 'join-status-punish-grid',
'dataProvider' => $model->search(),
'type' => 'striped bordered condensed',
'filter' => $model,
'columns' => array(
array(
'header' => 'Kode',
'name' => 'kode',
'htmlOptions'=>array('width'=>'100px'),
),
'status',
'punishes.id_status', // i have relation in has_one
'punishes.id_status',
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
'template'=>'{tambah} {detail}',
// 'header'=>'T. Operasi',
'buttons'=>array(
'tambah' => array
(
'icon'=>'icon-plus-sign',
'url'=>'Yii::app()->createUrl("master/2/punish/create", array("id"=>$data->id))',
),
'detail' => array
(
'icon'=>'icon-time',
'url'=>'Yii::app()->createUrl("master/2/punish/create", array("id"=>$data->primaryKey))',
),
),
),
),
)); ?>
Any help for this???