123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- <?php
- /* AJAX
- * Genera nombramientos en pdf
- * Recibe:
- * id reposicion
- * Return:
- * imprime pdf
- */
- setlocale(LC_TIME, 'es_MX.UTF-8');
- require_once("../../include/nocache.php");
- require_once("../../include/bd_pdo.php");
- require_once("../../include/util.php");
- require_once("../../include/constantes.php");
- require_once("../../classes/ValidaSesion.php");
- include_once('../../include/xTemplate/xtemplate.class.php'); // including mpdf.php
- require "../../include/phpSpreadsheet/autoload.php";
- use PhpOffice\PhpSpreadsheet\IOFactory;
- use PhpOffice\PhpSpreadsheet\Spreadsheet;
- use PhpOffice\PhpSpreadsheet\Style\Border;
- use PhpOffice\PhpSpreadsheet\Style\Fill;
- use PhpOffice\PhpSpreadsheet\Style\Style;
- use PhpOffice\PhpSpreadsheet\Shared\Date;
- $pag = "../perfil.php";
- //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
- $objSesion = new ValidaSesion($pdo, 52, APSA);
- if(!$objSesion->tieneAcceso()){
- echo "<script>window.close();</script>";
- exit();
- }
- unset($objValida);
- if(!isset($_GET["id"])){
- echo "<script>window.close();</script>";
- exit();
- }
- $periodo_id = $_SESSION["periodo_id"];
- $profesor = $_GET["id"];
- //Obtiene datos de reposición
- $stmt = $pdo->prepare('Select * from fs_reposicion(:id, :per, NULL, NULL, NULL, NULL, NULL, 0, NULL)');
- $stmt->bindParam(":id", $profesor);
- $stmt->bindParam(":per", $periodo_id);
- if(!$stmt->execute()){
- header("Location:".$pag."?error=4");
- //print_r($stmt->errorInfo());
- exit();
- }
- $reposicion_rs = $stmt->fetch();
- $stmt->closeCursor();
- if(empty($reposicion_rs["HorarioGrupo_id"]) || $reposicion_rs["ReposicionEstado_id"] < 2){
- //echo "Error";
- echo "<script>window.close();</script>";
- exit();
- }
- //$reposicion_rs["Horario_id"]
- //Obtiene datos de horario original
- $stmt = $pdo->prepare('Select * from fs_horario(:id)');
- $stmt->bindParam(":id", $reposicion_rs["HorarioGrupo_id"]);
- if(!$stmt->execute()){
- header("Location:".$pag."?error=4");
- //print_r($stmt->errorInfo());
- exit();
- }
- $horario_rs = $stmt->fetch();
- $stmt->closeCursor();
- //-----
- // Create new Spreadsheet object
- $spreadsheet = new Spreadsheet();
- // Set document properties
- $spreadsheet->getProperties()->setCreator('Ingeniería La Salle')
- ->setLastModifiedBy('Ingeniería La Salle')
- ->setTitle('Asistencias profesores')
- ->setDescription('Reporte de asistencia de profesores.');
- // Rename worksheet
- $spreadsheet->getActiveSheet()->setTitle('Asistencias');
- $headerStyle = new Style();
- $headerStyle->applyFromArray(
- [
- 'fill' => [
- 'fillType' => Fill::FILL_SOLID,
- 'color' => ['argb' => 'FF001d68'],
- ],
- 'borders' => [
- 'bottom' => ['borderStyle' => Border::BORDER_THIN],
- 'right' => ['borderStyle' => Border::BORDER_MEDIUM],
- ],
- 'font' => [
- 'bold' => true,
- 'color' => ['argb' => 'FFFFFFFF'],
- ]
- ]
- );
- // Add some data
- $spreadsheet->setActiveSheetIndex(0)
- ->setCellValue('A1', 'Dependencia')
- ->setCellValue('B1', 'Nivel')
- ->setCellValue('C1', 'Programa académico')
- ->setCellValue('D1', 'Ciclo')
- ->setCellValue('E1', 'Bloque')
- ->setCellValue('F1', 'Plan')
- ->setCellValue('G1', 'Grupo')
- ->setCellValue('H1', 'Asignatura')
- ->setCellValue('I1', 'Docente')
- ->setCellValue('J1', 'Día')
- ->setCellValue('K1', 'Bloque horario')
- ->setCellValue('L1', 'Espacio actual')
- ->setCellValue('M1', 'Espacio requerido')
- ->setCellValue('N1', 'Motivo del cambio');
- $spreadsheet->getActiveSheet()->duplicateStyle($headerStyle, 'A1:N1');
- $highestRow = count($profesores_rs)+1;
- $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
- $fontDirs = $defaultConfig['fontDir'];
- $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
- $fontData = $defaultFontConfig['fontdata'];
- $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
- $fontDirs = $defaultConfig['fontDir'];
- $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
- $fontData = $defaultFontConfig['fontdata'];
- $mpdf = new \Mpdf\Mpdf([
- 'mode' => 'utf-8',
- 'format' => [215, 279],
- 'orientation' => 'P',
- 'fontDir' => array_merge($fontDirs, [
- __DIR__ . '/../../fonts/indivisaFont/ttf',
- ]),
- 'fontdata' => $fontData + [
- 'indivisa-display' => [
- 'R' => 'IndivisaDisplaySans-Regular.ttf',
- ],
- 'indivisa-title' => [
- 'R' => 'IndivisaDisplaySerif-RegularItalic.ttf',
- ],
- 'indivisa-text' => [
- 'R' => 'IndivisaTextSans-Regular.ttf',
- ]
- ],
- 'default_font' => 'indivisa-text'
- ]);
- $stylesheet = "<style>";
- $stylesheet .= file_get_contents('../../css/indivisa.css'); // external css
- $stylesheet .= file_get_contents('../css/cartareposicion.css'); // external css
- $stylesheet .= "</style>";
- $xtpl = new XTemplate('../tpl/reposicion.tpl.html');
- $xtpl->assign("TITULO1", "FACULTAD");
- $xtpl->assign("VALOR1", "FACULTAD DE INGENIERÍA");
- $xtpl->assign("TITULO2", "CARRERA");
- $xtpl->assign("VALOR2", mb_strtoupper($reposicion_rs["Carrera_desc"]));
- $xtpl->parse("main.tabla.renglon.data4");
- $xtpl->parse("main.tabla.renglon");
- $xtpl->assign("TITULO", "PROFESOR");
- $xtpl->assign("VALOR", mb_strtoupper($reposicion_rs["Usuario_nombre"]." ".$reposicion_rs["Usuario_apellidos"]));
- $xtpl->parse("main.tabla.renglon.data2");
- $xtpl->parse("main.tabla.renglon");
- $salon = $horario_rs["Salon_desc"];
- if($salon == ""){
- $salon = "<i>Pendiente</i>";
- }else{
- if(!empty($horario_rs["Salon_desc_larga"]))
- $salon = $horario_rs["Salon_desc_larga"];
- }
- $xtpl->assign("TITULO1", "SEMESTRE");
- $xtpl->assign("VALOR1", $reposicion_rs["Materia_semestre"]);
- $xtpl->assign("TITULO2", "SALON HABITUAL");
- $xtpl->assign("VALOR2", $salon);
- $xtpl->parse("main.tabla.renglon.data4");
- $xtpl->parse("main.tabla.renglon");
- $xtpl->assign("TITULO", "ASIGNATURA");
- $xtpl->assign("VALOR", mb_strtoupper($reposicion_rs["Materia_desc"]));
- $xtpl->parse("main.tabla.renglon.data2");
- $xtpl->parse("main.tabla.renglon");
- $xtpl->parse("main.tabla");
- $xtpl->assign("TITULO1", "FECHA DE SOLICITUD");
- $xtpl->assign("VALOR1", date("d/m/Y"));
- $xtpl->assign("TITULO2", "NÚMERO DE ALUMNOS");
- $xtpl->assign("VALOR2", $reposicion_rs["Reposicion_alumnos"]);
- $xtpl->parse("main.tabla.renglon.data4");
- $xtpl->parse("main.tabla.renglon");
- $xtpl->assign("TITULO1", "FECHA DE INASISTENCIA");
- $xtpl->assign("VALOR1", date("d/m/Y", strtotime($reposicion_rs["Reposicion_fecha_falta"])));
- $xtpl->assign("TITULO2", "HORARIO DE CLASE");
- $xtpl->assign("VALOR2", substr($horario_rs["Horario_hora"],0,-3)." a ".substr($horario_rs["Horario_hora_final"],0,-3)." hrs");
- $xtpl->parse("main.tabla.renglon.data4");
- $xtpl->parse("main.tabla.renglon");
- $xtpl->assign("TITULO1", "FECHA DE REPOSICIÓN");
- $xtpl->assign("VALOR1", date("d/m/Y", strtotime($reposicion_rs["Reposicion_fecha_nueva"])) );
- $xtpl->assign("TITULO2", "HORARIO DE CLASE");
- $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");
- $xtpl->parse("main.tabla.renglon.data4");
- $xtpl->parse("main.tabla.renglon");
- $xtpl->parse("main.tabla");
- $obs = "Ninguna";
- if(!empty($reposicion_rs["Reposicion_comentario"])){
- $obs = $reposicion_rs["Reposicion_comentario"];
- }
- $xtpl->assign("TITULO", "OBSERVACIONES");
- $xtpl->assign("VALOR", $obs);
- $xtpl->parse("main.tabla.renglon.data2");
- $xtpl->parse("main.tabla.renglon");
- $xtpl->parse("main.tabla");
- $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");
- foreach($nombres as $nom){
- $xtpl->assign("NOMBRE", $nom);
- $xtpl->parse("main.auxiliar");
- }
- $xtpl->parse("main");
- /*echo $stylesheet;
- $xtpl->out("main");exit();*/
- $mpdf->useActiveForms = true;
- $mpdf->WriteHTML($stylesheet);
- $mpdf->WriteHTML($xtpl->text("main"));
- $mpdf->Output("reposicion.pdf", 'I');
|