Actualización

This commit is contained in:
Your Name
2024-10-07 19:31:30 +00:00
parent 189566ce16
commit e5715e3b05
108 changed files with 27751 additions and 26012 deletions

View File

@@ -1,50 +1,50 @@
<?php
/**
* PHPMailer SPL autoloader.
* PHP Version 5
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* PHPMailer SPL autoloader.
* @param string $classname The name of the class to load
*/
function PHPMailerAutoload($classname)
{
//Can't use __DIR__ as it's only in PHP 5.3+
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
if (is_readable($filename)) {
require $filename;
}
}
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
spl_autoload_register($classname);
/*function __autoload($classname)
{
PHPMailerAutoload($classname);
}*/
}
<?php
/**
* PHPMailer SPL autoloader.
* PHP Version 5
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* PHPMailer SPL autoloader.
* @param string $classname The name of the class to load
*/
function PHPMailerAutoload($classname)
{
//Can't use __DIR__ as it's only in PHP 5.3+
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
if (is_readable($filename)) {
require $filename;
}
}
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
spl_autoload_register($classname);
/*function __autoload($classname)
{
PHPMailerAutoload($classname);
}*/
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,252 +1,252 @@
<style>
details {
border: 1px solid #aaa;
border-radius: 4px;
padding: 0.5em 0.5em 0;
margin: 0.5em 0;
}
summary {
font-weight: bold;
margin: -0.5em -0.5em 0;
padding: 0.5em;
}
details[open] {
padding: 0.5em;
}
details[open] summary {
border-bottom: 1px solid #aaa;
margin-bottom: 0.5em;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
th,
td {
padding: 8px;
border: 1px solid #ccc;
text-align: left;
}
th {
background-color: #f2f2f2;
}
tr:nth-child(even):not(.empty):not(.area-comun) {
background-color: #f9f9f9;
}
.json-container {
white-space: pre-wrap;
/* Since JSON is formatted with whitespace, this will keep formatting */
word-break: break-word;
/* To prevent horizontal scrolling */
max-height: 150px;
/* Set a max-height and add scroll to prevent very long JSON from cluttering the table */
overflow-y: auto;
}
.empty {
/* rosa pastel */
background-color: #ffe8f4;
}
.area-comun {
/* naranja pastel */
background-color: #ffe9d4;
}
</style>
<?php
/*
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
claveFacultad: clave de la facultad a consultar (opcional, cadena)
claveCarrera: clave de la carrera a consultar (opcional, cadena)
claveProfesor: clave del empleado a consultar (opcional, cadena)
fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('post_max_size', 1);
ini_set('max_execution_time', 8 * 60);
error_reporting(E_ALL);
date_default_timezone_set('America/Mexico_City');
$ruta = "../";
$ruta_superior = dirname(__DIR__);
require_once $ruta_superior . "/include/bd_pdo.php";
require_once __DIR__ . "/token.php";
require_once __DIR__ . "/LogCambios.php";
$fecha = isset($_GET["fecha"]) ? $_GET["fecha"] : date("Y-m-d");
$periodos = $db
->where("id_periodo_sgu", 0, ">")
->where("periodo_fecha_inicio", $fecha, "<=")
->where("periodo_fecha_fin", $fecha, ">=")
->orderBy("periodo_id")
->get("periodo");
?>
<nav>
<form action="" method="get">
<label for="fecha">Fecha</label>
<input type="date" name="fecha" id="fecha" value="<?= $fecha ?>">
<button type="submit">Buscar</button>
</form>
<details>
<summary>Periodos</summary>
<pre>
<code><?= json_encode($periodos, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code>
</pre>
</details>
<?php
$horarios = array();
foreach (array_column($periodos, "id_periodo_sgu") as $idPeriodo) {
$curl = curl_init();
$params = array(
'idPeriodo' => $idPeriodo,
'fecha' => $fecha,
);
curl_setopt_array($curl, [
CURLOPT_URL => 'https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/seleccionar',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode($params),
CURLOPT_HTTPHEADER => [
"token: $token",
'username: SGU_APSA_AUD_ASIST',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$response = json_decode($response, true, 512, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$horarios = array_merge($horarios, $response);
?>
<details>
<summary>Periodo
<?= $idPeriodo ?>
</summary>
<pre><code><?= json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code></pre>
</details>
<?php } ?>
</nav>
<main>
<p>
<?= count($horarios) ?> horarios encontrados para
<?= $fecha ?>
</p>
<table>
<thead>
<tr>
<th>Materia en SGU</th>
<th>Materia en Postgres</th>
</tr>
</thead>
<tbody>
<?php
// $horarios with unique "NombreMateria" field
$horarios = array_map("unserialize", array_unique(array_map("serialize", $horarios)));
foreach ($horarios as $horario) {
$materias = $db
->where("materia_nombre", trim($horario["NombreMateria"]), "ILIKE")
->join("carrera", "carrera.carrera_id = materia.carrera_id")
->join("facultad", "facultad.facultad_id = carrera.facultad_id")
->get("materia");
if (
count(array_filter($materias, fn($m) =>
$m["clave_materia"] == trim($horario["ClaveMateria"]) and
$m["clave_carrera"] == trim($horario["ClaveCarrera"]))) > 0
) {
continue;
}
// si de las materias alguna tiene carrera_id entre 1 y 4 entonces es de área común
$area_comun = count(array_filter($materias, fn($m) => $m["carrera_id"] >= 1 and $m["carrera_id"] <= 4)) > 0;
$vacío = count($materias) == 0;
?>
<!-- si es vacío ponle la clase empty y si es área común ponle la clase area-comun -->
<tr class="<?= $vacío ? "empty" : "" ?> <?= $area_comun ? "area-comun" : "" ?>">
<td class="json-container">
<details>
<summary>Horario</summary>
<pre><code><?= json_encode($horario, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code></pre>
</details>
<?= json_encode(array_intersect_key($horario, array_flip(["ClaveMateria", "NombreMateria", "ClaveCarrera", "Dependencia"])), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>
</td>
<td class="json-container">
<?php if ($vacío) { ?>
<p>No se encontraron materias</p>
<?php } else { ?>
<details>
<summary>Materias</summary>
<pre><code><?= json_encode($materias, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code></pre>
</details>
<table>
<thead>
<tr>
<th>Materia</th>
<th>Carrera</th>
<th>Facultad</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<script>
async function copiar_seleccionados() {
// en mi clipboard quiero (join con ,)
const materias_seleccionadas = Array.from(document.querySelectorAll("input[name='materia_id']:checked"))
.map(input => input.value)
.join(",");
// copiar al clipboard
await navigator.clipboard.writeText(materias_seleccionadas);
// mostrar mensaje de éxito
alert("Copiado al portapapeles");
}
</script>
<?php foreach ($materias as $materia) { ?>
<tr>
<td>
<input type="checkbox" name="materia_id" id="materia_id"
value="<?= $materia["materia_id"] ?>">
</td>
<td>
<?= $materia["materia_id"] ?>
<small>
(
<?= $materia["clave_materia"] ?>)
</small>
<?= $materia["materia_nombre"] ?>
</td>
<td>
<small>
(
<?= $materia["clave_carrera"] ?>)
</small>
<?= $materia["carrera_nombre"] ?>
</td>
<td>
<small>
(
<?= $materia["clave_dependencia"] ?>)
</small>
<?= $materia["facultad_nombre"] ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<style>
details {
border: 1px solid #aaa;
border-radius: 4px;
padding: 0.5em 0.5em 0;
margin: 0.5em 0;
}
summary {
font-weight: bold;
margin: -0.5em -0.5em 0;
padding: 0.5em;
}
details[open] {
padding: 0.5em;
}
details[open] summary {
border-bottom: 1px solid #aaa;
margin-bottom: 0.5em;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
th,
td {
padding: 8px;
border: 1px solid #ccc;
text-align: left;
}
th {
background-color: #f2f2f2;
}
tr:nth-child(even):not(.empty):not(.area-comun) {
background-color: #f9f9f9;
}
.json-container {
white-space: pre-wrap;
/* Since JSON is formatted with whitespace, this will keep formatting */
word-break: break-word;
/* To prevent horizontal scrolling */
max-height: 150px;
/* Set a max-height and add scroll to prevent very long JSON from cluttering the table */
overflow-y: auto;
}
.empty {
/* rosa pastel */
background-color: #ffe8f4;
}
.area-comun {
/* naranja pastel */
background-color: #ffe9d4;
}
</style>
<?php
/*
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
claveFacultad: clave de la facultad a consultar (opcional, cadena)
claveCarrera: clave de la carrera a consultar (opcional, cadena)
claveProfesor: clave del empleado a consultar (opcional, cadena)
fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('post_max_size', 1);
ini_set('max_execution_time', 8 * 60);
error_reporting(E_ALL);
date_default_timezone_set('America/Mexico_City');
$ruta = "../";
$ruta_superior = dirname(__DIR__);
require_once $ruta_superior . "/include/bd_pdo.php";
require_once __DIR__ . "/token.php";
require_once __DIR__ . "/LogCambios.php";
$fecha = isset($_GET["fecha"]) ? $_GET["fecha"] : date("Y-m-d");
$periodos = $db
->where("id_periodo_sgu", 0, ">")
->where("periodo_fecha_inicio", $fecha, "<=")
->where("periodo_fecha_fin", $fecha, ">=")
->orderBy("periodo_id")
->get("periodo");
?>
<nav>
<form action="" method="get">
<label for="fecha">Fecha</label>
<input type="date" name="fecha" id="fecha" value="<?= $fecha ?>">
<button type="submit">Buscar</button>
</form>
<details>
<summary>Periodos</summary>
<pre>
<code><?= json_encode($periodos, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code>
</pre>
</details>
<?php
$horarios = array();
foreach (array_column($periodos, "id_periodo_sgu") as $idPeriodo) {
$curl = curl_init();
$params = array(
'idPeriodo' => $idPeriodo,
'fecha' => $fecha,
);
curl_setopt_array($curl, [
CURLOPT_URL => 'https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/seleccionar',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode($params),
CURLOPT_HTTPHEADER => [
"token: $token",
'username: SGU_APSA_AUD_ASIST',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$response = json_decode($response, true, 512, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$horarios = array_merge($horarios, $response);
?>
<details>
<summary>Periodo
<?= $idPeriodo ?>
</summary>
<pre><code><?= json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code></pre>
</details>
<?php } ?>
</nav>
<main>
<p>
<?= count($horarios) ?> horarios encontrados para
<?= $fecha ?>
</p>
<table>
<thead>
<tr>
<th>Materia en SGU</th>
<th>Materia en Postgres</th>
</tr>
</thead>
<tbody>
<?php
// $horarios with unique "NombreMateria" field
$horarios = array_map("unserialize", array_unique(array_map("serialize", $horarios)));
foreach ($horarios as $horario) {
$materias = $db
->where("materia_nombre", trim($horario["NombreMateria"]), "ILIKE")
->join("carrera", "carrera.carrera_id = materia.carrera_id")
->join("facultad", "facultad.facultad_id = carrera.facultad_id")
->get("materia");
if (
count(array_filter($materias, fn($m) =>
$m["clave_materia"] == trim($horario["ClaveMateria"]) and
$m["clave_carrera"] == trim($horario["ClaveCarrera"]))) > 0
) {
continue;
}
// si de las materias alguna tiene carrera_id entre 1 y 4 entonces es de área común
$area_comun = count(array_filter($materias, fn($m) => $m["carrera_id"] >= 1 and $m["carrera_id"] <= 4)) > 0;
$vacío = count($materias) == 0;
?>
<!-- si es vacío ponle la clase empty y si es área común ponle la clase area-comun -->
<tr class="<?= $vacío ? "empty" : "" ?> <?= $area_comun ? "area-comun" : "" ?>">
<td class="json-container">
<details>
<summary>Horario</summary>
<pre><code><?= json_encode($horario, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code></pre>
</details>
<?= json_encode(array_intersect_key($horario, array_flip(["ClaveMateria", "NombreMateria", "ClaveCarrera", "Dependencia"])), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>
</td>
<td class="json-container">
<?php if ($vacío) { ?>
<p>No se encontraron materias</p>
<?php } else { ?>
<details>
<summary>Materias</summary>
<pre><code><?= json_encode($materias, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code></pre>
</details>
<table>
<thead>
<tr>
<th>Materia</th>
<th>Carrera</th>
<th>Facultad</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<script>
async function copiar_seleccionados() {
// en mi clipboard quiero (join con ,)
const materias_seleccionadas = Array.from(document.querySelectorAll("input[name='materia_id']:checked"))
.map(input => input.value)
.join(",");
// copiar al clipboard
await navigator.clipboard.writeText(materias_seleccionadas);
// mostrar mensaje de éxito
alert("Copiado al portapapeles");
}
</script>
<?php foreach ($materias as $materia) { ?>
<tr>
<td>
<input type="checkbox" name="materia_id" id="materia_id"
value="<?= $materia["materia_id"] ?>">
</td>
<td>
<?= $materia["materia_id"] ?>
<small>
(
<?= $materia["clave_materia"] ?>)
</small>
<?= $materia["materia_nombre"] ?>
</td>
<td>
<small>
(
<?= $materia["clave_carrera"] ?>)
</small>
<?= $materia["carrera_nombre"] ?>
</td>
<td>
<small>
(
<?= $materia["clave_dependencia"] ?>)
</small>
<?= $materia["facultad_nombre"] ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</main>

View File

@@ -1,149 +1,149 @@
<style>
details {
border: 1px solid #aaa;
border-radius: 4px;
padding: 0.5em 0.5em 0;
margin: 0.5em 0;
}
summary {
font-weight: bold;
margin: -0.5em -0.5em 0;
padding: 0.5em;
}
details[open] {
padding: 0.5em;
}
details[open] summary {
border-bottom: 1px solid #aaa;
margin-bottom: 0.5em;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
th,
td {
padding: 8px;
border: 1px solid #ccc;
text-align: left;
}
th {
background-color: #f2f2f2;
}
.json-container {
white-space: pre-wrap;
/* Since JSON is formatted with whitespace, this will keep formatting */
word-break: break-word;
/* To prevent horizontal scrolling */
max-height: 150px;
/* Set a max-height and add scroll to prevent very long JSON from cluttering the table */
overflow-y: auto;
}
.empty {
/* rosa pastel */
background-color: #ffe8f4;
}
.no-igual {
/* púrpura pastel */
background-color: #f4e8ff;
}
</style>
<?php
/*
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
claveFacultad: clave de la facultad a consultar (opcional, cadena)
claveCarrera: clave de la carrera a consultar (opcional, cadena)
claveProfesor: clave del empleado a consultar (opcional, cadena)
fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('post_max_size', 1);
ini_set('max_execution_time', 8 * 60);
error_reporting(E_ALL);
date_default_timezone_set('America/Mexico_City');
$ruta = "../";
$ruta_superior = dirname(__DIR__);
require_once $ruta_superior . "/include/bd_pdo.php";
require_once __DIR__ . "/token.php";
require_once __DIR__ . "/LogCambios.php";
$salon = array();
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL =>
'https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/espacios/seleccionar',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode([]),
CURLOPT_HTTPHEADER => [
"token: $token",
'username: SGU_APSA_AUD_ASIST',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$json_flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT;
$salones = json_decode($response, true, 512, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
?>
<main>
<p>
<?= count($salones) ?> salones encontrados
</p>
<table>
<thead>
<tr>
<th>Salones en SGU</th>
<th>SALONES en Postgres</th>
</tr>
</thead>
<tbody>
<?php
foreach ($salones as $salon) {
$salon_db = $db->where("id_espacio_sgu", $salon["IdEspacio"])->get("salon");
// si de el salon es igual NombreEspacio == salon
$vacío = empty($salon_db);
$igual = $salon["NombreEspacio"] == ($salon["salon"] ?? "");
if ($vacío) {
$db->insert("salon", [
"id_espacio_sgu" => $salon["IdEspacio"],
"salon" => $salon["NombreEspacio"],
"id_espacio_padre" => $salon["IdEspacioPadre"] > 0 ? $salon["IdEspacioPadre"] : null,
]);
} else if (!$igual) {
$db->where("id_espacio_sgu", $salon["IdEspacio"])->update("salon", [
"salon" => $salon["NombreEspacio"],
// "id_espacio_padre" => $salon["IdEspacioPadre"] > 0 ? $salon["IdEspacioPadre"] : null,
]);
}
?>
<tr class="<?= $igual ? "empty" : "no-igual" ?>">
<td class="json-container">
<?= json_encode($salon, $json_flags) ?>
</td>
<td class="json-container">
<?= json_encode($salon_db, $json_flags) ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<style>
details {
border: 1px solid #aaa;
border-radius: 4px;
padding: 0.5em 0.5em 0;
margin: 0.5em 0;
}
summary {
font-weight: bold;
margin: -0.5em -0.5em 0;
padding: 0.5em;
}
details[open] {
padding: 0.5em;
}
details[open] summary {
border-bottom: 1px solid #aaa;
margin-bottom: 0.5em;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
th,
td {
padding: 8px;
border: 1px solid #ccc;
text-align: left;
}
th {
background-color: #f2f2f2;
}
.json-container {
white-space: pre-wrap;
/* Since JSON is formatted with whitespace, this will keep formatting */
word-break: break-word;
/* To prevent horizontal scrolling */
max-height: 150px;
/* Set a max-height and add scroll to prevent very long JSON from cluttering the table */
overflow-y: auto;
}
.empty {
/* rosa pastel */
background-color: #ffe8f4;
}
.no-igual {
/* púrpura pastel */
background-color: #f4e8ff;
}
</style>
<?php
/*
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
claveFacultad: clave de la facultad a consultar (opcional, cadena)
claveCarrera: clave de la carrera a consultar (opcional, cadena)
claveProfesor: clave del empleado a consultar (opcional, cadena)
fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('post_max_size', 1);
ini_set('max_execution_time', 8 * 60);
error_reporting(E_ALL);
date_default_timezone_set('America/Mexico_City');
$ruta = "../";
$ruta_superior = dirname(__DIR__);
require_once $ruta_superior . "/include/bd_pdo.php";
require_once __DIR__ . "/token.php";
require_once __DIR__ . "/LogCambios.php";
$salon = array();
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL =>
'https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/espacios/seleccionar',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode([]),
CURLOPT_HTTPHEADER => [
"token: $token",
'username: SGU_APSA_AUD_ASIST',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$json_flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT;
$salones = json_decode($response, true, 512, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
?>
<main>
<p>
<?= count($salones) ?> salones encontrados
</p>
<table>
<thead>
<tr>
<th>Salones en SGU</th>
<th>SALONES en Postgres</th>
</tr>
</thead>
<tbody>
<?php
foreach ($salones as $salon) {
$salon_db = $db->where("id_espacio_sgu", $salon["IdEspacio"])->get("salon");
// si de el salon es igual NombreEspacio == salon
$vacío = empty($salon_db);
$igual = $salon["NombreEspacio"] == ($salon["salon"] ?? "");
if ($vacío) {
$db->insert("salon", [
"id_espacio_sgu" => $salon["IdEspacio"],
"salon" => $salon["NombreEspacio"],
"id_espacio_padre" => $salon["IdEspacioPadre"] > 0 ? $salon["IdEspacioPadre"] : null,
]);
} else if (!$igual) {
$db->where("id_espacio_sgu", $salon["IdEspacio"])->update("salon", [
"salon" => $salon["NombreEspacio"],
// "id_espacio_padre" => $salon["IdEspacioPadre"] > 0 ? $salon["IdEspacioPadre"] : null,
]);
}
?>
<tr class="<?= $igual ? "empty" : "no-igual" ?>">
<td class="json-container">
<?= json_encode($salon, $json_flags) ?>
</td>
<td class="json-container">
<?= json_encode($salon_db, $json_flags) ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</main>