OrderreturnSearch.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\models;
  3. use yii\base\Model;
  4. use yii\data\ActiveDataProvider;
  5. use app\models\Orderreturn;
  6. /**
  7. * OrderreturnSearch represents the model behind the search form of `app\models\Orderreturn`.
  8. */
  9. class OrderreturnSearch extends Orderreturn
  10. {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function rules()
  15. {
  16. return [
  17. [['id', 'num','shop'], 'integer'],
  18. [['deliveryid', 'website', 'customer', 'delivery', 'origin_goodsinfo', 'goodsinfo', 'usage', 'mark'], 'safe'],
  19. ];
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function scenarios()
  25. {
  26. // bypass scenarios() implementation in the parent class
  27. return Model::scenarios();
  28. }
  29. /**
  30. * Creates data provider instance with search query applied
  31. *
  32. * @param array $params
  33. *
  34. * @return ActiveDataProvider
  35. */
  36. public function search($params)
  37. {
  38. $query = Orderreturn::find();
  39. // add conditions that should always apply here
  40. $dataProvider = new ActiveDataProvider([
  41. 'query' => $query,
  42. ]);
  43. $this->load($params);
  44. if (!$this->validate()) {
  45. // uncomment the following line if you do not want to return any records when validation fails
  46. // $query->where('0=1');
  47. return $dataProvider;
  48. }
  49. $shop=$params['shop']??1;
  50. // grid filtering conditions
  51. $query->andFilterWhere([
  52. 'id' => $this->id,
  53. 'receiptdate' => $this->receiptdate,
  54. 'num' => $this->num,
  55. 'shop'=>$shop,
  56. ]);
  57. $query->orderBy([
  58. 'id'=>SORT_DESC
  59. ]);
  60. $query->andFilterWhere(['like', 'deliveryid', $this->deliveryid])
  61. ->andFilterWhere(['like', 'website', $this->website])
  62. ->andFilterWhere(['like', 'customer', $this->customer])
  63. ->andFilterWhere(['like', 'delivery', $this->delivery])
  64. ->andFilterWhere(['like', 'origin_goodsinfo', $this->origin_goodsinfo])
  65. ->andFilterWhere(['like', 'goodsinfo', $this->goodsinfo])
  66. ->andFilterWhere(['like', 'usage', $this->usage])
  67. ->andFilterWhere(['like', 'mark', $this->mark]);
  68. return $dataProvider;
  69. }
  70. }