pdf_plancatedra.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <?php
  2. ini_set('display_errors', 1);
  3. error_reporting(E_ALL);
  4. require_once './ims-blti/blti.php';
  5. setlocale(LC_TIME, 'es_MX.UTF-8');
  6. require_once("../include/nocache.php");
  7. require_once("../include/bd_pdo.php");
  8. require_once("../include/util.php");
  9. include_once('../include/xTemplate/xtemplate.class.php'); // including mpdf.php
  10. include_once('../include/mpdf/autoload.php'); // including mpdf.php
  11. $lti = new BLTI("Pl4n&Syll4bus", false, false);// Secreto compartido
  12. function getRGBA_color($hex, $a=0){
  13. list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
  14. $style = "rgba($r,$g, $b,";
  15. $style .= "$a)";
  16. return $style;
  17. }
  18. function buscaVacacion($fecha, $vacacionesArr){
  19. $i=0;
  20. foreach($vacacionesArr as $vacacion){
  21. if ($vacacion["fecha"] == $fecha){
  22. return $i;
  23. }
  24. $i++;
  25. }
  26. return false;
  27. }
  28. function getSesiones($arr, $num){
  29. foreach($arr as $ses){
  30. if($ses["sesion"] == $num ){
  31. return $ses["subsesiones"];
  32. }
  33. }
  34. return array();
  35. }
  36. //-------
  37. $electiva = false;
  38. if (!$lti->valid) {//si está fuera de moodle consulta por variables get (para pruebas)
  39. $errorDesc = $lti->message;
  40. $errorDesc .="- No se pueden obtener los datos del curso para generar el pdf.";
  41. echo $errorDesc;
  42. exit();
  43. }// LTI de conexión a moodle
  44. $clave_ulsa = intval(substr($lti->info["ext_user_username"], 2));//clave como entero
  45. if(substr_count($lti->info["context_label"], "-")<3){
  46. echo "<h1>Error</h1><p>No se puede hacer la consulta porque el shortaname no es válido.</p>";
  47. exit();
  48. }
  49. $tmp = explode("-", $lti->info["context_label"]);//Shortname
  50. $gpo_nom = $tmp[0];
  51. if($gpo_nom == "ELECTIVA"){
  52. $electiva = true;
  53. }
  54. $iniciales = $tmp[1];
  55. $mat = $tmp[3];
  56. $periodo_id = $lti->info["custom_periodo"]; //Obtenerlo de parametros
  57. $submateria = false;
  58. if($gpo_nom != "ELECTIVA"){ //No es electiva
  59. //Obtiene id gpo a partir de nombre
  60. $stmt = $pdo->prepare('SELECT * FROM fs_grupo(NULL, :per, :nombre)');
  61. $stmt->bindParam(":per", $periodo_id);
  62. $stmt->bindParam(":nombre", $gpo_nom);
  63. if(!$stmt->execute()){
  64. echo "Error al consultar la clave de usuario";
  65. exit();
  66. }else{
  67. $gpo_rs = $stmt->fetch();
  68. if(empty($gpo_rs)){
  69. echo "No existe el grupo";
  70. exit();
  71. }
  72. $gpo = $gpo_rs["Grupo_id"];
  73. }
  74. $stmt->closeCursor();
  75. //----------
  76. $stmt = $pdo->prepare('Select * from fs_profesoresmateriagrupo(:per, :mat, :gpo, NULL, NULL, NULL)');
  77. $stmt->bindParam(":mat", $mat);
  78. $stmt->bindParam(":per", $periodo_id);
  79. $stmt->bindParam(":gpo", $gpo);
  80. if(!$stmt->execute()){
  81. $t = $stmt->errorInfo();
  82. echo "Ocurrió un error al obtener los datos de los profesores ".$t[2];
  83. exit();
  84. }
  85. $profesor_rs = $stmt->fetchAll();
  86. $stmt->closeCursor();
  87. $usr = $profesor_rs[0]["Usuario_id"];
  88. $usr_nombre = $profesor_rs[0]["Usuario_nombre"]." ".$profesor_rs[0]["Usuario_apellidos"];
  89. //----------
  90. //echo "Select * from fs_syllabus_datos($periodo_id, $usr, $mat, $gpo, NULL ) limit 1"; exit();
  91. $stmt = $pdo->prepare('Select * from fs_syllabus(:periodo, :prof, :mat, :gpo, NULL ) limit 1');
  92. $stmt->bindParam(":periodo", $periodo_id);
  93. $stmt->bindParam(":mat", $mat);
  94. $stmt->bindParam(":gpo", $gpo);
  95. $syllabus_rs = [];
  96. foreach ($profesor_rs as $pr){
  97. $usr = $pr["Usuario_id"];
  98. $usr_nombre = $pr["Usuario_nombre"]." ".$pr["Usuario_apellidos"];
  99. $stmt->bindParam(":prof", $usr);
  100. if(!$stmt->execute()){
  101. $errorDesc = "Error al cargar los datos del alumno";
  102. echo $errorDesc;
  103. print_r($stmt->errorInfo());
  104. exit();
  105. }
  106. //$syllabus_rs = $stmt->fetch();
  107. $s_rs = $stmt->fetch();
  108. if(!empty($s_rs)){
  109. //break;
  110. $syllabus_rs[] = $s_rs;
  111. }
  112. }
  113. $stmt->closeCursor();
  114. }else{//Es electiva
  115. $usr = $tmp[4];//Último campo del shortname es is del usuario de electiva
  116. $stmt = $pdo->prepare('Select * from fs_usuario(:id)');
  117. $stmt->bindParam(":id", $usr);
  118. if(!$stmt->execute()){
  119. $t = $stmt->errorInfo();
  120. echo "Ocurrió un error al obtener los datos de los profesores ".$t[2];
  121. exit();
  122. }
  123. $profesor_rs = $stmt->fetch();
  124. $stmt->closeCursor();
  125. $usr_nombre = $profesor_rs["Usuario_nombre"]." ".$profesor_rs["Usuario_apellidos"];
  126. //----------
  127. //echo "Select * from fs_syllabus_datos($periodo_id, $usr, NULL, NULL, $mat ) limit 1"; exit();
  128. $stmt = $pdo->prepare('Select * from fs_syllabus_datos(:periodo, :prof, NULL, NULL, :sub ) limit 1');
  129. $stmt->bindParam(":periodo", $periodo_id);
  130. $stmt->bindParam(":prof", $usr);
  131. $stmt->bindParam(":sub", $mat);
  132. if(!$stmt->execute()){
  133. $errorDesc = "Error al cargar los datos del alumno";
  134. echo $errorDesc;
  135. print_r($stmt->errorInfo());
  136. exit();
  137. }
  138. $syllabus_rs = [];
  139. $s_rs = $stmt->fetch();
  140. $syllabus_rs[] = $s_rs;
  141. $gpo = $s_rs["Grupo_id"];
  142. $stmt->closeCursor();
  143. $submateria = true;
  144. }
  145. // -------------
  146. $stmt = $pdo->prepare('Select * from fs_periodo(:periodo, NULL, NULL, NULL )');
  147. $stmt->bindParam(":periodo", $periodo_id);
  148. if(!$stmt->execute()){
  149. $errorDesc = "Error al cargar los datos del alumno";
  150. echo $errorDesc;
  151. print_r($stmt->errorInfo());
  152. exit();
  153. }
  154. $periodo_rs = $stmt->fetch();
  155. $stmt->closeCursor();
  156. $fecha_min = $periodo_rs["Periodo_fecha_inicial"];
  157. $fecha_max = $periodo_rs["Periodo_fecha_final"];
  158. //Obtiene materias de profesor
  159. if(!$submateria){
  160. $stmt = $pdo->prepare('Select * from fs_materiadias(:usr, :mat, :gpo, NULL)');
  161. $stmt->bindParam(":mat", $mat);
  162. }else{
  163. //echo "Select * from fs_materiadias($usr, NULL, $gpo, $mat)";
  164. $stmt = $pdo->prepare('Select * from fs_materiadias(:usr, NULL, :gpo, :sub)');
  165. $stmt->bindParam(":sub", $mat);
  166. }
  167. //echo "Select * from fs_materiadias($usr, $mat, $gpo, $sub)"; exit();
  168. $stmt->bindParam(":usr", $usr);
  169. $stmt->bindParam(":gpo", $gpo);
  170. if(!$stmt->execute()){
  171. //print_r($stmt->errorInfo());
  172. $errorDesc = "Ocurrió un error al cargar los días de las materias";
  173. echo $errorDesc;
  174. exit();
  175. }else{
  176. $rs = $stmt->fetchAll();
  177. $diasMatArr = array();
  178. foreach($rs as $dia){
  179. $diasMatArr[] = array( "dia"=> $dia["Dia_id"], "hora"=>substr($dia["Horario_hora"],0, 5));
  180. }
  181. }
  182. $stmt->closeCursor();
  183. $stmt = null;
  184. //-----
  185. // ---- Obtiene fechas de vacaciones
  186. $stmt = $pdo->prepare('select * from fs_calendarioevento_categoria(:fini, :ffin, 2, :periodo)');
  187. $stmt->bindParam(":fini", $fecha_min);
  188. $stmt->bindParam(":ffin", $fecha_max);
  189. $stmt->bindParam(":periodo", $periodo_id);
  190. if(!$stmt->execute()){
  191. $errorDesc = "Ocurrió un error al cargar las fechas de vacaciones";
  192. }else{
  193. $vacaciones_rs = $stmt->fetchAll();
  194. }
  195. $stmt->closeCursor();
  196. $stmt = null;
  197. $vacacionesArr = array();//Guarda los días individuales de vacaciones
  198. foreach($vacaciones_rs as $evento){
  199. $fecha = fechaGuion($evento["CalendarioEvento_fecha"]);
  200. switch($evento["CalendarioRepeticion_id"]){
  201. case 1: //diario
  202. while (strtotime($fecha) <= strtotime($evento["CalendarioReglas_fecha_final"])) {
  203. $vacacionesArr[] = array("fecha"=> $fecha, "titulo"=>$evento["CalendarioEvento_titulo"]);
  204. $fecha = date ("Y-m-d", strtotime("+1 day", strtotime($fecha)));
  205. }
  206. break;
  207. case 2: //semanal
  208. $diasArr = explode(",", $evento["CalendarioReglas_dias_str"]);
  209. while (strtotime($fecha) <= strtotime($evento["CalendarioReglas_fecha_final"])) {
  210. if(in_array(date("w", strtotime($fecha)), $diasArr) ){//si es el día que quiero
  211. $vacacionesArr[] = array("fecha"=> $fecha, "titulo"=>$evento["CalendarioEvento_titulo"]);
  212. }
  213. $fecha = date ("Y-m-d", strtotime("+1 day", strtotime($fecha)));
  214. }
  215. break;
  216. case 3://mensual
  217. $diasArr = explode(",", $evento["CalendarioReglas_dias_str"]);
  218. //reglas
  219. $weekTxt = array(1=>"first", 2=>"second", 3=>"third", 4=>"fourth", -1=>"last");
  220. $dayname = array("sun", "mon", "tue", "wed", "thu", "fri", "sat");
  221. $fecha = date ("Y-m-01", strtotime($fecha));//empieza a revisar en el primer día del mes
  222. $semana = $evento["CalendarioReglas_semana"];
  223. while (strtotime($fecha) <= strtotime($evento["CalendarioReglas_fecha_final"])) {
  224. foreach($diasArr as $d){
  225. //echo "-->". intval(date("w", strtotime($fecha)))." == ". intval($d)."[".$fecha."]";
  226. if($semana == 1 && intval(date("w", strtotime($fecha))) == intval($d) ){//si el día actual es el que quiero lo guarda
  227. $vacacionesArr[] = array("fecha"=> $fecha, "titulo"=>$evento["CalendarioEvento_titulo"]);
  228. }else{//si no calcula siguiente día
  229. if(intval(date("w", strtotime($fecha))) == intval($d)){
  230. $fechaTmp = date ("Y-m-d", strtotime($weekTxt[$semana-1]." ".$dayname[$d], strtotime($fecha)));
  231. }else{
  232. $fechaTmp = date ("Y-m-d", strtotime($weekTxt[$semana]." ".$dayname[$d], strtotime($fecha)));
  233. }
  234. $vacacionesArr[] = array("fecha"=> $fecha, "titulo"=>$evento["CalendarioEvento_titulo"]);
  235. }
  236. }
  237. $fecha = date ("Y-m-01", strtotime("+1 month", strtotime($fecha)));//siguiente mes primer día
  238. }
  239. break;
  240. default: //no se repite
  241. $vacacionesArr[] = array("fecha"=> $fecha, "titulo"=>$evento["CalendarioEvento_titulo"]);
  242. }
  243. }
  244. //----- Calcula fechas de clases
  245. $MESES = array(1=>"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
  246. $DIAS = array("Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado");
  247. $calendario = array();
  248. $fechasArr = array();
  249. $fecha = $fecha_min;
  250. $semOld=1;
  251. $cont = 0;
  252. if(count($diasMatArr)==0){
  253. echo "<h3>No hay días registrados</h3>";
  254. exit();
  255. }
  256. while (strtotime($fecha) <= strtotime($fecha_max)) {
  257. if(date("w", strtotime($fecha)) == $diasMatArr[$cont%count($diasMatArr)]["dia"]) {//si es el día que quiero
  258. if($semOld != floor($cont/count($diasMatArr))+1){
  259. $sem = floor($cont/count($diasMatArr))+1;
  260. $semOld = $sem;
  261. $calendario[] = array("semana"=>$sem-1, "fechas"=>$fechasArr);
  262. $fechasArr = array();
  263. }
  264. $vacPos = buscaVacacion($fecha, $vacacionesArr);
  265. if($vacPos === false){//no vacaciones
  266. $fechasArr[] = array("numSesion"=>$cont+1, "fecha"=>fechaSlash($fecha)." ".$diasMatArr[$cont%count($diasMatArr)]["hora"], "mes"=>date("n", strtotime($fecha)), "habil"=>true, "dia"=>$DIAS[date("w", strtotime($fecha))-1], "titulo"=>"");
  267. //Si el día de la fecha no es el día del siguiente evento O se reinicia el arreglo de días
  268. if(date("w", strtotime($fecha)) != $diasMatArr[$cont%count($diasMatArr)]["dia"] || ($cont+1)%count($diasMatArr)==0){
  269. $fecha = date ("Y-m-d", strtotime("+1 day", strtotime($fecha)));
  270. }
  271. }else{//vacaciones
  272. $fechasArr[] = array("numSesion"=> 0,"fecha"=>fechaSlash($fecha), "mes"=>date("n", strtotime($fecha)), "habil"=>false, "dia"=>$DIAS[date("w", strtotime($fecha))-1], "titulo"=>$vacacionesArr[$vacPos]["titulo"]);
  273. $aux = $cont/count($diasMatArr);//para que sean de la misma semana
  274. //mientras sea el mismodía de la misma semana
  275. if(date("w", strtotime($fecha)) != $diasMatArr[$cont%count($diasMatArr)]["dia"] || ($cont+1)%count($diasMatArr)==0){
  276. while(date("w", strtotime($fecha)) == $diasMatArr[$cont%count($diasMatArr)]["dia"] && ($cont+1)%count($diasMatArr)!=0){
  277. $cont++;
  278. }
  279. $fecha = date ("Y-m-d", strtotime("+1 day", strtotime($fecha)));
  280. }
  281. }
  282. $cont++;
  283. }else{
  284. $fecha = date ("Y-m-d", strtotime("+1 day", strtotime($fecha)));
  285. }
  286. }
  287. if($semOld != floor($cont/count($diasMatArr))){
  288. $sem = floor($cont/count($diasMatArr))+1;
  289. }else{
  290. $sem = floor($cont/count($diasMatArr));
  291. }
  292. $calendario[] = array("semana"=>$sem, "fechas"=>$fechasArr);
  293. //$mesMin = $calendario[0]["fechas"][0]["mes"];
  294. //$mesMax = $calendario[count($calendario)-1]["fechas"][0]["mes"];
  295. $cont = 1;
  296. $i=0;
  297. $j=0;
  298. for($i=0; $i< count($calendario); $i++){
  299. for($j=0; $j< count($calendario[$i]["fechas"]); $j++){
  300. if($calendario[$i]["fechas"][$j]["habil"]){
  301. $calendario[$i]["fechas"][$j]["numSesion"] = $cont;
  302. $cont++;
  303. }
  304. }
  305. }
  306. //---Obtiebe contenido de sesiones plan cátedra
  307. if($electiva){
  308. $stmt = $pdo->prepare('Select * from fs_sesioncatedra(:mat, :usr, :gpo, :sub, NULL)');
  309. $stmt->bindParam(":sub", $mat);
  310. }else{
  311. $stmt = $pdo->prepare('Select * from fs_sesioncatedra(:mat, :usr, :gpo, NULL, NULL)');
  312. }
  313. $stmt->bindParam(":mat", $mat);
  314. $stmt->bindParam(":usr", $usr);
  315. $stmt->bindParam(":gpo", $gpo);
  316. if(!$stmt->execute()){
  317. //print_r($stmt->errorInfo());
  318. $errorDesc = "Ocurrió un error al cargar las sesiones del plan de cátedra";
  319. }else{
  320. $rs = $stmt->fetchAll();
  321. $sesionesArr = array();
  322. $ses_old = -1;
  323. //$subsesionArr = array();
  324. $i = -1;
  325. foreach($rs as $ses){
  326. if($ses_old != $ses["SesionCatedra_numero"]){
  327. $i++;
  328. $sesionesArr[$i]=array("sesion"=>$ses["SesionCatedra_numero"], "subsesiones"=>array());
  329. $ses_old = $ses["SesionCatedra_numero"];
  330. }
  331. $sesionesArr[$i]["subsesiones"][] = array("desc"=>$ses["SesionCatedra_desc"], "tipo_id"=>$ses["SesionCatedraTipo_id"], "tipo"=>$ses["SesionCatedraTipo_desc"], "color"=>$ses["SesionCatedraTipo_color"]);
  332. //$diasMatArr[] = array( "dia"=> $dia["Dia_id"], "hora"=>substr($dia["Horario_hora"],0, 5));
  333. }
  334. }
  335. //print_r($sesionesArr); exit();
  336. $stmt->closeCursor();
  337. $stmt = null;
  338. if($electiva){
  339. //echo "SELECT * FROM fs_submateria_materia($gpo, $usr, $mat)";exit();
  340. $stmt = $pdo->prepare('SELECT * FROM fs_submateria_materia(:gpo, :usr, :sub)');
  341. $stmt->bindParam(":gpo", $gpo);
  342. $stmt->bindParam(":usr", $usr);
  343. $stmt->bindParam(":sub", $mat);
  344. if(!$stmt->execute()){
  345. $errorDesc = "Error al cargar los datos de la materia";
  346. echo $errorDesc;
  347. print_r($stmt->errorInfo());
  348. exit();
  349. }
  350. $submat_rs = $stmt->fetch();
  351. //$stmt = $pdo->prepare('Select * from fs_horariogrupo(:gpo, NULL, false) AS hg INNER JOIN "Dia" d ON hg."Dia_id" = d."Dia_id" WHERE "Materia_id" = :mat ORDER BY d."Dia_id", hg."Horario_hora"');
  352. $stmt = $pdo->prepare('Select "Hora_inicio" AS "Horario_hora", "Dia_desc", "Salon_desc", "Salon_desc_larga" from fs_mihorario(:usr, :per, 3) as hg INNER JOIN "Dia" d ON hg."Dia_id" = d."Dia_id" where "TipoHorario_id" = 3 and hg."Materia_id" = :mat ORDER BY d."Dia_id", "Hora_inicio"');
  353. $stmt->bindParam(":usr", $usr);
  354. $stmt->bindParam(":per", $periodo_id);
  355. $stmt->bindParam(":mat", $submat_rs["Materia_id"]);
  356. }else{
  357. $stmt = $pdo->prepare('Select * from fs_horariogrupo(:gpo, NULL, false) AS hg INNER JOIN "Dia" d ON hg."Dia_id" = d."Dia_id" WHERE "Materia_id" = :mat ORDER BY d."Dia_id", hg."Horario_hora"');
  358. $stmt->bindParam(":mat", $mat);
  359. $stmt->bindParam(":gpo", $gpo);
  360. }
  361. if(!$stmt->execute()){
  362. $errorDesc = "Error al cargar los datos del horario";
  363. echo $errorDesc;
  364. print_r($stmt->errorInfo());
  365. exit();
  366. }
  367. $horario_rs = $stmt->fetchAll();
  368. $stmt->closeCursor();
  369. //---Tipo de sesiones plan cátedra
  370. $stmt = $pdo->prepare('Select * from fs_sesioncatedra_tipo(NULL)');
  371. if(!$stmt->execute()){
  372. //print_r($stmt->errorInfo());
  373. $errorDesc = "Ocurrió un error al cargar los días de las materias";
  374. }else{
  375. $tipoSesionArr = $stmt->fetchAll();
  376. }
  377. $stmt->closeCursor();
  378. $stmt = null;
  379. //-----
  380. $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
  381. $fontDirs = $defaultConfig['fontDir'];
  382. $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
  383. $fontData = $defaultFontConfig['fontdata'];
  384. $mpdf = new \Mpdf\Mpdf([
  385. 'mode' => 'utf-8',
  386. 'format' => [215, 279],
  387. 'orientation' => 'P',
  388. 'margin_left' => 14,
  389. 'margin_right' => 14,
  390. 'margin_top' => 27,
  391. 'margin_bottom' => 27,
  392. 'fontDir' => array_merge($fontDirs, [
  393. __DIR__ . '/../fonts/indivisaFont/ttf',
  394. ]),
  395. 'fontdata' => $fontData + [
  396. 'indivisa-display' => [
  397. 'R' => 'IndivisaDisplaySans-Regular.ttf',
  398. ],
  399. 'indivisa-title' => [
  400. 'R' => 'IndivisaDisplaySerif-RegularItalic.ttf',
  401. ],
  402. 'indivisa-text' => [
  403. 'R' => 'IndivisaTextSans-Regular.ttf',
  404. ]
  405. ],
  406. 'default_font' => 'indivisa-text',
  407. ]);
  408. //$mpdf->SetDisplayMode('fullpage');
  409. $stylesheet = "<style>";
  410. $stylesheet .= file_get_contents('../css/indivisa.css'); // external css
  411. $stylesheet .= file_get_contents('../apsa/css/syllabus.css'); // external css
  412. $stylesheet .= "</style>";
  413. $xtpl = new XTemplate('../apsa/tpl/plancatedra.tpl.html');
  414. foreach($syllabus_rs as $data){
  415. $mat_nombre = isset($data["Submateria_desc"])?$data["Submateria_desc"]:$data["Materia_desc"];
  416. $xtpl->assign("MATERIA", $mat_nombre." ".$gpo_nom);
  417. $xtpl->assign("SEMESTRE", $data["Materia_semestre"]);
  418. $xtpl->assign("PERIODO", $periodo_rs["Periodo_desc"]);
  419. $xtpl->assign("PROFESOR", $usr_nombre);
  420. foreach($horario_rs as $h){
  421. $hora = substr($h["Horario_hora"], 0, 5);
  422. if($h["Salon_desc"]==""){
  423. $salon = "Salón pendiente";
  424. }else{
  425. $salon = $h["Salon_desc"];
  426. if($h["Salon_desc_larga"] != ""){
  427. $salon .=" (".$h["Salon_desc_larga"].")";
  428. }
  429. }
  430. $xtpl->assign("DIA", $h["Dia_desc"]);
  431. $xtpl->assign("HORA", $hora);
  432. $xtpl->assign("SALON", $salon);
  433. $xtpl->parse("main.content.fechas");
  434. }
  435. foreach($tipoSesionArr as $tses){
  436. $xtpl->assign("COLOR", $tses["SesionCatedraTipo_color"]);
  437. $xtpl->assign("TIPO", $tses["SesionCatedraTipo_desc"]);
  438. $xtpl->parse("main.content.tipo");
  439. }
  440. //---
  441. $mes_old = 0;
  442. $i=0;
  443. foreach($calendario as $semana){
  444. foreach($semana["fechas"] as $dia){
  445. if($mes_old != $dia["mes"]){
  446. $mes_old = $dia["mes"];
  447. $xtpl->assign("MES", mb_strtoupper($MESES[$mes_old]));
  448. $xtpl->parse("main.content.sesion.mes");
  449. $xtpl->parse("main.content.sesion");
  450. }
  451. $fechaArr = explode(" ",$dia["dia"]." ".fechaSlash($dia["fecha"]));
  452. if(count($fechaArr) == 2){
  453. $fechaArr[] = "00:00:00";
  454. }
  455. $xtpl->assign("FECHA_DIA", $fechaArr[0]);
  456. $xtpl->assign("FECHA", $fechaArr[1]);
  457. if($dia["habil"]){
  458. $xtpl->assign("HORA", $fechaArr[2]);
  459. $xtpl->assign("SEMANA", $semana["semana"]);
  460. $xtpl->assign("SESION", $dia["numSesion"]);
  461. $sesArr = getSesiones($sesionesArr, $dia["numSesion"]);
  462. if(count($sesArr) > 0){
  463. foreach($sesArr as $ses){
  464. if($ses["tipo_id"] == 1)
  465. $xtpl->assign("COLOR", getRGBA_color($ses["color"], 0.0));
  466. else
  467. $xtpl->assign("COLOR", getRGBA_color($ses["color"], 0.3));
  468. $xtpl->assign("DESC", $ses["desc"]);
  469. $xtpl->parse("main.content.sesion.regular.tema");
  470. }
  471. $xtpl->parse("main.content.sesion.regular");
  472. }else{
  473. $xtpl->assign("COLOR", getRGBA_color("#ffffff", 0));
  474. $xtpl->assign("DESC", "");
  475. $xtpl->parse("main.content.sesion.regular");
  476. }
  477. }else{
  478. $xtpl->assign("HORA", "");
  479. $xtpl->assign("DESC", $dia["titulo"]);
  480. $xtpl->parse("main.content.sesion.vacacion");
  481. }
  482. $xtpl->parse("main.content.sesion");
  483. }
  484. }
  485. /*$i++;
  486. if($i < count($syllabus_rs)){
  487. $xtpl->parse("main.content.pagebreak");
  488. }*/
  489. $xtpl->parse("main.content");
  490. }
  491. $xtpl->parse("main");
  492. //echo $stylesheet;
  493. //$xtpl->out("main"); exit;
  494. $header = '<table style="width:100%"><tr>
  495. <td><img src="../img/logopdf.png" width="40mm" class=""></td>
  496. <td align="right"><h1 class="titulo">PLAN DE CÁTEDRA | FACULTAD DE INGENIERÍA</h1></td>
  497. </tr></table>';
  498. $mpdf->SHYlang = 'es';
  499. $mpdf-> SetTitle('Plan de cátedra -' . $mat_nombre);
  500. $mpdf-> SetAuthor('Facultad de Ingeniería. © Universidad La Salle A.C. '.date("Y").' Todos los derechos Reservados.');
  501. $mpdf->SetHTMLHeader($header);//se pone como fondo
  502. $mpdf->SetHTMLFooter('<img src="../img/footer_docs.png" >');//se pone como fondo
  503. $mpdf->WriteHTML($stylesheet);
  504. if(!isset($errorDesc))
  505. $mpdf->WriteHTML($xtpl->text("main"));
  506. else
  507. $mpdf->WriteHTML($errorDesc);
  508. $mpdf->Output("planCátedra_".getIniciales($mat_nombre)."_".$gpo_nom.".pdf", 'I');
  509. ?>