Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CellPhoneCosts::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['year' => SORT_DESC, 'month' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('profitCenter');
     $query->joinWith('workstations');
     //'pagination'=>['pageSize'=>10,],
     $query->andFilterWhere(['month' => $this->month, 'year' => $this->year, 'sms_cost' => $this->sms_cost, 'cost' => $this->cost, 'real_cost_time' => $this->real_cost_time, 'long_distance' => $this->long_distance, 'id' => $this->id]);
     $query->andFilterWhere(['like', 'cell_number', $this->cell_number])->andFilterWhere(['like', 'plan', $this->plan])->andFilterWhere(['like', 'profit_center_id', $this->profit_center_id])->andFilterWhere(['like', 'workstations.full_name', $this->workstations_id]);
     return $dataProvider;
 }
Example #2
0
 public static function getYears()
 {
     //$years = Yii::$app->db->createCommand('SELECT year FROM cell_phone_costs Group BY year Order By year DESC')->queryAll(); //funciona igual.
     $years = CellPhoneCosts::find()->select('year')->groupBy('year')->orderBy('year')->asArray()->all();
     return $years;
 }