diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c613117 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Directorio de dependecia +node_modules/ \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..e03da2f --- /dev/null +++ b/index.js @@ -0,0 +1,102 @@ +const express = require('express'); +const { Client } = require('pg'); +const path = require('path'); + +const app = express(); +const port = process.env.PORT || 3000; + +app.use(express.static(path.join(__dirname, 'public'))); + +// Ruta para servir el archivo HTML +app.get('/', (req, res) => { + res.sendFile(path.join(__dirname, 'public', 'index.html')); +}); + +// Configuración de la conexión a la base de datos +const client = new Client({ + user: "xupuufxtqinskd", + host: "ec2-52-22-136-117.compute-1.amazonaws.com", + password: "c8f36e06dda45351374f252d25579eee3de9ef362c3429ed29398e5004bcca48", + database: "d4gh2v3i5p549d", + port: 5432, + ssl: { + rejectUnauthorized: false + }, +}); + +// Conectar a la base de datos +client.connect(); + +// Ruta para obtener los datos +app.get('/consulta', async (req, res) => { + const id_serie = req.query.id_serie || 0; + try { + const query = "SELECT base_radicacion.id, base_radicacion.numero_radicado, base_radicacion.alistamiento, base_radicacion.alistado_por FROM base_radicacion LEFT JOIN domicilios ON base_radicacion.numero_radicado = domicilios.autorizacion WHERE base_radicacion.acta_entrega IS NULL AND domicilios.autorizacion IS NULL AND base_radicacion.id > $1 ORDER BY base_radicacion.datetime ASC LIMIT 1"; + const result = await client.query(query, [id_serie]); + const datos = result.rows[0]; // Suponiendo que solo quieres el primer resultado de la consulta + + res.json(datos); + } catch (error) { + console.error('Error:', error); + res.status(500).json({ error: 'Error al obtener los datos' }); + } +}); + +app.get('/consulta_atras', async (req, res) => { + const id_serie = req.query.id_serie || 0; + try { + const query = "SELECT base_radicacion.id, base_radicacion.numero_radicado FROM base_radicacion LEFT JOIN domicilios ON base_radicacion.numero_radicado = domicilios.autorizacion WHERE base_radicacion.acta_entrega IS NULL AND domicilios.autorizacion IS NULL AND base_radicacion.id < $1 ORDER BY base_radicacion.datetime DESC LIMIT 1"; + const result = await client.query(query, [id_serie]); + const datos = result.rows[0]; // Suponiendo que solo quieres el primer resultado de la consulta + + res.json(datos); + } catch (error) { + console.error('Error:', error); + res.status(500).json({ error: 'Error al obtener los datos' }); + } +}); + +app.get('/validacion', async (req, res) => { + const id_cedula = req.query.id_cedula || 0; + try { + const query = "SELECT nombre, id_cedu FROM usuarios WHERE id_cedu = $1"; + const resul = await client.query(query, [id_cedula]); + + if (resul.rows.length > 0) { + const dato = resul.rows[0]; + + res.json(dato); + } else { + res.json({ error: 'No se encontraron datos' }); + } + } catch (error) { + console.error('Error:', error); + res.status(500).json({ error: 'Error al obtener los datos' }); + } +}); + +app.get('/update', async (req, res) => { + const nombre = req.query.nombre || ''; + const auto = req.query.auto || 0; + + try { + + const query = "UPDATE base_radicacion SET alistamiento = NOW(), alistado_por = $1 WHERE numero_radicado = $2"; + + const result = await client.query(query, [nombre, auto]); + + const datos = result.rows[0]; + + res.json(datos); + + } catch (error) { + console.error('Error:', error); + res.status(500).json({ error: 'Error al obtener los datos' }); + } +}) + +// Iniciar el servidor +app.listen(port, () => { + console.log(`Servidor escuchando en el puerto ${port}`); +}); + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e9e7a5e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,731 @@ +{ + "name": "ver_autorizacion", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ver_autorizacion", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "express": "^4.18.2", + "pg": "^8.10.0" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "node_modules/body-parser": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/buffer-writer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", + "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dependencies": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.1", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.5.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "node_modules/get-intrinsic": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", + "integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==", + "dependencies": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-inspect": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/packet-reader": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", + "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/pg": { + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.10.0.tgz", + "integrity": "sha512-ke7o7qSTMb47iwzOSaZMfeR7xToFdkE71ifIipOAAaLIM0DYzfOAXlgFFmYUIE2BcJtvnVlGCID84ZzCegE8CQ==", + "dependencies": { + "buffer-writer": "2.0.0", + "packet-reader": "1.0.0", + "pg-connection-string": "^2.5.0", + "pg-pool": "^3.6.0", + "pg-protocol": "^1.6.0", + "pg-types": "^2.1.0", + "pgpass": "1.x" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-connection-string": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz", + "integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.6.0.tgz", + "integrity": "sha512-clFRf2ksqd+F497kWFyM21tMjeikn60oGDmqMT8UBrynEwVEX/5R5xd2sdvdo1cZCFlguORNpVuqxIj+aK4cfQ==", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.6.0.tgz", + "integrity": "sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q==" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/send": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..501ad58 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "ver_autorizacion", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node index.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "express": "^4.18.2", + "pg": "^8.10.0" + } +} diff --git a/public/Css/styles.css b/public/Css/styles.css new file mode 100644 index 0000000..49f6dbe --- /dev/null +++ b/public/Css/styles.css @@ -0,0 +1,335 @@ +h1, h2, h3, h4, h5, h6, p, a, span, strong, div, form, select, option, textarea, button { + font-family: 'Montserrat', sans-serif; } + + header, main, footer, aside, nav, figure, figcaption, article { display: block;} + + h1, h2, h3, h4, h5, h6, p {margin: 0; } + + body { margin: 0 !important;} + + html {scroll-behavior: smooth;} + +.section { + display: block; + opacity: 1; +} + +.conten_registro{ + display: flex; + position: absolute; + width: 100%; + height: 100%; + display: none; + z-index: 99; +} +.registro{ + position: relative; + width: 30%; + height: 20%; + margin: auto; + border: solid 1px; + background: #ffff; +} +.text{ + width: 100%; + height: 30px; + text-align: center; + margin: 9px 0px 0px 0; + display: block; +} + +.text_error{ + display: none; + width: 100%; + height: 39px; + text-align: center; + margin: 5px 0px 0px 0; +} + +.conte_input{ + position: relative; + width: 100%; + height: 30px; + display: flex; +} +.inpt_text{ + position: relative; + width: 50%; + margin: auto; +} +.conte_btn{ + position: relative; + width: 100%; + height: 30px; + display: flex; + margin: 9px 0px 0px 0; +} +.btn_regis{ + margin: auto; + position: relative; + +} + +.bloq_a {position: relative; + width: 100%; + height: 7vh;} +.conten_img{position: relative; + width: 16%; + height: 100%;} +.img_logo{position: relative; + width: 100%; + height: 100%;} + +.bloq_b{position: relative;} + +.conten_info{ +display: flex; +position: absolute; +margin: 7px; +} +.conten_nomb{ + position: relative; + width: 35%; + height: 3vh; +} +.nombre{ +border: solid 0px; +position: relative; + width: 100%; + height: 100%; +} +.conten_fech{ + position: relative; + width: 50%; + height: 3vh; +} +.fecha{ + border: solid 0px; + position: relative; + width: 100%; + height: 100%; +} + +.conten_auto{position: relative; + width: 28%; + height: 30px; + display: flex; + left: 72%;} + +.serial{ + position: relative; + width: 30%; + display: flex; + opacity: 0; +} + +.serial_tex{ + position: relative; + width: 50%; +} + +.serial_num{ + position: relative; + width: 50%; + height: 50%; + text-align: center; +} + +.conten_inpu{position: relative; + width: 50%;} +.auto{position: relative;} + +.conten_buscar{ position: relative; + width: 17%} +.buscar{position: relative;} + + +.conten_butt{position: relative; + width: 100%; + height: 25px; + display: flex;} + +.subconten_butt{position: relative; + margin: 0 auto; + width: 20%; + height: 100%;} +.button{position: relative; + width: 32%; +} + +.bloq_c{position: relative; + width: 100%; + display: flex; + margin: 0 0px 0 0;} + +.doc_auto{position: relative; + width: 48%; + height: 80vh; + margin: 0px 12px;} + +.doc_formu{position: relative; + width: 48%; + height: 80vh; + margin: 0px 5px;} + +.conten_print{position: relative; + width: 100%; + height: 25px; + display: flex;} + +.print{position: relative; + margin: 0 auto; +} + +.fortmat_auto{position: relative; + width: 100%; + height: 95%; + border: solid 1px; + overflow: hidden; +} + +.fortmat_formu{position: relative; + width: 100%; + height: 95%; + border: solid 1px; + overflow: hidden; +} + + +.pag1{width: 200%; + height: 200%; + transform: scale(0.5); + transform-origin: top left} + +.pag2{width: 100%; + height: 100%;} + + +@media print { + + .conten_registro{ + display: none; + } + .registro{display: none;} + + .section { + display: block; + opacity: 1; + } + + .bloq_a {position: relative; + width: 100%; + height: 100%; + display: none;} + .conten_img{position: relative; + width: 20%; + height: 65%;} + .img_logo{position: relative; + width: 100%; + height: 100%;} + + .bloq_b{position: relative; + display: none; + } + + .conten_auto{position: relative; + width: 28%; + height: 30px; + display: flex; + left: 72%;} + + .serial{ + position: relative; + width: 30%; + display: flex; + } + + .serial_tex{ + position: relative; + width: 50%; + } + + .serial_num{ + position: relative; + width: 50%; + height: 50%; + text-align: center; + } + + .conten_inpu{position: relative; + width: 50%;} + .auto{position: relative;} + + .conten_buscar{ position: relative; + width: 17%} + .buscar{position: relative;} + + + .conten_butt{position: relative; + width: 100%; + height: 25px; + display: flex;} + + .subconten_butt{position: relative; + margin: 0 auto; + width: 20%; + height: 100%;} + .button{position: relative; + width: 32%; + } + + .bloq_c{position: relative; + width: 100%; + display: flex; + margin: 0 0px 0 0;} + + .doc_auto{position: relative; + width: 100%; + height: 90vh; + margin: 0px 0px;} + + .doc_formu{position: relative; + width: 48%; + height: 80vh; + margin: 0px 0px; + display: none; +} + + .conten_print{position: relative; + width: 100%; + height: 25px; + display: flex; + display: none; + } + + .print{position: relative; + margin: 0 auto; + } + + .fortmat_auto{position: relative; + width: 100%; + height: 135%; + border: solid 0px; + overflow: hidden; + } + + .fortmat_formu{position: relative; + width: 100%; + height: 95%; + border: solid 1px; + overflow: hidden; + } + + + .pag1{width: 150%; + height: 154%; + transform: scale(0.7); + transform-origin: top left; + right: -10px; + } + + .pag2{width: 100%; + height: 100%;} + +} + diff --git a/public/consulta_DB.js b/public/consulta_DB.js new file mode 100644 index 0000000..07c7dec --- /dev/null +++ b/public/consulta_DB.js @@ -0,0 +1,287 @@ +let nombre_responsable = document.getElementById('nombre_responsable').value; +let fecha_responsable = document.getElementById('fecha_responsable').value; + +function buscar_auto() { + fetch('/consulta') + .then(response => response.json()) + .then(data => { + const id = data.id; + const radicado = data.numero_radicado; + const nombre = data.alistado_por; + const fecha = data.alistamiento; + + console.log(nombre); + console.log(fecha); + + document.getElementById('serial').value = id; + document.getElementById('num_auto').value = radicado; + document.getElementById('nombre_responsable').value = nombre; + document.getElementById('fecha_responsable').value = fecha; + + + const a = radicado.slice(-8); + const b = radicado.slice(0, -8); + const url = "https://genesis.cajacopieps.com/views/autorizaciones/formatoautorizacionPrint_ips.php?numero=" + a + "&ubicacion=" + b; + + const iframe_auto = document.getElementById("myIframe"); + const iframe_formu = document.getElementById("myIframe2"); + + iframe_auto.src = url; + + const myHeaders = new Headers(); + myHeaders.append("Content-Type", "text/plain"); + myHeaders.append("Cookie", "PHPSESSID=tupmb6mo9amo6sathg5q47536i"); + + const base_raw = "{\r\n\"function\": \"p_mostrar_autorizacion\",\r\n\"serial\": \"0000000000000\",\r\n\"nit\": \"900073223\"\r\n}"; + + const objeto = JSON.parse(base_raw); + + objeto.serial = radicado; + + const raw = JSON.stringify(objeto); + + const requestOptions = { + method: 'POST', + headers: myHeaders, + body: raw, + redirect: 'follow' + }; + + fetch("https://genesis.cajacopieps.com/api/api_qr.php", requestOptions) + .then(response => response.json()) + .then(data => { + const nombreArchivo = data["ARCHIVO"]; + + // Aquí puedes utilizar la variable 'nombreArchivo' como desees + iframe_formu.src = nombreArchivo; + + }) + .catch(error => console.log('error', error)); + + // Aquí puedes manipular los datos recibidos y hacer lo que desees con ellos + + }) + .catch(error => { + console.error('Error:', error); + }); +}; + +const imprimirBtn = document.getElementById('imprimir_auto').addEventListener('click', impri); + +function impri(){ + + const auto = document.getElementById('num_auto').value; + + if (auto > 10000000000 && auto < 1000000000000) { + + const modal = document.getElementById('conten_registro'); + const sect = document.getElementById('section'); + + modal.style.display = 'flex'; + sect.style.opacity = '0.4'; + + document.getElementById('btn_aceptar').addEventListener('click', aceptar); + + let impreso = false; + + function aceptar(){ + + const id_cedula = document.getElementById('id_cedu').value; + const auto = document.getElementById('num_auto').value; + + fetch(`/validacion?id_cedula=${id_cedula}`) + .then(response => response.json()) + .then(data => { + + const modal = document.getElementById('conten_registro'); + const sect = document.getElementById('section'); + const text_error = document.getElementById('text_error'); + const text = document.getElementById('text'); + + const id_cedu = data.id_cedu; + const nombre = data.nombre; + + if (id_cedula == id_cedu) { + + modal.style.display = 'none'; + sect.style.opacity = '1'; + + fetch(`/update?nombre=${nombre}&auto=${auto}`) + .then(response => response.json()); + + if (!impreso) { + window.print(); + impreso = true; + } + + }else{ + + text.style.display = 'none'; + text_error.style.display = 'block'; + id_cedu.value = ""; + + } + + }); + + }; + + document.getElementById('btn_cancelar').addEventListener('click', cancelar); + + function cancelar(){ + + const modal = document.getElementById('conten_registro'); + const sect = document.getElementById('section'); + const id_cedu = document.getElementById('id_cedu'); + + + modal.style.display = 'none'; + sect.style.opacity = '1'; + id_cedu.value = ""; + + }; + + + } else { + + console.log('numero de autorizacion no valido'); + + } + + +}; + + +function buscar_siguiente() { + + const id_serie = document.getElementById('serial').value; + document.getElementById('nombre_responsable').value = ""; + document.getElementById('fecha_responsable').value = ""; + + // Realizar la solicitud POST al servidor + fetch(`/consulta?id_serie=${id_serie}`) + .then(response => response.json()) + .then(data => { + // Hacer algo con los datos recibidos + const id = data.id; + const radicado = data.numero_radicado; + + document.getElementById('serial').value = id; + document.getElementById('num_auto').value = radicado; + + const a = radicado.slice(-8); + const b = radicado.slice(0, -8); + const url = "https://genesis.cajacopieps.com/views/autorizaciones/formatoautorizacionPrint_ips.php?numero=" + a + "&ubicacion=" + b; + + const iframe_auto = document.getElementById("myIframe"); + const iframe_formu = document.getElementById("myIframe2"); + + iframe_auto.src = url; + +const myHeaders = new Headers(); +myHeaders.append("Content-Type", "text/plain"); +myHeaders.append("Cookie", "PHPSESSID=tupmb6mo9amo6sathg5q47536i"); + +const base_raw = "{\r\n\"function\": \"p_mostrar_autorizacion\",\r\n\"serial\": \"0000000000000\",\r\n\"nit\": \"900073223\"\r\n}"; + +const objeto = JSON.parse(base_raw); + +objeto.serial = radicado; + +const raw = JSON.stringify(objeto); + + +const requestOptions = { + method: 'POST', + headers: myHeaders, + body: raw, + redirect: 'follow' +}; + +fetch("https://genesis.cajacopieps.com/api/api_qr.php", requestOptions) + .then(response => response.json()) // Parsear la respuesta como JSON + .then(data => { + const nombreArchivo = data["ARCHIVO"]; + + // Aquí puedes utilizar la variable 'nombreArchivo' como desees + iframe_formu.src = nombreArchivo; + + }) + .catch(error => console.log('error', error)); + + // Aquí puedes manipular los datos recibidos y hacer lo que desees con ellos + + }) + .catch(error => { + console.error('Error:', error); + // Manejar el error + }); + + +}; + +function buscar_atras() { + + const id_serie = document.getElementById('serial').value; + + // Realizar la solicitud POST al servidor + fetch(`/consulta_atras?id_serie=${id_serie}`) + .then(response => response.json()) + .then(data => { + // Hacer algo con los datos recibidos + const id = data.id; + const radicado = data.numero_radicado; + + document.getElementById('serial').value = id; + document.getElementById('num_auto').value = radicado; + + const a = radicado.slice(-8); + const b = radicado.slice(0, -8); + const url = "https://genesis.cajacopieps.com/views/autorizaciones/formatoautorizacionPrint_ips.php?numero=" + a + "&ubicacion=" + b; + + const iframe_auto = document.getElementById("myIframe"); + const iframe_formu = document.getElementById("myIframe2"); + + iframe_auto.src = url; + +const myHeaders = new Headers(); +myHeaders.append("Content-Type", "text/plain"); +myHeaders.append("Cookie", "PHPSESSID=tupmb6mo9amo6sathg5q47536i"); + +const base_raw = "{\r\n\"function\": \"p_mostrar_autorizacion\",\r\n\"serial\": \"0000000000000\",\r\n\"nit\": \"900073223\"\r\n}"; + +const objeto = JSON.parse(base_raw); + +objeto.serial = radicado; + +const raw = JSON.stringify(objeto); + + +const requestOptions = { + method: 'POST', + headers: myHeaders, + body: raw, + redirect: 'follow' +}; + +fetch("https://genesis.cajacopieps.com/api/api_qr.php", requestOptions) + .then(response => response.json()) // Parsear la respuesta como JSON + .then(data => { + const nombreArchivo = data["ARCHIVO"]; + + // Aquí puedes utilizar la variable 'nombreArchivo' como desees + iframe_formu.src = nombreArchivo; + + }) + .catch(error => console.log('error', error)); + + // Aquí puedes manipular los datos recibidos y hacer lo que desees con ellos + + }) + .catch(error => { + console.error('Error:', error); + // Manejar el error + }); + + +}; diff --git a/public/consulta_api.js b/public/consulta_api.js new file mode 100644 index 0000000..fdab0a8 --- /dev/null +++ b/public/consulta_api.js @@ -0,0 +1,55 @@ +function generarURL() { + + const auto = document.getElementById('num_auto').value; + + if (auto > 100000000 && auto < 1000000000000) { + + const numero = document.getElementById("num_auto").value; + const a = numero.slice(-8); + const b = numero.slice(0, -8); + const url = "https://genesis.cajacopieps.com/views/autorizaciones/formatoautorizacionPrint_ips.php?numero=" + a + "&ubicacion=" + b; + + const iframe_auto = document.getElementById("myIframe"); + const iframe_formu = document.getElementById("myIframe2"); + + iframe_auto.src = url; + console.log(a); + console.log(b); + +const myHeaders = new Headers(); +myHeaders.append("Content-Type", "text/plain"); +myHeaders.append("Cookie", "PHPSESSID=tupmb6mo9amo6sathg5q47536i"); + +const base_raw = "{\r\n\"function\": \"p_mostrar_autorizacion\",\r\n\"serial\": \"0000000000000\",\r\n\"nit\": \"900073223\"\r\n}"; + +const objeto = JSON.parse(base_raw); + +objeto.serial = numero; + +const raw = JSON.stringify(objeto); + + +const requestOptions = { + method: 'POST', + headers: myHeaders, + body: raw, + redirect: 'follow' +}; + +fetch("https://genesis.cajacopieps.com/api/api_qr.php", requestOptions) + .then(response => response.json()) // Parsear la respuesta como JSON + .then(data => { + const nombreArchivo = data["ARCHIVO"]; + console.log(nombreArchivo); + // Aquí puedes utilizar la variable 'nombreArchivo' como desees + iframe_formu.src = nombreArchivo; + }) + .catch(error => console.log('error', error)); + + }else { + + console.log('no se puede'); + + } + +}; \ No newline at end of file diff --git a/public/img/ICONO-AZUL.png b/public/img/ICONO-AZUL.png new file mode 100644 index 0000000..54b6d54 Binary files /dev/null and b/public/img/ICONO-AZUL.png differ diff --git a/public/img/LOGO ORIGINAL.png b/public/img/LOGO ORIGINAL.png new file mode 100644 index 0000000..8e8db9b Binary files /dev/null and b/public/img/LOGO ORIGINAL.png differ diff --git a/public/img/logifarma-cajacopi.png b/public/img/logifarma-cajacopi.png new file mode 100644 index 0000000..e0849c3 Binary files /dev/null and b/public/img/logifarma-cajacopi.png differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..3efba74 --- /dev/null +++ b/public/index.html @@ -0,0 +1,122 @@ + + + +
+ + + +Ingrese codigo de usuario
+ Este usuario no existe.
Inténtelo de nuevo!
Serial
+ +