public function unscheduled() { // Get a list of all ticket IDs scheduled in the next 2 weeks $scheduled = Schedule::find()->joinWith('labors.note', false)->select(Note::tableName() . '.ticket_id')->between(new Expression('NOW()'), date('Y-m-d', strtotime('+14 days'))); // return tickets not in that list $this->andWhere(['not in', Ticket::tableName() . '.id', $scheduled])->joinWith('invoice.location.client')->orderBy([Client::tableName() . '.name' => SORT_ASC, Location::tableName() . '.name' => SORT_ASC, Ticket::tableName() . '.id' => SORT_ASC]); return $this; }
public function actionIndex() { $model = $this->findModel(Yii::$app->user->id); $laborTally = []; $laborTally['Hourly'] = Labor::find()->hourly()->tech($model->contact_id)->total(); $laborTally['Proactive'] = Labor::find()->hourly(false)->tech($model->contact_id)->total(); $openTickets = new ActiveDataProvider(['query' => Ticket::find()->active()->joinWith('invoice.location.client', false), 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['status_id' => SORT_ASC, 'id' => SORT_ASC]]]); $openTickets->sort->attributes['location_id'] = ['asc' => [Client::tableName() . '.name' => SORT_ASC, Location::tableName() . '.name' => SORT_ASC], 'desc' => [Client::tableName() . '.name' => SORT_DESC, Location::tableName() . '.name' => SORT_DESC]]; Url::remember(); return $this->render('index', ['model' => $model, 'laborTally' => $laborTally, 'openTickets' => $openTickets]); }
/** * 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; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Invoice::find()->andWhere(['not', ['status_id' => Invoice::STATUS_CURRENT]])->with('location.client'); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]); $dataProvider->sort->attributes['location_id'] = ['asc' => [Client::tableName() . '.name' => SORT_ASC, Location::tableName() . '.name' => SORT_ASC], 'desc' => [Client::tableName() . '.name' => SORT_DESC, Location::tableName() . '.name' => 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->andFilterWhere([Invoice::tableName() . '.location_id' => $this->location_id, Invoice::tableName() . '.status_id' => $this->status_id]); $query->andFilterWhere(['like', Invoice::tableName() . '.id', (int) $this->id]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Ticket::find()->current()->joinWith(['invoice.location', 'invoice.location.client']); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50], 'sort' => ['defaultOrder' => ['status_id' => SORT_ASC]]]); $dataProvider->sort->attributes['location_id'] = ['asc' => [Client::tableName() . '.name' => SORT_ASC, Location::tableName() . '.name' => SORT_ASC], 'desc' => [Client::tableName() . '.name' => SORT_DESC, Location::tableName() . '.name' => SORT_DESC]]; $dataProvider->sort->attributes['status_id'] = ['asc' => [Ticket::tableName() . '.status_id' => SORT_DESC], 'desc' => [Ticket::tableName() . '.status_id' => 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([Location::tableName() . '.id' => $this->location_id, Ticket::tableName() . '.status_id' => $this->status_id, Ticket::tableName() . '.priority_id' => $this->priority_id, Ticket::tableName() . '.bill_type_id' => $this->bill_type_id]); $query->andFilterWhere(['like', Ticket::tableName() . '.id', $this->id]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Location::find()->joinWith('client')->andWhere([Client::tableName() . '.active' => true]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false, 'sort' => ['defaultOrder' => ['client_id' => SORT_ASC, 'name' => SORT_ASC]]]); $dataProvider->sort->attributes['client_id'] = ['asc' => [Client::tableName() . '.name' => SORT_ASC], 'desc' => [Client::tableName() . '.name' => SORT_DESC]]; if (Yii::$app->user->can('Accounting')) { $query->joinWith('lastInvoice'); $dataProvider->sort->attributes['lastInvoiceStatus'] = ['asc' => [Invoice::tableName() . '.status_id' => SORT_ASC], 'desc' => [Invoice::tableName() . '.status_id' => 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->andFilterWhere([self::tableName() . '.client_id' => $this->client_id, self::tableName() . '.proactive' => $this->proactive, self::tableName() . '.active' => $this->active]); if (Yii::$app->user->can('Accounting')) { $query->andFilterWhere([Invoice::tableName() . '.status_id' => $this->lastInvoiceStatus]); } $query->andFilterWhere(['or', ['like', self::tableName() . '.name', $this->name], ['like', Client::tableName() . '.name', $this->name]])->andFilterWhere(['like', 'phone', $this->phone]); return $dataProvider; }