/** * Finds the Vendor model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Vendor the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Vendor::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getVendor() { return $this->hasOne(Vendor::className(), ['id' => 'vendor_id']); }
public function actionVendorList($term = '') { $response = Yii::$app->response; $response->format = 'json'; return Vendor::find()->filterWhere(['like', 'lower([[name]])', strtolower($term)])->orFilterWhere(['like', 'lower([[code]])', strtolower($term)])->limit(10)->asArray()->all(); }
<?php echo $form->field($model, 'type')->dropDownList(Vendor::enums('TYPE_'), ['style' => 'width:30%']); ?> <?php echo $form->field($model, 'code')->textInput(['maxlength' => true, 'style' => 'width:40%']); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'contact_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'contact_number')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'status')->dropDownList(Vendor::enums('STATUS_'), ['style' => 'width:30%']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
<?php use yii\helpers\Html; use yii\grid\GridView; use backend\models\master\Vendor; /* @var $this yii\web\View */ /* @var $searchModel backend\models\master\search\Vendor */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = $searchModel->nmType ? ucfirst(strtolower($searchModel->nmType)) : 'Vendor'; $this->params['breadcrumbs'][] = $this->title; ?> <p class='pull-right'> <?php echo Html::a('Create ' . ($searchModel->nmType ? ucfirst(strtolower($searchModel->nmType)) : 'Vendor'), ['create', 'type' => $searchModel->type], ['class' => 'btn btn-default']); ?> </p> <br> <div class="vendor-index"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'tableOptions' => ['class' => 'table table-hover'], 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'code', 'name', 'contact_name', 'contact_number', ['attribute' => 'status', 'value' => 'nmStatus', 'filter' => Vendor::enums('STATUS_')], 'created_at:datetime', ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
<?php use yii\helpers\Html; use yii\grid\GridView; use backend\models\inventory\GoodsMovement; use backend\models\master\Warehouse; /* @var $this yii\web\View */ /* @var $searchModel GoodsMovement */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = $searchModel->type == GoodsMovement::TYPE_RECEIVE ? 'Penerimaan' : 'Mutasi'; $this->title = $searchModel->type == GoodsMovement::TYPE_ISSUE ? 'Pengeluaran' : $this->title; $this->title .= ' Barang'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="col-lg-12"> <div class='btn-group pull-right'> <?php echo $searchModel->type ? Html::a($searchModel->type == GoodsMovement::TYPE_RECEIVE ? 'Penerimaan Baru' : 'Pengeluaran Baru', ['inventory/gm-manual/create', 'type' => $searchModel->type], ['class' => 'btn btn-default']) : ''; ?> </div> </div> <br><br> <div class="col-lg-12 goods-movement-index"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'tableOptions' => ['class' => 'table table-hover'], 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'number', ['attribute' => 'type', 'value' => 'nmType', 'filter' => GoodsMovement::enums('TYPE_')], 'description', ['attribute' => 'warehouse_id', 'value' => 'warehouse.name', 'filter' => Warehouse::selectOptions()], ['attribute' => 'vendor_id', 'value' => 'vendor.name', 'filter' => \backend\models\master\Vendor::selectOptions()], 'date', ['attribute' => 'status', 'value' => 'nmStatus', 'filter' => GoodsMovement::enums('STATUS_')], ['label' => 'Invoice Number', 'format' => 'raw', 'value' => function ($model) { return $model->invoice != null ? Html::a($model->invoice->number, ['/accounting/invoice/view', 'id' => $model->invoice->id]) : ''; }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getVendors() { return $this->hasMany(Vendor::className(), ['id' => 'vendor_id'])->viaTable('product_vendor', ['product_id' => 'id']); }