{"id":2938,"date":"2024-10-04T09:55:42","date_gmt":"2024-10-04T14:55:42","guid":{"rendered":"https:\/\/www.lem.uni.edu.pe\/?page_id=2938"},"modified":"2025-02-03T00:06:47","modified_gmt":"2025-02-03T05:06:47","slug":"expedientes-emitidos","status":"publish","type":"page","link":"https:\/\/www.lem.uni.edu.pe\/?page_id=2938","title":{"rendered":"Expedientes Emitidos"},"content":{"rendered":"    <div id=\"expedientes-plugin-container\" style=\"width: 100%; max-width: 100%; text-align: center;\"> <!-- Contenedor que ocupa todo el ancho -->\r\n        <div class=\"columns form-container\" data-index=\"1\" style=\"width: 100%; display: flex; flex-direction: column; align-items: center;\">\r\n            <div class=\"column is-full\" style=\"width: 100%; padding: 0;\">\r\n                <div class=\"field is-grouped is-centered\" style=\"width: 100%; display: flex; justify-content: center; align-items: center;\">\r\n                    <div class=\"control\" style=\"display: flex; align-items: center;\">\r\n                        <button class=\"button is-black\" id=\"searchButton\" style=\"width: 100px; height: 40px;\"><b>BUSCAR<\/b><\/button>\r\n                    <\/div>\r\n                    <div class=\"control\" style=\"display: flex; align-items: center; margin-left: 10px;\">\r\n                        <input class=\"input is-link\" type=\"text\" id=\"searchInput\" placeholder=\"Expediente\" style=\"width: 90px; height: 34px; text-align: center;\"\/>\r\n                    <\/div>\r\n                <\/div>\r\n                <div class=\"control\" style=\"margin-top: 10px; width: 100%; text-align: center;\">\r\n                    <b>Expedientes emitidos listos para ser entregados a clientes que pagaron la totalidad del servicio.<\/b>\r\n                <\/div>\r\n            <\/div>\r\n        <\/div>\r\n\r\n        <!-- Aqu\u00ed la tabla debe aparecer debajo del texto -->\r\n        <div id=\"google-sheets-data\" style=\"margin-top: 20px;\">Cargando datos...<\/div>\r\n    <\/div>\r\n\r\n    <script>\r\n      let allData = []; \/\/ Para almacenar todos los datos\r\n\r\n      function fetchGoogleSheetsData() {\r\n        fetch('https:\/\/script.google.com\/macros\/s\/AKfycbzII6QjZSf1WkHaBfVB4ybEGCzL0S57-U6Coj0X8X8VaBoKYV2XbWzhoXAdc_8oQvEz2w\/exec')\r\n          .then(response => response.json())\r\n          .then(data => {\r\n            allData = data; \/\/ Guardar todos los datos\r\n            renderTable(allData);\r\n          })\r\n          .catch(error => console.error('Error al obtener datos de Google Sheets:', error));\r\n      }\r\n\r\n      function renderTable(data) {\r\n        let htmlContent = '<table>';\r\n        htmlContent += '<thead><tr>';\r\n        data[0].forEach(cell => {\r\n          htmlContent += `<th>${cell}<\/th>`;\r\n        });\r\n        htmlContent += '<\/tr><\/thead><tbody>';\r\n\r\n        const maxRows = 200;\r\n        const rowsToDisplay = data.slice(1, maxRows + 1);\r\n\r\n        rowsToDisplay.forEach(row => {\r\n          htmlContent += '<tr>';\r\n          row.forEach((cell, index) => {\r\n            if (index === 2 || index === 3) { \/\/ Formatear la fecha en la tercera y cuarta columna\r\n              let date = new Date(cell);\r\n              if (!isNaN(date)) {\r\n                let formattedDate = ('0' + date.getDate()).slice(-2) + '\/' + \r\n                                    ('0' + (date.getMonth() + 1)).slice(-2) + '\/' + \r\n                                    date.getFullYear();\r\n                htmlContent += `<td>${formattedDate}<\/td>`;\r\n              } else {\r\n                htmlContent += `<td>${cell}<\/td>`;\r\n              }\r\n            } else if (index === 5) { \/\/ Formatear n\u00famero a 2 decimales\r\n              let num = parseFloat(cell);\r\n              if (!isNaN(num)) {\r\n                htmlContent += `<td>${num.toFixed(2)}<\/td>`;\r\n              } else {\r\n                htmlContent += `<td>${cell}<\/td>`;\r\n              }\r\n            } else {\r\n              htmlContent += `<td>${cell}<\/td>`;\r\n            }\r\n          });\r\n          htmlContent += '<\/tr>';\r\n        });\r\n\r\n        htmlContent += '<\/tbody><\/table>';\r\n        document.getElementById('google-sheets-data').innerHTML = htmlContent;\r\n      }\r\n\r\n      function searchRow() {\r\n        const searchValue = document.getElementById('searchInput').value.toLowerCase();\r\n        const filteredData = allData.filter(row => row[0].toString().toLowerCase() === searchValue);\r\n        \r\n        \/\/ Incluir cabeceras en los resultados\r\n        const resultData = filteredData.length ? [allData[0], ...filteredData] : [['No se encontr\u00f3 el expediente que ingres\u00f3, puede que a\u00fan no culmin\u00f3 sus ensayos o que escribi\u00f3 mal el n\u00famero de expediente']];\r\n        \r\n        renderTable(resultData);\r\n      }\r\n\r\n      document.getElementById('searchButton').addEventListener('click', searchRow);\r\n\r\n      \/\/ Escuchar el evento de tecla \"Enter\"\r\n      document.getElementById('searchInput').addEventListener('keypress', function(event) {\r\n        if (event.key === 'Enter') {\r\n          searchRow();\r\n        }\r\n      });\r\n\r\n      \/\/ Escuchar el evento de tecla \"Escape\"\r\n      document.addEventListener('keydown', function(event) {\r\n        if (event.key === 'Escape') {\r\n          document.getElementById('searchInput').value = ''; \/\/ Limpiar el campo de b\u00fasqueda\r\n          renderTable(allData); \/\/ Mostrar todos los datos\r\n        }\r\n      });\r\n\r\n      window.onload = fetchGoogleSheetsData;\r\n      setInterval(fetchGoogleSheetsData, 30000);\r\n    <\/script>\r\n    \n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"template-full.php","meta":{"_joinchat":[],"footnotes":""},"class_list":["post-2938","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.lem.uni.edu.pe\/index.php?rest_route=\/wp\/v2\/pages\/2938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lem.uni.edu.pe\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.lem.uni.edu.pe\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.lem.uni.edu.pe\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lem.uni.edu.pe\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2938"}],"version-history":[{"count":5,"href":"https:\/\/www.lem.uni.edu.pe\/index.php?rest_route=\/wp\/v2\/pages\/2938\/revisions"}],"predecessor-version":[{"id":3501,"href":"https:\/\/www.lem.uni.edu.pe\/index.php?rest_route=\/wp\/v2\/pages\/2938\/revisions\/3501"}],"wp:attachment":[{"href":"https:\/\/www.lem.uni.edu.pe\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}