/** * Check QTY SUM |RoDetail <= Purchasdetail * @author ptrnov <*****@*****.**> * @since 1.1 */ public function findcheck($attribute, $params) { if (!$this->hasErrors()) { $roDetail = Rodetail::find()->where(['ID' => $this->{$iD}])->one(); //$cntDetailPo = Purchasedetail::find()->where(['KD_PO'=>$this->kD_PO,'KD_BARANG'=>$this->kD_BARANG])->count(); $pqtyTaken = "SELECT SUM(QTY) as QTY FROM p0002 WHERE KD_RO='" . $roDetail->kD_RO . "' AND KD_BARANG='" . $roDetail->kD_BARANG . "'"; $poDetailQtySum = Purchasedetail::findBySql($pqtyTaken)->one(); //$roDetail=Rodetail::find()->where(['KD_RO'=>$this->kD_PO,'KD_BARANG'=>$this->kD_BARANG])->one(); $poQty = $poDetailQtySum->QTY != '' ? $poDetailQtySum->QTY : 0; $roQty = $roDetail->SQTY; if ($poDetailQtySum) { $ttlPQTY = $roQty - $poQty; if ($this->PQTY > $ttlPQTY) { $this->addError($attribute, 'QTY Request Order Limited, please insert free Qty, Check Request Order'); } } elseif (!$poDetailQtySum) { if ($this->PQTY > $roQty) { $this->addError($attribute, 'QTY Request Order Limited, please insert free Qty, Check Request Order'); } } } }
public function actionTempCetakpdf($kdpo) { $poHeader = Purchaseorder::find()->where(['KD_PO' => $kdpo])->one(); //$poDetail = Purchasedetail::find()->where(['KD_PO'=>$kdpo])->all(); $poDetailQry = "SELECT ID,KD_PO,KD_RO,KD_BARANG,NM_BARANG,UNIT,NM_UNIT,UNIT_QTY,UNIT_WIGHT,SUM(QTY) AS QTY,HARGA,STATUS,STATUS_DATE,NOTE\n\t\t\t\t\t\tFROM `p0002` WHERE KD_PO='" . $kdpo . "' GROUP BY KD_BARANG,NM_UNIT,HARGA"; $poDetail = Purchasedetail::findBySql($poDetailQry)->all(); $dataProvider = new ArrayDataProvider(['key' => 'KD_PO', 'allModels' => $poDetail, 'pagination' => ['pageSize' => 20]]); $content = $this->renderPartial('pdf_tmp', ['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; */ }
} 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]; } else { return ['checked' => $model->TMP_CK, 'hidden' => true]; } } }]], 'pjax' => true, 'pjaxSettings' => ['options' => ['enablePushState' => true, 'id' => 'gv-ropo']], 'hover' => true, 'responsive' => true, 'responsiveWrap' => true, 'bordered' => true, 'striped' => '4px', 'autoXlFormat' => true, 'export' => false]); ?>