</div> <?php echo $form->error($detil_item, 'TANGGAL_JATUH_TEMPO'); ?> </div> </div> <div class="form-group"> <?php echo $form->labelEx($detil_item, 'STATUS_PEMBAYARAN', array('class' => 'control-label col-md-3')); ?> <div class="col-md-9"> <div class="input-group"> <div class="radio-list"> <?php echo $form->radioButtonList($detil_item, 'STATUS_PEMBAYARAN', DetilItem::listStatusPembayaran(), array('class' => 'form-control input-large', 'labelOptions' => array('style' => 'display:inline'), 'template' => '{input} {label}', 'onchange' => ' var today = new Date(); var dateFormatted = today.toISOString().substr(0,10); if(this.value == ' . DetilItem::STATUS_HUTANG . ') { $("#DetilItem_TANGGAL_PEMBAYARAN").attr("value", ""); } else { $("#DetilItem_TANGGAL_PEMBAYARAN").attr("value", dateFormatted); } ')); ?> </div> </div> </div> </div>
public static function updateStokItem($iditem, $permintaan) { $stok = self::getTotalStok($iditem); if ($stok >= $permintaan) { $criteria = new CDbCriteria(); $criteria->condition = 'ID_ITEM=:iditem'; $criteria->params = array(':iditem' => $iditem); $criteria->order = 'STOK DESC'; $detilbarang = DetilItem::model()->findAll($criteria); $temp = $permintaan; foreach ($detilbarang as $databarang) { $databarang->scenario = 'updatestok'; if ($databarang->STOK >= $temp) { $databarang->STOK = $databarang->STOK - $temp; $databarang->save(); break; } else { $temp = $databarang->STOK - $temp; //ini hasil pasti minus if ($temp <= 0) { $databarang->STOK = 0; } $temp = abs($temp); $databarang->save(); } } } else { //jelas ndak boleh return false; } }
public function actionStep($id) { DetilItem::model()->updateByPk($id, array('STATUS_PEMBAYARAN' => DetilItem::STATUS_LUNAS, 'TANGGAL_PEMBAYARAN' => date('Y-m-d'))); $item = DetilItem::model()->findByPk($id); Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Sukses!</strong> Data telah berhasil disimpan.')); //$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index')); $this->redirect(array('view', 'id' => $item->ID_ITEM)); }