Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

63 righe
1.7 KiB

  1. <?php
  2. namespace backend\modules\motorcade\models;
  3. use yii\base\Model;
  4. use yii\data\ActiveDataProvider;
  5. /**
  6. * searchRunBusExpenses represents the model behind the search form about `backend\modules\motorcade\models\RunBusExpenses`.
  7. * @property $date_from
  8. * @property $date_to
  9. */
  10. class searchRunBusExpenses extends RunBusExpenses
  11. {
  12. public $date_from;
  13. public $date_to;
  14. public $search_type = 'bus'; //默认搜索车辆
  15. public $search_key;
  16. /**
  17. * @inheritdoc
  18. */
  19. public function rules()
  20. {
  21. return [
  22. [['cancel_flag', 'bus_number', 'use_bus_org_id', 'bus_res_id', 'bus_driver_res_id', 'expense_subject_id', 'expense_type', 'doc_log_id'], 'integer'],
  23. [['date_from', 'date_to', 'search_type', 'search_key'], 'safe'],
  24. [['search_key'], 'trim'],
  25. [['expense_value', 'start_value', 'end_value'], 'number'],
  26. ];
  27. }
  28. public function attributeLabels()
  29. {
  30. return array_merge([
  31. 'date_from' => '日期',
  32. 'driver_name' => '司机',
  33. 'bus_no' => '车辆'
  34. ], parent::attributeLabels());
  35. }
  36. /**
  37. * Creates data provider instance with search query applied
  38. *
  39. * @param array $params
  40. * @param string $type 司机或车辆
  41. *
  42. * @return ActiveDataProvider
  43. */
  44. public function search($params)
  45. {
  46. $this->load($params);
  47. //车辆
  48. if($this->search_type!=='driver'){
  49. $dataProvider = $this->getOilConsumptionList($this->search_key, $this->date_from, $this->date_to);
  50. }else{
  51. $dataProvider = $this->getDriverConsumptionList($this->search_key, $this->date_from, $this->date_to);
  52. }
  53. return $dataProvider;
  54. }
  55. }