use kartik\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use kartik\widgets\Select2; use kartik\widgets\TouchSpin; use lukisongroup\master\models\Customer; use lukisongroup\esm\models\Barang; use yii\web\JsExpression; /* @var $this yii\web\View */ /* @var $model crm\salespromo\models\Stock_gudang */ /* @var $form yii\widgets\ActiveForm */ //$cust = ArrayHelper::map(Customer::find(), 'CUST_KD', 'CUST_NM'); /*TEST ARRAY*/ $data = ["red" => "red", "green" => "green", "blue" => "blue", "orange" => "orange", "white" => "white", "black" => "black", "purple" => "purple", "cyan" => "cyan", "teal" => "teal"]; $cust = ArrayHelper::map(Customer::find()->orderBy('CUST_NM')->all(), 'CUST_KD', 'CUST_NM'); $esm_brg = ArrayHelper::map(Barang::find()->orderBy('NM_BARANG')->all(), 'KD_BARANG', 'NM_BARANG'); //$url = \yii\helpers\Url::to(['/salespromo/stock-gudang/cust-list']); /* $this->registerJs(" $.fn.modal.Constructor.prototype.enforceFocus = function() {}; ",$this::POS_HEAD); */ ?> <div class="stock-gudang-form"> <?php $form = ActiveForm::begin(['id' => 'afspgudang', 'enableClientValidation' => true, 'method' => 'post', 'action' => ['/salespromo/stock-gudang/simpan']]); ?> <?php //= $form->errorSummary($model);
public function actionCustList($q = null, $CUST_KD = null) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $out = ['results' => ['CUST_KD' => '', 'text' => '']]; if (!is_null($q)) { $query = new Query(); $query->select('CUST_KD, CUST_NM AS text')->from('customer')->where(['like', 'CUST_NM', $q])->limit(20); $command = $query->createCommand(); $data = $command->queryAll(); $out['results'] = array_values($data); } elseif ($id > 0) { $out['results'] = ['id' => $CUST_KD, 'text' => Customer::find($id)->CUST_NM]; } return $out; }
echo Html::encode($this->title); ?> </h3> <h4><?php echo '<h6>Tanggal : ' . Yii::$app->ambilKonvesi->convert(date('Y-m-d'), 'date') . '</h6>'; ?> </h4> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'WAKTU', ['attribute' => 'CUST_KD', 'format' => 'html', 'value' => function ($model, $key, $index, $widget) { $cus_atrb = Customer::find()->where(['CUST_KD' => $model->CUST_KD])->one(); if (count($cus_atrb) == 0) { return '<div style="color:red"> CUST_KD Changed </div>'; } else { return $cus_atrb['CUST_NM']; } }], ['attribute' => 'KD_BARANG', 'format' => 'html', 'value' => function ($model, $key, $index, $widget) { $brg_atrb = Barang::find()->where(['KD_BARANG' => $model->KD_BARANG])->one(); if (count($brg_atrb) == 0) { return '<div style="color:red"> KD_BARANG Changed </div>'; } else { return $brg_atrb['NM_BARANG']; } }], ['label' => 'Stock-Unit', 'hAlign' => 'right', 'attribute' => 'STOCK_GUDANG_UNIT'], ['label' => 'Stock-PCS', 'hAlign' => 'right', 'attribute' => 'STOCK_GUDANG_PCS'], 'CREATED_BY'], 'pjax' => true, 'pjaxSettings' => ['options' => ['enablePushState' => false, 'id' => 'active']], 'toolbar' => ['{export}'], 'panel' => ['type' => 'warning', 'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> ' . Yii::t('app', 'Stock Gudang ', ['modelClass' => 'customer']), '/salespromo/stock-gudang/create', ['data-toggle' => "modal", 'data-target' => "#stock-gudang", 'class' => 'btn btn-success']), 'showFooter' => false], 'export' => ['target' => GridView::TARGET_BLANK], 'exportConfig' => [GridView::PDF => ['filename' => 'customer' . '-' . date('ymdHis')], GridView::EXCEL => ['filename' => 'customer' . '-' . date('ymdHis')]]]); ?>