123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <?php
- require_once 'Etapa.php';
- class Concurso {
- private $id;
- private $nombre;
- private $activo;
- private $carpeta;
-
- function getId(){
- return $this->id;
- }
-
- function getNombre(){
- return $this->nombre;
- }
-
- function estaActivo(){
- return $this->activo;
- }
-
- function getCarpeta(){
- return $this->carpeta;
- }
-
- function getConcursoActivo($pdo){
- $stmt = $pdo->prepare('Select * from cidit_fs_concursoactivo()');
- if($stmt->execute()){
- $concurso = $stmt->fetch();
- $this->id = $concurso['idconcurso'];
- $this->nombre = $concurso['nom'];
- $this->activo = true;
- $this->carpeta = $concurso['carpeta'];
- } else {
- $this->id = 0;
- }
- $stmt->closeCursor();
- $stmt = null;
- }
-
- function getConcursoAnterior($pdo){
- $stmt = $pdo->prepare('Select * from cidit_fs_concursoanterior()');
- if($stmt->execute()){
- $concurso = $stmt->fetch();
- $this->id = $concurso['idconcurso'];
- $this->nombre = $concurso['nom'];
- $this->activo = true;
- $this->carpeta = $concurso['carpeta'];
- } else {
- $this->id = 0;
- }
- $stmt->closeCursor();
- $stmt = null;
- }
-
- public static function getCouncursoxId($pdo, $id){
- $concurso = array();
- $stmt = $pdo->prepare('Select * from CIDIT_fs_concursoxid(:id)');
- $stmt->bindParam(':id', $id);
- if($stmt->execute())
- $concurso = $stmt->fetch();
- $stmt->closeCursor();
- $stmt = null;
- return $concurso;
- }
-
- public static function getCouncursos($pdo){
- $concursos = array();
- $stmt = $pdo->prepare('Select idconcurso, nom from CIDIT_fs_concursoxid(null) ORDER BY nom');
- if($stmt->execute())
- $concursos = $stmt->fetchAll();
- $stmt->closeCursor();
- $stmt = null;
- return $concursos;
- }
-
- public static function getCategoriasConcurso($pdo,$id){
- $categorias = array();
- $stmt = $pdo->prepare('Select * from cidit_fs_categoriasconcurso(:id)');
- $stmt->bindParam(':id', $id);
- if($stmt->execute())
- $categorias = $stmt->fetchAll();
- $stmt->closeCursor();
- $stmt = null;
- return $categorias;
- }
-
- public static function getFechas($pdo,$concurso){
- $fechas = array();
- $etapas = Etapa::getEtapaXID($pdo);
- foreach ($etapas as $etapa){
- $fechas[$etapa['clave']] = self::getFechaXEtapa($pdo, $concurso, $etapa);
- }
- return $fechas;
- }
-
- public static function getFechaXEtapa($pdo, $concurso, $etapa){
- date_default_timezone_set('America/Mexico_City');
- $hoy = strtotime(date('Y-m-d'));
- switch (mb_strtoupper($etapa['clave'])){
- case 'REGISTRO':
- $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
- $activo = false;
- $activoGral = false;
- if (count($fechas) > 0){
- $registro = array();
- foreach ($fechas as $fecha){
- $temp = str_replace('{', '', $fecha['fecha']);
- $temp = str_replace('}', '', $temp);
- $temp = explode(',', $temp);
- for ($cont = 0; $cont < count($temp); $cont++){
- $temp[$cont] = new DateTime($temp[$cont]);
- }
- if ($hoy >= strtotime(date($temp[0]->format('Y/n/d'))) && $hoy <= strtotime(date($temp[1]->format('Y/n/d')))){
- $activo = true;
- if (!$activoGral)
- $activoGral = true;
- } else
- $activo = false;
- array_push($registro, array('fechas' => $temp, 'orden' => $fecha['orden'], 'activo' => $activo));
- }
- return array('fechas' => $registro, 'activo' => $activoGral);
- } else
- return array('fechas' =>'Por definir', 'activo' => false);
- break;
- case 'AUTORIZACION':
- $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
- $activo = false;
- $activoGral = false;
- if (count($fechas) > 0){
- $autorizacion = array();
- foreach ($fechas as $fecha){
- $temp = str_replace('{', '', $fecha['fecha']);
- $temp = str_replace('}', '', $temp);
- $temp = new DateTime($temp);
- if ($hoy >= strtotime(date($temp->format('Y/n/d')))){
- $activo = true;
- if (!$activoGral)
- $activoGral = true;
- } else
- $activo = false;
- array_push($autorizacion, array('fechas' => $temp, 'orden' => $fecha['orden']));
- }
- return array('fechas' => $autorizacion, 'activo' => $activoGral);
- } else
- return array('fechas' =>'Por definir', 'activo' => false);
- break;
- case 'GALERIA':
- case 'FINALISTAS':
- case 'GANADORES':
- $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
- $activo = false;
- if (count($fechas) > 0){
- $fecha = end($fechas);
- $temp = str_replace('{', '', $fecha['fecha']);
- $temp = str_replace('}', '', $temp);
- $temp = new DateTime($temp);
- if ($hoy >= strtotime(date($temp->format('Y/n/d'))))
- $activo = true;
- else
- $activo = false;
- return array('fechas' => $temp, 'activo' => $activo);
- } else
- return array('fechas' =>'Por definir', 'activo' => false);
- break;
- case 'EDITOR':
- $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
- $activo = false;
- if (count($fechas) > 0){
- $fecha = end($fechas);
- $temp = str_replace('{', '', $fecha['fecha']);
- $temp = str_replace('}', '', $temp);
- $temp = new DateTime($temp);
- if ($hoy <= strtotime(date($temp->format('Y/n/d'))))
- $activo = true;
- else
- $activo = false;
- return array('fechas' => $temp, 'activo' => $activo);
- } else
- return array('fechas' =>'Por definir', 'activo' => false);
- break;
- case 'REVISION':
- case 'EVALUACION':
- $activo = false;
- $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
- if (count($fechas) > 0){
- $fecha = end($fechas);
- $temp = str_replace('{', '', $fecha['fecha']);
- $temp = str_replace('}', '', $temp);
- $temp = explode(',', $temp);
- for ($cont = 0; $cont < count($temp); $cont++){
- $temp[$cont] = new DateTime($temp[$cont]);
- }
- if ($hoy >= strtotime(date($temp[0]->format('Y/n/d'))) && $hoy <= strtotime(date($temp[1]->format('Y/n/d'))))
- $activo = true;
- else
- $activo = false;
- return array('fechas' => $temp, 'activo' => $activo);
- } else
- return array('fechas' =>'Por definir', 'activo' => false);
- break;
- }
- }
-
- public static function tieneEvaluaciones($pdo,$etapa, $concurso){
- $evaluaciones = false;
- $stmt = $pdo->prepare('Select * from cidit_fs_existenevaluacionesconcurso(:etapa,:concurso)');
- $stmt->bindParam(':etapa', $etapa);
- $stmt->bindParam(':concurso', $concurso);
- if($stmt->execute()){
- $evaluaciones = $stmt->fetch();
- $evaluaciones = $evaluaciones['existe'];
- }
- $stmt->closeCursor();
- $stmt = null;
- return $evaluaciones;
- }
-
- public static function getMemorias($pdo){
- $memorias = array();
- $stmt = $pdo->prepare('Select * from cidit_fs_memorias()');
- if($stmt->execute())
- $memorias = $stmt->fetchAll();
- $stmt->closeCursor();
- $stmt = null;
- return $memorias;
- }
- }
|