pdf_plancatedra_resp.php 21 KB

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