Setelah kita mengcustomisasi CGridView untukng sending for approval, langkah selanjutnya adalah membuat konformasi mengenai proses ini dan mengeksekusinya.
Untuk itu pada controller controllers/MutationOrderController kita tambahkan :
public function actionSend($id,$exe)
{
$cd_status_old=0;
$model=$this->loadModel($id);
if ($model->cd_status!=$cd_status_old)
{
$this->redirect(array(‘view’,’id’=>$model->mutation_order_id));
}
$model->cd_status=1;
if ($exe)
{
$trx=$model->dbConnection->beginTransaction();
try
{
$model->save();
$trx->commit();
Yii::app()->user->setFlash(“pesan”,”Sending for approval Success”);
$this->redirect(array(‘view’,’id’=>$model->mutation_order_id));
}
catch(Exception $e)
{
$trx->rollback();
}
}
$this->render(‘send’,array(
‘model’=>$this->loadModel($id),
));
}
Kemudian kita tambahkan views/mutationOrder/send.php seperti gambar di bawah ini:
<?php
$this->breadcrumbs=array(
Yii::app()->user->getState(“s_group_name”)=>array(‘user/menu’,’group_id’=>Yii::app()->user->getState(“s_group_id”)),
$model->mutation_no,
);
<h1>Send for approval MutationOrder #<?php echo $model->mutation_no; ?></h1>
<?php $this->widget(‘zii.widgets.CDetailView’, array(
‘data’=>$model,
‘attributes’=>array(
‘branch.branch_name’,
‘store.store_name’,
array(
‘name’=>’mutation_type’,
‘value’=>$model->getMutTypeStr($model->mutation_type) ,
),
‘date_mutation’,
‘time_mutation’,
‘mutation_no’,
‘reference_no’,
array(
‘name’=>’cd_status’,
‘value’=>$model->getStatusStr($model->cd_status) ,
),
‘user_draft’,
‘time_draft’,
‘user_approve’,
‘time_approve’,
‘remark’,
),
)); ?>
<?php echo CHtml::Button(‘Send for approval Now!’,array(‘onClick’=>”location=’index.php?r=mutationOrder/send&id=$model->mutation_order_id&exe=1′”)); ?>
<?php echo CHtml::Button(‘Cancel’,array(‘onClick’=>”location=’index.php?r=mutationOrder/admin'”)); ?>
Hasilnya bisa dilihat seperti gambar di bawah ini:
Kunjungi www.proweb.co.id untuk menambah wawasan anda.