add inventory
This commit is contained in:
64
frontend/models/ProductInventorySearch.php
Normal file
64
frontend/models/ProductInventorySearch.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user