Concurso.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. require_once 'Etapa.php';
  3. class Concurso {
  4. private $id;
  5. private $nombre;
  6. private $activo;
  7. private $carpeta;
  8. function getId(){
  9. return $this->id;
  10. }
  11. function getNombre(){
  12. return $this->nombre;
  13. }
  14. function estaActivo(){
  15. return $this->activo;
  16. }
  17. function getCarpeta(){
  18. return $this->carpeta;
  19. }
  20. function getConcursoActivo($pdo){
  21. $stmt = $pdo->prepare('Select * from cidit_fs_concursoactivo()');
  22. if($stmt->execute()){
  23. $concurso = $stmt->fetch();
  24. $this->id = $concurso['idconcurso'];
  25. $this->nombre = $concurso['nom'];
  26. $this->activo = true;
  27. $this->carpeta = $concurso['carpeta'];
  28. } else {
  29. $this->id = 0;
  30. }
  31. $stmt->closeCursor();
  32. $stmt = null;
  33. }
  34. function getConcursoAnterior($pdo){
  35. $stmt = $pdo->prepare('Select * from cidit_fs_concursoanterior()');
  36. if($stmt->execute()){
  37. $concurso = $stmt->fetch();
  38. $this->id = $concurso['idconcurso'];
  39. $this->nombre = $concurso['nom'];
  40. $this->activo = true;
  41. $this->carpeta = $concurso['carpeta'];
  42. } else {
  43. $this->id = 0;
  44. }
  45. $stmt->closeCursor();
  46. $stmt = null;
  47. }
  48. public static function getCouncursoxId($pdo, $id){
  49. $concurso = array();
  50. $stmt = $pdo->prepare('Select * from CIDIT_fs_concursoxid(:id)');
  51. $stmt->bindParam(':id', $id);
  52. if($stmt->execute())
  53. $concurso = $stmt->fetch();
  54. $stmt->closeCursor();
  55. $stmt = null;
  56. return $concurso;
  57. }
  58. public static function getCouncursos($pdo){
  59. $concursos = array();
  60. $stmt = $pdo->prepare('Select idconcurso, nom from CIDIT_fs_concursoxid(null) ORDER BY nom');
  61. if($stmt->execute())
  62. $concursos = $stmt->fetchAll();
  63. $stmt->closeCursor();
  64. $stmt = null;
  65. return $concursos;
  66. }
  67. public static function getCategoriasConcurso($pdo,$id){
  68. $categorias = array();
  69. $stmt = $pdo->prepare('Select * from cidit_fs_categoriasconcurso(:id)');
  70. $stmt->bindParam(':id', $id);
  71. if($stmt->execute())
  72. $categorias = $stmt->fetchAll();
  73. $stmt->closeCursor();
  74. $stmt = null;
  75. return $categorias;
  76. }
  77. public static function getFechas($pdo,$concurso){
  78. $fechas = array();
  79. $etapas = Etapa::getEtapaXID($pdo);
  80. foreach ($etapas as $etapa){
  81. $fechas[$etapa['clave']] = self::getFechaXEtapa($pdo, $concurso, $etapa);
  82. }
  83. return $fechas;
  84. }
  85. public static function getFechaXEtapa($pdo, $concurso, $etapa){
  86. date_default_timezone_set('America/Mexico_City');
  87. $hoy = strtotime(date('Y-m-d'));
  88. switch (mb_strtoupper($etapa['clave'])){
  89. case 'REGISTRO':
  90. $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
  91. $activo = false;
  92. $activoGral = false;
  93. if (count($fechas) > 0){
  94. $registro = array();
  95. foreach ($fechas as $fecha){
  96. $temp = str_replace('{', '', $fecha['fecha']);
  97. $temp = str_replace('}', '', $temp);
  98. $temp = explode(',', $temp);
  99. for ($cont = 0; $cont < count($temp); $cont++){
  100. $temp[$cont] = new DateTime($temp[$cont]);
  101. }
  102. if ($hoy >= strtotime(date($temp[0]->format('Y/n/d'))) && $hoy <= strtotime(date($temp[1]->format('Y/n/d')))){
  103. $activo = true;
  104. if (!$activoGral)
  105. $activoGral = true;
  106. } else
  107. $activo = false;
  108. array_push($registro, array('fechas' => $temp, 'orden' => $fecha['orden'], 'activo' => $activo));
  109. }
  110. return array('fechas' => $registro, 'activo' => $activoGral);
  111. } else
  112. return array('fechas' =>'Por definir', 'activo' => false);
  113. break;
  114. case 'AUTORIZACION':
  115. $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
  116. $activo = false;
  117. $activoGral = false;
  118. if (count($fechas) > 0){
  119. $autorizacion = array();
  120. foreach ($fechas as $fecha){
  121. $temp = str_replace('{', '', $fecha['fecha']);
  122. $temp = str_replace('}', '', $temp);
  123. $temp = new DateTime($temp);
  124. if ($hoy >= strtotime(date($temp->format('Y/n/d')))){
  125. $activo = true;
  126. if (!$activoGral)
  127. $activoGral = true;
  128. } else
  129. $activo = false;
  130. array_push($autorizacion, array('fechas' => $temp, 'orden' => $fecha['orden']));
  131. }
  132. return array('fechas' => $autorizacion, 'activo' => $activoGral);
  133. } else
  134. return array('fechas' =>'Por definir', 'activo' => false);
  135. break;
  136. case 'GALERIA':
  137. case 'FINALISTAS':
  138. case 'GANADORES':
  139. $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
  140. $activo = false;
  141. if (count($fechas) > 0){
  142. $fecha = end($fechas);
  143. $temp = str_replace('{', '', $fecha['fecha']);
  144. $temp = str_replace('}', '', $temp);
  145. $temp = new DateTime($temp);
  146. if ($hoy >= strtotime(date($temp->format('Y/n/d'))))
  147. $activo = true;
  148. else
  149. $activo = false;
  150. return array('fechas' => $temp, 'activo' => $activo);
  151. } else
  152. return array('fechas' =>'Por definir', 'activo' => false);
  153. break;
  154. case 'EDITOR':
  155. $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
  156. $activo = false;
  157. if (count($fechas) > 0){
  158. $fecha = end($fechas);
  159. $temp = str_replace('{', '', $fecha['fecha']);
  160. $temp = str_replace('}', '', $temp);
  161. $temp = new DateTime($temp);
  162. if ($hoy <= strtotime(date($temp->format('Y/n/d'))))
  163. $activo = true;
  164. else
  165. $activo = false;
  166. return array('fechas' => $temp, 'activo' => $activo);
  167. } else
  168. return array('fechas' =>'Por definir', 'activo' => false);
  169. break;
  170. case 'REVISION':
  171. case 'EVALUACION':
  172. $activo = false;
  173. $fechas = Etapa::getFechasXEtapa($pdo, $concurso, $etapa['idetapa']);
  174. if (count($fechas) > 0){
  175. $fecha = end($fechas);
  176. $temp = str_replace('{', '', $fecha['fecha']);
  177. $temp = str_replace('}', '', $temp);
  178. $temp = explode(',', $temp);
  179. for ($cont = 0; $cont < count($temp); $cont++){
  180. $temp[$cont] = new DateTime($temp[$cont]);
  181. }
  182. if ($hoy >= strtotime(date($temp[0]->format('Y/n/d'))) && $hoy <= strtotime(date($temp[1]->format('Y/n/d'))))
  183. $activo = true;
  184. else
  185. $activo = false;
  186. return array('fechas' => $temp, 'activo' => $activo);
  187. } else
  188. return array('fechas' =>'Por definir', 'activo' => false);
  189. break;
  190. }
  191. }
  192. public static function tieneEvaluaciones($pdo,$etapa, $concurso){
  193. $evaluaciones = false;
  194. $stmt = $pdo->prepare('Select * from cidit_fs_existenevaluacionesconcurso(:etapa,:concurso)');
  195. $stmt->bindParam(':etapa', $etapa);
  196. $stmt->bindParam(':concurso', $concurso);
  197. if($stmt->execute()){
  198. $evaluaciones = $stmt->fetch();
  199. $evaluaciones = $evaluaciones['existe'];
  200. }
  201. $stmt->closeCursor();
  202. $stmt = null;
  203. return $evaluaciones;
  204. }
  205. public static function getMemorias($pdo){
  206. $memorias = array();
  207. $stmt = $pdo->prepare('Select * from cidit_fs_memorias()');
  208. if($stmt->execute())
  209. $memorias = $stmt->fetchAll();
  210. $stmt->closeCursor();
  211. $stmt = null;
  212. return $memorias;
  213. }
  214. }