public function getDataProvider($reportId) { $dataProvider = new ActiveDataProvider(); $pagination = new Pagination(['pageSize' => 50]); $query = ReportItem::find()->where(['reportId' => $reportId, 'expenditure' => ['$gte' => $this->sum]]); $dataProvider->query = $query; $dataProvider->pagination = $pagination; return $dataProvider; }
public function getDataProvider($reportId) { $dataProvider = new ActiveDataProvider(); $pagination = new Pagination(['pageSize' => 50]); $query = ReportItem::find()->where(['reportId' => $reportId, 'overrun' => ['$exists' => true]]); $dataProvider->query = $query; $dataProvider->pagination = $pagination; return $dataProvider; }
/** * @param array $params * @return ActiveDataProvider */ public function search($params) { $query = ReportItem::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['employee' => SORT_ASC]]]); if (!$this->load($params) || !$this->validate()) { $query->where(['1' => false]); return $dataProvider; } /** @var Report $report */ $report = Report::findOne(['operatorId' => $this->operatorId, 'period' => $this->_period]); $query->andWhere(['reportId' => $report->primaryKey]); $query->andWhere(['or', ['number' => ['$in' => $this->_numbers]], ['employee' => ['$in' => $this->_employees]]]); return $dataProvider; }
public function actionNumbers() { if ($this->deleteReports) { $this->cleanCollection(Report::collectionName()); $this->cleanCollection(ReportItem::collectionName()); } $this->actionOperators(); $query = (new Query())->from($this->numberTableName); $this->stdout("Загружаю номера\n", Console::FG_BLUE, Console::BOLD); $this->stdout("Источник: таблица '{$this->numberTableName}' " . $query->count() . " записей.\nЦелевая коллекция: '" . Number::collectionName() . "'\n"); $this->cleanCollection(Number::collectionName()); $count = 0; foreach ($query->all() as $item) { $number = new Number(['number' => $item['number']]); $number->ownerId = (int) $item['owner_id']; $number->operatorId = $this->operatorJunction[$item['operator_id']]; $number->destination = $item['type'] == '1' ? Number::DESTINATION_PHONE : Number::DESTINATION_MODEM; $number->limit = $item['limit'] == '0' || $item['limit'] === null ? null : (int) $item['limit']; $options = []; if ($item['rent_date'] === null && $number->limit === null) { $options[] = Number::OPTION_TRIP; } if ($number->limit !== null && $item['accounting'] == '1') { $options[] = Number::OPTION_ACCOUNTING; } $number->options = $options; $history = []; if ($item['rent_date'] !== null && $item['owner_id'] !== null) { $history[] = ['rentDate' => new MongoDate((int) $item['rent_date']), 'ownerId' => (int) $item['owner_id']]; } $number->history = $history; $number->comment = $item['comment']; if ($number->save(false)) { $count++; } } $this->stdout("Успешно загружено {$count} записей\n", Console::BOLD, Console::FG_GREEN); $this->stdout("\n"); $this->actionDocuments(); return Controller::EXIT_CODE_NORMAL; }
public function getItems() { return $this->hasMany(ReportItem::className(), ['reportId' => '_id']); }