/** * Check KD_PO Purchasdetail * @author ptrnov <*****@*****.**> * @since 1.1 */ public function findcheck($attribute, $params) { if (!$this->hasErrors()) { $cntDetailPo = Purchasedetail::find()->where(['KD_PO' => $this->kD_PO])->count(); if (!$cntDetailPo) { $this->addError($attribute, 'Please, Input Item SKU First'); } } }
/** * Check PO PLUS| kD_PO kD_BARANG =0 | Jika Ada, update Harga/QTY * @author ptrnov <*****@*****.**> * @since 1.1 */ public function findcheck($attribute, $params) { if (!$this->hasErrors()) { $cntDetailPo = Purchasedetail::find()->where(['KD_PO' => $this->kD_PO, 'KD_BARANG' => $this->kD_BARANG])->count(); if ($cntDetailPo) { $this->addError($attribute, 'SKU Alrady Exist,Please Update Quantity or Price'); } else { $brgUmum = Barangumum::find()->where(['KD_BARANG' => $this->kD_BARANG])->one(); $brgUnit = $brgUmum->unit; $this->nM_BARANG = $brgUmum->NM_BARANG; $this->nM_UNIT = $brgUnit->NM_UNIT; $this->qTY_UNIT = $brgUnit->QTY; $this->wEIGHT_UNIT = $brgUnit->WEIGHT; } } }
/** * Check PO PLUS| kD_PO kD_BARANG =0 | Jika Ada, update Harga/QTY * @author ptrnov <*****@*****.**> * @since 1.1 */ public function findcheck($attribute, $params) { if (!$this->hasErrors()) { $cntDetailPo = Purchasedetail::find()->where('STATUS<>3 AND KD_PO="' . $this->kD_PO . '" AND KD_BARANG="' . $this->kD_BARANG . '"')->count(); if ($cntDetailPo) { $this->addError($attribute, 'SKU Alrady Exist,Please Update Quantity or Price'); } else { $brg = Barang::find()->where(['KD_BARANG' => $this->kD_BARANG])->one(); //$roDetail = Rodetail::find()->where(['KD_RO'=>$kD_RO,'KD_BARANG'=>$this->kD_BARANG])->all(); $brgUnit = $brg->unitb; $this->nM_BARANG = $brg->NM_BARANG; $this->hARGA = $brg->PARENT == 1 ? $brg->HARGA_PABRIK : $brg->HARGA_SPL; $this->nM_UNIT = $brgUnit->NM_UNIT; $this->qTY_UNIT = $brgUnit->QTY; $this->wEIGHT_UNIT = $brgUnit->WEIGHT; } } }
/** * Password Find Oldpassword for validation * @author ptrnov <*****@*****.**> * @since 1.1 */ public function findPasswords($attribute, $params) { /* * @author ptrnov <*****@*****.**> * @since 1.1 */ if (!$this->hasErrors()) { $empid = $this->getEmpid(); $id = $this->kdpo; $data = Purchasedetail::find()->where('STATUS<>3 AND KD_PO="' . $id . '"')->count(); if (!$empid || !$empid->validateOldPasswordCheck($this->password)) { $this->addError($attribute, 'Incorrect password.'); } elseif ($data == 0) { $this->addError($attribute, 'Sorry data PO ' . $data); } elseif ($this->getPermission()->BTN_SIGN1 != 1) { $this->addError($attribute, 'Wrong Permission'); } } }
public function actionCreatepo() { $post = Yii::$app->request->post(); $coall = count($post['hargaBarang']); $kdpo = $post['kdpo']; for ($i = 0; $i < $coall; $i++) { $kdBrg = $post['kdBarang'][$i]; $harga = $post['hargaBarang'][$i]; $ckBrg = explode('.', $kdBrg); if ($ckBrg[0] == 'BRG') { $nmBrg = Barang::find('NM_BARANG')->where(['KD_BARANG' => $kdBrg])->one(); $nmBrg->HARGA = $harga; $nmBrg->save(); } else { if ($ckBrg[0] == 'BRGU') { $nmBrg = Barang::find('NM_BARANG')->where(['KD_BARANG' => $kdBrg])->one(); $nmBrg->HARGA = $harga; $nmBrg->save(); } } $detpo = Purchasedetail::find('ID')->where(['KD_BARANG' => $kdBrg, 'KD_PO' => $kdpo])->one(); $cons = \Yii::$app->db_esm; $command = $cons->createCommand(); $command->update('p0002', ['HARGA' => $harga], "ID='{$detpo->ID}'")->execute(); } $po = Purchaseorder::find()->where(['KD_PO' => $kdpo])->one(); $po->STATUS = '101'; $po->PAJAK = $post['pajak']; $po->DISC = $post['disc']; $po->NOTE = $post['note']; $po->ETA = $post['eta']; $po->ETD = $post['etd']; $po->SHIPPING = $post['shipping']; $po->BILLING = $post['billing']; $po->DELIVERY_COST = $post['delvCost']; $po->save(); return $this->redirect([' ']); }
use lukisongroup\master\models\Suplier; use lukisongroup\master\models\Barangumum; use lukisongroup\master\models\Nmperusahaan; use lukisongroup\purchasing\models\pr\Purchasedetail; use lukisongroup\esm\models\Barang; /* @var $this yii\web\View */ /* @var $poHeader lukisongroup\poHeaders\esm\po\Purchaseorder */ $this->title = 'Detail PO'; $this->params['breadcrumbs'][] = ['label' => 'Purchaseorders', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; $y = 4; ?> <?php $sup = Suplier::find()->where(['KD_SUPPLIER' => $poHeader->KD_SUPPLIER])->one(); $pod = Purchasedetail::find()->where(['KD_PO' => $poHeader->KD_PO])->all(); $ship = Nmperusahaan::find()->where(['ID' => $poHeader->SHIPPING])->one(); $bill = Nmperusahaan::find()->where(['ID' => $poHeader->BILLING])->one(); /* $x=10; function ax(){ return '10'; } */ /* function formulaAmount($summary, $data, $widget){ //$calculate = dataCell($model, $key, $index); //$p = compact('model', 'key', 'index'); return '<div>'.$summary * $this->model().',</div> <div>'.min($data).'</div> <div>'.$summary.'</div> <div>100,0</div> <div><b>10000,0</b></div>';
}, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '60px', 'font-family' => 'tahoma', 'font-size' => '8pt', 'background-color' => 'rgba(0, 95, 218, 0.3)']], 'contentOptions' => ['style' => ['text-align' => 'right', 'width' => '60px', 'font-family' => 'tahoma', 'font-size' => '8pt']], 'pageSummaryOptions' => ['style' => ['border-left' => '0px', 'border-right' => '0px']]], ['attribute' => 'UNIT', 'mergeHeader' => true, 'label' => 'UoM', 'vAlign' => 'middle', 'hAlign' => 'right', 'value' => function ($model) { $model = Unitbarang::find()->where('KD_UNIT="' . $model->UNIT . '"')->one(); if (count($model) != 0) { $UnitNm = $model->NM_UNIT; } else { $UnitNm = 'Not Set'; } return $UnitNm; }, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '150px', 'font-family' => 'tahoma', 'font-size' => '8pt', 'background-color' => 'rgba(0, 95, 218, 0.3)']], 'contentOptions' => ['style' => ['text-align' => 'left', 'width' => '150px', 'font-family' => 'tahoma', 'font-size' => '8pt', 'border-left' => '0px']], 'pageSummaryOptions' => ['style' => ['border-left' => '0px', 'border-right' => '0px']], 'pageSummary' => function ($summary, $data, $widget) { return '<div>Sub Total :</div> <div>Discount :</div> <div>TAX :</div> <div>Delevery.Cost :</div> <div><b>GRAND TOTAL :</b></div>'; }, 'pageSummaryOptions' => ['style' => ['font-family' => 'tahoma', 'font-size' => '8pt', 'text-align' => 'right', 'border-left' => '0px', 'border-right' => '0px']]], ['attribute' => 'HARGA', 'label' => 'Price', 'vAlign' => 'middle', 'hAlign' => 'center', 'mergeHeader' => true, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '100px', 'font-family' => 'tahoma', 'font-size' => '8pt', 'background-color' => 'rgba(0, 95, 218, 0.3)']], 'contentOptions' => ['style' => ['text-align' => 'right', 'width' => '100px', 'font-family' => 'tahoma', 'font-size' => '8pt']], 'pageSummaryOptions' => ['style' => ['border-left' => '0px', 'border-right' => '0px']]], ['class' => 'kartik\\grid\\CheckboxColumn', 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '20px', 'font-family' => 'tahoma', 'font-size' => '8pt', 'background-color' => 'rgba(0, 95, 218, 0.3)']], 'contentOptions' => ['readonly' => true, 'style' => ['text-align' => 'center', 'width' => '20px', 'font-family' => 'tahoma', 'font-size' => '8pt', 'border-left' => '0px']], 'checkboxOptions' => ['is' => 'ck-gv', 'class' => 'simple', 'style' => ['text-align' => 'left', 'width' => '20px', 'font-family' => 'tahoma', 'font-size' => '8pt', 'border-left' => '0px']], 'rowSelectedClass' => GridView::TYPE_WARNING, 'checkboxOptions' => function ($model, $key, $index, $column) use($kdpo) { $poDetail = Purchasedetail::find()->where('STATUS<>3 AND KD_PO="' . $kdpo . '" AND KD_RO="' . $model->KD_RO . '" AND KD_BARANG="' . $model->KD_BARANG . '"')->one(); if ($poDetail) { return ['checked' => $model->TMP_CK, 'hidden' => true]; } else { /*FORMULA*/ $pqtyTaken = "SELECT SUM(QTY) as QTY FROM p0002 WHERE STATUS<>3 AND KD_RO='" . $model->KD_RO . "' AND KD_BARANG='" . $model->KD_BARANG . "' GROUP BY KD_BARANG"; $countQtyTaken = Purchasedetail::findBySql($pqtyTaken)->one(); if ($countQtyTaken) { $qtyInPo = $countQtyTaken->QTY != '' ? $countQtyTaken->QTY : 0; } else { $qtyInPo = 0; } //$qtyInPo=$countQtyTaken!=''? $countQtyTaken->QTY :0; $actualQty = $model->SQTY - $qtyInPo; if ($actualQty > 0) { return ['checked' => $model->TMP_CK];
public function actionCetakpdf($kdpo) { $poHeader = Purchaseorder::find()->where(['KD_PO' => $kdpo])->one(); $poDetail = Purchasedetail::find()->where(['KD_PO' => $kdpo])->all(); $dataProvider = new ArrayDataProvider(['key' => 'KD_PO', 'allModels' => $poDetail, 'pagination' => ['pageSize' => 20]]); $content = $this->renderPartial('pdf', ['poHeader' => $poHeader, 'dataProvider' => $dataProvider]); $pdf = new Pdf(['mode' => Pdf::MODE_CORE, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@lukisongroup/web/widget/pdf-asset/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:12px}', 'options' => ['title' => 'Form Request Order', 'subject' => 'ro'], 'methods' => ['SetHeader' => ['Copyright@LukisonGroup ' . date("r")], 'SetFooter' => ['{PAGENO}']]]); return $pdf->render(); /* $mpdf=new mPDF(); $mpdf->WriteHTML($this->renderPartial( 'pdf', [ 'model' => Purchaseorder::find()->where(['KD_PO'=>$kdpo])->one(), ])); $mpdf->Output(); exit; */ }
public function actionDelpo($idpo, $kdpo) { $podet = Podetail::find()->where(['KD_PO' => $kdpo, 'ID' => $idpo])->one(); $po = Purchasedetail::find()->where(['KD_PO' => $kdpo, 'ID' => $podet->ID_DET_PO])->one(); $sisa = $po->QTY - $podet->QTY; if ($sisa == '0') { \Yii::$app->db_esm->createCommand()->update('p0002', ['QTY' => $sisa, 'STATUS' => '3'], "ID='{$po->ID}'")->execute(); } else { \Yii::$app->db_esm->createCommand()->update('p0002', ['QTY' => $sisa], "ID='{$po->ID}'")->execute(); } $podet->STATUS = '3'; $podet->save(); return $this->redirect(['create', 'kdpo' => $kdpo]); }