|
- <?php
-
- namespace backend\modules\motorcade\models;
-
- use yii\base\Model;
- use yii\data\ActiveDataProvider;
-
- /**
- * searchRunBusExpenses represents the model behind the search form about `backend\modules\motorcade\models\RunBusExpenses`.
- * @property $date_from
- * @property $date_to
- */
- class searchRunBusExpenses extends RunBusExpenses
- {
- public $date_from;
- public $date_to;
- public $search_type = 'bus'; //默认搜索车辆
- public $search_key;
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['cancel_flag', 'bus_number', 'use_bus_org_id', 'bus_res_id', 'bus_driver_res_id', 'expense_subject_id', 'expense_type', 'doc_log_id'], 'integer'],
- [['date_from', 'date_to', 'search_type', 'search_key'], 'safe'],
- [['search_key'], 'trim'],
- [['expense_value', 'start_value', 'end_value'], 'number'],
- ];
- }
-
- public function attributeLabels()
- {
- return array_merge([
- 'date_from' => '日期',
- 'driver_name' => '司机',
- 'bus_no' => '车辆'
- ], parent::attributeLabels());
- }
-
- /**
- * Creates data provider instance with search query applied
- *
- * @param array $params
- * @param string $type 司机或车辆
- *
- * @return ActiveDataProvider
- */
- public function search($params)
- {
- $this->load($params);
- //车辆
- if($this->search_type!=='driver'){
- $dataProvider = $this->getOilConsumptionList($this->search_key, $this->date_from, $this->date_to);
- }else{
- $dataProvider = $this->getDriverConsumptionList($this->search_key, $this->date_from, $this->date_to);
-
- }
- return $dataProvider;
- }
- }
|