Exemplo n.º 1
0
 /**
  * Displays a single Ticket model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $notes = new ActiveDataProvider(['query' => $model->getNotes()->complete()->with(['author', 'attachment']), 'pagination' => false, 'sort' => ['attributes' => ['public', 'created_at'], 'defaultOrder' => ['created_at' => SORT_ASC]]]);
     $labors = new ActiveDataProvider(['query' => $model->getLabors()->joinWith('schedule.tech')->with(['note', 'schedule.travel'])->orderBy(Schedule::tableName() . '.start_time'), 'key' => 'schedule_id', 'pagination' => false, 'sort' => ['attributes' => ['schedule.start_time' => ['asc' => [Schedule::tableName() . '.start_time' => SORT_ASC], 'desc' => [Schedule::tableName() . '.start_time' => SORT_DESC]], 'schedule.tech_id' => ['asc' => [Contact::tableName() . '.name' => SORT_ASC], 'desc' => [Contact::tableName() . '.name' => SORT_DESC]]], 'defaultOrder' => ['schedule.start_time' => SORT_DESC]]]);
     $purchases = new ActiveDataProvider(['query' => $model->getPurchasedItems(), 'pagination' => false, 'sort' => ['defaultOrder' => ['id' => SORT_ASC]]]);
     if (Yii::$app->request->isAjax) {
         return $this->renderAjax('view', ['model' => $model, 'notes' => $notes, 'labors' => $labors, 'purchases' => $purchases]);
     }
     Url::remember();
     return $this->render('view', ['model' => $model, 'notes' => $notes, 'labors' => $labors, 'purchases' => $purchases]);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Contact::find()->joinWith('client')->andWhere([Client::tableName() . '.active' => true]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 25], 'sort' => ['defaultOrder' => ['name' => SORT_ASC]]]);
     $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([Contact::tableName() . '.client_id' => $this->client_id, Contact::tableName() . '.active' => $this->active]);
     $query->andFilterWhere(['like', Contact::tableName() . '.name', $this->name])->andFilterWhere(['like', Contact::tableName() . '.email', $this->email])->andFilterWhere(['like', Contact::tableName() . '.phone', $this->phone]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Tech::find()->joinWith('contact');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['username'] = ['asc' => [Contact::tableName() . '.email' => SORT_ASC], 'desc' => [Contact::tableName() . '.email' => SORT_DESC]];
     $dataProvider->sort->attributes['name'] = ['asc' => [Contact::tableName() . '.name' => SORT_ASC], 'desc' => [Contact::tableName() . '.name' => SORT_DESC]];
     $dataProvider->sort->defaultOrder = ['name' => SORT_ASC];
     $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([Tech::tableName() . '.contact_id' => $this->id]);
     $query->andFilterWhere(['like', Contact::tableName() . '.email', $this->username])->andFilterWhere(['like', Contact::tableName() . '.name', $this->name]);
     return $dataProvider;
 }