/* @var $this BanController */ /* @var $model Ban */ $this->breadcrumbs = array('Data Ban'); ?> <h1>Data Ban</h1> <div class="search-form"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <p></p> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'perbaikan-grid', 'type' => TbHtml::GRID_TYPE_HOVER, 'dataProvider' => $model->search(), 'columns' => array(array('header' => 'Posisi Ban', 'value' => '$data->iDPOSISI->POSISI'), array('name' => 'NOMOR_SERI'), array('name' => 'MERK'), array('name' => 'HARGA'), array('name' => 'JUMLAH'), array('header' => 'Aksi', 'type' => 'raw', 'value' => 'TbHtml::link("Ambil", array("Ambilban", "id"=>$_GET[\'id\'], "id_ban"=>$data->ID_BAN),array("style" => "font-weight:900;text-decoration:none;"))')))); ?> <p></p> <?php $this->renderPartial('/relasiPb/view', array('model' => RelasiPb::model(), 'id' => '$_GET[\'id\']')); ?> <p></p> <div align="right"> <?php echo TbHtml::formActions(array(TbHtml::linkButton('SELESAI', array('submit' => array('perbaikan/admin'), 'style' => 'text-decoration:none;', 'color' => TbHtml::BUTTON_COLOR_PRIMARY)))); ?> </div>
public function actionHapusrelasi($id) { $model = RelasiPb::model()->findByAttributes(array('ID_PERBAIKAN' => $id)); $jumlah_tambah = $model->JUMLAH; $jumlah_ban = Yii::app()->db->createCommand()->select('JUMLAH')->from('ban')->where('ID_BAN=:ID_BAN', array(':ID_BAN' => $model->ID_BAN))->queryScalar(); $jumlah_ban = $jumlah_ban + $jumlah_tambah; Yii::app()->db->createCommand()->update('ban', array('JUMLAH' => $jumlah_ban), 'ID_BAN=:ID_BAN', array(':ID_BAN' => $model->ID_BAN)); $relasi = RelasiPb::model()->findByPk($model->ID_RELASI_PB); $relasi->delete(); Yii::app()->db->createCommand()->update('perbaikan', array('STATUS' => 'Ganti Ban'), 'ID_PERBAIKAN=:ID_PERBAIKAN', array(':ID_PERBAIKAN' => $id)); $this->redirect(array('ban/index', 'id' => $id)); }
/** * 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 RelasiPb the loaded model * @throws CHttpException */ public function loadModel($id) { $model = RelasiPb::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }