public function barangumum($kdCorp, $kdType, $kdKategori, $kdUnit) { $ck = Barangumum::find()->select('KD_BARANG')->where(['KD_CORP' => $kdCorp])->andWhere('STATUS <> 3')->orderBy(['ID' => SORT_DESC])->one(); if (count($ck) == 0) { $nkd = 1; } else { $kd = explode('.', $ck->KD_BARANG); $nkd = $kd[5] + 1; } $kd = "BRGU." . $kdCorp . "." . $kdType . "." . $kdKategori . "." . $kdUnit . "." . str_pad($nkd, "4", "0", STR_PAD_LEFT); return $kd; }
/** * 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; } } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Barangumum::find()->where('b1000.STATUS <> 3'); $query->joinWith(['type' => function ($q) { $q->where('b1001.NM_TYPE LIKE "%' . $this->nmtype . '%"'); }]); $query->joinWith(['kategori' => function ($q) { $q->where('b1002.NM_KATEGORI LIKE "%' . $this->nmktegori . '%"'); }]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['attributes' => ['KD_BARANG', 'NM_BARANG', 'nmtype' => ['asc' => ['b1001.NM_TYPE' => SORT_ASC], 'desc' => ['b1001.NM_TYPE' => SORT_DESC], 'label' => 'Type'], 'nmktegori' => ['asc' => ['b1002.NM_KATEGORI' => SORT_ASC], 'desc' => ['b1002.NM_KATEGORI' => SORT_DESC], 'label' => 'Type']]]); if (!($this->load($params) && $this->validate())) { /** * The following line will allow eager loading with country data * to enable sorting by country on initial loading of the grid. */ $query->joinWith(['type']); $query->joinWith(['kategori']); return $dataProvider; } $query->andFilterWhere(['NM_BARANG' => $this->NM_BARANG, 'KD_BARANG' => $this->KD_BARANG, 'HARGA' => $this->HARGA]); // $query->andFilterWhere(['like', 'KD_BARANG', $this->KD_BARANG]) // ->andFilterWhere(['like', 'NM_BARANG', $this->NM_BARANG]); // ->andFilterWhere(['like', 'KD_TYPE', $this->KD_TYPE]) // ->andFilterWhere(['like', 'KD_KATEGORI', $this->KD_TYPE]) // ->andFilterWhere(['like', 'KD_UNIT', $this->KD_UNIT]) // ->andFilterWhere(['like', 'KD_SUPPLIER', $this->KD_SUPPLIER]) // ->andFilterWhere(['like', 'KD_DISTRIBUTOR', $this->KD_DISTRIBUTOR]) // ->andFilterWhere(['like', 'BARCODE', $this->BARCODE]) // ->andFilterWhere(['like', 'IMAGE', $this->IMAGE]) // ->andFilterWhere(['like', 'NOTE', $this->NOTE]) // ->andFilterWhere(['like', 'KD_CORP', $this->KD_CORP]) // ->andFilterWhere(['like', 'KD_CAB', $this->KD_CAB]) // ->andFilterWhere(['like', 'KD_DEP', $this->KD_DEP]) // ->andFilterWhere(['like', 'CREATED_BY', $this->CREATED_BY]) // ->andFilterWhere(['like', 'UPDATED_BY', $this->UPDATED_BY]) // ->andFilterWhere(['like', 'DATA_ALL', $this->DATA_ALL]); return $dataProvider; }
use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use kartik\widgets\Select2; use kartik\widgets\DepDrop; use yii\helpers\Url; use kartik\builder\Form; use kartik\widgets\TouchSpin; use yii\web\JsExpression; use yii\data\ActiveDataProvider; use lukisongroup\master\models\Barangumum; use lukisongroup\esm\models\Barang; use lukisongroup\master\models\Kategori; use lukisongroup\master\models\Unitbarang; $brgUnit = ArrayHelper::map(Unitbarang::find()->orderBy('NM_UNIT')->all(), 'KD_UNIT', 'NM_UNIT'); $brgKtg = ArrayHelper::map(Kategori::find()->orderBy('NM_KATEGORI')->all(), 'KD_KATEGORI', 'NM_KATEGORI'); $brgUmum = ArrayHelper::map(Barangumum::find()->orderBy('NM_BARANG')->all(), 'KD_BARANG', 'NM_BARANG'); /* $this->registerJs(" $.fn.modal.Constructor.prototype.enforceFocus = function() {}; ",$this::POS_HEAD); */ ?> <?php $form = ActiveForm::begin(['id' => 'roInput', 'enableClientValidation' => true, 'method' => 'post', 'action' => ['/purchasing/request-order/simpanfirst']]); ?> <?php //= $form->errorSummary($model); ?> <?php
public function getBrgumum() { return $this->hasOne(Barangumum::className(), ['KD_BARANG' => 'KD_BARANG']); }
public function actionSimpantambah() { $roDetail = new Rodetail(); if ($roDetail->load(Yii::$app->request->post()) && $roDetail->validate()) { $hsl = \Yii::$app->request->post(); $kdro = $hsl['Rodetail']['KD_RO']; $kdBarang = $hsl['Rodetail']['KD_BARANG']; $nmBarang = Barangumum::findOne(['KD_BARANG' => $kdBarang]); $kdUnit = $hsl['Rodetail']['UNIT']; $rqty = $hsl['Rodetail']['RQTY']; $note = $hsl['Rodetail']['NOTE']; /* * Detail Request Order **/ $roDetail->KD_RO = $kdro; $roDetail->CREATED_AT = date('Y-m-d H:i:s'); $roDetail->NM_BARANG = $nmBarang->NM_BARANG; $roDetail->KD_BARANG = $kdBarang; $roDetail->UNIT = $kdUnit; $roDetail->RQTY = $rqty; $roDetail->NOTE = $note; $roDetail->STATUS = 0; $roDetail->save(); return $this->redirect(['index?RequestorderSearch[KD_RO]=' . $kdro]); } else { return $this->redirect(['index']); } }
<td class="head">Total Harga</td> </tr> <tbody> <?php $total = 0; $a = 0; foreach ($pod as $key => $val) { $a = $a + 1; $ckBrg = explode('.', $val->KD_BARANG); if ($ckBrg[0] == 'BRG') { $nmBrg = Barang::find('NM_BARANG')->where(['KD_BARANG' => $val->KD_BARANG])->one(); } else { if ($ckBrg[0] == 'BRGU') { $nmBrg = Barangumum::find('NM_BARANG')->where(['KD_BARANG' => $val->KD_BARANG])->one(); } } $ckUnit = preg_replace("/[^A-Z\\']/", '', $val->UNIT); if ($ckUnit == 'U') { $brg = lukisongroup\master\models\Unitbarang::find('NM_UNIT')->where(['KD_UNIT' => $val->UNIT])->one(); } else { $brg = lukisongroup\esm\models\Unitbarang::find('NM_UNIT')->where(['KD_UNIT' => $val->UNIT])->one(); } ?> <tr> <td><?php echo $a; ?> </td>
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 = Barangumum::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([' ']); }
protected function namaBarang($kdBarang) { $nmBarang = Barangumum::findOne(['KD_BARANG' => $kdBarang]); return $nmBarang->NM_BARANG; }
?> <?php if ($a == 1) { echo "</form>"; } ?> <tr style="cursor:pointer;"> <?php $ckBrg = explode('.', $rows->KD_BARANG); if ($ckBrg[0] == 'BRG') { $nmBrg = Barang::find('NM_BARANG', 'HARGA')->where(['KD_BARANG' => $rows->KD_BARANG])->one(); } else { if ($ckBrg[0] == 'BRGU') { $nmBrg = Barangumum::find('NM_BARANG', 'HARGA')->where(['KD_BARANG' => $rows->KD_BARANG])->one(); } } $ckUnit = preg_replace("/[^A-Z\\']/", '', $rows->UNIT); if ($ckUnit == 'U') { $brg = lukisongroup\master\models\Unitbarang::find('NM_UNIT')->where(['KD_UNIT' => $rows->UNIT])->one(); } else { $brg = lukisongroup\esm\models\Unitbarang::find('NM_UNIT')->where(['KD_UNIT' => $rows->UNIT])->one(); } ?> <td class=" accordion-toggle" data-toggle="collapse" data-target="#demo<?php echo $a; ?> "><?php echo $a;