/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ProfitCenter::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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->andFilterWhere(['like', 'number', $this->number])->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
Pjax::begin(); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'options' => ['class' => "col-md-120"], 'tableOptions' => ['class' => 'table table-striped table-hover table-bordered table-condensed'], 'summary' => "Mostrando <strong>{begin} - {end}</strong> de <strong>{totalCount}</strong> celulares.", 'rowOptions' => function ($model) { if (CellPhoneCosts::getOverPlan($model->plan, $model->real_cost_time)) { return ['class' => 'danger']; } }, '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>