/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Barang::find()->where('b0001.STATUS <> 3'); $query->joinWith(['dbtr' => function ($q) { $q->where('d0001.NM_DISTRIBUTOR LIKE "%' . $this->nmdbtr . '%"'); }]); $query->joinWith(['unitb' => function ($q) { $q->where('ub0001.NM_UNIT LIKE "%' . $this->unitbrg . '%"'); }]); $query->joinWith(['tipebg' => function ($q) { $q->where('b1001.NM_TYPE LIKE "%' . $this->tipebrg . '%"'); }]); $query->joinWith(['kategori' => function ($q) { $q->where('b1002.NM_KATEGORI LIKE "%' . $this->nmkategori . '%"'); }]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['attributes' => ['KD_BARANG', 'NM_BARANG', 'HPP', 'HARGA', 'nmdbtr' => ['asc' => ['d0001.NM_DISTRIBUTOR' => SORT_ASC], 'desc' => ['d0001.NM_DISTRIBUTOR' => SORT_DESC], 'label' => 'Supplier'], 'unitbrg' => ['asc' => ['ub0001.NM_UNIT' => SORT_ASC], 'desc' => ['ub0001.NM_UNIT' => SORT_DESC], 'label' => 'Unit Barang'], 'tipebrg' => ['asc' => ['b1001.NM_TYPE' => SORT_ASC], 'desc' => ['b1001.NM_TYPE' => SORT_DESC], 'label' => 'Tipe Barang'], 'nmkategori' => ['asc' => ['b1002.NM_KATEGORI' => SORT_ASC], 'desc' => ['b1002.NM_KATEGORI' => SORT_DESC], 'label' => 'Kategori']]]); 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. */ return $dataProvider; } $query->andFilterWhere(['like', 'HPP', $this->HPP])->andFilterWhere(['like', 'HARGA', $this->HARGA])->andFilterWhere(['like', 'b0001.KD_BARANG', $this->KD_BARANG]); return $dataProvider; /* $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere([ 'ID' => $this->ID, 'HPP' => $this->HPP, 'HARGA' => $this->HARGA, 'BARCODE' => $this->BARCODE, 'NOTE' => $this->NOTE, 'STATUS' => $this->STATUS, 'CREATED_BY' => $this->CREATED_BY, 'CREATED_AT' => $this->CREATED_AT, 'UPDATED_AT' => $this->UPDATED_AT, ]); $query->andFilterWhere(['like', 'KD_BARANG', $this->KD_BARANG]) ->andFilterWhere(['like', 'NM_BARANG', $this->NM_BARANG]) ->andFilterWhere(['like', 'KD_SUPPLIER', $this->KD_SUPPLIER]) ->andFilterWhere(['like', 'KD_DISTRIBUTOR', $this->KD_DISTRIBUTOR]) ->andFilterWhere(['like', 'DATA_ALL', $this->DATA_ALL]); return $dataProvider; */ }
public function getTbesm() { return $this->hasMany(Barang::className(), ['KD_BARANG' => 'KD_TYPE']); }
/** * Finds the Barang model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $ID * @return Barang the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($ID) { if (($model = Barang::findOne($ID)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionSimpan($id) { $rodetail = new Rodetail(); $hsl = Yii::$app->request->post(); $created = $hsl['Rodetail']['CREATED_AT']; $nmBarang = $hsl['Rodetail']['NM_BARANG']; $kdRo = $hsl['Rodetail']['KD_RO']; $kdBarang = $hsl['Rodetail']['KD_BARANG']; $qty = $hsl['Rodetail']['QTY']; $note = $hsl['Rodetail']['NOTE']; $ck = Rodetail::find()->where(['KD_BARANG' => $kdBarang, 'KD_RO' => $kdRo])->andWhere('STATUS <> 3')->one(); if (count($ck) == 1) { \Yii::$app->getSession()->setFlash('error', '<br/><br/><p class="bg-danger" style="padding:15px"><b>Barang Sudah di Masukkan</b></p>'); return $this->redirect(['buatro', 'id' => $id]); } else { $kdBrg = $hsl['Rodetail']['KD_BARANG']; $ckBrg = explode('.', $kdBrg); if ($ckBrg[0] == 'BRG') { $kdUnit = Barang::find('KD_UNIT')->where(['KD_BARANG' => $kdBrg])->one(); } else { if ($ckBrg[0] == 'BRGU') { $kdUnit = Barangumum::find('KD_UNIT')->where(['KD_BARANG' => $kdBrg])->one(); } } $rodetail->UNIT = $kdUnit->KD_UNIT; $rodetail->CREATED_AT = $created; $rodetail->NM_BARANG = $nmBarang; $rodetail->KD_RO = $kdRo; $rodetail->KD_BARANG = $kdBarang; $rodetail->QTY = $qty; $rodetail->NOTE = $note; $rodetail->save(); \Yii::$app->getSession()->setFlash('error', '<br/><br/><p class="bg-success" style="padding:15px"><b>Barang berhasil di Masukkan</b></p>'); return $this->redirect(['buatro', 'id' => $id]); } }
<td class="head">Quantity</td> <td class="head">Satuan Barang</td> <td class="head">Harga</td> <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\models\master\Unitbarang::find('NM_UNIT')->where(['KD_UNIT' => $val->UNIT])->one(); } else { $brg = lukisongroup\models\esm\Unitbarang::find('NM_UNIT')->where(['KD_UNIT' => $val->UNIT])->one(); } ?> <tr> <td><?php
$a = 0; foreach ($podet as $po => $rows) { $a = $a + 1; ?> <?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\models\master\Unitbarang::find('NM_UNIT')->where(['KD_UNIT' => $rows->UNIT])->one(); } else { $brg = lukisongroup\models\esm\Unitbarang::find('NM_UNIT')->where(['KD_UNIT' => $rows->UNIT])->one(); } ?> <td class=" accordion-toggle" data-toggle="collapse" data-target="#demo<?php echo $a;
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([' ']); }
</div> </div> <div class="form-group"> <div class="col-sm-12"> <br/> </div> </div> </form> <?php $form = ActiveForm::begin(['method' => 'post', 'action' => ['esm/requestorder/simpan?id=' . $id]]); $brgar['Barang Umum'] = $brg = ArrayHelper::map(Barangumum::find()->all(), 'KD_BARANG', 'NM_BARANG'); $brgar['Barang ESM'] = $brgs = ArrayHelper::map(Barang::find()->all(), 'KD_BARANG', 'NM_BARANG'); $unit = ArrayHelper::map(Unitbarang::find()->all(), 'KD_UNIT', 'NM_UNIT'); echo $form->field($rodetail, 'CREATED_AT')->hiddenInput(['value' => date('Y-m-d H:i:s')])->label(false); ?> <?php echo $form->field($rodetail, 'NM_BARANG')->hiddenInput(['value' => ''])->label(false); ?> <?php echo $form->field($rodetail, 'KD_RO')->textInput(['value' => $id, 'readonly' => true])->label('Kode Request Order'); ?> <div class="row"> <div class="col-xs-3"><?php