pdf_plancatedra_other copy.php 22 KB

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