Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a78500206 | ||
|
|
27465cd89d | ||
|
|
8d6425aa01 | ||
|
|
b85d0ca019 | ||
|
|
ae5377f0e6 | ||
|
|
e00f8fffb4 | ||
|
|
d4531744c4 | ||
|
|
663a10f2d2 | ||
|
|
322e4cc983 | ||
|
|
8c1d3f43fe | ||
|
|
91dd1d0196 | ||
|
|
14b08a8727 | ||
|
|
ce039c33eb | ||
|
|
8e3037d38d | ||
|
|
f86798a45b | ||
|
|
25eeee9d34 | ||
|
|
5324f1a061 | ||
|
|
8df46f0dbe | ||
|
|
5dbd7c06aa | ||
|
|
51d534d330 | ||
|
|
33a32413f0 | ||
|
|
77bd580615 | ||
|
|
4abf10fd69 | ||
|
|
bbbee76cfe | ||
|
|
451d27d7df | ||
|
|
440e0f4edb | ||
|
|
e1bc94fc5a | ||
|
|
480d5b9403 | ||
|
|
6560ecedf7 | ||
|
|
c4894ff3c1 | ||
|
|
227d03fbd7 | ||
|
|
d9b1f7ccb7 | ||
|
|
27a77c9545 | ||
|
|
53bff8d618 |
@@ -8,3 +8,5 @@ node_modules/
|
||||
*.db-wal
|
||||
*.db
|
||||
cloudflared.exe
|
||||
scratch/
|
||||
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
"better-sqlite3": "^13.0.3",
|
||||
"cors": "^2.8.6",
|
||||
"express": "^5.2.1",
|
||||
"imap-simple": "^5.1.0",
|
||||
"jsqr": "^1.4.0",
|
||||
"mailparser": "^3.9.36",
|
||||
"pg": "^8.23.1",
|
||||
"puppeteer-core": "^25.12.0",
|
||||
"qrcode": "^1.5.4",
|
||||
"synckit": "^0.11.13",
|
||||
"web-push": "^3.6.7"
|
||||
@@ -31,6 +34,222 @@
|
||||
"url": "https://opencollective.com/pkgr"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.3.tgz",
|
||||
"integrity": "sha512-2Bt3m6dDAJqmZehn0wiXSYyQmuhyiHHZ7FjvrVaS1W2RoFGV6eCK71UvKYkNJjkwC1Q9nobjhvTMhLQztFVINA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"modern-tar": "^0.8.4",
|
||||
"yargs": "^18.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"browsers": "lib/main-cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.12.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"proxy-agent": ">=8.0.1",
|
||||
"yauzl": "^2.10.0 || ^3.4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"proxy-agent": {
|
||||
"optional": true
|
||||
},
|
||||
"yauzl": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/ansi-regex": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz",
|
||||
"integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/ansi-styles": {
|
||||
"version": "6.2.3",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
|
||||
"integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/cliui": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
|
||||
"integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^7.2.0",
|
||||
"strip-ansi": "^7.1.0",
|
||||
"wrap-ansi": "^9.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/cliui/node_modules/string-width": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^10.3.0",
|
||||
"get-east-asian-width": "^1.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/emoji-regex": {
|
||||
"version": "10.6.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/string-width": {
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz",
|
||||
"integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"get-east-asian-width": "^1.5.0",
|
||||
"strip-ansi": "^7.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/strip-ansi": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
|
||||
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^6.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/wrap-ansi": {
|
||||
"version": "9.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz",
|
||||
"integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^6.2.1",
|
||||
"string-width": "^7.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/wrap-ansi/node_modules/string-width": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^10.3.0",
|
||||
"get-east-asian-width": "^1.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/y18n": {
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/yargs": {
|
||||
"version": "18.2.0",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz",
|
||||
"integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cliui": "^9.0.1",
|
||||
"escalade": "^3.1.1",
|
||||
"get-caller-file": "^2.0.5",
|
||||
"string-width": "^8.2.1",
|
||||
"y18n": "^5.0.5",
|
||||
"yargs-parser": "^22.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||
}
|
||||
},
|
||||
"node_modules/@puppeteer/browsers/node_modules/yargs-parser": {
|
||||
"version": "22.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
|
||||
"integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||
}
|
||||
},
|
||||
"node_modules/@selderee/plugin-htmlparser2": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.12.0.tgz",
|
||||
"integrity": "sha512-oELmoyA6ML9jDRMV3kgcMQFKxUfBU0yFVn6yTctVaLT5ygXnxH52I3TZEgV9EhXJC68/uFvE5Daj1/25c0Xa/A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"domelementtype": "~2.3.0",
|
||||
"domhandler": "~5.0.3"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/KillyMXI"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"selderee": "~0.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@zone-eu/mailsplit": {
|
||||
"version": "5.4.20",
|
||||
"resolved": "https://registry.npmjs.org/@zone-eu/mailsplit/-/mailsplit-5.4.20.tgz",
|
||||
"integrity": "sha512-6B2w0zRBWOwbO5h7SL5N/2z1AuNchTP3OT33MObUr4/cz9bWPrZ6KadLKxnSrOZG0AGu7Q03p4X7eQhZHc1u/A==",
|
||||
"license": "(MIT OR EUPL-1.1+)",
|
||||
"dependencies": {
|
||||
"libbase64": "1.3.2",
|
||||
"libmime": "5.4.7",
|
||||
"libqp": "2.1.2"
|
||||
}
|
||||
},
|
||||
"node_modules/accepts": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
|
||||
@@ -197,6 +416,22 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/chromium-bidi": {
|
||||
"version": "17.0.2",
|
||||
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-17.0.2.tgz",
|
||||
"integrity": "sha512-5v9GQFhTktFvotn/OFNJBmKLKRAb6n9r0bVCwf7sHgWc3/JryK0bj1nn93L3pHFrfgcsu6Be6EWsDi+1XHTGDg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"mitt": "^3.0.1",
|
||||
"zod": "^3.24.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.19.0 <22.0.0 || >=22.12.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"devtools-protocol": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/cliui": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
|
||||
@@ -266,6 +501,12 @@
|
||||
"node": ">=6.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/core-util-is": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
|
||||
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cors": {
|
||||
"version": "2.8.6",
|
||||
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz",
|
||||
@@ -309,6 +550,25 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/deepmerge-ts": {
|
||||
"version": "8.0.2",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-8.0.2.tgz",
|
||||
"integrity": "sha512-uqbvqLUMrc6p0MO+WBRtTxY55hmyh94WRwI5a++PZe54X+bfVh59FSN7uWCBCW1CCVjzjnrwzfI8zidE2obMMw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "ko-fi",
|
||||
"url": "https://ko-fi.com/rebeccastevens"
|
||||
},
|
||||
{
|
||||
"type": "tidelift",
|
||||
"url": "https://tidelift.com/funding/github/npm/deepmerge-ts"
|
||||
}
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=16.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/depd": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||
@@ -318,12 +578,73 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/devtools-protocol": {
|
||||
"version": "0.0.1687809",
|
||||
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1687809.tgz",
|
||||
"integrity": "sha512-t7kSb+UKYdyxcmqy98U2P86ne6rCve3DIJ4+lp54i/hhClgFuG35JrLj23rO14Jw3sWDsp7i+22QhNU0+/qk8g==",
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/dijkstrajs": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz",
|
||||
"integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dom-serializer": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
|
||||
"integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"entities": "^4.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domelementtype": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
|
||||
"integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
],
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/domhandler": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
|
||||
"integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domhandler?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/domutils": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz",
|
||||
"integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"dom-serializer": "^2.0.0",
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.3"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domutils?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
@@ -368,6 +689,27 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/encoding-japanese": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/encoding-japanese/-/encoding-japanese-2.4.0.tgz",
|
||||
"integrity": "sha512-PE0KjlsDy9JSsoU4C2Q8NXb1kC4c+bZRac9ZvHXUE4q1Ht63gScKMdEy9jst9+Fi3M4eDkqzkEhBZvix4blP2A==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
@@ -398,6 +740,15 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
||||
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
@@ -526,6 +877,18 @@
|
||||
"node": "6.* || 8.* || >= 10.*"
|
||||
}
|
||||
},
|
||||
"node_modules/get-east-asian-width": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz",
|
||||
"integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
@@ -599,6 +962,65 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/he": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"he": "bin/he"
|
||||
}
|
||||
},
|
||||
"node_modules/html-to-text": {
|
||||
"version": "10.0.1",
|
||||
"resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-10.0.1.tgz",
|
||||
"integrity": "sha512-GiVhRI1BatGARSCmlXWNCjDT0cWrwBWoeduLoV0WSKAgaV/wa+hUWy5LiQLUs4UwiUrE52ZCMfBGiKD87TDPrg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@selderee/plugin-htmlparser2": "~0.12.0",
|
||||
"deepmerge-ts": "^8.0.1",
|
||||
"dom-serializer": "^2.0.0",
|
||||
"htmlparser2": "^10.1.0",
|
||||
"selderee": "~0.12.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/KillyMXI"
|
||||
}
|
||||
},
|
||||
"node_modules/htmlparser2": {
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.1.0.tgz",
|
||||
"integrity": "sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==",
|
||||
"funding": [
|
||||
"https://github.com/fb55/htmlparser2?sponsor=1",
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fb55"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.3",
|
||||
"domutils": "^3.2.2",
|
||||
"entities": "^7.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/htmlparser2/node_modules/entities": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
|
||||
"integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/http_ece": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/http_ece/-/http_ece-1.2.0.tgz",
|
||||
@@ -657,6 +1079,47 @@
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/imap": {
|
||||
"version": "0.8.19",
|
||||
"resolved": "https://registry.npmjs.org/imap/-/imap-0.8.19.tgz",
|
||||
"integrity": "sha512-z5DxEA1uRnZG73UcPA4ES5NSCGnPuuouUx43OPX7KZx1yzq3N8/vx2mtXEShT5inxB3pRgnfG1hijfu7XN2YMw==",
|
||||
"dependencies": {
|
||||
"readable-stream": "1.1.x",
|
||||
"utf7": ">=1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/imap-simple": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/imap-simple/-/imap-simple-5.1.0.tgz",
|
||||
"integrity": "sha512-FLZm1v38C5ekN46l/9X5gBRNMQNVc5TSLYQ3Hsq3xBLvKwt1i5fcuShyth8MYMPuvId1R46oaPNrH92hFGHr/g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"iconv-lite": "~0.4.13",
|
||||
"imap": "^0.8.18",
|
||||
"nodeify": "^1.0.0",
|
||||
"quoted-printable": "^1.0.0",
|
||||
"utf8": "^2.1.1",
|
||||
"uuencode": "0.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/imap-simple/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==",
|
||||
"license": "MIT",
|
||||
"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",
|
||||
@@ -687,6 +1150,12 @@
|
||||
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/isarray": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/jsqr": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.4.0.tgz",
|
||||
@@ -714,6 +1183,58 @@
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/leac": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/leac/-/leac-0.7.0.tgz",
|
||||
"integrity": "sha512-qMrZeyEekgdRQ9o6a4NAB2EQZrv827GJdn1vnapwSJ90hWRB4TzUSunvacPkxQ2TnNqHNI1/zSt0hlo0crG8Jw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/KillyMXI"
|
||||
}
|
||||
},
|
||||
"node_modules/libbase64": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.3.2.tgz",
|
||||
"integrity": "sha512-fFCoI0ceXhTu/0QiJ6Uf6BV9k7X/8QW2/D4BR1vw3BPrHcIjLbGLH+U7inQ4SeWrfNCOmpGE09Qt4XjSFfus0g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/libmime": {
|
||||
"version": "5.4.7",
|
||||
"resolved": "https://registry.npmjs.org/libmime/-/libmime-5.4.7.tgz",
|
||||
"integrity": "sha512-r1ENu4wMVSB52AAORwaW4L/MeQJr9rryzHLRpcjud3zcUPWXh1Xkgn+tAqL8oTnRO/LW7y5xxPBE20ta5amtMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encoding-japanese": "2.4.0",
|
||||
"iconv-lite": "0.7.3",
|
||||
"libbase64": "1.3.2",
|
||||
"libqp": "2.1.2"
|
||||
}
|
||||
},
|
||||
"node_modules/libqp": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/libqp/-/libqp-2.1.2.tgz",
|
||||
"integrity": "sha512-rp+U80tl9Os4K7GnVbPzPRmghPu6eqB8rcF+ontvNAnoga0JhMFG/bkTD/reC8yoznKMgOc5/ttZHJasiWeFPw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/linkify-it": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz",
|
||||
"integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/puzrin"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/markdown-it"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"uc.micro": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/locate-path": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
|
||||
@@ -726,6 +1247,27 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/mailparser": {
|
||||
"version": "3.9.36",
|
||||
"resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.9.36.tgz",
|
||||
"integrity": "sha512-Fng3OmPN7khG0oVHDwwBIOYxjGu7kFxEuN6NnVV1H2tQYCIWjqvjK6cKvhj2r3XQVToVabP0b4HF+N7YgNdXFQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@zone-eu/mailsplit": "5.4.20",
|
||||
"encoding-japanese": "2.4.0",
|
||||
"he": "1.2.0",
|
||||
"html-to-text": "10.0.1",
|
||||
"iconv-lite": "0.7.3",
|
||||
"libmime": "5.4.7",
|
||||
"linkify-it": "5.0.2",
|
||||
"nodemailer": "10.0.14",
|
||||
"punycode.js": "2.3.1",
|
||||
"tlds": "1.261.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
@@ -800,6 +1342,21 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/mitt": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
|
||||
"integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/modern-tar": {
|
||||
"version": "0.8.5",
|
||||
"resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.5.tgz",
|
||||
"integrity": "sha512-snEhs+6G5Tjd4I7tLCDOaoln2RgE0bD19RzEKgvgK2hZ5VKy3MpLhLTZ2fWpXSTg4K2cyPwp+VHATFJhxfnOeA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
@@ -844,6 +1401,31 @@
|
||||
"node": "^18 || ^20 || >= 21"
|
||||
}
|
||||
},
|
||||
"node_modules/nodeify": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/nodeify/-/nodeify-1.0.1.tgz",
|
||||
"integrity": "sha512-n7C2NyEze8GCo/z73KdbjRsBiLbv6eBn1FxwYKQ23IqGo7pQY3mhQan61Sv7eEDJCiyUjTVrVkXTzJCo1dW7Aw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-promise": "~1.0.0",
|
||||
"promise": "~1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nodeify/node_modules/is-promise": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-1.0.1.tgz",
|
||||
"integrity": "sha512-mjWH5XxnhMA8cFnDchr6qRP9S/kLntKuEfIYku+PaN1CnS8v+OG9O/BKpRCVRJvpIkgAZm0Pf5Is3iSSOILlcg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/nodemailer": {
|
||||
"version": "10.0.14",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.0.14.tgz",
|
||||
"integrity": "sha512-eJoLFKg55fesSlzUekmfOv/SBXh4KUYT8oiQc2RLP0tfG0rbNMJBK7wgHJwXTJwqyKlSJMz9UzDZ4v+aHEvo8g==",
|
||||
"license": "MIT-0",
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
@@ -922,6 +1504,19 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/parseley": {
|
||||
"version": "0.13.1",
|
||||
"resolved": "https://registry.npmjs.org/parseley/-/parseley-0.13.1.tgz",
|
||||
"integrity": "sha512-uNBJZzmb60l6p6VWLTmevizNAGnE0xoSf1n0B4q3ntegDNzcS68NRCcBDZTcyXHxt2XhBChsCuqj4M+nChvE/A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"leac": "^0.7.0",
|
||||
"peberminta": "^0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/KillyMXI"
|
||||
}
|
||||
},
|
||||
"node_modules/parseurl": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
@@ -950,6 +1545,15 @@
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/peberminta": {
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/peberminta/-/peberminta-0.10.0.tgz",
|
||||
"integrity": "sha512-80B2AsU+I4Qdb0ZAPSfe9UwvGzwkM37IKIFEvdS3D/3Ndgv2bsuJ0bfG1+iEYO+l7Gfd4EUJmuRyq7efLgRMzQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/KillyMXI"
|
||||
}
|
||||
},
|
||||
"node_modules/pg": {
|
||||
"version": "8.23.1",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.23.1.tgz",
|
||||
@@ -1087,6 +1691,21 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/promise": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/promise/-/promise-1.3.0.tgz",
|
||||
"integrity": "sha512-R9WrbTF3EPkVtWjp7B7umQGVndpsi+rsDAfrR4xAALQpFLa/+2OriecLhawxzvii2gd9+DZFwROWDuUUaqS5yA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-promise": "~1"
|
||||
}
|
||||
},
|
||||
"node_modules/promise/node_modules/is-promise": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-1.0.1.tgz",
|
||||
"integrity": "sha512-mjWH5XxnhMA8cFnDchr6qRP9S/kLntKuEfIYku+PaN1CnS8v+OG9O/BKpRCVRJvpIkgAZm0Pf5Is3iSSOILlcg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
|
||||
@@ -1104,6 +1723,32 @@
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/punycode.js": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
|
||||
"integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/puppeteer-core": {
|
||||
"version": "25.12.0",
|
||||
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-25.12.0.tgz",
|
||||
"integrity": "sha512-z6LQUt5SH7jwGtGA+nMtJuEjZIsqPiwQ+EFHCYuVDQrJpvifNmmGuyDvTzAKPyFzihxgHc5f3aMzu2kn8Ps37A==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@puppeteer/browsers": "3.2.3",
|
||||
"chromium-bidi": "17.0.2",
|
||||
"devtools-protocol": "0.0.1687809",
|
||||
"typed-query-selector": "^2.12.2",
|
||||
"webdriver-bidi-protocol": "0.4.3",
|
||||
"ws": "^8.21.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/qrcode": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",
|
||||
@@ -1137,6 +1782,18 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/quoted-printable": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/quoted-printable/-/quoted-printable-1.0.1.tgz",
|
||||
"integrity": "sha512-cihC68OcGiQOjGiXuo5Jk6XHANTHl1K4JLk/xlEJRTIXfy19Sg6XzB95XonYgr+1rB88bCpr7WZE7D7AlZow4g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"utf8": "^2.1.0"
|
||||
},
|
||||
"bin": {
|
||||
"quoted-printable": "bin/quoted-printable"
|
||||
}
|
||||
},
|
||||
"node_modules/range-parser": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz",
|
||||
@@ -1165,6 +1822,18 @@
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/readable-stream": {
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.1",
|
||||
"isarray": "0.0.1",
|
||||
"string_decoder": "~0.10.x"
|
||||
}
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
@@ -1222,6 +1891,27 @@
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/selderee": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/selderee/-/selderee-0.12.0.tgz",
|
||||
"integrity": "sha512-b1YMh3+DHZp59DLna3qVwQ5iOla/nrI6mLBNW02XxU77M3046Df6VLkoaJyFz20VsGIG5kkp+FK0kg4K4HnUFw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"parseley": "~0.13.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/KillyMXI"
|
||||
}
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
|
||||
"integrity": "sha512-mfmm3/H9+67MCVix1h+IXTpDwL6710LyHuk7+cWC9T1mE0qz4iHhh6r4hU2wrIT9iTsAAC2XQRvfblL028cpLw==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver"
|
||||
}
|
||||
},
|
||||
"node_modules/send": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz",
|
||||
@@ -1369,6 +2059,12 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder": {
|
||||
"version": "0.10.31",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
|
||||
"integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
@@ -1410,6 +2106,15 @@
|
||||
"url": "https://opencollective.com/synckit"
|
||||
}
|
||||
},
|
||||
"node_modules/tlds": {
|
||||
"version": "1.261.0",
|
||||
"resolved": "https://registry.npmjs.org/tlds/-/tlds-1.261.0.tgz",
|
||||
"integrity": "sha512-QXqwfEl9ddlGBaRFXIvNKK6OhipSiLXuRuLJX5DErz0o0Q0rYxulWLdFryTkV5PkdZct5iMInwYEGe/eR++1AA==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"tlds": "bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/toidentifier": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
||||
@@ -1450,6 +2155,18 @@
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/typed-query-selector": {
|
||||
"version": "2.12.3",
|
||||
"resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.3.tgz",
|
||||
"integrity": "sha512-/dtuMZyutHLlrxWhhC1uib00ELUr2dZ8C9B8YzZYsJmeE3V56OxRblrSM2UaF142pcMtak7ehZ6+poWGeehNIg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/uc.micro": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
|
||||
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
@@ -1459,6 +2176,25 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/utf7": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/utf7/-/utf7-1.0.2.tgz",
|
||||
"integrity": "sha512-qQrPtYLLLl12NF4DrM9CvfkxkYI97xOb5dsnGZHE3teFr0tWiEZ9UdgMPczv24vl708cYMpe6mGXGHrotIp3Bw==",
|
||||
"dependencies": {
|
||||
"semver": "~5.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/utf8": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.2.tgz",
|
||||
"integrity": "sha512-QXo+O/QkLP/x1nyi54uQiG0XrODxdysuQvE5dtVqv7F5K2Qb6FsN+qbr6KhF5wQ20tfcV3VQp0/2x1e1MRSPWg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/uuencode": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/uuencode/-/uuencode-0.0.4.tgz",
|
||||
"integrity": "sha512-yEEhCuCi5wRV7Z5ZVf9iV2gWMvUZqKJhAs1ecFdKJ0qzbyaVelmsE3QjYAamehfp9FKLiZbKldd+jklG3O0LfA=="
|
||||
},
|
||||
"node_modules/vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
@@ -1487,6 +2223,12 @@
|
||||
"node": ">= 16"
|
||||
}
|
||||
},
|
||||
"node_modules/webdriver-bidi-protocol": {
|
||||
"version": "0.4.3",
|
||||
"resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-0.4.3.tgz",
|
||||
"integrity": "sha512-uuN0goWfxP22B7J/uAgBpOYNPttC+XVseYE+rSY5+rQ+YBeVz/VORw8WbmLVcqW78zNg5A4qnjNXYUWR3il2ig==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/which-module": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz",
|
||||
@@ -1513,6 +2255,27 @@
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.22.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz",
|
||||
"integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
@@ -1562,6 +2325,15 @@
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.25.76",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
|
||||
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,11 @@
|
||||
"better-sqlite3": "^13.0.3",
|
||||
"cors": "^2.8.6",
|
||||
"express": "^5.2.1",
|
||||
"imap-simple": "^5.1.0",
|
||||
"jsqr": "^1.4.0",
|
||||
"mailparser": "^3.9.36",
|
||||
"pg": "^8.23.1",
|
||||
"puppeteer-core": "^25.12.0",
|
||||
"qrcode": "^1.5.4",
|
||||
"synckit": "^0.11.13",
|
||||
"web-push": "^3.6.7"
|
||||
|
||||
@@ -0,0 +1,571 @@
|
||||
/* ==========================================================================
|
||||
SIBOPAY DESKTOP WEB EXPERIENCE (desktop.css)
|
||||
Exclusivo para computadoras y monitores de escritorio (>= 1024px).
|
||||
Desacoplado de la PWA móvil: Los celulares (< 1024px) no se ven afectados.
|
||||
Basado en la distribución, paleta de colores y tamaño de botones del Panel Admin.
|
||||
========================================================================== */
|
||||
|
||||
@media (min-width: 860px) {
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
1. CONTENEDORES GENERALES EN PANTALLA COMPLETA
|
||||
-------------------------------------------------------------------------- */
|
||||
.parent-container {
|
||||
max-width: 100vw !important;
|
||||
width: 100% !important;
|
||||
padding: 18px 24px 60px 24px !important;
|
||||
min-height: 100vh;
|
||||
background: var(--bg-main, #f8fafc) !important;
|
||||
box-sizing: border-box !important;
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
|
||||
.app-container {
|
||||
max-width: 100vw !important;
|
||||
width: 100% !important;
|
||||
padding: 18px 24px 80px 24px !important;
|
||||
min-height: 100vh;
|
||||
background: var(--bg-main, #f8fafc) !important;
|
||||
box-sizing: border-box !important;
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
2. PORTAL DE PADRES: CABECERA IDÉNTICA A LA DEL ADMINISTRADOR
|
||||
-------------------------------------------------------------------------- */
|
||||
.parent-header {
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1px solid var(--border, #e2e8f0) !important;
|
||||
border-radius: 18px !important;
|
||||
padding: 14px 18px !important;
|
||||
margin-bottom: 16px !important;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
|
||||
display: flex !important;
|
||||
justify-content: space-between !important;
|
||||
align-items: center !important;
|
||||
flex-wrap: wrap !important;
|
||||
gap: 12px !important;
|
||||
}
|
||||
|
||||
.parent-badge {
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
gap: 10px !important;
|
||||
}
|
||||
|
||||
.parent-icon {
|
||||
width: 38px !important;
|
||||
height: 38px !important;
|
||||
min-width: 38px !important;
|
||||
border-radius: 10px !important;
|
||||
display: inline-flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
font-size: 1.05rem !important;
|
||||
background: var(--bg-main, #f8fafc) !important;
|
||||
color: #0284c7 !important;
|
||||
border: 1.5px solid var(--border, #e2e8f0) !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.parent-badge h2 {
|
||||
font-size: 1.15rem !important;
|
||||
font-weight: 900 !important;
|
||||
margin: 0 !important;
|
||||
color: var(--text-main, #0f172a) !important;
|
||||
line-height: 1.2 !important;
|
||||
}
|
||||
|
||||
#parentLoggedName {
|
||||
font-size: 0.76rem !important;
|
||||
color: #0284c7 !important;
|
||||
font-weight: 700 !important;
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.parent-header-actions {
|
||||
display: flex !important;
|
||||
gap: 8px !important;
|
||||
align-items: center !important;
|
||||
}
|
||||
|
||||
.parent-header-actions .theme-toggle-btn {
|
||||
width: 34px !important;
|
||||
height: 34px !important;
|
||||
min-width: 34px !important;
|
||||
border-radius: 9px !important;
|
||||
display: inline-flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
font-size: 0.95rem !important;
|
||||
box-sizing: border-box !important;
|
||||
margin: 0 !important;
|
||||
border: 1.5px solid var(--border, #e2e8f0) !important;
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
color: var(--text-main, #334155) !important;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
.parent-header-actions .mode-btn {
|
||||
height: 34px !important;
|
||||
font-size: 0.82rem !important;
|
||||
font-weight: 700 !important;
|
||||
border-radius: 9px !important;
|
||||
padding: 0 14px !important;
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
color: var(--text-main, #334155) !important;
|
||||
border: 1.5px solid var(--border, #cbd5e1) !important;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
|
||||
display: inline-flex !important;
|
||||
align-items: center !important;
|
||||
gap: 6px !important;
|
||||
cursor: pointer !important;
|
||||
transition: all 0.15s ease !important;
|
||||
}
|
||||
|
||||
.parent-header-actions .mode-btn:hover {
|
||||
background: var(--bg-main, #f8fafc) !important;
|
||||
border-color: #94a3b8 !important;
|
||||
color: var(--text-main, #0f172a) !important;
|
||||
}
|
||||
|
||||
.parent-header-actions .logout-btn {
|
||||
height: 34px !important;
|
||||
font-size: 0.82rem !important;
|
||||
font-weight: 800 !important;
|
||||
border-radius: 9px !important;
|
||||
padding: 0 14px !important;
|
||||
background: #fef2f2 !important;
|
||||
color: #991b1b !important;
|
||||
border: 1px solid #fecaca !important;
|
||||
box-shadow: 0 1px 3px rgba(220, 38, 38, 0.08) !important;
|
||||
display: inline-flex !important;
|
||||
align-items: center !important;
|
||||
gap: 6px !important;
|
||||
cursor: pointer !important;
|
||||
transition: all 0.15s ease !important;
|
||||
}
|
||||
|
||||
.parent-header-actions .logout-btn:hover {
|
||||
background: #fee2e2 !important;
|
||||
border-color: #f87171 !important;
|
||||
color: #7f1d1d !important;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
3. PORTAL DE PADRES: CUADRÍCULA DE HIJOS VINCULADOS
|
||||
-------------------------------------------------------------------------- */
|
||||
.parent-children-grid {
|
||||
display: grid !important;
|
||||
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
|
||||
gap: 14px !important;
|
||||
margin-bottom: 18px !important;
|
||||
}
|
||||
|
||||
.parent-child-card {
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1px solid var(--border, #e2e8f0) !important;
|
||||
border-radius: 16px !important;
|
||||
padding: 14px 16px !important;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
|
||||
cursor: pointer !important;
|
||||
transition: all 0.2s ease !important;
|
||||
}
|
||||
|
||||
.parent-child-card:hover {
|
||||
transform: translateY(-2px) !important;
|
||||
box-shadow: 0 4px 12px rgba(2, 132, 199, 0.12) !important;
|
||||
border-color: #cbd5e1 !important;
|
||||
}
|
||||
|
||||
.parent-child-card.active,
|
||||
.parent-child-card.selected {
|
||||
border: 2px solid #0284c7 !important;
|
||||
background: #f0f9ff !important;
|
||||
box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.18), 0 4px 12px rgba(2, 132, 199, 0.12) !important;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
4. PORTAL DE PADRES: DASHBOARD DEL HIJO SELECCIONADO
|
||||
-------------------------------------------------------------------------- */
|
||||
.parent-balance-card-refined {
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1px solid var(--border, #e2e8f0) !important;
|
||||
border-radius: 18px !important;
|
||||
padding: 18px 22px !important;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
|
||||
margin-bottom: 16px !important;
|
||||
}
|
||||
|
||||
.parent-balance-amount-display span {
|
||||
font-size: 2.2rem !important;
|
||||
font-weight: 900 !important;
|
||||
color: #0284c7 !important;
|
||||
letter-spacing: -0.5px !important;
|
||||
}
|
||||
|
||||
.parent-balance-btn-recharge {
|
||||
height: 34px !important;
|
||||
font-size: 0.82rem !important;
|
||||
font-weight: 700 !important;
|
||||
border-radius: 9px !important;
|
||||
padding: 0 16px !important;
|
||||
background: #0f172a !important;
|
||||
color: #ffffff !important;
|
||||
border: 1px solid #0f172a !important;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12) !important;
|
||||
display: inline-flex !important;
|
||||
align-items: center !important;
|
||||
gap: 6px !important;
|
||||
cursor: pointer !important;
|
||||
transition: all 0.15s ease !important;
|
||||
}
|
||||
|
||||
.parent-balance-btn-recharge:hover {
|
||||
background: #1e293b !important;
|
||||
border-color: #1e293b !important;
|
||||
box-shadow: 0 2px 5px rgba(15, 23, 42, 0.2) !important;
|
||||
}
|
||||
|
||||
.parent-school-selector-pill {
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1px solid var(--border, #e2e8f0) !important;
|
||||
border-radius: 14px !important;
|
||||
padding: 10px 16px !important;
|
||||
margin-bottom: 16px !important;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
|
||||
}
|
||||
|
||||
.parent-smart-search-card {
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1px solid var(--border, #e2e8f0) !important;
|
||||
border-radius: 18px !important;
|
||||
padding: 16px 20px !important;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
|
||||
margin-bottom: 16px !important;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
4. PORTAL DE PADRES: LAYOUT DIVIDIDO IZQUIERDA / DERECHA (ESTILO GMAIL)
|
||||
-------------------------------------------------------------------------- */
|
||||
.parent-split-wrapper {
|
||||
display: flex !important;
|
||||
gap: 22px !important;
|
||||
align-items: flex-start !important;
|
||||
width: 100% !important;
|
||||
margin-top: 14px !important;
|
||||
}
|
||||
|
||||
/* Columna Izquierda: Menú de Cajitas (Sidebar Fijo) */
|
||||
.parent-sidebar-boxes {
|
||||
width: 330px !important;
|
||||
min-width: 330px !important;
|
||||
max-width: 330px !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
gap: 10px !important;
|
||||
position: sticky !important;
|
||||
top: 20px !important;
|
||||
flex-shrink: 0 !important;
|
||||
}
|
||||
|
||||
.parent-nav-box {
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1.5px solid var(--border, #e2e8f0) !important;
|
||||
border-radius: 14px !important;
|
||||
padding: 12px 16px !important;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
|
||||
transition: all 0.15s ease !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: space-between !important;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
.parent-nav-box:hover {
|
||||
background: var(--bg-main, #f8fafc) !important;
|
||||
border-color: #cbd5e1 !important;
|
||||
transform: translateX(4px) !important;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
|
||||
}
|
||||
|
||||
.parent-nav-box.active {
|
||||
background: #f0f9ff !important;
|
||||
border-color: #0284c7 !important;
|
||||
border-left: 5px solid #0284c7 !important;
|
||||
box-shadow: 0 2px 8px rgba(2, 132, 199, 0.12) !important;
|
||||
}
|
||||
|
||||
.parent-nav-box.active .parent-nav-box-text strong {
|
||||
color: #0284c7 !important;
|
||||
}
|
||||
|
||||
.parent-nav-box-icon {
|
||||
width: 38px !important;
|
||||
height: 38px !important;
|
||||
min-width: 38px !important;
|
||||
border-radius: 10px !important;
|
||||
background: var(--bg-main, #f8fafc) !important;
|
||||
border: 1px solid var(--border, #e2e8f0) !important;
|
||||
display: inline-flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
font-size: 1.2rem !important;
|
||||
margin-right: 12px !important;
|
||||
flex-shrink: 0 !important;
|
||||
}
|
||||
|
||||
.parent-nav-box-icon.rose-halo {
|
||||
background: #fff1f2 !important;
|
||||
border-color: #fecdd3 !important;
|
||||
}
|
||||
|
||||
.parent-nav-box-icon.green-halo {
|
||||
background: #f0fdf4 !important;
|
||||
border-color: #bbf7d0 !important;
|
||||
}
|
||||
|
||||
.parent-nav-box-text {
|
||||
flex: 1 !important;
|
||||
min-width: 0 !important;
|
||||
}
|
||||
|
||||
.parent-nav-box-text strong {
|
||||
display: block !important;
|
||||
font-size: 0.88rem !important;
|
||||
color: var(--text-main, #0f172a) !important;
|
||||
font-weight: 800 !important;
|
||||
line-height: 1.25 !important;
|
||||
}
|
||||
|
||||
.parent-nav-box-text span {
|
||||
display: block !important;
|
||||
font-size: 0.72rem !important;
|
||||
color: var(--text-muted, #64748b) !important;
|
||||
margin-top: 2px !important;
|
||||
}
|
||||
|
||||
.parent-nav-arrow {
|
||||
font-size: 1.25rem !important;
|
||||
color: var(--text-muted, #94a3b8) !important;
|
||||
font-weight: 800 !important;
|
||||
margin-left: 8px !important;
|
||||
}
|
||||
|
||||
/* Columna Derecha: Escenario de Contenido (Panel de Información) */
|
||||
.parent-content-stage {
|
||||
flex: 1 !important;
|
||||
min-width: 0 !important;
|
||||
width: calc(100% - 352px) !important;
|
||||
}
|
||||
|
||||
.parent-card {
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1px solid var(--border, #e2e8f0) !important;
|
||||
border-radius: 18px !important;
|
||||
padding: 22px !important;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
|
||||
margin-bottom: 16px !important;
|
||||
}
|
||||
|
||||
/* Contención ergonómica de formularios y ajustes en desktop (máx 620px) */
|
||||
.parent-subview:not(#parentSubViewMenu):not(#parentSubViewSinpe) .parent-card {
|
||||
max-width: 620px !important;
|
||||
width: 100% !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
#parentSubViewMenu .parent-card {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
/* Sección Recarga SINPE Móvil en Desktop (Grid de Formulario + Términos) */
|
||||
#parentSubViewSinpe {
|
||||
max-width: 1150px !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
#parentSubViewSinpe .parent-sinpe-desktop-grid {
|
||||
display: grid !important;
|
||||
grid-template-columns: minmax(350px, 1.15fr) minmax(320px, 0.85fr) !important;
|
||||
gap: 22px !important;
|
||||
align-items: start !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
#parentSubViewSinpe .parent-card {
|
||||
max-width: 100% !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.parent-sinpe-form-card {
|
||||
background: #f0fdf4 !important;
|
||||
border: 1.5px solid #86efac !important;
|
||||
box-shadow: 0 4px 14px rgba(22, 163, 74, 0.08) !important;
|
||||
}
|
||||
|
||||
.parent-sinpe-terms-card {
|
||||
display: block !important;
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1.5px solid var(--border, #e2e8f0) !important;
|
||||
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03) !important;
|
||||
}
|
||||
|
||||
/* Ocultar botón Volver en escritorio ya que la barra lateral siempre está visible */
|
||||
.parent-subview-back-btn {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.parent-subview-header {
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: flex-end !important;
|
||||
margin-bottom: 16px !important;
|
||||
padding-bottom: 12px !important;
|
||||
border-bottom: 1px solid var(--border, #e2e8f0) !important;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
5. PORTAL ESTUDIANTE / SODA (app-container en desktop)
|
||||
-------------------------------------------------------------------------- */
|
||||
.top-bar {
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1px solid var(--border, #e2e8f0) !important;
|
||||
border-radius: 18px !important;
|
||||
padding: 14px 18px !important;
|
||||
margin-bottom: 16px !important;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
.wallet-card {
|
||||
background: var(--card-bg, #ffffff) !important;
|
||||
border: 1px solid var(--border, #e2e8f0) !important;
|
||||
border-radius: 18px !important;
|
||||
padding: 18px 22px !important;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
|
||||
margin: 0 0 16px 0 !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
.products-grid {
|
||||
display: grid !important;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
|
||||
gap: 14px !important;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
6. MODO OSCURO EN DESKTOP (Coherencia exacta con el panel de administración)
|
||||
-------------------------------------------------------------------------- */
|
||||
body.dark-mode .parent-container,
|
||||
body.dark-mode .app-container {
|
||||
background: #0b1120 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-header,
|
||||
body.dark-mode .parent-balance-card-refined,
|
||||
body.dark-mode .parent-school-selector-pill,
|
||||
body.dark-mode .parent-smart-search-card,
|
||||
body.dark-mode .parent-card,
|
||||
body.dark-mode .parent-child-card,
|
||||
body.dark-mode .parent-refined-menu-item,
|
||||
body.dark-mode .top-bar,
|
||||
body.dark-mode .wallet-card {
|
||||
background: #1e293b !important;
|
||||
border-color: #334155 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-icon {
|
||||
background: #0f172a !important;
|
||||
border-color: #334155 !important;
|
||||
color: #38bdf8 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-header-actions .theme-toggle-btn,
|
||||
body.dark-mode .parent-header-actions .mode-btn,
|
||||
body.dark-mode .parent-subview-back-btn {
|
||||
background: #1e293b !important;
|
||||
border-color: #334155 !important;
|
||||
color: #f1f5f9 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-header-actions .mode-btn:hover,
|
||||
body.dark-mode .parent-subview-back-btn:hover {
|
||||
background: #334155 !important;
|
||||
border-color: #475569 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-header-actions .logout-btn {
|
||||
background: rgba(239, 68, 68, 0.12) !important;
|
||||
color: #fca5a5 !important;
|
||||
border-color: rgba(239, 68, 68, 0.3) !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-header-actions .logout-btn:hover {
|
||||
background: rgba(239, 68, 68, 0.2) !important;
|
||||
border-color: #f87171 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-balance-btn-recharge {
|
||||
background: #0284c7 !important;
|
||||
border-color: #0284c7 !important;
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-balance-btn-recharge:hover {
|
||||
background: #0369a1 !important;
|
||||
border-color: #0369a1 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-child-card.active,
|
||||
body.dark-mode .parent-child-card.selected {
|
||||
border-color: #38bdf8 !important;
|
||||
background: rgba(2, 132, 199, 0.15) !important;
|
||||
box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25) !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-nav-box {
|
||||
background: #1e293b !important;
|
||||
border-color: #334155 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-nav-box:hover {
|
||||
background: #243447 !important;
|
||||
border-color: #475569 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-nav-box.active {
|
||||
background: rgba(2, 132, 199, 0.18) !important;
|
||||
border-color: #38bdf8 !important;
|
||||
border-left: 5px solid #38bdf8 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-nav-box.active .parent-nav-box-text strong {
|
||||
color: #38bdf8 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-nav-box-icon {
|
||||
background: #0f172a !important;
|
||||
border-color: #334155 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-refined-menu-item:hover {
|
||||
background: #0f172a !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-balance-amount-display span {
|
||||
color: #38bdf8 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-sinpe-form-card {
|
||||
background: rgba(6, 78, 59, 0.22) !important;
|
||||
border-color: #059669 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .parent-sinpe-terms-card {
|
||||
background: #1e293b !important;
|
||||
border-color: #334155 !important;
|
||||
color: #f1f5f9 !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 890 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 4.0 MiB |
|
After Width: | Height: | Size: 984 KiB |
|
After Width: | Height: | Size: 4.9 MiB |
|
After Width: | Height: | Size: 760 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 726 KiB |
|
After Width: | Height: | Size: 710 KiB |
|
After Width: | Height: | Size: 646 KiB |
|
After Width: | Height: | Size: 634 KiB |
|
After Width: | Height: | Size: 493 KiB |
|
After Width: | Height: | Size: 641 KiB |
|
After Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 655 KiB |
|
After Width: | Height: | Size: 742 KiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 642 KiB |
|
After Width: | Height: | Size: 891 KiB |
|
After Width: | Height: | Size: 5.2 MiB |
|
After Width: | Height: | Size: 404 KiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 3.3 MiB |
|
After Width: | Height: | Size: 1.7 MiB |
|
After Width: | Height: | Size: 730 KiB |
|
After Width: | Height: | Size: 720 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 712 KiB |
|
After Width: | Height: | Size: 753 KiB |
@@ -0,0 +1,241 @@
|
||||
/**
|
||||
* SiboPay Food & Beverage Vector Icons (SVG)
|
||||
* Iconografía vectorial fina, minimalista y elegante para productos escolares y soda
|
||||
*/
|
||||
|
||||
(function (window) {
|
||||
'use strict';
|
||||
|
||||
const FOOD_ICONS = {
|
||||
'sandwich': {
|
||||
label: 'Sandwich / Panini',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M3 11v3a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1v-3"/><path d="M12 4C7 4 4 7 4 9h16c0-2-3-5-8-5Z"/><path d="M4 18h16a1 1 0 0 0 1-1v-1H3v1a1 1 0 0 0 1 1Z"/><line x1="3" y1="13" x2="21" y2="13"/></svg>'
|
||||
},
|
||||
'croissant': {
|
||||
label: 'Empanada / Repostería',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m4.6 13.4 1.8 1.8a2 2 0 0 0 2.8 0l8.4-8.4a2 2 0 0 0 0-2.8l-1.8-1.8a2 2 0 0 0-2.8 0L4.6 10.6a2 2 0 0 0 0 2.8Z"/><path d="m14.5 9.5-6 6"/><path d="M7 17a5 5 0 0 0 7 7 5 5 0 0 0 7-7"/><path d="M3 13a5 5 0 0 0 7-7"/></svg>'
|
||||
},
|
||||
'utensils': {
|
||||
label: 'Plato Fuerte / Almuerzo',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M18 2v20"/><path d="M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7"/><path d="M6 2v20"/><path d="M3 7V2h6v5a3 3 0 0 1-6 0v0Z"/></svg>'
|
||||
},
|
||||
'cup-soda': {
|
||||
label: 'Bebida / Fresco Natural',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m6 8 1.75 12.28A2 2 0 0 0 9.73 22h4.54a2 2 0 0 0 1.98-1.72L18 8"/><path d="M5 8h14"/><path d="M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0"/><path d="m12 8 1-6h2"/></svg>'
|
||||
},
|
||||
'milk': {
|
||||
label: 'Leche / Lácteos',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2h8"/><path d="M9 2v3a3 3 0 0 1-.88 2.12L7 8.24A4 4 0 0 0 6 11v9a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-9a4 4 0 0 0-1-2.76l-1.12-1.12A3 3 0 0 1 15 5V2"/><line x1="6" y1="15" x2="18" y2="15"/></svg>'
|
||||
},
|
||||
'coffee': {
|
||||
label: 'Café / Infusión Caliente',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M17 8h1a4 4 0 1 1 0 8h-1"/><path d="M3 8h14v9a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4Z"/><line x1="6" y1="2" x2="6" y2="4"/><line x1="10" y1="2" x2="10" y2="4"/><line x1="14" y1="2" x2="14" y2="4"/></svg>'
|
||||
},
|
||||
'apple': {
|
||||
label: 'Fruta / Saludable',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20.94c1.5 0 2.75 1.06 4 1.06 3 0 6-8 6-12.22A4.91 4.91 0 0 0 17 5c-2.22 0-4 1.44-5 2-1-.56-2.78-2-5-2a4.9 4.9 0 0 0-5 4.78C2 14 5 22 8 22c1.25 0 2.5-1.06 4-1.06Z"/><path d="M10 2c1 .5 2 2 2 5"/></svg>'
|
||||
},
|
||||
'bowl': {
|
||||
label: 'Bowl / Ensalada / Sopa',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M4 11h16a1 1 0 0 1 1 1 8 8 0 0 1-16 0 1 1 0 0 1 1-1Z"/><path d="M8 7c0-2 2-3 2-5"/><path d="M12 7c0-2 2-3 2-5"/><path d="M16 7c0-2 2-3 2-5"/></svg>'
|
||||
},
|
||||
'cookie': {
|
||||
label: 'Galleta / Snack',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5"/><circle cx="8.5" cy="8.5" r="0.75" fill="currentColor"/><circle cx="7" cy="13.5" r="0.75" fill="currentColor"/><circle cx="12" cy="16" r="0.75" fill="currentColor"/><circle cx="16.5" cy="13" r="0.75" fill="currentColor"/><circle cx="11.5" cy="11.5" r="0.75" fill="currentColor"/></svg>'
|
||||
},
|
||||
'pizza': {
|
||||
label: 'Pizza / Taco / Rápida',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m12 2-9 18a2.5 2.5 0 0 0 2.2 1.3h13.6a2.5 2.5 0 0 0 2.2-1.3L12 2Z"/><circle cx="12" cy="9.5" r="1" fill="currentColor"/><circle cx="9" cy="15.5" r="1" fill="currentColor"/><circle cx="15" cy="15.5" r="1" fill="currentColor"/></svg>'
|
||||
},
|
||||
'meat': {
|
||||
label: 'Carne / Pollo / Proteína',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m15.4 15.4-3.9 3.9a5.5 5.5 0 1 1-7.8-7.8l3.9-3.9a5.5 5.5 0 0 1 7.8 7.8Z"/><path d="m14 10 4-4"/><circle cx="19" cy="5" r="1.5"/></svg>'
|
||||
},
|
||||
'wheat': {
|
||||
label: 'Cereal / Granola / Avena',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 10-10"/><path d="M16 8a4 4 0 0 0-6 0 4 4 0 0 0 0 6 4 4 0 0 0 6 0 4 4 0 0 0 0-6Z"/><path d="M19 5a4 4 0 0 0-6 0 4 4 0 0 0 0 6 4 4 0 0 0 6 0 4 4 0 0 0 0-6Z"/></svg>'
|
||||
},
|
||||
'ice-cream': {
|
||||
label: 'Postre / Gelatina / Helado',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m7 11 5 11 5-11"/><path d="M12 2a5 5 0 0 0-5 5v4h10V7a5 5 0 0 0-5-5Z"/></svg>'
|
||||
},
|
||||
'store': {
|
||||
label: 'Todos / Menú Completo',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7"/><path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><path d="M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4"/><path d="M2 7h20"/></svg>'
|
||||
}
|
||||
};
|
||||
|
||||
// Mapeo automático de emojis antiguos a iconos SVG elegantes
|
||||
const EMOJI_TO_KEY = {
|
||||
'🥪': 'sandwich',
|
||||
'🥟': 'croissant',
|
||||
'🌮': 'pizza',
|
||||
'🍳': 'utensils',
|
||||
'🍗': 'meat',
|
||||
'🍛': 'utensils',
|
||||
'🍹': 'cup-soda',
|
||||
'🥤': 'cup-soda',
|
||||
'🧃': 'cup-soda',
|
||||
'🥛': 'milk',
|
||||
'🍉': 'apple',
|
||||
'🥣': 'bowl',
|
||||
'🌾': 'wheat',
|
||||
'🍮': 'ice-cream',
|
||||
'🍎': 'apple',
|
||||
'🍕': 'pizza',
|
||||
'🥗': 'bowl',
|
||||
'🍪': 'cookie',
|
||||
'🍽️': 'utensils',
|
||||
'☕': 'coffee',
|
||||
'🥩': 'meat',
|
||||
'🍦': 'ice-cream',
|
||||
'🥑': 'apple',
|
||||
'🥐': 'croissant',
|
||||
'🍞': 'sandwich',
|
||||
'🍔': 'sandwich'
|
||||
};
|
||||
|
||||
/**
|
||||
* Resuelve el identificador de icono SVG a partir de una clave, emoji o nombre de producto
|
||||
*/
|
||||
function resolveIconKey(rawInput, fallbackName) {
|
||||
if (!rawInput && !fallbackName) return 'sandwich';
|
||||
const input = String(rawInput || '').trim();
|
||||
|
||||
// 1. Si coincide directamente con una clave conocida
|
||||
if (FOOD_ICONS[input]) return input;
|
||||
|
||||
// 2. Si coincide con un emoji mapeado
|
||||
if (EMOJI_TO_KEY[input]) return EMOJI_TO_KEY[input];
|
||||
|
||||
// 3. Analizar palabras clave en el nombre del producto
|
||||
const text = (String(fallbackName || '') + ' ' + input).toLowerCase();
|
||||
if (text.includes('empanada') || text.includes('pastel') || text.includes('reposter') || text.includes('croissant')) return 'croissant';
|
||||
if (text.includes('sandwich') || text.includes('emparedado') || text.includes('pan') || text.includes('tostada')) return 'sandwich';
|
||||
if (text.includes('fresco') || text.includes('jugo') || text.includes('te frio') || text.includes('té') || text.includes('gaseosa') || text.includes('bebida') || text.includes('refresco')) return 'cup-soda';
|
||||
if (text.includes('leche') || text.includes('batido')) return 'milk';
|
||||
if (text.includes('cafe') || text.includes('café') || text.includes('chocolate caliente')) return 'coffee';
|
||||
if (text.includes('fruta') || text.includes('manzana') || text.includes('sandia') || text.includes('sandía') || text.includes('pina') || text.includes('piña')) return 'apple';
|
||||
if (text.includes('ensalada') || text.includes('sopa') || text.includes('bowl') || text.includes('yogurt')) return 'bowl';
|
||||
if (text.includes('pinto') || text.includes('casado') || text.includes('almuerzo') || text.includes('arroz') || text.includes('plato')) return 'utensils';
|
||||
if (text.includes('pollo') || text.includes('carne') || text.includes('bistec') || text.includes('chuleta')) return 'meat';
|
||||
if (text.includes('pizza') || text.includes('taco') || text.includes('wrap')) return 'pizza';
|
||||
if (text.includes('galleta') || text.includes('snack') || text.includes('barra') || text.includes('cereal') || text.includes('avena')) return 'cookie';
|
||||
if (text.includes('gelatina') || text.includes('helado') || text.includes('postre') || text.includes('flan')) return 'ice-cream';
|
||||
|
||||
return 'sandwich';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retorna el SVG puro del icono
|
||||
*/
|
||||
function getFoodSvg(rawInput, fallbackName, size = 22) {
|
||||
const key = resolveIconKey(rawInput, fallbackName);
|
||||
const item = FOOD_ICONS[key] || FOOD_ICONS['sandwich'];
|
||||
return item.svg.replace('<svg ', `<svg width="${size}" height="${size}" `);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retorna una insignia circular elegante y limpia con el SVG dentro
|
||||
* variant: 'card' (catálogo POS/PWA 50x50), 'badge' (34x34 para carrito/filas), 'inline' (15x15 para texto)
|
||||
*/
|
||||
function getFoodIconBadge(rawInput, fallbackName, variant = 'card') {
|
||||
const key = resolveIconKey(rawInput, fallbackName);
|
||||
|
||||
if (variant === 'card') {
|
||||
const svg = getFoodSvg(key, null, 24);
|
||||
return `
|
||||
<div class="sibopay-food-badge-card" style="width: 50px; height: 50px; border-radius: 50%; background: #f0f9ff; border: 1.5px solid #bae6fd; color: #0284c7; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.08); flex-shrink: 0; transition: all 0.2s ease;">
|
||||
${svg}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (variant === 'badge') {
|
||||
const svg = getFoodSvg(key, null, 17);
|
||||
return `
|
||||
<div class="sibopay-food-badge-sm" style="width: 34px; height: 34px; border-radius: 9px; background: #f0f9ff; border: 1.2px solid #bae6fd; color: #0284c7; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; margin-right: 8px;">
|
||||
${svg}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (variant === 'inline') {
|
||||
const svg = getFoodSvg(key, null, 15);
|
||||
return `<span style="display: inline-flex; align-items: center; justify-content: center; vertical-align: -2px; color: #0284c7; margin-right: 5px;">${svg}</span>`;
|
||||
}
|
||||
|
||||
return getFoodSvg(key, fallbackName, 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza el selector de iconos finos para los modales de creación/edición de productos
|
||||
*/
|
||||
function renderIconPicker(containerId, inputId, previewId, currentKey) {
|
||||
const container = document.getElementById(containerId);
|
||||
const input = document.getElementById(inputId);
|
||||
const preview = document.getElementById(previewId);
|
||||
if (!container) return;
|
||||
|
||||
const resolved = resolveIconKey(currentKey || (input ? input.value : 'sandwich'));
|
||||
if (input) input.value = resolved;
|
||||
if (preview) preview.innerHTML = getFoodIconBadge(resolved, null, 'card');
|
||||
|
||||
const pickerKeys = [
|
||||
'sandwich', 'croissant', 'utensils', 'cup-soda',
|
||||
'milk', 'coffee', 'apple', 'bowl',
|
||||
'cookie', 'pizza', 'meat', 'ice-cream'
|
||||
];
|
||||
|
||||
container.innerHTML = pickerKeys.map(k => {
|
||||
const isAct = (k === resolved);
|
||||
const svg = getFoodSvg(k, null, 18);
|
||||
const label = FOOD_ICONS[k]?.label || k;
|
||||
return `
|
||||
<button type="button"
|
||||
class="btn-food-icon-picker ${isAct ? 'active' : ''}"
|
||||
id="btnFoodPick_${k}"
|
||||
onclick="window.SiboPayIcons.onPickIcon('${k}', '${containerId}', '${inputId}', '${previewId}')"
|
||||
title="${label}"
|
||||
style="width: 38px; height: 38px; border-radius: 8px; border: 1.5px solid ${isAct ? '#0284c7' : 'var(--border)'}; background: ${isAct ? '#f0f9ff' : 'var(--card-bg)'}; color: ${isAct ? '#0284c7' : 'var(--text-muted)'}; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.15s ease;">
|
||||
${svg}
|
||||
</button>
|
||||
`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function onPickIcon(key, containerId, inputId, previewId) {
|
||||
const input = document.getElementById(inputId);
|
||||
const preview = document.getElementById(previewId);
|
||||
if (input) input.value = key;
|
||||
if (preview) preview.innerHTML = getFoodIconBadge(key, null, 'card');
|
||||
|
||||
const container = document.getElementById(containerId);
|
||||
if (container) {
|
||||
container.querySelectorAll('.btn-food-icon-picker').forEach(b => {
|
||||
b.classList.remove('active');
|
||||
b.style.borderColor = 'var(--border)';
|
||||
b.style.background = 'var(--card-bg)';
|
||||
b.style.color = 'var(--text-muted)';
|
||||
});
|
||||
const activeBtn = document.getElementById(`btnFoodPick_${key}`);
|
||||
if (activeBtn) {
|
||||
activeBtn.classList.add('active');
|
||||
activeBtn.style.borderColor = '#0284c7';
|
||||
activeBtn.style.background = '#f0f9ff';
|
||||
activeBtn.style.color = '#0284c7';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exportar al ámbito global
|
||||
window.SiboPayIcons = {
|
||||
FOOD_ICONS,
|
||||
resolveIconKey,
|
||||
getFoodSvg,
|
||||
getFoodIconBadge,
|
||||
renderIconPicker,
|
||||
onPickIcon
|
||||
};
|
||||
|
||||
})(window);
|
||||
@@ -90,7 +90,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
|
||||
// Registrar Service Worker para Notificaciones PWA
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/sw.js?v=8.5').then(() => {
|
||||
navigator.serviceWorker.register('/sw.js?v=12.2').then((reg) => {
|
||||
reg.update().catch(() => {});
|
||||
if ('Notification' in window && Notification.permission === 'granted') {
|
||||
subscribeDeviceToWebPush().catch(() => {});
|
||||
}
|
||||
@@ -127,6 +128,15 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
};
|
||||
window.addEventListener('click', promptOnFirstInteraction, { once: true });
|
||||
window.addEventListener('touchstart', promptOnFirstInteraction, { once: true });
|
||||
|
||||
// Inicializar preferencia de auto-impresión de ticket térmico
|
||||
const chkAutoPrint = document.getElementById('chkPosAutoPrint');
|
||||
if (chkAutoPrint) {
|
||||
chkAutoPrint.checked = localStorage.getItem('sibopay_pos_autoprint') === '1';
|
||||
chkAutoPrint.addEventListener('change', () => {
|
||||
localStorage.setItem('sibopay_pos_autoprint', chkAutoPrint.checked ? '1' : '0');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Cargar catálogo de productos
|
||||
@@ -157,13 +167,19 @@ async function loadCatalog() {
|
||||
function renderPosCategories() {
|
||||
const bar = document.getElementById('posCategoriesBar');
|
||||
if (!bar) return;
|
||||
const storeIcon = window.SiboPayIcons ? window.SiboPayIcons.getFoodIconBadge('store', 'Todos', 'inline') : '';
|
||||
bar.innerHTML = `
|
||||
<button class="pos-cat-pill active" onclick="filterPosCat(null, this)">Todos</button>
|
||||
${posCategories.map(c => `
|
||||
<button class="pos-cat-pill" onclick="filterPosCat(${c.id}, this)">
|
||||
<span>${c.icono || '🍽️'}</span> ${c.nombre}
|
||||
<button class="pos-cat-pill active" onclick="filterPosCat(null, this)">
|
||||
${storeIcon}Todos
|
||||
</button>
|
||||
`).join('')}
|
||||
${posCategories.map(c => {
|
||||
const catIcon = window.SiboPayIcons ? window.SiboPayIcons.getFoodIconBadge(c.icono, c.nombre, 'inline') : `<span>${c.icono || '🍽️'}</span> `;
|
||||
return `
|
||||
<button class="pos-cat-pill" onclick="filterPosCat(${c.id}, this)">
|
||||
${catIcon}${c.nombre}
|
||||
</button>
|
||||
`;
|
||||
}).join('')}
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -196,7 +212,7 @@ function matchesProduct(prod, query) {
|
||||
}
|
||||
|
||||
// 2. Filtros especiales por palabras clave
|
||||
if (cleanQ === 'mep' || cleanQ === 'saludable') {
|
||||
if (cleanQ === 'saludable' || cleanQ === 'nutritivo') {
|
||||
return Boolean(prod.cumple_mep || prod.es_saludable);
|
||||
}
|
||||
if (cleanQ === 'bloqueado' || cleanQ === 'agotado' || cleanQ === 'sin stock') {
|
||||
@@ -334,15 +350,25 @@ function renderPosProducts(catId) {
|
||||
const isOutOfStock = prod.disponible === 0 || (prod.control_stock === 1 && prod.stock <= 0);
|
||||
const isFirstMatch = hasSearch && idx === 0 && !isOutOfStock;
|
||||
|
||||
const iconBadge = window.SiboPayIcons ? window.SiboPayIcons.getFoodIconBadge(prod.icono, prod.nombre, 'card') : `<div style="font-size: 2.2rem; text-align: center; margin-bottom: 6px;">${prod.icono || '🥪'}</div>`;
|
||||
|
||||
const mediaHtml = prod.imagen_url
|
||||
? `<div style="width: 100%; height: 95px; border-radius: 9px; overflow: hidden; margin-bottom: 8px; background: #f8fafc; border: 1px solid #e2e8f0; position: relative; display: flex; align-items: center; justify-content: center;">
|
||||
<img src="${prod.imagen_url}" alt="${prod.nombre}" style="width: 100%; height: 100%; object-fit: cover; display: block;" onerror="this.style.display='none'; if(this.nextElementSibling) this.nextElementSibling.style.display='flex';">
|
||||
<div style="display: none; width: 100%; height: 100%; align-items: center; justify-content: center;">
|
||||
${iconBadge}
|
||||
</div>
|
||||
</div>`
|
||||
: iconBadge;
|
||||
|
||||
return `
|
||||
<div class="pos-prod-card ${isOutOfStock ? 'out-of-stock-pos' : ''} ${isFirstMatch ? 'search-match-first' : ''}"
|
||||
title="${isFirstMatch ? 'Primer resultado coincidente (pulsa Enter para cobrar)' : ''}"
|
||||
onclick="${isOutOfStock ? `alert('El producto \\'${prod.nombre.replace(/'/g, "\\'")}\\' se encuentra bloqueado o agotado.')` : `addToPosCart(${prod.id})`}">
|
||||
${isOutOfStock ? '<div style="position: absolute; top: 10px; right: 10px;"><span class="saas-status-badge saas-status-blocked"><span class="saas-dot"></span>BLOQUEADO</span></div>' : (isFirstMatch ? '<div style="position: absolute; top: 8px; right: 8px;"><span class="saas-status-badge saas-status-active" style="font-size: 0.65rem; padding: 2px 6px;">Enter ↵</span></div>' : '')}
|
||||
<div style="font-size: 2.2rem; text-align: center; margin-bottom: 6px;">${prod.icono || '🥪'}</div>
|
||||
${mediaHtml}
|
||||
<div>
|
||||
<div class="prod-title">${prod.nombre}</div>
|
||||
${prod.cumple_mep ? '<span style="font-size: 0.68rem; color: #166534; font-weight: 700; margin-top: 3px; display: inline-flex; align-items: center; gap: 3px;">🌿 MEP Saludable</span>' : ''}
|
||||
${isOutOfStock ? '<span style="font-size: 0.68rem; color: #dc2626; display: block; margin-top: 2px; font-weight: 700;">No disponible</span>' : ''}
|
||||
</div>
|
||||
<div class="prod-price" style="color: ${isOutOfStock ? '#94a3b8' : '#0284c7'};">
|
||||
@@ -533,11 +559,17 @@ function updatePosCartUI() {
|
||||
list.innerHTML = posCart.map((item, idx) => {
|
||||
const subtotal = item.product.precio_colones * item.cantidad;
|
||||
total += subtotal;
|
||||
const itemBadge = window.SiboPayIcons
|
||||
? window.SiboPayIcons.getFoodIconBadge(item.product.icono, item.product.nombre, 'badge')
|
||||
: '';
|
||||
return `
|
||||
<div class="pos-cart-item">
|
||||
<div style="flex: 1; min-width: 0; word-break: break-word;">
|
||||
<strong style="color: #0f172a; font-size: 0.88rem; font-weight: 800; display: block; line-height: 1.25;">${item.product.icono ? `<span style="margin-right: 5px; font-size: 1rem;">${item.product.icono}</span>` : ''}${item.product.nombre}</strong>
|
||||
<div style="font-size: 0.74rem; color: #64748b; font-weight: 600; margin-top: 3px;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
|
||||
<div style="display: flex; align-items: center; min-width: 0; flex: 1;">
|
||||
${itemBadge}
|
||||
<div style="min-width: 0; flex: 1; word-break: break-word;">
|
||||
<strong style="color: #0f172a; font-size: 0.88rem; font-weight: 800; display: block; line-height: 1.25;">${item.product.nombre}</strong>
|
||||
<div style="font-size: 0.74rem; color: #64748b; font-weight: 600; margin-top: 2px;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px; flex-shrink: 0;">
|
||||
<button onclick="changePosQty(${idx}, -1)" class="pos-qty-btn" title="Disminuir">−</button>
|
||||
@@ -1024,6 +1056,17 @@ function openPistolaModal(mode = 'cobro') {
|
||||
|
||||
startModalCamera();
|
||||
|
||||
// Notificar al teléfono vinculado que la caja está lista para escanear
|
||||
try {
|
||||
const total = posModalMode === 'cobro' ? posCart.reduce((sum, item) => sum + (item.product.precio_colones * item.cantidad), 0) : 0;
|
||||
const totalItems = posCart.reduce((sum, item) => sum + item.cantidad, 0);
|
||||
fetch('/api/pos/notify-scan-ready', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ mode: posModalMode, total, itemsCount: totalItems })
|
||||
}).catch(() => {});
|
||||
} catch (e) {}
|
||||
|
||||
setTimeout(() => {
|
||||
const input = document.getElementById('inputPistolaDirectScan');
|
||||
if (input) input.focus();
|
||||
@@ -1041,6 +1084,11 @@ function closePistolaModal(e) {
|
||||
// SIEMPRE apagar la cámara de inmediato al salir del modal
|
||||
stopModalCamera();
|
||||
|
||||
// Notificar al teléfono vinculado que la sesión de escaneo terminó
|
||||
try {
|
||||
fetch('/api/pos/notify-scan-cancel', { method: 'POST' }).catch(() => {});
|
||||
} catch (e) {}
|
||||
|
||||
const modal = document.getElementById('modalPistolaCobro');
|
||||
if (modal) modal.style.display = 'none';
|
||||
}
|
||||
@@ -1174,14 +1222,42 @@ async function handlePistolBarcodeScan(rawToken) {
|
||||
window.sounds.playCoin();
|
||||
}
|
||||
|
||||
// Guardar para impresión de comanda / ticket térmico
|
||||
window.lastCompletedOrder = {
|
||||
orderCode: dataCobro.codigo_orden || ('ORD-' + Date.now().toString().slice(-4)),
|
||||
student: {
|
||||
nombre_completo: student.nombre_completo,
|
||||
codigo_estudiante: student.codigo_estudiante,
|
||||
grado: student.grado || student.grado_seccion || ''
|
||||
},
|
||||
items: posCart.map(i => ({
|
||||
nombre: i.product?.nombre || 'Producto',
|
||||
cantidad: i.cantidad || 1,
|
||||
precio: i.product?.precio || 0,
|
||||
subtotal: (i.product?.precio || 0) * (i.cantidad || 1)
|
||||
})),
|
||||
total: totalCompra,
|
||||
nuevoSaldo: nuevoSaldo,
|
||||
fecha: new Date()
|
||||
};
|
||||
|
||||
// Auto-imprimir ticket si está activada la casilla
|
||||
const autoPrintActive = !!document.getElementById('chkPosAutoPrint')?.checked;
|
||||
if (autoPrintActive) {
|
||||
setTimeout(() => {
|
||||
imprimirTicketTermico();
|
||||
}, 350);
|
||||
}
|
||||
|
||||
// Limpiar carrito de mostrador
|
||||
clearPosCart();
|
||||
clearScannedStudent();
|
||||
|
||||
// Auto-cerrar el modal en 2.5 segundos para quedar listo para el siguiente alumno
|
||||
// Auto-cerrar el modal (dar más tiempo si se imprime para no interrumpir el diálogo)
|
||||
const closeDelay = autoPrintActive ? 6000 : 2500;
|
||||
pistolaAutoCloseTimer = setTimeout(() => {
|
||||
closePistolaModal();
|
||||
}, 2500);
|
||||
}, closeDelay);
|
||||
|
||||
} catch (err) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
@@ -1233,6 +1309,241 @@ function switchPosTab(tab) {
|
||||
}
|
||||
}
|
||||
|
||||
let currentPreOrderFilter = 'todos';
|
||||
let cachedPreOrders = [];
|
||||
|
||||
function normalizeMomentoKey(val) {
|
||||
if (!val) return 'recreo_1';
|
||||
const v = String(val).toLowerCase().trim();
|
||||
if (v === 'recreo_1' || v.includes('1er') || v.includes('9:30')) return 'recreo_1';
|
||||
if (v === 'almuerzo' || v.includes('almuerzo') || v.includes('11:45')) return 'almuerzo';
|
||||
if (v === 'recreo_2' || v.includes('2do') || v.includes('1:45')) return 'recreo_2';
|
||||
if (v === 'inmediato' || v.includes('inmediato')) return 'inmediato';
|
||||
return v;
|
||||
}
|
||||
|
||||
function getMomentoBadge(val) {
|
||||
const key = normalizeMomentoKey(val);
|
||||
switch (key) {
|
||||
case 'recreo_1':
|
||||
return {
|
||||
key: 'recreo_1',
|
||||
title: '1er Recreo (9:30 AM)',
|
||||
full: '1er Recreo de la Mañana (9:30 AM)',
|
||||
icon: '🔔',
|
||||
bg: '#fffbeb',
|
||||
border: '#f59e0b',
|
||||
text: '#b45309',
|
||||
badgeBg: '#fef3c7',
|
||||
badgeColor: '#92400e',
|
||||
badgeBorder: '#fde68a'
|
||||
};
|
||||
case 'almuerzo':
|
||||
return {
|
||||
key: 'almuerzo',
|
||||
title: 'Almuerzo (11:45 AM)',
|
||||
full: 'Hora de Almuerzo (11:45 AM)',
|
||||
icon: '🍲',
|
||||
bg: '#f0fdf4',
|
||||
border: '#16a34a',
|
||||
text: '#15803d',
|
||||
badgeBg: '#dcfce7',
|
||||
badgeColor: '#166534',
|
||||
badgeBorder: '#86efac'
|
||||
};
|
||||
case 'recreo_2':
|
||||
return {
|
||||
key: 'recreo_2',
|
||||
title: '2do Recreo (1:45 PM)',
|
||||
full: '2do Recreo de la Tarde (1:45 PM)',
|
||||
icon: '⏰',
|
||||
bg: '#eef2ff',
|
||||
border: '#6366f1',
|
||||
text: '#4338ca',
|
||||
badgeBg: '#e0e7ff',
|
||||
badgeColor: '#3730a3',
|
||||
badgeBorder: '#c7d2fe'
|
||||
};
|
||||
case 'inmediato':
|
||||
return {
|
||||
key: 'inmediato',
|
||||
title: 'Entrega Inmediata',
|
||||
full: 'Entrega Inmediata en Mostrador',
|
||||
icon: '⚡',
|
||||
bg: '#f8fafc',
|
||||
border: '#64748b',
|
||||
text: '#334155',
|
||||
badgeBg: '#f1f5f9',
|
||||
badgeColor: '#334155',
|
||||
badgeBorder: '#cbd5e1'
|
||||
};
|
||||
default:
|
||||
return {
|
||||
key: val || 'otro',
|
||||
title: val || 'Pre-orden',
|
||||
full: val || 'Pre-orden de recreo',
|
||||
icon: '🥪',
|
||||
bg: '#f8fafc',
|
||||
border: '#0284c7',
|
||||
text: '#0369a1',
|
||||
badgeBg: '#e0f2fe',
|
||||
badgeColor: '#0369a1',
|
||||
badgeBorder: '#bae6fd'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function filterPreOrdersByMomento(key) {
|
||||
currentPreOrderFilter = key;
|
||||
renderPreOrdersList();
|
||||
}
|
||||
|
||||
function renderPreOrdersList() {
|
||||
const orders = cachedPreOrders || [];
|
||||
|
||||
// Conteo total de pendientes
|
||||
const pendingOrders = orders.filter(o => o.estado !== 'entregado' && o.estado !== 'cancelado');
|
||||
const countTodosPending = pendingOrders.length;
|
||||
|
||||
const badgeCount = document.getElementById('badgePreordenesCount');
|
||||
if (badgeCount) badgeCount.textContent = countTodosPending;
|
||||
|
||||
// Conteo por cada horario de entrega
|
||||
let countR1 = 0, countAlm = 0, countR2 = 0;
|
||||
pendingOrders.forEach(o => {
|
||||
const k = normalizeMomentoKey(o.momento_entrega);
|
||||
if (k === 'recreo_1') countR1++;
|
||||
else if (k === 'almuerzo') countAlm++;
|
||||
else if (k === 'recreo_2') countR2++;
|
||||
});
|
||||
|
||||
const elTodos = document.getElementById('countFilterTodos');
|
||||
const elR1 = document.getElementById('countFilterRecreo1');
|
||||
const elAlm = document.getElementById('countFilterAlmuerzo');
|
||||
const elR2 = document.getElementById('countFilterRecreo2');
|
||||
if (elTodos) elTodos.textContent = countTodosPending;
|
||||
if (elR1) elR1.textContent = countR1;
|
||||
if (elAlm) elAlm.textContent = countAlm;
|
||||
if (elR2) elR2.textContent = countR2;
|
||||
|
||||
// Actualizar clase activa en los botones de filtro
|
||||
const pillMap = {
|
||||
'todos': 'filterPillTodos',
|
||||
'recreo_1': 'filterPillRecreo_1',
|
||||
'almuerzo': 'filterPillAlmuerzo',
|
||||
'recreo_2': 'filterPillRecreo_2'
|
||||
};
|
||||
Object.keys(pillMap).forEach(k => {
|
||||
const btn = document.getElementById(pillMap[k]);
|
||||
if (btn) btn.classList.toggle('active', currentPreOrderFilter === k);
|
||||
});
|
||||
|
||||
// Filtrar según botón seleccionado
|
||||
let filtered = orders;
|
||||
if (currentPreOrderFilter !== 'todos') {
|
||||
filtered = orders.filter(o => normalizeMomentoKey(o.momento_entrega) === currentPreOrderFilter);
|
||||
}
|
||||
|
||||
const list = document.getElementById('preOrdersList');
|
||||
if (!list) return;
|
||||
|
||||
if (filtered.length === 0) {
|
||||
const filterNames = {
|
||||
'todos': 'para hoy',
|
||||
'recreo_1': 'para el 1er Recreo (9:30 AM)',
|
||||
'almuerzo': 'para el Almuerzo (11:45 AM)',
|
||||
'recreo_2': 'para el 2do Recreo (1:45 PM)'
|
||||
};
|
||||
list.innerHTML = `
|
||||
<div style="text-align: center; color: #64748b; padding: 40px 20px; background: white; border-radius: 14px; border: 1.5px dashed #cbd5e1; margin-top: 4px;">
|
||||
<span style="font-size: 2.2rem; display: block; margin-bottom: 8px;">🥪</span>
|
||||
<strong style="color: #334155; font-size: 0.95rem; display: block;">No hay pre-órdenes registradas ${filterNames[currentPreOrderFilter] || ''}</strong>
|
||||
<p style="font-size: 0.8rem; margin: 4px 0 0 0; color: #94a3b8;">Las órdenes programadas para este horario aparecerán aquí automáticamente.</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
list.innerHTML = filtered.map(ord => {
|
||||
const hora = new Date(ord.creado_en).toLocaleTimeString('es-CR', { hour: '2-digit', minute: '2-digit' });
|
||||
const items = Array.isArray(ord.items) ? ord.items : [];
|
||||
const itemsList = items.map(i => `${i.cantidad}× ${i.nombre}`).join(' • ');
|
||||
const badge = getMomentoBadge(ord.momento_entrega);
|
||||
|
||||
return `
|
||||
<div class="pos-preorder-card" style="border-left: 6px solid ${badge.border};">
|
||||
<!-- Banner Superior de Horario Programado -->
|
||||
<div class="pos-preorder-badge-banner" style="background: ${badge.bg}; border: 1.5px solid ${badge.badgeBorder}; color: ${badge.text};">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span style="font-size: 1.3rem;">${badge.icon}</span>
|
||||
<div>
|
||||
<span style="font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.85; display: block; font-weight: 800;">ALISTAR PARA:</span>
|
||||
<strong style="font-size: 0.96rem; letter-spacing: -0.2px;">${badge.full}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 6px;">
|
||||
${ord.estado === 'entregado'
|
||||
? '<span class="saas-status-badge saas-status-active" style="padding: 4px 10px; font-weight: 800;"><span class="saas-dot"></span>Entregado</span>'
|
||||
: '<span class="saas-status-badge saas-status-pending" style="padding: 4px 10px; background: #fef08a; color: #854d0e; border: 1px solid #fde047; font-weight: 800;"><span class="saas-dot" style="background: #eab308;"></span>Pendiente Alistar</span>'
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pos-preorder-header" style="margin-top: 2px;">
|
||||
<div class="pos-preorder-student">
|
||||
<div class="pos-preorder-avatar" style="display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 0.9rem; background: linear-gradient(135deg, #0284c7, #0369a1); color: #ffffff;">
|
||||
${getStudentInitials(ord.estudiante_nombre)}
|
||||
</div>
|
||||
<div>
|
||||
<div class="pos-preorder-name-row">
|
||||
<strong class="pos-preorder-name">${ord.estudiante_nombre}</strong>
|
||||
<span class="pos-preorder-grade">${ord.grado} • ${ord.seccion}</span>
|
||||
</div>
|
||||
<div class="pos-preorder-ticket-info" style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
|
||||
<span>Ticket: <strong>${ord.codigo_orden}</strong></span>
|
||||
<span>•</span>
|
||||
<span>Pedido: ${hora}</span>
|
||||
<span>•</span>
|
||||
<span style="color: ${badge.text}; font-weight: 800;">Retiro: ${badge.title}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
${ord.notas ? `
|
||||
<div style="background: #fef3c7; border: 1px solid #fde68a; color: #92400e; padding: 6px 10px; border-radius: 8px; font-size: 0.78rem; font-weight: 700;">
|
||||
📝 Nota del pedido: ${ord.notas}
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
<div class="pos-preorder-items-box" style="display: flex; align-items: center; gap: 8px;">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path d="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>
|
||||
<span style="flex: 1; word-break: break-word;">${itemsList}</span>
|
||||
</div>
|
||||
|
||||
<div class="pos-preorder-footer">
|
||||
<div class="pos-preorder-total">
|
||||
<span class="pos-preorder-total-label">Total Cobrado:</span>
|
||||
<strong class="pos-preorder-total-val">₡${ord.total_colones.toLocaleString('es-CR')}</strong>
|
||||
</div>
|
||||
<div>
|
||||
${ord.estado !== 'entregado' ? `
|
||||
<button onclick="updateOrderStatus(${ord.id}, 'entregado')" class="btn-saas pos-btn-entregar" title="Marcar como entregado al estudiante">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg>
|
||||
<span>Entregar Pedido</span>
|
||||
</button>
|
||||
` : `
|
||||
<span class="saas-status-badge saas-status-active" style="padding: 6px 12px; font-size: 0.8rem;">
|
||||
<span class="saas-dot"></span>Despachado en Soda
|
||||
</span>
|
||||
`}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
async function loadPreOrders() {
|
||||
try {
|
||||
const res = await fetch('/api/ordenes?tipo=preorden');
|
||||
@@ -1243,70 +1554,8 @@ async function loadPreOrders() {
|
||||
return;
|
||||
}
|
||||
|
||||
const pendingCount = orders.filter(o => o.estado !== 'entregado' && o.estado !== 'cancelado').length;
|
||||
document.getElementById('badgePreordenesCount').textContent = pendingCount;
|
||||
|
||||
const list = document.getElementById('preOrdersList');
|
||||
if (orders.length === 0) {
|
||||
list.innerHTML = '<p style="text-align: center; color: #64748b; padding: 30px;">No hay pre-órdenes registradas para hoy.</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
list.innerHTML = orders.map(ord => {
|
||||
const hora = new Date(ord.creado_en).toLocaleTimeString('es-CR', { hour: '2-digit', minute: '2-digit' });
|
||||
const items = Array.isArray(ord.items) ? ord.items : [];
|
||||
const itemsList = items.map(i => `${i.cantidad}x ${i.icono || '🥪'} ${i.nombre}`).join(', ');
|
||||
const avatarUrl = ord.foto_url || 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=150';
|
||||
|
||||
return `
|
||||
<div class="pos-preorder-card">
|
||||
<div class="pos-preorder-header">
|
||||
<div class="pos-preorder-student">
|
||||
<div class="pos-preorder-avatar" style="display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 0.9rem; background: linear-gradient(135deg, #0284c7, #0369a1); color: #ffffff;">
|
||||
${getStudentInitials(ord.estudiante_nombre)}
|
||||
</div>
|
||||
<div>
|
||||
<div class="pos-preorder-name-row">
|
||||
<strong class="pos-preorder-name">${ord.estudiante_nombre}</strong>
|
||||
<span class="pos-preorder-grade">${ord.grado} • ${ord.seccion}</span>
|
||||
</div>
|
||||
<div class="pos-preorder-ticket-info">Ticket: ${ord.codigo_orden} • Pedido a las ${hora}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
${ord.estado === 'entregado'
|
||||
? '<span class="saas-status-badge saas-status-active"><span class="saas-dot"></span>Entregado</span>'
|
||||
: '<span class="saas-status-badge saas-status-pending"><span class="saas-dot"></span>Pendiente</span>'
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pos-preorder-items-box">
|
||||
<span>📦</span>
|
||||
<span style="flex: 1; word-break: break-word;">${itemsList}</span>
|
||||
</div>
|
||||
|
||||
<div class="pos-preorder-footer">
|
||||
<div class="pos-preorder-total">
|
||||
<span class="pos-preorder-total-label">Total:</span>
|
||||
<strong class="pos-preorder-total-val">₡${ord.total_colones.toLocaleString('es-CR')}</strong>
|
||||
</div>
|
||||
<div>
|
||||
${ord.estado !== 'entregado' ? `
|
||||
<button onclick="updateOrderStatus(${ord.id}, 'entregado')" class="btn-saas pos-btn-entregar">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg>
|
||||
<span>Entregado</span>
|
||||
</button>
|
||||
` : `
|
||||
<span class="saas-status-badge saas-status-active" style="padding: 6px 12px; font-size: 0.8rem;">
|
||||
<span class="saas-dot"></span>Despachado
|
||||
</span>
|
||||
`}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
cachedPreOrders = orders;
|
||||
renderPreOrdersList();
|
||||
} catch (err) {
|
||||
console.error('Error cargando pre-órdenes:', err);
|
||||
}
|
||||
@@ -1344,8 +1593,9 @@ async function dispatchPreOrderExpress(qrToken) {
|
||||
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
|
||||
const badge = getMomentoBadge(data.orden ? data.orden.momento_entrega : '');
|
||||
const itemsList = (data.orden && Array.isArray(data.orden.items) ? data.orden.items : []).map(i => `• ${i.cantidad}x ${i.nombre}`).join('\n');
|
||||
alert(`¡ENTREGA EXPRESS EXITOSA!\n${data.mensaje}\nAlumno: ${data.estudiante.nombre_completo}\nGrado: ${data.estudiante.grado}\nProductos a entregar:\n${itemsList}`);
|
||||
alert(`¡ENTREGA EXPRESS EXITOSA!\n${data.mensaje}\nAlumno: ${data.estudiante.nombre_completo}\nGrado: ${data.estudiante.grado}\nHorario: ${badge.title}\n\nProductos a entregar:\n${itemsList}`);
|
||||
|
||||
loadPreOrders();
|
||||
} catch (err) {
|
||||
@@ -1353,6 +1603,42 @@ async function dispatchPreOrderExpress(qrToken) {
|
||||
}
|
||||
}
|
||||
|
||||
function showPreOrderIncomingNotification(orden) {
|
||||
const badge = getMomentoBadge(orden.momento_entrega);
|
||||
const container = document.createElement('div');
|
||||
container.className = 'pos-incoming-preorder-toast';
|
||||
container.style.borderLeft = `6px solid ${badge.border}`;
|
||||
|
||||
container.innerHTML = `
|
||||
<div style="font-size: 1.8rem; flex-shrink: 0;">${badge.icon}</div>
|
||||
<div style="flex: 1; min-width: 0;">
|
||||
<div style="display: flex; align-items: center; gap: 6px;">
|
||||
<strong style="color: #0f172a; font-size: 0.92rem;">¡Nueva Pre-orden Recibida!</strong>
|
||||
<span style="background: ${badge.badgeBg}; color: ${badge.badgeColor}; border: 1px solid ${badge.badgeBorder}; padding: 1px 7px; border-radius: 6px; font-size: 0.72rem; font-weight: 800;">
|
||||
${badge.title}
|
||||
</span>
|
||||
</div>
|
||||
<div style="font-size: 0.8rem; color: #475569; margin-top: 2px;">
|
||||
<strong>${orden.estudiante_nombre || 'Estudiante'}</strong> (${orden.grado || ''}) • ₡${(orden.total_colones || 0).toLocaleString('es-CR')}
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" onclick="switchPosTab('preordenes'); this.closest('.pos-incoming-preorder-toast').remove();" class="btn-saas btn-saas-primary" style="padding: 6px 12px; font-size: 0.78rem; border-radius: 8px; flex-shrink: 0;">
|
||||
Ver
|
||||
</button>
|
||||
<button type="button" onclick="this.closest('.pos-incoming-preorder-toast').remove();" style="background: none; border: none; font-size: 1.1rem; color: #94a3b8; cursor: pointer; padding: 4px;">✕</button>
|
||||
`;
|
||||
|
||||
document.body.appendChild(container);
|
||||
setTimeout(() => {
|
||||
if (container.parentNode) {
|
||||
container.style.opacity = '0';
|
||||
container.style.transform = 'translateX(100%)';
|
||||
container.style.transition = 'all 0.3s ease';
|
||||
setTimeout(() => container.remove(), 300);
|
||||
}
|
||||
}, 6000);
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// SSE (SERVER-SENT EVENTS EN TIEMPO REAL)
|
||||
// ==========================================
|
||||
@@ -1361,16 +1647,53 @@ function initSSE() {
|
||||
sseSource = new EventSource('/api/events');
|
||||
|
||||
sseSource.addEventListener('nueva_orden', (e) => {
|
||||
try {
|
||||
const orden = JSON.parse(e.data);
|
||||
if (window.sounds) window.sounds.playSuccess();
|
||||
// Notificación sonora y visual
|
||||
loadPreOrders();
|
||||
if (orden && orden.tipo_orden === 'preorden') {
|
||||
showPreOrderIncomingNotification(orden);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Error en SSE nueva_orden:', err);
|
||||
}
|
||||
});
|
||||
|
||||
sseSource.addEventListener('orden_actualizada', () => {
|
||||
loadPreOrders();
|
||||
});
|
||||
|
||||
// Disparo recibido desde pistola remota (teléfono celular)
|
||||
sseSource.addEventListener('pistola_scan', async (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.data);
|
||||
if (data && data.token) {
|
||||
console.log('📡 [POS] Disparo recibido desde pistola remota (teléfono):', data.token);
|
||||
|
||||
// Feedback visual en la barra superior
|
||||
const badge = document.getElementById('pistolaStatusBadge');
|
||||
if (badge) {
|
||||
const prevHtml = badge.innerHTML;
|
||||
badge.innerHTML = `<span class="saas-dot" style="background: #10b981;"></span> 📱 Disparo: ${data.token}`;
|
||||
badge.style.background = '#dcfce7';
|
||||
badge.style.borderColor = '#86efac';
|
||||
badge.style.color = '#15803d';
|
||||
setTimeout(() => {
|
||||
badge.innerHTML = prevHtml;
|
||||
badge.style.background = '#e0f2fe';
|
||||
badge.style.borderColor = '#bae6fd';
|
||||
badge.style.color = '#0369a1';
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
// Ejecutar procesamiento del carné escaneado
|
||||
await onQrCodeDetected(data.token);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error procesando disparo remoto:', err);
|
||||
}
|
||||
});
|
||||
|
||||
sseSource.addEventListener('producto_actualizado', (e) => {
|
||||
try {
|
||||
const prod = JSON.parse(e.data);
|
||||
@@ -1716,41 +2039,78 @@ async function loadSinpeRequests() {
|
||||
});
|
||||
|
||||
return `
|
||||
<div style="background: #ffffff; border: 1.5px solid #86efac; border-radius: 16px; padding: 14px; box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08); display: flex; flex-direction: column; gap: 12px; width: 100%; box-sizing: border-box;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; width: 100%; box-sizing: border-box;">
|
||||
<div class="sinpe-admin-card" style="background: #ffffff; border: 1.5px solid #86efac; border-radius: 14px; padding: 14px 14px; box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08); display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 100%; box-sizing: border-box; overflow: hidden;">
|
||||
|
||||
<!-- FILA 1: ESTUDIANTE Y MONTO -->
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; box-sizing: border-box;">
|
||||
<div style="display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;">
|
||||
<div style="width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #0284c7, #0369a1); color: #ffffff; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 0.95rem; border: 1.5px solid #bae6fd; flex-shrink: 0; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.15);">
|
||||
<div style="width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, #0284c7, #0369a1); color: #ffffff; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 0.95rem; border: 1.5px solid #bae6fd; flex-shrink: 0; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.15);">
|
||||
${getStudentInitials(s.estudiante_nombre)}
|
||||
</div>
|
||||
<div style="min-width: 0; flex: 1;">
|
||||
<div style="font-weight: 800; font-size: 0.95rem; color: #0f172a; word-break: break-word;">${s.estudiante_nombre}</div>
|
||||
<div style="font-size: 0.74rem; color: #64748b; margin-top: 1px;">
|
||||
${s.estudiante_grado || ''} ${s.estudiante_seccion ? '• Sec. ' + s.estudiante_seccion : ''}
|
||||
<div style="font-weight: 900; font-size: 1rem; color: #0f172a; line-height: 1.2; word-break: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
|
||||
${s.estudiante_nombre}
|
||||
</div>
|
||||
<div style="font-size: 0.70rem; color: #94a3b8; margin-top: 2px;">
|
||||
Reportado: ${fecha}
|
||||
<div style="font-size: 0.75rem; color: #64748b; margin-top: 1px; font-weight: 600;">
|
||||
${s.estudiante_grado || 'Estudiante'} ${s.estudiante_seccion ? '• Sec. ' + s.estudiante_seccion : ''}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="text-align: right; flex-shrink: 0;">
|
||||
<div style="font-size: 1.25rem; font-weight: 900; color: #16a34a; letter-spacing: -0.5px;">
|
||||
<div style="font-size: 1.25rem; font-weight: 900; color: #16a34a; letter-spacing: -0.5px; line-height: 1;">
|
||||
+₡${s.monto_colones.toLocaleString('es-CR')}
|
||||
</div>
|
||||
<div style="font-size: 0.74rem; font-weight: 800; color: #1e293b; background: #f0fdf4; border: 1px solid #bbf7d0; padding: 2px 7px; border-radius: 6px; margin-top: 2px;">
|
||||
Comp: <strong style="font-family: monospace; color: #0284c7;">#${s.comprobante_sinpe}</strong>
|
||||
<div style="display: inline-block; font-size: 0.68rem; font-weight: 800; color: #b45309; background: #fef3c7; border: 1px solid #fde68a; padding: 2px 6px; border-radius: 6px; margin-top: 3px;">
|
||||
⏳ Por Verificar
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; align-items: center; width: 100%; border-top: 1px solid #f1f5f9; padding-top: 10px;">
|
||||
<button onclick="procesarSinpePos(${s.id}, 'rechazar')" style="flex: 1; max-width: 120px; padding: 10px 10px; background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3; border-radius: 10px; font-weight: 800; font-size: 0.82rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 4px;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
||||
<!-- FILA 2: DATOS DEL COMPROBANTE Y DETALLE -->
|
||||
<div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 0.80rem; box-sizing: border-box;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;">
|
||||
<div style="display: flex; align-items: center; gap: 5px;">
|
||||
<span style="color: #64748b; font-weight: 700; font-size: 0.72rem; text-transform: uppercase;">Código:</span>
|
||||
<span style="font-family: monospace; font-size: 0.88rem; font-weight: 900; color: #16a34a; background: #dcfce7; padding: 2px 7px; border-radius: 6px; border: 1px solid #bbf7d0;">
|
||||
${s.codigo_detalle || '-'}
|
||||
</span>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 5px;">
|
||||
<span style="color: #64748b; font-weight: 700; font-size: 0.72rem; text-transform: uppercase;">Saldo:</span>
|
||||
<span style="color: #334155; font-weight: 800; font-size: 0.82rem;">₡${(s.estudiante_saldo || 0).toLocaleString('es-CR')}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px dashed #e2e8f0; padding-top: 5px;">
|
||||
<div style="display: flex; align-items: center; gap: 5px; min-width: 0; flex: 1;">
|
||||
<span style="color: #64748b; font-weight: 700; font-size: 0.72rem; text-transform: uppercase; flex-shrink: 0;">Comp:</span>
|
||||
<span style="font-family: monospace; font-size: 0.80rem; font-weight: 800; color: #0369a1; background: #e0f2fe; padding: 2px 6px; border-radius: 6px; border: 1px solid #bae6fd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
|
||||
#${s.comprobante_sinpe || '-'}
|
||||
</span>
|
||||
</div>
|
||||
<div style="font-size: 0.73rem; color: #64748b; font-weight: 600; flex-shrink: 0;">
|
||||
${fecha}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
${s.notas ? `
|
||||
<div style="font-size: 0.75rem; color: #475569; background: #ffffff; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 5px 10px; display: flex; align-items: center; gap: 6px; box-sizing: border-box; overflow: hidden;">
|
||||
<span style="flex-shrink: 0;">💬</span>
|
||||
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"><strong>Detalle:</strong> ${s.notas}</span>
|
||||
</div>
|
||||
` : ''}
|
||||
|
||||
<!-- FILA 3: BOTONES DE ACCIÓN (RECHAZAR / APROBAR) -->
|
||||
<div style="display: flex; gap: 8px; align-items: center; width: 100%; border-top: 1px solid #f1f5f9; padding-top: 8px; box-sizing: border-box;">
|
||||
<button type="button" onclick="procesarSinpePos(${s.id}, 'rechazar')" style="flex: 0 0 auto; width: 95px; padding: 10px 8px; background: #fff1f2; color: #e11d48; border: 1.5px solid #fecdd3; border-radius: 10px; font-weight: 800; font-size: 0.82rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 4px; box-sizing: border-box; transition: all 0.15s;">
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
||||
<span>Rechazar</span>
|
||||
</button>
|
||||
<button onclick="procesarSinpePos(${s.id}, 'aprobar')" style="flex: 2; padding: 10px 16px; background: linear-gradient(135deg, #16a34a, #15803d); color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg>
|
||||
<span>Aprobar y Acreditar</span>
|
||||
<button type="button" onclick="procesarSinpePos(${s.id}, 'aprobar')" style="flex: 1 1 0; min-width: 0; padding: 10px 8px; background: linear-gradient(135deg, #16a34a, #15803d); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.86rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25); box-sizing: border-box; transition: all 0.15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" style="flex-shrink: 0;"><polyline points="20 6 9 17 4 12"/></svg>
|
||||
<span>Aprobar (+₡${s.monto_colones.toLocaleString('es-CR')})</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1812,3 +2172,160 @@ async function procesarSinpePos(solicitudId, accion) {
|
||||
}
|
||||
}
|
||||
|
||||
function posLogout() {
|
||||
try {
|
||||
localStorage.removeItem('sibopay_token');
|
||||
localStorage.removeItem('sibopay_user');
|
||||
localStorage.removeItem('recreopay_token');
|
||||
localStorage.removeItem('recreopay_user');
|
||||
sessionStorage.clear();
|
||||
} catch (e) {}
|
||||
window.location.href = '/index.html?logout=true';
|
||||
}
|
||||
window.posLogout = posLogout;
|
||||
|
||||
// ==========================================
|
||||
// VINCULACIÓN DE TELÉFONO COMO PISTOLA QR
|
||||
// ==========================================
|
||||
|
||||
function openPhonePairingModal() {
|
||||
const modal = document.getElementById('modalPhonePairing');
|
||||
if (!modal) return;
|
||||
const pistolaUrl = window.location.origin + '/pistola.html';
|
||||
const img = document.getElementById('imgPairingQr');
|
||||
const link = document.getElementById('linkDirectPistola');
|
||||
if (img) img.src = `/api/qr-image/${encodeURIComponent(pistolaUrl)}`;
|
||||
if (link) {
|
||||
link.href = pistolaUrl;
|
||||
}
|
||||
modal.style.display = 'flex';
|
||||
}
|
||||
window.openPhonePairingModal = openPhonePairingModal;
|
||||
|
||||
function closePhonePairingModal(e) {
|
||||
if (e && e.target && e.target.id !== 'modalPhonePairing') return;
|
||||
const modal = document.getElementById('modalPhonePairing');
|
||||
if (modal) modal.style.display = 'none';
|
||||
}
|
||||
window.closePhonePairingModal = closePhonePairingModal;
|
||||
|
||||
function copyPistolaUrl() {
|
||||
const pistolaUrl = window.location.origin + '/pistola.html';
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(pistolaUrl).then(() => {
|
||||
const feedback = document.getElementById('lblCopyPistolaFeedback');
|
||||
if (feedback) {
|
||||
feedback.style.display = 'block';
|
||||
setTimeout(() => { if (feedback) feedback.style.display = 'none'; }, 3000);
|
||||
}
|
||||
}).catch(() => {
|
||||
prompt('Copia este enlace para abrir la pistola en tu teléfono:', pistolaUrl);
|
||||
});
|
||||
} else {
|
||||
prompt('Copia este enlace para abrir la pistola en tu teléfono:', pistolaUrl);
|
||||
}
|
||||
}
|
||||
window.copyPistolaUrl = copyPistolaUrl;
|
||||
|
||||
// ==========================================
|
||||
// IMPRESIÓN DE COMANDA / TICKET TÉRMICO (58mm / 80mm)
|
||||
// ==========================================
|
||||
function escapeHtml(str) {
|
||||
if (!str) return '';
|
||||
return String(str)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function imprimirTicketTermico(orderData) {
|
||||
const ord = orderData || window.lastCompletedOrder;
|
||||
if (!ord) {
|
||||
alert('No hay ninguna venta o comanda reciente para imprimir.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Si el modal está abierto con auto-cierre, pausar o extender el temporizador
|
||||
if (typeof pistolaAutoCloseTimer !== 'undefined' && pistolaAutoCloseTimer) {
|
||||
clearTimeout(pistolaAutoCloseTimer);
|
||||
pistolaAutoCloseTimer = setTimeout(() => {
|
||||
if (typeof closePistolaModal === 'function') closePistolaModal();
|
||||
}, 6000);
|
||||
}
|
||||
|
||||
const container = document.getElementById('posThermalReceipt');
|
||||
if (!container) return;
|
||||
|
||||
const fechaFmt = (ord.fecha ? new Date(ord.fecha) : new Date()).toLocaleString('es-CR', {
|
||||
day: '2-digit', month: '2-digit', year: 'numeric',
|
||||
hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true
|
||||
});
|
||||
|
||||
const itemsRows = (ord.items || []).map(it => {
|
||||
const cant = it.cantidad || 1;
|
||||
const subt = (it.subtotal != null ? it.subtotal : ((it.precio || 0) * cant));
|
||||
return `
|
||||
<tr>
|
||||
<td style="padding: 2px 4px 2px 0; vertical-align: top; width: 26px; font-weight: bold;">${cant}x</td>
|
||||
<td style="padding: 2px 4px; vertical-align: top; word-break: break-word;">${escapeHtml(it.nombre)}</td>
|
||||
<td style="padding: 2px 0 2px 4px; vertical-align: top; text-align: right; white-space: nowrap; font-weight: bold;">₡${Number(subt).toLocaleString('es-CR')}</td>
|
||||
</tr>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
container.innerHTML = `
|
||||
<div style="text-align: center; font-family: 'Courier New', Courier, monospace; font-size: 12px; line-height: 1.25; color: #000; width: 100%; max-width: 80mm; margin: 0 auto; box-sizing: border-box;">
|
||||
<div style="font-size: 15px; font-weight: 900; letter-spacing: 0.5px; margin-bottom: 2px;">SIBOPAY</div>
|
||||
<div style="font-size: 11px; font-weight: bold; text-transform: uppercase; margin-bottom: 4px;">SODA ESCOLAR • COMPROBANTE</div>
|
||||
<div style="border-top: 1px dashed #000; margin: 5px 0;"></div>
|
||||
|
||||
<div style="text-align: left; font-size: 11px; line-height: 1.35;">
|
||||
<div><strong>Fecha:</strong> ${fechaFmt}</div>
|
||||
<div><strong>Ticket:</strong> #${escapeHtml(ord.orderCode)}</div>
|
||||
<div><strong>Estudiante:</strong> ${escapeHtml(ord.student?.nombre_completo || 'Cliente')}</div>
|
||||
${ord.student?.grado ? `<div><strong>Grado:</strong> ${escapeHtml(ord.student.grado)}</div>` : ''}
|
||||
</div>
|
||||
|
||||
<div style="border-top: 1px dashed #000; margin: 5px 0;"></div>
|
||||
|
||||
<table style="width: 100%; font-size: 11px; border-collapse: collapse; text-align: left; margin: 4px 0;">
|
||||
<thead>
|
||||
<tr style="border-bottom: 1px dashed #000;">
|
||||
<th style="padding-bottom: 3px; font-weight: bold;">Cant.</th>
|
||||
<th style="padding-bottom: 3px; font-weight: bold;">Detalle</th>
|
||||
<th style="text-align: right; padding-bottom: 3px; font-weight: bold;">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${itemsRows}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="border-top: 1px dashed #000; margin: 5px 0;"></div>
|
||||
|
||||
<div style="display: flex; justify-content: space-between; font-size: 14px; font-weight: 900; margin: 4px 0;">
|
||||
<span>TOTAL COBRADO:</span>
|
||||
<span>₡${Number(ord.total || 0).toLocaleString('es-CR')}</span>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: space-between; font-size: 11px; margin: 2px 0;">
|
||||
<span>Saldo Disponible:</span>
|
||||
<span style="font-weight: bold;">₡${Number(ord.nuevoSaldo || 0).toLocaleString('es-CR')}</span>
|
||||
</div>
|
||||
|
||||
<div style="border-top: 1px dashed #000; margin: 6px 0;"></div>
|
||||
<div style="text-align: center; font-size: 10px; margin-top: 6px; line-height: 1.3;">
|
||||
¡Gracias por su compra!<br>
|
||||
Monedero Escolar SiboPay
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
window.print();
|
||||
}
|
||||
window.imprimirTicketTermico = imprimirTicketTermico;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,730 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
||||
<title>SiboPay - Pistola Lectora QR Remota</title>
|
||||
<link rel="icon" type="image/png" href="/img/sibopay-emblem.png">
|
||||
<meta name="theme-color" content="#0f172a">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #0f172a;
|
||||
color: #f8fafc;
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
/* Top Bar */
|
||||
.pistola-header {
|
||||
background: #1e293b;
|
||||
border-bottom: 1.5px solid #334155;
|
||||
padding: 12px 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.brand-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.brand-box img {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.brand-box h1 {
|
||||
font-size: 1rem;
|
||||
font-weight: 900;
|
||||
letter-spacing: -0.3px;
|
||||
}
|
||||
|
||||
.brand-box h1 span {
|
||||
color: #38bdf8;
|
||||
}
|
||||
|
||||
.brand-box p {
|
||||
font-size: 0.68rem;
|
||||
color: #94a3b8;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 4px 10px;
|
||||
border-radius: 20px;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 800;
|
||||
background: rgba(16, 185, 129, 0.15);
|
||||
color: #34d399;
|
||||
border: 1px solid rgba(16, 185, 129, 0.4);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.status-badge.connecting {
|
||||
background: rgba(245, 158, 11, 0.15);
|
||||
color: #fbbf24;
|
||||
border-color: rgba(245, 158, 11, 0.4);
|
||||
}
|
||||
|
||||
.status-badge.offline {
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
color: #f87171;
|
||||
border-color: rgba(239, 68, 68, 0.4);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
}
|
||||
|
||||
/* Banner de cobro sincronizado desde la PC */
|
||||
.pos-sync-banner {
|
||||
background: #0284c7;
|
||||
color: #ffffff;
|
||||
padding: 10px 14px;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 800;
|
||||
animation: bannerPulse 1.8s ease-in-out infinite;
|
||||
z-index: 15;
|
||||
}
|
||||
|
||||
@keyframes bannerPulse {
|
||||
0%, 100% { background: #0284c7; }
|
||||
50% { background: #0369a1; }
|
||||
}
|
||||
|
||||
.pos-sync-banner.active {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Visor de Cámara Principal */
|
||||
.scanner-viewport {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
background: #000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#scannerVideo {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
/* Retícula de mira láser */
|
||||
.aiming-reticle {
|
||||
position: absolute;
|
||||
width: 260px;
|
||||
height: 260px;
|
||||
pointer-events: none;
|
||||
box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.55);
|
||||
border-radius: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Esquinas estilizadas */
|
||||
.corner {
|
||||
position: absolute;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-color: #38bdf8;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
.corner.tl { top: 0; left: 0; border-width: 4px 0 0 4px; border-top-left-radius: 20px; }
|
||||
.corner.tr { top: 0; right: 0; border-width: 4px 4px 0 0; border-top-right-radius: 20px; }
|
||||
.corner.bl { bottom: 0; left: 0; border-width: 0 0 4px 4px; border-bottom-left-radius: 20px; }
|
||||
.corner.br { bottom: 0; right: 0; border-width: 0 4px 4px 0; border-bottom-right-radius: 20px; }
|
||||
|
||||
/* Haz de escáner láser rojo / cyan */
|
||||
.laser-beam {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
right: 10px;
|
||||
height: 2.5px;
|
||||
background: #38bdf8;
|
||||
box-shadow: 0 0 14px 2px #38bdf8;
|
||||
border-radius: 2px;
|
||||
animation: laserSweep 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
||||
}
|
||||
|
||||
@keyframes laserSweep {
|
||||
0% { top: 12px; opacity: 0.3; }
|
||||
50% { top: 240px; opacity: 1; }
|
||||
100% { top: 12px; opacity: 0.3; }
|
||||
}
|
||||
|
||||
/* Flash verde de disparo exitoso */
|
||||
.flash-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(16, 185, 129, 0.45);
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
z-index: 30;
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.flash-overlay.active {
|
||||
display: flex;
|
||||
animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
||||
}
|
||||
|
||||
@keyframes popIn {
|
||||
from { opacity: 0; transform: scale(0.95); }
|
||||
to { opacity: 1; transform: scale(1); }
|
||||
}
|
||||
|
||||
.flash-badge {
|
||||
background: #065f46;
|
||||
color: #34d399;
|
||||
border: 2px solid #10b981;
|
||||
padding: 12px 24px;
|
||||
border-radius: 16px;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 900;
|
||||
text-align: center;
|
||||
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
/* Controles de cámara flotantes */
|
||||
.cam-controls {
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
right: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
z-index: 25;
|
||||
}
|
||||
|
||||
.cam-btn {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 50%;
|
||||
background: rgba(15, 23, 42, 0.75);
|
||||
border: 1.5px solid rgba(255, 255, 255, 0.2);
|
||||
color: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
backdrop-filter: blur(6px);
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.cam-btn.active {
|
||||
background: #0284c7;
|
||||
border-color: #38bdf8;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* Barra inferior: Último disparo y botones de prueba */
|
||||
.pistola-footer {
|
||||
background: #1e293b;
|
||||
border-top: 1.5px solid #334155;
|
||||
padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px)) 14px;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.last-shot-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: #0f172a;
|
||||
border: 1px solid #334155;
|
||||
border-radius: 12px;
|
||||
padding: 8px 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.last-shot-title {
|
||||
font-size: 0.68rem;
|
||||
color: #94a3b8;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.last-shot-value {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 900;
|
||||
color: #38bdf8;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.test-shortcuts-row {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.test-btn {
|
||||
flex: 1;
|
||||
min-width: 90px;
|
||||
padding: 8px 10px;
|
||||
background: #334155;
|
||||
color: #f1f5f9;
|
||||
border: 1px solid #475569;
|
||||
border-radius: 10px;
|
||||
font-size: 0.74rem;
|
||||
font-weight: 800;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.test-btn:active {
|
||||
transform: scale(0.96);
|
||||
background: #0284c7;
|
||||
border-color: #38bdf8;
|
||||
}
|
||||
|
||||
/* Mensaje de permiso / error */
|
||||
.cam-error-box {
|
||||
position: absolute;
|
||||
inset: 20px;
|
||||
background: rgba(15, 23, 42, 0.95);
|
||||
border: 1.5px solid #ef4444;
|
||||
border-radius: 18px;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
z-index: 28;
|
||||
}
|
||||
|
||||
.cam-error-box.active {
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- CABECERA -->
|
||||
<header class="pistola-header">
|
||||
<div class="brand-box">
|
||||
<img src="/img/sibopay-emblem.png" alt="SiboPay">
|
||||
<div>
|
||||
<h1>Sibo<span>Pay</span> Handheld</h1>
|
||||
<p>Pistola QR Inalámbrica</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="connectionStatusBadge" class="status-badge connecting">
|
||||
<span class="status-dot"></span>
|
||||
<span id="lblConnectionStatus">Conectando...</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- BANNER COBRO ACTIVO EN PC -->
|
||||
<div id="posChargeBanner" class="pos-sync-banner">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span style="font-size: 1.2rem;">⚡</span>
|
||||
<div>
|
||||
<div style="font-size: 0.72rem; text-transform: uppercase; opacity: 0.9;">Cobro en Caja Listo</div>
|
||||
<div id="lblChargeAmount" style="font-size: 1.05rem; font-weight: 900;">Esperando carné...</div>
|
||||
</div>
|
||||
</div>
|
||||
<span style="background: rgba(255,255,255,0.25); padding: 3px 8px; border-radius: 6px; font-size: 0.7rem;">¡Apunta!</span>
|
||||
</div>
|
||||
|
||||
<!-- VISOR DE CÁMARA CON MIRA LÁSER -->
|
||||
<main class="scanner-viewport">
|
||||
<video id="scannerVideo" playsinline autoplay muted></video>
|
||||
|
||||
<!-- Mira Láser -->
|
||||
<div class="aiming-reticle">
|
||||
<div class="corner tl"></div>
|
||||
<div class="corner tr"></div>
|
||||
<div class="corner bl"></div>
|
||||
<div class="corner br"></div>
|
||||
<div class="laser-beam"></div>
|
||||
</div>
|
||||
|
||||
<!-- Controles flotantes: Linterna y Alternar Cámara -->
|
||||
<div class="cam-controls">
|
||||
<button id="btnToggleTorch" onclick="toggleTorch()" class="cam-btn" title="Encender / Apagar Linterna" style="display: none;">
|
||||
🔦
|
||||
</button>
|
||||
<button onclick="flipCamera()" class="cam-btn" title="Cambiar Cámara">
|
||||
🔄
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Overlay de Disparo Exitoso -->
|
||||
<div id="shotSuccessOverlay" class="flash-overlay">
|
||||
<div class="flash-badge">
|
||||
<div style="font-size: 1.8rem; margin-bottom: 4px;">⚡ BEEP!</div>
|
||||
<div style="font-size: 0.9rem; font-weight: 800; color: #ffffff;">Disparo Enviado a Caja</div>
|
||||
<div id="lblSuccessToken" style="font-size: 0.78rem; opacity: 0.9; margin-top: 4px; font-family: monospace;">QR-MATEO-2026-A891</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Error / Permiso Denegado -->
|
||||
<div id="camErrorBox" class="cam-error-box">
|
||||
<div style="font-size: 2.5rem; margin-bottom: 8px;">📷</div>
|
||||
<h3 style="font-size: 1.1rem; font-weight: 900; margin-bottom: 6px;">Se requiere acceso a la cámara</h3>
|
||||
<p style="font-size: 0.8rem; color: #94a3b8; margin-bottom: 16px;">
|
||||
Para usar tu teléfono como pistola lectora, habilita el permiso de cámara en este navegador.
|
||||
</p>
|
||||
<button onclick="startScannerCamera()" style="padding: 10px 20px; background: #0284c7; color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.85rem; cursor: pointer;">
|
||||
Reintentar Permiso
|
||||
</button>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- PIE DE PÁGINA: ESTADO Y BOTONES DE DISPARO RÁPIDO PARA PRUEBAS -->
|
||||
<footer class="pistola-footer">
|
||||
<div class="last-shot-box">
|
||||
<span class="last-shot-title">Último Disparo:</span>
|
||||
<span id="lblLastShot" class="last-shot-value">Ninguno</span>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 6px; font-size: 0.68rem; color: #94a3b8; font-weight: 700; text-transform: uppercase;">
|
||||
Disparo Rápido para Pruebas:
|
||||
</div>
|
||||
|
||||
<div class="test-shortcuts-row">
|
||||
<button type="button" onclick="sendDirectShot('QR-MATEO-2026-A891')" class="test-btn">
|
||||
🧒 Mateo (8a)
|
||||
</button>
|
||||
<button type="button" onclick="sendDirectShot('QR-SOFIA-2026-B442')" class="test-btn">
|
||||
👧 Sofía (9a)
|
||||
</button>
|
||||
<button type="button" onclick="sendDirectShot('QR-NACHO-2026-D902')" class="test-btn">
|
||||
🧑 Ignacio (14a)
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Librería jsQR para fallback si BarcodeDetector no está presente -->
|
||||
<script src="/js/jsQR.js"></script>
|
||||
|
||||
<script>
|
||||
// Variables de control de cámara y escaneo
|
||||
let videoStream = null;
|
||||
let videoTrack = null;
|
||||
let facingMode = 'environment';
|
||||
let isTorchOn = false;
|
||||
let isScanning = true;
|
||||
let lastScannedToken = null;
|
||||
let lastScannedTime = 0;
|
||||
let sseSource = null;
|
||||
let audioCtx = null;
|
||||
|
||||
// Inicializar Audio Web sintético (beeper de pistola POS)
|
||||
function playLaserBeep() {
|
||||
try {
|
||||
if (!audioCtx) {
|
||||
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||
}
|
||||
if (audioCtx.state === 'suspended') {
|
||||
audioCtx.resume();
|
||||
}
|
||||
const osc = audioCtx.createOscillator();
|
||||
const gain = audioCtx.createGain();
|
||||
|
||||
// Tono agudo característico de pistola lectora de supermercado (2400Hz)
|
||||
osc.type = 'sine';
|
||||
osc.frequency.setValueAtTime(2400, audioCtx.currentTime);
|
||||
gain.gain.setValueAtTime(0.35, audioCtx.currentTime);
|
||||
gain.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + 0.08);
|
||||
|
||||
osc.connect(gain);
|
||||
gain.connect(audioCtx.destination);
|
||||
osc.start();
|
||||
osc.stop(audioCtx.currentTime + 0.08);
|
||||
} catch (e) {
|
||||
console.warn('Audio feedback error:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// Vibración háptica
|
||||
function vibratePhone() {
|
||||
try {
|
||||
if (navigator.vibrate) {
|
||||
navigator.vibrate([70]);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Inicializar Canal SSE con el Servidor
|
||||
function initSSEConnection() {
|
||||
const badge = document.getElementById('connectionStatusBadge');
|
||||
const lbl = document.getElementById('lblConnectionStatus');
|
||||
|
||||
if (sseSource) {
|
||||
sseSource.close();
|
||||
}
|
||||
|
||||
sseSource = new EventSource('/api/events');
|
||||
|
||||
sseSource.onopen = () => {
|
||||
badge.className = 'status-badge';
|
||||
lbl.textContent = 'En Línea • Conectado';
|
||||
};
|
||||
|
||||
sseSource.onerror = () => {
|
||||
badge.className = 'status-badge offline';
|
||||
lbl.textContent = 'Reconectando...';
|
||||
};
|
||||
|
||||
// Escuchar cuando la caja en la PC entra en modo de cobro
|
||||
sseSource.addEventListener('pistola_solicitud_cobro', (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.data);
|
||||
const banner = document.getElementById('posChargeBanner');
|
||||
const lblAmount = document.getElementById('lblChargeAmount');
|
||||
if (banner && lblAmount) {
|
||||
lblAmount.textContent = `₡${Number(data.total || 0).toLocaleString('es-CR')} (${data.itemsCount || 1} ítems)`;
|
||||
banner.classList.add('active');
|
||||
}
|
||||
playLaserBeep();
|
||||
vibratePhone();
|
||||
} catch (err) {}
|
||||
});
|
||||
|
||||
// Escuchar cuando la caja en la PC cancela o cierra el modal
|
||||
sseSource.addEventListener('pistola_cancelar_cobro', () => {
|
||||
const banner = document.getElementById('posChargeBanner');
|
||||
if (banner) banner.classList.remove('active');
|
||||
});
|
||||
}
|
||||
|
||||
// Inicializar Cámara
|
||||
async function startScannerCamera() {
|
||||
const video = document.getElementById('scannerVideo');
|
||||
const errBox = document.getElementById('camErrorBox');
|
||||
const btnTorch = document.getElementById('btnToggleTorch');
|
||||
|
||||
errBox.classList.remove('active');
|
||||
|
||||
if (videoStream) {
|
||||
videoStream.getTracks().forEach(t => t.stop());
|
||||
videoStream = null;
|
||||
}
|
||||
|
||||
try {
|
||||
videoStream = await navigator.mediaDevices.getUserMedia({
|
||||
video: {
|
||||
facingMode: { ideal: facingMode },
|
||||
width: { ideal: 1280 },
|
||||
height: { ideal: 720 }
|
||||
},
|
||||
audio: false
|
||||
});
|
||||
|
||||
video.srcObject = videoStream;
|
||||
await video.play();
|
||||
|
||||
videoTrack = videoStream.getVideoTracks()[0];
|
||||
|
||||
// Verificar soporte de linterna
|
||||
if (videoTrack) {
|
||||
const capabilities = videoTrack.getCapabilities ? videoTrack.getCapabilities() : {};
|
||||
if (capabilities.torch) {
|
||||
btnTorch.style.display = 'flex';
|
||||
} else {
|
||||
btnTorch.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
startDetectionLoop();
|
||||
} catch (err) {
|
||||
console.error('Error cámara:', err);
|
||||
errBox.classList.add('active');
|
||||
}
|
||||
}
|
||||
|
||||
// Alternar linterna
|
||||
async function toggleTorch() {
|
||||
if (!videoTrack) return;
|
||||
try {
|
||||
isTorchOn = !isTorchOn;
|
||||
await videoTrack.applyConstraints({
|
||||
advanced: [{ torch: isTorchOn }]
|
||||
});
|
||||
const btn = document.getElementById('btnToggleTorch');
|
||||
if (btn) btn.classList.toggle('active', isTorchOn);
|
||||
} catch (e) {
|
||||
console.warn('Torch no soportado:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// Cambiar cámara frontal / trasera
|
||||
function flipCamera() {
|
||||
facingMode = (facingMode === 'environment') ? 'user' : 'environment';
|
||||
isTorchOn = false;
|
||||
const btn = document.getElementById('btnToggleTorch');
|
||||
if (btn) btn.classList.remove('active');
|
||||
startScannerCamera();
|
||||
}
|
||||
|
||||
// Detección Ultra-Rápida de Código QR
|
||||
let scanCanvas = null;
|
||||
let scanCtx = null;
|
||||
let barcodeDetector = null;
|
||||
|
||||
if ('BarcodeDetector' in window) {
|
||||
try {
|
||||
barcodeDetector = new BarcodeDetector({ formats: ['qr_code'] });
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function startDetectionLoop() {
|
||||
const video = document.getElementById('scannerVideo');
|
||||
|
||||
async function checkFrame() {
|
||||
if (!isScanning) return;
|
||||
|
||||
if (video && video.readyState >= video.HAVE_CURRENT_DATA) {
|
||||
try {
|
||||
// 1. Intentar con BarcodeDetector nativo (acelerado por hardware)
|
||||
if (barcodeDetector) {
|
||||
const barcodes = await barcodeDetector.detect(video);
|
||||
if (barcodes.length > 0 && barcodes[0].rawValue) {
|
||||
handleScannedCode(barcodes[0].rawValue);
|
||||
}
|
||||
} else if (window.jsQR) {
|
||||
// 2. Fallback a jsQR
|
||||
if (!scanCanvas) {
|
||||
scanCanvas = document.createElement('canvas');
|
||||
scanCtx = scanCanvas.getContext('2d', { willReadFrequently: true });
|
||||
}
|
||||
scanCanvas.width = video.videoWidth;
|
||||
scanCanvas.height = video.videoHeight;
|
||||
scanCtx.drawImage(video, 0, 0, scanCanvas.width, scanCanvas.height);
|
||||
const imgData = scanCtx.getImageData(0, 0, scanCanvas.width, scanCanvas.height);
|
||||
const code = window.jsQR(imgData.data, imgData.width, imgData.height, {
|
||||
inversionAttempts: 'dontInvert'
|
||||
});
|
||||
if (code && code.data) {
|
||||
handleScannedCode(code.data);
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
requestAnimationFrame(checkFrame);
|
||||
}
|
||||
|
||||
requestAnimationFrame(checkFrame);
|
||||
}
|
||||
|
||||
// Procesar Código QR Detectado
|
||||
async function handleScannedCode(rawToken) {
|
||||
if (!rawToken) return;
|
||||
const token = rawToken.trim();
|
||||
const now = Date.now();
|
||||
|
||||
// Cooldown de 2 segundos para evitar disparos duplicados involuntarios
|
||||
if (token === lastScannedToken && (now - lastScannedTime) < 2000) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastScannedToken = token;
|
||||
lastScannedTime = now;
|
||||
|
||||
// Disparar feedback sonoro y háptico
|
||||
playLaserBeep();
|
||||
vibratePhone();
|
||||
|
||||
// Destello visual en pantalla
|
||||
showShotSuccess(token);
|
||||
|
||||
// Enviar disparo a la caja POS
|
||||
sendTokenToPos(token);
|
||||
}
|
||||
|
||||
function showShotSuccess(token) {
|
||||
const overlay = document.getElementById('shotSuccessOverlay');
|
||||
const lbl = document.getElementById('lblSuccessToken');
|
||||
const lblLast = document.getElementById('lblLastShot');
|
||||
|
||||
if (lbl) lbl.textContent = token;
|
||||
if (lblLast) lblLast.textContent = token;
|
||||
|
||||
if (overlay) {
|
||||
overlay.classList.add('active');
|
||||
setTimeout(() => {
|
||||
overlay.classList.remove('active');
|
||||
}, 800);
|
||||
}
|
||||
}
|
||||
|
||||
// Envío por API a la Terminal POS
|
||||
async function sendTokenToPos(token) {
|
||||
try {
|
||||
const res = await fetch('/api/pos/remote-scan', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
token: token,
|
||||
deviceName: navigator.userAgent.includes('iPhone') ? 'iPhone' : 'Android'
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
console.log('📡 Disparo enviado exitosamente a la terminal:', data);
|
||||
} catch (err) {
|
||||
console.error('Error enviando disparo a la terminal:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Botones directos de prueba
|
||||
function sendDirectShot(token) {
|
||||
handleScannedCode(token);
|
||||
}
|
||||
|
||||
// Iniciar todo al cargar
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
initSSEConnection();
|
||||
startScannerCamera();
|
||||
|
||||
// Desbloquear AudioContext al primer toque
|
||||
document.body.addEventListener('click', () => {
|
||||
if (!audioCtx) playLaserBeep();
|
||||
}, { once: true });
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SiboPay POS - Terminal de Mostrador y Despacho</title>
|
||||
<link rel="icon" type="image/png" href="/img/sibopay-emblem.png">
|
||||
<link rel="stylesheet" href="/css/styles.css">
|
||||
<link rel="stylesheet" href="/css/styles.css?v=10.7">
|
||||
<style>
|
||||
/* Estilos específicos de terminal de alta velocidad */
|
||||
.student-badge-scanned {
|
||||
@@ -38,7 +38,51 @@
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* Formateo de impresión para Comanda / Ticket Térmico (58mm / 80mm) */
|
||||
@media print {
|
||||
body * {
|
||||
visibility: hidden !important;
|
||||
}
|
||||
#posThermalReceipt, #posThermalReceipt * {
|
||||
visibility: visible !important;
|
||||
}
|
||||
#posThermalReceipt {
|
||||
position: fixed !important;
|
||||
left: 0 !important;
|
||||
top: 0 !important;
|
||||
width: 100% !important;
|
||||
max-width: 80mm !important;
|
||||
margin: 0 !important;
|
||||
padding: 4mm 2mm !important;
|
||||
font-family: 'Courier New', Courier, monospace !important;
|
||||
font-size: 12px !important;
|
||||
line-height: 1.3 !important;
|
||||
color: #000000 !important;
|
||||
background: #ffffff !important;
|
||||
display: block !important;
|
||||
z-index: 999999 !important;
|
||||
}
|
||||
@page {
|
||||
margin: 0;
|
||||
size: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function posLogout() {
|
||||
try {
|
||||
localStorage.removeItem('sibopay_token');
|
||||
localStorage.removeItem('sibopay_user');
|
||||
localStorage.removeItem('recreopay_token');
|
||||
localStorage.removeItem('recreopay_user');
|
||||
sessionStorage.clear();
|
||||
} catch (e) {}
|
||||
window.location.href = '/index.html?logout=true';
|
||||
}
|
||||
window.posLogout = posLogout;
|
||||
</script>
|
||||
</head>
|
||||
<body class="pos-mobile-view-catalog" style="background: #f8fafc; color: #0f172a;">
|
||||
|
||||
<!-- BANNER DE ADVERTENCIA HTTPS PARA TERMINALES REMOTAS -->
|
||||
@@ -52,10 +96,10 @@
|
||||
<!-- BARRA DE PESTAÑAS MÓVIL (PANTALLAS <= 900px) -->
|
||||
<div class="pos-mobile-nav" id="posMobileNav">
|
||||
<button class="pos-mobile-nav-btn active" id="btnMobileNavCatalog" onclick="switchPosMobileView('catalog')">
|
||||
<span>🥪</span> Catálogo
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block; vertical-align:middle; margin-right:4px;"><rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/></svg> Catálogo
|
||||
</button>
|
||||
<button class="pos-mobile-nav-btn" id="btnMobileNavCheckout" onclick="switchPosMobileView('checkout')">
|
||||
<span>💳</span> Caja / Cobro QR
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block; vertical-align:middle; margin-right:4px;"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg> Caja / Cobro QR
|
||||
<span class="pos-mobile-nav-badge" id="mobileCartBadge" style="display: none;">0</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -63,16 +107,26 @@
|
||||
<div class="pos-layout">
|
||||
<!-- PANEL IZQUIERDO: CATÁLOGO TÁCTIL Y COLA DE PRE-ÓRDENES -->
|
||||
<div class="pos-catalog-pane">
|
||||
<div class="pos-header-card">
|
||||
<div class="pos-header-card" style="display: flex; flex-direction: column; gap: 10px;">
|
||||
<!-- FILA SUPERIOR: MARCA A LA IZQUIERDA Y BOTÓN SALIR ÚNICO ARRIBA A LA DERECHA -->
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-start; width: 100%;">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<img src="/img/sibopay-emblem.png" alt="SiboPay" style="width: 38px; height: 38px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(2, 132, 199, 0.3));">
|
||||
<div>
|
||||
<h1 style="font-size: 1.2rem; font-weight: 800; color: #0f172a; margin: 0;">SiboPay <span style="color: #0284c7;">Terminal Soda</span></h1>
|
||||
<span style="font-size: 0.76rem; color: #64748b;">Soda Escolar • Ventana de Atención Rápida</span>
|
||||
<h1 style="font-size: 1.2rem; font-weight: 800; color: #0f172a; margin: 0; line-height: 1.2;">SiboPay <span style="color: #0284c7;">Terminal Soda</span></h1>
|
||||
<span style="font-size: 0.74rem; color: #64748b;">Soda Escolar • Ventana de Atención Rápida</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
|
||||
<!-- BOTÓN SALIR: COLOCADO ARRIBA A LA DERECHA DE 'TERMINAL SODA' -->
|
||||
<button type="button" onclick="posLogout()" class="btn-saas" style="height: 32px; font-size: 0.82rem; display: inline-flex; align-items: center; gap: 6px; font-weight: 800; cursor: pointer; color: #dc2626; background: #fef2f2; border: 1.5px solid #fecaca; border-radius: 9px; padding: 0 14px; box-shadow: 0 1px 3px rgba(220, 38, 38, 0.08); flex-shrink: 0;" title="Cerrar sesión de la terminal">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
|
||||
<span>Salir</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- FILA DE ESTADO: BADGES Y BOTÓN ADMIN A LA DERECHA DE NOTIFICACIONES -->
|
||||
<div style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
|
||||
<span id="pistolaStatusBadge" class="saas-status-badge" style="background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; font-weight: 700;" title="Pistola lectora USB/Bluetooth lista para escanear en cualquier momento">
|
||||
<span class="saas-dot" style="background: #0284c7;"></span>
|
||||
Pistola QR Conectada
|
||||
@@ -84,30 +138,36 @@
|
||||
<button id="btnPosNotificationToggle" onclick="enablePushNotificationsPrompt()" class="btn-saas btn-saas-outline" style="height: 30px; font-size: 0.76rem; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; color: #0284c7; border-color: #bae6fd;" title="Activar notificaciones de recargas en tiempo real">
|
||||
<span>🔔</span> <span id="lblPosNotificationStatus">Notificaciones</span>
|
||||
</button>
|
||||
<a href="/index.html" class="btn-saas btn-saas-outline" style="height: 30px; font-size: 0.76rem;">
|
||||
<span>👨🍳</span> Admin
|
||||
</a>
|
||||
<a href="/index.html" target="_blank" class="btn-saas btn-saas-outline" style="height: 30px; font-size: 0.76rem; color: #0284c7; border-color: #bae6fd;">
|
||||
<span>📱</span> PWA Estudiante ↗
|
||||
<button type="button" onclick="openPhonePairingModal()" class="btn-saas btn-saas-outline" style="height: 30px; font-size: 0.76rem; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; color: #0284c7; border-color: #bae6fd; font-weight: 700;" title="Vincular tu teléfono celular como pistola lectora QR inalámbrica">
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><line x1="12" y1="18" x2="12.01" y2="18"/></svg>
|
||||
<span>📱 Vincular Celular</span>
|
||||
</button>
|
||||
<a href="/index.html?tab=admin" class="btn-saas btn-saas-outline" style="height: 30px; font-size: 0.76rem; display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: #475569; border-color: #cbd5e1;" title="Ir al Panel de Administración">
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>
|
||||
<span>Admin</span>
|
||||
</a>
|
||||
<label style="display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; font-weight: 700; color: #475569; background: #ffffff; padding: 4px 10px; border-radius: 8px; border: 1.5px solid #cbd5e1; cursor: pointer; user-select: none;" title="Imprimir comanda o ticket térmico automáticamente al finalizar cada cobro">
|
||||
<input type="checkbox" id="chkPosAutoPrint" style="cursor: pointer; width: 14px; height: 14px;">
|
||||
<span>🖨️ Auto-imprimir ticket</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TABS DE MODO DE TERMINAL (RESPONSIVE SIN RECORTES) -->
|
||||
<div class="pos-tabs">
|
||||
<button class="pos-tab-btn active" id="tabBtnMostrador" onclick="switchPosTab('mostrador')">
|
||||
<span class="tab-icon">🛒</span>
|
||||
<span class="tab-icon"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/></svg></span>
|
||||
<span class="tab-label-full">Venta de Mostrador</span>
|
||||
<span class="tab-label-short">Mostrador</span>
|
||||
</button>
|
||||
<button class="pos-tab-btn" id="tabBtnPreordenes" onclick="switchPosTab('preordenes')">
|
||||
<span class="tab-icon">📦</span>
|
||||
<span class="tab-icon"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg></span>
|
||||
<span class="tab-label-full">Fila Rápida Pre-Órdenes</span>
|
||||
<span class="tab-label-short">Pre-Órdenes</span>
|
||||
<span id="badgePreordenesCount" style="background: #ef4444; color: white; padding: 2px 7px; border-radius: 10px; font-size: 0.72rem; font-weight: 800;">0</span>
|
||||
</button>
|
||||
<button class="pos-tab-btn" id="tabBtnSinpe" onclick="switchPosTab('sinpe')">
|
||||
<span class="tab-icon">📱</span>
|
||||
<span class="tab-icon"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg></span>
|
||||
<span class="tab-label-full">Recargas SINPE</span>
|
||||
<span class="tab-label-short">Recargas SINPE</span>
|
||||
<span id="badgeSinpeCount" style="background: #10b981; color: white; padding: 2px 7px; border-radius: 10px; font-size: 0.72rem; font-weight: 800; display: none;">0</span>
|
||||
@@ -127,7 +187,7 @@
|
||||
type="text"
|
||||
id="posProductSearch"
|
||||
class="pos-search-input"
|
||||
placeholder="Buscar por nombre, categoría o precio (ej: empanada, jugo, 1200, mep)..."
|
||||
placeholder="Buscar por nombre, categoría o precio (ej: empanada, jugo, 1200)..."
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
oninput="handlePosSearchInput(this.value)"
|
||||
@@ -181,6 +241,26 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- FILTROS POR RECREO / HORARIO -->
|
||||
<div class="pos-preorder-filter-bar">
|
||||
<button type="button" class="pos-filter-pill active" id="filterPillTodos" onclick="filterPreOrdersByMomento('todos')">
|
||||
<span>📋 Todos los Recreos</span>
|
||||
<span class="pos-pill-count" id="countFilterTodos">0</span>
|
||||
</button>
|
||||
<button type="button" class="pos-filter-pill" id="filterPillRecreo_1" onclick="filterPreOrdersByMomento('recreo_1')">
|
||||
<span>🔔 1er Recreo (9:30 AM)</span>
|
||||
<span class="pos-pill-count" id="countFilterRecreo1">0</span>
|
||||
</button>
|
||||
<button type="button" class="pos-filter-pill" id="filterPillAlmuerzo" onclick="filterPreOrdersByMomento('almuerzo')">
|
||||
<span>🍲 Almuerzo (11:45 AM)</span>
|
||||
<span class="pos-pill-count" id="countFilterAlmuerzo">0</span>
|
||||
</button>
|
||||
<button type="button" class="pos-filter-pill" id="filterPillRecreo_2" onclick="filterPreOrdersByMomento('recreo_2')">
|
||||
<span>⏰ 2do Recreo (1:45 PM)</span>
|
||||
<span class="pos-pill-count" id="countFilterRecreo2">0</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="preOrdersList" style="display: flex; flex-direction: column; gap: 12px;">
|
||||
<!-- Lista de pre-órdenes -->
|
||||
</div>
|
||||
@@ -212,7 +292,9 @@
|
||||
<!-- BARRA FLOTANTE DE ACCESO RÁPIDO A CAJA EN MÓVIL -->
|
||||
<div id="posFloatingCheckoutBar" class="pos-floating-checkout-bar" onclick="switchPosMobileView('checkout')" style="display: none;">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<span style="font-size: 1.3rem;">🛒</span>
|
||||
<div style="width: 36px; height: 36px; border-radius: 50%; background: rgba(56, 189, 248, 0.2); display: flex; align-items: center; justify-content: center; color: #38bdf8;">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/></svg>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-weight: 800; font-size: 0.88rem; color: #ffffff;" id="posFloatingCartText">0 ítems</div>
|
||||
<div style="font-size: 0.72rem; color: #cbd5e1;">Toca para cobrar o escanear QR</div>
|
||||
@@ -390,6 +472,11 @@
|
||||
<strong id="pistolaSuccessBalance" style="color: #16a34a; font-size: 0.95rem;">-</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 10px;">
|
||||
<button type="button" onclick="imprimirTicketTermico()" class="btn-saas btn-saas-outline" style="flex: 1; height: 40px; font-size: 0.86rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: #0284c7; border-color: #bae6fd; background: #f0f9ff;" title="Imprimir ticket para impresora térmica de 58mm o 80mm">
|
||||
<span>🖨️ Imprimir Ticket Térmico</span>
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" onclick="closePistolaModal()" class="btn-saas btn-saas-primary" style="width: 100%; height: 42px; background: #16a34a; border-color: #16a34a; font-size: 0.92rem; font-weight: 800;">
|
||||
Listo / Siguiente Alumno (Enter) ➔
|
||||
</button>
|
||||
@@ -437,7 +524,7 @@
|
||||
<input type="number" id="inputQuickProdPrecio" placeholder="1500" required min="1" step="50" style="width: 100%; padding: 10px 12px 10px 32px; border-radius: 10px; border: 1.5px solid #cbd5e1; background: #f8fafc; color: #0f172a; font-size: 1.1rem; font-weight: 900; box-sizing: border-box; outline: none;">
|
||||
</div>
|
||||
<span style="font-size: 0.72rem; color: #16a34a; margin-top: 6px; display: block; font-weight: 600;">
|
||||
🌿 Sello MEP Saludable asignado automáticamente (sin bloqueo parental)
|
||||
🌿 Alimento saludable asignado automáticamente (sin bloqueo parental)
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -446,15 +533,47 @@
|
||||
Cancelar (Esc)
|
||||
</button>
|
||||
<button type="submit" id="btnSubmitQuickProd" class="btn-saas btn-saas-primary" style="flex: 2; height: 38px; background: #0f172a; border-color: #0f172a; font-size: 0.88rem; font-weight: 800;">
|
||||
<span>💾</span> Guardar y Cobrar ➔
|
||||
<span>Guardar y Cobrar ➔</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL: VINCULAR TELÉFONO COMO PISTOLA QR INALÁMBRICA -->
|
||||
<div class="modal-qr-backdrop" id="modalPhonePairing" style="display: none;" onclick="closePhonePairingModal(event)">
|
||||
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: center; border-radius: 20px; padding: 22px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-bottom: 1px solid var(--border, #e2e8f0); padding-bottom: 8px;">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span style="font-size: 1.3rem;">📱</span>
|
||||
<strong style="font-size: 1.05rem; color: var(--text-main, #0f172a);">Pistola QR en tu Celular</strong>
|
||||
</div>
|
||||
<button type="button" onclick="closePhonePairingModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted, #64748b);">✕</button>
|
||||
</div>
|
||||
<p style="font-size: 0.82rem; color: #64748b; margin-bottom: 14px; line-height: 1.4;">
|
||||
Apunta la cámara de tu teléfono a este código para activarlo como <strong>pistola lectora inalámbrica en tiempo real</strong>. Cualquier carné que escanees con tu celular se cobrará aquí al instante.
|
||||
</p>
|
||||
<div style="background: #ffffff; border: 2px solid #0284c7; border-radius: 16px; padding: 14px; display: inline-block; margin-bottom: 14px; box-shadow: 0 4px 14px rgba(2, 132, 199, 0.15);">
|
||||
<img id="imgPairingQr" src="/api/qr-image/http%3A%2F%2Flocalhost%2Fpistola.html" alt="QR Pistola" style="width: 200px; height: 200px; display: block; border-radius: 8px;">
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; justify-content: center; align-items: center; margin-bottom: 10px; flex-wrap: wrap;">
|
||||
<a id="linkDirectPistola" href="/pistola.html" target="_blank" class="btn-saas btn-saas-outline" style="font-size: 0.78rem; text-decoration: none;">
|
||||
Abrir Pistola en pestaña ↗
|
||||
</a>
|
||||
<button type="button" onclick="copyPistolaUrl()" class="btn-saas btn-saas-primary" style="font-size: 0.78rem;">
|
||||
Copiar Enlace
|
||||
</button>
|
||||
</div>
|
||||
<span id="lblCopyPistolaFeedback" style="font-size: 0.74rem; color: #10b981; font-weight: 800; display: none;">¡Enlace copiado al portapapeles!</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CONTENEDOR DE TICKET TÉRMICO OCULTO EN PANTALLA (VISIBLE EN IMPRESIÓN 58mm / 80mm) -->
|
||||
<div id="posThermalReceipt" style="display: none;"></div>
|
||||
|
||||
<script src="/js/sounds.js?v=8.6"></script>
|
||||
<script src="/js/jsQR.js"></script>
|
||||
<script src="/js/pos.js?v=8.6"></script>
|
||||
<script src="/js/food-icons.js?v=1.1"></script>
|
||||
<script src="/js/pos.js?v=12.0"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
// RecreoPay PWA Service Worker v8.5 - Soporte Web Push VAPID en Segundo Plano
|
||||
const CACHE_NAME = 'recreopay-v8.5';
|
||||
// SiboPay PWA Service Worker v12.2 - Alta Velocidad & Despacho
|
||||
const CACHE_NAME = 'sibopay-v12.2';
|
||||
const STATIC_ASSETS = [
|
||||
'/',
|
||||
'/index.html',
|
||||
'/pos.html',
|
||||
'/pistola.html',
|
||||
'/carnet.html',
|
||||
'/manifest.json',
|
||||
'/css/styles.css',
|
||||
'/css/desktop.css',
|
||||
'/js/app.js',
|
||||
'/js/pos.js',
|
||||
'/js/sounds.js',
|
||||
'/js/food-icons.js',
|
||||
'/icons/icon-192.png',
|
||||
'/icons/icon-512.png'
|
||||
'/icons/icon-512.png',
|
||||
'/img/sibopay-emblem.png',
|
||||
'/apple-touch-icon.png'
|
||||
];
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
@@ -83,18 +88,18 @@ self.addEventListener('push', (event) => {
|
||||
try {
|
||||
data = event.data.json();
|
||||
} catch (e) {
|
||||
data = { title: '🔔 RecreoPay', body: event.data.text() };
|
||||
data = { title: '🔔 SiboPay', body: event.data.text() };
|
||||
}
|
||||
}
|
||||
|
||||
const title = data.title || '🔔 RecreoPay';
|
||||
const title = data.title || '🔔 SiboPay';
|
||||
const options = {
|
||||
body: data.body || 'Tienes una nueva notificación de RecreoPay',
|
||||
body: data.body || 'Tienes una nueva notificación de SiboPay',
|
||||
icon: data.icon || '/icons/icon-192.png',
|
||||
badge: data.badge || '/icons/icon-192.png',
|
||||
vibrate: [250, 100, 250, 100, 250],
|
||||
data: data.data || { url: '/pos.html?tab=sinpe' },
|
||||
tag: data.tag || `recreopay-push-${Date.now()}`,
|
||||
tag: data.tag || `sibopay-push-${Date.now()}`,
|
||||
renotify: true,
|
||||
requireInteraction: true
|
||||
};
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
<!-- ==========================================================================
|
||||
PLANTILLA DE RESPALDO: DISEÑO DE LOGIN CLÁSICO CON ROLES (PADRE / ESTUDIANTE / PERSONAL)
|
||||
Guardado: 07-Oct-2026
|
||||
Para reactivar este diseño en el futuro, copia este bloque en #viewLogin dentro de public/index.html
|
||||
========================================================================== -->
|
||||
|
||||
<div id="viewLoginClassicCard" class="login-card">
|
||||
<div class="login-brand">
|
||||
<div class="login-logo" style="margin-bottom: 6px;">
|
||||
<img src="/img/sibopay-emblem.png" alt="SiboPay Logo" style="width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(2, 132, 199, 0.3)); display: inline-block;">
|
||||
</div>
|
||||
<h1 class="login-title" style="margin: 0; font-size: 1.85rem; font-weight: 900; letter-spacing: -0.5px;">Sibo<strong style="color: #0284c7;">Pay</strong></h1>
|
||||
<p class="login-subtitle">Sistema Digital de Pagos y Monedero Estudiantil</p>
|
||||
</div>
|
||||
|
||||
<!-- SELECTOR ENTRE INICIO DE SESIÓN Y REGISTRO -->
|
||||
<div class="login-tabs">
|
||||
<button type="button" class="login-tab-btn active" id="tabBtnLogin" onclick="switchLoginTab('login')" style="display: inline-flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" x2="3" y1="12" y2="12"/></svg>
|
||||
<span>Iniciar Sesión</span>
|
||||
</button>
|
||||
<button type="button" class="login-tab-btn" id="tabBtnRegister" onclick="switchLoginTab('register')" style="display: inline-flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="7" r="3.5"/><path d="M3 20v-1.5A4.5 4.5 0 0 1 7.5 14h3A4.5 4.5 0 0 1 15 18.5V20"/><circle cx="17.5" cy="7.5" r="2.5"/><path d="M15 14a3.5 3.5 0 0 1 5.5 3v3"/></svg>
|
||||
<span>Registro de Padres</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- FORMULARIO 1: INICIAR SESIÓN CON SELECTOR DE ROL -->
|
||||
<form id="formLogin" onsubmit="handleLoginSubmit(event)">
|
||||
<div class="login-role-selector-wrap">
|
||||
<label style="font-size: 0.74rem; font-weight: 900; color: #475569; text-transform: uppercase; letter-spacing: 0.6px; display: block; margin-bottom: 8px;">¿Quién eres?</label>
|
||||
<div class="login-role-grid">
|
||||
<div onclick="selectLoginRole('padre')" id="loginRoleCardPadre" class="login-role-card selected">
|
||||
<div class="login-role-icon">
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="9" cy="7" r="3.5"/>
|
||||
<path d="M3 20v-1.5A4.5 4.5 0 0 1 7.5 14h3A4.5 4.5 0 0 1 15 18.5V20"/>
|
||||
<circle cx="17.5" cy="7.5" r="2.5"/>
|
||||
<path d="M15 14a3.5 3.5 0 0 1 5.5 3v3"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="login-role-name">Padre</span>
|
||||
<span class="login-role-desc">o Encargado</span>
|
||||
</div>
|
||||
|
||||
<div onclick="selectLoginRole('estudiante')" id="loginRoleCardEstudiante" class="login-role-card">
|
||||
<div class="login-role-icon">
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1-2.5-2.5Z"/>
|
||||
<path d="M6 6h10"/>
|
||||
<path d="M6 10h10"/>
|
||||
<circle cx="12" cy="15" r="2"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="login-role-name">Estudiante</span>
|
||||
<span class="login-role-desc">Carné QR</span>
|
||||
</div>
|
||||
|
||||
<div onclick="selectLoginRole('personal')" id="loginRoleCardPersonal" class="login-role-card">
|
||||
<div class="login-role-icon">
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M6 13.8V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v9.8"/>
|
||||
<path d="M4 13.8h16a1 1 0 0 1 1 1V20a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5.2a1 1 0 0 1 1-1Z"/>
|
||||
<line x1="10" y1="18" x2="14" y2="18"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="login-role-name">Personal</span>
|
||||
<span class="login-role-desc">Soda / Caja</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label id="lblLoginUser" for="loginUsername">Usuario o Teléfono del Padre:</label>
|
||||
<input type="text" id="loginUsername" class="login-input" placeholder="Ej: padre, carlos_papa o 8888-1122" required autocomplete="username">
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label id="lblLoginPass" for="loginPassword">Contraseña:</label>
|
||||
<input type="password" id="loginPassword" class="login-input" placeholder="••••••••" required autocomplete="current-password">
|
||||
</div>
|
||||
|
||||
<div id="loginErrorMsg" style="display: none; background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 8px 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 700; margin-bottom: 12px; text-align: center;"></div>
|
||||
|
||||
<button type="submit" id="btnLoginSubmit" class="login-submit-btn" style="display: flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" x2="3" y1="12" y2="12"/></svg>
|
||||
<span id="lblBtnLoginText">Ingresar como Padre / Encargado</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- FORMULARIO 2: REGISTRO DE NUEVOS PADRES -->
|
||||
<form id="formRegisterPadre" onsubmit="handleRegisterPadreSubmit(event)" style="display: none;">
|
||||
<div style="background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); border: 1.5px solid #bae6fd; border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.08);">
|
||||
<div style="width: 44px; height: 44px; border-radius: 12px; background: white; border: 1.5px solid #bae6fd; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 2px 8px rgba(2, 132, 199, 0.12); padding: 5px;">
|
||||
<img src="/img/sibopay-emblem.png" alt="SiboPay" style="width: 100%; height: 100%; object-fit: contain;">
|
||||
</div>
|
||||
<div>
|
||||
<strong style="color: #0369a1; font-size: 0.92rem; display: block; font-weight: 800; letter-spacing: -0.2px;">Registro de Padres o Encargados</strong>
|
||||
<span style="font-size: 0.74rem; color: #475569; line-height: 1.35; display: block; margin-top: 2px;">Crea tu cuenta oficial en SiboPay para vincular a tus hijos y recargarles saldo escolar.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label for="regNombre">Nombre y Apellidos:</label>
|
||||
<input type="text" id="regNombre" class="login-input" placeholder="Ej: Carlos Alvarado Castro" required autocomplete="name">
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label for="regTelefono">Teléfono o Celular (para SINPE):</label>
|
||||
<input type="tel" id="regTelefono" class="login-input" placeholder="Ej: 8888-1122" required autocomplete="tel">
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label for="regEmail">Correo Electrónico <span style="font-size: 0.75rem; font-weight: 600; color: #64748b;">(Opcional)</span>:</label>
|
||||
<input type="email" id="regEmail" class="login-input" placeholder="Ej: [email protected]" autocomplete="email">
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label for="regUsername">Nombre de Usuario:</label>
|
||||
<input type="text" id="regUsername" class="login-input" placeholder="Ej: carlos_papa" required autocomplete="username">
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label for="regPassword">Contraseña:</label>
|
||||
<input type="password" id="regPassword" class="login-input" placeholder="Mínimo 4 caracteres" required autocomplete="new-password">
|
||||
</div>
|
||||
|
||||
<div id="registerErrorMsg" style="display: none; background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 8px 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 700; margin-bottom: 12px; text-align: center;"></div>
|
||||
|
||||
<button type="submit" id="btnRegisterSubmit" class="login-submit-btn" style="display: flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="7" r="3.5"/><path d="M3 20v-1.5A4.5 4.5 0 0 1 7.5 14h3A4.5 4.5 0 0 1 15 18.5V20"/><circle cx="17.5" cy="7.5" r="2.5"/><path d="M15 14a3.5 3.5 0 0 1 5.5 3v3"/></svg>
|
||||
<span>Crear Cuenta de Padre y Entrar</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- ACCESOS RÁPIDOS DE PRUEBA (1-CLICK DEMO) -->
|
||||
<div class="login-demo-box">
|
||||
<div class="login-demo-title">Accesos Rápidos de Prueba:</div>
|
||||
<div class="login-demo-btns">
|
||||
<button type="button" class="login-demo-btn" onclick="quickFillLogin('dev', 'dev123')" style="border: 1.5px solid #0284c7; background: #f0f9ff;">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
|
||||
<span style="color: #0284c7; font-weight: 800;">Developer</span>
|
||||
</button>
|
||||
<button type="button" class="login-demo-btn" onclick="quickFillLogin('admin', 'admin123')">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>
|
||||
<span>Admin Soda</span>
|
||||
</button>
|
||||
<button type="button" class="login-demo-btn" onclick="quickFillLogin('cajero', 'cajero123')">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg>
|
||||
<span>Cajero</span>
|
||||
</button>
|
||||
<button type="button" class="login-demo-btn" onclick="quickFillLogin('padre', 'padre123')">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
|
||||
<span>Padre</span>
|
||||
</button>
|
||||
<button type="button" class="login-demo-btn" onclick="quickFillLogin('mateo', '1234')">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
|
||||
<span>Mateo (2°)</span>
|
||||
</button>
|
||||
<button type="button" class="login-demo-btn" onclick="quickFillLogin('sofia', '1234')">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
|
||||
<span>Sofía (3°)</span>
|
||||
</button>
|
||||
</div>
|
||||
<div style="text-align: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid #f1f5f9;">
|
||||
<a href="/" style="display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 800; color: #0284c7; text-decoration: none; padding: 6px 14px; border-radius: 9999px; background: #e0f2fe; transition: all 0.2s;">
|
||||
<span>🌐 Ver Presentación Web de SiboPay ↗</span>
|
||||
</a>
|
||||
<p style="font-size: 0.72rem; color: #64748b; margin-top: 14px; line-height: 1.45;">
|
||||
Al iniciar sesión o registrarte, aceptas nuestros
|
||||
<a href="/terminos" target="_blank" style="color: #0284c7; font-weight: 700; text-decoration: underline;">Términos y Condiciones</a>
|
||||
y nuestra
|
||||
<a href="/privacidad" target="_blank" style="color: #0284c7; font-weight: 700; text-decoration: underline;">Política de Privacidad</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,37 @@
|
||||
# Catálogo de Pantallas de Inicio de Sesión de SiboPay
|
||||
|
||||
Este documento actúa como la **memoria y registro de versiones** de pantallas de inicio de sesión de SiboPay. Cada diseño está preservado en código para que pueda ser reactivado cuando el administrador o el usuario lo solicite.
|
||||
|
||||
---
|
||||
|
||||
## 🎨 Opción 1: Clásico con Selector de Roles (Padre, Estudiante, Personal)
|
||||
- **Archivo de Respaldo:** `public/templates/login-classic-roles.html`
|
||||
- **Estilo:** Tarjeta flotante central sobre fondo neutro con efecto blur.
|
||||
- **Características:**
|
||||
- Selector de pestaña superior: "Iniciar Sesión" y "Registro de Padres".
|
||||
- Selector visual interactivo "¿Quién eres?":
|
||||
- **Padre o Encargado** (ícono de familia)
|
||||
- **Estudiante Carné QR** (ícono de libreta/carné)
|
||||
- **Personal Soda / Caja** (ícono de local de comida/caja)
|
||||
- Formularios dinámicos que cambian placeholders y etiquetas según el rol seleccionado.
|
||||
- Accesos rápidos demo de 1-clic integrados en la tarjeta.
|
||||
- **Cómo restaurarlo:**
|
||||
Reemplazar el contenido de `<div id="viewLogin">` en `public/index.html` con el código almacenado en `public/templates/login-classic-roles.html`.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Opción 2: Minimalista Splash & Bottom Sheet (Estilo OrderEAT / SiboPay)
|
||||
- **Archivo de Implementación:** `public/index.html` (dentro de `#viewLogin`)
|
||||
- **Estilo:** Pantalla completa en degradado celeste oficial (`#0284c7` a `#0369a1`) con marca de agua difuminada de siluetas de comida (ollas, brócoli, manzanas, cubiertos).
|
||||
- **Características:**
|
||||
- Emblema central de SiboPay con aura translúcida y título blanco de alta legibilidad.
|
||||
- Eslogan institucional "Sistema Digital de Pagos y Monedero Estudiantil".
|
||||
- Botón principal tipo píldora blanca sólida: **"Iniciar Sesión"**.
|
||||
- Botón secundario translúcido con borde blanco: **"Registrarse"**.
|
||||
- Al pie absoluto de la pantalla: Enlace a **Términos y Condiciones** que abre un modal emergente rápido.
|
||||
- **Interacción fluida (Bottom Sheet):** Al presionar Iniciar Sesión o Registrarse, se despliega suavemente desde abajo una ventana moderna con los formularios, sin tapar abruptamente la identidad visual de la aplicación.
|
||||
- El sistema detecta el rol automáticamente al validar credenciales contra `/api/auth/login`.
|
||||
|
||||
---
|
||||
|
||||
*Fecha de registro: 07 de Octubre de 2026*
|
||||
@@ -0,0 +1,167 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SiboPay - Inicio de Sesión Clásico con Roles</title>
|
||||
<link rel="icon" type="image/png" href="/img/sibopay-emblem.png">
|
||||
<link rel="stylesheet" href="/css/styles.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
|
||||
background: radial-gradient(circle at 50% 10%, #0284c7 0%, #0f172a 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.login-overlay {
|
||||
position: relative !important;
|
||||
background: none !important;
|
||||
padding: 20px !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="login-overlay">
|
||||
<div id="viewLoginClassicCard" class="login-card">
|
||||
<div class="login-brand">
|
||||
<div class="login-logo" style="margin-bottom: 6px;">
|
||||
<img src="/img/sibopay-emblem.png" alt="SiboPay Logo" style="width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(2, 132, 199, 0.3)); display: inline-block;">
|
||||
</div>
|
||||
<h1 class="login-title" style="margin: 0; font-size: 1.85rem; font-weight: 900; letter-spacing: -0.5px;">Sibo<strong style="color: #0284c7;">Pay</strong></h1>
|
||||
<p class="login-subtitle">Sistema Digital de Pagos y Monedero Estudiantil</p>
|
||||
</div>
|
||||
|
||||
<!-- SELECTOR ENTRE INICIO DE SESIÓN Y REGISTRO -->
|
||||
<div class="login-tabs">
|
||||
<button type="button" class="login-tab-btn active" id="tabBtnLogin" onclick="switchLoginTab('login')" style="display: inline-flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" x2="3" y1="12" y2="12"/></svg>
|
||||
<span>Iniciar Sesión</span>
|
||||
</button>
|
||||
<button type="button" class="login-tab-btn" id="tabBtnRegister" onclick="switchLoginTab('register')" style="display: inline-flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="7" r="3.5"/><path d="M3 20v-1.5A4.5 4.5 0 0 1 7.5 14h3A4.5 4.5 0 0 1 15 18.5V20"/><circle cx="17.5" cy="7.5" r="2.5"/><path d="M15 14a3.5 3.5 0 0 1 5.5 3v3"/></svg>
|
||||
<span>Registro de Padres</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- FORMULARIO 1: INICIAR SESIÓN CON SELECTOR DE ROL -->
|
||||
<form id="formLogin" onsubmit="event.preventDefault()">
|
||||
<div class="login-role-selector-wrap">
|
||||
<label style="font-size: 0.74rem; font-weight: 900; color: #475569; text-transform: uppercase; letter-spacing: 0.6px; display: block; margin-bottom: 8px;">¿Quién eres?</label>
|
||||
<div class="login-role-grid">
|
||||
<div onclick="selectLoginRole('padre')" id="loginRoleCardPadre" class="login-role-card selected">
|
||||
<div class="login-role-icon">
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="9" cy="7" r="3.5"/>
|
||||
<path d="M3 20v-1.5A4.5 4.5 0 0 1 7.5 14h3A4.5 4.5 0 0 1 15 18.5V20"/>
|
||||
<circle cx="17.5" cy="7.5" r="2.5"/>
|
||||
<path d="M15 14a3.5 3.5 0 0 1 5.5 3v3"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="login-role-name">Padre</span>
|
||||
<span class="login-role-desc">o Encargado</span>
|
||||
</div>
|
||||
|
||||
<div onclick="selectLoginRole('estudiante')" id="loginRoleCardEstudiante" class="login-role-card">
|
||||
<div class="login-role-icon">
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1-2.5-2.5Z"/>
|
||||
<path d="M6 6h10"/>
|
||||
<path d="M6 10h10"/>
|
||||
<circle cx="12" cy="15" r="2"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="login-role-name">Estudiante</span>
|
||||
<span class="login-role-desc">Carné QR</span>
|
||||
</div>
|
||||
|
||||
<div onclick="selectLoginRole('personal')" id="loginRoleCardPersonal" class="login-role-card">
|
||||
<div class="login-role-icon">
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M6 13.8V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v9.8"/>
|
||||
<path d="M4 13.8h16a1 1 0 0 1 1 1V20a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5.2a1 1 0 0 1 1-1Z"/>
|
||||
<line x1="10" y1="18" x2="14" y2="18"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="login-role-name">Personal</span>
|
||||
<span class="login-role-desc">Soda / Cocina</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label id="lblLoginUser" for="loginUsername">Usuario o Teléfono del Padre:</label>
|
||||
<input type="text" id="loginUsername" class="login-input" placeholder="Ej: padre, carlos_papa o 8888-1122" value="padre">
|
||||
</div>
|
||||
|
||||
<div class="login-form-group">
|
||||
<label id="lblLoginPass" for="loginPassword">Contraseña:</label>
|
||||
<input type="password" id="loginPassword" class="login-input" placeholder="••••••••" value="••••••••">
|
||||
</div>
|
||||
|
||||
<button type="submit" id="btnLoginSubmit" class="login-submit-btn" style="display: flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" x2="3" y1="12" y2="12"/></svg>
|
||||
<span id="lblBtnLoginText">Ingresar como Padre / Encargado</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- ACCESOS RÁPIDOS DE PRUEBA (1-CLICK DEMO) -->
|
||||
<div class="login-demo-box">
|
||||
<div class="login-demo-title">Accesos Rápidos de Prueba:</div>
|
||||
<div class="login-demo-btns">
|
||||
<button type="button" class="login-demo-btn" style="border: 1.5px solid #0284c7; background: #f0f9ff;">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
|
||||
<span style="color: #0284c7; font-weight: 800;">Developer</span>
|
||||
</button>
|
||||
<button type="button" class="login-demo-btn">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>
|
||||
<span>Admin Soda</span>
|
||||
</button>
|
||||
<button type="button" class="login-demo-btn">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg>
|
||||
<span>Cajero</span>
|
||||
</button>
|
||||
<button type="button" class="login-demo-btn">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
|
||||
<span>Padre</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function selectLoginRole(role) {
|
||||
document.getElementById('loginRoleCardPadre').classList.toggle('selected', role === 'padre');
|
||||
document.getElementById('loginRoleCardEstudiante').classList.toggle('selected', role === 'estudiante');
|
||||
document.getElementById('loginRoleCardPersonal').classList.toggle('selected', role === 'personal');
|
||||
|
||||
const lblUser = document.getElementById('lblLoginUser');
|
||||
const inputUser = document.getElementById('loginUsername');
|
||||
const btnText = document.getElementById('lblBtnLoginText');
|
||||
|
||||
if (role === 'estudiante') {
|
||||
lblUser.textContent = 'Carné o Código de Estudiante:';
|
||||
inputUser.placeholder = 'Ej: EST-2026-00001';
|
||||
btnText.textContent = 'Ingresar como Estudiante';
|
||||
} else if (role === 'personal') {
|
||||
lblUser.textContent = 'Usuario de Personal / Cocina:';
|
||||
inputUser.placeholder = 'Ej: cocina, cajero, soda';
|
||||
btnText.textContent = 'Ingresar al Personal de Soda / Cocina';
|
||||
} else {
|
||||
lblUser.textContent = 'Usuario o Teléfono del Padre:';
|
||||
inputUser.placeholder = 'Ej: padre, 8888-1122';
|
||||
btnText.textContent = 'Ingresar como Padre / Encargado';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 472 KiB |
|
After Width: | Height: | Size: 178 KiB |
|
After Width: | Height: | Size: 426 KiB |
|
After Width: | Height: | Size: 328 KiB |
|
After Width: | Height: | Size: 333 KiB |
|
After Width: | Height: | Size: 574 KiB |
|
After Width: | Height: | Size: 565 KiB |
|
After Width: | Height: | Size: 369 KiB |
|
After Width: | Height: | Size: 724 KiB |
|
After Width: | Height: | Size: 364 KiB |
|
After Width: | Height: | Size: 231 KiB |
|
After Width: | Height: | Size: 947 KiB |
|
After Width: | Height: | Size: 402 KiB |
|
After Width: | Height: | Size: 404 KiB |
|
After Width: | Height: | Size: 273 KiB |
|
After Width: | Height: | Size: 383 KiB |
|
After Width: | Height: | Size: 262 KiB |
|
After Width: | Height: | Size: 741 KiB |
|
After Width: | Height: | Size: 377 KiB |
|
After Width: | Height: | Size: 234 KiB |
|
After Width: | Height: | Size: 974 KiB |
|
After Width: | Height: | Size: 417 KiB |
|
After Width: | Height: | Size: 419 KiB |
|
After Width: | Height: | Size: 290 KiB |
|
After Width: | Height: | Size: 410 KiB |
|
After Width: | Height: | Size: 279 KiB |
|
After Width: | Height: | Size: 648 KiB |
|
After Width: | Height: | Size: 620 KiB |
|
After Width: | Height: | Size: 290 KiB |
|
After Width: | Height: | Size: 208 KiB |
|
After Width: | Height: | Size: 924 KiB |
|
After Width: | Height: | Size: 355 KiB |
|
After Width: | Height: | Size: 357 KiB |
|
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 281 KiB |
|
After Width: | Height: | Size: 224 KiB |
|
After Width: | Height: | Size: 415 KiB |
|
After Width: | Height: | Size: 428 KiB |
|
After Width: | Height: | Size: 425 KiB |
@@ -0,0 +1,52 @@
|
||||
const { Client } = require('pg');
|
||||
|
||||
const pgUrl = process.env.DATABASE_URL || 'postgresql://postgres:[email protected]:5432/recreopay_db';
|
||||
|
||||
const MAPPING = [
|
||||
{ match: /empanada.*arreglada/i, url: '/img/products/empanada_arreglada.jpg' },
|
||||
{ match: /empanada.*queso/i, url: '/img/products/empanada_queso.jpg' },
|
||||
{ match: /sandwich/i, url: '/img/products/sandwich_jamon_queso.jpg' },
|
||||
{ match: /taco.*tico/i, url: '/img/products/taco_tico.jpg' },
|
||||
{ match: /gallo.*pinto/i, url: '/img/products/gallo_pinto.jpg' },
|
||||
{ match: /arroz.*pollo/i, url: '/img/products/arroz_con_pollo.jpg' },
|
||||
{ match: /casad/i, url: '/img/products/casadito_infantil.jpg' },
|
||||
{ match: /t[eé]\s*fr[ií]o/i, url: '/img/products/te_frio_limon.jpg' },
|
||||
{ match: /mora/i, url: '/img/products/fresco_mora.jpg' },
|
||||
{ match: /\bcas\b/i, url: '/img/products/fresco_cas.jpg' },
|
||||
{ match: /leche.*chocolate/i, url: '/img/products/leche_chocolate.jpg' },
|
||||
{ match: /fruta.*picada/i, url: '/img/products/fruta_picada.jpg' },
|
||||
{ match: /yogurt/i, url: '/img/products/yogurt_granola.jpg' },
|
||||
{ match: /barra.*avena/i, url: '/img/products/barra_avena.jpg' },
|
||||
{ match: /gelatina/i, url: '/img/products/gelatina_tricolor.jpg' },
|
||||
];
|
||||
|
||||
async function assignImages() {
|
||||
const client = new Client({ connectionString: pgUrl });
|
||||
await client.connect();
|
||||
console.log('🚀 Conectado a la base de datos PostgreSQL.');
|
||||
|
||||
const res = await client.query('SELECT id, nombre FROM productos ORDER BY id ASC;');
|
||||
console.log(`Encontrados ${res.rows.length} productos en la base de datos.`);
|
||||
|
||||
for (const prod of res.rows) {
|
||||
let chosenUrl = null;
|
||||
for (const rule of MAPPING) {
|
||||
if (rule.match.test(prod.nombre)) {
|
||||
chosenUrl = rule.url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (chosenUrl) {
|
||||
await client.query('UPDATE productos SET imagen_url = $1 WHERE id = $2;', [chosenUrl, prod.id]);
|
||||
console.log(`✅ [ID ${prod.id}] "${prod.nombre}" -> ${chosenUrl}`);
|
||||
} else {
|
||||
console.warn(`⚠️ [ID ${prod.id}] "${prod.nombre}" no tuvo coincidencia de imagen.`);
|
||||
}
|
||||
}
|
||||
|
||||
await client.end();
|
||||
console.log('✨ Asignación de imágenes completada y verificada.');
|
||||
}
|
||||
|
||||
assignImages().catch(console.error);
|
||||
@@ -0,0 +1,45 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const puppeteer = require('puppeteer-core');
|
||||
|
||||
const CHROME_PATH = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe';
|
||||
const PREVIEW_URL = 'http://localhost:3030/templates/preview-login-clasico.html';
|
||||
const OUT_DIR = path.join(__dirname, '../screenshots/login_clasico_roles');
|
||||
|
||||
async function run() {
|
||||
if (!fs.existsSync(OUT_DIR)) fs.mkdirSync(OUT_DIR, { recursive: true });
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
executablePath: CHROME_PATH,
|
||||
headless: 'new',
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
||||
});
|
||||
|
||||
const page = await browser.newPage();
|
||||
|
||||
// 1. Captura en resolución móvil moderna (1080 x 2400 px)
|
||||
await page.setViewport({ width: 360, height: 800, deviceScaleFactor: 3 });
|
||||
await page.goto(PREVIEW_URL, { waitUntil: 'networkidle2' });
|
||||
const outMobile = path.join(OUT_DIR, 'Login_Clasico_Roles_Padre_Estudiante_Personal.png');
|
||||
await page.screenshot({ path: outMobile, type: 'png' });
|
||||
console.log('✓ Guardado screenshot móvil:', outMobile);
|
||||
|
||||
// 2. Captura con rol Estudiante seleccionado
|
||||
await page.evaluate(() => selectLoginRole('estudiante'));
|
||||
await new Promise(r => setTimeout(r, 400));
|
||||
const outEstudiante = path.join(OUT_DIR, 'Login_Clasico_Rol_Estudiante.png');
|
||||
await page.screenshot({ path: outEstudiante, type: 'png' });
|
||||
console.log('✓ Guardado screenshot estudiante:', outEstudiante);
|
||||
|
||||
// 3. Captura con rol Personal de cocina seleccionado
|
||||
await page.evaluate(() => selectLoginRole('personal'));
|
||||
await new Promise(r => setTimeout(r, 400));
|
||||
const outPersonal = path.join(OUT_DIR, 'Login_Clasico_Rol_Personal_Cocina.png');
|
||||
await page.screenshot({ path: outPersonal, type: 'png' });
|
||||
console.log('✓ Guardado screenshot personal cocina:', outPersonal);
|
||||
|
||||
await browser.close();
|
||||
console.log('¡Capturas del inicio de sesión clásico generadas con éxito!');
|
||||
}
|
||||
|
||||
run().catch(console.error);
|
||||
@@ -0,0 +1,12 @@
|
||||
const { Client } = require('pg');
|
||||
const pgUrl = process.env.DATABASE_URL || 'postgresql://postgres:[email protected]:5432/recreopay_db';
|
||||
|
||||
async function run() {
|
||||
const client = new Client({ connectionString: pgUrl });
|
||||
await client.connect();
|
||||
const res = await client.query("UPDATE productos SET alergenos = NULL WHERE alergenos ILIKE '%ninguno%' OR alergenos ILIKE '%no%' OR TRIM(alergenos) = '';");
|
||||
console.log(`✅ Alérgenos limpiados: ${res.rowCount} filas actualizadas a NULL.`);
|
||||
await client.end();
|
||||
}
|
||||
|
||||
run().catch(console.error);
|
||||
@@ -0,0 +1,264 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const puppeteer = require('puppeteer-core');
|
||||
|
||||
const CHROME_PATH = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe';
|
||||
const APP_URL = 'http://localhost:3030/app';
|
||||
const POS_URL = 'http://localhost:3030/pos.html';
|
||||
|
||||
const BASE_OUT_DIR = path.join(__dirname, '../screenshots');
|
||||
|
||||
// Especificaciones oficiales exigidas por Apple App Store Connect y Google Play Console
|
||||
const PRESETS = [
|
||||
{
|
||||
name: 'apple_app_store/iphone_6_7_inch',
|
||||
description: 'iPhone 6.7" (iPhone 16 / 15 / 14 Pro Max) - 1290 x 2796 px',
|
||||
width: 430,
|
||||
height: 932,
|
||||
scale: 3,
|
||||
expectedRes: '1290 x 2796'
|
||||
},
|
||||
{
|
||||
name: 'apple_app_store/iphone_6_5_inch',
|
||||
description: 'iPhone 6.5" (iPhone 11 Pro Max / XS Max / XR) - 1242 x 2688 px',
|
||||
width: 414,
|
||||
height: 896,
|
||||
scale: 3,
|
||||
expectedRes: '1242 x 2688'
|
||||
},
|
||||
{
|
||||
name: 'google_play_store/phone_1080x2400',
|
||||
description: 'Android Phone Google Play (FHD+ 20:9) - 1080 x 2400 px',
|
||||
width: 360,
|
||||
height: 800,
|
||||
scale: 3,
|
||||
expectedRes: '1080 x 2400'
|
||||
},
|
||||
{
|
||||
name: 'apple_app_store/ipad_pro_12_9_inch',
|
||||
description: 'iPad Pro 12.9" (App Store Tablet) - 2048 x 2732 px',
|
||||
width: 1024,
|
||||
height: 1366,
|
||||
scale: 2,
|
||||
expectedRes: '2048 x 2732'
|
||||
}
|
||||
];
|
||||
|
||||
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
||||
|
||||
// Sanitización y anonimización de nombres reales para screenshots oficiales de tiendas
|
||||
async function anonymizeNamesInPage(page) {
|
||||
await page.evaluate(() => {
|
||||
const walkTextNodes = (root) => {
|
||||
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null, false);
|
||||
let node;
|
||||
while ((node = walker.nextNode())) {
|
||||
if (!node.nodeValue) continue;
|
||||
let txt = node.nodeValue;
|
||||
txt = txt.replace(/Mateo Alvarado Castro/gi, 'Nombre del Estudiante');
|
||||
txt = txt.replace(/Mateo Castro Alvarado/gi, 'Nombre del Estudiante');
|
||||
txt = txt.replace(/Carlos Alvarado \(Papá\)/gi, 'Nombre de los Padres');
|
||||
txt = txt.replace(/Carlos Alvarado/gi, 'Nombre del Padre');
|
||||
txt = txt.replace(/QR-MATEO-/gi, 'QR-ESTUDIANTE-');
|
||||
if (txt !== node.nodeValue) {
|
||||
node.nodeValue = txt;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 1. Reemplazos globales en todos los nodos de texto
|
||||
walkTextNodes(document.body);
|
||||
|
||||
// 2. Tarjeta del Estudiante en Menú Principal
|
||||
const walletName = document.getElementById('walletName');
|
||||
if (walletName) walletName.textContent = 'Nombre del Estudiante';
|
||||
|
||||
const walletAvatar = document.getElementById('walletAvatar');
|
||||
if (walletAvatar) walletAvatar.textContent = 'NE';
|
||||
|
||||
// 3. Modal de Carné QR
|
||||
const qrCardTitle = document.querySelector('.qr-card-header-title');
|
||||
if (qrCardTitle) {
|
||||
let sub = document.getElementById('qrStudentNameHeader');
|
||||
if (!sub) {
|
||||
sub = document.createElement('div');
|
||||
sub.id = 'qrStudentNameHeader';
|
||||
sub.style.cssText = 'font-size: 0.95rem; font-weight: 800; color: #0284c7; margin-top: 4px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;';
|
||||
qrCardTitle.parentNode.insertBefore(sub, qrCardTitle.nextSibling);
|
||||
}
|
||||
sub.textContent = 'Nombre del Estudiante';
|
||||
}
|
||||
|
||||
const qrToken = document.getElementById('qrTokenDisplay');
|
||||
if (qrToken) {
|
||||
qrToken.textContent = qrToken.textContent.replace(/MATEO/g, 'ESTUDIANTE');
|
||||
}
|
||||
|
||||
// 4. Portal de Padres: Cabecera
|
||||
const parentLoggedName = document.getElementById('parentLoggedName');
|
||||
if (parentLoggedName) {
|
||||
parentLoggedName.textContent = 'Nombre de los Padres (Padre/Madre)';
|
||||
}
|
||||
|
||||
// 5. Portal de Padres: Estudiante seleccionado
|
||||
const parentActiveChildName = document.getElementById('parentActiveChildName');
|
||||
if (parentActiveChildName) {
|
||||
parentActiveChildName.textContent = 'Nombre del Estudiante';
|
||||
}
|
||||
|
||||
// 6. Portal de Padres: Fichas de Hijos e iniciales
|
||||
document.querySelectorAll('#viewPadres div, #viewPadres span, #viewPadres strong, #viewPadres h4').forEach(el => {
|
||||
if (el.children.length === 0 && el.textContent.trim() === 'MA') {
|
||||
el.textContent = 'NE';
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('#parentHijosList > div, .parent-child-card').forEach(card => {
|
||||
const strong = card.querySelector('strong');
|
||||
if (strong && (strong.textContent.includes('Mateo') || strong.textContent.includes('Alvarado'))) {
|
||||
strong.textContent = 'Nombre del Estudiante';
|
||||
}
|
||||
});
|
||||
|
||||
// 7. Subvista SINPE Móvil
|
||||
const sinpeBanner = document.querySelector('#parentSubViewSinpe');
|
||||
if (sinpeBanner) {
|
||||
walkTextNodes(sinpeBanner);
|
||||
sinpeBanner.querySelectorAll('div, span, button').forEach(el => {
|
||||
if (el.textContent.trim() === 'MA') el.textContent = 'NE';
|
||||
});
|
||||
}
|
||||
|
||||
// Pasada final de seguridad
|
||||
walkTextNodes(document.body);
|
||||
});
|
||||
}
|
||||
|
||||
async function captureScreen(page, outPath) {
|
||||
const dir = path.dirname(outPath);
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||
await page.screenshot({ path: outPath, type: 'png' });
|
||||
const buf = fs.readFileSync(outPath);
|
||||
const w = buf.readUInt32BE(16);
|
||||
const h = buf.readUInt32BE(20);
|
||||
const kb = Math.round(buf.length / 1024);
|
||||
console.log(` ✓ Guardado: ${path.basename(outPath)} (${w}x${h} px, ${kb} KB)`);
|
||||
}
|
||||
|
||||
async function run() {
|
||||
console.log('========================================================================');
|
||||
console.log('📸 GENERADOR DE SCREENSHOTS OFICIALES ANONIMIZADOS (APPLE & GOOGLE STORE)');
|
||||
console.log('========================================================================\n');
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
executablePath: CHROME_PATH,
|
||||
headless: 'new',
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox', '--hide-scrollbars']
|
||||
});
|
||||
|
||||
for (const preset of PRESETS) {
|
||||
console.log(`\n📱 Procesando preset: ${preset.description}`);
|
||||
const outDir = path.join(BASE_OUT_DIR, preset.name);
|
||||
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
|
||||
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({
|
||||
width: preset.width,
|
||||
height: preset.height,
|
||||
deviceScaleFactor: preset.scale
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 1. PANTALLA DE BIENVENIDA / SPLASH LOGIN
|
||||
// -------------------------------------------------------------
|
||||
await page.goto(APP_URL, { waitUntil: 'networkidle2' });
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
await page.reload({ waitUntil: 'networkidle2' });
|
||||
await sleep(700);
|
||||
await anonymizeNamesInPage(page);
|
||||
await captureScreen(page, path.join(outDir, '01_Bienvenida_Login_SiboPay.png'));
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 2. MODAL INFERIOR (BOTTOM SHEET) INICIO DE SESIÓN
|
||||
// -------------------------------------------------------------
|
||||
await page.evaluate(() => {
|
||||
if (typeof openLoginSheet === 'function') openLoginSheet('login');
|
||||
});
|
||||
await sleep(600);
|
||||
await anonymizeNamesInPage(page);
|
||||
await captureScreen(page, path.join(outDir, '02_Acceso_Seguro_BottomSheet.png'));
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 3. MONEDERO ESTUDIANTIL & CARNÉ QR (ANONIMIZADO)
|
||||
// -------------------------------------------------------------
|
||||
await page.evaluate(async () => {
|
||||
document.getElementById('loginUsername').value = 'mateo';
|
||||
document.getElementById('loginPassword').value = '1234';
|
||||
await handleLoginSubmit();
|
||||
});
|
||||
await sleep(1500);
|
||||
|
||||
// Abrir Modal de Carné QR
|
||||
await page.evaluate(() => {
|
||||
if (typeof openQrModal === 'function') openQrModal();
|
||||
});
|
||||
await sleep(800);
|
||||
await anonymizeNamesInPage(page);
|
||||
await captureScreen(page, path.join(outDir, '03_Carne_Digital_QR_Estudiante.png'));
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 4. CATÁLOGO DE LA SODA ESCOLAR & PRODUCTOS (ANONIMIZADO)
|
||||
// -------------------------------------------------------------
|
||||
await page.evaluate(() => {
|
||||
if (typeof closeQrModal === 'function') closeQrModal();
|
||||
});
|
||||
await sleep(600);
|
||||
await anonymizeNamesInPage(page);
|
||||
await captureScreen(page, path.join(outDir, '04_Catalogo_Soda_Escolar.png'));
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 5. PORTAL PARENTAL (MONITOREO DE HIJOS Y SALDOS ANONIMIZADOS)
|
||||
// -------------------------------------------------------------
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
await page.reload({ waitUntil: 'networkidle2' });
|
||||
await page.evaluate(async () => {
|
||||
document.getElementById('loginUsername').value = 'padre';
|
||||
document.getElementById('loginPassword').value = 'padre123';
|
||||
await handleLoginSubmit();
|
||||
});
|
||||
await sleep(1800);
|
||||
await anonymizeNamesInPage(page);
|
||||
await captureScreen(page, path.join(outDir, '05_Portal_Padres_Monitoreo.png'));
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 6. RECARGA OFICIAL POR SINPE MÓVIL (ANONIMIZADO)
|
||||
// -------------------------------------------------------------
|
||||
await page.evaluate(() => {
|
||||
if (typeof openParentSubView === 'function') openParentSubView('sinpe');
|
||||
});
|
||||
await sleep(800);
|
||||
await anonymizeNamesInPage(page);
|
||||
await captureScreen(page, path.join(outDir, '06_Recarga_SINPE_Movil.png'));
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 7. TERMINAL POS Y CAJA RÁPIDA DE LA SODA ESCOLAR
|
||||
// -------------------------------------------------------------
|
||||
await page.goto(POS_URL, { waitUntil: 'networkidle2' });
|
||||
await sleep(1200);
|
||||
await anonymizeNamesInPage(page);
|
||||
await captureScreen(page, path.join(outDir, '07_Terminal_POS_Caja_Soda.png'));
|
||||
|
||||
await page.close();
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
console.log('\n========================================================================');
|
||||
console.log('🎉 ¡TODOS LOS SCREENSHOTS ANONIMIZADOS FUERON GENERADOS CON ÉXITO!');
|
||||
console.log(`📁 Carpeta principal: ${BASE_OUT_DIR}`);
|
||||
console.log('========================================================================\n');
|
||||
}
|
||||
|
||||
run().catch(err => {
|
||||
console.error('Error fatal durante la generación de screenshots:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
const db = require('../server/db');
|
||||
|
||||
try {
|
||||
db.db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS escuelas (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
codigo TEXT UNIQUE NOT NULL,
|
||||
nombre TEXT NOT NULL,
|
||||
telefono_sinpe TEXT DEFAULT '8888-8888',
|
||||
nombre_sinpe TEXT DEFAULT 'Soda Central',
|
||||
concesionario TEXT,
|
||||
activo INTEGER DEFAULT 1,
|
||||
creado_en DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
INSERT OR IGNORE INTO escuelas (id, codigo, nombre, telefono_sinpe, nombre_sinpe, concesionario, activo)
|
||||
VALUES (1, 'ESC01', 'Soda Escolar Central', '8888-8888', 'Soda Central', 'Concesionario Central', 1);
|
||||
`);
|
||||
|
||||
// Column additions if missing
|
||||
const cols = [
|
||||
{ table: 'estudiantes', col: 'escuela_id', type: 'INTEGER DEFAULT 1' },
|
||||
{ table: 'productos', col: 'escuela_id', type: 'INTEGER DEFAULT 1' },
|
||||
{ table: 'ordenes', col: 'escuela_id', type: 'INTEGER DEFAULT 1' },
|
||||
{ table: 'usuarios', col: 'escuela_id', type: 'INTEGER DEFAULT 1' },
|
||||
{ table: 'solicitudes_recarga_sinpe', col: 'escuela_id', type: 'INTEGER DEFAULT 1' }
|
||||
];
|
||||
|
||||
for (const c of cols) {
|
||||
try {
|
||||
db.db.exec(`ALTER TABLE ${c.table} ADD COLUMN ${c.col} ${c.type};`);
|
||||
} catch (e) {
|
||||
// Column might already exist
|
||||
}
|
||||
}
|
||||
|
||||
console.log('SQLite local database migration completed successfully!');
|
||||
} catch (err) {
|
||||
console.error('Migration error:', err);
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
const { Client } = require('pg');
|
||||
|
||||
const pgUrl = process.env.DATABASE_URL || 'postgresql://postgres:[email protected]:5432/recreopay_db';
|
||||
|
||||
const NEW_PRODUCTS = [
|
||||
// --- 10 COMIDAS Y SNACKS ---
|
||||
{
|
||||
categoria_id: 1, // Meriendas Saludables
|
||||
nombre: 'Chalupa de Pollo Mechado',
|
||||
descripcion: 'Tortilla de maíz tostada con frijoles molidos, pollo mechado, repollo fresco y salsa rosada.',
|
||||
precio_colones: 1400,
|
||||
imagen_url: '/img/products/chalupa_pollo.jpg',
|
||||
icono: 'utensils',
|
||||
alergenos: 'Ninguno'
|
||||
},
|
||||
{
|
||||
categoria_id: 1, // Meriendas Saludables
|
||||
nombre: 'Quesadilla de Queso y Frijol',
|
||||
descripcion: 'Tortilla de trigo dorada a la plancha con abundante queso blanco fundido y frijoles negros.',
|
||||
precio_colones: 1100,
|
||||
imagen_url: '/img/products/quesadilla_queso_frijol.jpg',
|
||||
icono: 'sandwich',
|
||||
alergenos: 'Lácteos, Gluten'
|
||||
},
|
||||
{
|
||||
categoria_id: 2, // Platos Fuertes y Pintos
|
||||
nombre: 'Pinto con Huevo y Salchicha',
|
||||
descripcion: 'Gallo pinto tradicional con huevo revuelto fresco y salchicha criolla en rodajas.',
|
||||
precio_colones: 1500,
|
||||
imagen_url: '/img/products/pinto_huevo_salchicha.jpg',
|
||||
icono: 'utensils',
|
||||
alergenos: 'Huevo'
|
||||
},
|
||||
{
|
||||
categoria_id: 2, // Platos Fuertes y Pintos
|
||||
nombre: 'Casado con Pechuga a la Plancha',
|
||||
descripcion: 'Pechuga a la plancha con arroz blanco, frijoles negros, plátano maduro y ensalada fresca.',
|
||||
precio_colones: 2200,
|
||||
imagen_url: '/img/products/casado_pollo_plancha.jpg',
|
||||
icono: 'utensils',
|
||||
alergenos: 'Ninguno'
|
||||
},
|
||||
{
|
||||
categoria_id: 1, // Meriendas Saludables
|
||||
nombre: 'Pastelito de Pollo Hojaldrado',
|
||||
descripcion: 'Pastel horneado de hojaldre crujiente relleno de pechuga de pollo desmenuzada y verduras.',
|
||||
precio_colones: 950,
|
||||
imagen_url: '/img/products/pastel_pollo_hojaldre.jpg',
|
||||
icono: 'croissant',
|
||||
alergenos: 'Gluten'
|
||||
},
|
||||
{
|
||||
categoria_id: 1, // Meriendas Saludables
|
||||
nombre: 'Pan con Aguacate y Huevo Duro',
|
||||
descripcion: 'Pan tostado integral con aguacate majado, huevo duro en rodajas y toque de sal.',
|
||||
precio_colones: 1200,
|
||||
imagen_url: '/img/products/pan_aguacate_huevo.jpg',
|
||||
icono: 'sandwich',
|
||||
alergenos: 'Huevo, Gluten'
|
||||
},
|
||||
{
|
||||
categoria_id: 4, // Frutas y Snacks
|
||||
nombre: 'Dedos de Queso Horneados',
|
||||
descripcion: 'Palitos suaves horneados rellenos de queso blanco tierno, servidos con salsa de tomate.',
|
||||
precio_colones: 1000,
|
||||
imagen_url: '/img/products/dedos_queso_horneados.jpg',
|
||||
icono: 'cookie',
|
||||
alergenos: 'Lácteos, Gluten'
|
||||
},
|
||||
{
|
||||
categoria_id: 4, // Frutas y Snacks
|
||||
nombre: 'Muffin Casero de Zanahoria',
|
||||
descripcion: 'Muffin esponjoso horneado con zanahoria fresca rallada, canela y pasas.',
|
||||
precio_colones: 750,
|
||||
imagen_url: '/img/products/muffin_zanahoria.jpg',
|
||||
icono: 'cookie',
|
||||
alergenos: 'Huevo, Gluten'
|
||||
},
|
||||
{
|
||||
categoria_id: 4, // Frutas y Snacks
|
||||
nombre: 'Bowl de Avena con Manzana y Canela',
|
||||
descripcion: 'Avena tibia en leche descremada con trozos de manzana fresca y canela molida.',
|
||||
precio_colones: 850,
|
||||
imagen_url: '/img/products/bowl_avena_manzana.jpg',
|
||||
icono: 'bowl',
|
||||
alergenos: 'Lácteos'
|
||||
},
|
||||
{
|
||||
categoria_id: 1, // Meriendas Saludables
|
||||
nombre: 'Tacos Dorados de Papa y Queso',
|
||||
descripcion: 'Tacos crujientes de maíz rellenos de puré de papa sazonado y queso fresco.',
|
||||
precio_colones: 1150,
|
||||
imagen_url: '/img/products/tacos_papa_queso.jpg',
|
||||
icono: 'pizza',
|
||||
alergenos: 'Lácteos'
|
||||
},
|
||||
|
||||
// --- 5 REFRESCOS NATURALES (Categoría 3) ---
|
||||
{
|
||||
categoria_id: 3, // Bebidas y Frescos
|
||||
nombre: 'Fresco Natural de Maracuyá (350ml)',
|
||||
descripcion: 'Jugo natural de maracuyá costarricense preparado con hielo y semillas frescas.',
|
||||
precio_colones: 750,
|
||||
imagen_url: '/img/products/fresco_maracuya.jpg',
|
||||
icono: 'cup-soda',
|
||||
alergenos: 'Ninguno'
|
||||
},
|
||||
{
|
||||
categoria_id: 3, // Bebidas y Frescos
|
||||
nombre: 'Fresco Natural de Sandía (350ml)',
|
||||
descripcion: 'Bebida natural de sandía fresca licuada con hielo, dulce, ligera y refrescante.',
|
||||
precio_colones: 700,
|
||||
imagen_url: '/img/products/fresco_sandia.jpg',
|
||||
icono: 'cup-soda',
|
||||
alergenos: 'Ninguno'
|
||||
},
|
||||
{
|
||||
categoria_id: 3, // Bebidas y Frescos
|
||||
nombre: 'Limonada con Hierbabuena (350ml)',
|
||||
descripcion: 'Limonada natural recién exprimida con hojas frescas de hierbabuena y hielo picado.',
|
||||
precio_colones: 750,
|
||||
imagen_url: '/img/products/limonada_hierbabuena.jpg',
|
||||
icono: 'cup-soda',
|
||||
alergenos: 'Ninguno'
|
||||
},
|
||||
{
|
||||
categoria_id: 3, // Bebidas y Frescos
|
||||
nombre: 'Batido Natural de Guanábana (350ml)',
|
||||
descripcion: 'Fresco cremoso de pulpa natural de guanábana con hielo, suave y tropical.',
|
||||
precio_colones: 850,
|
||||
imagen_url: '/img/products/fresco_guanabana.jpg',
|
||||
icono: 'cup-soda',
|
||||
alergenos: 'Ninguno'
|
||||
},
|
||||
{
|
||||
categoria_id: 3, // Bebidas y Frescos
|
||||
nombre: 'Fresco de Piña con Arroz (350ml)',
|
||||
descripcion: 'Tradicional refresco tico de piña cocida con arroz y toque de canela, servido bien frío.',
|
||||
precio_colones: 750,
|
||||
imagen_url: '/img/products/fresco_pina_arroz.jpg',
|
||||
icono: 'cup-soda',
|
||||
alergenos: 'Ninguno'
|
||||
}
|
||||
];
|
||||
|
||||
async function seed() {
|
||||
const client = new Client({ connectionString: pgUrl });
|
||||
await client.connect();
|
||||
console.log('🚀 Conectado a PostgreSQL.');
|
||||
|
||||
// Obtener escuelas activas
|
||||
const escuelasRes = await client.query('SELECT id, nombre FROM escuelas ORDER BY id ASC;');
|
||||
const escuelas = escuelasRes.rows;
|
||||
console.log(`Escuelas encontradas: ${escuelas.map(e => `${e.id}: ${e.nombre}`).join(', ')}`);
|
||||
|
||||
for (const esc of escuelas) {
|
||||
console.log(`\n📌 Procesando productos para Escuela ID ${esc.id} (${esc.nombre})...`);
|
||||
for (const item of NEW_PRODUCTS) {
|
||||
// Verificar si ya existe en esta escuela
|
||||
const checkRes = await client.query(
|
||||
'SELECT id FROM productos WHERE escuela_id = $1 AND LOWER(TRIM(nombre)) = LOWER(TRIM($2));',
|
||||
[esc.id, item.nombre]
|
||||
);
|
||||
|
||||
if (checkRes.rows.length === 0) {
|
||||
const insertRes = await client.query(
|
||||
`INSERT INTO productos
|
||||
(categoria_id, nombre, descripcion, precio_colones, imagen_url, icono, alergenos, stock, es_saludable, cumple_mep, disponible, permite_preorden, control_stock, escuela_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, 25, 1, 1, 1, 1, 1, $8)
|
||||
RETURNING id;`,
|
||||
[
|
||||
item.categoria_id,
|
||||
item.nombre,
|
||||
item.descripcion,
|
||||
item.precio_colones,
|
||||
item.imagen_url,
|
||||
item.icono,
|
||||
item.alergenos,
|
||||
esc.id
|
||||
]
|
||||
);
|
||||
console.log(` ➕ Insertado: [ID ${insertRes.rows[0].id}] ${item.nombre} (₡${item.precio_colones})`);
|
||||
} else {
|
||||
// Actualizar foto y datos
|
||||
await client.query(
|
||||
`UPDATE productos
|
||||
SET descripcion = $1, precio_colones = $2, imagen_url = $3, icono = $4, alergenos = $5, categoria_id = $6
|
||||
WHERE id = $7;`,
|
||||
[
|
||||
item.descripcion,
|
||||
item.precio_colones,
|
||||
item.imagen_url,
|
||||
item.icono,
|
||||
item.alergenos,
|
||||
item.categoria_id,
|
||||
checkRes.rows[0].id
|
||||
]
|
||||
);
|
||||
console.log(` 🔄 Actualizado: [ID ${checkRes.rows[0].id}] ${item.nombre}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Comprobar total de productos en Escuela 1
|
||||
const countRes = await client.query('SELECT COUNT(*) as total FROM productos WHERE escuela_id = 1;');
|
||||
console.log(`\n✨ Total de productos en Escuela 1: ${countRes.rows[0].total}`);
|
||||
|
||||
await client.end();
|
||||
}
|
||||
|
||||
seed().catch(console.error);
|
||||
@@ -0,0 +1,58 @@
|
||||
const path = require('path');
|
||||
const puppeteer = require('puppeteer-core');
|
||||
const express = require('express');
|
||||
|
||||
const CHROME_PATH = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe';
|
||||
const PORT = 3033;
|
||||
const OUT_DIR = path.join(__dirname, '../screenshots/desktop_preview');
|
||||
|
||||
async function main() {
|
||||
const fs = require('fs');
|
||||
if (!fs.existsSync(OUT_DIR)) fs.mkdirSync(OUT_DIR, { recursive: true });
|
||||
|
||||
const app = express();
|
||||
app.use(express.static(path.join(__dirname, '../public')));
|
||||
|
||||
const server = app.listen(PORT, async () => {
|
||||
console.log(`Server listening on port ${PORT}`);
|
||||
try {
|
||||
const browser = await puppeteer.launch({
|
||||
executablePath: CHROME_PATH,
|
||||
headless: 'new',
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
||||
});
|
||||
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({ width: 1920, height: 1080, deviceScaleFactor: 1 });
|
||||
await page.goto(`http://localhost:${PORT}/index.html`, { waitUntil: 'networkidle2' });
|
||||
|
||||
// Verify computed style of .splash-doodle-bg
|
||||
const animInfo = await page.evaluate(() => {
|
||||
const el = document.querySelector('.splash-doodle-bg');
|
||||
if (!el) return null;
|
||||
const style = window.getComputedStyle(el);
|
||||
return {
|
||||
animation: style.animation,
|
||||
animationName: style.animationName,
|
||||
animationDuration: style.animationDuration,
|
||||
backgroundSize: style.backgroundSize
|
||||
};
|
||||
});
|
||||
console.log('Animation Info:', animInfo);
|
||||
|
||||
const outPath = path.join(OUT_DIR, 'Login_Desktop_Fondo_Animado.png');
|
||||
await page.screenshot({ path: outPath, type: 'png' });
|
||||
console.log('✓ Guardado screenshot desktop:', outPath);
|
||||
|
||||
await browser.close();
|
||||
server.close();
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
server.close();
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -1,5 +1,6 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { normalizarCodigoDetalle } = require('./sinpeParser');
|
||||
|
||||
try {
|
||||
const envPath = path.join(__dirname, '../.env');
|
||||
@@ -145,6 +146,27 @@ function initDatabase() {
|
||||
`);
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS sinpe_transacciones_banco (
|
||||
id VARCHAR(100) PRIMARY KEY,
|
||||
reference_number VARCHAR(100),
|
||||
codigo_detalle VARCHAR(100),
|
||||
codigo_detalle_norm VARCHAR(100),
|
||||
amount_crc NUMERIC NOT NULL,
|
||||
sender_phone VARCHAR(50),
|
||||
sender_name VARCHAR(100),
|
||||
origin_bank VARCHAR(100),
|
||||
status VARCHAR(20) DEFAULT 'unclaimed',
|
||||
claimed_by_estudiante_id INTEGER,
|
||||
raw_data TEXT,
|
||||
received_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
verified_at TIMESTAMP
|
||||
);
|
||||
`);
|
||||
try { db.exec('ALTER TABLE solicitudes_recarga_sinpe ADD COLUMN IF NOT EXISTS codigo_detalle VARCHAR(100);'); } catch (_) {}
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS push_subscriptions (
|
||||
@@ -161,8 +183,15 @@ function initDatabase() {
|
||||
} catch (e) {
|
||||
console.error('Error creando push_subscriptions en PostgreSQL:', e);
|
||||
}
|
||||
try {
|
||||
db.exec('ALTER TABLE transacciones_saldo ADD COLUMN IF NOT EXISTS revertida INTEGER DEFAULT 0;');
|
||||
db.exec('ALTER TABLE transacciones_saldo ADD COLUMN IF NOT EXISTS revertido_por_usuario_id INTEGER REFERENCES usuarios(id);');
|
||||
db.exec('ALTER TABLE transacciones_saldo ADD COLUMN IF NOT EXISTS revertido_en TIMESTAMP;');
|
||||
} catch (e) {}
|
||||
|
||||
seedUsuarios();
|
||||
seedDisenosTarjetas();
|
||||
migrarTrazabilidadSinpeRechazadas();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -312,6 +341,14 @@ function initDatabase() {
|
||||
`);
|
||||
} catch (e) {}
|
||||
|
||||
// 9.2 Garantizar columnas de ordenes para SQLite
|
||||
try { db.exec('ALTER TABLE ordenes ADD COLUMN cajero_id INTEGER DEFAULT 1'); } catch (e) {}
|
||||
try { db.exec('ALTER TABLE ordenes ADD COLUMN saldo_anterior INTEGER DEFAULT 0'); } catch (e) {}
|
||||
try { db.exec('ALTER TABLE ordenes ADD COLUMN saldo_posterior INTEGER DEFAULT 0'); } catch (e) {}
|
||||
try { db.exec('ALTER TABLE ordenes ADD COLUMN metodo_pago TEXT DEFAULT "monedero_qr"'); } catch (e) {}
|
||||
try { db.exec('ALTER TABLE ordenes ADD COLUMN observaciones TEXT'); } catch (e) {}
|
||||
try { db.exec('ALTER TABLE ordenes ADD COLUMN escuela_id INTEGER DEFAULT 1'); } catch (e) {}
|
||||
|
||||
// 10. Diseños de Tarjetas Virtuales para Estudiantes
|
||||
try {
|
||||
db.exec(`
|
||||
@@ -345,6 +382,28 @@ function initDatabase() {
|
||||
procesado_en DATETIME
|
||||
);
|
||||
`);
|
||||
try { db.exec('ALTER TABLE solicitudes_recarga_sinpe ADD COLUMN codigo_detalle TEXT;'); } catch (_) {}
|
||||
} catch (e) {}
|
||||
|
||||
// 11b. Transacciones Bancarias SINPE Detectadas por Correo / IMAP
|
||||
try {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS sinpe_transacciones_banco (
|
||||
id TEXT PRIMARY KEY,
|
||||
reference_number TEXT,
|
||||
codigo_detalle TEXT,
|
||||
codigo_detalle_norm TEXT,
|
||||
amount_crc NUMERIC NOT NULL,
|
||||
sender_phone TEXT,
|
||||
sender_name TEXT,
|
||||
origin_bank TEXT,
|
||||
status TEXT DEFAULT 'unclaimed',
|
||||
claimed_by_estudiante_id INTEGER,
|
||||
raw_data TEXT,
|
||||
received_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
verified_at DATETIME
|
||||
);
|
||||
`);
|
||||
} catch (e) {}
|
||||
|
||||
// 12. Suscripciones Web Push (VAPID) para Alertas en Segundo Plano (App Cerrada)
|
||||
@@ -363,11 +422,54 @@ function initDatabase() {
|
||||
`);
|
||||
} catch (e) {}
|
||||
|
||||
migrarTrazabilidadSinpeRechazadas();
|
||||
seedInitialData();
|
||||
seedUsuarios();
|
||||
seedDisenosTarjetas();
|
||||
}
|
||||
|
||||
function migrarTrazabilidadSinpeRechazadas() {
|
||||
try {
|
||||
const rechazadasSinMov = db.prepare(`
|
||||
SELECT s.*, e.saldo_colones as saldo_actual
|
||||
FROM solicitudes_recarga_sinpe s
|
||||
JOIN estudiantes e ON s.estudiante_id = e.id
|
||||
WHERE s.estado = 'rechazada'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM transacciones_saldo t
|
||||
WHERE t.tipo = 'sinpe_rechazado'
|
||||
AND t.estudiante_id = s.estudiante_id
|
||||
AND (t.comprobante_sinpe = s.comprobante_sinpe OR (s.codigo_detalle IS NOT NULL AND t.comprobante_sinpe = s.codigo_detalle))
|
||||
)
|
||||
`).all();
|
||||
|
||||
if (rechazadasSinMov && rechazadasSinMov.length > 0) {
|
||||
console.log(`[Trazabilidad SINPE] Sincronizando ${rechazadasSinMov.length} solicitudes rechazadas previas en transacciones_saldo...`);
|
||||
for (const r of rechazadasSinMov) {
|
||||
const motivoRechazo = r.notas || 'Comprobante no verificado en cuenta';
|
||||
const comp = r.comprobante_sinpe || r.codigo_detalle || 'N/A';
|
||||
const fechaTx = r.procesado_en || r.creado_en || new Date().toISOString();
|
||||
db.prepare(`
|
||||
INSERT INTO transacciones_saldo
|
||||
(estudiante_id, tipo, monto_colones, saldo_previo, saldo_posterior, comprobante_sinpe, descripcion, fecha)
|
||||
VALUES (?, 'sinpe_rechazado', ?, ?, ?, ?, ?, ?)
|
||||
`).run(
|
||||
r.estudiante_id,
|
||||
r.monto_colones,
|
||||
r.saldo_actual || 0,
|
||||
r.saldo_actual || 0,
|
||||
r.comprobante_sinpe || r.codigo_detalle || 'SINPE-RECHAZADO',
|
||||
`SINPE Rechazado: ${motivoRechazo} (Comprobante #${comp})`,
|
||||
fechaTx
|
||||
);
|
||||
}
|
||||
console.log('[Trazabilidad SINPE] Sincronización retroactiva completada con éxito.');
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Migración trazabilidad sinpe rechazadas:', e.message);
|
||||
}
|
||||
}
|
||||
|
||||
function seedUsuarios() {
|
||||
const res = db.prepare('SELECT COUNT(*) as count FROM usuarios').get();
|
||||
const count = res ? Number(res.count) : 0;
|
||||
@@ -706,6 +808,18 @@ function recargaSaldoTransaction({ estudianteId, monto, comprobanteSinpe, descri
|
||||
return transaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Traduce y estandariza el código o texto de momento de entrega a una etiqueta humana amigable
|
||||
*/
|
||||
function formatMomentoLabel(momento) {
|
||||
const m = String(momento || '').toLowerCase().trim();
|
||||
if (m === 'recreo_1' || m.includes('1er') || m.includes('9:30')) return '1er Recreo (9:30 AM)';
|
||||
if (m === 'almuerzo' || m.includes('almuerzo') || m.includes('11:45')) return 'Almuerzo (11:45 AM)';
|
||||
if (m === 'recreo_2' || m.includes('2do') || m.includes('1:45')) return '2do Recreo (1:45 PM)';
|
||||
if (m === 'inmediato' || m.includes('inmediato')) return 'Entrega Inmediata';
|
||||
return momento || '1er Recreo (9:30 AM)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Crea una orden completa (Mostrador o Preorden) con sus ítems
|
||||
*/
|
||||
@@ -825,13 +939,19 @@ function crearOrdenCompleta({ estudianteId, tipoOrden, momentoEntrega, notas, it
|
||||
|
||||
return {
|
||||
orden_id: ordenId,
|
||||
id: ordenId,
|
||||
codigo_orden: codigoOrden,
|
||||
estudiante_id: estudianteId,
|
||||
estudiante_nombre: est.nombre_completo,
|
||||
grado: est.grado,
|
||||
seccion: est.seccion,
|
||||
tipo_orden: tipoOrden,
|
||||
momento_entrega: momentoEntrega,
|
||||
momento_entrega: momentoVal,
|
||||
momento_entrega_label: formatMomentoLabel(momentoVal),
|
||||
estado: estadoInicial,
|
||||
total_colones: totalColones,
|
||||
detalles: detallesParaInsertar,
|
||||
items: detallesParaInsertar,
|
||||
productosActualizados,
|
||||
financiero: resultadoDebito
|
||||
};
|
||||
@@ -972,8 +1092,8 @@ function revertirTransaccionSaldoTransaction({ transaccionId, usuarioId, usuario
|
||||
throw new Error('Esta transacción ya fue revertida previamente');
|
||||
}
|
||||
|
||||
if (tx.tipo === 'reversion_recarga' || tx.tipo === 'reembolso') {
|
||||
throw new Error('No es posible revertir una transacción que ya corresponde a una reversión o reembolso');
|
||||
if (tx.tipo === 'reversion_recarga' || tx.tipo === 'reembolso' || tx.tipo === 'sinpe_rechazado') {
|
||||
throw new Error('No es posible revertir una transacción que fue rechazada o que ya corresponde a una reversión o reembolso');
|
||||
}
|
||||
|
||||
// 2. Control de tiempo según el rol (Cajero: <= 10 min, Admin: ilimitado)
|
||||
@@ -1100,31 +1220,127 @@ function revertirTransaccionSaldoTransaction({ transaccionId, usuarioId, usuario
|
||||
return transaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un código de detalle amigable y tolerante: "SIBO-" + 4 caracteres anti-confusión
|
||||
*/
|
||||
function generarCodigoDetalleSinpe() {
|
||||
const chars = '23456789ACDEFGHJKMNPQRSTUVWXYZ';
|
||||
let rand = '';
|
||||
for (let i = 0; i < 4; i++) {
|
||||
rand += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||
}
|
||||
return `SIBO-${rand}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crea una nueva solicitud de recarga por SINPE Móvil enviada por un padre
|
||||
*/
|
||||
function crearSolicitudRecargaSinpe({ estudianteId, padreUsuarioId, monto, comprobante, notas }) {
|
||||
function crearSolicitudRecargaSinpe({ estudianteId, padreUsuarioId, monto, comprobante, notas, codigoDetalle }) {
|
||||
let escuelaId = 1;
|
||||
try {
|
||||
const est = db.prepare('SELECT escuela_id FROM estudiantes WHERE id = ?').get(estudianteId);
|
||||
if (est && est.escuela_id) escuelaId = est.escuela_id;
|
||||
} catch (e) {}
|
||||
|
||||
const finalCodigo = codigoDetalle || generarCodigoDetalleSinpe();
|
||||
const finalComp = comprobante ? String(comprobante).trim() : `SINPE-${finalCodigo.replace(/[^A-Za-z0-9]/g, '')}`;
|
||||
|
||||
const insert = db.prepare(`
|
||||
INSERT INTO solicitudes_recarga_sinpe (estudiante_id, padre_usuario_id, monto_colones, comprobante_sinpe, estado, notas, escuela_id)
|
||||
VALUES (?, ?, ?, ?, 'pendiente', ?, ?)
|
||||
INSERT INTO solicitudes_recarga_sinpe (estudiante_id, padre_usuario_id, monto_colones, comprobante_sinpe, codigo_detalle, estado, notas, escuela_id)
|
||||
VALUES (?, ?, ?, ?, ?, 'pendiente', ?, ?)
|
||||
`);
|
||||
const res = insert.run(estudianteId, padreUsuarioId || null, parseInt(monto, 10), String(comprobante).trim(), notas || '', escuelaId);
|
||||
const res = insert.run(estudianteId, padreUsuarioId || null, parseInt(monto, 10), finalComp, finalCodigo, notas || '', escuelaId);
|
||||
return {
|
||||
id: res.lastInsertRowid || res.id,
|
||||
estudiante_id: estudianteId,
|
||||
escuela_id: escuelaId,
|
||||
monto_colones: parseInt(monto, 10),
|
||||
comprobante_sinpe: String(comprobante).trim(),
|
||||
comprobante_sinpe: finalComp,
|
||||
codigo_detalle: finalCodigo,
|
||||
estado: 'pendiente'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Busca una transacción bancaria capturada por IMAP/correo para validar la recarga
|
||||
*/
|
||||
function buscarTransaccionSinpeBanco({ codigoDetalle, comprobante, monto }) {
|
||||
const normCod = codigoDetalle ? normalizarCodigoDetalle(codigoDetalle) : null;
|
||||
const cleanComp = comprobante ? String(comprobante).trim().replace(/^[#:\.\-\s]+/, '') : null;
|
||||
const numMonto = parseInt(monto, 10);
|
||||
|
||||
// 1. Búsqueda por código de detalle normalizado (máxima prioridad)
|
||||
if (normCod && normCod.length >= 4) {
|
||||
let tx = db.prepare(`
|
||||
SELECT * FROM sinpe_transacciones_banco
|
||||
WHERE (codigo_detalle_norm = ? OR UPPER(REPLACE(REPLACE(codigo_detalle, '-', ''), ' ', '')) = ?)
|
||||
AND status = 'unclaimed'
|
||||
ORDER BY received_at DESC
|
||||
LIMIT 1
|
||||
`).get(normCod, normCod);
|
||||
|
||||
if (tx) {
|
||||
if (numMonto && Math.abs(Number(tx.amount_crc) - numMonto) > 0.01) {
|
||||
return { error: 'MONTO_DISCREPANCIA', tx, mensaje: `El comprobante bancario corresponde a ₡${Number(tx.amount_crc).toLocaleString('es-CR')}, pero la recarga solicitada es por ₡${numMonto.toLocaleString('es-CR')}.` };
|
||||
}
|
||||
return { encontrado: true, tx };
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Búsqueda por número de comprobante emitido por el banco
|
||||
if (cleanComp && cleanComp.length >= 3) {
|
||||
let tx = db.prepare(`
|
||||
SELECT * FROM sinpe_transacciones_banco
|
||||
WHERE (reference_number = ? OR reference_number LIKE ?)
|
||||
AND status = 'unclaimed'
|
||||
ORDER BY received_at DESC
|
||||
LIMIT 1
|
||||
`).get(cleanComp, `%${cleanComp}%`);
|
||||
|
||||
if (tx) {
|
||||
if (numMonto && Math.abs(Number(tx.amount_crc) - numMonto) > 0.01) {
|
||||
return { error: 'MONTO_DISCREPANCIA', tx, mensaje: `El comprobante bancario corresponde a ₡${Number(tx.amount_crc).toLocaleString('es-CR')}, pero la recarga solicitada es por ₡${numMonto.toLocaleString('es-CR')}.` };
|
||||
}
|
||||
return { encontrado: true, tx };
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Verificar si el código o comprobante ya fue usado previamente (anti-fraude)
|
||||
if (normCod) {
|
||||
const used = db.prepare(`
|
||||
SELECT * FROM sinpe_transacciones_banco
|
||||
WHERE codigo_detalle_norm = ? AND status = 'used'
|
||||
LIMIT 1
|
||||
`).get(normCod);
|
||||
|
||||
if (used) {
|
||||
return { error: 'COMPROBANTE_YA_UTILIZADO', mensaje: `Este código de detalle ya fue utilizado anteriormente y no es válido para otra recarga.` };
|
||||
}
|
||||
} else if (cleanComp) {
|
||||
const used = db.prepare(`
|
||||
SELECT * FROM sinpe_transacciones_banco
|
||||
WHERE reference_number = ? AND status = 'used'
|
||||
LIMIT 1
|
||||
`).get(cleanComp);
|
||||
|
||||
if (used) {
|
||||
return { error: 'COMPROBANTE_YA_UTILIZADO', mensaje: `Este comprobante bancario ya fue utilizado anteriormente y no es válido para otra recarga.` };
|
||||
}
|
||||
}
|
||||
|
||||
return { encontrado: false };
|
||||
}
|
||||
|
||||
function marcarTransaccionSinpeUsada(txId, estudianteId) {
|
||||
return db.prepare(`
|
||||
UPDATE sinpe_transacciones_banco
|
||||
SET status = 'used',
|
||||
claimed_by_estudiante_id = ?,
|
||||
verified_at = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
`).run(estudianteId || null, txId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene las solicitudes de recarga SINPE (con datos del estudiante y escuela)
|
||||
*/
|
||||
@@ -1206,17 +1422,40 @@ function procesarSolicitudRecargaSinpe({ solicitudId, accion, usuarioId, motivo
|
||||
estudiante_nombre: resultadoSaldo.nombre
|
||||
};
|
||||
} else if (accion === 'rechazar') {
|
||||
const est = db.prepare('SELECT * FROM estudiantes WHERE id = ?').get(sol.estudiante_id);
|
||||
const saldoActual = est ? est.saldo_colones : 0;
|
||||
const motivoRechazo = motivo || 'Comprobante no verificado en cuenta';
|
||||
|
||||
db.prepare(`
|
||||
UPDATE solicitudes_recarga_sinpe
|
||||
SET estado = 'rechazada', aprobado_por_usuario_id = ?, procesado_en = CURRENT_TIMESTAMP, notas = ?
|
||||
WHERE id = ?
|
||||
`).run(usuarioId || null, motivo || 'Comprobante no verificado en cuenta', solicitudId);
|
||||
`).run(usuarioId || null, motivoRechazo, solicitudId);
|
||||
|
||||
// Registrar en transacciones_saldo para trazabilidad en Movimientos y Reversiones
|
||||
const compLabel = sol.comprobante_sinpe || (sol.codigo_detalle ? `Cód: ${sol.codigo_detalle}` : 'N/A');
|
||||
const descTrazabilidad = `SINPE Rechazado: ${motivoRechazo} (Comprobante #${compLabel})`;
|
||||
|
||||
db.prepare(`
|
||||
INSERT INTO transacciones_saldo
|
||||
(estudiante_id, tipo, monto_colones, saldo_previo, saldo_posterior, comprobante_sinpe, descripcion)
|
||||
VALUES (?, 'sinpe_rechazado', ?, ?, ?, ?, ?)
|
||||
`).run(
|
||||
sol.estudiante_id,
|
||||
sol.monto_colones,
|
||||
saldoActual,
|
||||
saldoActual,
|
||||
sol.comprobante_sinpe || (sol.codigo_detalle ? `Cód: ${sol.codigo_detalle}` : 'SINPE-RECHAZADO'),
|
||||
descTrazabilidad
|
||||
);
|
||||
|
||||
return {
|
||||
solicitud_id: solicitudId,
|
||||
estado: 'rechazada',
|
||||
estudiante_id: sol.estudiante_id,
|
||||
monto: sol.monto_colones
|
||||
monto: sol.monto_colones,
|
||||
estudiante_nombre: est ? est.nombre_completo : 'Estudiante',
|
||||
motivo: motivoRechazo
|
||||
};
|
||||
} else {
|
||||
throw new Error('Acción no válida (usar aprobar o rechazar)');
|
||||
@@ -1271,11 +1510,15 @@ module.exports = {
|
||||
crearOrdenCompleta,
|
||||
transferenciaP2PTransaction,
|
||||
revertirTransaccionSaldoTransaction,
|
||||
generarCodigoDetalleSinpe,
|
||||
crearSolicitudRecargaSinpe,
|
||||
buscarTransaccionSinpeBanco,
|
||||
marcarTransaccionSinpeUsada,
|
||||
obtenerSolicitudesRecargaSinpe,
|
||||
obtenerSolicitudesRecargaPorEstudiante,
|
||||
procesarSolicitudRecargaSinpe,
|
||||
guardarSuscripcionPush,
|
||||
obtenerSuscripcionesPush,
|
||||
eliminarSuscripcionPush
|
||||
eliminarSuscripcionPush,
|
||||
formatMomentoLabel
|
||||
};
|
||||
|
||||
@@ -18,14 +18,21 @@ const {
|
||||
crearOrdenCompleta,
|
||||
transferenciaP2PTransaction,
|
||||
revertirTransaccionSaldoTransaction,
|
||||
generarCodigoDetalleSinpe,
|
||||
crearSolicitudRecargaSinpe,
|
||||
buscarTransaccionSinpeBanco,
|
||||
marcarTransaccionSinpeUsada,
|
||||
obtenerSolicitudesRecargaSinpe,
|
||||
obtenerSolicitudesRecargaPorEstudiante,
|
||||
procesarSolicitudRecargaSinpe,
|
||||
guardarSuscripcionPush,
|
||||
obtenerSuscripcionesPush,
|
||||
eliminarSuscripcionPush
|
||||
eliminarSuscripcionPush,
|
||||
formatMomentoLabel
|
||||
} = require('./db');
|
||||
const { checkSinpeEmailsOnce, simularSinpeEmail } = require('./sinpeImapService');
|
||||
const { normalizarCodigoDetalle, parseSinpeEmail } = require('./sinpeParser');
|
||||
const { simpleParser } = require('mailparser');
|
||||
|
||||
const webpush = require('web-push');
|
||||
|
||||
@@ -151,6 +158,57 @@ setInterval(() => {
|
||||
}
|
||||
}, 10000);
|
||||
|
||||
// ==========================================
|
||||
// PISTOLA REMOTA QR / HANDHELD SMARTPHONE
|
||||
// ==========================================
|
||||
|
||||
// Disparo remoto desde la pistola móvil (teléfono) hacia la caja POS
|
||||
app.post('/api/pos/remote-scan', (req, res) => {
|
||||
try {
|
||||
const { token, deviceName } = req.body;
|
||||
if (!token) return res.status(400).json({ error: 'Token requerido' });
|
||||
|
||||
console.log(`📡 [PISTOLA REMOTA] Disparo recibido desde ${deviceName || 'teléfono'}: ${token}`);
|
||||
|
||||
// Broadcast a todas las terminales POS conectadas por SSE
|
||||
broadcastEvent('pistola_scan', {
|
||||
token: String(token).trim(),
|
||||
deviceName: deviceName || 'Pistola Teléfono',
|
||||
timestamp: Date.now()
|
||||
});
|
||||
|
||||
res.json({ ok: true, token: String(token).trim() });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Solicitud desde el POS en PC al teléfono para avisar que la caja está lista para cobrar
|
||||
app.post('/api/pos/notify-scan-ready', (req, res) => {
|
||||
try {
|
||||
const { mode, total, itemsCount } = req.body;
|
||||
broadcastEvent('pistola_solicitud_cobro', {
|
||||
mode: mode || 'cobro',
|
||||
total: total || 0,
|
||||
itemsCount: itemsCount || 0,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
res.json({ ok: true });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Cancelación de solicitud cuando se cierra el modal de cobro en la PC
|
||||
app.post('/api/pos/notify-scan-cancel', (req, res) => {
|
||||
try {
|
||||
broadcastEvent('pistola_cancelar_cobro', { timestamp: Date.now() });
|
||||
res.json({ ok: true });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// 0. AUTENTICACIÓN Y ROLES (ADMIN, PADRE, ESTUDIANTE)
|
||||
// ==========================================
|
||||
@@ -600,7 +658,7 @@ app.post('/api/admin/productos', (req, res) => {
|
||||
icono || '🥪',
|
||||
calorias ? parseInt(calorias, 10) : 220,
|
||||
mep,
|
||||
alergenos ? String(alergenos).trim() : 'Ninguno conocido',
|
||||
(alergenos && !['ninguno', 'ninguno conocido', 'no', 'sin alérgenos', 'sin alergenos'].includes(String(alergenos).trim().toLowerCase())) ? String(alergenos).trim() : null,
|
||||
disp,
|
||||
permite_preorden !== undefined ? (permite_preorden ? 1 : 0) : 1,
|
||||
ctrlStock,
|
||||
@@ -661,7 +719,7 @@ app.put('/api/admin/productos/:id', (req, res) => {
|
||||
icono !== undefined ? icono : prod.icono,
|
||||
calorias !== undefined ? (calorias ? parseInt(calorias, 10) : null) : prod.calorias,
|
||||
mep,
|
||||
alergenos !== undefined ? (alergenos ? String(alergenos).trim() : null) : prod.alergenos,
|
||||
alergenos !== undefined ? ((alergenos && !['ninguno', 'ninguno conocido', 'no', 'sin alérgenos', 'sin alergenos'].includes(String(alergenos).trim().toLowerCase())) ? String(alergenos).trim() : null) : prod.alergenos,
|
||||
disp,
|
||||
permite_preorden !== undefined ? (permite_preorden ? 1 : 0) : prod.permite_preorden,
|
||||
ctrlStock,
|
||||
@@ -1284,6 +1342,284 @@ app.put('/api/developer/escuelas/:id/estado', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// MÓDULO DE COPIAS DE SEGURIDAD (BACKUPS)
|
||||
// ==========================================
|
||||
const backupsDir = path.join(__dirname, 'backups');
|
||||
if (!fs.existsSync(backupsDir)) {
|
||||
try { fs.mkdirSync(backupsDir, { recursive: true }); } catch (e) {}
|
||||
}
|
||||
|
||||
function rotarBackups() {
|
||||
try {
|
||||
const files = fs.readdirSync(backupsDir)
|
||||
.filter(f => f.startsWith('sibopay_'))
|
||||
.map(f => {
|
||||
const p = path.join(backupsDir, f);
|
||||
return { name: f, path: p, time: fs.statSync(p).mtimeMs };
|
||||
})
|
||||
.sort((a, b) => b.time - a.time);
|
||||
if (files.length > 20) {
|
||||
for (const oldFile of files.slice(20)) {
|
||||
try { fs.unlinkSync(oldFile.path); } catch (e) {}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
async function ejecutarBackupBaseDatos() {
|
||||
const isPg = Boolean(process.env.DATABASE_URL);
|
||||
const now = new Date();
|
||||
const pad = (n) => String(n).padStart(2, '0');
|
||||
const timestamp = `${now.getFullYear()}-${pad(now.getMonth()+1)}-${pad(now.getDate())}_${pad(now.getHours())}-${pad(now.getMinutes())}-${pad(now.getSeconds())}`;
|
||||
|
||||
if (isPg) {
|
||||
const filename = `sibopay_pg_${timestamp}.sql`;
|
||||
const targetPath = path.join(backupsDir, filename);
|
||||
const dbUrl = process.env.DATABASE_URL;
|
||||
const parsed = new URL(dbUrl);
|
||||
const user = parsed.username || 'postgres';
|
||||
const password = parsed.password || '';
|
||||
const host = parsed.hostname || '127.0.0.1';
|
||||
const port = parsed.port || '5432';
|
||||
const dbname = parsed.pathname ? parsed.pathname.replace(/^\//, '') : 'recreopay_db';
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const { exec } = require('child_process');
|
||||
const cmd = `PGPASSWORD="${password}" pg_dump -h ${host} -p ${port} -U ${user} -d ${dbname} --clean > "${targetPath}"`;
|
||||
exec(cmd, (err, stdout, stderr) => {
|
||||
if (err) return reject(new Error('Fallo al ejecutar pg_dump: ' + (stderr || err.message)));
|
||||
const stat = fs.statSync(targetPath);
|
||||
rotarBackups();
|
||||
resolve({
|
||||
filename,
|
||||
sizeBytes: stat.size,
|
||||
sizeFmt: (stat.size / 1024).toFixed(1) + ' KB',
|
||||
fecha: now.toISOString(),
|
||||
tipo: 'PostgreSQL'
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
const filename = `sibopay_sqlite_${timestamp}.db`;
|
||||
const targetPath = path.join(backupsDir, filename);
|
||||
const sqliteSource = path.join(__dirname, 'recreopay.db');
|
||||
if (fs.existsSync(sqliteSource)) {
|
||||
fs.copyFileSync(sqliteSource, targetPath);
|
||||
}
|
||||
const stat = fs.existsSync(targetPath) ? fs.statSync(targetPath) : { size: 0 };
|
||||
rotarBackups();
|
||||
return {
|
||||
filename,
|
||||
sizeBytes: stat.size,
|
||||
sizeFmt: (stat.size / 1024).toFixed(1) + ' KB',
|
||||
fecha: now.toISOString(),
|
||||
tipo: 'SQLite'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Programar backup automático cada 24 horas (iniciado tras 5 minutos de uptime)
|
||||
setTimeout(() => {
|
||||
ejecutarBackupBaseDatos().catch(() => {});
|
||||
setInterval(() => {
|
||||
ejecutarBackupBaseDatos().catch(() => {});
|
||||
}, 24 * 60 * 60 * 1000);
|
||||
}, 5 * 60 * 1000);
|
||||
|
||||
// Endpoint: Listar backups existentes (Developer)
|
||||
app.get('/api/developer/backups', (req, res) => {
|
||||
try {
|
||||
if (!fs.existsSync(backupsDir)) {
|
||||
return res.json({ backups: [] });
|
||||
}
|
||||
const files = fs.readdirSync(backupsDir)
|
||||
.filter(f => f.startsWith('sibopay_'))
|
||||
.map(f => {
|
||||
const p = path.join(backupsDir, f);
|
||||
const stat = fs.statSync(p);
|
||||
return {
|
||||
filename: f,
|
||||
sizeBytes: stat.size,
|
||||
sizeFmt: (stat.size / 1024).toFixed(1) + ' KB',
|
||||
fecha: stat.mtime.toISOString(),
|
||||
tipo: f.includes('_pg_') ? 'PostgreSQL' : 'SQLite'
|
||||
};
|
||||
})
|
||||
.sort((a, b) => new Date(b.fecha) - new Date(a.fecha));
|
||||
|
||||
res.json({ backups: files });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Endpoint: Crear backup manual inmediato (Developer)
|
||||
app.post('/api/developer/backups/crear', async (req, res) => {
|
||||
try {
|
||||
const backupInfo = await ejecutarBackupBaseDatos();
|
||||
res.json({
|
||||
exito: true,
|
||||
mensaje: `Respaldo "${backupInfo.filename}" generado exitosamente (${backupInfo.sizeFmt}).`,
|
||||
backup: backupInfo
|
||||
});
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Endpoint: Descargar archivo de backup (Developer)
|
||||
app.get('/api/developer/backups/descargar/:filename', (req, res) => {
|
||||
try {
|
||||
const safeFilename = path.basename(req.params.filename);
|
||||
const targetPath = path.join(backupsDir, safeFilename);
|
||||
if (!fs.existsSync(targetPath)) {
|
||||
return res.status(404).send('Archivo de respaldo no encontrado.');
|
||||
}
|
||||
res.download(targetPath, safeFilename);
|
||||
} catch (err) {
|
||||
res.status(500).send(err.message);
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// CARGA MASIVA DE ESTUDIANTES (DEVELOPER)
|
||||
// ==========================================
|
||||
app.post('/api/developer/estudiantes/importar-masivo', (req, res) => {
|
||||
try {
|
||||
const { escuela_id, estudiantes } = req.body;
|
||||
if (!escuela_id) {
|
||||
return res.status(400).json({ error: 'Debes seleccionar la escuela de destino.' });
|
||||
}
|
||||
if (!Array.isArray(estudiantes) || estudiantes.length === 0) {
|
||||
return res.status(400).json({ error: 'No se recibieron estudiantes para importar.' });
|
||||
}
|
||||
|
||||
const escuela = db.prepare('SELECT id, codigo, nombre FROM escuelas WHERE id = ?').get(escuela_id);
|
||||
if (!escuela) {
|
||||
return res.status(404).json({ error: 'La escuela seleccionada no existe.' });
|
||||
}
|
||||
|
||||
const schoolPrefix = (escuela.codigo || 'EST').toUpperCase().trim().replace(/[^A-Z0-9]/g, '');
|
||||
const year = new Date().getFullYear();
|
||||
|
||||
const maxRow = db.prepare('SELECT MAX(id) as maxId FROM estudiantes').get();
|
||||
let currentSeq = (maxRow && maxRow.maxId ? maxRow.maxId : 0) + 1;
|
||||
|
||||
let insertados = 0;
|
||||
let omitidos = 0;
|
||||
const errores = [];
|
||||
const resultados = [];
|
||||
|
||||
const insertEstStmt = db.prepare(`
|
||||
INSERT INTO estudiantes (
|
||||
codigo_estudiante, nombre_completo, edad, grado, seccion,
|
||||
qr_token, pin_seguridad, foto_url, saldo_colones, limite_diario_colones,
|
||||
alergias, padre_nombre, padre_telefono, permitir_transferencias,
|
||||
tarjeta_bloqueada, activo, escuela_id
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, 1, 0, 1, ?)
|
||||
`);
|
||||
|
||||
const insertTxStmt = db.prepare(`
|
||||
INSERT INTO transacciones_saldo (
|
||||
estudiante_id, tipo, monto_colones, saldo_anterior, saldo_nuevo, descripcion
|
||||
) VALUES (?, 'recarga_manual', ?, 0, ?, 'Saldo inicial asignado por importación masiva')
|
||||
`);
|
||||
|
||||
const insertUserStmt = db.prepare(`
|
||||
INSERT INTO usuarios (username, password_hash, rol, nombre, activo, escuela_id)
|
||||
VALUES (?, ?, 'estudiante', ?, 1, ?)
|
||||
`);
|
||||
|
||||
const processImport = db.transaction(() => {
|
||||
for (let i = 0; i < estudiantes.length; i++) {
|
||||
const item = estudiantes[i];
|
||||
const rawNombre = item.nombre_completo || item.nombre || '';
|
||||
const cleanNombre = String(rawNombre).trim();
|
||||
|
||||
if (!cleanNombre) {
|
||||
omitidos++;
|
||||
errores.push(`Fila ${i + 1}: Nombre vacío.`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const grado = String(item.grado || item.nivel || 'Primaria').trim();
|
||||
const seccion = String(item.seccion || item.grupo || 'A').trim();
|
||||
const saldoInicial = Math.max(0, parseInt(item.saldo_inicial || item.saldo || 0, 10));
|
||||
const limiteDiario = Math.max(500, parseInt(item.limite_diario || 3000, 10));
|
||||
const alergias = String(item.alergias || 'Ninguna conocida').trim();
|
||||
const padreNombre = String(item.padre_nombre || item.encargado || '').trim();
|
||||
const padreTelefono = String(item.padre_telefono || item.telefono || '').trim();
|
||||
const edad = parseInt(item.edad || 10, 10);
|
||||
const pin = String(item.pin || '1234').trim();
|
||||
|
||||
let codigoEstudiante = item.codigo ? String(item.codigo).trim().toUpperCase() : null;
|
||||
if (codigoEstudiante) {
|
||||
const existe = db.prepare('SELECT id FROM estudiantes WHERE codigo_estudiante = ?').get(codigoEstudiante);
|
||||
if (existe) {
|
||||
omitidos++;
|
||||
errores.push(`Fila ${i + 1} ("${cleanNombre}"): El código "${codigoEstudiante}" ya está registrado.`);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
codigoEstudiante = `${schoolPrefix}-${year}-${String(currentSeq).padStart(5, '0')}`;
|
||||
}
|
||||
|
||||
const primerNombre = cleanNombre.split(' ')[0].toUpperCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||
const randomHex = Math.random().toString(16).substring(2, 6).toUpperCase();
|
||||
const qrToken = `QR-${schoolPrefix}-${primerNombre}-${year}-${String(currentSeq).padStart(5, '0')}-${randomHex}`;
|
||||
|
||||
const resEst = insertEstStmt.run(
|
||||
codigoEstudiante,
|
||||
cleanNombre,
|
||||
edad,
|
||||
grado,
|
||||
seccion,
|
||||
qrToken,
|
||||
pin,
|
||||
saldoInicial,
|
||||
limiteDiario,
|
||||
alergias,
|
||||
padreNombre,
|
||||
padreTelefono,
|
||||
escuela_id
|
||||
);
|
||||
|
||||
const newEstId = resEst.lastInsertRowid || resEst.id;
|
||||
|
||||
if (saldoInicial > 0) {
|
||||
insertTxStmt.run(newEstId, saldoInicial, saldoInicial);
|
||||
}
|
||||
|
||||
const usernameEst = primerNombre.toLowerCase() + currentSeq;
|
||||
try {
|
||||
const resUser = insertUserStmt.run(usernameEst, pin, cleanNombre, escuela_id);
|
||||
const userId = resUser.lastInsertRowid || resUser.id;
|
||||
db.prepare('UPDATE estudiantes SET usuario_id = ? WHERE id = ?').run(userId, newEstId);
|
||||
} catch (e) {}
|
||||
|
||||
currentSeq++;
|
||||
insertados++;
|
||||
resultados.push({ id: newEstId, codigo: codigoEstudiante, nombre: cleanNombre });
|
||||
}
|
||||
});
|
||||
|
||||
processImport();
|
||||
|
||||
res.json({
|
||||
exito: true,
|
||||
totalProcesados: estudiantes.length,
|
||||
insertados,
|
||||
omitidos,
|
||||
errores,
|
||||
estudiantes: resultados.slice(0, 100),
|
||||
mensaje: `¡Importación completada! Se crearon ${insertados} estudiante(s) con éxito en "${escuela.nombre}".`
|
||||
});
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Crear nuevo estudiante / usuario + carné QR (escalable a 5 dígitos y prefijos multi-negocio)
|
||||
app.post('/api/admin/estudiantes', (req, res) => {
|
||||
try {
|
||||
@@ -1509,6 +1845,113 @@ app.post('/api/admin/movimientos/:id/revertir', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// EXPORTACIÓN A EXCEL / CSV (ADMIN SODA)
|
||||
// ==========================================
|
||||
function arrayToCsv(headers, rows) {
|
||||
const escapeCell = (cell) => {
|
||||
if (cell === null || cell === undefined) return '';
|
||||
const str = String(cell);
|
||||
if (str.includes(',') || str.includes('"') || str.includes('\n') || str.includes('\r')) {
|
||||
return `"${str.replace(/"/g, '""')}"`;
|
||||
}
|
||||
return str;
|
||||
};
|
||||
const headerLine = headers.map(escapeCell).join(',');
|
||||
const rowLines = rows.map(r => r.map(escapeCell).join(','));
|
||||
return '\uFEFF' + [headerLine, ...rowLines].join('\r\n');
|
||||
}
|
||||
|
||||
// Exportar Ventas a CSV
|
||||
app.get('/api/admin/export/ventas.csv', (req, res) => {
|
||||
try {
|
||||
const escuelaId = req.query.escuela_id ? parseInt(req.query.escuela_id, 10) : null;
|
||||
let query = `
|
||||
SELECT o.id, o.codigo_orden, o.tipo_orden, o.momento_entrega, o.total_colones, o.estado, o.creado_en,
|
||||
e.nombre_completo as estudiante_nombre, e.codigo_estudiante
|
||||
FROM ordenes o
|
||||
JOIN estudiantes e ON o.estudiante_id = e.id
|
||||
`;
|
||||
const params = [];
|
||||
if (escuelaId) {
|
||||
query += ` WHERE e.escuela_id = ? `;
|
||||
params.push(escuelaId);
|
||||
}
|
||||
query += ` ORDER BY o.id DESC LIMIT 2000`;
|
||||
|
||||
const ordenes = db.prepare(query).all(...params);
|
||||
|
||||
const headers = ['Fecha y Hora', 'Código Orden', 'Estudiante', 'Código Est.', 'Tipo Orden', 'Horario Entrega', 'Total (CRC)', 'Estado'];
|
||||
const csvData = ordenes.map(o => {
|
||||
const fechaFmt = o.creado_en ? new Date(o.creado_en).toLocaleString('es-CR') : '';
|
||||
return [
|
||||
fechaFmt,
|
||||
o.codigo_orden,
|
||||
o.estudiante_nombre,
|
||||
o.codigo_estudiante,
|
||||
o.tipo_orden === 'preorden' ? 'Pre-orden' : 'Mostrador',
|
||||
o.momento_entrega || 'Inmediato',
|
||||
o.total_colones,
|
||||
o.estado
|
||||
];
|
||||
});
|
||||
|
||||
const csvOutput = arrayToCsv(headers, csvData);
|
||||
const filename = `ventas_sibopay_${new Date().toISOString().slice(0, 10)}.csv`;
|
||||
res.setHeader('Content-Type', 'text/csv; charset=utf-8');
|
||||
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`);
|
||||
res.send(csvOutput);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Exportar Saldos de Estudiantes a CSV
|
||||
app.get('/api/admin/export/estudiantes.csv', (req, res) => {
|
||||
try {
|
||||
const escuelaId = req.query.escuela_id ? parseInt(req.query.escuela_id, 10) : null;
|
||||
let query = `
|
||||
SELECT e.codigo_estudiante, e.nombre_completo, e.grado, e.seccion,
|
||||
e.saldo_colones, e.limite_diario_colones, e.alergias, e.bloquear_chucherias,
|
||||
e.padre_nombre, e.padre_telefono, e.activo, esc.nombre as escuela_nombre
|
||||
FROM estudiantes e
|
||||
LEFT JOIN escuelas esc ON e.escuela_id = esc.id
|
||||
`;
|
||||
const params = [];
|
||||
if (escuelaId) {
|
||||
query += ` WHERE e.escuela_id = ? `;
|
||||
params.push(escuelaId);
|
||||
}
|
||||
query += ` ORDER BY e.nombre_completo ASC`;
|
||||
|
||||
const rows = db.prepare(query).all(...params);
|
||||
const headers = ['Código Estudiante', 'Nombre Completo', 'Grado', 'Sección', 'Saldo Actual (CRC)', 'Límite Diario (CRC)', 'Alergias / Salud', 'Veto Chatarra', 'Encargado / Padre', 'Teléfono Padre', 'Sede Escolar', 'Estado'];
|
||||
|
||||
const csvData = rows.map(r => [
|
||||
r.codigo_estudiante,
|
||||
r.nombre_completo,
|
||||
r.grado || '',
|
||||
r.seccion || '',
|
||||
r.saldo_colones || 0,
|
||||
r.limite_diario_colones || 3000,
|
||||
r.alergias || 'Ninguna conocida',
|
||||
r.bloquear_chucherias ? 'SÍ (Veto Activo)' : 'NO',
|
||||
r.padre_nombre || '',
|
||||
r.padre_telefono || '',
|
||||
r.escuela_nombre || 'Sede Central',
|
||||
r.activo ? 'Activo' : 'Bloqueado'
|
||||
]);
|
||||
|
||||
const csvOutput = arrayToCsv(headers, csvData);
|
||||
const filename = `estudiantes_saldos_sibopay_${new Date().toISOString().slice(0, 10)}.csv`;
|
||||
res.setHeader('Content-Type', 'text/csv; charset=utf-8');
|
||||
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`);
|
||||
res.send(csvOutput);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// 1. ESTUDIANTES Y QR
|
||||
// ==========================================
|
||||
@@ -1668,7 +2111,7 @@ app.get('/api/qr-image/:token', async (req, res) => {
|
||||
const qrDataUrl = await QRCode.toDataURL(req.params.token, {
|
||||
width: 350,
|
||||
margin: 3,
|
||||
errorCorrectionLevel: 'M',
|
||||
errorCorrectionLevel: 'H',
|
||||
color: {
|
||||
dark: '#000000',
|
||||
light: '#ffffff'
|
||||
@@ -1712,25 +2155,62 @@ app.post('/api/estudiantes/:id/recarga', (req, res) => {
|
||||
// SOLICITUDES DE RECARGA SINPE MÓVIL (PORTAL PADRES & SODA)
|
||||
// ==========================================
|
||||
|
||||
// 0. Generar código de detalle único para recarga SINPE
|
||||
app.post('/api/sinpe/generar-codigo', (req, res) => {
|
||||
try {
|
||||
const { estudiante_id, monto } = req.body;
|
||||
const codigo = generarCodigoDetalleSinpe();
|
||||
let telefono_sinpe = '8888-8888';
|
||||
let titular_sinpe = 'Soda Escolar';
|
||||
let escuela_nombre = 'Soda Escolar';
|
||||
|
||||
if (estudiante_id) {
|
||||
const est = db.prepare(`
|
||||
SELECT e.id, esc.telefono_sinpe, esc.nombre_sinpe, esc.nombre as escuela_nombre
|
||||
FROM estudiantes e
|
||||
LEFT JOIN escuelas esc ON esc.id = e.escuela_id
|
||||
WHERE e.id = ?
|
||||
`).get(estudiante_id);
|
||||
if (est) {
|
||||
if (est.telefono_sinpe) telefono_sinpe = est.telefono_sinpe;
|
||||
if (est.nombre_sinpe) titular_sinpe = est.nombre_sinpe;
|
||||
if (est.escuela_nombre) escuela_nombre = est.escuela_nombre;
|
||||
}
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
codigo,
|
||||
telefono_sinpe,
|
||||
titular_sinpe,
|
||||
escuela_nombre
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// 1. Crear solicitud de recarga (enviada por el padre)
|
||||
app.post('/api/sinpe/solicitar', (req, res) => {
|
||||
try {
|
||||
const { estudiante_id, padre_usuario_id, monto, comprobante, notas } = req.body;
|
||||
const { estudiante_id, padre_usuario_id, monto, comprobante, codigo_detalle, notas } = req.body;
|
||||
if (!estudiante_id) return res.status(400).json({ error: 'Estudiante no especificado' });
|
||||
const montoNum = parseInt(monto, 10);
|
||||
if (isNaN(montoNum) || montoNum <= 0) {
|
||||
return res.status(400).json({ error: 'Ingresa un monto válido mayor a ₡0' });
|
||||
}
|
||||
const cleanComp = String(comprobante || '').trim();
|
||||
if (!cleanComp) {
|
||||
return res.status(400).json({ error: 'Debes ingresar el número de comprobante SINPE' });
|
||||
const cleanCod = codigo_detalle ? String(codigo_detalle).trim() : null;
|
||||
if (!cleanComp && !cleanCod) {
|
||||
return res.status(400).json({ error: 'Debes ingresar el comprobante o código de detalle SINPE' });
|
||||
}
|
||||
|
||||
const nuevaSol = crearSolicitudRecargaSinpe({
|
||||
estudianteId: parseInt(estudiante_id, 10),
|
||||
padreUsuarioId: padre_usuario_id ? parseInt(padre_usuario_id, 10) : null,
|
||||
monto: montoNum,
|
||||
comprobante: cleanComp,
|
||||
comprobante: cleanComp || (cleanCod ? `SINPE-${cleanCod}` : ''),
|
||||
codigoDetalle: cleanCod,
|
||||
notas
|
||||
});
|
||||
|
||||
@@ -1752,7 +2232,7 @@ app.post('/api/sinpe/solicitar', (req, res) => {
|
||||
escuelaId: nuevaSol.escuela_id || 1,
|
||||
payload: {
|
||||
title: '🔔 Nueva Recarga SINPE - SiboPay',
|
||||
body: `Recarga de ₡${montoFmt} para ${payloadNotificacion.estudiante_nombre}. Comprobante: #${payloadNotificacion.comprobante_sinpe}`,
|
||||
body: `Recarga de ₡${montoFmt} para ${payloadNotificacion.estudiante_nombre}. Detalle: ${payloadNotificacion.codigo_detalle || payloadNotificacion.comprobante_sinpe}`,
|
||||
icon: '/icons/icon-192.png',
|
||||
badge: '/icons/icon-192.png',
|
||||
tag: `sinpe-${payloadNotificacion.id || Date.now()}`,
|
||||
@@ -1762,7 +2242,7 @@ app.post('/api/sinpe/solicitar', (req, res) => {
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
mensaje: 'Solicitud de recarga enviada. La soda verificará el comprobante en breve.',
|
||||
mensaje: 'Solicitud de recarga enviada.',
|
||||
solicitud: payloadNotificacion
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -1770,6 +2250,247 @@ app.post('/api/sinpe/solicitar', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 1b. Validar SINPE en tiempo real por correo bancario
|
||||
app.post('/api/sinpe/validar', async (req, res) => {
|
||||
try {
|
||||
const { estudiante_id, monto, codigo, comprobante, solicitud_id, padre_usuario_id } = req.body;
|
||||
if (!estudiante_id) return res.status(400).json({ error: 'Estudiante no especificado' });
|
||||
const montoNum = parseInt(monto, 10);
|
||||
if (isNaN(montoNum) || montoNum <= 0) {
|
||||
return res.status(400).json({ error: 'Ingresa un monto válido mayor a ₡0' });
|
||||
}
|
||||
|
||||
const cleanCod = codigo ? String(codigo).trim() : null;
|
||||
const cleanComp = comprobante ? String(comprobante).trim() : null;
|
||||
|
||||
if (!cleanCod && !cleanComp) {
|
||||
return res.status(400).json({ error: 'Se requiere el código de detalle (ej. SIBO-XXXX) o el número de comprobante para validar.' });
|
||||
}
|
||||
|
||||
// 1. Escaneo en caliente del buzón IMAP (si está configurado)
|
||||
try {
|
||||
await checkSinpeEmailsOnce(db);
|
||||
} catch (scanErr) {
|
||||
console.warn('⚠️ [SINPE Validar] Error en escaneo IMAP caliente:', scanErr.message);
|
||||
}
|
||||
|
||||
// 2. Buscar en las transacciones registradas
|
||||
const busqueda = buscarTransaccionSinpeBanco({
|
||||
codigoDetalle: cleanCod,
|
||||
comprobante: cleanComp,
|
||||
monto: montoNum
|
||||
});
|
||||
|
||||
if (busqueda.error) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
verificado: false,
|
||||
error: busqueda.error,
|
||||
message: busqueda.mensaje
|
||||
});
|
||||
}
|
||||
|
||||
if (busqueda.encontrado && busqueda.tx) {
|
||||
const tx = busqueda.tx;
|
||||
marcarTransaccionSinpeUsada(tx.id, estudiante_id);
|
||||
|
||||
let resultadoAprobacion = null;
|
||||
if (solicitud_id) {
|
||||
try {
|
||||
resultadoAprobacion = procesarSolicitudRecargaSinpe({
|
||||
solicitudId: parseInt(solicitud_id, 10),
|
||||
accion: 'aprobar',
|
||||
usuarioId: null,
|
||||
motivo: `Validación automática por correo (${tx.origin_bank} - Ref #${tx.reference_number || tx.codigo_detalle})`
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
if (!resultadoAprobacion) {
|
||||
resultadoAprobacion = recargaSaldoTransaction({
|
||||
estudianteId: parseInt(estudiante_id, 10),
|
||||
monto: montoNum,
|
||||
comprobanteSinpe: tx.reference_number || cleanComp || tx.codigo_detalle,
|
||||
descripcion: `Recarga SINPE verificada automáticamente por correo (${tx.origin_bank} Ref #${tx.reference_number || tx.codigo_detalle})`
|
||||
});
|
||||
}
|
||||
|
||||
const est = db.prepare('SELECT nombre_completo, saldo_colones FROM estudiantes WHERE id = ?').get(estudiante_id);
|
||||
const nuevoSaldo = est ? est.saldo_colones : (resultadoAprobacion.saldo_nuevo || montoNum);
|
||||
|
||||
broadcastEvent('recarga_exitosa', {
|
||||
estudiante_id,
|
||||
monto: montoNum,
|
||||
saldo_nuevo: nuevoSaldo,
|
||||
origen_banco: tx.origin_bank,
|
||||
referencia: tx.reference_number
|
||||
});
|
||||
broadcastEvent('saldo_actualizado', { id: estudiante_id, saldo_colones: nuevoSaldo });
|
||||
broadcastEvent('estudiante_actualizado', { id: estudiante_id, saldo_colones: nuevoSaldo });
|
||||
|
||||
console.log(`🎉 [SINPE Validado] ₡${montoNum} acreditados a estudiante #${estudiante_id} vía ${tx.origin_bank} (Ref #${tx.reference_number})`);
|
||||
|
||||
return res.json({
|
||||
success: true,
|
||||
verificado: true,
|
||||
monto: montoNum,
|
||||
banco: tx.origin_bank,
|
||||
comprobante: tx.reference_number,
|
||||
codigo: tx.codigo_detalle,
|
||||
saldo_nuevo: nuevoSaldo,
|
||||
mensaje: `🎉 ¡Pago verificado con éxito! Se acreditaron ₡${montoNum.toLocaleString('es-CR')} de ${tx.origin_bank}.`
|
||||
});
|
||||
}
|
||||
|
||||
// Si aún no se detectó el correo
|
||||
return res.json({
|
||||
success: false,
|
||||
verificado: false,
|
||||
retry: true,
|
||||
mensaje: `⏳ Aún no detectamos la notificación del banco en el correo. Si acabas de realizar la transferencia, espera unos 10-15 segundos a que el banco emita el comprobante y presiona "Validar SINPE" nuevamente.`
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error en /api/sinpe/validar:', error);
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// 1c. Simular correo bancario entrante (para pruebas y demos)
|
||||
app.post('/api/sinpe/simular-correo', (req, res) => {
|
||||
try {
|
||||
const { codigo, monto, banco, remitente, telefono, comprobante } = req.body;
|
||||
if (!monto) return res.status(400).json({ error: 'Monto es requerido' });
|
||||
const tx = simularSinpeEmail(db, { codigo, monto, banco, remitente, telefono, comprobante });
|
||||
res.json({ success: true, mensaje: 'Transacción simulada registrada exitosamente', tx });
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// 1d. Webhook receptor en el aire para Cloudflare Email Routing / Worker
|
||||
app.post('/api/sinpe/webhook-email', express.text({ type: ['text/*', 'application/json', '*/*'], limit: '25mb' }), async (req, res) => {
|
||||
try {
|
||||
const rawData = req.body;
|
||||
let subject = '';
|
||||
let bodyText = '';
|
||||
let bodyHtml = '';
|
||||
let from = '';
|
||||
|
||||
if (typeof rawData === 'string') {
|
||||
try {
|
||||
const parsed = await simpleParser(rawData);
|
||||
subject = parsed.subject || '';
|
||||
bodyText = parsed.text || '';
|
||||
bodyHtml = parsed.html || '';
|
||||
from = parsed.from ? parsed.from.text : '';
|
||||
} catch (e) {
|
||||
bodyText = rawData;
|
||||
}
|
||||
if (!bodyText && !bodyHtml) {
|
||||
bodyText = rawData;
|
||||
} else {
|
||||
bodyText = `${bodyText}\n${rawData}`;
|
||||
}
|
||||
} else if (typeof rawData === 'object' && rawData !== null) {
|
||||
subject = rawData.subject || '';
|
||||
bodyText = rawData.text || rawData.body || '';
|
||||
from = rawData.from || '';
|
||||
}
|
||||
|
||||
const parsedSinpe = parseSinpeEmail(subject, bodyText, bodyHtml, from);
|
||||
|
||||
if (parsedSinpe.isSinpe && parsedSinpe.amountCrc > 0) {
|
||||
const txId = `sinpe_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`;
|
||||
const normCod = parsedSinpe.codigoDetalleNormalizado || '';
|
||||
const refNum = parsedSinpe.referenceNumber || (normCod ? `REF-${normCod}` : `TX-${Date.now()}`);
|
||||
|
||||
// Evitar duplicados exactos: solo si el código ya fue recibido previamente
|
||||
const existing = db.prepare(`
|
||||
SELECT id FROM sinpe_transacciones_banco
|
||||
WHERE (codigo_detalle_norm = ? AND codigo_detalle_norm IS NOT NULL AND codigo_detalle_norm != '')
|
||||
OR (reference_number = ? AND reference_number IS NOT NULL AND codigo_detalle_norm = ?)
|
||||
LIMIT 1
|
||||
`).get(normCod || '__none__', refNum, normCod || '__none__');
|
||||
|
||||
if (!existing) {
|
||||
db.prepare(`
|
||||
INSERT INTO sinpe_transacciones_banco
|
||||
(id, reference_number, codigo_detalle, codigo_detalle_norm, amount_crc, sender_phone, sender_name, origin_bank, status, raw_data)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, 'unclaimed', ?)
|
||||
`).run(
|
||||
txId,
|
||||
refNum,
|
||||
parsedSinpe.codigoDetalle || null,
|
||||
normCod || null,
|
||||
parsedSinpe.amountCrc,
|
||||
parsedSinpe.senderPhone || null,
|
||||
parsedSinpe.senderName || 'Cliente SINPE',
|
||||
parsedSinpe.originBank || 'SINPE Móvil',
|
||||
JSON.stringify({ from, subject, summary: parsedSinpe.rawSummary, source: 'cloudflare_webhook' })
|
||||
);
|
||||
console.log(`⚡ [SINPE Webhook Cloudflare] Correo atrapado en el aire: ₡${parsedSinpe.amountCrc} | Cód: ${parsedSinpe.codigoDetalle || 'N/A'} | Ref: #${refNum} | Banco: ${parsedSinpe.originBank}`);
|
||||
|
||||
// AUTO-CONCILIACIÓN INMEDIATA:
|
||||
// Si hay una solicitud pendiente con este código y monto, aprobarla al instante
|
||||
if (normCod || refNum) {
|
||||
try {
|
||||
const solPendiente = db.prepare(`
|
||||
SELECT id, estudiante_id, monto_colones, codigo_detalle, comprobante_sinpe
|
||||
FROM solicitudes_recarga_sinpe
|
||||
WHERE estado = 'pendiente'
|
||||
AND (
|
||||
(codigo_detalle IS NOT NULL AND (codigo_detalle = ? OR UPPER(REPLACE(REPLACE(codigo_detalle, '-', ''), ' ', '')) = ?))
|
||||
OR (comprobante_sinpe IS NOT NULL AND (comprobante_sinpe = ? OR comprobante_sinpe = ? OR comprobante_sinpe LIKE ?))
|
||||
)
|
||||
ORDER BY creado_en DESC LIMIT 1
|
||||
`).get(
|
||||
parsedSinpe.codigoDetalle || '__none__',
|
||||
normCod || '__none__',
|
||||
refNum,
|
||||
`SINPE-${parsedSinpe.codigoDetalle}`,
|
||||
`%${refNum}%`
|
||||
);
|
||||
|
||||
if (solPendiente && Math.abs(Number(solPendiente.monto_colones) - parsedSinpe.amountCrc) < 0.01) {
|
||||
marcarTransaccionSinpeUsada(txId, solPendiente.estudiante_id);
|
||||
procesarSolicitudRecargaSinpe({
|
||||
solicitudId: solPendiente.id,
|
||||
accion: 'aprobar',
|
||||
usuarioId: null,
|
||||
motivo: `Validación automática por correo (${parsedSinpe.originBank} Ref #${refNum})`
|
||||
});
|
||||
|
||||
const est = db.prepare('SELECT saldo_colones FROM estudiantes WHERE id = ?').get(solPendiente.estudiante_id);
|
||||
const nuevoSaldo = est ? est.saldo_colones : parsedSinpe.amountCrc;
|
||||
|
||||
broadcastEvent('recarga_exitosa', {
|
||||
estudiante_id: solPendiente.estudiante_id,
|
||||
monto: parsedSinpe.amountCrc,
|
||||
saldo_nuevo: nuevoSaldo,
|
||||
origen_banco: parsedSinpe.originBank,
|
||||
referencia: refNum
|
||||
});
|
||||
broadcastEvent('saldo_actualizado', { id: solPendiente.estudiante_id, saldo_colones: nuevoSaldo });
|
||||
broadcastEvent('estudiante_actualizado', { id: solPendiente.estudiante_id, saldo_colones: nuevoSaldo });
|
||||
broadcastEvent('solicitud_sinpe_procesada', { id: solPendiente.id, estado: 'aprobada' });
|
||||
|
||||
console.log(`🎉 [SINPE Auto-Conciliado] Solicitud #${solPendiente.id} aprobada automáticamente al llegar el correo bancario (+₡${parsedSinpe.amountCrc} a estudiante #${solPendiente.estudiante_id})`);
|
||||
}
|
||||
} catch (autoErr) {
|
||||
console.warn('⚠️ Error en auto-conciliación de webhook:', autoErr.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ success: true, parsed: parsedSinpe });
|
||||
} catch (error) {
|
||||
console.error('Error en /api/sinpe/webhook-email:', error);
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// 2. Listar solicitudes (para la soda/admin)
|
||||
app.get('/api/sinpe/solicitudes', (req, res) => {
|
||||
try {
|
||||
@@ -1810,8 +2531,11 @@ app.post('/api/sinpe/procesar', (req, res) => {
|
||||
broadcastEvent('recarga_exitosa', resultado);
|
||||
broadcastEvent('estudiante_actualizado', { id: resultado.estudiante_id, saldo_colones: resultado.saldo_nuevo });
|
||||
broadcastEvent('saldo_actualizado', { id: resultado.estudiante_id, saldo_colones: resultado.saldo_nuevo });
|
||||
} else if (resultado.estado === 'rechazada') {
|
||||
broadcastEvent('sinpe_rechazado', resultado);
|
||||
}
|
||||
broadcastEvent('solicitud_sinpe_procesada', resultado);
|
||||
broadcastEvent('movimiento_registrado', resultado);
|
||||
|
||||
res.json({ success: true, resultado });
|
||||
} catch (error) {
|
||||
@@ -1960,22 +2684,17 @@ app.post('/api/transferencias', (req, res) => {
|
||||
|
||||
app.get('/api/productos', (req, res) => {
|
||||
try {
|
||||
const escuelaId = req.query.escuela_id ? parseInt(req.query.escuela_id, 10) : null;
|
||||
const escuelaId = req.query.escuela_id ? parseInt(req.query.escuela_id, 10) : 1;
|
||||
const categorias = db.prepare('SELECT * FROM categorias ORDER BY orden ASC').all();
|
||||
|
||||
let sql = `
|
||||
const sql = `
|
||||
SELECT p.*, c.nombre as categoria_nombre, c.icono as categoria_icono
|
||||
FROM productos p
|
||||
JOIN categorias c ON p.categoria_id = c.id
|
||||
WHERE (p.escuela_id = ? OR p.escuela_id IS NULL)
|
||||
ORDER BY p.categoria_id, p.id ASC
|
||||
`;
|
||||
const params = [];
|
||||
if (escuelaId) {
|
||||
sql += ' WHERE (p.escuela_id = ? OR p.escuela_id IS NULL) ';
|
||||
params.push(escuelaId);
|
||||
}
|
||||
sql += ' ORDER BY p.categoria_id, p.nombre';
|
||||
|
||||
const productos = db.prepare(sql).all(...params);
|
||||
const productos = db.prepare(sql).all(escuelaId);
|
||||
|
||||
res.json({ categorias, productos });
|
||||
} catch (error) {
|
||||
@@ -2140,6 +2859,7 @@ app.get('/api/ordenes', (req, res) => {
|
||||
const ordenes = db.prepare(query).all(...params);
|
||||
const resultado = ordenes.map(o => ({
|
||||
...o,
|
||||
momento_entrega_label: formatMomentoLabel(o.momento_entrega),
|
||||
items: Array.isArray(o.items_json)
|
||||
? o.items_json
|
||||
: (typeof o.items_json === 'string' ? JSON.parse(o.items_json || '[]') : [])
|
||||
@@ -2215,6 +2935,7 @@ app.post('/api/ordenes/despachar-qr', (req, res) => {
|
||||
id: preorden.id,
|
||||
codigo: preorden.codigo_orden,
|
||||
momento_entrega: preorden.momento_entrega,
|
||||
momento_entrega_label: formatMomentoLabel(preorden.momento_entrega),
|
||||
total: preorden.total_colones,
|
||||
items
|
||||
}
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
/**
|
||||
* Servicio de Lectura y Conciliación IMAP de Notificaciones SINPE Móvil para SiboPay
|
||||
*/
|
||||
|
||||
const imapSimple = require('imap-simple');
|
||||
const { simpleParser } = require('mailparser');
|
||||
const { parseSinpeEmail, normalizarCodigoDetalle } = require('./sinpeParser');
|
||||
|
||||
let isChecking = false;
|
||||
|
||||
const getImapConfig = () => {
|
||||
const cleanPassword = (process.env.SINPE_EMAIL_PASSWORD || '').replace(/\s+/g, '');
|
||||
return {
|
||||
imap: {
|
||||
user: process.env.SINPE_EMAIL_USER || '',
|
||||
password: cleanPassword,
|
||||
host: process.env.SINPE_IMAP_HOST || 'imap.gmail.com',
|
||||
port: parseInt(process.env.SINPE_IMAP_PORT || '993', 10),
|
||||
tls: true,
|
||||
authTimeout: 10000,
|
||||
tlsOptions: { rejectUnauthorized: false }
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Escanea la bandeja de entrada buscando los correos más recientes de notificación SINPE
|
||||
* y los guarda en la base de datos de transacciones.
|
||||
*/
|
||||
async function checkSinpeEmailsOnce(db) {
|
||||
if (isChecking) return { scanned: 0, status: 'already_running' };
|
||||
|
||||
const user = process.env.SINPE_EMAIL_USER;
|
||||
const pass = process.env.SINPE_EMAIL_PASSWORD;
|
||||
const isEnabled = process.env.SINPE_IMAP_ENABLED === 'true' || process.env.SINPE_IMAP_ENABLED === '1';
|
||||
|
||||
if (!isEnabled || !user || !pass) {
|
||||
return { scanned: 0, status: 'disabled_or_unconfigured' };
|
||||
}
|
||||
|
||||
isChecking = true;
|
||||
let connection = null;
|
||||
let savedCount = 0;
|
||||
|
||||
try {
|
||||
const config = getImapConfig();
|
||||
connection = await imapSimple.connect(config);
|
||||
const box = await connection.openBox('INBOX');
|
||||
|
||||
const totalMessages = (box && box.messages && box.messages.total) || 0;
|
||||
if (totalMessages === 0) {
|
||||
return { scanned: 0, status: 'empty_inbox' };
|
||||
}
|
||||
|
||||
// Consultar los últimos 25 correos
|
||||
const startSeq = Math.max(1, totalMessages - 24);
|
||||
const searchCriteria = [`${startSeq}:${totalMessages}`];
|
||||
const fetchOptions = {
|
||||
bodies: ['HEADER', 'TEXT', ''],
|
||||
markSeen: false,
|
||||
struct: true
|
||||
};
|
||||
|
||||
const messages = await connection.search(searchCriteria, fetchOptions);
|
||||
|
||||
if (messages && messages.length > 0) {
|
||||
for (const msg of messages) {
|
||||
try {
|
||||
const headerPart = msg.parts.find(p => p.which === 'HEADER');
|
||||
const rawHeader = headerPart ? headerPart.body : {};
|
||||
let subject = Array.isArray(rawHeader.subject) ? rawHeader.subject[0] : (rawHeader.subject || '');
|
||||
let from = Array.isArray(rawHeader.from) ? rawHeader.from[0] : (rawHeader.from || '');
|
||||
|
||||
const allPart = msg.parts.find(p => p.which === '' || p.which === 'TEXT');
|
||||
let bodyText = '';
|
||||
let bodyHtml = '';
|
||||
|
||||
if (allPart && allPart.body) {
|
||||
const parsed = await simpleParser(allPart.body);
|
||||
bodyText = parsed.text || '';
|
||||
bodyHtml = parsed.html || '';
|
||||
if (parsed.subject) subject = parsed.subject;
|
||||
if (parsed.from && parsed.from.text) from = parsed.from.text;
|
||||
}
|
||||
|
||||
const parsedSinpe = parseSinpeEmail(subject, bodyText, bodyHtml, from);
|
||||
|
||||
if (parsedSinpe.isSinpe && parsedSinpe.amountCrc > 0) {
|
||||
const txId = `sinpe_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`;
|
||||
const normCod = parsedSinpe.codigoDetalleNormalizado || '';
|
||||
const refNum = parsedSinpe.referenceNumber || (normCod ? `REF-${normCod}` : `TX-${Date.now()}`);
|
||||
|
||||
// Insertar o ignorar si ya existe
|
||||
try {
|
||||
if (db) {
|
||||
const existing = db.prepare(`
|
||||
SELECT id FROM sinpe_transacciones_banco
|
||||
WHERE (codigo_detalle_norm = ? AND codigo_detalle_norm IS NOT NULL AND codigo_detalle_norm != '')
|
||||
OR (reference_number = ? AND reference_number IS NOT NULL AND reference_number != '')
|
||||
LIMIT 1
|
||||
`).get(normCod || '__none__', refNum);
|
||||
|
||||
if (!existing) {
|
||||
db.prepare(`
|
||||
INSERT INTO sinpe_transacciones_banco
|
||||
(id, reference_number, codigo_detalle, codigo_detalle_norm, amount_crc, sender_phone, sender_name, origin_bank, status, raw_data)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, 'unclaimed', ?)
|
||||
`).run(
|
||||
txId,
|
||||
refNum,
|
||||
parsedSinpe.codigoDetalle || null,
|
||||
normCod || null,
|
||||
parsedSinpe.amountCrc,
|
||||
parsedSinpe.senderPhone || null,
|
||||
parsedSinpe.senderName || 'Cliente SINPE',
|
||||
parsedSinpe.originBank || 'SINPE Móvil',
|
||||
JSON.stringify({ from, subject, summary: parsedSinpe.rawSummary })
|
||||
);
|
||||
savedCount++;
|
||||
console.log(`💵 [SINPE IMAP] Notificación registrada: ₡${parsedSinpe.amountCrc} | Código: ${parsedSinpe.codigoDetalle || 'N/A'} | Ref: #${refNum} | Banco: ${parsedSinpe.originBank}`);
|
||||
}
|
||||
}
|
||||
} catch (dbErr) {
|
||||
console.warn('⚠️ [SINPE IMAP] Error al persistir en BD:', dbErr.message);
|
||||
}
|
||||
}
|
||||
} catch (msgErr) {
|
||||
console.warn('⚠️ [SINPE IMAP] Error procesando correo:', msgErr.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { scanned: messages ? messages.length : 0, saved: savedCount, status: 'ok' };
|
||||
} catch (err) {
|
||||
console.error('❌ [SINPE IMAP] Error de conexión:', err.message);
|
||||
return { scanned: 0, status: 'error', error: err.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
try { connection.end(); } catch (_) {}
|
||||
}
|
||||
isChecking = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserta manualmente una transacción simulada (útil para pruebas inmediatas en QA o sin transferir dinero real)
|
||||
*/
|
||||
function simularSinpeEmail(db, { codigo, codigoDetalle, monto, banco, remitente, telefono, comprobante }) {
|
||||
if (!db) throw new Error('DB no inicializada');
|
||||
const txId = `sim_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`;
|
||||
const rawCod = codigo || codigoDetalle || null;
|
||||
const cleanCod = rawCod ? String(rawCod).trim() : null;
|
||||
const normCod = cleanCod ? normalizarCodigoDetalle(cleanCod) : null;
|
||||
const refNum = comprobante ? String(comprobante).trim() : (normCod ? `REF-${normCod}` : `SIM-${Date.now()}`);
|
||||
const montoNum = parseInt(monto, 10) || 1000;
|
||||
|
||||
db.prepare(`
|
||||
INSERT INTO sinpe_transacciones_banco
|
||||
(id, reference_number, codigo_detalle, codigo_detalle_norm, amount_crc, sender_phone, sender_name, origin_bank, status, raw_data)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, 'unclaimed', ?)
|
||||
`).run(
|
||||
txId,
|
||||
refNum,
|
||||
cleanCod,
|
||||
normCod,
|
||||
montoNum,
|
||||
telefono || '8888-1122',
|
||||
remitente || 'Padre de Familia',
|
||||
banco || 'BAC Credomatic',
|
||||
JSON.stringify({ simulado: true, fecha: new Date().toISOString() })
|
||||
);
|
||||
|
||||
return {
|
||||
id: txId,
|
||||
codigo_detalle: cleanCod,
|
||||
codigo_detalle_norm: normCod,
|
||||
reference_number: refNum,
|
||||
amount_crc: montoNum,
|
||||
origin_bank: banco || 'BAC Credomatic',
|
||||
sender_name: remitente || 'Padre de Familia'
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
checkSinpeEmailsOnce,
|
||||
simularSinpeEmail
|
||||
};
|
||||
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* Parser de Notificaciones Bancarias de SINPE Móvil (Costa Rica) para SiboPay
|
||||
* Extrae:
|
||||
* - Códigos de detalle SiboPay (SIBO-XXXX o SIBOXXXX) con tolerancia total a guiones/espacios/mayúsculas
|
||||
* - Montos en colones (₡ / CRC)
|
||||
* - Números de comprobante / referencia bancaria
|
||||
* - Banco de origen (BAC, BCR, BNCR, Promerica, Davivienda, Scotiabank, etc.)
|
||||
* - Teléfono y nombre del remitente
|
||||
*/
|
||||
|
||||
function stripHtml(html = '') {
|
||||
return String(html)
|
||||
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '')
|
||||
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '')
|
||||
.replace(/<[^>]+>/g, ' ')
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/&/gi, '&')
|
||||
.replace(/</gi, '<')
|
||||
.replace(/>/gi, '>')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Normaliza un código de SINPE para comparación tolerante
|
||||
* Ejemplos: "SIBO-7K9M", "sibo7k9m", "SIBO 7k9m", "sibo-7k9m" -> "SIBO7K9M"
|
||||
*/
|
||||
function normalizarCodigoDetalle(codigo = '') {
|
||||
if (!codigo) return '';
|
||||
const str = String(codigo).trim();
|
||||
const match = str.match(/\bSIBO[\s\-_]?([A-Za-z0-9]{3,8})\b/i) || str.match(/SIBO[\s\-_]?([A-Za-z0-9]{3,8})/i);
|
||||
if (match) {
|
||||
return `SIBO${match[1].toUpperCase()}`;
|
||||
}
|
||||
return str.replace(/[\s\-_]/g, '').toUpperCase();
|
||||
}
|
||||
|
||||
function parseSinpeEmail(arg1 = '', bodyText = '', bodyHtml = '', from = '') {
|
||||
let subject = '';
|
||||
let text = '';
|
||||
let html = '';
|
||||
let cleanFrom = '';
|
||||
|
||||
if (typeof arg1 === 'object' && arg1 !== null) {
|
||||
subject = arg1.subject || '';
|
||||
text = arg1.text || arg1.bodyText || '';
|
||||
html = arg1.html || arg1.bodyHtml || '';
|
||||
cleanFrom = String(arg1.from || '').toLowerCase();
|
||||
} else {
|
||||
subject = String(arg1 || '');
|
||||
text = String(bodyText || '');
|
||||
html = String(bodyHtml || '');
|
||||
cleanFrom = String(from || '').toLowerCase();
|
||||
}
|
||||
|
||||
const fullText = `${subject}\n${text}\n${stripHtml(html)}`.trim();
|
||||
const lowerText = fullText.toLowerCase();
|
||||
|
||||
// 1. Detección de Banco de Costa Rica
|
||||
let originBank = 'SINPE Móvil CR';
|
||||
if (cleanFrom.includes('bac') || lowerText.includes('bac credomatic') || lowerText.includes('bac san jose')) {
|
||||
originBank = 'BAC Credomatic';
|
||||
} else if (cleanFrom.includes('bncr') || lowerText.includes('banco nacional') || lowerText.includes('bn móvil') || lowerText.includes('bn movil')) {
|
||||
originBank = 'Banco Nacional (BNCR)';
|
||||
} else if (cleanFrom.includes('bancobcr') || cleanFrom.includes('bcr') || lowerText.includes('banco de costa rica')) {
|
||||
originBank = 'Banco de Costa Rica (BCR)';
|
||||
} else if (cleanFrom.includes('promerica') || lowerText.includes('promerica')) {
|
||||
originBank = 'Banco Promerica';
|
||||
} else if (cleanFrom.includes('scotiabank') || lowerText.includes('scotiabank')) {
|
||||
originBank = 'Scotiabank';
|
||||
} else if (cleanFrom.includes('davivienda') || lowerText.includes('davivienda')) {
|
||||
originBank = 'Davivienda';
|
||||
} else if (cleanFrom.includes('wink') || cleanFrom.includes('coopenae') || lowerText.includes('wink')) {
|
||||
originBank = 'Wink (Coopenae)';
|
||||
} else if (cleanFrom.includes('sibopay') || cleanFrom.includes('simulad')) {
|
||||
originBank = 'SiboPay Direct';
|
||||
}
|
||||
|
||||
// 2. Extraer Código de Detalle SiboPay (Tolerancia total a guión, espacios o todo pegado)
|
||||
let codigoDetalle = null;
|
||||
const codigoRegex = /\bSIBO[\s\-_]?([A-Za-z0-9]{3,8})\b/i;
|
||||
const matchCodigo = fullText.match(codigoRegex) || fullText.match(/SIBO[\s\-_]?([A-Za-z0-9]{3,8})/i);
|
||||
if (matchCodigo) {
|
||||
codigoDetalle = `SIBO-${matchCodigo[1].toUpperCase()}`;
|
||||
}
|
||||
|
||||
// 3. Extraer Monto en Colones (₡ / CRC / ¢)
|
||||
let amountCrc = 0;
|
||||
const amountPatterns = [
|
||||
/(?:monto|importe|valor|suma|por concepto de|total|cr[eé]dito|acreditad[oa]|recibid[oa]|transferid[oa])\s*(?:de|por)?\s*[:#=\-]?\s*(?:₡|¢|CRC)?\s*([0-9]+(?:[,.\s][0-9]+)*)\s*(?:colones|crc|¢|₡)?/i,
|
||||
/(?:₡|¢|CRC)\s*[:#=\-]?\s*([0-9]+(?:[,.\s][0-9]+)*)/i,
|
||||
/([0-9]+(?:[,.\s][0-9]+)*)\s*(?:colones|crc|¢|₡)/i,
|
||||
/(?:crc|colones)\s*[:#=\-]?\s*([0-9]+(?:[,.\s][0-9]+)*)/i
|
||||
];
|
||||
|
||||
for (const regex of amountPatterns) {
|
||||
const match = fullText.match(regex);
|
||||
if (match && match[1]) {
|
||||
let numStr = match[1].trim().replace(/\s+/g, '');
|
||||
if (numStr.includes('.') && numStr.includes(',')) {
|
||||
if (numStr.indexOf('.') < numStr.indexOf(',')) {
|
||||
numStr = numStr.replace(/\./g, '').replace(',', '.');
|
||||
} else {
|
||||
numStr = numStr.replace(/,/g, '');
|
||||
}
|
||||
} else if (numStr.includes(',')) {
|
||||
const parts = numStr.split(',');
|
||||
if (parts[1] && parts[1].length === 2) {
|
||||
numStr = parts[0] + '.' + parts[1];
|
||||
} else {
|
||||
numStr = numStr.replace(/,/g, '');
|
||||
}
|
||||
}
|
||||
const parsedNum = parseFloat(numStr);
|
||||
if (!isNaN(parsedNum) && parsedNum > 0) {
|
||||
amountCrc = Math.round(parsedNum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Extraer Teléfono Emisor (8 dígitos)
|
||||
let senderPhone = null;
|
||||
const phonePatterns = [
|
||||
/(?:tel[eé]fono|origen|celular|m[oó]vil|remitente|emisor)\s*[:#=\-]?\s*(?:\+?506\s*[-.]?)?([245678]\d{3}[-\s.]?\d{4})/i,
|
||||
/(?:\+?506\s*[-.]?)?([245678]\d{3}[-\s.]?\d{4})/i
|
||||
];
|
||||
for (const regex of phonePatterns) {
|
||||
const match = fullText.match(regex);
|
||||
if (match && match[1]) {
|
||||
const digits = match[1].replace(/\D/g, '');
|
||||
if (digits.length === 8) {
|
||||
senderPhone = `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Extraer Número de Comprobante / Referencia Bancaria
|
||||
let referenceNumber = null;
|
||||
const refPatterns = [
|
||||
/(?:n[uú]mero\s*(?:de\s*)?|n[o°º]\.?\s*(?:de\s*)?|c[oó]digo\s*(?:de\s*)?)?(?:comprobante|referencia|transacci[oó]n|autorizaci[oó]n|operaci[oó]n|documento|folio|confirmaci[oó]n|trf|ref|doc|aut)(?:\s+de\s+(?:transferencia|pago|operaci[oó]n|dep[oó]sito|transacci[oó]n))?\s*[:#=\.\-]?\s*([A-Za-z0-9\-_]{4,35})/i,
|
||||
/#\s*([A-Za-z0-9\-_]{4,24})/,
|
||||
/(?:SINPE|TRF|DOC|REF|AUT)[-_]?([0-9]{4,20})/i
|
||||
];
|
||||
for (const regex of refPatterns) {
|
||||
const match = fullText.match(regex);
|
||||
if (match && match[1]) {
|
||||
const clean = match[1].trim();
|
||||
if (!clean.toUpperCase().startsWith('SIBO') && clean.length >= 4) {
|
||||
referenceNumber = clean;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Nombre del remitente si está disponible
|
||||
let senderName = null;
|
||||
const nameMatch = fullText.match(/(?:de|de parte de|remitente|ordenante|cliente|titular)\s*[:#=\-]?\s*([A-Za-zÀ-ÿ\s]{4,40})(?:\n|\r|\.|,|-)/i);
|
||||
if (nameMatch && nameMatch[1]) {
|
||||
const cand = nameMatch[1].trim();
|
||||
if (!cand.toLowerCase().includes('banco') && !cand.toLowerCase().includes('sinpe')) {
|
||||
senderName = cand;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
isSinpe: Boolean(amountCrc > 0 && (codigoDetalle || referenceNumber || originBank !== 'SINPE Móvil CR')),
|
||||
codigoDetalle,
|
||||
codigoDetalleNormalizado: codigoDetalle ? normalizarCodigoDetalle(codigoDetalle) : null,
|
||||
amount: amountCrc,
|
||||
amountCrc,
|
||||
referenceNumber: referenceNumber || (codigoDetalle ? `REF-${codigoDetalle.replace(/[^A-Za-z0-9]/g, '')}` : null),
|
||||
senderPhone: senderPhone || '',
|
||||
senderName: senderName || 'Cliente SINPE',
|
||||
originBank,
|
||||
rawSummary: subject || ''
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseSinpeEmail,
|
||||
normalizarCodigoDetalle
|
||||
};
|
||||