コード例 #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;
 }
コード例 #2
0
ファイル: index.php プロジェクト: ricardo91/basic
    }
}, 'layout' => '
                                        <div class="pull-right">
                                            {summary}
                                        </div>
                                        {items}
                                        <div class="pull-right">
                                            {pager}
                                        </div>
                                        ', 'pager' => ['maxButtonCount' => 10, 'prevPageLabel' => 'Anterior', 'nextPageLabel' => 'Siguiente', 'prevPageCssClass' => 'prev hidden-xs', 'nextPageCssClass' => 'next hidden-xs'], 'columns' => [['attribute' => 'workstations_id', 'value' => 'workstations.full_name', 'headerOptions' => ['style' => 'text-align: center']], ['attribute' => 'cell_number', 'contentOptions' => ['width' => '80', 'style' => 'text-align: center'], 'headerOptions' => ['style' => 'text-align: center']], ['attribute' => 'profit_center_id', 'value' => 'profitCenter.name', 'filter' => Arrayhelper::map(ProfitCenter::find()->all(), 'number', 'name'), 'headerOptions' => ['style' => 'text-align: center']], ['attribute' => 'plan', 'value' => function ($data) {
    return CellPhoneCosts::getPlans($data->plan);
}, 'filter' => CellPhoneCosts::getPlans(), 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => ['width' => '150']], ['attribute' => 'real_cost_time', 'value' => function ($data) {
    return round($data->real_cost_time) . ' minutos';
}, 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => ['width' => '80', 'style' => 'text-align: center']], ['attribute' => 'sms_cost', 'format' => 'currency', 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => ['width' => '115', 'style' => 'text-align: right']], ['attribute' => 'long_distance', 'format' => 'currency', 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => ['width' => '120', 'style' => 'text-align: right']], ['attribute' => 'month', 'value' => function ($data) {
    return CellPhoneCosts::getMonths($data->month);
}, 'filter' => CellPhoneCosts::getMonths(), 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => ['width' => '60', 'style' => 'text-align: center']], ['attribute' => 'year', 'filter' => ArrayHelper::map(CellPhoneCosts::getYears(), 'year', 'year'), 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => ['width' => '60', 'style' => 'text-align: center']], ['attribute' => 'cost', 'format' => 'currency', 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => ['width' => '60', 'style' => 'text-align: right']]]]);
?>
                        <?php 
Pjax::end();
?>



                    </div>
                </div>


            </div>
        </div>
    </div>
コード例 #3
0
ファイル: CellPhoneCosts.php プロジェクト: ricardo91/basic
 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;
 }
コード例 #4
0
 /**
  * Finds the CellPhoneCosts model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CellPhoneCosts the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CellPhoneCosts::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }