65 lines
1.2 KiB
PHP
65 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace frontend\models;
|
|
|
|
use Yii;
|
|
use yii\base\Model;
|
|
use yii\data\ActiveDataProvider;
|
|
use common\models\Product;
|
|
use common\components\ProductInventory;
|
|
|
|
/**
|
|
* ProductSearch represents the model behind the search form about `common\models\Product`.
|
|
*/
|
|
class ProductInventorySearch extends Product
|
|
{
|
|
public $output = '';
|
|
public $account = null;
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[[ 'output'], 'safe'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function scenarios()
|
|
{
|
|
// bypass scenarios() implementation in the parent class
|
|
return Model::scenarios();
|
|
}
|
|
|
|
/**
|
|
* Creates data provider instance with search query applied
|
|
*
|
|
* @param array $params
|
|
*
|
|
* @return ActiveDataProvider
|
|
*/
|
|
public function search($params)
|
|
{
|
|
|
|
$this->load($params);
|
|
|
|
$this->validate() ;
|
|
|
|
$inventory = new ProductInventory([
|
|
'account' => $this->account
|
|
]);
|
|
if ( $this->output == 'xls'){
|
|
$inventory->pagination = false;
|
|
}
|
|
|
|
$inventory->createDataProvider();
|
|
$dp = $inventory->dataProvider;
|
|
|
|
return $dp;
|
|
}
|
|
}
|