/** * Busca os Eventos passados, com incrições abertas ou inscrições que podem ser abertas do usuário autenticado criando uma instância data provider. * * @param array $params * * @return ActiveDataProvider */ public function searchEventosResponsavel($params) { $status = $params['status']; $inscricoes = $params['inscricoes']; if ($status == 'passado') { $query = Evento::find()->select(['*'])->where("dataFim < '" . date('Y-m-d') . "'")->joinWith("inscreve")->andWhere(['responsavel' => Yii::$app->user->identity->idusuario])->innerJoin('tipo', 'evento.tipo_idtipo = tipo.idtipo'); } else { if ($inscricoes == 'fechada') { $query = Evento::find()->select(['*'])->where("dataFim >= '" . date('Y-m-d') . "'")->andWhere("allow = '0'")->joinWith("inscreve")->andWhere(['responsavel' => Yii::$app->user->identity->idusuario])->innerJoin('tipo', 'evento.tipo_idtipo = tipo.idtipo'); } else { if ($inscricoes == 'naoiniciada') { $query = Evento::find()->select(['*'])->where("dataFim >= '" . date('Y-m-d') . "'")->andWhere("allow is null")->joinWith("inscreve")->andWhere(['responsavel' => Yii::$app->user->identity->idusuario])->innerJoin('tipo', 'evento.tipo_idtipo = tipo.idtipo'); } else { $query = Evento::find()->select(['*'])->where("dataFim >= '" . date('Y-m-d') . "'")->andWhere("allow = '1'")->joinWith("inscreve")->andWhere(['responsavel' => Yii::$app->user->identity->idusuario])->innerJoin('tipo', 'evento.tipo_idtipo = tipo.idtipo'); } } } $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['sigla', 'descricao', 'Vagas', 'Total De Inscritos', 'tipo.titulo', 'qtd_evento']]]); //$this->load($params); if (!$this->validate()) { return $dataProvider; } $dataProvider->sort->attributes['tipo'] = ['asc' => ['titulo' => SORT_ASC], 'desc' => ['titulo' => SORT_DESC]]; $dataProvider->sort->attributes['local'] = ['asc' => ['descricao' => SORT_ASC], 'desc' => ['descricao' => SORT_DESC]]; $query->andFilterWhere(['idevento' => $this->idevento, 'horaIni' => $this->horaIni, 'horaFim' => $this->horaFim, 'vagas' => $this->vagas, 'cargaHoraria' => $this->cargaHoraria, 'allow' => $this->allow, 'responsavel' => $this->responsavel]); $query->andFilterWhere(['like', 'sigla', $this->sigla])->andFilterWhere(['like', 'descricao', $this->descricao])->andFilterWhere(['like', 'dataIni', $this->dataIni])->andFilterWhere(['like', 'dataFim', $this->dataFim])->andFilterWhere(['like', 'imagem', $this->imagem])->andFilterWhere(['like', 'detalhe', $this->detalhe])->andFilterWhere(['like', 'tipo.titulo', $this->tipo])->andFilterWhere(['like', 'local.descricao', $this->descricao]); return $dataProvider; }
public function actionEliminar() { $msg = null; $id; if (!isset($_REQUEST['confirmar']) && isset($_REQUEST['id'])) { $id = $_REQUEST['id']; $tabla = Evento::find()->where(['id_categoria' => $id]); if ($tabla->count() != 0) { $msg = "existen eventos registrados con esta categoria"; } $tabla = Deportista_cat::find()->where(['id_categoria' => $id]); if ($tabla->count() != 0) { $msg .= "<br>" . "existen Deportistas registrados con esta categoria"; } $tabla = Comision::find()->where(['id_categoria' => $id]); if ($tabla->count() != 0) { $msg .= "<br>" . "existen Comisiones registrados con esta categoria"; } if ($msg != null) { return $this->render("confirmar", ['msg' => $msg, 'id' => $id]); } else { if (Categoria::deleteAll($id)) { $msg = "Categoria eliminado con exito"; } else { $msg = "ocurrio un error"; } } } else { if (isset($_REQUEST['confirmar'])) { if (Categoria::deleteAll($_REQUEST['id'])) { $msg = "Categoria eliminado con exito"; } else { $msg = "ocurrio un error"; } } } return $this->render("eliminar", ['msg' => $msg]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $evento = Evento::find($id); $evento->delete(); return redirect()->back(); }
public function getInscritosEventosPacotes($iditemProgramacao) { $model = Evento::find()->select(['nome'])->innerJoin('inscreve', 'inscreve.evento_idevento = evento.idevento')->innerJoin('itemProgramacao_has_pacote', 'itemProgramacao_has_pacote.pacote_idpacote = inscreve.pacote_idpacote')->innerJoin('user', 'user.idusuario = inscreve.usuario_idusuario')->where('itemProgramacao_has_pacote.itemProgramacao_idItemProgramacao =' . $iditemProgramacao)->orderBy('nome')->all(); return $model; }
public function actionBuscar($msg = null) { $this->menu(); $form = new ValidarBusqueda(); $search = null; $search_desde = null; $search_hasta = null; if ($form->load(Yii::$app->request->post())) { if ($form->validate()) { $search = Html::encode($form->q); $search_desde = Html::encode($form->desde); $search_hasta = Html::encode($form->hasta); if ($search == "" && $search_desde == "" && $search_hasta == "") { $sql = "select id_evento,id_deporte,nombre, fecha, condicion from evento"; } elseif ($search == "" && $search_desde == "") { $sql = "select id_evento,id_deporte,nombre, fecha, condicion from evento where evento.fecha BETWEEN '0000-00-00' and '{$search_hasta}'"; } elseif ($search == "" && $search_hasta == "") { $sql = "select id_evento,id_deporte,nombre, fecha, condicion from evento where evento.fecha BETWEEN '{$search_desde}' and curdate()"; } elseif ($search == "") { $sql = "select id_evento,id_deporte,nombre, fecha, condicion from evento where evento.fecha BETWEEN '{$search_desde}' and '{$search_hasta}'"; } elseif ($search != "" && $search_desde == "" && $search_hasta == "") { $sql = "select id_evento,id_deporte,nombre, fecha, condicion from evento where nombre like '%{$search}%'"; } else { $sql = "select id_evento,id_deporte,nombre, fecha, condicion from evento where nombre like '%{$search}%' and evento.fecha BETWEEN '{$search_desde}' and '{$search_hasta}'"; } $command = Yii::$app->db->createCommand($sql)->query(); $count = clone $command; $pages = new Pagination(["pageSize" => 10, "totalCount" => $count->count()]); $sql .= " LIMIT {$pages->limit} OFFSET {$pages->offset} "; $command = Yii::$app->db->createCommand($sql)->queryAll(); $model = $command; } else { $form->getErrors(); } } else { $table = Evento::find(); $count = clone $table; $pages = new Pagination(["pageSize" => 10, "totalCount" => $count->count()]); $sql = "select id_deporte, id_evento,nombre,fecha " . "from evento" . " " . "LIMIT {$pages->limit} OFFSET {$pages->offset}"; $command = Yii::$app->db->createCommand($sql)->queryAll(); $model = $command; } return $this->render("buscar", ['model' => $model, 'msg' => $msg, "pages" => $pages, "model" => $model, "form" => $form, "search" => $search]); }