71 lines
1.9 KiB
PHP
71 lines
1.9 KiB
PHP
<?php
|
|
require_once __DIR__.'/auth_guard.php';
|
|
|
|
include '../config.php';
|
|
require_once '../vendor/Classes/PHPExcel.php';
|
|
session_name($CFG->sessionname);
|
|
session_start();
|
|
if(!isset($_SESSION['usersession'])){
|
|
header("Location: ".$CFG->wwwroot);
|
|
}
|
|
|
|
dbConnect();
|
|
global $link;
|
|
|
|
|
|
$sqlusers = "SELECT
|
|
categoria.nombre
|
|
FROM
|
|
categoria
|
|
WHERE
|
|
habilitado = 1 AND padre = 0";
|
|
|
|
|
|
|
|
$resultados = mysqli_query($link, $sqlusers);
|
|
$columnasname = ['numempl'];
|
|
while ($row = mysqli_fetch_array ($resultados)){
|
|
array_push($columnasname,$row['nombre']);
|
|
}
|
|
|
|
|
|
|
|
$objPHPExcel = new PHPExcel();
|
|
|
|
|
|
|
|
$objPHPExcel->
|
|
getProperties()
|
|
->setCreator("Estafeta")
|
|
->setLastModifiedBy("Estafeta")
|
|
->setTitle("Template asignación")
|
|
->setSubject("Template")
|
|
->setDescription("Template para asignación de usuarios a categorías")
|
|
->setKeywords("Template")
|
|
->setCategory("Template");
|
|
|
|
|
|
$columnas = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
|
|
|
|
for ($i=0; $i < sizeof($columnasname) ; $i++) {
|
|
$objPHPExcel->setActiveSheetIndex(0)
|
|
->setCellValue($columnas[$i].'1', $columnasname[$i]);
|
|
$objPHPExcel->getActiveSheet()
|
|
->getColumnDimension($columnas[$i])
|
|
->setAutoSize(true);
|
|
}
|
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setTitle('Asignaciones');
|
|
$objPHPExcel->setActiveSheetIndex(0);
|
|
|
|
|
|
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
header('Content-Disposition: attachment;filename="template_asignacion_'.date('Ymd').'.xlsx"');
|
|
header('Cache-Control: max-age=0');
|
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
|
$objWriter->save('php://output');
|
|
exit;
|
|
|
|
?>
|