xls_cartareposicion.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. /* AJAX
  3. * Genera nombramientos en pdf
  4. * Recibe:
  5. * id reposicion
  6. * Return:
  7. * imprime pdf
  8. */
  9. setlocale(LC_TIME, 'es_MX.UTF-8');
  10. require_once("../../include/nocache.php");
  11. require_once("../../include/bd_pdo.php");
  12. require_once("../../include/util.php");
  13. require_once("../../include/constantes.php");
  14. require_once("../../classes/ValidaSesion.php");
  15. include_once('../../include/xTemplate/xtemplate.class.php'); // including mpdf.php
  16. require "../../include/phpSpreadsheet/autoload.php";
  17. use PhpOffice\PhpSpreadsheet\IOFactory;
  18. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  19. use PhpOffice\PhpSpreadsheet\Style\Border;
  20. use PhpOffice\PhpSpreadsheet\Style\Fill;
  21. use PhpOffice\PhpSpreadsheet\Style\Style;
  22. use PhpOffice\PhpSpreadsheet\Shared\Date;
  23. $pag = "../perfil.php";
  24. //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
  25. $objSesion = new ValidaSesion($pdo, 52, APSA);
  26. if(!$objSesion->tieneAcceso()){
  27. echo "<script>window.close();</script>";
  28. exit();
  29. }
  30. unset($objValida);
  31. if(!isset($_GET["id"])){
  32. echo "<script>window.close();</script>";
  33. exit();
  34. }
  35. $periodo_id = $_SESSION["periodo_id"];
  36. $profesor = $_GET["id"];
  37. //Obtiene datos de reposición
  38. $stmt = $pdo->prepare('Select * from fs_reposicion(:id, :per, NULL, NULL, NULL, NULL, NULL, 0, NULL)');
  39. $stmt->bindParam(":id", $profesor);
  40. $stmt->bindParam(":per", $periodo_id);
  41. if(!$stmt->execute()){
  42. header("Location:".$pag."?error=4");
  43. //print_r($stmt->errorInfo());
  44. exit();
  45. }
  46. $reposicion_rs = $stmt->fetch();
  47. $stmt->closeCursor();
  48. if(empty($reposicion_rs["HorarioGrupo_id"]) || $reposicion_rs["ReposicionEstado_id"] < 2){
  49. //echo "Error";
  50. echo "<script>window.close();</script>";
  51. exit();
  52. }
  53. //$reposicion_rs["Horario_id"]
  54. //Obtiene datos de horario original
  55. $stmt = $pdo->prepare('Select * from fs_horario(:id)');
  56. $stmt->bindParam(":id", $reposicion_rs["HorarioGrupo_id"]);
  57. if(!$stmt->execute()){
  58. header("Location:".$pag."?error=4");
  59. //print_r($stmt->errorInfo());
  60. exit();
  61. }
  62. $horario_rs = $stmt->fetch();
  63. $stmt->closeCursor();
  64. //-----
  65. // Create new Spreadsheet object
  66. $spreadsheet = new Spreadsheet();
  67. // Set document properties
  68. $spreadsheet->getProperties()->setCreator('Ingeniería La Salle')
  69. ->setLastModifiedBy('Ingeniería La Salle')
  70. ->setTitle('Asistencias profesores')
  71. ->setDescription('Reporte de asistencia de profesores.');
  72. // Rename worksheet
  73. $spreadsheet->getActiveSheet()->setTitle('Asistencias');
  74. $headerStyle = new Style();
  75. $headerStyle->applyFromArray(
  76. [
  77. 'fill' => [
  78. 'fillType' => Fill::FILL_SOLID,
  79. 'color' => ['argb' => 'FF001d68'],
  80. ],
  81. 'borders' => [
  82. 'bottom' => ['borderStyle' => Border::BORDER_THIN],
  83. 'right' => ['borderStyle' => Border::BORDER_MEDIUM],
  84. ],
  85. 'font' => [
  86. 'bold' => true,
  87. 'color' => ['argb' => 'FFFFFFFF'],
  88. ]
  89. ]
  90. );
  91. // Add some data
  92. $spreadsheet->setActiveSheetIndex(0)
  93. ->setCellValue('A1', 'Dependencia')
  94. ->setCellValue('B1', 'Nivel')
  95. ->setCellValue('C1', 'Programa académico')
  96. ->setCellValue('D1', 'Ciclo')
  97. ->setCellValue('E1', 'Bloque')
  98. ->setCellValue('F1', 'Plan')
  99. ->setCellValue('G1', 'Grupo')
  100. ->setCellValue('H1', 'Asignatura')
  101. ->setCellValue('I1', 'Docente')
  102. ->setCellValue('J1', 'Día')
  103. ->setCellValue('K1', 'Bloque horario')
  104. ->setCellValue('L1', 'Espacio actual')
  105. ->setCellValue('M1', 'Espacio requerido')
  106. ->setCellValue('N1', 'Motivo del cambio');
  107. $spreadsheet->getActiveSheet()->duplicateStyle($headerStyle, 'A1:N1');
  108. $highestRow = count($profesores_rs)+1;
  109. $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
  110. $fontDirs = $defaultConfig['fontDir'];
  111. $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
  112. $fontData = $defaultFontConfig['fontdata'];
  113. $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
  114. $fontDirs = $defaultConfig['fontDir'];
  115. $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
  116. $fontData = $defaultFontConfig['fontdata'];
  117. $mpdf = new \Mpdf\Mpdf([
  118. 'mode' => 'utf-8',
  119. 'format' => [215, 279],
  120. 'orientation' => 'P',
  121. 'fontDir' => array_merge($fontDirs, [
  122. __DIR__ . '/../../fonts/indivisaFont/ttf',
  123. ]),
  124. 'fontdata' => $fontData + [
  125. 'indivisa-display' => [
  126. 'R' => 'IndivisaDisplaySans-Regular.ttf',
  127. ],
  128. 'indivisa-title' => [
  129. 'R' => 'IndivisaDisplaySerif-RegularItalic.ttf',
  130. ],
  131. 'indivisa-text' => [
  132. 'R' => 'IndivisaTextSans-Regular.ttf',
  133. ]
  134. ],
  135. 'default_font' => 'indivisa-text'
  136. ]);
  137. $stylesheet = "<style>";
  138. $stylesheet .= file_get_contents('../../css/indivisa.css'); // external css
  139. $stylesheet .= file_get_contents('../css/cartareposicion.css'); // external css
  140. $stylesheet .= "</style>";
  141. $xtpl = new XTemplate('../tpl/reposicion.tpl.html');
  142. $xtpl->assign("TITULO1", "FACULTAD");
  143. $xtpl->assign("VALOR1", "FACULTAD DE INGENIERÍA");
  144. $xtpl->assign("TITULO2", "CARRERA");
  145. $xtpl->assign("VALOR2", mb_strtoupper($reposicion_rs["Carrera_desc"]));
  146. $xtpl->parse("main.tabla.renglon.data4");
  147. $xtpl->parse("main.tabla.renglon");
  148. $xtpl->assign("TITULO", "PROFESOR");
  149. $xtpl->assign("VALOR", mb_strtoupper($reposicion_rs["Usuario_nombre"]." ".$reposicion_rs["Usuario_apellidos"]));
  150. $xtpl->parse("main.tabla.renglon.data2");
  151. $xtpl->parse("main.tabla.renglon");
  152. $salon = $horario_rs["Salon_desc"];
  153. if($salon == ""){
  154. $salon = "<i>Pendiente</i>";
  155. }else{
  156. if(!empty($horario_rs["Salon_desc_larga"]))
  157. $salon = $horario_rs["Salon_desc_larga"];
  158. }
  159. $xtpl->assign("TITULO1", "SEMESTRE");
  160. $xtpl->assign("VALOR1", $reposicion_rs["Materia_semestre"]);
  161. $xtpl->assign("TITULO2", "SALON HABITUAL");
  162. $xtpl->assign("VALOR2", $salon);
  163. $xtpl->parse("main.tabla.renglon.data4");
  164. $xtpl->parse("main.tabla.renglon");
  165. $xtpl->assign("TITULO", "ASIGNATURA");
  166. $xtpl->assign("VALOR", mb_strtoupper($reposicion_rs["Materia_desc"]));
  167. $xtpl->parse("main.tabla.renglon.data2");
  168. $xtpl->parse("main.tabla.renglon");
  169. $xtpl->parse("main.tabla");
  170. $xtpl->assign("TITULO1", "FECHA DE SOLICITUD");
  171. $xtpl->assign("VALOR1", date("d/m/Y"));
  172. $xtpl->assign("TITULO2", "NÚMERO DE ALUMNOS");
  173. $xtpl->assign("VALOR2", $reposicion_rs["Reposicion_alumnos"]);
  174. $xtpl->parse("main.tabla.renglon.data4");
  175. $xtpl->parse("main.tabla.renglon");
  176. $xtpl->assign("TITULO1", "FECHA DE INASISTENCIA");
  177. $xtpl->assign("VALOR1", date("d/m/Y", strtotime($reposicion_rs["Reposicion_fecha_falta"])));
  178. $xtpl->assign("TITULO2", "HORARIO DE CLASE");
  179. $xtpl->assign("VALOR2", substr($horario_rs["Horario_hora"],0,-3)." a ".substr($horario_rs["Horario_hora_final"],0,-3)." hrs");
  180. $xtpl->parse("main.tabla.renglon.data4");
  181. $xtpl->parse("main.tabla.renglon");
  182. $xtpl->assign("TITULO1", "FECHA DE REPOSICIÓN");
  183. $xtpl->assign("VALOR1", date("d/m/Y", strtotime($reposicion_rs["Reposicion_fecha_nueva"])) );
  184. $xtpl->assign("TITULO2", "HORARIO DE CLASE");
  185. $xtpl->assign("VALOR2", date("H:i", strtotime($reposicion_rs["Reposicion_fecha_nueva"]))." A ".date("H:i", strtotime($reposicion_rs["Reposicion_fecha_nueva"].' +'.$horario_rs["Horario_duracion"].'minutes'))." hrs");
  186. $xtpl->parse("main.tabla.renglon.data4");
  187. $xtpl->parse("main.tabla.renglon");
  188. $xtpl->parse("main.tabla");
  189. $obs = "Ninguna";
  190. if(!empty($reposicion_rs["Reposicion_comentario"])){
  191. $obs = $reposicion_rs["Reposicion_comentario"];
  192. }
  193. $xtpl->assign("TITULO", "OBSERVACIONES");
  194. $xtpl->assign("VALOR", $obs);
  195. $xtpl->parse("main.tabla.renglon.data2");
  196. $xtpl->parse("main.tabla.renglon");
  197. $xtpl->parse("main.tabla");
  198. $nombres = array("Rosa Lilia Salazar Trejo", "Ivonne Valdez Medina","María Fernanda Miranda Temahuay","David Cardoso de la Cruz","Fabricio Campos Villaseñor","Gilberto Adolfo Reyes Piñón","Juan Manuel Sánchez Durán");
  199. foreach($nombres as $nom){
  200. $xtpl->assign("NOMBRE", $nom);
  201. $xtpl->parse("main.auxiliar");
  202. }
  203. $xtpl->parse("main");
  204. /*echo $stylesheet;
  205. $xtpl->out("main");exit();*/
  206. $mpdf->useActiveForms = true;
  207. $mpdf->WriteHTML($stylesheet);
  208. $mpdf->WriteHTML($xtpl->text("main"));
  209. $mpdf->Output("reposicion.pdf", 'I');