/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SnProductCategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query->where(['status' => [Status::STATUS_ACTIVE, Status::STATUS_INACTIVE]])]);
     $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, 'status' => $this->status, 'created_date' => $this->created_date, 'modified_date' => $this->modified_date]);
     $query->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'created_by', $this->created_by])->andFilterWhere(['like', 'modified_by', $this->modified_by]);
     return $dataProvider;
 }
 /**
  * Finds the SnProductCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return SnProductCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = SnProductCategory::findOne(['id' => $id, 'status' => [STATUS::STATUS_ACTIVE, STATUS::STATUS_INACTIVE]])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSnProductCategory()
 {
     return $this->hasOne(SnProductCategory::className(), ['id' => 'sn_product_category_id']);
 }
Example #4
0
?>

                <?php 
echo $form->field($product, 'name')->textInput(['maxlength' => true]);
?>

                <?php 
echo $form->field($product, 'selling_price')->textInput();
?>
                
                <?php 
echo $form->field($product, 'selling_type')->dropDownList([Product::READY_STOCK => Product::READY_STOCK, Product::READY_ORDER => Product::READY_ORDER, Product::PURCHASE_ORDER => Product::PURCHASE_ORDER], ['prompt' => 'Select Selling Type']);
?>

                <?php 
echo $form->field($product, 'sn_product_category_id')->dropDownList(ArrayHelper::map(SnProductCategory::find()->where(['status' => [Status::STATUS_ACTIVE, Status::STATUS_INACTIVE]])->all(), 'id', 'category'), ['prompt' => 'Select Product Category']);
?>

                <?php 
echo $form->field($product, 'stock')->textInput();
?>
                
                <?php 
echo $form->field($product, 'po_start_date')->widget(DatePicker::className(), ['inline' => false, 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-m-d']]);
?>

                <?php 
echo $form->field($product, 'po_end_date')->widget(DatePicker::className(), ['inline' => false, 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-m-d']]);
?>

                <?php 
Example #5
0
<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\grid\GridView;
use common\models\SnProductCategory;
use common\models\Status;
/* @var $this yii\web\View */
/* @var $searchModel common\models\ProductSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Products';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="product-index">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'summary' => '', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', 'description:html', ['format' => 'Currency', 'attribute' => 'selling_price'], ['label' => 'Product Category', 'attribute' => 'sn_product_category_id', 'filter' => ArrayHelper::map(SnProductCategory::find()->all(), 'id', 'category'), 'value' => 'snProductCategory.category'], ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    if ($model->status === Status::STATUS_ACTIVE) {
        $class = 'label-success';
    } elseif ($model->status === Status::STATUS_INACTIVE) {
        $class = 'label-warning';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . $model->getStatus()->label . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', Status::labels(), ['class' => 'form-control', 'prompt' => 'Please Select'])], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {delete} {inactive}', 'buttons' => ['inactive' => function ($url, $model) {
    if ($model->status != Status::STATUS_INACTIVE) {
        return Html::a('<span class="glyphicon glyphicon-remove"></span>', ['inactive', 'id' => $model->id], ['title' => 'Inactive', 'data' => ['confirm' => 'Are you sure you want to inactive this user?', 'method' => 'post']]);
    } else {
        if ($model->status == Status::STATUS_INACTIVE) {
            return Html::a('<span class="glyphicon glyphicon-ok"></span>', ['active', 'id' => $model->id], ['title' => 'Active', 'data' => ['confirm' => 'Are you sure you want to actived this user?', 'method' => 'post']]);
        } else {