public function actionEventos($from, $to) { $date = new \Datetime(null); $hoje = $date->getTimestamp() + $date->getOffset(); $de = date("Y-m-d", $from / 1000); $para = date("Y-m-d", $to / 1000); $model = Eventos::find()->joinWith('atividade')->where(['>=', 'd_ini', $de])->orWhere(['<=', 'd_ter', $de])->orWhere(['<=', 'd_ter', $para])->andWhere(['atividades.empresa_id' => Yii::$app->session->get('empresa')])->all(); $d = ['success' => 1]; foreach ($model as $dados) { $d['result'][] = ['id' => $dados['id'], 'title' => $dados['atividade']['atividade'], 'url' => Url::to(['evento/visualizar', 'id' => $dados['id']]), 'class' => Yii::$app->AgobUtils->cssStatus($dados['status'], $dados['d_ter']), 'start' => strtotime($dados['d_ini']) . '000', 'end' => strtotime($dados['d_ter']) . '000', 'dias' => Yii::$app->AgobUtils->diffDias($dados['d_ter']), 'status' => $dados['status']]; } echo json_encode($d); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Eventos::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(['id' => $this->id, 'atividade_id' => $this->atividade_id, 'd_ini' => $this->d_ini, 'd_ter' => $this->d_ter]); $query->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'status_observacao', $this->status_observacao]); return $dataProvider; }
/** * Find Eventos by given id * * @param int $id * * @return \Illuminate\Support\Collection|null|static|Eventos */ public function findEventosById($id) { return Eventos::find($id); }
/** * Displays a single Atividades model. * @param integer $id * @return mixed */ public function actionView($id) { $modelEventos = Eventos::find()->andWhere(['atividade_id' => $id])->all(); $modelEventos = new ArrayDataProvider(['allModels' => $modelEventos]); return $this->render('view', ['model' => $this->findModel($id), 'modelEventos' => $modelEventos]); }