|
- <?php
-
-
-
- namespace common\models;
-
- use common\helpers\GlobalParam;
- use Yii;
- use yii\helpers\Html;
- use common\models\UserPointSale;
- use common\models\PointSaleDistribution;
- use common\components\ActiveRecordCommon;
-
-
- class ProductPriceSearch extends ProductPrice
- {
-
- public function rules()
- {
- return [
- [['id_user', 'id_point_sale'], 'string'],
- [['price'], 'double'],
- ];
- }
-
- public function search($params)
- {
- $optionsSearch = self::defaultOptionsSearch() ;
-
- $query = ProductPrice::find()
- ->with($optionsSearch['with'])
- ->innerJoinWith($optionsSearch['join_with'], true)
- ->where(['product.id_producer' => GlobalParam::getCurrentProducerId()])
- ->orderBy('product_price.price ASC')
- ;
-
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- 'sort' => false,
- 'pagination' => [
- 'pageSize' => 1000,
- ],
- ]);
-
- $this->load($params);
- if (!$this->validate()) {
- return $dataProvider;
- }
-
- if(isset($params['id_product'])) {
- $query->andWhere(['product.id' => (int) $params['id_product']]) ;
- }
-
- return $dataProvider;
- }
-
- }
|