示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SupplierModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#2
0
$this->title = 'Purchases';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row purchase-index">
    <section class="col-lg-12">
        <?php 
echo Toolbar::widget(['items' => [['label' => '', 'url' => ['print-html'], 'icon' => 'fa fa-print', 'linkOptions' => ['class' => 'btn btn-default btn-sm disabled', 'target' => '_blank', 'title' => 'Html Print']], ['label' => '', 'url' => ['print-pdf'], 'icon' => 'fa fa-file', 'linkOptions' => ['class' => 'btn btn-default btn-sm disabled', 'target' => '_blank', 'title' => 'Export to Pdf']], ['label' => '', 'url' => ['print-xsl'], 'icon' => 'fa fa-table', 'linkOptions' => ['class' => 'btn btn-default btn-sm disabled', 'target' => '_blank', 'title' => 'Export to Excel']]]]) . '&nbsp;&nbsp;';
echo ActionToolbar::widget(['items' => [['label' => 'Create New', 'url' => ['create', 'type' => 100], 'icon' => 'fa fa-plus-square'], ['label' => 'Update', 'url' => ['update'], 'icon' => 'fa fa-pencil', 'linkOptions' => ['class' => 'disabled']], ['label' => 'Delete', 'url' => ['delete'], 'icon' => 'fa fa-trash-o', 'linkOptions' => ['class' => 'disabled', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]], ['label' => 'PO List', 'url' => ['index'], 'icon' => 'fa fa-list', 'linkOptions' => ['class' => 'disabled']]]]);
?>
        <div class="box box-info">
            <div class="box-body no-padding">
                <?php 
\yii\widgets\Pjax::begin(['enablePushState' => false]);
?>
                <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => "{items}\n{pager}", 'tableOptions' => ['class' => 'table table-striped'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'number', ['attribute' => 'supplier_id', 'value' => 'supplier.name', 'filter' => Supplier::selectOptions()], ['attribute' => 'branch_id', 'value' => 'branch.name', 'filter' => Branch::selectOptions()], 'date:date', 'value:currency', ['attribute' => 'status', 'format' => 'raw', 'value' => function ($data) {
    $color = $data->status == Purchase::STATUS_DRAFT ? 'danger' : 'success';
    $color = $data->status == Purchase::STATUS_CONFIRMED ? 'warning' : $color;
    $color = $data->status == Purchase::STATUS_PROCESS ? 'info' : $color;
    $color = $data->status == Purchase::STATUS_CLOSE ? 'success' : $color;
    return Html::tag('small', $data->nmStatus, ['class' => 'label label-' . $color]);
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
                <?php 
\yii\widgets\Pjax::end();
?>
            </div>
    </section>
</div>

示例#3
0
 public function behaviors()
 {
     $behaviors = parent::behaviors();
     return array_merge($behaviors, [['class' => 'mdm\\converter\\DateConverter', 'attributes' => ['Date' => 'date']], ['class' => 'mdm\\converter\\RelatedConverter', 'attributes' => ['nmSupplier' => [[Supplier::className(), 'id' => 'supplier_id'], 'name']]]]);
 }
示例#4
0
use app\models\master\Branch;
use app\models\master\Supplier;
/* @var $this yii\web\View */
/* @var $searchModel app\models\purchase\searchs\Purchase */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Purchase List';
$this->params['breadcrumbs'][] = ['label' => 'Prices', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="purchase-index">
    <?php 
echo Toolbar::widget(['items' => [['label' => 'Create', 'url' => ['create'], 'icon' => 'fa fa-plus-square', 'linkOptions' => ['class' => 'btn btn-success btn-sm']]]]);
?>
    <div class="box box-info">
        <div class="box-body no-padding">
            <?php 
\yii\widgets\Pjax::begin(['enablePushState' => false]);
?>
            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => "{items}\n{pager}", 'tableOptions' => ['class' => 'table table-striped'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'number', ['attribute' => 'supplier_id', 'value' => 'supplier.name', 'filter' => Supplier::selectOptions()], ['attribute' => 'branch_id', 'value' => 'branch.name', 'filter' => Branch::selectOptions()], 'date:date', 'value:currency', ['attribute' => 'status', 'value' => 'nmStatus', 'filter' => [Purchase::STATUS_DRAFT => 'Draft', Purchase::STATUS_PROCESS => 'Process', Purchase::STATUS_CLOSE => 'Close']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{create-by-po}', 'buttons' => ['create-by-po' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, ['title' => Yii::t('yii', 'View'), 'data-pjax' => '0']);
}]]]]);
?>
            <?php 
\yii\widgets\Pjax::end();
?>
        </div>
    </div>
</div>

 /**
  * Finds the Supplier model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Supplier the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Supplier::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#6
0
 public static function getMasters($masters)
 {
     $masters = array_flip($masters);
     $result = [];
     // master product
     if (isset($masters['products'])) {
         $query_product = Product::find()->select(['id', 'cd' => 'code', 'text' => 'name', 'label' => 'name'])->andWhere(['status' => Product::STATUS_ACTIVE])->indexBy('id')->asArray();
         $products = $query_product->all();
         $query_uom = ProductUom::find()->select(['pu.product_id', 'pu.uom_id', 'pu.isi', 'uom_nm' => 'u.name'])->from(ProductUom::tableName() . ' pu')->joinWith(['uom' => function ($q) {
             $q->from(Uom::tableName() . ' u');
         }])->orderBy(['pu.product_id' => SORT_ASC, 'pu.isi' => SORT_ASC])->asArray();
         foreach ($query_uom->all() as $row) {
             $products[$row['product_id']]['uoms'][] = ['id' => $row['uom_id'], 'nm' => $row['uom_nm'], 'isi' => $row['isi']];
         }
         $result['products'] = $products;
     }
     // barcodes
     if (isset($masters['barcodes'])) {
         $barcodes = [];
         $query_barcode = ProductChild::find()->select(['barcode' => 'lower(barcode)', 'id' => 'product_id'])->union(Product::find()->select(['lower(code)', 'id']))->asArray();
         foreach ($query_barcode->all() as $row) {
             $barcodes[$row['barcode']] = $row['id'];
         }
         $result['barcodes'] = $barcodes;
     }
     // price_category
     if (isset($masters['price_category'])) {
         $price_category = [];
         $query_price_category = PriceCategory::find()->asArray();
         foreach ($query_price_category->all() as $row) {
             $price_category[$row['id']] = $row['name'];
         }
         $result['price_category'] = $price_category;
     }
     // prices
     if (isset($masters['prices'])) {
         $prices = [];
         $query_prices = Price::find()->asArray();
         foreach ($query_prices->all() as $row) {
             $prices[$row['product_id']][$row['price_category_id']] = $row['price'];
         }
         $result['prices'] = $prices;
     }
     // customer
     if (isset($masters['customers'])) {
         $result['customers'] = Customer::find()->select(['id', 'label' => 'name'])->asArray()->all();
     }
     // supplier
     if (isset($masters['suppliers'])) {
         $result['suppliers'] = Supplier::find()->select(['id', 'label' => 'name'])->asArray()->all();
     }
     // product_supplier
     if (isset($masters['product_supplier'])) {
         $prod_supp = [];
         $query_prod_supp = ProductSupplier::find()->select(['supplier_id', 'product_id'])->asArray();
         foreach ($query_prod_supp->all() as $row) {
             $prod_supp[$row['supplier_id']][] = $row['product_id'];
         }
         $result['product_supplier'] = $prod_supp;
     }
     // product_stock
     if (isset($masters['product_stock'])) {
         $prod_stock = [];
         $query_prod_stock = ProductStock::find()->select(['warehouse_id', 'product_id'])->asArray();
         foreach ($query_prod_stock->all() as $row) {
             $prod_stock[$row['warehouse_id']][$row['product_id']] = $row['qty'];
         }
         $result['product_stock'] = $prod_stock;
     }
     // supplier
     if (isset($masters['coa'])) {
         $result['coa'] = Coa::find()->select(['id', 'cd' => 'code', 'text' => 'name', 'label' => 'name'])->asArray()->all();
     }
     return $result;
 }