示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Products::find();
     $query->joinWith(['manufacturer', 'manufacturer']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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, "{$this->tableName()}.Manufacturer" => $this->ManufacturerID, 'Measure' => $this->Measure, 'Price' => $this->Price, 'ProductType' => $this->ProductType]);
     $query->andFilterWhere(['like', 'Product', $this->Product])->andFilterWhere(['like', 'Article', $this->Article])->andFilterWhere(['like', 'Description', $this->Description])->andFilterWhere(['like', 'Manufacturers.Manufacturer', $this->Manufacturer]);
     return $dataProvider;
 }
示例#2
0
use app\modules\warehouse\models\ProductsSearch;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model app\models\Contents */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="contents-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'Product')->dropDownList(ArrayHelper::map(Products::find()->orderBy('Manufacturer, Product')->all(), 'ID', 'productInfo', 'manufacturer.Manufacturer'), ['prompt' => Yii::t('app', 'Select...')]);
?>

    <!--Popup buttons-->
    <div class="form-group">
        <?php 
echo Html::button(Yii::t('app', 'Search product'), ['class' => 'btn btn-primary btn-ajax-modal', 'value' => Url::to('/products/search'), 'data-target' => '#search-product-popup', 'data-toggle' => 'modal']);
?>
        <?php 
echo Html::button(Yii::t('app', 'Create product'), ['class' => 'btn btn-primary btn-ajax-modal', 'value' => Url::to('/products/create'), 'data-target' => '#create-product-popup', 'data-toggle' => 'modal']);
?>
        
    </div>

    <?php 
echo $form->field($model, 'Amount')->textInput();