<?php /* @var $this PengadaanController */ /* @var $model Pengadaan */ $this->breadcrumbs = array('Pengadaans' => array('index'), 'Create'); $this->menu = array(array('label' => 'List Pengadaan', 'url' => array('index')), array('label' => 'Manage Pengadaan', 'url' => array('admin'))); ?> <h1>Pilih jenis Spare-parts yang akan diadakan</h1> <?php $this->renderPartial('/sparepart/admin', array('model' => Sparepart::model()));
public function actionSetuju($id) { $model = $this->loadModel($id); $relasi = RelasiPengadaanSparepart::model()->findAllByAttributes(array('ID_PENGADAAN' => $id)); foreach ($relasi as $rel) { $stok = Yii::app()->db->createCommand()->select('STOK')->from('sparepart')->where('ID_SPAREPART=:ID_SPAREPART', array(':ID_SPAREPART' => $rel->ID_SPAREPART))->queryScalar(); if ($stok == NULL) { $stok = $rel->JUMLAH; } else { $stok = $stok + $rel->JUMLAH; } Sparepart::model()->updateByPk($rel->ID_SPAREPART, array("STOK" => $stok)); } Pengadaan::model()->updateByPk($id, array("STATUS" => "DISETUJUI KEUANGAN")); $this->redirect(array('admin')); }
/** * 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 Sparepart the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Sparepart::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }