diff --git a/app.js b/app.js index 98b9569..8c0dc66 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,7 @@ var express = require('express'); var app = express(); var cors = require('cors'); +var clave = require('./routes/check_clave.js'); app.get('/', function(req, res) { res.send('Hello World!'); }); @@ -9,6 +10,8 @@ app.use(cors()); app.use(express.json()) // for parsing application/json app.use(express.urlencoded({ extended: true })) app.use(require('./routes/index.js')) + app.listen(process.env.PORT, function() { + //clave(); console.log('Example app listening on port ' + process.env.PORT + '!'); }); \ No newline at end of file diff --git a/conf/connection.js b/conf/connection.js index 4aa4042..6e3ae8f 100644 --- a/conf/connection.js +++ b/conf/connection.js @@ -1,5 +1,19 @@ var mysql = require('mysql'); + +require('dotenv').config() + + +// console.log({ + + +// host: process.env.HOSTDB, +// user: process.env.USERDB, +// password: process.env.PASSDB, +// database: process.env.DB +// }) var connection = mysql.createConnection({ + + host: process.env.HOSTDB, user: process.env.USERDB, password: process.env.PASSDB, diff --git a/files/carta_aceptacion-2.docx b/files/carta_aceptacion-2.docx new file mode 100644 index 0000000..8ee6603 Binary files /dev/null and b/files/carta_aceptacion-2.docx differ diff --git a/files/carta_aceptacion-5.docx b/files/carta_aceptacion-5.docx new file mode 100644 index 0000000..8ee6603 Binary files /dev/null and b/files/carta_aceptacion-5.docx differ diff --git a/files/carta_aceptacion-6.docx b/files/carta_aceptacion-6.docx new file mode 100644 index 0000000..8ee6603 Binary files /dev/null and b/files/carta_aceptacion-6.docx differ diff --git a/files/comprobante_pago-1.docx b/files/comprobante_pago-1.docx new file mode 100644 index 0000000..ac518cd Binary files /dev/null and b/files/comprobante_pago-1.docx differ diff --git a/files/comprobante_pago-2.docx b/files/comprobante_pago-2.docx new file mode 100644 index 0000000..8ee6603 Binary files /dev/null and b/files/comprobante_pago-2.docx differ diff --git a/files/comprobante_pago-2.pdf b/files/comprobante_pago-2.pdf new file mode 100644 index 0000000..8ee6603 Binary files /dev/null and b/files/comprobante_pago-2.pdf differ diff --git a/files/comprobante_pago-5.docx b/files/comprobante_pago-5.docx new file mode 100644 index 0000000..8ee6603 Binary files /dev/null and b/files/comprobante_pago-5.docx differ diff --git a/files/comprobante_pago-6.docx b/files/comprobante_pago-6.docx new file mode 100644 index 0000000..aa15a9d Binary files /dev/null and b/files/comprobante_pago-6.docx differ diff --git a/package-lock.json b/package-lock.json index 7a04199..7837468 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,17 +50,6 @@ "resolved": "https://registry.npmjs.org/addressparser/-/addressparser-1.0.1.tgz", "integrity": "sha1-R6++GiqSYhkdtoOOT9HTm0CCF0Y=" }, - "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", - "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" - } - }, "amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", @@ -96,18 +85,10 @@ "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=" }, - "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", - "requires": { - "safer-buffer": "~2.1.0" - } - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + "array-uniq": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz", + "integrity": "sha1-X8w3OSB3VyPP1k1lxkvvU7+eum0=" }, "ast-transform": { "version": "0.0.0", @@ -161,21 +142,6 @@ "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.7.8.tgz", "integrity": "sha1-kC0uDWDQcb3NRtwRXhgJ7RHBOKk=" }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" - }, - "aws4": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz", - "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==" - }, "babel-runtime": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", @@ -204,14 +170,6 @@ "node-pre-gyp": "0.14.0" } }, - "bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "requires": { - "tweetnacl": "^0.14.3" - } - }, "body-parser": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", @@ -229,14 +187,6 @@ "type-is": "~1.6.17" } }, - "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", - "requires": { - "hoek": "4.x.x" - } - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -343,11 +293,6 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" - }, "chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", @@ -358,23 +303,15 @@ "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=" }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" - }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, - "combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "requires": { - "delayed-stream": "~1.0.0" - } + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, "concat-map": { "version": "0.0.1", @@ -447,24 +384,6 @@ "vary": "^1" } }, - "cryptiles": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.4.tgz", - "integrity": "sha512-8I1sgZHfVwcSOY6mSGpVU3lw/GSIZvusg8dD2+OGehCJpOhQRLNcH0qb9upQnOH4XhgxxFJSg6E2kx95deb1Tw==", - "requires": { - "boom": "5.x.x" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", - "requires": { - "hoek": "4.x.x" - } - } - } - }, "crypto-js": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.3.0.tgz", @@ -479,14 +398,6 @@ "type": "^1.0.1" } }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "requires": { - "assert-plus": "^1.0.0" - } - }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -526,11 +437,6 @@ "object-keys": "^1.0.12" } }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -585,15 +491,6 @@ "readable-stream": "^2.0.2" } }, - "ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "requires": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } - }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -815,16 +712,6 @@ } } }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" - }, "falafel": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/falafel/-/falafel-2.1.0.tgz", @@ -843,16 +730,6 @@ } } }, - "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" - }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", @@ -895,21 +772,6 @@ "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=" }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" - }, - "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - }, "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", @@ -958,14 +820,6 @@ "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==" }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "requires": { - "assert-plus": "^1.0.0" - } - }, "glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", @@ -979,20 +833,6 @@ "path-is-absolute": "^1.0.0" } }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" - }, - "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", - "requires": { - "ajv": "^5.1.0", - "har-schema": "^2.0.0" - } - }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -1011,22 +851,6 @@ "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, - "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", - "requires": { - "boom": "4.x.x", - "cryptiles": "3.x.x", - "hoek": "4.x.x", - "sntp": "2.x.x" - } - }, - "hoek": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==" - }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -1039,16 +863,6 @@ "toidentifier": "1.0.0" } }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -1128,52 +942,26 @@ "has-symbols": "^1.0.1" } }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" - }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "json2csv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/json2csv/-/json2csv-4.5.4.tgz", + "integrity": "sha512-YxBhY4Lmn8IvVZ36nqg5omxneLy9JlorkqW1j/EDCeqvmi+CQ4uM+wsvXlcIqvGDewIPXMC/O/oF8DX9EH5aoA==", "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" + "commander": "^2.15.1", + "jsonparse": "^1.3.1", + "lodash.get": "^4.4.2" } }, + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=" + }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -1268,6 +1056,11 @@ } } }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" + }, "magic-string": { "version": "0.22.5", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz", @@ -1450,14 +1243,6 @@ "tar": "^4.4.2" } }, - "node-wget": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/node-wget/-/node-wget-0.4.3.tgz", - "integrity": "sha512-sltt/nc4NJeI4CuncyBFZZ7W4Wz3Q1oM8h27mYEbj5OihXMsuqJpplPl0WUZTSpXy8AyGczT08jIBsXHxdCtgg==", - "requires": { - "request": "~2.85.0" - } - }, "nodemailer-fetch": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/nodemailer-fetch/-/nodemailer-fetch-1.6.0.tgz", @@ -1519,11 +1304,6 @@ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, - "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" - }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -1639,11 +1419,6 @@ "png-js": "^1.0.0" } }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" - }, "png-js": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/png-js/-/png-js-1.0.0.tgz", @@ -1668,11 +1443,6 @@ "ipaddr.js": "1.9.0" } }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" - }, "qr-image": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/qr-image/-/qr-image-3.2.0.tgz", @@ -1700,6 +1470,14 @@ } } }, + "randomstring": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/randomstring/-/randomstring-1.1.5.tgz", + "integrity": "sha1-bfBij3XL1ZMpMNn+OrTpVqGFGMM=", + "requires": { + "array-uniq": "1.0.2" + } + }, "range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -1762,42 +1540,6 @@ "es-abstract": "^1.17.0-next.1" } }, - "request": { - "version": "2.85.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz", - "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==", - "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.6.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.1", - "forever-agent": "~0.6.1", - "form-data": "~2.3.1", - "har-validator": "~5.0.3", - "hawk": "~6.0.2", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.17", - "oauth-sign": "~0.8.2", - "performance-now": "^2.1.0", - "qs": "~6.5.1", - "safe-buffer": "^5.1.1", - "stringstream": "~0.0.5", - "tough-cookie": "~2.3.3", - "tunnel-agent": "^0.6.0", - "uuid": "^3.1.0" - }, - "dependencies": { - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" - } - } - }, "resolve": { "version": "1.15.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", @@ -1922,36 +1664,12 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, - "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", - "requires": { - "hoek": "4.x.x" - } - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "optional": true }, - "sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - } - }, "static-eval": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.3.tgz", @@ -2046,11 +1764,6 @@ "safe-buffer": "~5.1.0" } }, - "stringstream": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz", - "integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==" - }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -2102,27 +1815,6 @@ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" }, - "tough-cookie": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", - "requires": { - "punycode": "^1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" - }, "type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", @@ -2194,26 +1886,11 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" - }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, "vlq": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz", diff --git a/package.json b/package.json index 9d2f27a..b9c1c5f 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,10 @@ "dotenv": "^8.2.0", "express": "^4.17.1", "express-fileupload": "^1.1.6", + "json2csv": "^4.5.4", "pdfkit": "^0.11.0", "qr-image": "^3.2.0", + "randomstring": "^1.1.5", "sendmail": "^1.6.1" } -} \ No newline at end of file +} diff --git a/routes/check_clave.js b/routes/check_clave.js new file mode 100644 index 0000000..9fe6e0b --- /dev/null +++ b/routes/check_clave.js @@ -0,0 +1,73 @@ +const connection = require('../conf/connection.js'); +const express = require('express') +var enviar_correo = require('./enviar_correo.js'); + + +let con = 0; +let time; + +function query(consulta) { + return new Promise(function(resolve, reject) { + connection.query(`${consulta}`, (error, results, files) => { + if (error) reject(error); + resolve(results); + }); + }) +} + + + +const iterar = () => { + con++; + var actual = new Date(); + var menor = new Date(); + //actual.setMinutes(datetime.getMinutes()); + console.log(actual); + + actual = actual.getFullYear() + '-' + + ('00' + (actual.getMonth() + 1)).slice(-2) + '-' + + ('00' + actual.getDate()).slice(-2) + ' ' + + ('00' + actual.getHours()).slice(-2) + ':' + + ('00' + actual.getMinutes()).slice(-2) + ':' + + ('00' + actual.getSeconds()).slice(-2); + console.log("despues ... "); + console.log(actual); + if (con == 10) { + console.log("acabo"); + clearInterval(time); + } + let cad = `select n.*, p.* from numero_referencia as n inner join persona as p where n.pagado=false and n.fecha_caducacion<='${actual}' and n.id_persona!=null and n.id_persona=p.id_persona;`; + let ans = query(cad); + ans.then(async p => { + for (let i = 0; i < p.lenght; i++) { + let actualizar = `update numero_referencia set id_persona=null where id_num_referencia=${p[i].id_num_referencia};`; + let msj = `Estima usuario su numero de refencia ${p[i].clave} ha caducado debido a que ha transcurrido 48 hrs sin subir su comprobante de pago. + Para poder acceder a todas las actividades registradas debera iniciar sesion en ASINEA para elegir una nueva forma de pago.`; + let correo = p[i].correo; + let encabezado = `Aviso de caducación de clave bancaria ASINEA`; + let r = enviar_correo(correo, encabezado, msj); + r.then(async() => { + let n_ans = await query(actualizar); + if (p[i].situacion_academica == 'Alumno') { + actualizar = `update alumno set metodo_pago_asignado=null where id_persona=${p[i].id_persona};`; + n_ans = await query(actualizar); + } + if (p[i].situacion_academica == 'Académico') { + actualizar = `update academico set metodo_pago_asignado=null where id_persona=${p[i].id_persona};`; + n_ans = await query(actualizar); + + } + actualizar = `insert into mensaje values(null, ${p[i].id_persona}, 'Estima usuario su numero de refencia ${p[i].clave} ha caducado debido a que ha transcurrido 48 hrs sin subir su comprobante de pago. + Para poder acceder a todas las actividades registradas debera elegir una nueva forma de pago.')`; + n_ans = await query(actualizar); + }) + } + }) + +} + +let check_clave = function(id_persona) { + time = setInterval(iterar, 30000); +} + +module.exports = check_clave; \ No newline at end of file diff --git a/routes/crear_ccv.js b/routes/crear_ccv.js new file mode 100644 index 0000000..76936c2 --- /dev/null +++ b/routes/crear_ccv.js @@ -0,0 +1,221 @@ +const connection = require('../conf/connection.js'); +const express = require('express'); + +const fs = require('fs'); +var app = express() +const { Parser } = require('json2csv'); + + + + +function query(consulta) { + return new Promise(function(resolve, reject) { + connection.query(`${consulta}`, (error, results, files) => { + if (error) reject(error); + resolve(results); + }); + }) +} + + + +app.get('/crear_ccv', async(req, res) => { + data = { alumno: [], academico: [] }; + try { + let cad = `select * from persona;`; + let r = query(cad); + r.then(async(p) => { + for (let i = 0; i < p.length; i++) { + if (p[i].situacion_academica == 'Alumno') { + let aux = {} + cad = `select e.*, asi.* from evento as e inner join asistencia as asi where asi.id_persona=${p[i].id_persona} and e.id_evento=asi.id_evento`; + + let n_ans = await query(cad); + console.log(p[i]); + console.log("nuevo ans ", n_ans); + + + + + aux.id_persona = p[i].id_persona; + aux.nombre = p[i].nombre; + aux.apellido_p = p[i].apellido_p; + aux.apellido_m = p[i].apellido_m; + aux.comunidad = p[i].comunidad; + aux.conversatorio_ponente = 'No'; + aux.conversatorio_asistente = 'No'; + aux.taller = 'No'; + aux.visita = 'No'; + aux.magistral = 'No'; + aux.comprobante_pago = false; + aux.carta_aceptacion = false; + if (fs.existsSync(`./files/carta_aceptacion-${p[i].id_persona}.docx`)) { + + aux.carta_aceptacion = true; + } + + + if (fs.existsSync(`./files/comprobante_pago-${p[i].id_persona}.docx`)) { + aux.comprobante_pago = true; + } + + + + aux.correo = p[i].correo; + let nueva_cadena = `select * from alumno where id_persona=${p[i].id_persona};` + let nueva_query = await query(nueva_cadena); + aux.tipo_pago = nueva_query[0].metodo_pago_asignado; + let ext = true; + if (aux.comunidad == 'UNAM') + ext = false; + + let tot = 0; + for (let j = 0; j < n_ans.length; j++) { + + console.log(aux.nombre, " ", aux.comunidad, " ", tot, " ", ext, " ", n_ans[j].tipo_de_participacion); + if (n_ans[j].tipo_evento == 'Conversatorio') { + if (n_ans[j].tipo_de_participacion == 'Video') { + if (ext == true) + tot += 700; + else + tot += 100; + aux.conversatorio_ponente = 'Video: ' + n_ans[j].nombre_evento; + + } else + if (n_ans[j].tipo_de_participacion == 'Ensayo') { + if (ext == true) + tot += 700; + else + tot += 100; + aux.conversatorio_ponente = 'Ensayo: ' + n_ans[j].nombre_evento; + } else { + aux.conversatorio_asistente = n_ans[j].nombre_evento; + if (ext == true) + tot += 200; + else + tot += 100; + } + + + } + if (n_ans[j].tipo_evento == 'Taller alumno') { + if (ext == true) + tot += 900; + else + tot += 200; + aux.taller = n_ans[j].nombre_evento; + + + } + if (n_ans[j].tipo_evento == 'Visitas guiadas') { + if (ext == true) + tot += 500; + else + tot += 500; + aux.visita = n_ans[j].nombre_evento; + + } + if (n_ans[j].tipo_evento == 'Dialogo magistral') { + aux.magistral = n_ans[j].nombre_evento; + } + aux.pago = tot; + + } + + data.alumno.push(aux); + console.log(" "); + console.log(" "); + } + if (p[i].situacion_academica == 'Académico') { + let aux = {} + cad = `select e.*, asi.* from evento as e inner join asistencia as asi where asi.id_persona=${p[i].id_persona} and e.id_evento=asi.id_evento`; + + let n_ans = await query(cad); + aux.id_persona = p[i].id_persona; + aux.nombre = p[i].nombre; + aux.apellido_p = p[i].apellido_p; + aux.apellido_m = p[i].apellido_m; + aux.comunidad = p[i].comunidad; + aux.conversatorio_ponente = 'No'; + aux.conversatorio_asistente = 'No'; + aux.taller = 'No'; + aux.visita = 'No'; + aux.magistral = 'No'; + aux.pago = n_ans[0].metodo_pago_asignado; + aux.correo = p[i].correo; + + let nueva_cadena = `select * from academico where id_persona=${p[i].id_persona};` + let nueva_query = await query(nueva_cadena); + aux.tipo_pago = nueva_query[0].metodo_pago_asignado; + + let tot = 0; + let ext = true; + if (aux.comunidad == 'UNAM') + ext = false; + + + for (let j = 0; j < n_ans.length; j++) { + if (n_ans[j].tipo_evento == 'Conversatorio') { + + if (n_ans[j].tipo_de_participacion == 'Ponente') { + if (ext == true) + tot += 1000; + else + tot += 500; + aux.conversatorio_ponente = n_ans[j].nombre_event; + + } else { + aux.conversatorio_asistente = n_ans[j].nombre_evento; + if (ext == true) + tot += 1300; + else + tot += 650; + } + + + } + if (n_ans[j].tipo_evento == 'Taller profesor') { + if (ext == true) + tot += 1500; + else + tot += 750; + aux.taller = n_ans[j].nombre_evento; + + + } + if (n_ans[j].tipo_evento == 'Visitas guiadas') { + if (ext == true) + tot += 500; + else + tot += 500; + aux.visita = n_ans[j].nombre_evento; + + } + if (n_ans[j].tipo_evento == 'Dialogo magistral') { + aux.magistral = n_ans[j].nombre_evento; + } + aux.pago = tot; + + } + + data.academico.push(aux); + } + } + + const parser = new Parser(data); + const csv = parser.parse(myData); + console.log(csv); + // console.log(p); + // res.status(200).json({ error: false, datos: data }); + + + + }) + + } catch (err) { + return res.status(400).json({ error: true, msj: "Error al traer los datos" }); + } + +}); + +module.exports = app; \ No newline at end of file diff --git a/routes/datos_personales.js b/routes/datos_personales.js index 6f8140b..0323cc7 100644 --- a/routes/datos_personales.js +++ b/routes/datos_personales.js @@ -1,7 +1,9 @@ const connection = require('../conf/connection.js'); const express = require('express'); const bcrypt = require('bcrypt'); +const clave = require('./elegir_clave.js'); +const email = require('./enviar_correo.js'); var app = express() @@ -25,7 +27,7 @@ function depurado(cadena) { app.post('/datos_personales', async(req, res) => { let body = req.body; console.log(body); - + let mandar = ''; try { let n_correo = depurado(body.correo); let cad = `select * from persona where correo='${n_correo}';`; @@ -94,10 +96,21 @@ app.post('/datos_personales', async(req, res) => { let n_year = depurado(body.año.toString()); let n_participacion = depurado(body.participacion); + + // if (body.tipo_pago == 'ficha') { + // let n_respuesta = clave(id_persona, n_correo); + // n_respuesta.then(p => { + // if (p[0].error == true) { + // return res.status(400).json({ err: true, msj: p[0].msj, type: err }); + // } else + // mandar = p[0].msj; + // }) + // } + console.log("tipo pde pago: ", body.tipo_pago); if (n_cuenta != null) - cad = `insert into alumno values( ${id_persona}, '${n_cuenta}', '${n_year}' ) ;`; + cad = `insert into alumno values( ${id_persona}, '${n_cuenta}', '${n_year}', '${body.tipo_pago}' ) ;`; else - cad = `insert into alumno values( ${id_persona}, null, '${n_year}' ) ;`; + cad = `insert into alumno values( ${id_persona}, null, '${n_year}', '${body.tipo_pago}' ) ;`; let n_ans = query(cad); @@ -112,7 +125,7 @@ app.post('/datos_personales', async(req, res) => { } if (body.taller_a != undefined) { let ta = body.taller_a; - cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}' );`; + cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, 'Asistente' );`; let n_q = await query(cad); cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`; n_q = await query(cad); @@ -120,7 +133,7 @@ app.post('/datos_personales', async(req, res) => { } if (body.taller_p != undefined) { let ta = body.taller_p; - cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}');`; + cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, 'Asistente');`; let n_q = await query(cad); cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`; n_q = await query(cad); @@ -129,7 +142,7 @@ app.post('/datos_personales', async(req, res) => { } if (body.visitas != undefined) { let ta = body.visitas; - cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}');`; + cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, 'Asistente');`; let n_q = await query(cad); cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`; n_q = await query(cad); @@ -137,17 +150,22 @@ app.post('/datos_personales', async(req, res) => { } if (body.magistral != undefined) { let ta = body.magistral; - cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, false, false , false , false, false, '${ta.participacion}' );`; + cad = `insert into asistencia values(null, ${id_persona}, ${ta.id_evento}, true, false , false , false, false, 'Asistente' );`; let n_q = await query(cad); cad = `update evento set cupo= cupo-1 where id_evento=${ta.id_evento};`; n_q = await query(cad); } + let msj = "Bienvenido a ASINEA 2020\n\nEn el transcurso de dos días hábiles sera enviado a tu correo las instrucciones de pago." + let encabezado = "Registro ASINEA 2020"; - - - return res.status(200).json({ err: false, msj: "Exito", id_persona: id_persona }); + await email(n_correo, encabezado, msj); + // send.then(() => { + return res.status(200).json({ error: false, msj: "Exito", id_persona: id_persona, clave: mandar }); + // }).catch(err => { + // return res.status(400).json({ error: false, msj: "no se puede enviar el correo" }); + // }) }).catch(async(err) => { @@ -155,13 +173,13 @@ app.post('/datos_personales', async(req, res) => { //se deberia borrar el registro anterio de persona; - return res.status(400).json({ err: true, msj: "Error al insirtar en la base en alumno", type: err }); + return res.status(400).json({ err: true, msj: "Error al insertar en la base en alumno", type: err }); }) } catch (err) { //se deberia borrar el registro anterio de persona; console.log(err); - return res.status(400).json({ err: true, msj: "Error al insirtar en la base en alumno", type: err }); + return res.status(400).json({ err: true, msj: "Error al insertar en la base en alumno", type: err }); } } else if (n_situacion == 'Académico') { @@ -169,7 +187,7 @@ app.post('/datos_personales', async(req, res) => { let n_grado = depurado(body.grado); let n_asignatura = depurado(body.asignatura); let n_participacion = depurado(body.participacion); - cad = `insert into academico values(${id_persona}, '${n_grado}', '${n_asignatura}' );`; + cad = `insert into academico values(${id_persona}, '${n_grado}', '${n_asignatura}', '${body.tipo_pago}' );`; let n_ans = query(cad); n_ans.then(async() => { @@ -216,8 +234,20 @@ app.post('/datos_personales', async(req, res) => { + let msj = "Bienvenido a ASINEA 2020\n\nEn el transcurso de dos días hábiles sera enviado a tu correo las instrucciones de pago." + let encabezado = "Registro ASINEA 2020"; + + let send = email(n_correo, encabezado, msj); + send.then(() => { + return res.status(200).json({ error: false, msj: "Exito", id_persona: id_persona, clave: mandar }); + }).catch(err => { + return res.status(400).json({ error: false, msj: "no se puede enviar el correo" }); + }) + + + + - return res.status(200).json({ err: false, msj: "Exito", id_persona: id_persona }); }).catch(async err => { //se deberia borrar el registro anterio de persona; //se deberia borrar el registro anterio de persona; @@ -233,7 +263,7 @@ app.post('/datos_personales', async(req, res) => { } } else { - res.status(200).json({ error: false, msj: "Exito", id_persona: id_persona }); + res.status(200).json({ error: false, msj: "Exito", id_persona: id_persona, clave: mandar }); return; } }).catch(async err => { diff --git a/routes/descargar_carta.js b/routes/descargar_carta.js index 7d20e4a..7d6a03a 100644 --- a/routes/descargar_carta.js +++ b/routes/descargar_carta.js @@ -3,7 +3,7 @@ const express = require('express') var app = express(); -app.get('/descargar_cartel', (req, res) => { +app.get('/descargar_carta', (req, res) => { res.download(__dirname + `/../files/carta_aceptacion-${req.query.id_persona}.docx`); }) diff --git a/routes/descargar_comprobante.js b/routes/descargar_comprobante.js index 2256bec..5f8da6c 100644 --- a/routes/descargar_comprobante.js +++ b/routes/descargar_comprobante.js @@ -3,7 +3,7 @@ const express = require('express') var app = express(); -app.get('/descargar_cartel', (req, res) => { +app.get('/descargar_comprobante', (req, res) => { res.download(__dirname + `/../files/comprobante_pago-${req.query.id_persona}.docx`); }) diff --git a/routes/elegir_clave.js b/routes/elegir_clave.js new file mode 100644 index 0000000..1e435c0 --- /dev/null +++ b/routes/elegir_clave.js @@ -0,0 +1,76 @@ +const connection = require('../conf/connection.js'); +const express = require('express') +var app = express(); +var enviar_correo = require('./enviar_correo.js'); + +function query(consulta) { + return new Promise(function(resolve, reject) { + connection.query(`${consulta}`, (error, results, files) => { + if (error) reject(error); + resolve(results); + }); + }) +} + + +let elegir = function(id_persona, correo) { + let cad = 'select * from numero_referencia where id_persona=null;'; + let ans = query(cad); + ans.then(async p => { + if (p.lenght == 0) { + + let n_cad = 'select * from mensaje where id_pesona=0'; + let n_q = await query(n_cad); + if (n_q.lenght == 0) { + let actualizar = `insert into mensaje values(null, 0, 'Se han acabado las claves interbancarias')`; + let n_ans = await query(actualizar); + } + return { error: true, msj: "Ya no hay calves de referencia disponibles" }; + + } else { + let num = p[0]; + + var actual = new Date(); + var caduca = new Date(); + console.log(caduca); + caduca.setDate(caduca.getMinutes() + 2); + console.log(caduca); + + actual = actual.getFullYear() + '-' + + ('00' + (actual.getMonth() + 1)).slice(-2) + '-' + + ('00' + actual.getDate()).slice(-2) + ' ' + + ('00' + actual.getHours()).slice(-2) + ':' + + ('00' + actual.getMinutes()).slice(-2) + ':' + + ('00' + actual.getSeconds()).slice(-2); + + caduca = caduca.getFullYear() + '-' + + ('00' + (caduca.getMonth() + 1)).slice(-2) + '-' + + ('00' + caduca.getDate()).slice(-2) + ' ' + + ('00' + caduca.getHours()).slice(-2) + ':' + + ('00' + caduca.getMinutes()).slice(-2) + ':' + + ('00' + caduca.getSeconds()).slice(-2); + + + + + let n_cad = `update numero_referencia set id_persona=${id_persona}, fecha_registro='${actual}', fecha_caducidad='${caduca}' where id_num_referecia=${num.id_num_referencia};`; + let n_query = query(n_cad); + n_query.then(() => { + let msj = `Estima usuario su numero de refencia ${num.clave} tendra 48 hrs para completar su pago y subir el comprobante a la plataforma. + Despues de este transcurrir este tiempo y que no se haya completado el pago ni subirlo a la plataforma su clave caducara por lo que tendra que elegir de nuevo su forma de pago para que pueda asistir a todos los eventos que eligo. + Muchas gracias.`; + + let encabezado = `Asignacion de clave bancaria ASINEA`; + let n_ans = enviar_correo(correo, encabezado, msj); + n_ans.then(() => { + return { erro: false, msj: msj }; + }) + }).catch(err => { + console.log(err); + return { erro: true, msj: "error al actualiza la referencia bancaria", type: err }; + }) + } + }) +} + +module.exports = elegir; \ No newline at end of file diff --git a/routes/eliminar_mensaje.js b/routes/eliminar_mensaje.js new file mode 100644 index 0000000..c668185 --- /dev/null +++ b/routes/eliminar_mensaje.js @@ -0,0 +1,18 @@ +const connection = require('../conf/connection.js'); +const express = require('express') +var app = express(); + + +app.get('/mostrar_mensaje', (req, res) => { + let cad = `delete form mensaje where id_mensaje=${req.query.id_mensaje};`; + let n_ans = query(cad); + n_ans.then(p => { + return res.status(200).json({ error: false, msj: "exito" }); + }).catch(err => { + console.log(err); + return res.status(400).json({ error: true, msj: "error al traer los mensaje", type: err }); + + }) +}) + +module.exports = app; \ No newline at end of file diff --git a/routes/enviar_correo.js b/routes/enviar_correo.js new file mode 100644 index 0000000..cfa30db --- /dev/null +++ b/routes/enviar_correo.js @@ -0,0 +1,22 @@ +const connection = require('../conf/connection.js'); +const express = require('express'); +const sendmail = require('sendmail')(); + + + + +let enviar_correo = function(correo, encabezado, texto) { + console.log(correo); + console.log(encabezado); + console.log(object); + sendmail({ + from: 'conversatorios.asinea2020@fa.unam.mx', + to: `${correo}`, + subject: `${encabezado}`, + html: `${texto}`, + }, function(err, reply) { + console.log(err && err.stack); + console.dir(reply); + }); +} +module.exports = enviar_correo \ No newline at end of file diff --git a/routes/enviar_password.js b/routes/enviar_password.js index 39a4c77..2acd75b 100644 --- a/routes/enviar_password.js +++ b/routes/enviar_password.js @@ -25,7 +25,7 @@ function depurado(cadena) { return null; } -app.get('/enviar_email', async(req, res) => { +app.get('/enviar_password', async(req, res) => { let id_persona; try { @@ -35,6 +35,7 @@ app.get('/enviar_email', async(req, res) => { n = depurado(n); let cad = `select id_persona from persona where correo='${n}'`; + console.log(cad); let respuesta = await query(cad); console.log("depurado: ", n); console.log("respuesta: ", respuesta); diff --git a/routes/get_persona.js b/routes/get_persona.js new file mode 100644 index 0000000..2542d01 --- /dev/null +++ b/routes/get_persona.js @@ -0,0 +1,99 @@ +const connection = require('../conf/connection.js'); +const express = require('express'); +const bcrypt = require('bcrypt'); +const fs = require('fs'); + + + +var app = express() + +function query(consulta) { + return new Promise(function(resolve, reject) { + connection.query(`${consulta}`, (error, results, files) => { + if (error) reject(error); + resolve(results); + }); + }) +} + + +function depurado(cadena) { + if (cadena != null) { + cadena = cadena.replace(/'/g, "''"); + cadena = cadena.replace(/;/g, "m"); + return cadena; + + } else + return null; +} + + +app.get('/get_persona', async(req, res) => { + try { + //console.log(req.query); + let id_persona = req.query.id_persona; + + + let cad = `select * from persona where id_persona=${id_persona};`; + //console.log(cad); + let respuesta = query(cad); + // console.log(respuesta); + let ans = {} + respuesta.then(async r => { + // console.log(r, r.length); + ans.persona = r[0]; + + ans.persona.comprobante_pago = false; + ans.persona.carta_aceptacion = false; + if (fs.existsSync(`./files/carta_aceptacion-${id_persona}.docx`)) { + + ans.persona.carta_aceptacion = true; + } + + + if (fs.existsSync(`./files/comprobante_pago-${id_persona}.docx`)) { + ans.persona.comprobante_pago = true; + } + console.log("carta: ", ans.persona.carta_aceptacion); + console.log("comprobante: ", ans.persona.comprobante_pago); + + delete(ans.persona.password); + cad = `select asi.*, e.* from asistencia as asi inner join evento as e where asi.id_persona=${id_persona} and e.id_evento=asi.id_evento;`; + let n_ans = query(cad); + n_ans.then(async n => { + for (let i = 0; i < n.length; i++) { + //console.log(n); + await delete(n[i].cupo); + } + ans.evento = n; + return res.status(200).json({ error: false, data: ans }); + + }).catch(err => { + console.log(err); + res.status(400).json({ error: true, msj: "error al elegir todos los eventos", type: err }); + return; + }) + + + + + } + + ).catch(err => { + console.log(err); + res.status(400).json({ error: true, msj: "Error al seleccionar a la persona", type: err }); + return; + }) + + + + + } catch (err) { + console.log("afuera ", err); + res.status(400).json({ error: true, msj: err }); + return; + } + +}); + +module.exports = app; \ No newline at end of file diff --git a/routes/index.js b/routes/index.js index 7017659..1597457 100644 --- a/routes/index.js +++ b/routes/index.js @@ -3,11 +3,15 @@ var app = express() app.use(require('./datos_personales')); app.use(require('./login_persona')); - app.use(require('./crear_pdf')); - app.use(require('./get_pdf')); app.use(require('./traer_datos')); app.use(require('./traer_persona')); -//app.use(require('./crear_qr')); +app.use(require('./enviar_password')); +app.use(require('./get_persona')); +app.use(require('./mostrar_mensaje')); +app.use(require('./subir_archivo')); +app.use(require('./descargar_comprobante')); +app.use(require('./descargar_carta')); +//app.use(require('./crear_ccv')); module.exports = app; \ No newline at end of file diff --git a/routes/login_persona.js b/routes/login_persona.js index 3ad79a3..df3d606 100644 --- a/routes/login_persona.js +++ b/routes/login_persona.js @@ -49,7 +49,7 @@ app.post('/login_persona', async(req, res) => { let ban = bcrypt.compareSync(data.password, r[0].password); if (ban == true) { - return res.status(200).json({ error: false, msj: "Bienvenido", data: r[0] }); + return res.status(200).json({ error: false, msj: "Bienvenido", data: r[0].id_persona }); } else { res.status(400).json({ error: false, msj: "Usuario o contraseña invalidos" }); @@ -76,4 +76,4 @@ app.post('/login_persona', async(req, res) => { }); -module.exports = app \ No newline at end of file +module.exports = app; \ No newline at end of file diff --git a/routes/mostrar_mensaje.js b/routes/mostrar_mensaje.js new file mode 100644 index 0000000..d755f04 --- /dev/null +++ b/routes/mostrar_mensaje.js @@ -0,0 +1,18 @@ +const connection = require('../conf/connection.js'); +const express = require('express') +var app = express(); + + +app.get('/mostrar_mensaje', (req, res) => { + let cad = `select * from mensaje where id_persona=${req.query.id_persona};`; + let n_ans = query(cad); + n_ans.then(p => { + return res.status(200).json({ error: false, msj: "exito", data: p }); + }).catch(err => { + console.log(err); + return res.status(400).json({ error: true, msj: "error al traer los mensaje", type: err }); + + }) +}) + +module.exports = app; \ No newline at end of file diff --git a/routes/subir_archivo.js b/routes/subir_archivo.js index cbf915e..07d8f1f 100644 --- a/routes/subir_archivo.js +++ b/routes/subir_archivo.js @@ -30,7 +30,7 @@ app.post('/subir_archivo', async(req, res) => { let sampleFile = req.files.comprobante_pago; let nombreCortado = sampleFile.name.split('.'); let extencion = nombreCortado[nombreCortado.length - 1]; - let extensionValidas = ['pdf', 'jpg', 'jpeg', 'png']; + let extensionValidas = ['pdf', 'jpg', 'jpeg', 'png', 'docx', 'doc', 'odt', 'pdf']; if (extensionValidas.indexOf(extencion) < 0) { return res.status(400).json({ @@ -44,7 +44,7 @@ app.post('/subir_archivo', async(req, res) => { let sampleFile = req.files.carta_aceptacion; let nombreCortado = sampleFile.name.split('.'); let extencion = nombreCortado[nombreCortado.length - 1]; - let extensionValidas = ['docx', 'doc', 'odt']; + let extensionValidas = ['docx', 'doc', 'odt', 'pdf', 'docx', 'doc', 'odt', 'pdf']; if (extensionValidas.indexOf(extencion) < 0) { return res.status(400).json({ diff --git a/routes/traer_datos.js b/routes/traer_datos.js index ad422b1..ebbed7f 100644 --- a/routes/traer_datos.js +++ b/routes/traer_datos.js @@ -40,6 +40,7 @@ app.get('/traer_datos', async(req, res) => { res.status(200).json({ error: false, msj: "exito", universidad: uni, conversatorio: con, taller_alumno: t_a, taller_profesor: t_p, visita: v_g, dialogo: d_m }); return; } catch (err) { + console.log(err); return res.status(400).json({ error: true, msj: "Error al traer los datos" }); } diff --git a/routes/traer_persona.js b/routes/traer_persona.js index dc51f49..a26c316 100644 --- a/routes/traer_persona.js +++ b/routes/traer_persona.js @@ -1,7 +1,7 @@ const connection = require('../conf/connection.js'); const express = require('express'); - +const fs = require('fs'); var app = express() function query(consulta) { @@ -28,6 +28,11 @@ app.get('/traer_persona', async(req, res) => { let n_ans = await query(cad); console.log(p[i]); + console.log("nuevo ans ", n_ans); + + + + aux.id_persona = p[i].id_persona; aux.nombre = p[i].nombre; aux.apellido_p = p[i].apellido_p; @@ -38,8 +43,24 @@ app.get('/traer_persona', async(req, res) => { aux.taller = 'No'; aux.visita = 'No'; aux.magistral = 'No'; + aux.comprobante_pago = false; + aux.carta_aceptacion = false; + if (fs.existsSync(`./files/carta_aceptacion-${p[i].id_persona}.docx`)) { + + aux.carta_aceptacion = true; + } + if (fs.existsSync(`./files/comprobante_pago-${p[i].id_persona}.docx`)) { + aux.comprobante_pago = true; + } + + + + aux.correo = p[i].correo; + let nueva_cadena = `select * from alumno where id_persona=${p[i].id_persona};` + let nueva_query = await query(nueva_cadena); + aux.tipo_pago = nueva_query[0].metodo_pago_asignado; let ext = true; if (aux.comunidad == 'UNAM') ext = false; @@ -116,6 +137,12 @@ app.get('/traer_persona', async(req, res) => { aux.taller = 'No'; aux.visita = 'No'; aux.magistral = 'No'; + aux.pago = n_ans[0].metodo_pago_asignado; + aux.correo = p[i].correo; + + let nueva_cadena = `select * from academico where id_persona=${p[i].id_persona};` + let nueva_query = await query(nueva_cadena); + aux.tipo_pago = nueva_query[0].metodo_pago_asignado; let tot = 0; let ext = true; diff --git a/sql/base.sql b/sql/base.sql index ed88409..b9ae268 100644 --- a/sql/base.sql +++ b/sql/base.sql @@ -31,13 +31,16 @@ CREATE TABLE `persona` ( CREATE TABLE `alumno` ( `id_persona` integer PRIMARY KEY NOT NULL, `numero_cuenta` varchar(20), - `año_curso` varchar(20) + `año_curso` varchar(20), + `metodo_pago_asignado` varchar(200) ); CREATE TABLE `academico` ( `id_persona` integer PRIMARY KEY NOT NULL, `grado_academico` varchar(50), - `aignatura_imparte` varchar(50) + `aignatura_imparte` varchar(50), + `metodo_pago_asignado` varchar(200) + ); @@ -62,13 +65,30 @@ CREATE TABLE `asistencia` ( CREATE TABLE `factura` ( `id_factura` integer PRIMARY KEY NOT NULL AUTO_INCREMENT, - `id_persona` int, + `id_persona` integer, `rfc` varchar(255), `domicilio` varchar(255), `telefono` varchar(255), `correo` varchar(255) ); + +CREATE TABLE `numero_referencia`( + `id_numero_refencia` integer PRIMARY KEY NOT NULL AUTO_INCREMENT, + `clave` varchar(200), + `id_persona` integer, + `fecha_registro` datetime, + `fecha_caducacion` datetime, + `pagado` boolean +); + +CREATE TABLE `mensaje`( + `id_mensaje` integer PRIMARY KEY NOT NULL AUTO_INCREMENT, + `id_persona` integer, + `mensaje` varchar(1000) + +); + ALTER TABLE `factura` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id_persona`); ALTER TABLE `asistencia` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id_persona`); @@ -79,6 +99,10 @@ ALTER TABLE `academico` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id ALTER TABLE `asistencia` ADD FOREIGN KEY (`id_evento`) REFERENCES `evento` (`id_evento`); +ALTER TABLE `numero_referencia` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id_persona`); + + +ALTER TABLE `mensaje` ADD FOREIGN KEY (`id_persona`) REFERENCES `persona` (`id_persona`);