319 Commits

Author SHA1 Message Date
7bd946976e Merge branch 'develop' into feature/cierres 2025-08-12 19:24:48 -04:00
4e4c0b7648 Merge pull request 'Se registra todo envio a Toku' (#28) from feature/mas-registro-en-toku into develop
Reviewed-on: #28
2025-08-12 19:20:27 -04:00
47679cd4e4 Se registra todo envio a Toku 2025-08-12 19:18:18 -04:00
27f7d1d579 Mostrar reservas 2025-08-12 19:17:32 -04:00
977b5f76f4 Mostrar reservations 2025-08-08 17:06:16 -04:00
42336133cd Reservations 2025-08-08 17:04:50 -04:00
62aa6a08a0 Listado de cierres 2025-08-05 18:18:05 -04:00
28b272bc55 Merge branch 'develop' into feature/cierres 2025-08-05 15:46:21 -04:00
0f8db5a3f8 Merge pull request 'FIX: Telefono sobre rango maximo de integer en MySQL' (#26) from hotfix/nueva-venta-fallando into develop
Reviewed-on: #26
2025-08-05 15:44:54 -04:00
c38e89d3f1 FIX: Telefono sobre rango maximo de integer en MySQL 2025-08-05 15:41:23 -04:00
909bb2b879 Mostrar reservas 2025-07-22 18:21:05 -04:00
39bc190775 Cambios a modelo Reservation 2025-07-22 18:20:48 -04:00
413709e443 Cambio a migraciones de reservation 2025-07-22 18:19:49 -04:00
808b55cf29 Merge branch 'develop' into feature/cierres 2025-07-22 18:15:55 -04:00
307f2ac7d7 feature/cierres (#25)
Varios cambios

Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl>
Reviewed-on: #25
2025-07-22 13:18:00 +00:00
6c25c5f6d5 FIX: Venta no se actualizaba 2025-07-18 16:20:23 -04:00
3ce41914e5 FIX: Venta desistida pero sin resciliacion 2025-07-18 16:15:30 -04:00
56505fe519 Merge 2025-07-18 13:57:31 -04:00
c7aa731261 FIX: Desistir cuando no existe pie 2025-07-18 13:56:07 -04:00
b211af47d0 Permissions 2025-07-15 23:30:53 -04:00
fd134804a2 Queue runs batch of jobs 2025-07-15 23:18:09 -04:00
d3d6940842 Add retries when job execute failed 2025-07-15 23:07:32 -04:00
c512d7a79a FIX: sacar configuracion de json 2025-07-15 22:56:48 -04:00
9310d65d77 Push can now push json file 2025-07-15 22:19:07 -04:00
8b3cf47762 Pending now in queue 2025-07-15 22:18:45 -04:00
48f992dd47 Merge remote-tracking branch 'origin/feature/cierres' into feature/cierres 2025-07-15 19:07:03 -04:00
2f1628887e Permisos entrypoint 2025-07-15 19:06:07 -04:00
79073ebeb7 Beanstalkd -> Pheanstalk 2025-07-15 19:04:19 -04:00
501151a90e Beanstalkd for jobs 2025-07-14 14:29:41 -04:00
e6e7470bb2 Limit children 2025-07-12 11:00:08 -04:00
2efe4e4a85 Don't run all jobs directly 2025-07-12 10:48:50 -04:00
5ab94e7b2d Reset memory 2025-07-12 10:33:50 -04:00
e037c86e6f Run one job at a time. 2025-07-12 10:31:48 -04:00
595a71d7dd System info 2025-07-12 10:30:32 -04:00
8666499626 Merge remote-tracking branch 'origin/feature/cierres' into feature/cierres 2025-07-12 09:43:19 -04:00
f752256f76 Fcgi idle timeout 2025-07-12 09:43:02 -04:00
6dda5aef00 Habilitar sync 2025-07-03 17:30:58 -04:00
18e79b76d6 Better logging 2025-07-03 17:17:55 -04:00
239376fadc Send all 2025-07-03 17:13:22 -04:00
15ba23bf23 Toku update output 2025-07-03 17:06:00 -04:00
73328240cc Update invoices 2025-07-03 17:00:01 -04:00
495581de8f Update subscriptions 2025-07-03 16:59:41 -04:00
cb0731b67d Update subscriptions 2025-07-03 16:37:57 -04:00
4980839568 Merge remote-tracking branch 'origin/feature/cierres' into feature/cierres 2025-07-01 17:16:39 -04:00
7714e25270 Uso de cuenta al agregar y editar para Toku 2025-07-01 17:14:53 -04:00
8a043b21bc Migracion para guardar account-key de toku 2025-07-01 17:14:21 -04:00
925faeb6f4 Migracion para guardar account-key de toku 2025-07-01 15:28:07 -04:00
f11b7dcd9b PHP more request handlers 2025-06-30 17:25:48 -04:00
e35053edce FastCGI Command max requests 2025-06-30 17:09:45 -04:00
829ab86770 FastCGI pool 2025-06-30 16:39:55 -04:00
4b66694166 Batch queue 2025-06-30 15:52:36 -04:00
d4f8804fbb Batch queue 2025-06-30 15:52:28 -04:00
5f4d8a4bc2 FIX: separate details exception 2025-06-30 11:47:57 -04:00
1fa152c07f FIX: new line exception.log 2025-06-30 11:44:05 -04:00
7f8bd607e3 Job retries 2025-06-27 18:42:47 -04:00
1bbee1121b FIX: Authorization en FastCGI 2025-06-27 18:00:45 -04:00
352e33179c More detail 2025-06-27 17:42:09 -04:00
f34d7338f1 FIX: FasCGI Response 2025-06-27 17:35:17 -04:00
4dd83ae63d FIX: Error observado 2025-06-27 17:24:04 -04:00
e265854958 FIX: Error observado 2025-06-27 17:21:25 -04:00
174b29efff FIX: str_starts_with 2025-06-27 17:17:21 -04:00
1c0f4a5ae9 Try to register fatal errors in file 2025-06-27 17:17:06 -04:00
ccee5f9f56 FIX: more details 2025-06-27 16:58:15 -04:00
9677f11aef FIX: seguir cuando existe error. 2025-06-27 16:56:24 -04:00
c21de2848d FIX: saltarse lineas comentadas 2025-06-27 16:51:16 -04:00
348bb18654 LoggerEnabled Fix 2025-06-25 18:14:43 -04:00
a2a9f4bbb4 LoggerEnabled Fix 2025-06-25 18:11:28 -04:00
ab7328b40b FastCGI 2025-06-25 18:07:08 -04:00
7f97862324 Revisiones 2025-06-25 12:41:28 -04:00
9edf0d9120 Revisiones 2025-06-25 12:22:01 -04:00
ca1ed3f870 Pruebas de integracion con seeds 2025-06-24 21:55:02 -04:00
360537c638 Prueba de integracion para service worker 2025-06-24 14:24:47 -04:00
a6e6b8acc0 Prueba de integracion para service worker 2025-06-24 12:56:03 -04:00
a4e2b4fc7a Seed TipoEstadoPago 2025-06-24 12:55:46 -04:00
479047cd6a Dependencias para testeo 2025-06-24 12:55:02 -04:00
29d9ea8e4a Correr seeds y botar tablas al final 2025-06-24 12:54:48 -04:00
a7cd661938 Registro de worker 2025-06-24 12:54:32 -04:00
7bdcc7168a Container separado a archivo a parte para poder cargarlo en otros lados 2025-06-24 12:54:19 -04:00
d2dff57531 FIX: id de migracion 2025-06-24 12:53:56 -04:00
39198bbe7c get Uf asincronico 2025-06-24 11:20:53 -04:00
200510d60a Prueba Service Worker 2025-06-24 11:20:21 -04:00
ecc67a43c8 Service Worker, corre metodos de servicios asincronicamente, requiere parametros escalares y no retornar mas que bool o void 2025-06-24 11:19:58 -04:00
64791d1fc5 Alias enqueue 2025-06-24 11:16:29 -04:00
4053854410 Prueba UF 2025-06-24 11:16:19 -04:00
a687743762 FIX: No buscar UF para fechas mayores a hoy o día nueve del mes 2025-06-24 11:04:33 -04:00
38fb6f3bcc Pausa a external 2025-06-19 16:47:24 -04:00
1e6bac61b5 FIX: Limpiar archivos 2025-06-19 16:47:06 -04:00
a611ae247d FIX: prorrateo ingresado en valor % 2025-06-12 11:28:04 -04:00
c02c6eb15c FIX: Add custom HttpException 2025-06-10 19:36:56 -04:00
b7e0217cf3 FIX: remove ext-http 2025-06-10 19:35:17 -04:00
2fd1a44984 FIX: install ext-http with external script 2025-06-10 19:04:32 -04:00
fe912db62b Add ext-http 2025-06-10 18:20:05 -04:00
da90160a2a Add ext-http 2025-06-10 18:02:05 -04:00
64047ef577 TOKU: FIX: exceptions 2025-06-10 17:48:36 -04:00
feef90afd6 TOKU: payments loop through pages 2025-06-10 17:46:16 -04:00
32e1e49a97 FIX: cuerpo para borrar payments 2025-06-10 17:34:04 -04:00
11c64cb10f FIX: url para borrar 2025-06-10 17:29:39 -04:00
823f97ce5f FIX: log levels 2025-06-10 17:24:38 -04:00
4ae72199fc Better external logging 2025-06-10 17:00:20 -04:00
d841b1aeed FIX: url de payments en Toku 2025-06-10 16:57:34 -04:00
666cac1958 FIX: url de payments en Toku 2025-06-10 16:54:46 -04:00
71c189e236 FIX: circular dependency 2025-06-10 16:49:34 -04:00
5b6a1c42e3 Toku: reorden 2025-06-10 16:28:46 -04:00
81bce6fe7f Cleanup 2025-06-10 16:28:13 -04:00
e1072ea252 Toku: Reset payments 2025-06-10 16:26:33 -04:00
21473fe52c Valor cuota en CLP 2025-06-10 15:27:09 -04:00
7d589e0e87 Valor cuota en CLF 2025-06-10 15:24:51 -04:00
c48a0d2381 Valor cuota en CLP 2025-06-10 15:14:25 -04:00
abb1ce7299 Mas logging 2025-06-09 12:44:42 -04:00
f1ed9668fc email -> mail 2025-06-06 18:25:12 -04:00
f9ae809fc4 Data too large 2025-06-06 18:10:59 -04:00
06e5292af1 Log add response 2025-06-06 18:10:06 -04:00
47ba664142 Log customer params 2025-06-06 18:04:57 -04:00
d10ee33215 better format for mysql 2025-06-06 17:55:58 -04:00
5134630525 Correct Exceptions 2025-06-06 17:37:42 -04:00
13b246b998 Merge remote-tracking branch 'origin/feature/cierres' into feature/cierres 2025-06-06 17:11:33 -04:00
d601d7d719 Mas logs y middlewares en Guzzle 2025-06-06 17:11:22 -04:00
dc0ae2746b FIX: Correct HMAC validation 2025-06-03 23:07:47 -04:00
eb402b1b71 FIX: notice logs 2025-06-03 23:07:08 -04:00
c5188a1feb HMAC not static 2025-06-03 23:04:57 -04:00
1c3052219c Debug 2025-06-03 22:59:49 -04:00
9e8a388653 Debug 2025-06-03 22:59:03 -04:00
cbee830f7a Debug 2025-06-03 22:55:35 -04:00
d5b8c7f877 FIX: JSON_SEARCH 2025-06-03 22:51:26 -04:00
b668844fea Debug 2025-06-03 22:29:13 -04:00
f2169c9536 FIX: fetch all values in column 2025-06-03 22:27:15 -04:00
48bcb33bad FIX: event_types -> events 2025-06-03 22:24:09 -04:00
92ae0b4ac2 FIX: Missing connection 2025-06-03 22:22:33 -04:00
44540d0dc3 Validated external query log 2025-06-03 22:19:11 -04:00
d9a2f63691 Use webhook secrets to validate 2025-06-03 22:11:57 -04:00
b10accf602 Store webhooks 2025-06-03 22:01:03 -04:00
981858f251 HMAC implementation for signature validation 2025-06-03 21:53:49 -04:00
8c0bd450ef FIX: delete url 2025-06-03 21:26:10 -04:00
8996765cb4 FIX: maxLogLevel 2025-06-03 21:16:44 -04:00
ec2451cb69 FIX: maxLogLevel 2025-06-03 21:12:43 -04:00
37d30d2aec Cleanup logs 2025-06-03 21:09:13 -04:00
afb6e2526f FIX: Timezone cli 2025-06-03 20:14:15 -04:00
a9b6f2a87b FIX: Error code for missing TOKU_ENV 2025-06-03 19:58:36 -04:00
9aeb6906f6 Debug 2025-06-03 19:43:46 -04:00
879d365baf Not needed 2025-06-03 19:42:23 -04:00
1d03b262ae Debug 2025-06-03 19:35:36 -04:00
2c175c8171 Detailed login errors 2025-06-03 19:20:55 -04:00
a750bdbfaa Detailed login errors 2025-06-03 19:20:44 -04:00
7f6d0232c0 Cleanup files 2025-06-03 19:20:09 -04:00
37cff67a1c Log reseteando 2025-06-03 17:06:39 -04:00
bc3d739af9 Cleanup 2025-06-03 16:52:01 -04:00
46efbb57c1 Log body de reset 2025-06-03 16:25:07 -04:00
d71333b334 Queue cada 2 minutos 2025-06-03 16:13:04 -04:00
688b500f1e Parametros correctos 2025-06-03 16:06:14 -04:00
d4b1a66a9e FIX: ventas_ids vacios 2025-06-03 16:02:04 -04:00
e796d91d95 Si token no existe, no se puede borrar 2025-06-03 16:01:48 -04:00
2a442417ce FIX: Loop frequency 2025-06-03 13:01:40 -04:00
3c161ed4e9 Loop frequency 2025-06-03 12:58:57 -04:00
3c8822e531 FIX: Log job requests 2025-06-03 12:46:47 -04:00
b3b91d3f8f Log job requests 2025-06-03 12:45:36 -04:00
6e34a76a3f FIX: Request log processor no funciona 2025-06-03 12:34:08 -04:00
ed29dfb984 Request Log Processor 2025-06-03 12:17:52 -04:00
7f37dc76e3 Log forbidden 2025-06-03 12:06:35 -04:00
a62293e509 Mejora en separacion 2025-06-03 12:06:02 -04:00
fbfc2cb8ae Cambios de usos de env vars 2025-06-03 12:04:53 -04:00
02665ac6bd Extras ya enviados por processor 2025-06-03 11:52:31 -04:00
300d966f3f Separation of logs in cli 2025-06-03 11:49:03 -04:00
27031035ed Filtro en server params faltante 2025-06-03 11:45:36 -04:00
18fc9a76fd Filtro en server params 2025-06-03 11:37:14 -04:00
cb6fa73a21 FIX: Recargar proyectos si no se encuentra proyecto_id, si aun no existe retornar 0 2025-06-03 10:35:07 -04:00
8796762cfe Mas datos en el registro de accessos 2025-06-03 10:24:54 -04:00
99c9952c93 Mas datos en el registro de logins. 2025-06-03 10:22:52 -04:00
9895fd6a70 FIX: Mas registro de login desde cli 2025-06-02 18:45:11 -04:00
c1149d89be FIX: Cleanup after create, but before initialized query. 2025-06-02 18:03:43 -04:00
7d8e2249de FIX: Detalle en logging. 2025-06-02 17:58:24 -04:00
a54586e870 FIX: valor cuota cuando UF no existe. 2025-05-30 17:10:59 -04:00
734f258382 Validar con headers 2025-05-30 14:18:48 -04:00
f728ed0b55 FIX: Log de envio 2025-05-30 12:48:12 -04:00
6144accb8e FIX: Toku envía complejo el header 2025-05-29 19:56:43 -04:00
f399eb8d47 Validate with service 2025-05-29 19:43:06 -04:00
b4159d1417 Log external tries 2025-05-29 19:24:35 -04:00
2a792a947d More granular control of external validation configuration 2025-05-29 19:22:55 -04:00
25710d616a Registro de success entrantes 2025-05-29 19:15:17 -04:00
3197802264 Cleanup 2025-05-29 19:10:09 -04:00
6c53127c2f Body json 2025-05-29 19:06:54 -04:00
b7391a77d3 DEBUG: body 2025-05-29 17:44:30 -04:00
5b499aee75 Content-type 2025-05-29 17:43:14 -04:00
4505531c5f Output body 2025-05-29 17:42:21 -04:00
3f8adc753c Add body to Enqueue command 2025-05-29 17:40:45 -04:00
ace205798f FIX: Manejo de Errores en Ventas 2025-05-29 16:02:13 -04:00
6e0e1fc75e Parametros faltantes 2025-05-27 19:30:08 -04:00
026474c63c Enqueue ventas para enviar a Toku 2025-05-27 19:24:23 -04:00
f32204df97 FIX: Remove toku concept in database 2025-05-27 18:35:06 -04:00
2852816eae FIX: Parametros extra para Toku 2025-05-27 18:27:37 -04:00
892cdf324f Comando para resetear Toku 2025-05-27 18:17:56 -04:00
a9a10e012d Uso de external Logger para los servicios External 2025-05-27 16:28:34 -04:00
b7089f7a1c Timezone por DI 2025-05-27 16:19:47 -04:00
aed26cfcd8 FIX: Estado cuota abono 2025-05-23 12:15:51 -04:00
896dded6eb Apellido materno en blanco 2025-05-23 12:12:34 -04:00
3b03c4b64b Logging 2025-05-19 16:06:44 -04:00
f34ed03b84 Logging 2025-05-19 14:02:55 -04:00
ce75ec1548 External logs
FIX: Ofuscator
2025-05-19 13:55:59 -04:00
312baa34f6 Access Logs 2025-05-19 13:14:13 -04:00
b7c5e4ebc3 Opcion de enviar update a los servicios externos 2025-05-16 19:14:20 -04:00
105179b4ed Fixes de telefono y apellido de persona 2025-05-16 16:35:17 -04:00
16cd29635d Zona horaria en cli 2025-05-16 14:47:31 -04:00
2bdb2a0ed0 Uso de zona horaria en output de comandos 2025-05-16 14:44:48 -04:00
8ce7d2570d FIX: Check if invoice exists before sending, if exists then save
Send correct UF amount if date in future
2025-05-16 14:36:20 -04:00
8ba54fd3ad Queue command with direct redis access so it's faster 2025-05-16 13:56:32 -04:00
f47f86dd2b BaseLoop different logger 2025-05-16 12:54:52 -04:00
8ca68bf7e8 Crontab para revisar servicios externos 1 vez al dia 2025-05-15 19:33:53 -04:00
8965354528 Cambio en queue para que no quede pegado esperando respuesta en cli.
Chequeo de servicios externos para agregar elementos pendientes.
2025-05-15 19:32:25 -04:00
8d32aecd09 Zona horaria en logs 2025-05-15 16:07:29 -04:00
c8f79e076e Envio de datos editados de Propietario 2025-05-15 16:05:55 -04:00
9e0d604d79 Respuesta 200 a webhook de Toku 2025-05-15 16:05:03 -04:00
331d004040 Eliminar script::type 2025-05-15 16:04:35 -04:00
03317b3aa5 Agregar datos propietario 2025-05-15 15:23:34 -04:00
e33edc4d7b FIX: proyectos minuto 0 de cada hora, en vez de cada minuto de esa hora 2025-05-15 12:08:33 -04:00
bb459a2ff5 FIX: proxy no identificado por web 2025-05-15 11:47:28 -04:00
5e2d2e861f Logs no pasan desbordan de nivel 2025-05-15 10:53:59 -04:00
e9b2fe9963 FIX: monto enviado en UF 2025-05-15 10:12:34 -04:00
2f481ef8a9 FIX: mapeo de datos al actualizar pago 2025-05-15 10:06:35 -04:00
386fe452af Catch error 2025-05-15 10:06:00 -04:00
91ad1e39f8 Endpoint para la prueba 2025-05-14 12:41:59 -04:00
a3a5b58cfb Correctos parametros 2025-05-13 20:19:03 -04:00
1d77d65af2 Ventas con cuotas pendientes 2025-05-13 20:18:51 -04:00
0f0c81e283 Uso de request en queue 2025-05-13 20:18:40 -04:00
ac278ca690 Parametros correctos para persona. 2025-05-13 20:18:20 -04:00
97d34f9ad6 Uso de request original 2025-05-13 20:18:09 -04:00
134588c96d Envio de estado de cuotas. 2025-05-13 20:17:53 -04:00
8b6516241d Manejo de contenido 2025-05-13 20:13:15 -04:00
d6e60efcaf Parametros correctos 2025-05-13 20:12:26 -04:00
3e937ab748 Fetch ventas con cuotas pendientes 2025-05-13 20:11:49 -04:00
fa6881d0a9 Formato correcto de fecha y bool 2025-05-13 20:11:02 -04:00
f07c1f1cbd Formato correcto de fecha 2025-05-13 20:10:46 -04:00
148d08089d Estado Cuota y Pago 2025-05-13 20:10:24 -04:00
45b6ee710e Job mas completo 2025-05-13 20:10:12 -04:00
c84277fdc4 Update services 2025-05-13 20:09:50 -04:00
c0024a4a63 Parse body correctly and test fill 2025-05-13 20:03:20 -04:00
308a84a448 Send current request to queue for parameters 2025-05-13 20:02:50 -04:00
91c74bf113 Min log level 2025-05-13 16:17:47 -04:00
024a6eae54 Jobs not being updated 2025-05-13 16:06:09 -04:00
d536342425 No output on wait 2025-05-13 15:58:49 -04:00
e7f3b33850 Wait till next minute after running jobs 2025-05-13 15:53:13 -04:00
c47d94d475 FIX: missing use 2025-05-13 15:49:41 -04:00
ee74fc7588 FIX: esperar al siguiente minuto 2025-05-13 15:47:18 -04:00
5ac324de6a Hora en output 2025-05-13 15:40:32 -04:00
dfb0ff7aea Missing middlewares 2025-05-13 15:16:29 -04:00
6d1a1c914a Wait for execution 2025-05-13 15:15:20 -04:00
b45d03aa7e Reestructura APIClient 2025-05-13 09:32:48 -04:00
4e0b611bcf FIX: Mayuscula 2025-05-13 09:31:51 -04:00
20ea5d021d FIX: missing text 2025-05-12 19:58:20 -04:00
32dc24a783 Newline 2025-05-12 19:54:03 -04:00
95a6aa96e9 Queue 2025-05-12 19:46:31 -04:00
f14cdd2730 Updates 2025-05-12 19:46:09 -04:00
3006adb0f7 Configuracion servicios 2025-05-12 19:44:58 -04:00
d22480dcb8 User edit and delete 2025-05-12 19:44:16 -04:00
425b85e40d Unify cli logs 2025-05-12 19:44:00 -04:00
2c21e48562 FIX: DEPRECATED 2025-05-12 19:43:39 -04:00
8d3ce99be7 Update env sample 2025-05-12 18:32:30 -04:00
35386724b3 FIX: DEPRECATED 2025-05-12 18:07:14 -04:00
1597657f0e FIX: Toku external 2025-05-12 16:35:33 -04:00
c6bbaf3404 FIX: DEPRECATED 2025-05-12 16:08:10 -04:00
9e2d7277b0 Validacion API/external 2025-05-12 16:01:09 -04:00
abe37227ce API/external 2025-05-12 15:47:51 -04:00
32130f0bc2 Usando variables definidas 2025-05-12 14:04:58 -04:00
d78bdaa7f5 Falta ortografia 2025-05-12 13:57:43 -04:00
1266c3859d Migration for Jobs 2025-05-12 13:54:28 -04:00
c5466b2c4d Ignore optionals 2025-05-12 13:15:22 -04:00
6d8e8a9068 Env sample update 2025-05-12 13:06:44 -04:00
4d5b657b92 Manejo de trabajos en cli por php en vez de cron 2025-05-10 12:40:06 -04:00
4ca1616dfc Integracion Toku a flujo 2025-05-10 12:39:31 -04:00
fb7177fd65 Reorden Toku 2025-05-10 12:38:14 -04:00
1486d6cf38 Toku settings 2025-05-10 12:32:01 -04:00
8b2de31e02 Job Queue 2025-05-10 12:30:35 -04:00
61324f159b Toku endpoint 2025-05-10 12:30:21 -04:00
c95e74d574 Controlador Toku 2025-05-09 18:31:00 -04:00
59ecb6cc79 Se agregan fetchs 2025-05-09 18:05:40 -04:00
db84187461 Pruebas de Toku 2025-05-09 18:05:19 -04:00
c2f98c8b0d Excepcion 2025-05-09 18:04:37 -04:00
8d73987ac3 FIX: Cambios a Servicios Toku 2025-05-09 18:04:17 -04:00
400b2754bf FIX: Totales para multipropietario no sumaban correctamente 2025-05-09 13:33:08 -04:00
418becaeda FIX: onChange 2025-05-08 18:15:32 -04:00
679b401101 Servicio Toku para enviar datos 2025-05-08 17:17:49 -04:00
26b6862955 FIX: prueba Servicio Customer 2025-05-08 17:17:24 -04:00
e239669839 FIX: prueba modelo Customer 2025-05-08 17:16:55 -04:00
adc0e52c1e Fix: estructura interface 2025-05-08 17:16:32 -04:00
d1905194bd rut en Customer en formato Toku 2025-05-08 17:16:03 -04:00
a5c1d60819 Servicios para Toku 2025-05-08 16:17:26 -04:00
5ad4fc4038 Tests de Repositories 2025-05-08 16:17:14 -04:00
ca5354a3ee Cambio en namespace 2025-05-08 11:13:23 -04:00
c1ebac6c0c Pruebas de repositories 2025-05-08 11:13:06 -04:00
f742c7ddd0 Pruebas de modelos 2025-05-08 10:45:31 -04:00
5d5f9866bb Modelos para Toku 2025-05-07 20:05:00 -04:00
0866292d84 Migraciones para guardar datos de Toku 2025-05-07 20:04:27 -04:00
e02ed4684f LoggerAwareInterface abstract 2025-05-07 20:04:06 -04:00
8be5f94b7c Log solo los errores fatales. 2025-05-07 20:01:55 -04:00
878b02ee52 SII falla si fecha está en el futuro. 2025-05-07 19:42:39 -04:00
f3e15b34a8 Persona conectada con Propietario 2025-05-07 19:24:33 -04:00
3903551176 FIX: migraciones fallando 2025-05-07 19:23:37 -04:00
43eb8ec758 FIX: no borra todo 2025-05-07 19:22:39 -04:00
a405b15410 Uso de script central de Rut 2025-05-06 10:00:12 -04:00
a2f2d94e64 Docker image con tag 2025-05-06 09:47:54 -04:00
0587b64d65 Docker image 2025-05-06 09:37:23 -04:00
a6b81f1bff FIX: Not needed 2025-05-06 09:15:46 -04:00
4239bafc26 FIX: echo append 2025-05-05 19:33:46 -04:00
6591e9f80e FIX: debian ftp 2025-05-05 19:33:01 -04:00
b57f32c86b FIX: Circular dependency 2025-05-05 19:10:31 -04:00
0e903f99c4 FIX: Circular dependency 2025-05-05 19:08:44 -04:00
186cd0f5b8 Reparaciones con Prueba 2025-05-05 19:01:15 -04:00
167d8e1ab7 PHP Dom en PHP 8.4 2025-05-05 19:00:41 -04:00
46802507a7 SII como provider de UF 2025-05-05 18:16:18 -04:00
aaf2ed7612 UF service en Venta 2025-05-05 18:15:48 -04:00
3ced9e40b1 const en Money y multi provider 2025-05-05 18:15:29 -04:00
594cb68b09 Provider SII 2025-05-05 18:14:50 -04:00
af68c4b8ec Ine null date 2025-05-05 18:14:20 -04:00
ea8f483dd5 FIX: Repository UF 2025-05-05 18:13:55 -04:00
5f53c77a1f Repository::getConnection 2025-05-05 18:13:12 -04:00
b9adb9108b Provider null date 2025-05-05 18:12:58 -04:00
8be085222a Not Allowed template 2025-05-05 16:46:41 -04:00
d1e4314b35 Valor de UF de hoy cuando no se encuentra valor. 2025-05-05 16:46:14 -04:00
7d04b406ab Grabar UF y capacidad de obtener hoy. 2025-05-05 16:45:43 -04:00
972e57b6f1 Mejora en respuesta cuando no existe algun valor. 2025-05-05 16:43:24 -04:00
5f63bdbf4a Fecha maxima de venta es hoy 2025-05-05 16:41:08 -04:00
328 changed files with 13780 additions and 829 deletions

View File

@ -1,19 +1,22 @@
FROM php:8.2-cli FROM php:8.4-cli
ENV TZ "${TZ}" ENV TZ "${TZ}"
ENV APP_NAME "${APP_NAME}" ENV APP_NAME "${APP_NAME}"
ENV API_URL "${API_URL}"
RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano && rm -r /var/lib/apt/lists/* RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano beanstalkd \
&& rm -r /var/lib/apt/lists/*
RUN pecl install xdebug-3.2.2 \ RUN pecl install xdebug-3.4.2 \
&& docker-php-ext-enable xdebug \ && docker-php-ext-enable xdebug \
&& echo "#/bin/bash\nprintenv >> /etc/environment\ncron -f -L 11" > /root/entrypoint && chmod a+x /root/entrypoint && echo $TZ > /etc/timezone
COPY --chmod=550 ./cli/start_command /root/start_command
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
COPY ./php-timezone.ini /usr/local/etc/php/conf.d/docker-php-timezone.ini
WORKDIR /code/bin WORKDIR /code/bin
COPY --chmod=644 ./cli/crontab /var/spool/cron/crontabs/root COPY --chmod=644 ./cli/crontab /var/spool/cron/crontabs/root
CMD [ "/root/entrypoint" ] CMD [ "/root/start_command" ]

View File

@ -1,11 +1,12 @@
FROM php:8.2-fpm FROM php:8.4-fpm
ENV TZ=America/Santiago ENV TZ=America/Santiago
RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git libpng-dev unzip tzdata \ RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git \
libpng-dev unzip tzdata libxml2-dev beanstalkd \
&& rm -r /var/lib/apt/lists/* \ && rm -r /var/lib/apt/lists/* \
&& docker-php-ext-install pdo pdo_mysql zip intl gd bcmath \ && docker-php-ext-install pdo pdo_mysql zip intl gd bcmath dom \
&& pecl install xdebug-3.3.2 \ && pecl install xdebug-3.4.2 \
&& docker-php-ext-enable xdebug \ && docker-php-ext-enable xdebug \
&& echo $TZ > /etc/timezone && echo $TZ > /etc/timezone

View File

@ -2,17 +2,18 @@
APP_URL= APP_URL=
MYSQL_HOST=db
COOKIE_NAME= COOKIE_NAME=
COOKIE_DOMAIN= COOKIE_DOMAIN=
COOKIE_PATH=/ COOKIE_PATH=/
MAX_LOGIN_HOURS=120 MAX_LOGIN_HOURS=120
REDIS_HOST=redis #REDIS_HOST=redis
REDIS_PORT=6379 #REDIS_PORT=6379
DB_HOST=db DB_HOST=db
DB_DATABASE=incoviba DB_DATABASE=incoviba
DB_USER=incoviba DB_USER=incoviba
DB_PASSWORD= DB_PASSWORD=
TOKU_URL=
TOKU_TOKEN=

0
app/bin/console Normal file → Executable file
View File

0
app/bin/integration_tests Normal file → Executable file
View File

0
app/bin/performance_tests Normal file → Executable file
View File

0
app/bin/unit_tests Normal file → Executable file
View File

View File

@ -8,9 +8,9 @@ interface Provider
{ {
/** /**
* @param string $money_symbol * @param string $money_symbol
* @param DateTimeInterface $dateTime * @param ?DateTimeInterface $dateTime = null
* @return float * @return float
* @throws EmptyResponse * @throws EmptyResponse
*/ */
public function get(string $money_symbol, DateTimeInterface $dateTime): float; public function get(string $money_symbol, ?DateTimeInterface $dateTime = null): float;
} }

View File

@ -0,0 +1,18 @@
<?php
namespace Incoviba\Common\Ideal;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
abstract class LoggerEnabled implements LoggerAwareInterface
{
public LoggerInterface $logger;
public function setLogger(LoggerInterface $logger): void
{
$this->logger = $logger;
}
public function getLogger(): LoggerInterface
{
return $this->logger;
}
}

View File

@ -24,6 +24,11 @@ abstract class Repository implements Define\Repository
return $this; return $this;
} }
public function getConnection(): Define\Connection
{
return $this->connection;
}
public function load(array $data_row): Define\Model public function load(array $data_row): Define\Model
{ {
$model = $this->create($data_row); $model = $this->create($data_row);

View File

@ -0,0 +1,10 @@
<?php
namespace Incoviba\Common\Ideal\Service;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal;
abstract class Repository extends Ideal\Service
{
abstract public function getRepository(): Define\Repository;
}

View File

@ -64,10 +64,10 @@ class Select extends Ideal\Query implements Define\Query\Select
public function having(array|string $conditions): Select public function having(array|string $conditions): Select
{ {
if (is_string($conditions)) { if (is_string($conditions)) {
return $this->addCondition($conditions); return $this->addHaving($conditions);
} }
foreach ($conditions as $condition) { foreach ($conditions as $condition) {
$this->addCondition($condition); $this->addHaving($condition);
} }
return $this; return $this;
} }

View File

@ -0,0 +1,13 @@
<?php
namespace Incoviba\Common\Implement\Exception;
use Throwable;
use Exception;
class HttpException extends Exception
{
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace Incoviba\Common\Implement\Log\Formatter;
use Throwable;
use Monolog\Formatter\JsonFormatter;
use Monolog\LogRecord;
class PDO extends JsonFormatter
{
public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = true)
{
parent::__construct($batchMode, $appendNewline, $ignoreEmptyContextAndExtra, $includeStacktraces);
}
public function format(LogRecord $record): string
{
if (is_a($record->message, Throwable::class)) {
$exception = $record->message;
$message = $this->normalizeException($exception);
$context = $record->context;
$context['exception'] = $exception;
if ($exception->getPrevious()) {
$context['previous'] = $this->walkException($exception);
}
$new_record = new LogRecord(
$record->datetime,
$record->channel,
$record->level,
json_encode($message),
$context,
$record->extra
);
$record = $new_record;
}
$normalized = $this->normalize($record, $this->maxNormalizeDepth);
return $normalized['message'];
}
protected function walkException(Throwable $exception, int $depth = 0): array
{
$output = [];
$currentDepth = $depth;
while ($previous = $exception->getPrevious() and $currentDepth < $this->maxNormalizeDepth) {
$output []= $this->normalizeException($previous);
}
return $output;
}
}

View File

@ -1,13 +1,13 @@
<?php <?php
namespace Incoviba\Common\Implement\Log; namespace Incoviba\Common\Implement\Log\Handler;
use PDOStatement;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\LogRecord;
use Monolog\Level;
use Incoviba\Common\Define\Connection; use Incoviba\Common\Define\Connection;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Level;
use Monolog\LogRecord;
use PDOStatement;
class MySQLHandler extends AbstractProcessingHandler class MySQL extends AbstractProcessingHandler
{ {
private bool $initialized = false; private bool $initialized = false;
private PDOStatement $statement; private PDOStatement $statement;
@ -19,9 +19,12 @@ class MySQLHandler extends AbstractProcessingHandler
public function write(LogRecord $record): void public function write(LogRecord $record): void
{ {
if (!$this->initialized) { if (!$this->initialized) {
if (!$this->checkTableExists()) {
$this->createTable();
}
$this->cleanup();
$this->initialized(); $this->initialized();
} }
$this->cleanup();
$this->statement->execute([ $this->statement->execute([
'channel' => $record->channel, 'channel' => $record->channel,
'level' => $record->level->getName(), 'level' => $record->level->getName(),
@ -35,6 +38,21 @@ class MySQLHandler extends AbstractProcessingHandler
private function initialized(): void private function initialized(): void
{ {
$query = <<<QUERY $query = <<<QUERY
INSERT INTO monolog (channel, level, message, time, context, extra)
VALUES (:channel, :level, :message, :time, :context, :extra)
QUERY;
$this->statement = $this->connection->getPDO()->prepare($query);
$this->initialized = true;
}
private function checkTableExists(): bool
{
$query = "SHOW TABLES LIKE 'monolog'";
$result = $this->connection->query($query);
return $result->rowCount() > 0;
}
private function createTable(): void
{
$query = <<<QUERY
CREATE TABLE IF NOT EXISTS monolog ( CREATE TABLE IF NOT EXISTS monolog (
channel VARCHAR(255), channel VARCHAR(255),
level VARCHAR(100), level VARCHAR(100),
@ -45,12 +63,6 @@ CREATE TABLE IF NOT EXISTS monolog (
) )
QUERY; QUERY;
$this->connection->getPDO()->exec($query); $this->connection->getPDO()->exec($query);
$query = <<<QUERY
INSERT INTO monolog (channel, level, message, time, context, extra)
VALUES (:channel, :level, :message, :time, :context, :extra)
QUERY;
$this->statement = $this->connection->getPDO()->prepare($query);
$this->initialized = true;
} }
private function cleanup(): void private function cleanup(): void
{ {

View File

@ -1,19 +0,0 @@
<?php
namespace Incoviba\Common\Implement\Log;
use Monolog\Formatter\JsonFormatter;
use Monolog\LogRecord;
class PDOFormatter extends JsonFormatter
{
public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = true)
{
parent::__construct($batchMode, $appendNewline, $ignoreEmptyContextAndExtra, $includeStacktraces);
}
public function format(LogRecord $record): string
{
$normalized = $this->normalize($record, $this->maxNormalizeDepth);
return $normalized['message'];
}
}

View File

@ -0,0 +1,139 @@
<?php
namespace Incoviba\Common\Implement\Log\Processor;
use DateInvalidTimeZoneException;
use DateMalformedStringException;
use DateTimeImmutable;
use DateTimeZone;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Monolog\Formatter;
use Monolog\Handler;
use Monolog\Level;
use Predis;
use Incoviba;
use Throwable;
class ArrayBuilder
{
public function __construct(protected ContainerInterface $container) {}
public function build(array $data): array
{
$handlers = [];
foreach ($data as $handlerData) {
if (in_array($handlerData['handler'], [Handler\StreamHandler::class, Handler\RotatingFileHandler::class,])) {
$params = [
"/logs/{$handlerData['filename']}",
];
if ($handlerData['handler'] === Handler\RotatingFileHandler::class) {
$params []= 10;
}
try {
$formatter = Formatter\LineFormatter::class;
if (array_key_exists('formatter', $handlerData)) {
$formatter = $handlerData['formatter'];
}
$handler = new $handlerData['handler'](...$params)
->setFormatter($this->container->get($formatter));
} catch (NotFoundExceptionInterface | ContainerExceptionInterface $exception) {
$this->log($exception, ['handlerData' => $handlerData]);
continue;
}
} elseif ($handlerData['handler'] === Incoviba\Common\Implement\Log\Handler\MySQL::class) {
try {
$params = [
$this->container->get(Incoviba\Common\Define\Connection::class)
];
$formatter = Incoviba\Common\Implement\Log\Formatter\PDO::class;
if (array_key_exists('formatter', $handlerData)) {
$formatter = $handlerData['formatter'];
}
$handler = new $handlerData['handler'](...$params)
->setFormatter($this->container->get($formatter));
} catch (NotFoundExceptionInterface | ContainerExceptionInterface $exception) {
$this->log($exception, ['handlerData' => $handlerData]);
continue;
}
} elseif ($handlerData['handler'] === Handler\RedisHandler::class) {
try {
$params = [
$this->container->get(Predis\ClientInterface::class),
"logs:{$handlerData['name']}"
];
} catch (NotFoundExceptionInterface | ContainerExceptionInterface $exception) {
$this->log($exception, ['handlerData' => $handlerData]);
continue;
}
$handler = new $handlerData['handler'](...$params);
}
if (!isset($handler)) {
$this->log("Invalid handler", ['handlerData' => $handlerData]);
continue;
}
$params = [
$handler,
];
if (is_array($handlerData['levels'])) {
foreach ($handlerData['levels'] as $level) {
$params []= $level;
}
} else {
$params []= $handlerData['levels'];
$params []= Level::Emergency;
}
$params []= false;
$handlers []= new Handler\FilterHandler(...$params);
}
return $handlers;
}
protected function log(string|Throwable $message, array $context = []): void
{
try {
$dateTime = new DateTimeImmutable('now', new DateTimeZone($_ENV['TZ'] ?? 'America/Santiago'));
} catch (DateMalformedStringException | DateInvalidTimeZoneException $exception) {
$dateTime = new DateTimeImmutable();
}
if (is_a($message, Throwable::class)) {
$exception = $message;
$message = $exception->getMessage();
}
$context = json_encode($context, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if ($context === false) {
$context = '[]';
}
$extra = [];
$extra['from'] = __FILE__;
if (isset($exception)) {
$extra['file'] = $exception->getFile();
$extra['line'] = $exception->getLine();
$extra['trace'] = $exception->getTrace();
}
$extra = json_encode($extra, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$code = 0;
if (isset($exception)) {
$code = $exception->getCode();
}
if ($extra === false) {
$extra = '[]';
}
$output = "[{$dateTime->format('Y-m-d H:i:s P')}] [{$code}] {$message} {$context} {$extra}";
$filename = '/logs/error.json';
$fileContents = [];
if (file_exists($filename)) {
$fileContents = file_get_contents($filename);
$fileContents = json_decode($fileContents, true);
if ($fileContents === false) {
$fileContents = [];
}
}
$fileContents[$dateTime->getTimestamp()] = $output;
$fileContents = json_encode($fileContents, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if ($fileContents === false) {
$fileContents = '[]';
}
file_put_contents($filename, $fileContents);
}
}

View File

@ -1,11 +1,11 @@
<?php <?php
namespace Incoviba\Common\Implement\Log; namespace Incoviba\Common\Implement\Log\Processor;
use Incoviba\Service;
use Monolog\LogRecord; use Monolog\LogRecord;
use Monolog\Processor\ProcessorInterface; use Monolog\Processor\ProcessorInterface;
use Incoviba\Service;
class UserProcessor implements ProcessorInterface class User implements ProcessorInterface
{ {
public function __construct(protected Service\Login $loginService) {} public function __construct(protected Service\Login $loginService) {}
public function __invoke(LogRecord $record): LogRecord public function __invoke(LogRecord $record): LogRecord

View File

@ -2,7 +2,9 @@
namespace Incoviba\Common\Implement\Repository; namespace Incoviba\Common\Implement\Repository;
use Closure; use Closure;
use Exception;
use Incoviba\Common\Define; use Incoviba\Common\Define;
use Incoviba\Common\Implement\Exception\EmptyResult;
class Factory implements Define\Repository\Factory class Factory implements Define\Repository\Factory
{ {
@ -20,8 +22,16 @@ class Factory implements Define\Repository\Factory
return $this; return $this;
} }
/**
* @return mixed
* @throws EmptyResult
*/
public function run(): mixed public function run(): mixed
{ {
return call_user_func_array($this->callable, $this->args); try {
return call_user_func_array($this->callable, $this->args);
} catch (Exception $exception) {
throw new EmptyResult($exception->getMessage(), $exception);
}
} }
} }

View File

@ -4,14 +4,17 @@
"type": "project", "type": "project",
"require": { "require": {
"ext-curl": "*", "ext-curl": "*",
"ext-dom": "*",
"ext-gd": "*", "ext-gd": "*",
"ext-openssl": "*", "ext-openssl": "*",
"ext-pdo": "*", "ext-pdo": "*",
"ext-sockets": "*",
"berrnd/slim-blade-view": "^1", "berrnd/slim-blade-view": "^1",
"guzzlehttp/guzzle": "^7", "guzzlehttp/guzzle": "^7",
"monolog/monolog": "^3", "monolog/monolog": "^3",
"nyholm/psr7": "^1", "nyholm/psr7": "^1",
"nyholm/psr7-server": "^1", "nyholm/psr7-server": "^1",
"pda/pheanstalk": "^7.0",
"php-di/php-di": "^7", "php-di/php-di": "^7",
"php-di/slim-bridge": "^3", "php-di/slim-bridge": "^3",
"phpoffice/phpspreadsheet": "^3", "phpoffice/phpspreadsheet": "^3",

496
app/fcgi.conf Normal file
View File

@ -0,0 +1,496 @@
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[fcgi]
; Per pool prefix
; It only applies on the following directives:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or NONE) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool
; Unix user/group of the child processes. This can be used only if the master
; process running user is root. It is set after the child process is created.
; The user and group can be specified either by their name or by their numeric
; IDs.
; Note: If the user is root, the executable needs to be started with
; --allow-to-run-as-root option to work.
; Default Values: The user is set to master process running user by default.
; If the group is not set, the user's group is used.
user = www-data
group = www-data
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
;listen = 127.0.0.1:9000
listen = 9090
; Set listen(2) backlog.
; Default Value: 511 (-1 on Linux, FreeBSD and OpenBSD)
;listen.backlog = 511
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. The owner
; and group can be specified either by name or by their numeric IDs.
; Default Values: Owner is set to the master process running user. If the group
; is not set, the owner's group is used. Mode is set to 0660.
;listen.owner = www-data
;listen.group = www-data
;listen.mode = 0660
; When POSIX Access Control Lists are supported you can set them using
; these options, value is a comma separated list of user/group names.
; When set, listen.owner and listen.group are ignored
;listen.acl_users =
;listen.acl_groups =
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1
; Set the associated the route table (FIB). FreeBSD only
; Default Value: -1
;listen.setfib = 1
; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; process.priority = -19
; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
; or group is different than the master process user. It allows to create process
; core dump and ptrace the process for the pool user.
; Default Value: no
; process.dumpable = yes
; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; pm.max_spawn_rate - the maximum number of rate to spawn child
; processes at once.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = ondemand
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 2
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: (min_spare_servers + max_spare_servers) / 2
;pm.start_servers = 2
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
;pm.min_spare_servers = 1
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
;pm.max_spare_servers = 3
; The number of rate to spawn child processes at once.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
; Default Value: 32
;pm.max_spawn_rate = 32
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
pm.process_idle_timeout = 10s
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following information:
; pool - the name of the pool;
; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
; start since - number of seconds since FPM has started;
; accepted conn - the number of request accepted by the pool;
; listen queue - the number of request in the queue of pending
; connections (see backlog in listen(2));
; max listen queue - the maximum number of requests in the queue
; of pending connections since FPM has started;
; listen queue len - the size of the socket queue of pending connections;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes;
; max active processes - the maximum number of active processes since FPM
; has started;
; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for
; pm 'dynamic' and 'ondemand');
; Value are updated in real time.
; Example output:
; pool: www
; process manager: static
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 62636
; accepted conn: 190460
; listen queue: 0
; max listen queue: 1
; listen queue len: 42
; idle processes: 4
; active processes: 11
; total processes: 15
; max active processes: 12
; max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either
; 'html', 'xml' or 'json' in the query string will return the corresponding
; output syntax. Example:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; http://www.foo.bar/status?xml
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
; http://www.foo.bar/status?xml&full
; The Full status returns for each process:
; pid - the PID of the process;
; state - the state of the process (Idle, Running, ...);
; start time - the date and time the process has started;
; start since - the number of seconds since the process has started;
; requests - the number of requests the process has served;
; request duration - the duration in µs of the requests;
; request method - the request method (GET, POST, ...);
; request URI - the request URI with the query string;
; content length - the content length of the request (only with POST);
; user - the user (PHP_AUTH_USER) (or '-' if not set);
; script - the main script called (or '-' if not set);
; last request cpu - the %cpu the last request consumed
; it's always 0 if the process is not in Idle state
; because CPU calculation is done when the request
; processing has terminated;
; last request memory - the max amount of memory the last request consumed
; it's always 0 if the process is not in Idle state
; because memory calculation is done when the request
; processing has terminated;
; If the process is in Idle state, then information is related to the
; last request the process has served. Otherwise information is related to
; the current request being served.
; Example output:
; ************************
; pid: 31330
; state: Running
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 63087
; requests: 12808
; request duration: 1250261
; request method: GET
; request URI: /test_mem.php?N=10000
; content length: 0
; user: -
; script: /home/fat/web/docs/php/test_mem.php
; last request cpu: 0.00
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: /usr/local/share/php/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status
; The address on which to accept FastCGI status request. This creates a new
; invisible pool that can handle requests independently. This is useful
; if the main pool is busy with long running requests because it is still possible
; to get the status before finishing the long running requests.
;
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Default Value: value of the listen option
;pm.status_listen = 127.0.0.1:9001
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping
; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong
; The access log file
; Default: not set
;access.log = log/$pool.access.log
access.log = /proc/self/fd/2
; The access log format.
; The following syntax is allowed
; %%: the '%' character
; %C: %CPU used by the request
; it can accept the following format:
; - %{user}C for user CPU only
; - %{system}C for system CPU only
; - %{total}C for user + system CPU (default)
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{milliseconds}d
; - %{milli}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some examples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
; %l: content-length of the request (for POST request only)
; %m: request method
; %M: peak of memory allocated by PHP
; it can accept the following format:
; - %{bytes}M (default)
; - %{kilobytes}M
; - %{kilo}M
; - %{megabytes}M
; - %{mega}M
; %n: pool name
; %o: output header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
; - %{Transfert-Encoding}o
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
; %s: status (response code)
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
; %u: basic auth user if specified in Authorization header
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%"
; A list of request_uri values which should be filtered from the access log.
;
; As a security precaution, this setting will be ignored if:
; - the request method is not GET or HEAD; or
; - there is a request body; or
; - there are query parameters; or
; - the response code is outwith the successful range of 200 to 299
;
; Note: The paths are matched against the output of the access.format tag "%r".
; On common configurations, this may look more like SCRIPT_NAME than the
; expected pre-rewrite URI.
;
; Default Value: not set
;access.suppress_path[] = /ping
;access.suppress_path[] = /health_check.php
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0
; Depth of slow log stack trace.
; Default Value: 20
;request_slowlog_trace_depth = 20
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
; The timeout set by 'request_terminate_timeout' ini option is not engaged after
; application calls 'fastcgi_finish_request' or when application has finished and
; shutdown functions are being called (registered via register_shutdown_function).
; This option will enable timeout limit to be applied unconditionally
; even in such cases.
; Default Value: no
;request_terminate_timeout_track_finished = no
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
;chdir = /var/www
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environment, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes
catch_workers_output = yes
; Decorate worker output with prefix and suffix containing information about
; the child that writes to the log and if stdout or stderr is used as well as
; log level and time. This options is used only if catch_workers_output is yes.
; Settings to "no" will output data as written to the stdout or stderr.
; Default value: yes
;decorate_workers_output = no
decorate_workers_output = no
; Clear environment in FPM workers
; Prevents arbitrary environment variables from reaching FPM worker processes
; by clearing the environment in workers before env vars specified in this
; pool configuration are added.
; Setting to "no" will make all environment variables available to PHP code
; via getenv(), $_ENV and $_SERVER.
; Default Value: yes
;clear_env = no
clear_env = no
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; execute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5 .php7
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.
; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr/local)
; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

View File

@ -16,7 +16,9 @@ try {
register_shutdown_function(function() { register_shutdown_function(function() {
$error = error_get_last(); $error = error_get_last();
if ($error !== null) { $fatal_errors = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR];
if ($error !== null and in_array($error['type'], $fatal_errors, true)) {
error_log(json_encode($error).PHP_EOL,3, '/logs/fatal.log'); error_log(json_encode($error).PHP_EOL,3, '/logs/fatal.log');
} }
error_clear_last();
}); });

View File

@ -13,9 +13,9 @@ class CreateCartolas extends Phinx\Migration\AbstractMigration
$this->table('cartolas') $this->table('cartolas')
->addColumn('cuenta_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) ->addColumn('cuenta_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false])
->addColumn('fecha', 'date', ['null' => false]) ->addColumn('fecha', 'date', ['null' => false])
->addColumn('cargos', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) ->addColumn('cargos', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false])
->addColumn('abonos', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) ->addColumn('abonos', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false])
->addColumn('saldo', 'bigint', ['length' => 20, 'default' => 0, 'null' => false]) ->addColumn('saldo', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false])
->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');

View File

@ -15,7 +15,7 @@ class CreateCentrosCostos extends Phinx\Migration\AbstractMigration
->addColumn('categoria_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) ->addColumn('categoria_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false])
->addColumn('tipo_cuenta_id', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) ->addColumn('tipo_cuenta_id', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false])
->addColumn('cuenta_contable', 'string', ['length' => 100, 'null' => false]) ->addColumn('cuenta_contable', 'string', ['length' => 100, 'null' => false])
->addColumn('descripcion', 'mediumtext', ['null' => false]) ->addColumn('descripcion', 'text', ['null' => false, 'limit' => MysqlAdapter::TEXT_MEDIUM])
->addForeignKey('tipo_centro_id', 'tipos_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->addForeignKey('tipo_centro_id', 'tipos_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->addForeignKey('categoria_id', 'categorias_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->addForeignKey('categoria_id', 'categorias_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->create(); ->create();

View File

@ -19,7 +19,7 @@ class CreateCobro extends Phinx\Migration\AbstractMigration
->addColumn('iva', 'float', ['default' => 0]) ->addColumn('iva', 'float', ['default' => 0])
->addColumn('uf', 'float', ['default' => null, 'null' => true]) ->addColumn('uf', 'float', ['default' => null, 'null' => true])
->addColumn('identificador', 'string', ['length' => 50, 'default' => null, 'null' => true]) ->addColumn('identificador', 'string', ['length' => 50, 'default' => null, 'null' => true])
->addColumn('glosa', 'mediumtext', ['default' => null, 'null' => true]) ->addColumn('glosa', 'text', ['default' => null, 'null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
} }

View File

@ -11,7 +11,7 @@ class CreateEscritura extends Phinx\Migration\AbstractMigration
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
$this->table('escritura') $this->table('escritura')
->addColumn('valor', 'bigint', ['length' => 20, 'null' => false]) ->addColumn('valor', 'biginteger', ['length' => 20, 'null' => false])
->addColumn('fecha', 'date', ['null' => false]) ->addColumn('fecha', 'date', ['null' => false])
->addColumn('uf', 'float', ['default' => null, 'null' => true]) ->addColumn('uf', 'float', ['default' => null, 'null' => true])
->addColumn('abonado', 'integer', ['length' => 11, 'default' => 0]) ->addColumn('abonado', 'integer', ['length' => 11, 'default' => 0])

View File

@ -13,7 +13,7 @@ class CreateEstadoProblema extends Phinx\Migration\AbstractMigration
$this->table('estado_problema') $this->table('estado_problema')
->addColumn('problema', 'integer', ['length' => 11, 'default' => null, 'null' => true]) ->addColumn('problema', 'integer', ['length' => 11, 'default' => null, 'null' => true])
->addColumn('fecha', 'date', ['default' => null, 'null' => true]) ->addColumn('fecha', 'date', ['default' => null, 'null' => true])
->addColumn('estado', 'enum', ['length' => 'ingreso','revision','correccion','ok', 'default' => null, 'null' => true]) ->addColumn('estado', 'enum', ['values' => ['ingreso','revision','correccion','ok'], 'default' => null, 'null' => true])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
} }

View File

@ -15,7 +15,7 @@ class CreateInmobiliariasNubox extends Phinx\Migration\AbstractMigration
->addColumn('alias', 'string', ['length' => 100, 'null' => false]) ->addColumn('alias', 'string', ['length' => 100, 'null' => false])
->addColumn('usuario', 'string', ['length' => 100, 'null' => false]) ->addColumn('usuario', 'string', ['length' => 100, 'null' => false])
->addColumn('contraseña', 'string', ['length' => 100, 'null' => false]) ->addColumn('contraseña', 'string', ['length' => 100, 'null' => false])
->addForeignKey('inmobiliaria_rut', 'inmobiliaria', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) #->addForeignKey('inmobiliaria_rut', 'inmobiliaria', 'rut', ['delete' => 'cascade', 'update' => 'cascade'])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
} }

View File

@ -15,9 +15,9 @@ class CreateMovimientos extends Phinx\Migration\AbstractMigration
->addColumn('fecha', 'date', ['null' => false]) ->addColumn('fecha', 'date', ['null' => false])
->addColumn('glosa', 'text', ['null' => false]) ->addColumn('glosa', 'text', ['null' => false])
->addColumn('documento', 'string', ['length' => 50, 'null' => false]) ->addColumn('documento', 'string', ['length' => 50, 'null' => false])
->addColumn('cargo', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) ->addColumn('cargo', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false])
->addColumn('abono', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) ->addColumn('abono', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false])
->addColumn('saldo', 'bigint', ['length' => 20, 'default' => 0, 'null' => false]) ->addColumn('saldo', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false])
->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');

View File

@ -12,7 +12,7 @@ class CreateProblema extends Phinx\Migration\AbstractMigration
$this->table('problema') $this->table('problema')
->addColumn('venta', 'integer', ['length' => 11, 'default' => null, 'null' => true]) ->addColumn('venta', 'integer', ['length' => 11, 'default' => null, 'null' => true])
->addColumn('descripcion', 'mediumtext', ['default' => null, 'null' => true]) ->addColumn('descripcion', 'text', ['default' => null, 'null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
} }

View File

@ -12,7 +12,7 @@ class CreateProyecto extends Phinx\Migration\AbstractMigration
$this->table('proyecto') $this->table('proyecto')
->addColumn('inmobiliaria', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) ->addColumn('inmobiliaria', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false])
->addColumn('descripcion', 'mediumtext', ['null' => false]) ->addColumn('descripcion', 'text', ['null' => false, 'limit' => MysqlAdapter::TEXT_MEDIUM])
->addColumn('direccion', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) ->addColumn('direccion', 'integer', ['length' => 10, 'null' => false, 'signed' => false])
->addColumn('superficie_terreno', 'float', ['default' => 0, 'null' => false, 'signed' => false]) ->addColumn('superficie_terreno', 'float', ['default' => 0, 'null' => false, 'signed' => false])
->addColumn('valor_terreno', 'float', ['default' => 0, 'null' => false, 'signed' => false]) ->addColumn('valor_terreno', 'float', ['default' => 0, 'null' => false, 'signed' => false])

View File

@ -18,7 +18,7 @@ class CreateProyectoTipoUnidad extends Phinx\Migration\AbstractMigration
->addColumn('m2', 'float', ['default' => null, 'null' => true]) ->addColumn('m2', 'float', ['default' => null, 'null' => true])
->addColumn('logia', 'float', ['default' => 0]) ->addColumn('logia', 'float', ['default' => 0])
->addColumn('terraza', 'float', ['default' => 0]) ->addColumn('terraza', 'float', ['default' => 0])
->addColumn('descripcion', 'mediumtext', ['default' => null, 'null' => true]) ->addColumn('descripcion', 'text', ['default' => null, 'null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM])
->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');

View File

@ -10,7 +10,8 @@ class CreateTipoEstadoPago extends Phinx\Migration\AbstractMigration
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
$this->table('tipo_estado_pago') $this->table('tipo_estado_pago', ['id' => false, 'primary_key' => 'id'])
->addColumn('id', 'integer', ['signed' => true])
->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true]) ->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true])
->addColumn('active', 'integer', ['length' => 1, 'default' => 0]) ->addColumn('active', 'integer', ['length' => 1, 'default' => 0])
->create(); ->create();

View File

@ -33,7 +33,7 @@ class CreateVenta extends Phinx\Migration\AbstractMigration
->addColumn('resciliacion', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) ->addColumn('resciliacion', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false])
->addColumn('devolucion', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) ->addColumn('devolucion', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false])
->addForeignKey('propiedad', 'propiedad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->addForeignKey('propiedad', 'propiedad', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->addForeignKey('propietario', 'propietario', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) #->addForeignKey('propietario', 'propietario', 'rut', ['delete' => 'cascade', 'update' => 'cascade'])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
} }

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
use Phinx\Migration\AbstractMigration; use Phinx\Migration\AbstractMigration;
final class CreateReservation extends AbstractMigration final class CreateReservations extends AbstractMigration
{ {
/** /**
* Change Method. * Change Method.
@ -23,9 +23,11 @@ final class CreateReservation extends AbstractMigration
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
$this->table('reservation') $this->table('reservations')
->addColumn('project_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('buyer_rut', 'integer', ['signed' => false, 'null' => false]) ->addColumn('buyer_rut', 'integer', ['signed' => false, 'null' => false])
->addColumn('date', 'date', ['null' => false]) ->addColumn('date', 'date', ['null' => false])
->addForeignKey('project_id', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->addForeignKey('buyer_rut', 'personas', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) ->addForeignKey('buyer_rut', 'personas', 'rut', ['delete' => 'cascade', 'update' => 'cascade'])
->create(); ->create();

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
use Phinx\Migration\AbstractMigration; use Phinx\Migration\AbstractMigration;
final class CreateReservationDatas extends AbstractMigration final class CreateReservationDetails extends AbstractMigration
{ {
/** /**
* Change Method. * Change Method.
@ -23,11 +23,13 @@ final class CreateReservationDatas extends AbstractMigration
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';"); $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';"); $this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
$this->table('reservation_data') $this->table('reservation_details')
->addColumn('reservation_id', 'integer', ['signed' => false, 'null' => false]) ->addColumn('reservation_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('type', 'integer', ['length' => 1, 'signed' => false, 'null' => false]) ->addColumn('type', 'integer', ['length' => 1, 'signed' => false, 'null' => false])
->addColumn('reference_id', 'integer', ['signed' => false, 'null' => false]) ->addColumn('reference_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('value', 'decimal', ['precision' => 10, 'scale' => 2, 'signed' => false, 'default' => 0.00, 'null' => true]) ->addColumn('value', 'decimal', ['precision' => 10, 'scale' => 2, 'signed' => false, 'default' => null, 'null' => true])
->addForeignKey('reservation_id', 'reservations', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->addIndex(['reservation_id', 'type', 'reference_id'], ['unique' => true, 'name' => 'idx_reservation_details'])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');

View File

@ -27,7 +27,7 @@ final class CreateReservationStates extends AbstractMigration
->addColumn('reservation_id', 'integer', ['signed' => false, 'null' => false]) ->addColumn('reservation_id', 'integer', ['signed' => false, 'null' => false])
->addColumn('date', 'date', ['null' => false]) ->addColumn('date', 'date', ['null' => false])
->addColumn('type', 'integer', ['length' => 3, 'null' => false, 'default' => 0]) ->addColumn('type', 'integer', ['length' => 3, 'null' => false, 'default' => 0])
->addForeignKey('reservation_id', 'reservation', 'id', ['delete' => 'cascade', 'update' => 'cascade']) ->addForeignKey('reservation_id', 'reservations', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->create(); ->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); $this->execute('SET unique_checks=1; SET foreign_key_checks=1;');

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTokuCustomers extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('toku_customers')
->addColumn('rut', 'string', ['length' => 9])
->addColumn('toku_id', 'string', ['length' => 255])
->addTimestamps()
->addIndex(['rut'], ['unique' => true])
->create();
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTokuSubscriptions extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('toku_subscriptions')
->addColumn('venta_id', 'integer', ['signed' => false])
->addColumn('toku_id', 'string', ['length' => 255])
->addTimestamps()
->addIndex(['venta_id'], ['unique' => true])
->create();
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTokuInvoices extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('toku_invoices')
->addColumn('cuota_id', 'integer', ['signed' => false])
->addColumn('toku_id', 'string', ['length' => 255])
->addTimestamps()
->addIndex(['cuota_id'], ['unique' => true])
->create();
}
}

View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateJobs extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('jobs')
->addColumn('configuration', 'json')
->addColumn('executed', 'boolean', ['default' => false])
->addTimestamps()
->create();
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTokuWebhooks extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('toku_webhooks')
->addColumn('secret', 'string', ['length' => 255])
->addColumn('events', 'json')
->addColumn('enabled', 'boolean', ['default' => true])
->addTimestamps()
->create();
}
}

View File

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateTokuAccounts extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
$this->table('toku_accounts')
->addColumn('sociedad_rut', 'integer', ['limit' => 8, 'signed' => false, 'null' => false])
->addColumn('toku_id', 'string', ['length' => 255, 'null' => false])
->addColumn('account_key', 'string', ['length' => 255, 'null' => false])
->addColumn('enabled', 'boolean', ['default' => true])
->addTimestamps()
#->addForeignKey('sociedad_rut', 'inmobiliaria', 'rut', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
->addIndex(['toku_id'], ['unique' => true])
->create();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
}
}

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class ChangeTelefonoSizeInPropietario extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('propietario')
->changeColumn('telefono', 'biginteger', ['null' => true, 'signed' => false, 'default' => null])
->update();
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddCommentsToEstadoCierre extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
$this->table('estado_cierre_comentarios')
->addColumn('estado_cierre_id', 'integer', ['signed' => false])
->addColumn('fecha', 'datetime', ['default' => 'CURRENT_TIMESTAMP'])
->addColumn('comments', 'text')
->addForeignKey('estado_cierre_id', 'estado_cierre', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
->create();
}
}

View File

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
use Phinx\Seed\AbstractSeed;
class Comuna extends AbstractSeed
{
public function getDependencies(): array
{
return [
'Provincia',
];
}
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* https://book.cakephp.org/phinx/0/en/seeding.html
*/
public function run(): void
{
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
$table = $this->table('comuna');
$table->truncate();
$filename = implode(DIRECTORY_SEPARATOR, [getcwd(), 'resources', 'database', 'seeds', 'comuna.csv']);
$dataRows = explode(PHP_EOL, trim(file_get_contents($filename)));
$data = array_map(fn($row) => explode(';', $row), $dataRows);
$columns = array_shift($data);
$columns = array_map(function($column) {
if (str_contains($column, 'id')) {
return 'id';
}
if (str_contains($column, 'provincia')) {
return 'provincia';
}
return $column;
}, $columns);
$data = array_map(function ($row) use ($columns) {
return array_combine($columns, $row);
}, $data);
$table->insert($data)->save();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
}
}

View File

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
use Phinx\Seed\AbstractSeed;
class Provincia extends AbstractSeed
{
public function getDependencies(): array
{
return [
'Region',
];
}
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* https://book.cakephp.org/phinx/0/en/seeding.html
*/
public function run(): void
{
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
$table = $this->table('provincia');
$table->truncate();
$filename = implode(DIRECTORY_SEPARATOR, [getcwd(), 'resources', 'database', 'seeds', 'provincia.csv']);
$dataRows = explode(PHP_EOL, trim(file_get_contents($filename)));
$data = array_map(fn($row) => explode(';', $row), $dataRows);
$columns = array_shift($data);
$columns = array_map(function($column) {
if (str_contains($column, 'id')) {
return 'id';
}
if (str_contains($column, 'region')) {
return 'region';
}
return $column;
}, $columns);
$data = array_map(function ($row) use ($columns) {
return array_combine($columns, $row);
}, $data);
$table->insert($data)->save();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
}
}

View File

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
use Phinx\Seed\AbstractSeed;
class Region extends AbstractSeed
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* https://book.cakephp.org/phinx/0/en/seeding.html
*/
public function run(): void
{
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
$table = $this->table('region');
$table->truncate();
$filename = implode(DIRECTORY_SEPARATOR, [getcwd(), 'resources', 'database', 'seeds', 'region.csv']);
$dataRows = explode(PHP_EOL, trim(file_get_contents($filename)));
$data = array_map(fn($row) => explode(';', $row), $dataRows);
$columns = array_shift($data);
$columns = array_map(function($column) {
if (str_contains($column, 'id')) {
return 'id';
}
if (str_contains($column, 'numeracion')) {
return 'numeracion';
}
return $column;
}, $columns);
$data = array_map(function ($row) use ($columns) {
return array_combine($columns, $row);
}, $data);
$table->insert($data)->save();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
}
}

View File

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Phinx\Seed\AbstractSeed;
class TipoEstadoPago extends AbstractSeed
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* https://book.cakephp.org/phinx/0/en/seeding.html
*/
public function run(): void
{
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
$table = $this->table('tipo_estado_pago');
$table->truncate();
$data = [
['id' => -3, 'descripcion' => 'anulado'],
['id' => -2, 'descripcion' => 'reemplazado'],
['id' => -1, 'descripcion' => 'devuelto'],
['id' => 0, 'descripcion' => 'no pagado', 'active' => 1],
['id' => 1, 'descripcion' => 'depositado', 'active' => 1],
['id' => 2, 'descripcion' => 'abonado', 'active' => 1],
];
$table->insert($data)->saveData();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
}
}

View File

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
use Phinx\Seed\AbstractSeed;
class TipoPago extends AbstractSeed
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* https://book.cakephp.org/phinx/0/en/seeding.html
*/
public function run(): void
{
$table = $this->table('tipo_pago');
$data = [
[
'descripcion' => 'cheque',
],
[
'descripcion' => 'carta de resguardo',
],
[
'descripcion' => 'vale vista'
],
[
'descripcion' => 'deposito',
],
[
'descripcion' => 'efectivo',
],
[
'descripcion' => 'tarjeta de credito',
],
[
'descripcion' => 'transferencia electronica',
],
[
'descripcion' => 'virtual',
]
];
$table->truncate();
$table
->insert($data)
->saveData();
}
}

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
use Phinx\Seed\AbstractSeed;
class TipoSociedad extends AbstractSeed
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* https://book.cakephp.org/phinx/0/en/seeding.html
*/
public function run(): void
{
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
$table = $this->table('tipo_sociedad');
$table->truncate();
$data = [
[
'descripcion' => 'Limitada',
'abreviacion' => 'Ltda',
],
[
'descripcion' => 'Sociedad Anónima',
'abreviacion' => 'SA',
],
[
'descripcion' => 'Sociedad por Acciones',
'abreviacion' => 'SpA',
]
];
$table->insert($data)->saveData();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
}
}

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
use Phinx\Seed\AbstractSeed;
class TipoUnidad extends AbstractSeed
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* https://book.cakephp.org/phinx/0/en/seeding.html
*/
public function run(): void
{
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
$table = $this->table('tipo_unidad');
$table->truncate();
$data = [
[
'descripcion' => 'departamento',
'orden' => 0,
],
[
'descripcion' => 'estacionamiento',
'orden' => 1,
],
[
'descripcion' => 'bodega',
'orden' => 2,
]
];
$table->insert($data)->saveData();
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
}
}

View File

@ -0,0 +1,347 @@
id;descripcion;provincia
1101;Iquique;11
1107;Alto Hospicio;11
1401;Pozo Almonte;14
1402;Camiña;14
1403;Colchane;14
1404;Huara;14
1405;Pica;14
2101;Antofagasta;21
2102;Mejillones;21
2103;Sierra Gorda;21
2104;Taltal;21
2201;Calama;22
2202;Ollagüe;22
2203;San Pedro de Atacama;22
2301;Tocopilla;23
2302;María Elena;23
3101;Copiapó;31
3102;Caldera;31
3103;Tierra Amarilla;31
3201;Chañaral;32
3202;Diego de Almagro;32
3301;Vallenar;33
3302;Alto del Carmen;33
3303;Freirina;33
3304;Huasco;33
4101;La Serena;41
4102;Coquimbo;41
4103;Andacollo;41
4104;La Higuera;41
4105;Paiguano;41
4106;Vicuña;41
4201;Illapel;42
4202;Canela;42
4203;Los Vilos;42
4204;Salamanca;42
4301;Ovalle;43
4302;Combarbalá;43
4303;Monte Patria;43
4304;Punitaqui;43
4305;Río Hurtado;43
5101;Valparaíso;51
5102;Casablanca;51
5103;Concón;51
5104;Juan Fernández;51
5105;Puchuncaví;51
5107;Quintero;51
5109;Viña del Mar;51
5201;Isla de Pascua;52
5301;Los Andes;53
5302;Calle Larga;53
5303;Rinconada;53
5304;San Esteban;53
5401;La Ligua;54
5402;Cabildo;54
5403;Papudo;54
5404;Petorca;54
5405;Zapallar;54
5501;Quillota;55
5502;Calera;55
5503;Hijuelas;55
5504;La Cruz;55
5506;Nogales;55
5601;San Antonio;56
5602;Algarrobo;56
5603;Cartagena;56
5604;El Quisco;56
5605;El Tabo;56
5606;Santo Domingo;56
5701;San Felipe;57
5702;Catemu;57
5703;Llaillay;57
5704;Panquehue;57
5705;Putaendo;57
5706;Santa María;57
5801;Quilpué;58
5802;Limache;58
5803;Olmué;58
5804;Villa Alemana;58
6101;Rancagua;61
6102;Codegua;61
6103;Coinco;61
6104;Coltauco;61
6105;Doñihue;61
6106;Graneros;61
6107;Las Cabras;61
6108;Machalí;61
6109;Malloa;61
6110;Mostazal;61
6111;Olivar;61
6112;Peumo;61
6113;Pichidegua;61
6114;Quinta de Tilcoco;61
6115;Rengo;61
6116;Requínoa;61
6117;San Vicente;61
6201;Pichilemu;62
6202;La Estrella;62
6203;Litueche;62
6204;Marchihue;62
6205;Navidad;62
6206;Paredones;62
6301;San Fernando;63
6302;Chépica;63
6303;Chimbarongo;63
6304;Lolol;63
6305;Nancagua;63
6306;Palmilla;63
6307;Peralillo;63
6308;Placilla;63
6309;Pumanque;63
6310;Santa Cruz;63
7101;Talca;71
7102;Constitución;71
7103;Curepto;71
7104;Empedrado;71
7105;Maule;71
7106;Pelarco;71
7107;Pencahue;71
7108;Río Claro;71
7109;San Clemente;71
7110;San Rafael;71
7201;Cauquenes;72
7202;Chanco;72
7203;Pelluhue;72
7301;Curicó;73
7302;Hualañé;73
7303;Licantén;73
7304;Molina;73
7305;Rauco;73
7306;Romeral;73
7307;Sagrada Familia;73
7308;Teno;73
7309;Vichuquén;73
7401;Linares;74
7402;Colbún;74
7403;Longaví;74
7404;Parral;74
7405;Retiro;74
7406;San Javier;74
7407;Villa Alegre;74
7408;Yerbas Buenas;74
8101;Concepción;81
8102;Coronel;81
8103;Chiguayante;81
8104;Florida;81
8105;Hualqui;81
8106;Lota;81
8107;Penco;81
8108;San Pedro de la Paz;81
8109;Santa Juana;81
8110;Talcahuano;81
8111;Tomé;81
8112;Hualpén;81
8201;Lebu;82
8202;Arauco;82
8203;Cañete;82
8204;Contulmo;82
8205;Curanilahue;82
8206;Los Álamos;82
8207;Tirúa;82
8301;Los Ángeles;83
8302;Antuco;83
8303;Cabrero;83
8304;Laja;83
8305;Mulchén;83
8306;Nacimiento;83
8307;Negrete;83
8308;Quilaco;83
8309;Quilleco;83
8310;San Rosendo;83
8311;Santa Bárbara;83
8312;Tucapel;83
8313;Yumbel;83
8314;Alto Biobío;83
8401;Chillán;84
8402;Bulnes;84
8403;Cobquecura;84
8404;Coelemu;84
8405;Coihueco;84
8406;Chillán Viejo;84
8407;El Carmen;84
8408;Ninhue;84
8409;Ñiquén;84
8410;Pemuco;84
8411;Pinto;84
8412;Portezuelo;84
8413;Quillón;84
8414;Quirihue;84
8415;Ránquil;84
8416;San Carlos;84
8417;San Fabián;84
8418;San Ignacio;84
8419;San Nicolás;84
8420;Treguaco;84
8421;Yungay;84
9101;Temuco;91
9102;Carahue;91
9103;Cunco;91
9104;Curarrehue;91
9105;Freire;91
9106;Galvarino;91
9107;Gorbea;91
9108;Lautaro;91
9109;Loncoche;91
9110;Melipeuco;91
9111;Nueva Imperial;91
9112;Padre las Casas;91
9113;Perquenco;91
9114;Pitrufquén;91
9115;Pucón;91
9116;Saavedra;91
9117;Teodoro Schmidt;91
9118;Toltén;91
9119;Vilcún;91
9120;Villarrica;91
9121;Cholchol;91
9201;Angol;92
9202;Collipulli;92
9203;Curacautín;92
9204;Ercilla;92
9205;Lonquimay;92
9206;Los Sauces;92
9207;Lumaco;92
9208;Purén;92
9209;Renaico;92
9210;Traiguén;92
9211;Victoria;92
10101;Puerto Montt;101
10102;Calbuco;101
10103;Cochamó;101
10104;Fresia;101
10105;Frutillar;101
10106;Los Muermos;101
10107;Llanquihue;101
10108;Maullín;101
10109;Puerto Varas;101
10201;Castro;102
10202;Ancud;102
10203;Chonchi;102
10204;Curaco de Vélez;102
10205;Dalcahue;102
10206;Puqueldón;102
10207;Queilén;102
10208;Quellón;102
10209;Quemchi;102
10210;Quinchao;102
10301;Osorno;103
10302;Puerto Octay;103
10303;Purranque;103
10304;Puyehue;103
10305;Río Negro;103
10306;San Juan de la Costa;103
10307;San Pablo;103
10401;Chaitén;104
10402;Futaleufú;104
10403;Hualaihué;104
10404;Palena;104
11101;Coihaique;111
11102;Lago Verde;111
11201;Aisén;112
11202;Cisnes;112
11203;Guaitecas;112
11301;Cochrane;113
11302;OHiggins;113
11303;Tortel;113
11401;Chile Chico;114
11402;Río Ibáñez;114
12101;Punta Arenas;121
12102;Laguna Blanca;121
12103;Río Verde;121
12104;San Gregorio;121
12201;Cabo de Hornos (Ex Navarino);122
12202;Antártica;122
12301;Porvenir;123
12302;Primavera;123
12303;Timaukel;123
12401;Natales;124
12402;Torres del Paine;124
13101;Santiago;131
13102;Cerrillos;131
13103;Cerro Navia;131
13104;Conchalí;131
13105;El Bosque;131
13106;Estación Central;131
13107;Huechuraba;131
13108;Independencia;131
13109;La Cisterna;131
13110;La Florida;131
13111;La Granja;131
13112;La Pintana;131
13113;La Reina;131
13114;Las Condes;131
13115;Lo Barnechea;131
13116;Lo Espejo;131
13117;Lo Prado;131
13118;Macul;131
13119;Maipú;131
13120;Ñuñoa;131
13121;Pedro Aguirre Cerda;131
13122;Peñalolén;131
13123;Providencia;131
13124;Pudahuel;131
13125;Quilicura;131
13126;Quinta Normal;131
13127;Recoleta;131
13128;Renca;131
13129;San Joaquín;131
13130;San Miguel;131
13131;San Ramón;131
13132;Vitacura;131
13201;Puente Alto;132
13202;Pirque;132
13203;San José de Maipo;132
13301;Colina;133
13302;Lampa;133
13303;Tiltil;133
13401;San Bernardo;134
13402;Buin;134
13403;Calera de Tango;134
13404;Paine;134
13501;Melipilla;135
13502;Alhué;135
13503;Curacaví;135
13504;María Pinto;135
13505;San Pedro;135
13601;Talagante;136
13602;El Monte;136
13603;Isla de Maipo;136
13604;Padre Hurtado;136
13605;Peñaflor;136
14101;Valdivia;141
14102;Corral;141
14103;Lanco;141
14104;Los Lagos;141
14105;Máfil;141
14106;Mariquina;141
14107;Paillaco;141
14108;Panguipulli;141
14201;La Unión;142
14202;Futrono;142
14203;Lago Ranco;142
14204;Río Bueno;142
15101;Arica;151
15102;Camarones;151
15201;Putre;152
15202;General Lagos;152
1 id descripcion provincia
2 1101 Iquique 11
3 1107 Alto Hospicio 11
4 1401 Pozo Almonte 14
5 1402 Camiña 14
6 1403 Colchane 14
7 1404 Huara 14
8 1405 Pica 14
9 2101 Antofagasta 21
10 2102 Mejillones 21
11 2103 Sierra Gorda 21
12 2104 Taltal 21
13 2201 Calama 22
14 2202 Ollagüe 22
15 2203 San Pedro de Atacama 22
16 2301 Tocopilla 23
17 2302 María Elena 23
18 3101 Copiapó 31
19 3102 Caldera 31
20 3103 Tierra Amarilla 31
21 3201 Chañaral 32
22 3202 Diego de Almagro 32
23 3301 Vallenar 33
24 3302 Alto del Carmen 33
25 3303 Freirina 33
26 3304 Huasco 33
27 4101 La Serena 41
28 4102 Coquimbo 41
29 4103 Andacollo 41
30 4104 La Higuera 41
31 4105 Paiguano 41
32 4106 Vicuña 41
33 4201 Illapel 42
34 4202 Canela 42
35 4203 Los Vilos 42
36 4204 Salamanca 42
37 4301 Ovalle 43
38 4302 Combarbalá 43
39 4303 Monte Patria 43
40 4304 Punitaqui 43
41 4305 Río Hurtado 43
42 5101 Valparaíso 51
43 5102 Casablanca 51
44 5103 Concón 51
45 5104 Juan Fernández 51
46 5105 Puchuncaví 51
47 5107 Quintero 51
48 5109 Viña del Mar 51
49 5201 Isla de Pascua 52
50 5301 Los Andes 53
51 5302 Calle Larga 53
52 5303 Rinconada 53
53 5304 San Esteban 53
54 5401 La Ligua 54
55 5402 Cabildo 54
56 5403 Papudo 54
57 5404 Petorca 54
58 5405 Zapallar 54
59 5501 Quillota 55
60 5502 Calera 55
61 5503 Hijuelas 55
62 5504 La Cruz 55
63 5506 Nogales 55
64 5601 San Antonio 56
65 5602 Algarrobo 56
66 5603 Cartagena 56
67 5604 El Quisco 56
68 5605 El Tabo 56
69 5606 Santo Domingo 56
70 5701 San Felipe 57
71 5702 Catemu 57
72 5703 Llaillay 57
73 5704 Panquehue 57
74 5705 Putaendo 57
75 5706 Santa María 57
76 5801 Quilpué 58
77 5802 Limache 58
78 5803 Olmué 58
79 5804 Villa Alemana 58
80 6101 Rancagua 61
81 6102 Codegua 61
82 6103 Coinco 61
83 6104 Coltauco 61
84 6105 Doñihue 61
85 6106 Graneros 61
86 6107 Las Cabras 61
87 6108 Machalí 61
88 6109 Malloa 61
89 6110 Mostazal 61
90 6111 Olivar 61
91 6112 Peumo 61
92 6113 Pichidegua 61
93 6114 Quinta de Tilcoco 61
94 6115 Rengo 61
95 6116 Requínoa 61
96 6117 San Vicente 61
97 6201 Pichilemu 62
98 6202 La Estrella 62
99 6203 Litueche 62
100 6204 Marchihue 62
101 6205 Navidad 62
102 6206 Paredones 62
103 6301 San Fernando 63
104 6302 Chépica 63
105 6303 Chimbarongo 63
106 6304 Lolol 63
107 6305 Nancagua 63
108 6306 Palmilla 63
109 6307 Peralillo 63
110 6308 Placilla 63
111 6309 Pumanque 63
112 6310 Santa Cruz 63
113 7101 Talca 71
114 7102 Constitución 71
115 7103 Curepto 71
116 7104 Empedrado 71
117 7105 Maule 71
118 7106 Pelarco 71
119 7107 Pencahue 71
120 7108 Río Claro 71
121 7109 San Clemente 71
122 7110 San Rafael 71
123 7201 Cauquenes 72
124 7202 Chanco 72
125 7203 Pelluhue 72
126 7301 Curicó 73
127 7302 Hualañé 73
128 7303 Licantén 73
129 7304 Molina 73
130 7305 Rauco 73
131 7306 Romeral 73
132 7307 Sagrada Familia 73
133 7308 Teno 73
134 7309 Vichuquén 73
135 7401 Linares 74
136 7402 Colbún 74
137 7403 Longaví 74
138 7404 Parral 74
139 7405 Retiro 74
140 7406 San Javier 74
141 7407 Villa Alegre 74
142 7408 Yerbas Buenas 74
143 8101 Concepción 81
144 8102 Coronel 81
145 8103 Chiguayante 81
146 8104 Florida 81
147 8105 Hualqui 81
148 8106 Lota 81
149 8107 Penco 81
150 8108 San Pedro de la Paz 81
151 8109 Santa Juana 81
152 8110 Talcahuano 81
153 8111 Tomé 81
154 8112 Hualpén 81
155 8201 Lebu 82
156 8202 Arauco 82
157 8203 Cañete 82
158 8204 Contulmo 82
159 8205 Curanilahue 82
160 8206 Los Álamos 82
161 8207 Tirúa 82
162 8301 Los Ángeles 83
163 8302 Antuco 83
164 8303 Cabrero 83
165 8304 Laja 83
166 8305 Mulchén 83
167 8306 Nacimiento 83
168 8307 Negrete 83
169 8308 Quilaco 83
170 8309 Quilleco 83
171 8310 San Rosendo 83
172 8311 Santa Bárbara 83
173 8312 Tucapel 83
174 8313 Yumbel 83
175 8314 Alto Biobío 83
176 8401 Chillán 84
177 8402 Bulnes 84
178 8403 Cobquecura 84
179 8404 Coelemu 84
180 8405 Coihueco 84
181 8406 Chillán Viejo 84
182 8407 El Carmen 84
183 8408 Ninhue 84
184 8409 Ñiquén 84
185 8410 Pemuco 84
186 8411 Pinto 84
187 8412 Portezuelo 84
188 8413 Quillón 84
189 8414 Quirihue 84
190 8415 Ránquil 84
191 8416 San Carlos 84
192 8417 San Fabián 84
193 8418 San Ignacio 84
194 8419 San Nicolás 84
195 8420 Treguaco 84
196 8421 Yungay 84
197 9101 Temuco 91
198 9102 Carahue 91
199 9103 Cunco 91
200 9104 Curarrehue 91
201 9105 Freire 91
202 9106 Galvarino 91
203 9107 Gorbea 91
204 9108 Lautaro 91
205 9109 Loncoche 91
206 9110 Melipeuco 91
207 9111 Nueva Imperial 91
208 9112 Padre las Casas 91
209 9113 Perquenco 91
210 9114 Pitrufquén 91
211 9115 Pucón 91
212 9116 Saavedra 91
213 9117 Teodoro Schmidt 91
214 9118 Toltén 91
215 9119 Vilcún 91
216 9120 Villarrica 91
217 9121 Cholchol 91
218 9201 Angol 92
219 9202 Collipulli 92
220 9203 Curacautín 92
221 9204 Ercilla 92
222 9205 Lonquimay 92
223 9206 Los Sauces 92
224 9207 Lumaco 92
225 9208 Purén 92
226 9209 Renaico 92
227 9210 Traiguén 92
228 9211 Victoria 92
229 10101 Puerto Montt 101
230 10102 Calbuco 101
231 10103 Cochamó 101
232 10104 Fresia 101
233 10105 Frutillar 101
234 10106 Los Muermos 101
235 10107 Llanquihue 101
236 10108 Maullín 101
237 10109 Puerto Varas 101
238 10201 Castro 102
239 10202 Ancud 102
240 10203 Chonchi 102
241 10204 Curaco de Vélez 102
242 10205 Dalcahue 102
243 10206 Puqueldón 102
244 10207 Queilén 102
245 10208 Quellón 102
246 10209 Quemchi 102
247 10210 Quinchao 102
248 10301 Osorno 103
249 10302 Puerto Octay 103
250 10303 Purranque 103
251 10304 Puyehue 103
252 10305 Río Negro 103
253 10306 San Juan de la Costa 103
254 10307 San Pablo 103
255 10401 Chaitén 104
256 10402 Futaleufú 104
257 10403 Hualaihué 104
258 10404 Palena 104
259 11101 Coihaique 111
260 11102 Lago Verde 111
261 11201 Aisén 112
262 11202 Cisnes 112
263 11203 Guaitecas 112
264 11301 Cochrane 113
265 11302 O’Higgins 113
266 11303 Tortel 113
267 11401 Chile Chico 114
268 11402 Río Ibáñez 114
269 12101 Punta Arenas 121
270 12102 Laguna Blanca 121
271 12103 Río Verde 121
272 12104 San Gregorio 121
273 12201 Cabo de Hornos (Ex Navarino) 122
274 12202 Antártica 122
275 12301 Porvenir 123
276 12302 Primavera 123
277 12303 Timaukel 123
278 12401 Natales 124
279 12402 Torres del Paine 124
280 13101 Santiago 131
281 13102 Cerrillos 131
282 13103 Cerro Navia 131
283 13104 Conchalí 131
284 13105 El Bosque 131
285 13106 Estación Central 131
286 13107 Huechuraba 131
287 13108 Independencia 131
288 13109 La Cisterna 131
289 13110 La Florida 131
290 13111 La Granja 131
291 13112 La Pintana 131
292 13113 La Reina 131
293 13114 Las Condes 131
294 13115 Lo Barnechea 131
295 13116 Lo Espejo 131
296 13117 Lo Prado 131
297 13118 Macul 131
298 13119 Maipú 131
299 13120 Ñuñoa 131
300 13121 Pedro Aguirre Cerda 131
301 13122 Peñalolén 131
302 13123 Providencia 131
303 13124 Pudahuel 131
304 13125 Quilicura 131
305 13126 Quinta Normal 131
306 13127 Recoleta 131
307 13128 Renca 131
308 13129 San Joaquín 131
309 13130 San Miguel 131
310 13131 San Ramón 131
311 13132 Vitacura 131
312 13201 Puente Alto 132
313 13202 Pirque 132
314 13203 San José de Maipo 132
315 13301 Colina 133
316 13302 Lampa 133
317 13303 Tiltil 133
318 13401 San Bernardo 134
319 13402 Buin 134
320 13403 Calera de Tango 134
321 13404 Paine 134
322 13501 Melipilla 135
323 13502 Alhué 135
324 13503 Curacaví 135
325 13504 María Pinto 135
326 13505 San Pedro 135
327 13601 Talagante 136
328 13602 El Monte 136
329 13603 Isla de Maipo 136
330 13604 Padre Hurtado 136
331 13605 Peñaflor 136
332 14101 Valdivia 141
333 14102 Corral 141
334 14103 Lanco 141
335 14104 Los Lagos 141
336 14105 Máfil 141
337 14106 Mariquina 141
338 14107 Paillaco 141
339 14108 Panguipulli 141
340 14201 La Unión 142
341 14202 Futrono 142
342 14203 Lago Ranco 142
343 14204 Río Bueno 142
344 15101 Arica 151
345 15102 Camarones 151
346 15201 Putre 152
347 15202 General Lagos 152

View File

@ -0,0 +1,55 @@
id;descripcion;region
11;Iquique;1
14;Tamarugal;1
21;Antofagasta;2
22;El Loa;2
23;Tocopilla;2
31;Copiap;3
32;Chañaral;3
33;Huasco;3
41;Elqui;4
42;Choapa;4
43;Limari;4
51;Valparaíso;5
52;Isla de Pascua;5
53;Los Andes;5
54;Petorca;5
55;Quillota;5
56;San Antonio;5
57;San Felipe;5
58;Marga Marga;5
61;Cachapoal;6
62;Cardenal Caro;6
63;Colchagua;6
71;Talca;7
72;Cauquenes;7
73;Curico;7
74;Linares;7
81;Concepci;8
82;Arauco;8
83;Bío- Bío;8
84;Ñuble;8
91;Cautín;9
92;Malleco;9
101;Llanquihue;10
102;Chiloe;10
103;Osorno;10
104;Palena;10
111;Coihaique;11
112;Aisén;11
113;Capitan Prat;11
114;General Carrera;11
121;Magallanes;12
122;Antártica Chilena;12
123;Tierra del Fuego;12
124;Ultima Esperanza;12
131;Santiago;13
132;Cordillera;13
133;Chacabuco;13
134;Maipo;13
135;Melipilla;13
136;Talagante;13
141;Valdivia;14
142;Ranco;14
151;Arica;15
152;Parinacota;15
1 id descripcion region
2 11 Iquique 1
3 14 Tamarugal 1
4 21 Antofagasta 2
5 22 El Loa 2
6 23 Tocopilla 2
7 31 Copiap 3
8 32 Chañaral 3
9 33 Huasco 3
10 41 Elqui 4
11 42 Choapa 4
12 43 Limari 4
13 51 Valparaíso 5
14 52 Isla de Pascua 5
15 53 Los Andes 5
16 54 Petorca 5
17 55 Quillota 5
18 56 San Antonio 5
19 57 San Felipe 5
20 58 Marga Marga 5
21 61 Cachapoal 6
22 62 Cardenal Caro 6
23 63 Colchagua 6
24 71 Talca 7
25 72 Cauquenes 7
26 73 Curico 7
27 74 Linares 7
28 81 Concepci 8
29 82 Arauco 8
30 83 Bío- Bío 8
31 84 Ñuble 8
32 91 Cautín 9
33 92 Malleco 9
34 101 Llanquihue 10
35 102 Chiloe 10
36 103 Osorno 10
37 104 Palena 10
38 111 Coihaique 11
39 112 Aisén 11
40 113 Capitan Prat 11
41 114 General Carrera 11
42 121 Magallanes 12
43 122 Antártica Chilena 12
44 123 Tierra del Fuego 12
45 124 Ultima Esperanza 12
46 131 Santiago 13
47 132 Cordillera 13
48 133 Chacabuco 13
49 134 Maipo 13
50 135 Melipilla 13
51 136 Talagante 13
52 141 Valdivia 14
53 142 Ranco 14
54 151 Arica 15
55 152 Parinacota 15

View File

@ -0,0 +1,16 @@
id;descripcion;numeral;numeracion
1;Región de Tarapacá;I;1
2;Región de Antofagasta;II;2
3;Región de Atacama;III;3
4;Región de Coquimbo;IV;4
5;Región de Valparaíso;V;5
6;Región del Libertador Gral. Bernardo OHiggins;VI;6
7;Región del Maule;VII;7
8;Región del Biobío;VIII;8
9;Región de la Araucanía;IX;9
10;Región de Los Lagos;X;10
11;Región Aisén del Gral. Carlos Ibáñez del Campo;XI;11
12;Región de Magallanes y de la Antártica Chilena;XII;12
13;Región Metropolitana de Santiago;RM;13
14;Región de Los Ríos;XIV;14
15;Región de Arica y Parinacota;XV;15
1 id descripcion numeral numeracion
2 1 Región de Tarapacá I 1
3 2 Región de Antofagasta II 2
4 3 Región de Atacama III 3
5 4 Región de Coquimbo IV 4
6 5 Región de Valparaíso V 5
7 6 Región del Libertador Gral. Bernardo O’Higgins VI 6
8 7 Región del Maule VII 7
9 8 Región del Biobío VIII 8
10 9 Región de la Araucanía IX 9
11 10 Región de Los Lagos X 10
12 11 Región Aisén del Gral. Carlos Ibáñez del Campo XI 11
13 12 Región de Magallanes y de la Antártica Chilena XII 12
14 13 Región Metropolitana de Santiago RM 13
15 14 Región de Los Ríos XIV 14
16 15 Región de Arica y Parinacota XV 15

View File

@ -7,4 +7,4 @@ $app->group('/contabilidad', function($app) {
} }
include_once $file->getRealPath(); include_once $file->getRealPath();
} }
}); })->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));

View File

@ -7,4 +7,4 @@ $app->group('/admin', function($app) {
} }
include_once $file->getRealPath(); include_once $file->getRealPath();
} }
}); })->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class));

View File

@ -2,5 +2,9 @@
use Incoviba\Controller\API\Admin\Users; use Incoviba\Controller\API\Admin\Users;
$app->group('/users', function($app) { $app->group('/users', function($app) {
$app->post('/add[/]', Users::class . ':add'); $app->post('/add[/]', [Users::class, 'add']);
});
$app->group('/user/{user_id}', function($app) {
$app->post('/edit[/]', [Users::class, 'edit']);
$app->delete('[/]', [Users::class, 'delete']);
}); });

View File

@ -0,0 +1,16 @@
<?php
use Incoviba\Controller\API\External;
$app->group('/external', function($app) {
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'external']));
foreach ($files as $file) {
if ($file->isDir()) {
continue;
}
include_once $file->getRealPath();
}
$app->group('/services', function($app) {
$app->get('/check[/]', [External::class, 'check']);
$app->get('/update[/]', [External::class, 'update']);
});
});

View File

@ -0,0 +1,11 @@
<?php
use Incoviba\Controller\API\Ventas\MediosPago\Toku;
$app->group('/toku', function($app) {
$app->post('/cuotas/{venta_id}[/]', [Toku::class, 'cuotas']);
$app->post('/success[/]', [Toku::class, 'success']);
$app->get('/test[/]', [Toku::class, 'test']);
$app->delete('/reset[/]', [Toku::class, 'reset']);
$app->post('/enqueue[/]', [Toku::class, 'enqueue']);
$app->post('/update[/{type}[/]]', [Toku::class, 'update']);
});

View File

@ -0,0 +1,7 @@
<?php
use Incoviba\Controller\API\Personas;
//$app->group('/personas', function($app) {});
$app->group('/persona/{rut}', function($app) {
$app->get('[/]', [Personas::class, 'get']);
});

View File

@ -30,4 +30,5 @@ $app->group('/proyecto/{proyecto_id}', function($app) {
$app->post('/edit[/]', [Proyectos::class, 'terreno']); $app->post('/edit[/]', [Proyectos::class, 'terreno']);
}); });
$app->get('/brokers', [Proyectos::class, 'brokers']); $app->get('/brokers', [Proyectos::class, 'brokers']);
$app->get('/promotions', [Proyectos::class, 'promotions']);
}); });

View File

@ -0,0 +1,10 @@
<?php
use Incoviba\Controller\API\Queues;
$app->group('/queue', function($app) {
#$app->get('/jobs[/]', [Queues::class, 'jobs']);
$app->group('/run', function($app) {
#$app->get('/{job_id:[0-9]+}[/]', [Queues::class, 'run']);
$app->get('[/]', Queues::class);
});
});

View File

@ -3,6 +3,11 @@ use Incoviba\Controller\API\Ventas\Reservations;
$app->group('/reservations', function($app) { $app->group('/reservations', function($app) {
$app->post('/add[/]', [Reservations::class, 'add']); $app->post('/add[/]', [Reservations::class, 'add']);
$app->group('/project/{project_id}', function($app) {
$app->get('/active[/]', [Reservations::class, 'active']);
$app->get('/pending[/]', [Reservations::class, 'pending']);
$app->get('/rejected[/]', [Reservations::class, 'rejected']);
});
$app->get('[/]', Reservations::class); $app->get('[/]', Reservations::class);
}); });
$app->group('/reservation/{reservation_id}', function($app) { $app->group('/reservation/{reservation_id}', function($app) {

View File

@ -1,5 +1,6 @@
<?php <?php
use Incoviba\Controller\Ventas\Cierres; //use Incoviba\Controller\Ventas\Cierres;
use Incoviba\Controller\Ventas\Reservations as Cierres;
$app->group('/cierres', function($app) { $app->group('/cierres', function($app) {
$app->get('[/]', Cierres::class); $app->get('[/]', Cierres::class);

View File

@ -14,15 +14,15 @@
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody id="users">
@foreach($users as $user) @foreach($users as $user)
<tr> <tr data-user="{{ $user->id }}">
<td>{{ $user->name }}</td> <td>{{ $user->name }}</td>
<td class="right aligned"> <td class="right aligned">
<button class="ui mini blue icon button"> <button class="ui mini blue icon button edit" data-user="{{ $user->id }}">
<i class="edit icon"></i> <i class="edit icon"></i>
</button> </button>
<button class="ui mini red icon button"> <button class="ui mini red icon button remove" data-user="{{ $user->id }}">
<i class="trash icon"></i> <i class="trash icon"></i>
</button> </button>
</td> </td>
@ -50,6 +50,10 @@
<label>Contraseña</label> <label>Contraseña</label>
<input type="password" name="password" placeholder="Contraseña"> <input type="password" name="password" placeholder="Contraseña">
</div> </div>
<div class="field">
<label>Confirmar contraseña</label>
<input type="password" name="password_confirmation" placeholder="Confirmar contraseña">
</div>
</form> </form>
</div> </div>
<div class="actions"> <div class="actions">
@ -62,6 +66,45 @@
</div> </div>
</div> </div>
</div> </div>
<div class="ui modal" id="edit-user-modal">
<i class="close icon"></i>
<div class="header">
Editar usuario
</div>
<div class="content">
<form class="ui form">
<input type="hidden" name="id" />
<div class="field">
<label>Contraseña Antigua</label>
<input type="password" name="old_password" placeholder="Contraseña Antigua">
</div>
<div class="field">
<label>Force Change?</label>
<div class="ui checkbox">
<input type="checkbox" name="force" >
<label>Yes</label>
</div>
</div>
<div class="field">
<label>Contraseña</label>
<input type="password" name="password" placeholder="Contraseña">
</div>
<div class="field">
<label>Confirmar contraseña</label>
<input type="password" name="password_confirmation" placeholder="Confirmar contraseña">
</div>
</form>
</div>
<div class="actions">
<div class="ui black deny button">
Cancelar
</div>
<div class="ui positive right labeled icon button">
Guardar
<i class="checkmark icon"></i>
</div>
</div>
</div>
@endsection @endsection
@include('layout.body.scripts.cryptojs') @include('layout.body.scripts.cryptojs')
@ -74,12 +117,20 @@
return [passphrase, encrypted.toString()].join('') return [passphrase, encrypted.toString()].join('')
} }
$(document).ready(function () { $(document).ready(function () {
$('#create-user-modal').modal({ const $createUserModal = $('#create-user-modal')
$createUserModal.modal({
onApprove: function() { onApprove: function() {
const form = document.querySelector('#create-user-modal form')
const password = form.querySelector('[name="password"]').value
const password_confirmation = form.querySelector('[name="password_confirmation"]').value
if (password !== password_confirmation) {
alert('Las contraseñas no coinciden')
return
}
const url = '{{$urls->api}}/admin/users/add' const url = '{{$urls->api}}/admin/users/add'
const method = 'post' const method = 'post'
const body = new FormData(document.querySelector('#create-user-modal form')) const body = new FormData(form)
body.set('password', encryptPassword(body.get('password'))) body.set('password', encryptPassword(password))
fetchAPI(url, {method, body}).then(response => { fetchAPI(url, {method, body}).then(response => {
if (!response) { if (!response) {
return; return;
@ -92,8 +143,64 @@
}) })
} }
}) })
$('#create-user-button').on('click', function () { const $editUserModal = $('#edit-user-modal')
$('#create-user-modal').modal('show') $editUserModal.modal({
onApprove: function() {
const form = document.querySelector('#edit-user-modal form')
const user_id = form.querySelector('[name="id"]').value
const old_password = form.querySelector('[name="old_password"]').value
const password = form.querySelector('[name="password"]').value
const password_confirmation = form.querySelector('[name="password_confirmation"]').value
if (password !== password_confirmation) {
alert('Las nuevas contraseñas no coinciden')
return
}
const url = `{{$urls->api}}/admin/user/${user_id}/edit`
const method = 'post'
const body = new FormData(form)
body.set('old_password', encryptPassword(old_password))
body.set('password', encryptPassword(password))
if (form.querySelector('[name="force"]').checked) {
body.set('force', 'true')
}
fetchAPI(url, {method, body}).then(response => {
if (!response) {
return;
}
response.json().then(result => {
if (result.success) {
location.reload()
}
})
})
}
})
document.getElementById('create-user-modal').addEventListener('submit', event => {
$createUserModal.modal('show')
})
document.querySelectorAll('.button.edit').forEach(button => {
button.addEventListener('click', clickEvent => {
const user_id = clickEvent.currentTarget.dataset.user
$editUserModal.find('input[name="id"]').val(user_id)
$editUserModal.modal('show')
})
})
document.querySelectorAll('.button.remove').forEach(button => {
button.addEventListener('click', clickEvent => {
const user_id = clickEvent.currentTarget.dataset.user
const url = `{{$urls->api}}/admin/user/${user_id}`
const method = 'delete'
fetchAPI(url, {method}).then(response => {
if (!response) {
return;
}
response.json().then(result => {
if (result.success) {
location.reload()
}
})
})
})
}) })
}); });
</script> </script>

View File

@ -20,7 +20,7 @@
@endsection @endsection
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
const cuotas = { const cuotas = {
get: function() { get: function() {
return { return {

View File

@ -2,7 +2,7 @@
<div class="ui divided list" id="alertas_escrituras"></div> <div class="ui divided list" id="alertas_escrituras"></div>
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
const alertas_escrituras = { const alertas_escrituras = {
id: '#alertas_escrituras', id: '#alertas_escrituras',
data: { data: {

View File

@ -2,7 +2,7 @@
<div class="ui divided list" id="cierres_vigentes"></div> <div class="ui divided list" id="cierres_vigentes"></div>
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
const cierres_vigentes = { const cierres_vigentes = {
get: function() { get: function() {
const list = $('#cierres_vigentes') const list = $('#cierres_vigentes')

View File

@ -2,7 +2,7 @@
<div class="ui divided list" id="cuotas_por_vencer"></div> <div class="ui divided list" id="cuotas_por_vencer"></div>
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
const cuotas_por_vencer = { const cuotas_por_vencer = {
get: function() { get: function() {
const list = $('#cuotas_por_vencer') const list = $('#cuotas_por_vencer')

View File

@ -11,7 +11,7 @@
</div> </div>
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
function logout() { function logout() {
return fetch('{{$urls->base}}/logout').then(response => { return fetch('{{$urls->base}}/logout').then(response => {
if (response.ok) { if (response.ok) {

View File

@ -1,28 +1,32 @@
<script> <script>
class APIClient { class APIClient {
static getApiKey() {
return '{{md5($API_KEY)}}{{($login->isIn()) ? $login->getSeparator() . $login->getToken() : ''}}'
}
static fetch(url, options=null, showErrors=false) { static fetch(url, options=null, showErrors=false) {
return fetchAPI(url, options, showErrors) if (options === null) {
options = {}
}
if (!Object.hasOwn(options, 'headers')) {
options['headers'] = {}
}
if (!Object.hasOwn(options['headers'], 'Authorization')) {
options['headers']['Authorization'] = `Bearer ${APIClient.getApiKey()}`
}
return fetch(url, options).then(response => {
if (response.ok) {
return response
}
throw new Error(JSON.stringify({code: response.status, message: response.statusText, url}))
}).catch(error => {
if (showErrors) {
console.error(error)
}
})
} }
} }
function fetchAPI(url, options=null, showErrors=false) { function fetchAPI(url, options=null, showErrors=false) {
if (options === null) { return APIClient.fetch(url, options, showErrors)
options = {}
}
if (!Object.hasOwn(options, 'headers')) {
options['headers'] = {}
}
if (!Object.hasOwn(options['headers'], 'Authorization')) {
options['headers']['Authorization'] = 'Bearer {{md5($API_KEY)}}{{($login->isIn()) ? $login->getSeparator() . $login->getToken() : ''}}'
}
return fetch(url, options).then(response => {
if (response.ok) {
return response
}
throw new Error(JSON.stringify({code: response.status, message: response.statusText, url}))
}).catch(error => {
if (showErrors) {
console.error(error)
}
})
} }
</script> </script>

View File

@ -1,4 +1,4 @@
@push('page_scripts') @push('page_scripts')
<script type="text/javascript" src="https://cdn.datatables.net/2.0.3/js/dataTables.min.js"></script> <script src="https://cdn.datatables.net/2.0.3/js/dataTables.min.js"></script>
<script src="https://cdn.datatables.net/2.0.3/js/dataTables.semanticui.min.js"></script> <script src="https://cdn.datatables.net/2.0.3/js/dataTables.semanticui.min.js"></script>
@endpush @endpush

View File

@ -19,7 +19,7 @@
@include('layout.body.scripts.cryptojs') @include('layout.body.scripts.cryptojs')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
function encryptPassword(password) { function encryptPassword(password) {
const passphrase = Math.floor(Math.random() * Date.now()).toString() const passphrase = Math.floor(Math.random() * Date.now()).toString()
const encrypted = CryptoJS.AES.encrypt(password, passphrase) const encrypted = CryptoJS.AES.encrypt(password, passphrase)

View File

@ -0,0 +1,14 @@
@extends('layout.base')
@section('page_title')
405 - Método No Permitido
@endsection
@section('page_content')
<div class="ui container">
<div class="ui message">
<i class="exclamation triangle icon"></i>
No se ha encontrado la página solicitada para el método solicitado.
</div>
</div>
@endsection

View File

@ -35,7 +35,7 @@
@endsection @endsection
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
class Proyecto { class Proyecto {
id id
estados estados

View File

@ -141,7 +141,7 @@
@include('layout.body.scripts.chartjs') @include('layout.body.scripts.chartjs')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
const superficies = { const superficies = {
ids: { ids: {
vendible: '', vendible: '',

View File

@ -39,7 +39,7 @@
@endpush @endpush
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
class Unidad class Unidad
{ {
id id

View File

@ -31,7 +31,7 @@
@include('layout.body.scripts.datatables') @include('layout.body.scripts.datatables')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
class Row class Row
{ {
proyecto proyecto

View File

@ -153,10 +153,10 @@
@include('layout.body.scripts.rut') @include('layout.body.scripts.rut')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
const regiones = [ const regiones = [
@foreach ($regiones as $region) @foreach ($regiones as $region)
'<div class="item" data-value="{{$region->id}}">{{$region->descripcion}}</div>', '<div class="item" data-value="{{$region->id}}">{{$region->numeral}} - {{$region->descripcion}}</div>',
@endforeach @endforeach
] ]
@ -354,56 +354,65 @@
const lines = [ const lines = [
'<label for="rut">RUT</label>', '<label for="rut">RUT</label>',
'<div class="inline field">', '<div class="inline field">',
'<input type="text" id="rut" name="rut" placeholder="00000000-0" required />', '<input type="text" id="rut" name="rut" placeholder="00000000-0" required />',
'<span class="ui error message" id="alert_rut">', '<span class="ui error message" id="alert_rut">',
'<i class="exclamation triangle icon"></i>', '<i class="exclamation triangle icon"></i>',
'RUT Inválido', 'RUT Inválido',
'</span>', '</span>',
'</div>', '</div>',
'<label for="nombres">Nombre</label>', '<label for="nombres">Nombre</label>',
'<div class="inline fields">', '<div class="inline fields">',
'<div class="field">', '<div class="field">',
'<input type="text" name="nombres" id="nombres" placeholder="Nombre(s)" required />', '<input type="text" name="nombres" id="nombres" placeholder="Nombre(s)" required />',
'</div>', '</div>',
'<div class="field">', '<div class="field">',
'<input type="text" name="apellido_paterno" placeholder="Apellido Paterno" required />', '<input type="text" name="apellido_paterno" placeholder="Apellido Paterno" required />',
'</div>', '</div>',
'<div class="field">', '<div class="field">',
'<input type="text" name="apellido_materno" placeholder="Apellido Materno" required />', '<input type="text" name="apellido_materno" placeholder="Apellido Materno" required />',
'</div>', '</div>',
'</div>', '</div>',
'<label for="calle">Dirección</label>', '<label for="calle">Dirección</label>',
'<div class="inline fields">', '<div class="inline fields">',
'<div class="eight wide field">', '<div class="eight wide field">',
'<input type="text" name="calle" id="calle" size="16" placeholder="Calle" required />', '<input type="text" name="calle" id="calle" size="16" placeholder="Calle" required />',
'</div>', '</div>',
'<div class="field">', '<div class="field">',
'<input type="text" name="numero" size="5" placeholder="Número" required />', '<input type="text" name="numero" size="5" placeholder="Número" required />',
'</div>', '</div>',
'<div class="field">', '<div class="field">',
'<input type="text" name="extra" placeholder="Otros Detalles" />', '<input type="text" name="extra" placeholder="Otros Detalles" />',
'</div>', '</div>',
'</div>', '</div>',
'<div class="inline fields">', '<div class="inline fields">',
'<div class="two wide field"></div>', '<div class="two wide field"></div>',
'<div class="four wide field">', '<div class="four wide field">',
'<div class="ui fluid search selection dropdown" id="comuna">', '<div class="ui fluid search selection dropdown" id="comuna">',
'<input type="hidden" name="comuna" />', '<input type="hidden" name="comuna" />',
'<i class="dropdown icon"></i>', '<i class="dropdown icon"></i>',
'<div class="default text">Comuna</div>', '<div class="default text">Comuna</div>',
'<div class="menu"></div>', '<div class="menu"></div>',
'</div>', '</div>',
'</div>', '</div>',
'<div class="six wide field">', '<div class="six wide field">',
'<div class="ui fluid search selection dropdown" id="region">', '<div class="ui fluid search selection dropdown" id="region">',
'<input type="hidden" name="region" />', '<input type="hidden" name="region" />',
'<i class="dropdown icon"></i>', '<i class="dropdown icon"></i>',
'<div class="default text">Región</div>', '<div class="default text">Región</div>',
'<div class="menu">', '<div class="menu">',
...regiones, ...regiones,
'</div>', '</div>',
'</div>', '</div>',
'</div>',
'</div>', '</div>',
'<label>Otros Datos</label>',
'<div class="inline fields">',
'<div class="four wide field">',
'<input type="email" name="email" placeholder="Email" />',
'</div>',
'<div class="field">',
'<input type="text" name="telefono" placeholder="Teléfono" />',
'</div>',
'</div>' '</div>'
] ]
return lines.join("\n") return lines.join("\n")
@ -467,8 +476,10 @@
'</div>', '</div>',
'</div>', '</div>',
'<div>Representante Legal</div>', '<div>Representante Legal</div>',
'<div class="ui divider"></div>',
this.persona.draw()
] ]
return [lines.join("\n"), this.persona.draw()].join("\n") return lines.join("\n")
} }
activate() { activate() {
new RutHandler({id: '#rut_sociedad', alert_id: '#alert_rut_sociedad'}) new RutHandler({id: '#rut_sociedad', alert_id: '#alert_rut_sociedad'})
@ -486,6 +497,7 @@
draw() { draw() {
let lines = [ let lines = [
this.persona.draw(), this.persona.draw(),
'<div class="ui divider"></div>',
'<label for="rut">RUT Otro</label>', '<label for="rut">RUT Otro</label>',
'<div class="inline field">', '<div class="inline field">',
'<input type="text" id="rut_otro" name="rut_otro" required />', '<input type="text" id="rut_otro" name="rut_otro" required />',
@ -538,6 +550,15 @@
'</div>', '</div>',
'</div>', '</div>',
'</div>', '</div>',
'</div>',
'<label>Otros Datos para Otro</label>',
'<div class="inline fields">',
'<div class="four wide field">',
'<input type="email" name="email_otro" placeholder="Email" />',
'</div>',
'<div class="field">',
'<input type="text" name="telefono_otro" placeholder="Teléfono" />',
'</div>',
'</div>' '</div>'
] ]
return lines.join("\n") return lines.join("\n")
@ -607,6 +628,8 @@
parent.find("[name='extra']").val(data.propietario.direccion.extra) parent.find("[name='extra']").val(data.propietario.direccion.extra)
parent.find('#region').dropdown('set selected', data.propietario.direccion.comuna.provincia.region.id) parent.find('#region').dropdown('set selected', data.propietario.direccion.comuna.provincia.region.id)
parent.find('#comuna').dropdown('set selected', data.propietario.direccion.comuna.id) parent.find('#comuna').dropdown('set selected', data.propietario.direccion.comuna.id)
parent.find("[name='email']").val(data.propietario.email)
parent.find("[name='telefono']").val(data.propietario.telefono)
if (data.propietario.representante !== '') { if (data.propietario.representante !== '') {
document.getElementById(this.ids.tipo).trigger('check') document.getElementById(this.ids.tipo).trigger('check')
@ -785,7 +808,9 @@
} }
$(document).ready(() => { $(document).ready(() => {
$('#fecha_venta_calendar').calendar(calendar_date_options) const cdo = structuredClone(calendar_date_options)
cdo['maxDate'] = new Date()
$('#fecha_venta_calendar').calendar(cdo)
new Propietario({id: '#propietario', id_tipo: 'persona_propietario', id_cantidad: 'cantidad_propietario'}) new Propietario({id: '#propietario', id_tipo: 'persona_propietario', id_cantidad: 'cantidad_propietario'})
new Proyecto({unidades_id: '#unidades', proyecto_id: '#proyecto'}) new Proyecto({unidades_id: '#unidades', proyecto_id: '#proyecto'})

View File

@ -25,7 +25,7 @@
@endpush @endpush
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
class Cierre { class Cierre {
id id
proyecto_id proyecto_id

View File

@ -120,7 +120,7 @@
@endsection @endsection
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
function action(action, cierre_id) { function action(action, cierre_id) {
const url = '{{$urls->base}}/api/cierre/' + cierre_id + '/' + action const url = '{{$urls->base}}/api/cierre/' + cierre_id + '/' + action
console.debug(url) console.debug(url)

View File

@ -65,7 +65,7 @@
@include('layout.body.scripts.datatables') @include('layout.body.scripts.datatables')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
$(document).ready(() => { $(document).ready(() => {
const cuotas_tables = new DataTable('#cuotas', { const cuotas_tables = new DataTable('#cuotas', {
language: { language: {

View File

@ -66,7 +66,7 @@
@include('layout.body.scripts.datatables') @include('layout.body.scripts.datatables')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
$(document).ready(() => { $(document).ready(() => {
const cuotas_tables = new DataTable('#cuotas', { const cuotas_tables = new DataTable('#cuotas', {
language: { language: {

View File

@ -54,22 +54,23 @@
} }
$(document).ready(() => { $(document).ready(() => {
const url = '{{$urls->api}}/ventas/pago/{{$venta->resciliacion()->id}}' const url = '{{$urls->api}}/ventas/pago/{{$venta->resciliacion()->id}}'
let old = new Date({{$venta->resciliacion()?->fecha->format('Y') ?? date('Y')}}, let old = new Date(Date.parse('{{$venta->resciliacion()?->fecha->format('Y-m-d') ?? $venta->currentEstado()->fecha->format('Y-m-d') ?? $venta->fecha->format('Y-m-d')}}') + 24 * 60 * 60 * 1000)
{{$venta->resciliacion()?->fecha->format('n') ?? date('n')}}-1, {{$venta->resciliacion()?->fecha->format('j') ?? date('j')}})
calendar_date_options['initialDate'] = old calendar_date_options['initialDate'] = old
calendar_date_options['onChange'] = function(date, text, mode) { calendar_date_options['onChange'] = function(date, text, mode) {
if (date.getTime() === old.getTime()) { if (date.getTime() === old.getTime()) {
return return
} }
const body = new FormData() const body = new FormData()
body.set('fecha', date.toISOString()) const fecha = new Date(date.getTime())
fecha.setDate(fecha.getDate() - 1)
body.set('fecha', fecha.toISOString())
$('#loading-spinner-fecha').show() $('#loading-spinner-fecha').show()
APIClient.fetch(url, {method: 'post', body}).then(response => { APIClient.fetch(url, {method: 'post', body}).then(response => {
$('#loading-spinner-fecha').hide() $('#loading-spinner-fecha').hide()
if (!response) { if (!response) {
return return
} }
old = date old = new Date(date.getTime())
alertResponse('Fecha cambiada correctamente.') alertResponse('Fecha cambiada correctamente.')
}) })
} }

View File

@ -6,15 +6,26 @@
@section('venta_content') @section('venta_content')
<div class="ui list"> <div class="ui list">
<div class="item"> @if (isset($venta->formaPago()->pie))
<div class="header">Valor Pagado</div> <div class="item">
<div class="content"> <div class="header">Valor Pagado</div>
{{$format->pesos($venta->formaPago()->pie->pagado('pesos'))}} <div class="content">
<div class="ui left pointing small label"> {{$format->pesos($venta->formaPago()->pie->pagado('pesos'))}}
{{$format->number($venta->formaPago()->pie->pagado() / $venta->valor * 100)}}% de la venta <div class="ui left pointing small label">
{{$format->number($venta->formaPago()->pie->pagado() / $venta->valor * 100)}}% de la venta
</div>
</div> </div>
</div> </div>
</div> @else
<div class="item">
<div class="ui compact warning message">
<div class="content">
<i class="exclamation triangle icon"></i>
No tiene valor pagado
</div>
</div>
</div>
@endif
<div class="item"> <div class="item">
<div class="header"> <div class="header">
Multa Estandar Multa Estandar

View File

@ -29,7 +29,7 @@
@endsection @endsection
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
const editVenta = { const editVenta = {
getMonthsList() { getMonthsList() {
const formatter = new Intl.DateTimeFormat('es-CL', {month: 'long'}) const formatter = new Intl.DateTimeFormat('es-CL', {month: 'long'})

View File

@ -18,6 +18,8 @@
</div> </div>
@endsection @endsection
@include('layout.body.scripts.rut')
@push('page_scripts') @push('page_scripts')
@include('ventas.facturacion.show.factura') @include('ventas.facturacion.show.factura')
@include('ventas.facturacion.show.propietario') @include('ventas.facturacion.show.propietario')

View File

@ -194,7 +194,8 @@
}, },
unidad: ({unidad, no, classes, formatters}) => { unidad: ({unidad, no, classes, formatters}) => {
const descuento = this.props.terreno.valor * unidad.prorrateo * this.props.proporcion const descuento = this.props.terreno.valor * unidad.prorrateo * this.props.proporcion
const bruto = unidad.precio - descuento const precio = unidad.precio * this.props.proporcion
const bruto = precio - descuento
const neto = bruto / 1.19 const neto = bruto / 1.19
const data = [ const data = [
no, no,
@ -256,7 +257,7 @@
tooltips.neto = ` data-tooltip="No coinciden netos! Promesa: ${formatters.pesos.format(this.props.detalle.neto)} - Unidades: ${formatters.pesos.format(this.props.total.neto)}"` tooltips.neto = ` data-tooltip="No coinciden netos! Promesa: ${formatters.pesos.format(this.props.detalle.neto)} - Unidades: ${formatters.pesos.format(this.props.total.neto)}"`
} }
if (this.props.total.iva !== this.props.detalle.iva) { if (this.props.total.iva !== this.props.detalle.iva) {
tooltips.iva = ` data-tooltip="No coinciden ivas! Promesa: ${formatters.pesos.format(this.props.detalle.iva)} - Unidades: ${formatters.pesos.format(this.props.total.iva)}"` tooltips.iva = ` data-tooltip="No coinciden IVAs! Promesa: ${formatters.pesos.format(this.props.detalle.iva)} - Unidades: ${formatters.pesos.format(this.props.total.iva)}"`
} }
if (this.props.total.total !== this.props.detalle.total) { if (this.props.total.total !== this.props.detalle.total) {
tooltips.total = ` data-tooltip="No coinciden totales! Promesa: ${formatters.pesos.format(this.props.detalle.total)} - Unidades: ${formatters.pesos.format(this.props.total.total)}"` tooltips.total = ` data-tooltip="No coinciden totales! Promesa: ${formatters.pesos.format(this.props.detalle.total)} - Unidades: ${formatters.pesos.format(this.props.total.total)}"`
@ -399,7 +400,7 @@
}, },
total: () => { total: () => {
this.props.total.exento = this.props.detalle.terreno this.props.total.exento = this.props.detalle.terreno
this.props.total.neto = (this.props.unidades.reduce((sum, unidad) => sum + unidad.precio, 0) - this.props.total.exento) / 1.19 this.props.total.neto = (this.props.unidades.reduce((sum, unidad) => sum + unidad.precio, 0) * this.props.proporcion - this.props.total.exento) / 1.19
this.props.total.iva = this.props.total.neto * 0.19 this.props.total.iva = this.props.total.neto * 0.19
this.props.total.total = this.props.total.neto + this.props.total.iva + this.props.total.exento this.props.total.total = this.props.total.neto + this.props.total.iva + this.props.total.exento
}, },

View File

@ -28,7 +28,11 @@
facturas.draw().facturas() facturas.draw().facturas()
}, },
rut: rut => { rut: rut => {
this.props.rut = rut rut = rut.replaceAll(/~\d|\.|-/g, '')
const digito = rut.slice(-1)
rut = rut.slice(0, -1)
this.props.rut = Rut.format(rut) + '-' + digito
document.getElementById('rut'+this.props.index).value = this.props.rut
facturas.venta.update().facturas() facturas.venta.update().facturas()
facturas.draw().facturas() facturas.draw().facturas()
}, },
@ -72,7 +76,7 @@
}) })
}, },
rut: () => { rut: () => {
document.getElementById('rut'+this.props.index).addEventListener('input', inputEvent => { document.getElementById('rut'+this.props.index).addEventListener('change', inputEvent => {
const rut = inputEvent.currentTarget.value const rut = inputEvent.currentTarget.value
if (rut === this.props.rut) { if (rut === this.props.rut) {
return return
@ -81,7 +85,7 @@
}) })
}, },
nombre: () => { nombre: () => {
document.getElementById('propietario'+this.props.index).addEventListener('input', inputEvent => { document.getElementById('propietario'+this.props.index).addEventListener('change', inputEvent => {
const nombre = inputEvent.currentTarget.value const nombre = inputEvent.currentTarget.value
if (nombre === this.props.nombre) { if (nombre === this.props.nombre) {
return return
@ -90,7 +94,7 @@
}) })
}, },
direccion: () => { direccion: () => {
document.getElementById('direccion_propietario'+this.props.index).addEventListener('input', inputEvent => { document.getElementById('direccion_propietario'+this.props.index).addEventListener('change', inputEvent => {
const direccion = inputEvent.currentTarget.value const direccion = inputEvent.currentTarget.value
if (direccion === this.props.direccion) { if (direccion === this.props.direccion) {
return return

View File

@ -40,7 +40,7 @@
const url = '{{$urls->api}}/ventas/unidad/' + this.props.id + '/prorrateo' const url = '{{$urls->api}}/ventas/unidad/' + this.props.id + '/prorrateo'
const method = 'post' const method = 'post'
const body = new FormData() const body = new FormData()
body.set('prorrateo', newValue) body.set('prorrateo', (parseFloat(newValue) / 100).toFixed(8))
return fetchAPI(url, {method, body}).then(response => { return fetchAPI(url, {method, body}).then(response => {
if (!response) { if (!response) {
return return

View File

@ -31,7 +31,7 @@
@include('layout.body.scripts.datatables') @include('layout.body.scripts.datatables')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
class Venta { class Venta {
id id
propiedad propiedad

View File

@ -20,7 +20,7 @@
@include('layout.body.scripts.datatables') @include('layout.body.scripts.datatables')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
const historicos = { const historicos = {
id: '', id: '',
data: { data: {

View File

@ -61,6 +61,9 @@
<tbody>@php <tbody>@php
$now = new DateTimeImmutable(); $now = new DateTimeImmutable();
$uf_venta = $venta->uf === 0.0 ? $UF->get($venta->currentEstado()->fecha) : $venta->uf; $uf_venta = $venta->uf === 0.0 ? $UF->get($venta->currentEstado()->fecha) : $venta->uf;
if ($uf_venta === 0.0) {
$uf_venta = $UF->get();
}
@endphp @endphp
@foreach ($venta->formaPago()->pie->cuotas() as $cuota) @foreach ($venta->formaPago()->pie->cuotas() as $cuota)
<tr data-pago="{{$cuota->pago->id}}" <tr data-pago="{{$cuota->pago->id}}"
@ -201,7 +204,7 @@
@include('layout.body.scripts.datatables.buttons') @include('layout.body.scripts.datatables.buttons')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
$(document).ready(() => { $(document).ready(() => {
function updateRow({pago_id, valor, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) { function updateRow({pago_id, valor, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
const tr = $("tr[data-pago='" + pago_id + "']") const tr = $("tr[data-pago='" + pago_id + "']")

View File

@ -86,7 +86,7 @@
@include('layout.body.scripts.dayjs') @include('layout.body.scripts.dayjs')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
function setDate(index, calendar, date = new Date()) { function setDate(index, calendar, date = new Date()) {
const d = dayjs(date) const d = dayjs(date)
$(calendar).calendar('set date', new Date(d.add(index, 'M').valueOf())) $(calendar).calendar('set date', new Date(d.add(index, 'M').valueOf()))

View File

@ -73,7 +73,7 @@
@endpush @endpush
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
class Unidad { class Unidad {
id id
nombre nombre

View File

@ -71,7 +71,7 @@
@endsection @endsection
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
const propiedad = { const propiedad = {
unidades: [ unidades: [
@foreach($propiedad->unidades as $unidad) @foreach($propiedad->unidades as $unidad)

View File

@ -27,13 +27,13 @@ Editar Propietario
</div> </div>
<div class="field"> <div class="field">
<label for="apellido_materno">Apellido Materno</label> <label for="apellido_materno">Apellido Materno</label>
<input type="text" id="apellido_materno" name="apellido_materno" value="{{$propietario->apellidos['materno']}}" /> <input type="text" id="apellido_materno" name="apellido_materno" value="{{$propietario->apellidos['materno'] ?? ''}}" />
</div> </div>
</div> </div>
<div class="fields"> <div class="fields">
<div class="field"> <div class="field">
<label for="calle">Dirección</label> <label for="calle">Dirección</label>
<input type="text" name="calle" id="calle" value="{{$propietario->datos->direccion->calle}}" /> <input type="text" name="calle" id="calle" value="{'{$propietario->datos->direccion->calle}}" />
</div> </div>
<div class="field"> <div class="field">
<label for="numero">Número</label> <label for="numero">Número</label>
@ -58,16 +58,28 @@ Editar Propietario
<select class="ui search selection dropdown" name="comuna" id="comunas"></select> <select class="ui search selection dropdown" name="comuna" id="comunas"></select>
</div> </div>
</div> </div>
<button class="ui button" id="guardar_button">Guardar</button> <div class="fields">
<div class="four wide field">
<label>Email</label>
<input type="email" name="email" value="{{$propietario->datos?->email}}" />
</div>
<div class="field">
<label>Teléfono</label>
<input type="text" name="telefono" value="{{$propietario->datos?->telefono}}" />
</div>
</div>
<button type="button" class="ui button" id="guardar_button">Guardar</button>
</form> </form>
</div> </div>
@endsection @endsection
@include('layout.body.scripts.rut')
@push('page_scripts') @push('page_scripts')
<script type="text/javascript"> <script>
class Propietario { class Propietario {
props props
constructor({rut, digito, nombres, apellidos: {paterno, materno}, direccion: {calle, numero, extra, comuna, region}}) { constructor({rut, digito, nombres, apellidos: {paterno, materno}, direccion: {calle, numero, extra, comuna, region}, email, telefono}) {
this.props = { this.props = {
rut, rut,
digito, digito,
@ -83,6 +95,8 @@ Editar Propietario
comuna, comuna,
region region
}, },
email,
telefono
} }
} }
@ -90,7 +104,7 @@ Editar Propietario
return { return {
rut: rut => { rut: rut => {
this.props.rut = rut this.props.rut = rut
this.update().digito(Rut.digito(this.props.rut)) this.update().digito(Rut.digitoVerificador(this.props.rut))
}, },
digito: digito => { digito: digito => {
this.props.digito = digito this.props.digito = digito
@ -126,6 +140,12 @@ Editar Propietario
this.props.direccion.region = region this.props.direccion.region = region
} }
} }
},
email: email => {
this.props.email = email
},
telefono: telefono => {
this.props.telefono = telefono
} }
} }
} }
@ -136,14 +156,16 @@ Editar Propietario
nombres: '{{trim($propietario->nombres)}}', nombres: '{{trim($propietario->nombres)}}',
apellidos: { apellidos: {
paterno: '{{trim($propietario->apellidos['paterno'])}}', paterno: '{{trim($propietario->apellidos['paterno'])}}',
materno: '{{trim($propietario->apellidos['materno'])}}' materno: '{{trim($propietario->apellidos['materno'] ?? '')}}'
}, },
direccion: { direccion: {
calle: '{{trim($propietario->datos->direccion->calle)}}', calle: '{{trim($propietario->datos->direccion->calle)}}',
numero: '{{$propietario->datos->direccion->numero}}', numero: '{{$propietario->datos->direccion->numero}}',
extra: '{{trim($propietario->datos->direccion->extra)}}', extra: '{{trim($propietario->datos->direccion->extra)}}',
comuna: '{{$propietario->datos->direccion->comuna->id}}' comuna: '{{$propietario->datos->direccion->comuna->id}}'
} },
email: '{{trim($propietario->datos?->email)}}',
telefono: '{{trim($propietario->datos?->telefono)}}'
} }
const data = {} const data = {}
const collator = new Intl.Collator('es') const collator = new Intl.Collator('es')
@ -187,7 +209,7 @@ Editar Propietario
return return
} }
if ('rut' in data) { if ('rut' in data) {
data['dv'] = Rut.digito(data['rut']) data['dv'] = Rut.digitoVerificador(data['rut'])
} }
return fetchAPI(uri, return fetchAPI(uri,
{method: 'put', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)} {method: 'put', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data)}
@ -297,6 +319,16 @@ Editar Propietario
propietario.props.data.update().direccion().comuna(comuna_id) propietario.props.data.update().direccion().comuna(comuna_id)
}) })
} }
static email() {
$("[name='email']").change(event => {
propietario.props.data.update().email(event.currentTarget.value)
})
}
static telefono() {
$("[name='telefono']").change(event => {
propietario.props.data.update().telefono($(event.currentTarget).val())
})
}
static run() { static run() {
Watcher.rut() Watcher.rut()
@ -305,6 +337,8 @@ Editar Propietario
Watcher.direccion() Watcher.direccion()
Watcher.region() Watcher.region()
Watcher.comuna() Watcher.comuna()
Watcher.email()
Watcher.telefono()
} }
} }
class EventHandler { class EventHandler {
@ -360,22 +394,7 @@ Editar Propietario
} }
} }
} }
class Rut {
static format(rut) {
return Intl.NumberFormat('es-CL', {maximumFractionDigits: 0}).format(rut)
}
static digito(rut) {
const cleanRut = rut.replace(/\D/g, ''); // Removes non-digit characters more efficiently
let sum = 0;
const factors = [2, 3, 4, 5, 6, 7, 2, 3, 4, 5];
for (let i = 0; i < cleanRut.length; i++) {
const digit = parseInt(cleanRut[cleanRut.length - 1 - i], 10);
sum += digit * factors[i % factors.length];
}
const dv = 11 - (sum % 11);
return dv === 10 ? 'K' : dv === 11 ? '0' : dv.toString();
}
}
const propietario = { const propietario = {
props: { props: {
ids: {}, ids: {},
@ -394,6 +413,8 @@ Editar Propietario
$("[name='numero']").val(this.props.data.props.direccion.numero) $("[name='numero']").val(this.props.data.props.direccion.numero)
$("[name='extra']").val(this.props.data.props.direccion.extra) $("[name='extra']").val(this.props.data.props.direccion.extra)
$('#region').val(this.props.data.props.direccion.region) $('#region').val(this.props.data.props.direccion.region)
$("[name='email']").val(this.props.data.props.email)
$("[name='telefono']").val(this.props.data.props.telefono)
this.update().region() this.update().region()
}, },
region: () => { region: () => {
@ -435,6 +456,8 @@ Editar Propietario
this.props.data.update().direccion().extra(data.propietario.direccion.extra) this.props.data.update().direccion().extra(data.propietario.direccion.extra)
this.props.data.update().direccion().comuna(data.propietario.direccion.comuna.id) this.props.data.update().direccion().comuna(data.propietario.direccion.comuna.id)
this.props.data.update().direccion().region(data.propietario.direccion.comuna.provincia.region.id) this.props.data.update().direccion().region(data.propietario.direccion.comuna.provincia.region.id)
this.props.data.update().email(data.propietario.email)
this.props.data.update().telefono(data.propietario.telefono)
this.update().propietario() this.update().propietario()
}) })
}) })
@ -489,6 +512,8 @@ Editar Propietario
$("[name='calle']").val('') $("[name='calle']").val('')
$("[name='numero']").val('') $("[name='numero']").val('')
$("[name='extra']").val('') $("[name='extra']").val('')
$("[name='email']").val('')
$("[name='telefono']").val('')
} }
} }
}, },
@ -511,7 +536,8 @@ Editar Propietario
}) })
this.update().region() this.update().region()
$(this.props.ids.forms.edit).submit(Form.submit) document.getElementById(this.props.ids.forms.edit.replace('#', '')).addEventListener('submit', Form.submit)
document.getElementById(this.props.ids.buttons.guardar.replace('#', '')).addEventListener('click', Form.submit)
Watcher.run() Watcher.run()
} }
} }
@ -534,7 +560,7 @@ Editar Propietario
nombres: '{{$propietario->nombres}}', nombres: '{{$propietario->nombres}}',
apellidos: { apellidos: {
paterno: '{{$propietario->apellidos['paterno']}}', paterno: '{{$propietario->apellidos['paterno']}}',
materno: '{{$propietario->apellidos['materno']}}' materno: '{{$propietario->apellidos['materno'] ?? ''}}'
}, },
direccion: { direccion: {
calle: '{{$propietario->datos->direccion->calle}}', calle: '{{$propietario->datos->direccion->calle}}',
@ -542,7 +568,9 @@ Editar Propietario
extra: '{{$propietario->datos->direccion->extra}}', extra: '{{$propietario->datos->direccion->extra}}',
comuna: '{{$propietario->datos->direccion->comuna->id}}', comuna: '{{$propietario->datos->direccion->comuna->id}}',
region: '{{$propietario->datos->direccion->comuna->provincia->region->id}}', region: '{{$propietario->datos->direccion->comuna->provincia->region->id}}',
} },
email: '{{$propietario->datos?->email}}',
telefono: '{{$propietario->datos?->telefono}}'
}) })
}) })
}) })

View File

@ -0,0 +1,554 @@
@extends('layout.base')
@section('page_title')
Cierres -Reservas
@endsection
@section('page_content')
<div class="ui container">
<h2 class="ui header">Cierres - Reservas</h2>
<div class="ui compact segment" id="projects">
<div class="ui header">Proyectos</div>
@if (count($projects) == 0)
<div class="ui message">
No hay proyectos en venta.
</div>
@else
<div class="ui link list">
@foreach ($projects as $project)
<div class="item link" data-id="{{ $project->id }}">
{{ $project->descripcion }}
</div>
@endforeach
</div>
@endif
</div>
<div class="ui two column grid">
<div class="column">
<h3 class="ui header" id="project"></h3>
</div>
<div class="column">
<div class="ui active inline loader" id="loader"></div>
</div>
</div>
<div id="results">
<div class="ui right aligned top attached basic segment" id="controls">
<div class="ui tiny icon buttons">
<button class="ui button" id="up_button">
<i class="up arrow icon"></i>
</button>
<button class="ui button" id="refresh_button">
<i class="refresh icon"></i>
</button>
<button class="ui green icon button" id="add_button">
<i class="plus icon"></i>
</button>
</div>
</div>
<div class="ui top attached tabular menu" id="tabs">
<div class="yellow active item" data-tab="pending">Pendientes</div>
<div class="green item" data-tab="active">Activas</div>
<div class="red item" data-tab="rejected">Rechazadas</div>
</div>
<div class="ui bottom attached tab fitted segment active" data-tab="pending">
<table class="ui yellow striped table" id="pending_reservations">
<thead>
<tr>
<th>Unidades</th>
<th>Cliente</th>
<th>Fecha</th>
<th>Oferta</th>
<th>¿Valida?</th>
<th>Operador</th>
<th></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="ui bottom attached tab fitted segment" data-tab="active">
<table class="ui green striped table" id="active_reservations">
<thead>
<tr>
<th>Unidades</th>
<th>Cliente</th>
<th>Fecha</th>
<th>Oferta</th>
<th>Operador</th>
<th></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="ui bottom attached tab fitted segment" data-tab="rejected">
<table class="ui red striped table" id="rejected_reservations">
<thead>
<tr>
<th>Unidades</th>
<th>Cliente</th>
<th>Fecha</th>
<th>Oferta</th>
<th>Estado</th>
<th>Operador</th>
<th>Comentarios</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
@include('ventas.reservations.add_modal')
@endsection
@push('page_styles')
<style>
.item.link {
cursor: pointer;
text-decoration: underline;
}
</style>
@endpush
@push('page_scripts')
<script>
class Projects {
display = {
projects: '',
project: ''
}
component_id = ''
component = null
current_project = null;
title_id = ''
title_component = null
constructor({component_id, title_id}) {
this.component_id = component_id
this.component = document.getElementById(this.component_id)
this.display.projects = this.component.style.display
this.title_id = title_id
this.title_component = document.getElementById(this.title_id)
this.display.project = this.title_component.style.display
this.show()
this.watch()
}
select(event) {
event.preventDefault()
const project_id = event.currentTarget.dataset.id
reservations.show.results()
if (project_id === this.current_project) {
this.hide()
this.title_component.innerHTML = event.currentTarget.innerHTML
reservations.action.reservations()
return
}
this.current_project = project_id
reservations.get.reservations(project_id)
reservations.components.modals.add.load(project_id)
this.hide()
this.title_component.innerHTML = event.currentTarget.innerHTML
}
watch() {
this.component.querySelectorAll('.item.link').forEach(item => {
item.addEventListener('click', this.select.bind(this))
})
}
show() {
this.component.style.display = this.display.projects
this.title_component.style.display = 'none'
}
hide() {
this.component.style.display = 'none'
this.title_component.style.display = this.display.project
}
}
class Controls {
display = {
up: '',
reset: '',
}
component_id = ''
component = null
buttons = {
up: null,
reset: null,
add: null
}
constructor({component_id}) {
this.component_id = component_id
this.component = document.getElementById(this.component_id)
const buttons = this.component.querySelectorAll('button')
this.buttons.up = buttons[0]
this.buttons.reset = buttons[1]
this.buttons.add = buttons[2]
this.display.up = buttons[0].style.display
this.display.reset = buttons[1].style.display
this.watch()
this.hide()
}
watch() {
Object.entries(this.buttons).forEach(([key, value]) => {
const name = key.replace('_button', '')
value.addEventListener('click', this.action[name].bind(this))
})
}
hide() {
this.buttons.up.style.display = this.display.up
this.buttons.reset.style.display = this.display.reset
}
show() {
this.buttons.up.style.display = 'none'
this.buttons.reset.style.display = 'none'
}
action = {
reset: event => {
event.preventDefault()
reservations.action.reset(event)
return false
},
up: event => {
event.preventDefault()
reservations.action.up(event)
return false
},
add: event => {
event.preventDefault()
reservations.action.add(event)
return false
}
}
}
class Reservations {
display = {
reservations: '',
}
component_id = ''
component = null
formatters = {
date: null,
ufs: null
}
columnNames = []
reservations = []
constructor({component_id, formatters = {date, ufs}}) {
this.component_id = component_id
this.component = document.getElementById(this.component_id)
this.display.reservations = this.component.style.display
this.formatters = formatters
this.set().columnNames()
this.hide()
}
set() {
return {
reservations: reservations => {
this.reservations = reservations
return this
},
columnNames: () => {
const tds = this.component.querySelector('thead tr').querySelectorAll('th')
this.columnNames = []
tds.forEach(td => {
let name = td.innerHTML.toLowerCase()
if (name === '') {
return
}
if (name.includes('?')) {
name = name.replaceAll(/[¿?]/g, '')
}
this.columnNames.push(name)
})
return this
}
}
}
columnsData() {
return this.reservations.map(reservation => {
const date = new Date(Date.parse(reservation.fecha) + 24 * 60 * 60 * 1000)
return {
id: reservation.id,
unidades: reservation.summary,
cliente: reservation.buyer.nombreCompleto,
fecha: this.formatters.date.format(date),
oferta: `${this.formatters.ufs.format(reservation.offer)} UF`,
valida: reservation.valid ? '<span class="ui green text">Si</span>' : '<span class="ui red text">No</span>',
operador: reservation.broker?.name ?? '',
}
})
}
draw() {
const tbody = this.component.querySelector('tbody')
tbody.innerHTML = ''
this.columnsData().forEach(column => {
const tr = document.createElement('tr')
const contents = []
const id = column.id
this.columnNames.forEach(name => {
contents.push(`<td>${column[name]}</td>`)
})
const actions = this.drawActions(id)
if (actions !== '') {
contents.push(actions)
}
tr.innerHTML = contents.join("\n")
tbody.appendChild(tr)
})
this.show()
}
drawActions(id) {
return `
<td class="right aligned">
<button class="ui green mini icon button approve" data-id="${id}" title="Aprobar">
<i class="check icon"></i>
</button>
<button class="ui red mini icon button reject" data-id="${id}" title="Rechazar">
<i class="trash icon"></i>
</button>
</td>`
}
empty() {
const tbody = this.component.querySelector('tbody')
tbody.innerHTML = ''
const col_span = this.columnNames.length + 1
const tr = document.createElement('tr')
tr.innerHTML = `<td colspan="${col_span}">No hay cierres</td>`
tbody.appendChild(tr)
this.show()
}
show() {
this.component.style.display = this.display.reservations
}
hide() {
this.component.style.display = 'none'
}
}
class ActiveReservations extends Reservations {
constructor({component_id, formatters = {date, ufs}}) {
super({component_id, formatters})
}
columnsData() {
const data = super.columnsData();
return data.map(row => {
delete(row['valida'])
return row
})
}
drawActions(id) {
return `
<td class="right aligned">
<button class="ui green mini icon button edit" data-id="${id}" title="Promesar">
<i class="right chevron icon"></i>
</button>
<button class="ui red mini icon button remove" data-id="${id}" title="Abandonar">
<i class="trash icon"></i>
</button>
</td>`
}
}
class PendingReservations extends Reservations {
constructor({component_id, formatters = {date, ufs}}) {
super({component_id, formatters})
}
}
class RejectedReservations extends Reservations {
constructor({component_id, formatters = {date, ufs}}) {
super({component_id, formatters})
}
columnsData() {
const data = super.columnsData()
return this.reservations.map((reservation, idx) => {
data[idx]['estado'] = reservation.state.charAt(0).toUpperCase() + reservation.state.slice(1)
data[idx]['comentarios'] = reservation.comments?.join('<br />\n') ?? ''
return data[idx]
})
}
drawActions(id) {
return ''
}
}
const reservations = {
components: {
projects: null,
loader: null,
results: null,
controls: null,
reservations: {
active: null,
pending: null,
rejected: null
},
modals: {
add: null
}
},
display: {
loader: '',
results: '',
},
get: {
send: (project_id, url_segment, component) => {
const url = `/api/ventas/reservations/project/${project_id}/${url_segment}`
return APIClient.fetch(url).then(response => response.json()).then(json => {
if (json.reservations.length === 0) {
component.empty()
return
}
component.set().reservations(json.reservations).draw()
})
},
active: project_id => {
return reservations.get.send(project_id, 'active', reservations.components.reservations.active)
/*const url = `/ventas/reservations/project/${project_id}/active`
return APIClient.fetch(url).then(json => {
if (json.reservations.length === 0) {
return
}
this.components.reservations.active.set().reservations(json.reservations).draw()
})*/
},
pending: project_id => {
return reservations.get.send(project_id, 'pending', reservations.components.reservations.pending)
/*const url = `/ventas/reservations/project/${project_id}/pending`
return APIClient.fetch(url).then(json => {
if (json.reservations.length === 0) {
return
}
this.components.reservations.pending.set().reservations(json.reservations).draw()
})*/
},
rejected: project_id => {
return reservations.get.send(project_id, 'rejected', reservations.components.reservations.rejected)
/*const url = `/ventas/reservations/project/${project_id}/rejected`
return APIClient.fetch(url).then(json => {
if (json.reservations.length === 0) {
return
}
this.components.reservations.rejected.set().reservations(json.reservations).draw()
})*/
},
reservations: project_id => {
reservations.loading.show()
const promises = []
promises.push(reservations.get.active(project_id))
promises.push(reservations.get.pending(project_id))
promises.push(reservations.get.rejected(project_id))
return Promise.any(promises).then(() => {
reservations.loading.hide()
})
}
},
loading: {
show: () => {
reservations.components.loader.style.display = reservations.display.loader
},
hide: () => {
reservations.components.loader.style.display = 'none'
}
},
action: {
reset: event => {
event.preventDefault()
reservations.components.projects.current_project = null
Object.entries(reservations.components.reservations).forEach(([key, value]) => {
reservations.components.reservations[key].reservations = []
reservations.components.reservations[key].hide()
})
reservations.show.projects()
return false
},
up: event => {
event.preventDefault()
Object.values(reservations.components.reservations).forEach(reservations => reservations.hide())
reservations.show.projects()
return false
},
add: event => {
event.preventDefault()
reservations.components.modals.add.show()
return false
},
reservations: () => {
Object.values(reservations.components.reservations).forEach(reservations => {
reservations.draw()
})
}
},
show: {
projects: () => {
reservations.components.projects.show()
reservations.components.results.style.display = 'none'
},
results: () => {
reservations.components.projects.hide()
reservations.components.results.style.display = reservations.display.results
}
},
setup(configuration) {
const formatters = {
date: new Intl.DateTimeFormat('es-CL', {year: 'numeric', month: 'long', day: 'numeric'}),
ufs: new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
}
this.components.loader = document.getElementById(configuration.ids.loader)
this.components.projects = new Projects({component_id: configuration.ids.projects, title_id: configuration.ids.project})
this.components.controls = new Controls({component_id: configuration.ids.controls})
this.components.reservations.active = new ActiveReservations({component_id: configuration.ids.active, formatters})
this.components.reservations.pending = new PendingReservations({component_id: configuration.ids.pending, formatters})
this.components.reservations.rejected = new RejectedReservations({component_id: configuration.ids.rejected, formatters})
this.display.loader = this.components.loader.style.display
this.loading.hide()
$(`#${configuration.ids.tabs} .item`).tab()
this.components.results = document.getElementById(configuration.ids.results)
this.display.results = this.components.results.style.display
this.show.projects()
this.components.modals.add = new AddReservationModal()
}
}
$(document).ready(() => {
reservations.setup({
ids: {
projects: 'projects',
project: 'project',
results: 'results',
loader: 'loader',
controls: 'controls',
tabs: 'tabs',
active: 'active_reservations',
pending: 'pending_reservations',
rejected: 'rejected_reservations',
}
})
})
</script>
@endpush

View File

@ -0,0 +1,733 @@
<div class="ui modal" id="add_reservation_modal">
<div class="header">
Agregar Cierre
</div>
<div class="content">
<form class="ui form" id="add_reservation_form">
<input type="hidden" name="project_id" />
<div class="three wide required field">
<label>Fecha</label>
<div class="ui calendar" id="add_date">
<div class="ui icon input">
<i class="calendar icon"></i>
<input type="text" name="date" />
</div>
</div>
</div>
<div class="fields">
<div class="three wide required field">
<label>RUT</label>
<div class="ui right labeled input" id="add_rut">
<input type="text" name="rut" placeholder="RUT" />
<div class="ui basic label">-<span id="add_digit"></span></div>
</div>
</div>
<div class="field">
<label></label>
<div class="ui inline loader" id="add_rut_loader"></div>
</div>
</div>
<div class="fields">
<div class="three wide required field">
<label>Nombre</label>
<input type="text" name="name" placeholder="Nombre" />
</div>
<div class="six wide required field">
<label>Apellidos</label>
<input type="text" name="last_name" placeholder="Apellido Paterno" />
</div>
<div class="six wide field">
<label></label>
<input type="text" name="last_name2" placeholder="Apellido Materno" />
</div>
</div>
<div class="fields">
<div class="three wide field">
<label>Dirección</label>
<input type="text" name="calle" placeholder="Calle" />
</div>
<div class="field">
<label></label>
<input type="text" name="numero" placeholder="" />
</div>
<div class="three wide field">
<label></label>
<input type="text" name="extra" placeholder="Otros Detalles" />
</div>
</div>
<div class="fields">
<div class="three wide field">
<label>Comuna</label>
<div class="ui search selection dropdown" id="add_comuna">
<input type="hidden" name="comuna" />
<i class="dropdown icon"></i>
<div class="default text">Comuna</div>
<div class="menu"></div>
</div>
</div>
<div class="seven wide field">
<label>Región</label>
<div class="ui search selection dropdown" id="add_region">
<input type="hidden" name="region" />
<i class="dropdown icon"></i>
<div class="default text">Región</div>
<div class="menu">
@foreach($regions as $region)
<div class="item" data-value="{{$region->id}}">{{$region->numeral}} - {{$region->descripcion}}</div>
@endforeach
</div>
</div>
</div>
</div>
<div class="fields">
<div class="field">
<label>Telefono</label>
<input type="text" name="phone" placeholder="Telefono" />
</div>
<div class="field">
<label>Correo</label>
<div class="ui labeled input">
<input type="text" name="email_name" placeholder="Correo" />
<div class="ui basic label">@</div>
<input type="text" name="email_domain" placeholder="Dominio" />
</div>
</div>
</div>
<div class="fields">
<div class="field">
<label>Estado Civil</label>
<input type="text" name="civil_status" placeholder="Estado Civil" />
</div>
<div class="field">
<label>Profesión</label>
<input type="text" name="profession" placeholder="Profesión" />
</div>
<div class="field">
<label>Fecha de Nacimiento</label>
<div class="ui calendar" id="add_birthdate">
<div class="ui icon input">
<i class="calendar icon"></i>
<input type="text" name="birthdate" />
</div>
</div>
</div>
</div>
<div class="six wide field">
<label>Operador *</label>
<div class="ui clearable search selection dropdown" id="add_broker">
<input type="hidden" name="broker" />
<i class="dropdown icon"></i>
<div class="default text">Operador</div>
<div class="menu"></div>
</div>
</div>
<div class="field">
<label>Agregar Promoción</label>
<button type="button" class="ui icon button" id="add_promotion">
<i class="plus icon"></i>
</button>
</div>
<div id="add_promotions"></div>
<h4 class="ui dividing header">Unidades</h4>
<div class="fields" id="add_unit_buttons"></div>
<div id="add_units"></div>
</form>
</div>
<div class="actions">
<div class="ui cancel button">
Cancelar
</div>
<div class="ui green ok button">
Agregar
</div>
</div>
</div>
@include('layout.body.scripts.rut')
@push('page_scripts')
<script>
class AddModalPromotions {
ids = {
button: '',
elements: ''
}
data = {
promotions: []
}
components = {
button: null,
promotions: null,
}
display = {
button: ''
}
constructor() {
this.ids = {
button: 'add_promotion',
elements: 'add_promotions'
}
this.setup()
}
add() {
const idx = Math.max(this.data.promotions.length, 0, Math.max(...this.data.promotions) + 1)
this.data.promotions.push(idx)
this.draw.promotions()
}
reset() {
this.data.promotions = []
this.draw.promotions()
}
remove(idx) {
this.data.promotions = this.data.promotions.filter(promotion => promotion !== idx)
this.draw.promotions()
}
draw = {
promotion: idx => {
const promotions = this.data.promotions.map(promotion => {
return `<div class="item" data-value="${promotion.id}">${promotion.name}</div>`
})
return [
`<div class="fields promotion" data-id="${idx}">`,
'<div class="three wide field">',
'<label>Promoción</label>',
`<div class="ui search selection dropdown">`,
'<input type="hidden" name="promotions[]" />',
'<i class="dropdown icon"></i>',
'<div class="default text">Promoción</div>',
`<div class="menu">${promotions.join('')}</div>`,
'</div>',
'</div>',
'<div class="two wide field">',
'<label></label>',
`<button class="ui red tiny icon button remove_promotion" type="button" data-id="${idx}"><i class="trash icon"></i></button>`,
'</div>',
'</div>'
].join('')
},
promotions: () => {
if (this.data.promotions.length === 0) {
this.components.button.parentElement.style.display = 'none'
this.components.promotions.innerHTML = ''
return
}
this.components.button.parentElement.style.display = this.display.button
this.components.promotions.innerHTML = this.data.promotions.map((promotion, idx) => {
return this.draw.promotion(idx)
}).join('')
this.components.promotions.querySelectorAll('.dropdown').forEach(dropdown => {
$(dropdown).dropdown()
})
this.components.promotions.querySelectorAll('.remove_promotion').forEach(button => {
button.addEventListener('click', () => {
const idx = Number(button.dataset.id)
this.remove(idx)
})
})
}
}
setup() {
this.components.button = document.getElementById(this.ids.button)
this.components.promotions = document.getElementById(this.ids.elements)
this.components.button.addEventListener('click', () => {
this.add()
})
this.display.button = this.components.button.parentElement.style.display
this.draw.promotions()
}
}
class AddModalUnits {
ids = {
buttons_holder: '',
units: ''
}
data = {
button_map: {},
types: {},
units: [],
}
components = {
buttons_holder: null,
units: null,
}
constructor() {
this.ids = {
buttons_holder: 'add_unit_buttons',
units: 'add_units'
}
this.data.button_map = {
'departamento': 'building',
'estacionamiento': 'car',
'bodega': 'warehouse',
'terraza': 'vector square'
}
this.setup()
}
draw = {
button: type => {
return [
'<div class="field">',
`<button class="ui icon button" type="button" data-type="${type}" title="${type.charAt(0).toUpperCase() + type.slice(1)}">`,
'<i class="plus icon"></i>',
`<i class="${this.data.button_map[type]} icon"></i>`,
'</button>',
'</div>'
].join('')
},
buttons: () => {
this.components.buttons_holder.innerHTML = Object.keys(this.data.types).map(type => {
return this.draw.button(type)
}).join('')
this.components.buttons_holder.querySelectorAll('.button').forEach(button => {
button.addEventListener('click', () => {
const type = button.dataset.type
this.add(type)
})
})
},
units: () => {
if (this.data.units.length === 0) {
this.components.units.innerHTML = ''
return
}
this.components.units.innerHTML = this.data.units.map(unit => {
return [
'<div class="fields">',
'<div class="four wide field">',
`<label>${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</label>`,
`<div class="ui search selection dropdown">`,
'<input type="hidden" name="units[]" />',
'<i class="dropdown icon"></i>',
`<div class="default text">${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</div>`,
'<div class="menu">',
this.data.types[unit.type].map(unit => {
return `<div class="item" data-value="${unit.value}">${unit.name}</div>`
}).join(''),
'</div>',
'</div>',
'</div>',
'<div class="field">',
'<label></label>',
`<button class="ui red tiny icon button remove_unit" type="button" data-id="${unit.idx}"><i class="trash icon"></i></button>`,
'</div>',
'</div>',
].join('')
}).join('')
this.components.units.querySelectorAll('.dropdown').forEach(dropdown => {
$(dropdown).dropdown()
})
this.components.units.querySelectorAll('.remove_unit').forEach(button => {
button.addEventListener('click', () => {
const idx = Number(button.dataset.id)
this.remove(idx)
})
})
}
}
reset() {
this.data.units = []
this.draw.units()
}
add(type) {
const idx = Math.max(this.data.units.length, 0, Math.max(...this.data.units.map(unit => unit.idx)) + 1)
this.data.units.push({idx, type})
this.draw.units()
}
remove(idx) {
this.data.units = this.data.units.filter(unit => unit.idx !== idx)
this.draw.units()
}
setup() {
this.components.buttons_holder = document.getElementById(this.ids.buttons_holder)
this.components.units = document.getElementById(this.ids.units)
this.draw.buttons()
}
}
class AddReservationModal {
ids = {
modal: '',
form: '',
date: '',
rut: '',
digit: '',
birthdate: '',
comuna: '',
region: '',
broker: '',
promotion_button: '',
promotions: '',
unit_buttons: '',
units: ''
}
components = {
$modal: null,
form: null,
$date: null,
$rut: null,
rut: null,
digit: null,
$birthdate: null,
$comuna: null,
$region: null,
$broker: null,
promotion_button: null,
promotions: null,
unit_buttons: null,
units: null,
$loader: null
}
data = {
current_project: null,
comunas: {},
brokers: {},
promotions: {},
unit_buttons: [],
units: {},
added_units: {},
current_user: null
}
maps = {
unit_types: {
departamento: 'building',
estacionamiento: 'car',
bodega: 'warehouse',
terraza: 'tree',
}
}
constructor() {
this.ids = {
modal: 'add_reservation_modal',
form: 'add_reservation_form',
date: 'add_date',
rut: 'add_rut',
digit: 'add_digit',
birthdate: 'add_birthdate',
comuna: 'add_comuna',
region: 'add_region',
broker: 'add_broker',
promotion_button: 'add_promotion',
promotions: 'add_promotions',
unit_buttons: 'add_unit_buttons',
units: 'add_units',
loader: 'add_rut_loader'
}
this.setup()
}
load(project_id) {
this.reset()
this.data.current_project = project_id
this.components.form.querySelector('input[name="project_id"]').value = project_id
this.get.brokers(project_id)
this.get.promotions(project_id).then(promotions => {
this.components.promotions.data.promotions = promotions
this.components.promotions.draw.promotions()
})
this.get.units(project_id).then(units => {
this.components.units.data.types = units
this.components.units.draw.buttons()
})
}
reset() {
this.components.form.reset()
this.components.promotions.reset()
this.components.units.reset()
}
add() {
const url = '/api/ventas/reservations/add'
const form = document.getElementById(this.ids.form)
const body = new FormData(form)
const date = this.components.$date.calendar('get date')
console.debug(date)
body.set('date', [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-'))
body.set('comuna', this.components.$comuna.dropdown('get value'))
body.set('region', this.components.$region.dropdown('get value'))
body.set('broker_rut', this.components.$broker.dropdown('get value'))
/*body.set('promotions[]', '')
this.components.promotions.forEach(promotion => {
body.append('promotions[]', promotion.querySelector('promotion').value)
})*/
/*body.set('units[]', '')
this.components.units.forEach(unit => {
body.append('units[]', unit.querySelector('unit').value)
})*/
const method = 'post'
return APIClient.fetch(url, {method, body}).then(response => response.json()).then(json => {
if (json.success) {
window.location.reload()
}
})
}
get = {
comunas: region_id => {
if (region_id in this.data.comunas) {
this.components.$comuna.dropdown('change values', this.data.comunas[region_id])
if (this.data.current_user !== null && this.data.current_user?.direccion?.comuna !== null) {
this.components.$comuna.dropdown('set selected', this.data.current_user.direccion.comuna.id)
}
return
}
const uri = `/api/region/${region_id}/comunas`
return APIClient.fetch(uri).then(response => response.json()).then(json => {
if (json.comunas.length === 0) {
return
}
this.data.comunas[region_id] = json.comunas.map(comuna => {
return {
text: comuna.descripcion,
name: comuna.descripcion,
value: comuna.id
}
})
this.components.$comuna.dropdown('change values', this.data.comunas[region_id])
if (this.data.current_user !== null && this.data.current_user?.direccion?.comuna !== null) {
this.components.$comuna.dropdown('set selected', this.data.current_user.direccion.comuna.id)
}
})
},
brokers: project_id => {
if (project_id in this.data.brokers) {
return new Promise((resolve, reject) => {
resolve(this.data.brokers[project_id])
})
}
const uri = `/api/proyecto/${project_id}/brokers`
return APIClient.fetch(uri).then(response => response.json()).then(json => {
if (json.contracts.length === 0) {
return
}
const formatter = new Intl.NumberFormat('es-CL', { style: 'percent', minimumFractionDigits: 2 })
this.data.brokers[project_id] = json.contracts.map(contract => {
return {
id: contract.id,
broker_rut: contract.broker_rut,
commission: formatter.format(contract.commission),
name: '',
text: '',
}
})
const promises = []
json.contracts.forEach(contract => {
promises.push(this.get.broker(contract.broker_rut))
})
return Promise.all(promises).then(data => {
data.forEach(broker => {
if (!('rut' in broker)) {
return
}
const idx = this.data.brokers[project_id].findIndex(contract => contract.broker_rut === broker.rut)
this.data.brokers[project_id][idx].name = this.data.brokers[project_id][idx].text = `${broker.name} - ${this.data.brokers[project_id][idx].commission}`
})
this.fill.brokers()
})
})
},
broker: (broker_rut) => {
const uri = `/api/proyectos/broker/${broker_rut}`
return APIClient.fetch(uri).then(response => response.json()).then(json => {
if (!('broker' in json)) {
return []
}
return json.broker
})
},
promotions: project_id => {
if (project_id in this.data.promotions) {
return new Promise((resolve, reject) => {
resolve(this.data.promotions[project_id])
})
}
const uri = `/api/proyecto/${project_id}/promotions`
return APIClient.fetch(uri).then(response => response.json()).then(json => {
if (json.promotions.length === 0) {
return this.data.promotions[project_id] = []
}
return this.data.promotions[project_id] = json.promotions.map(promotion => {
return {
text: promotion.name,
name: promotion.name,
value: promotion.id
}
})
})
},
units: project_id => {
if (project_id in this.data.units) {
return new Promise((resolve, reject) => {
resolve(this.data.units[project_id])
})
}
const uri = `/api/proyecto/${project_id}/unidades`
return APIClient.fetch(uri).then(response => response.json()).then(json => {
if (json.total === 0) {
this.data.units[project_id] = {}
return this.data.units[project_id]
}
if (!(project_id in this.data.units)) {
this.data.units[project_id] = {}
}
Object.entries(json.unidades).forEach(([type, units]) => {
if (!(type in this.data.units[project_id])) {
this.data.units[project_id][type] = []
}
units.forEach(unit => {
this.data.units[project_id][type].push({
text: unit.descripcion,
name: unit.descripcion,
value: unit.id
})
})
})
return this.data.units[project_id]
})
},
user: rut => {
if (this.data.current_user !== null && this.data.current_user?.rut === rut) {
return this.data.current_user
}
this.loader.show()
const uri = `/api/persona/${rut}`
return APIClient.fetch(uri).then(response => response.json()).then(json => {
this.loader.hide()
if (!json.success) {
return
}
this.data.current_user = json.persona
return json.persona
})
}
}
fill = {
user: user => {
const form = this.components.form
form.querySelector('input[name="name"]').value = user.nombres || ''
form.querySelector('input[name="last_name"]').value = user.apellidoPaterno || ''
form.querySelector('input[name="last_name2"]').value = user.apellidoMaterno || ''
form.querySelector('input[name="calle"]').value = user.datos?.direccion?.calle || ''
form.querySelector('input[name="numero"]').value = user.datos?.direccion?.numero || ''
form.querySelector('input[name="extra"]').value = user.datos?.direccion?.extra || ''
if (parseInt(this.components.$region.dropdown('get value')) !== user.datos?.direccion?.comuna?.provincia?.region?.id) {
this.components.$region.dropdown('set selected', user.datos?.direccion?.comuna?.provincia?.region?.id)
} else {
this.components.$comuna.dropdown('set selected', user.datos?.direccion?.comuna?.id)
}
form.querySelector('input[name="phone"]').value = user.datos?.telefono
const email_parts = user.datos?.email.split('@')
form.querySelector('input[name="email_name"]').value = email_parts[0]
form.querySelector('input[name="email_domain"]').value = email_parts[1]
if ('estadoCivil' in user.datos) {
form.querySelector('input[name="civil_status"]').value = user.datos?.estadoCivil.charAt(0).toUpperCase() + user.datos?.estadoCivil.slice(1)
} else {
form.querySelector('input[name="civil_status"]').value = ''
}
if ('ocupacion' in user.datos) {
form.querySelector('input[name="profession"]').value = user.datos?.ocupacion
} else {
form.querySelector('input[name="profession"]').value = ''
}
if ('fechaNacimiento' in user.datos) {
this.components.$birthdate.calendar('set date', user.datos?.fechaNacimiento)
}
},
brokers: () => {
this.components.$broker.dropdown('change values', this.data.brokers[this.data.current_project])
},
units: () => {
const buttons = []
Object.entries(this.maps.unit_types).forEach(([type, map]) => {
if (!(type in this.data.units[this.data.current_project])) {
return
}
buttons.push(`<div class="field"><div class="ui icon button" data-type="${type}" title="${type.charAt(0).toUpperCase() + type.slice(1)}"><i class="plus icon"></i><i class="${map} icon"></i></div></div>`)
})
this.components.unit_buttons.innerHTML = buttons.join('')
this.components.unit_buttons.querySelectorAll('.ui.icon.button').forEach(button => {
button.addEventListener('click', () => {
this.units.add(button.dataset.type)
})
})
}
}
watch = {
region: (value, text, $choice) => {
this.get.comunas(value)
},
}
loader = {
show: () => {
this.components.$loader.show()
},
hide: () => {
this.components.$loader.hide()
}
}
show() {
this.reset()
this.components.$modal.modal('show')
}
setup() {
this.components.$modal = $(`#${this.ids.modal}`)
this.components.form = document.getElementById(this.ids.form)
this.components.$date = $(`#${this.ids.date}`)
this.components.rut = document.getElementById(this.ids.rut)
this.components.digit = document.getElementById(this.ids.digit)
this.components.$birthdate = $(`#${this.ids.birthdate}`)
this.components.$comuna = $(`#${this.ids.comuna}`)
this.components.$region = $(`#${this.ids.region}`)
this.components.$broker = $(`#${this.ids.broker}`)
this.components.promotions = new AddModalPromotions()
this.components.units = new AddModalUnits()
this.components.$modal.modal({
onApprove: () => {
this.add()
}
})
this.components.form.addEventListener('submit', event => {
event.preventDefault()
this.add()
return false
})
const cdo = structuredClone(calendar_date_options)
cdo['startDate'] = new Date()
cdo['maxDate'] = new Date()
this.components.$date.calendar(cdo)
const rutInput = this.components.rut.querySelector('input')
rutInput.addEventListener('input', event => {
const value = event.currentTarget.value.replace(/\D/g, '')
if (value.length <= 3) {
return
}
this.components.digit.textContent = Rut.digitoVerificador(value)
})
rutInput.addEventListener('blur', event => {
const value = event.currentTarget.value.replace(/\D/g, '')
if (value.length <= 3) {
return
}
event.currentTarget.value = Rut.format(value)
this.get.user(value).then(user => {
this.fill.user(user)
})
})
const cdo2 = structuredClone(cdo)
cdo2['startDate'].setFullYear(cdo2['startDate'].getFullYear() - 18)
cdo2['maxDate'].setFullYear(cdo2['maxDate'].getFullYear() - 18)
this.components.$birthdate.calendar(cdo2)
this.components.$region.dropdown({
fireOnInit: true,
onChange: this.watch.region
})
this.components.$region.dropdown('set selected', 13)
this.components.$comuna.dropdown()
this.components.$broker.dropdown()
this.components.$loader = $(`#${this.ids.loader}`)
}
}
</script>
@endpush

Some files were not shown because too many files have changed in this diff Show More