123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <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>
|