197 Commits

Author SHA1 Message Date
5138681718 feat/ot-datatable-news 2025-05-02 07:56:28 +02:00
9283059f9d Merge branch 'fix/entrega_taller_bubok' into 'main'
corregido

See merge request jjimenez/safekat!763
2025-05-01 07:08:36 +00:00
b75278f449 corregido 2025-05-01 09:08:14 +02:00
3fb944ff97 Merge branch 'mod/importador_bubok' into 'main'
añadido ajuste de precio, url en comentarios y crear pedido y ot

See merge request jjimenez/safekat!762
2025-05-01 06:59:59 +00:00
c7250cb8fd añadido ajuste de precio, url en comentarios y crear pedido y ot 2025-05-01 08:59:34 +02:00
7a9b2af8a6 Merge branch 'feat/ot-new-features' into 'main'
Features:

See merge request jjimenez/safekat!761
2025-05-01 04:16:42 +00:00
cf5a42de8d Merge branch 'main' into feat/ot-new-features 2025-05-01 06:15:26 +02:00
a259d76e5e ot new features 2025-05-01 06:02:22 +02:00
f696153d74 Merge branch 'fix/pliegos_presupuesto' into 'main'
terminado

See merge request jjimenez/safekat!760
2025-04-30 18:24:13 +00:00
9181905233 terminado 2025-04-30 20:23:45 +02:00
0ec7dff479 Merge branch 'feat/importador_bubok' into 'main'
Primera version del importador de Bubok

See merge request jjimenez/safekat!759
2025-04-30 13:39:21 +00:00
b0fb0f18fb Primera version del importador de Bubok 2025-04-30 15:36:33 +02:00
cf4c4df80a Features:
- Prototipo PDF
 - Ferro PDF
 - Ferro OK fecha cambiado a Ferro/Prototipo OK
 - Comentarios para orden,impresion,cubierta,encuadernacion y logistica
 - Migración para comentarios
 - Tarifas acabado migraciones con campos para identificar mejor si es plastificado,plakene,retractilado y el tipo de cada uno
2025-04-30 09:23:37 +02:00
36c9227586 fix pdf tables encuadernacion. Add tarifa acabado configuration for ots 2025-04-30 01:25:24 +02:00
4e9dfb51c7 Merge branch 'fix/descuento_con_ajuste' into 'main'
arreglado

See merge request jjimenez/safekat!757
2025-04-29 18:03:58 +00:00
5aab9a33ac arreglado 2025-04-29 20:03:02 +02:00
ea762a09c0 Merge branch 'fix/confirmar_presupuesto_ajustado' into 'main'
corregido

See merge request jjimenez/safekat!756
2025-04-29 17:56:28 +00:00
21014d029f corregido 2025-04-29 19:56:08 +02:00
9c31f2bbc5 Merge branch 'add/configuracion_cliente_cambios_importador_catalogo' into 'main'
terminado

See merge request jjimenez/safekat!755
2025-04-29 17:33:59 +00:00
b288ca498c terminado 2025-04-29 19:30:35 +02:00
96a6845c0c Merge branch 'feat/importador_rama_2' into 'main'
Feat/importador rama 2

See merge request jjimenez/safekat!754
2025-04-29 15:10:55 +00:00
eed5c0994e Importador rama con ajuste del precio 2025-04-29 17:09:19 +02:00
e2ab42cd84 Arreglado bug impresora de tickets (logistica) 2025-04-29 17:01:16 +02:00
7da76af866 Primera version del importador RAMA 2025-04-29 15:42:50 +02:00
bf1e66d746 Corregido bug en API imprimelibros 2025-04-29 12:40:35 +02:00
adccc414be Merge branch 'fix/bugs-ot' into 'main'
Fix/bugs ot

See merge request jjimenez/safekat!752
2025-04-28 06:13:50 +00:00
95fa192cb9 remove ? from orden_trabajo pdf 2025-04-28 08:12:22 +02:00
9310d2dabd delete class text-center from div.card otTask 2025-04-28 08:06:44 +02:00
3abf45ca6e tiempo real tarea empty when created 2025-04-28 08:00:39 +02:00
6ea22066c2 Merge branch 'feat/festivos-calendar' into 'main'
Feat/festivos calendar

See merge request jjimenez/safekat!751
2025-04-28 00:11:16 +00:00
bf21a336b1 Merge branch 'main' into feat/festivos-calendar 2025-04-28 02:10:52 +02:00
d1e5731d1d create POD dates pedido 2025-04-28 02:03:40 +02:00
029757bb40 add calendar festivos 2025-04-28 00:42:15 +02:00
bb4c9690b9 Merge branch 'feat/importador_rama' into 'main'
Feat/importador rama

See merge request jjimenez/safekat!750
2025-04-27 20:01:26 +00:00
6d45a950df Trabajando JS 2025-04-27 22:00:52 +02:00
6f8890a8b1 Merge branch 'main' into 'feat/importador_rama'
Main

See merge request jjimenez/safekat!749
2025-04-27 18:56:08 +00:00
c093c01c00 Merge branch 'main' into feat/festivos-calendar 2025-04-27 19:30:31 +02:00
a4532a7ff6 Merge branch 'fix/filter-datatable-ot' into 'main'
Fix/filter datatable ot

See merge request jjimenez/safekat!748
2025-04-27 17:27:30 +00:00
31a12ff343 try catch getTiempoProcesamientoHHMM 2025-04-27 19:26:02 +02:00
1d6f5fe53e default table encuadernacion 2025-04-27 19:24:11 +02:00
0b767c63e9 fix filter ferro 2025-04-27 19:13:06 +02:00
e464652fe2 festivo entity model 2025-04-27 19:01:23 +02:00
dd20f2a20e Merge branch 'maquinista-change-user' into 'main'
Maquinista change user

See merge request jjimenez/safekat!747
2025-04-27 16:54:35 +00:00
97554bffc9 add maquinista change user session 2025-04-27 18:53:24 +02:00
73e9e941ed Merge branch 'main' into maquinista-change-user 2025-04-27 12:25:09 +02:00
05720cf1ce Merge branch 'fix/migrate' into 'main'
fix migrate class name

See merge request jjimenez/safekat!746
2025-04-27 10:20:33 +00:00
04e9e3ee6f fix migrate class name 2025-04-27 12:18:20 +02:00
9804a6a927 change user session 2025-04-27 12:17:31 +02:00
3402e67fb2 Merge branch 'add/envio_ferros' into 'main'
Add/envio ferros

See merge request jjimenez/safekat!745
2025-04-27 10:14:05 +00:00
b1932e6f85 terminado envio de ferros 2025-04-27 12:12:52 +02:00
13ae70236e Merge branch 'feat/sk-44' into 'main'
Feat/sk 44

See merge request jjimenez/safekat!744
2025-04-27 09:00:23 +00:00
4d8332e625 Merge branch 'main' into feat/sk-44 2025-04-27 10:59:41 +02:00
c75d08b3c3 ot pliegos 2025-04-27 10:58:23 +02:00
a0b5f3b4df trabajando en envio de ferros 2025-04-27 09:51:52 +02:00
0e444295e3 trabajando en el formulario envio de ferros 2025-04-27 09:51:04 +02:00
ae7707057a Cambiando titulo pagina 2025-04-27 09:17:46 +02:00
ff115f4f20 Configurando logica de captacion del Excel 2025-04-27 09:16:15 +02:00
45e41c77e4 tablas encuadernacion ot pdf 2025-04-27 08:20:35 +02:00
ae456c8890 Implementado script principal 2025-04-27 00:00:58 +02:00
e8958dc893 Implementado menu lateral 2025-04-26 23:23:04 +02:00
b0ac132e59 Arreglado bug en archivo de migrate del catalogo 2025-04-26 23:05:15 +02:00
b50e564641 Desplegando arcihvos iniciales 2025-04-26 21:32:22 +02:00
894770d6ce Merge branch 'feat/importador_rama' of https://git.imnavajas.es/jjimenez/safekat into feat/importador_rama 2025-04-26 21:25:18 +02:00
367c7c2ea8 Merge branch 'main' into 'feat/importador_rama'
Main

See merge request jjimenez/safekat!743
2025-04-26 19:24:58 +00:00
9375b9b624 Añadiendo idiomas 2025-04-26 21:22:39 +02:00
9a6a4f89a2 Merge branch 'add/files_albaranes' into 'main'
subidos ficheros

See merge request jjimenez/safekat!742
2025-04-26 16:09:09 +00:00
7f31e65960 subidos ficheros 2025-04-26 18:08:41 +02:00
5aa2a2e6c9 Merge branch 'add/logistica_albaranes' into 'main'
Add/logistica albaranes

See merge request jjimenez/safekat!741
2025-04-26 15:27:46 +00:00
dfbcb13ba5 hecho tema albaranes logistica 2025-04-26 17:27:29 +02:00
033184cfa2 Iniciando herramienta de importacion desde catalogo 2025-04-26 16:52:59 +02:00
25b6d14423 falta boton borrar albaranes! 2025-04-26 14:16:32 +02:00
96bd24ae8b Merge branch 'add/impresion_etiquetas_envios' into 'main'
Add/impresion etiquetas envios

See merge request jjimenez/safekat!740
2025-04-26 08:51:24 +00:00
b5b86b4164 terminado a falta de pruebas 2025-04-26 10:50:59 +02:00
ef173ab0fc Merge branch 'main' into add/impresion_etiquetas_envios 2025-04-26 09:56:47 +02:00
f473caf06c Merge branch 'fix/change_pedido_ot_logistica' into 'main'
terminado

See merge request jjimenez/safekat!739
2025-04-26 07:55:29 +00:00
5e8a7f8bd4 terminado 2025-04-26 09:54:56 +02:00
905112334f Merge branch 'fix/php-syntax' into 'main'
<php syntax

See merge request jjimenez/safekat!738
2025-04-25 17:34:29 +00:00
d0f37cb714 <php syntax 2025-04-25 19:32:26 +02:00
151e4a2d7a cambios 2025-04-25 17:50:30 +02:00
05ebfa06df Merge branch 'feat/view-maquinista' into 'main'
Feat/view maquinista

See merge request jjimenez/safekat!737
2025-04-25 11:22:19 +00:00
dafdf68c41 view maquinista 2025-04-25 13:20:35 +02:00
4379a9d23b erase ot dates 2025-04-25 12:57:14 +02:00
cc2c9eee1c maquina button 2025-04-25 11:30:41 +02:00
b942064608 Merge branch 'main' into feat/view-maquinista 2025-04-25 07:41:25 +02:00
52b3b1ae4d maquinista view-basic 2025-04-25 07:40:20 +02:00
86dafb1133 Merge branch 'add/fechaEmbalajeForEnvio' into 'main'
cambiado ael añadir envios

See merge request jjimenez/safekat!736
2025-04-24 21:44:35 +00:00
5c68334e9a cambiado ael añadir envios 2025-04-24 23:44:07 +02:00
f16654f4ad Merge branch 'fix/findpedidoLogistica' into 'main'
corregido el añadir cuando no es multienvio y select añadir lineas

See merge request jjimenez/safekat!735
2025-04-24 16:40:46 +00:00
a1fd7075d6 corregido el añadir cuando no es multienvio y select añadir lineas 2025-04-24 18:40:10 +02:00
4fd242d4d2 Merge branch 'fix/facturas_problems' into 'main'
terminado

See merge request jjimenez/safekat!734
2025-04-24 10:01:38 +00:00
3838bcb536 terminado 2025-04-24 12:01:06 +02:00
e2011529b4 Merge branch 'fix/facturas_problema_albaranes_2' into 'main'
solucionado el totl aceptado

See merge request jjimenez/safekat!733
2025-04-24 09:02:06 +00:00
616c12002e solucionado el totl aceptado 2025-04-24 11:01:38 +02:00
ab36e86bdb Merge branch 'fix/facturas_problema_albaranes' into 'main'
solucionado

See merge request jjimenez/safekat!732
2025-04-24 08:56:17 +00:00
1ce4ac36a6 solucionado 2025-04-24 10:55:52 +02:00
7bfb49f412 Merge branch 'add/finalizar_envios_logistica' into 'main'
Add/finalizar envios logistica

See merge request jjimenez/safekat!731
2025-04-24 07:05:23 +00:00
f7b9c23f69 parece terminado los envios 2025-04-24 00:32:53 +02:00
f7d1c59c6a Merge branch 'fix/round_tiempo_rot_descuento_admin' into 'main'
corregidos los dos fallos

See merge request jjimenez/safekat!730
2025-04-23 15:42:50 +00:00
e918b5f400 corregidos los dos fallos 2025-04-23 17:41:43 +02:00
8b949a3173 Merge branch 'main' into add/finalizar_envios_logistica 2025-04-23 17:22:40 +02:00
e0916b567c tabajando 2025-04-23 17:22:12 +02:00
3779b3b8a0 Merge branch 'fix/bug_catalogo_rutas' into 'main'
Arreglado renaming de las rutas

See merge request jjimenez/safekat!729
2025-04-23 13:26:56 +00:00
6175da1d61 Arreglado renaming de las rutas 2025-04-23 15:26:22 +02:00
9473c10f97 Merge branch 'bug/ruta_duplicada' into 'main'
Renombrada ruta duplicada

See merge request jjimenez/safekat!728
2025-04-23 07:16:56 +00:00
800d32afde Renombrada ruta duplicada 2025-04-23 09:16:13 +02:00
00401aaf7f Merge branch 'feat/catalogo' into 'main'
Feat/catalogo

See merge request jjimenez/safekat!727
2025-04-22 20:58:42 +00:00
919c80fa9b Version 1.0 2025-04-22 22:57:27 +02:00
b5b4d6b026 añadidos ficheros 2025-04-22 22:20:21 +02:00
5ac1e3d4c1 finalizar envio ok 2025-04-22 22:20:03 +02:00
7dee2c26e8 Añadidas labels 2025-04-22 15:52:48 +02:00
649a244a10 Optimizando vista html 2025-04-22 12:00:12 +02:00
288a3f02eb Merge branch 'main' into feat/view-maquinista 2025-04-22 10:37:41 +02:00
952500e10e Merge branch 'main' into feat/view-maquinista 2025-04-22 10:34:06 +02:00
2cfe03b2ec Merge branch 'fix/papel-impresion-routes' into 'main'
Fix/papel impresion routes

See merge request jjimenez/safekat!726
2025-04-22 08:33:10 +00:00
b28c0d9f71 Merge branch 'main' into fix/papel-impresion-routes 2025-04-22 10:30:48 +02:00
01c7da8ca6 Merge branch 'main' of https://git.imnavajas.es/jjimenez/safekat 2025-04-22 10:30:23 +02:00
13128ebdae fix papel impresion plana filter 2025-04-22 10:30:05 +02:00
6016b6145c Merge branch 'add/view_logistica_principal' into 'main'
Add/view logistica principal

See merge request jjimenez/safekat!725
2025-04-22 08:26:52 +00:00
6450231b53 terminados albaranes 2025-04-22 10:26:33 +02:00
b86acc3949 fix papel route 2025-04-22 10:18:44 +02:00
92a6a3c16c ot tareas new migrations 2025-04-22 10:07:03 +02:00
62a95a0ca8 add views 2025-04-22 09:43:25 +02:00
ed5f73db25 Refactoring 2025-04-22 09:06:11 +02:00
ddf02f73b8 Añadido conenido merge 2025-04-22 08:40:49 +02:00
b555e988be Merge branch 'main' into 'feat/catalogo'
Main

See merge request jjimenez/safekat!724
2025-04-22 06:37:54 +00:00
2050f0ae1e botones albaran finalizado 2025-04-22 00:50:31 +02:00
fc1b69f2fe Merge branch 'main' into add/view_logistica_principal 2025-04-21 21:09:00 +02:00
946527cc1a Merge branch 'fix/plantillas_clientes_deleted_at_editor' into 'main'
arreglado

See merge request jjimenez/safekat!722
2025-04-21 15:42:34 +00:00
33d3e74e80 arreglado 2025-04-21 17:41:53 +02:00
67a7cda036 Cambios parciales 2025-04-21 15:39:02 +02:00
ed28263994 Merge branch 'fix/imposicion-ot-view' into 'main'
fix if imposicion null

See merge request jjimenez/safekat!721
2025-04-21 12:31:52 +00:00
0d24e50d01 fix if imposicion null 2025-04-21 14:29:51 +02:00
a27536e406 Merge branch 'fix/ot_view' into 'main'
Arreglado bug en visualizacion de OTs. Cambiada vista por defecto en listado a pendientes

See merge request jjimenez/safekat!719
2025-04-21 12:21:43 +00:00
4af34d7ba4 Arreglado bug en visualizacion de OTs. Cambiada vista por defecto en listado a pendientes 2025-04-21 14:21:19 +02:00
753aafe05d Resolviendo conflictos 2025-04-21 14:09:08 +02:00
63254f0bf3 Merge branch 'main' into 'feat/catalogo'
Main

See merge request jjimenez/safekat!718
2025-04-21 12:07:04 +00:00
0afd31aae0 Resolviendo conflictos 2025-04-21 14:06:47 +02:00
dd723f9889 Resolviendo conflictos 2025-04-21 14:06:13 +02:00
703781e115 Resolviendo conflictos 2025-04-21 13:59:55 +02:00
9ae3d8707c Merge branch 'fix/rutas_papeles_genericos' into 'main'
Arreglado bug de rutas

See merge request jjimenez/safekat!717
2025-04-21 11:35:36 +00:00
c344274f9d Arreglado bug de rutas 2025-04-21 13:35:12 +02:00
e18a39938b Revision con JJO 2025-04-21 13:26:00 +02:00
5ebf2c670f Merge branch 'fix/app-permissions' into 'main'
add 755 app

See merge request jjimenez/safekat!716
2025-04-21 10:56:43 +00:00
12e06937c4 add 755 app 2025-04-21 12:55:45 +02:00
fe164c4ab3 trabajando 2025-04-21 12:43:09 +02:00
9cb7762905 Creada migracion para tabla de isk's 2025-04-21 08:53:37 +02:00
548a444b7d Merge branch 'feat/imposiciones' into 'main'
Feat/imposiciones

See merge request jjimenez/safekat!715
2025-04-21 06:33:51 +00:00
969966ac78 add select imposicion datatable 2025-04-21 08:32:21 +02:00
b318721b90 button imprimir code safekat 2025-04-21 00:12:51 +02:00
a137ede1a7 fix sidebar toggle 2025-04-20 23:27:06 +02:00
5eaa5fea0b fix side bar toggle 2025-04-20 23:03:45 +02:00
19fd76e910 falta terminar albaranes 2025-04-20 22:10:56 +02:00
14b5f4bf95 Revisados formularios de crear y editar, con su validacion 2025-04-20 21:35:24 +02:00
61abcb3dbd trabajando en albaranes. Voy a quitar las cajas 2025-04-20 20:02:14 +02:00
f2ea93ddb6 fix menu toggle links 2025-04-20 20:01:15 +02:00
31524dcf61 fix menu toggle links 2025-04-20 20:00:52 +02:00
c3d38e29a4 imposiciones 2025-04-20 19:26:07 +02:00
f93ecda648 Creado concepto de ISK 2025-04-20 15:58:43 +02:00
49f9fe4009 Avances inicializacion edit 2025-04-19 22:27:27 +02:00
65c9b34f56 añadido switch a los grupos para seleccionar 2025-04-18 13:52:49 +02:00
46c29f3c13 añadidos links al pedido y al presupuesto 2025-04-18 13:42:45 +02:00
0b04e6dabd terminada envio lineas 2025-04-18 13:38:06 +02:00
15f6d0d675 voy a añadir grupos de cajas 2025-04-18 10:36:06 +02:00
3949607a3c trabajando en añadir lineas a envio 2025-04-17 13:47:26 +02:00
9e90ec798c Merge branch 'add/view_logistica_principal' of https://git.imnavajas.es/jjimenez/safekat into add/view_logistica_principal 2025-04-17 09:10:35 +02:00
76baae9e92 Merge branch 'main' into 'add/view_logistica_principal'
Main

See merge request jjimenez/safekat!714
2025-04-17 07:10:25 +00:00
52a4e7d37b Merge branch 'fix/ot-bugs' into 'main'
Fix/ot bugs

See merge request jjimenez/safekat!713
2025-04-16 18:31:44 +00:00
972d0c4ec8 pdf download file name 2025-04-16 20:31:18 +02:00
36f5d42d03 pdf uncomment 2025-04-16 20:27:08 +02:00
c28753e1f1 Merge branch 'fix/ot-bugs' into 'main'
fix pod and file if not exist

See merge request jjimenez/safekat!712
2025-04-16 18:26:15 +00:00
8e97e7b58c fix pod and file if not exist 2025-04-16 20:25:13 +02:00
f19d2b7ffe Merge branch 'fix/ot-bugs' into 'main'
fix ot

See merge request jjimenez/safekat!711
2025-04-16 17:57:24 +00:00
2a8c4b9da6 fix ot 2025-04-16 19:55:30 +02:00
d50b511e83 Merge branch 'add/view_logistica_principal' of https://git.imnavajas.es/jjimenez/safekat into add/view_logistica_principal 2025-04-16 18:24:53 +02:00
3ada529b6e trabajando 2025-04-16 18:24:48 +02:00
02a64fa40a Merge branch 'main' into 'add/view_logistica_principal'
Main

See merge request jjimenez/safekat!710
2025-04-16 16:24:25 +00:00
c42f223b9a Configurando la logica del catalogo (JS) 2025-04-16 16:10:04 +02:00
173afe403e Merge branch 'feat/ot-general-features' into 'main'
ot general features

See merge request jjimenez/safekat!709
2025-04-16 13:52:28 +00:00
c76f4428a6 ot general features 2025-04-16 15:51:09 +02:00
6a4e753a06 Merge branch 'feat/ot-pdf-colores' into 'main'
colores header pdf ot

See merge request jjimenez/safekat!708
2025-04-16 07:15:26 +00:00
6d5b8ab621 Importando estilo del comparador 2025-04-15 22:11:58 +02:00
a74021f97d Merge branch 'main' into 'feat/catalogo'
Main

See merge request jjimenez/safekat!707
2025-04-15 19:07:51 +00:00
725ea61078 Eliminada subida de ficheros y configurado menu de catalogo (no beta) 2025-04-15 21:05:33 +02:00
6a4e9b611e Merge branch 'add/view_logistica_principal' of https://git.imnavajas.es/jjimenez/safekat into add/view_logistica_principal 2025-04-15 18:48:07 +02:00
fedc608463 cambios antes del pull 2025-04-15 18:48:01 +02:00
4667e77144 Merge branch 'main' into 'add/view_logistica_principal'
Main

See merge request jjimenez/safekat!705
2025-04-15 16:47:08 +00:00
7cf1bf006d Prrrrrrrrrrr 2025-04-15 16:05:11 +02:00
67e588dd67 Primera version visual formulario catalogo completa 2025-04-15 09:54:33 +02:00
16dc39ee15 generando el grupo de envios 2025-04-14 22:00:52 +02:00
c157b1215c Merge branch 'add/view_logistica_principal' of https://git.imnavajas.es/jjimenez/safekat into add/view_logistica_principal 2025-04-14 20:07:36 +02:00
c226f031d9 trabajando en selector de pedidos 2025-04-14 20:07:29 +02:00
f9909bd8cd Merge branch 'main' into 'add/view_logistica_principal'
Main

See merge request jjimenez/safekat!701
2025-04-14 18:07:14 +00:00
c75a2f9ef4 Construyendo el formulario de edicion 2025-04-14 14:45:35 +02:00
f0a4f19089 vista creada de envios 2025-04-13 20:28:05 +02:00
e2da90926d Listado de libros de catalogo 2025-04-13 09:46:47 +02:00
5e8da603f9 Merge branch 'main' into 'feat/catalogo'
Main

See merge request jjimenez/safekat!697
2025-04-12 20:21:30 +00:00
9981f878d1 Inicializacion del modulo catalogo 2025-04-12 22:04:34 +02:00
906 changed files with 58320 additions and 4545 deletions

0
ci4/app/Config/Auth.php Normal file → Executable file
View File

0
ci4/app/Config/AuthGroups.php Normal file → Executable file
View File

0
ci4/app/Config/AuthJWT.php Normal file → Executable file
View File

0
ci4/app/Config/AuthToken.php Normal file → Executable file
View File

0
ci4/app/Config/CURLRequest.php Normal file → Executable file
View File

0
ci4/app/Config/Feature.php Normal file → Executable file
View File

0
ci4/app/Config/Kint.php Normal file → Executable file
View File

0
ci4/app/Config/LogoImpresion.php Normal file → Executable file
View File

23
ci4/app/Config/OrdenTrabajo.php Normal file → Executable file
View File

@ -12,8 +12,14 @@ class OrdenTrabajo extends BaseConfig
"interior_bn_at" => "interior_bn_user_id",
"interior_color_at" => "interior_color_user_id",
"cubierta_at" => "cubierta_user_id",
"sobrecubierta_at" => "sobrecubierta_user_id",
"guarda_at" => "guarda_user_id",
//ACABADO
"plastificado_at" => "plastificado_user_id",
"plakene_at" => "plakene_user_id",
"retractilado_at" => "retractilado_user_id",
"estampado_at" => "estampado_user_id",
"uvi_at" => "uvi_user_id",
"encuadernacion_at" => "encuadernacion_user_id",
"corte_at" => "corte_user_id",
"preparacion_interiores_at" => "preparacion_interior_user_id",
@ -21,10 +27,10 @@ class OrdenTrabajo extends BaseConfig
"cosido_at" => "cosido_user_id",
"grapado_at" => "grapado_user_id",
"solapa_at" => "solapa_user_id",
"retractilado_at" => "retractilado_user_id",
"retractilado5_at" => "retractilado5_user_id",
"prototipo_at" => "prototipo_user_id",
"marcapaginas_at" => "marcapaginas_user_id",
"espiral_at" => "espiral_user_id",
//FERRO
"pendiente_ferro_at" => "pendiente_ferro_user_id",
"ferro_en_cliente_at" => "ferro_en_cliente_user_id",
@ -64,7 +70,7 @@ class OrdenTrabajo extends BaseConfig
["bg" => "yellow", "color" => "black"],
["bg" => "purple", "color" => "white"],
["bg" => "orange", "color" => "white"],
["bg" => "blue", "color" => "black"],
["bg" => "blue", "color" => "white"],
["bg" => "pink", "color" => "black"],
["bg" => "#FFFFFF", "color" => "black"],
];
@ -99,9 +105,9 @@ class OrdenTrabajo extends BaseConfig
];
public array $OT_PLASTIFICADO_COLOR =
[
"BRIL" => ["bg" => "#00B0F0", "color" => "white"],
"BRILLO" => ["bg" => "#00B0F0", "color" => "white"],
"MATE" => ["bg" => "#FF0000", "color" => "white"],
"SOFT_TOUCH" => ["bg" => "#00B050", "color" => "white"],
"SOFT" => ["bg" => "#00B050", "color" => "white"],
"SANDY" => ["bg" => "#782170", "color" => "white"],
"ANTIRAYADO" => ["bg" => "#E97132", "color" => "white"],
"GOFRADO" => ["bg" => "#FFFF00", "color" => "black"],
@ -115,6 +121,15 @@ class OrdenTrabajo extends BaseConfig
"default" => ["bg" => "white", "color" => "black"],
];
public array $OT_TAREA_STATUS_COLOR = [
"P" => '#FFD63A',
"F" => '#67AE6E',
"S" => '#EB5B00',
"I" => '#3A59D1',
"E" => '#FF0B55',
"D" => '#FFA725',
];
public function __construct()
{
parent::__construct();

0
ci4/app/Config/PedidoXML.php Normal file → Executable file
View File

0
ci4/app/Config/Publisher.php Normal file → Executable file
View File

0
ci4/app/Config/RBAC/.gitkeep Normal file → Executable file
View File

96
ci4/app/Config/Routes.php Normal file → Executable file
View File

@ -32,7 +32,7 @@ $routes->group('activity', ['namespace' => 'App\Controllers\Sistema'], function
* --------------------------------------------------------------------
*/
// Carga archivos de rutas por dominio
// Carga archivos de rutas por dominio
foreach (glob(APPPATH . 'Config/Routes/*Routes.php') as $routeFile) {
require $routeFile;
}
@ -40,6 +40,8 @@ foreach (glob(APPPATH . 'Config/Routes/*Routes.php') as $routeFile) {
$routes->group('users', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('', 'Users::index', ['as' => 'userList']);
$routes->get('maquinista/change/user','Users::index_maquinista_change_user',['as' => 'maquinistaUserChangeList']);
$routes->get('maquinista/change/session/(:num)','Users::change_user_session/$1',['as' => 'maquinistaChangeUserSession']);
$routes->get('list', 'Users::index', ['as' => 'userList2']);
$routes->get('add', 'Users::add', ['as' => 'newUser']);
$routes->post('add', 'Users::add', ['as' => 'createUser']);
@ -146,17 +148,24 @@ $routes->group('tipologiaslibros', ['namespace' => 'App\Controllers\Configuracio
$routes->group('imposiciones', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('', 'Imposiciones::index', ['as' => 'imposicionList']);
$routes->get('add', 'Imposiciones::add', ['as' => 'newImposicion']);
$routes->post('add', 'Imposiciones::add', ['as' => 'createImposicion']);
$routes->get('add/esquema', 'Imposiciones::add_esquema', ['as' => 'newImposicionEsquema']);
$routes->get('find/(:num)', 'Imposiciones::find_imposicion/$1', ['as' => 'findImposicion']);
$routes->get('esquema/find/(:num)', 'Imposiciones::find_imposicion_esquema/$1', ['as' => 'findImposicionEsquema']);
$routes->post('create', 'Imposiciones::create', ['as' => 'ajaxCreateImposicion']);
$routes->put('(:num)/update', 'Imposiciones::update/$1', ['as' => 'ajaxUpdateImposicion']);
$routes->post('(:num)/edit', 'Imposiciones::edit/$1', ['as' => 'updateImposicion']);
$routes->post('datatable', 'Imposiciones::datatable', ['as' => 'dataTableOfImposiciones']);
$routes->post('esquema/create', 'Imposiciones::create_imposicion_esquema', ['as' => 'ajaxCreateImposicionEsquema']);
$routes->post('(:num)', 'Imposiciones::update/$1', ['as' => 'ajaxUpdateImposicion']);
$routes->post('esquema/(:num)', 'Imposiciones::update_imposicion_esquema/$1', ['as' => 'ajaxUpdateImposicionEsquema']);
$routes->delete('(:num)', 'Imposiciones::delete/$1', ['as' => 'deleteImposicion']);
$routes->delete('esquema/(:num)', 'Imposiciones::delete_imposicion_esquema/$1', ['as' => 'deleteImposicionEsquema']);
$routes->get('edit/(:num)', 'Imposiciones::edit/$1', ['as' => 'updateImposicionForm']);
$routes->get('esquema/edit/(:num)', 'Imposiciones::edit_imposicion_esquema/$1', ['as' => 'updateImposicionEsquemaForm']);
$routes->get('datatable', 'Imposiciones::datatable', ['as' => 'dataTableOfImposiciones']);
$routes->get('esquema/datatable', 'Imposiciones::datatable_imposicion_esquema', ['as' => 'dataTableOfEsquemaImposiciones']);
$routes->post('allmenuitems', 'Imposiciones::allItemsSelect', ['as' => 'select2ItemsOfImposiciones']);
$routes->post('menuitems', 'Imposiciones::menuItems', ['as' => 'menuItemsOfImposiciones']);
$routes->get('select', 'Imposiciones::selectImposicion', ['as' => 'selectImposicion']);
$routes->get('esquema/select', 'Imposiciones::selectImposicionEsquema', ['as' => 'selectImposicionEsquema']);
});
$routes->resource('imposiciones', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Imposiciones', 'except' => 'show,new,create,update']);
$routes->group('papelimpresiontipologias', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('add', 'Papelimpresiontipologias::add', ['as' => 'newPapelImpresionTipologia']);
@ -505,15 +514,19 @@ $routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function (
$routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']);
$routes->group('albaranes', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) {
$routes->post('add', 'Albaran::add', ['as' => 'crearAlbaranesPedido']);
$routes->post('update/(:any)', 'Albaran::update/$1', ['as' => 'actualizarAlbaran']);
$routes->post('updateLinea/(:any)', 'Albaran::updateLinea/$1', ['as' => 'actualizarLineaAlbaran']);
$routes->post('deletelinea', 'Albaran::borrarlinea', ['as' => 'borrarAlbaranLinea']);
$routes->get('delete/(:any)', 'Albaran::delete/$1', ['as' => 'borrarAlbaran']);
$routes->get('getalbaranes/(:any)', 'Albaran::getAlbaranes/$1', ['as' => 'getAlbaranes']);
$routes->get('nuevalinea/(:any)', 'Albaran::addLinea/$1', ['as' => 'addAlbaranLinea']);
$routes->post('nuevalinea/(:any)', 'Albaran::addLinea/$1', ['as' => 'addIVA']);
$routes->group('albaranes', ['namespace' => 'App\Controllers\Albaranes'], function ($routes) {
$routes->post('generarAlbaran', 'Albaran::generateAlbaran', ['as' => 'generarAlbaran']);
$routes->get('albaranesEnvio', 'Albaran::getAlbaranes');
$routes->get('datatablesAlbaranLinea', 'Albaran::datatablesLineasAlbaran');
$routes->post('updateAlbaran', 'Albaran::updateAlbaran');
$routes->post('borrarAlbaranLinea', 'Albaran::borrarLinea');
$routes->post('borrarAlbaran', 'Albaran::borrarAlbaran');
$routes->post('updateAlbaranLinea', 'Albaran::updateAlbaranLinea');
$routes->post('addIvaAlbaran', 'Albaran::addLineasIva');
$routes->post('nuevaLineaAlbaran', 'Albaran::addBlankLineaAlbaran');
$routes->get('datatable', 'Albaran::datatable', ['as' => 'dataTableOfAlbaranes']);
$routes->get('getAlbaran', 'Albaran::getAlbaran');
$routes->get('edit/(:num)', 'Albaran::editAlbaran/$1', ['as' => 'editarAlbaran']);
});
$routes->resource('albaranes', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Albaran', 'except' => 'show,new,create,update']);
@ -540,6 +553,7 @@ $routes->group('facturas', ['namespace' => 'App\Controllers\Facturacion'], funct
$routes->post('updateCabecera/(:any)', 'Facturas::updateCabecera/$1', ['as' => 'updateCabecera']);
$routes->post('datatablePagos/(:any)', 'FacturasPagos::datatable/$1', ['as' => 'dataTableOfPagosFacturas']);
$routes->post('editorPagos', 'FacturasPagos::datatable_editor', ['as' => 'editorOfPagosFacturas']);
$routes->post('deleteFacturaLineaPago', 'Facturas::deleteLineaPago', ['as' => 'deleteLineaPago']);
$routes->post('datatablePedidos', 'Facturas::datatablePedidos', ['as' => 'dataTableOfFacturasPedido']);
$routes->get('getdatoscliente/(:any)', 'Facturas::getDatosFacturacionClienteForm/$1');
});
@ -630,6 +644,7 @@ $routes->group('messages', ['namespace' => 'App\Controllers\Chat'], function ($r
$routes->get('datatable/presupuesto', 'ChatController::datatable_presupuesto_messages', ['as' => 'getDatatablePresupuestoMessages']);
$routes->get('datatable/pedido', 'ChatController::datatable_pedido_messages', ['as' => 'getDatatablePedidoMessages']);
$routes->get('datatable/factura', 'ChatController::datatable_factura_messages', ['as' => 'getDatatableFacturaMessages']);
$routes->get('datatable/ots', 'ChatController::datatable_ot_messages', ['as' => 'getDatatableOtMessages']);
$routes->post('direct', 'ChatController::store_new_direct_message', ['as' => 'storeNewDirectMessage']);
$routes->post('direct/client', 'ChatController::store_new_direct_message_client', ['as' => 'storeNewDirectMessageClient']);
@ -640,6 +655,8 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route
$routes->get('presupuesto/(:num)', 'ChatController::get_chat_presupuesto_view/$1', ['as' => 'getChatPresupuestoView']);
$routes->get('pedido/(:num)', 'ChatController::get_chat_pedido_view/$1', ['as' => 'getChatPedidoView']);
$routes->get('factura/(:num)', 'ChatController::get_chat_factura_view/$1', ['as' => 'getChatFacturaView']);
$routes->get('ot/(:num)', 'ChatController::get_chat_ot_view/$1', ['as' => 'getChatOtView']);
$routes->get('direct/conversation/(:num)', 'ChatController::get_chat_direct/$1', ['as' => 'getChatDirect']);
$routes->get('direct/users/select/(:num)', 'ChatController::get_chat_direct_select_users/$1', ['as' => 'getChatDirectSelectUsers']);
@ -734,29 +751,46 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func
$routes->get('datatable_pendientes', 'Ordentrabajo::datatable_pendientes');
$routes->get('datatable_ferro_pendiente', 'Ordentrabajo::datatable_ferro_pendiente');
$routes->get('datatable_ferro_ok', 'Ordentrabajo::datatable_ferro_ok');
$routes->get('datatable_news', 'Ordentrabajo::datatable_news');
$routes->get('datatable_prod', 'Ordentrabajo::datatable_prod');
$routes->get('datatable_waiting', 'Ordentrabajo::datatable_waiting');
$routes->get('datatable_revision_com', 'Ordentrabajo::datatable_revision_com');
$routes->get('tareas/datatable/(:num)', 'Ordentrabajo::tareas_datatable/$1', ['as' => 'datatableTareasOrdenTrabajo']);
$routes->get("tarea/progress/(:num)", "Ordentrabajo::get_orden_trabajo_progress_date/$1");
$routes->get('tarea/(:num)', 'Ordentrabajo::find_tarea/$1');
$routes->get('tarea/dates/(:num)','Ordentrabajo::get_orden_trabajo_tareas_dates/$1');
/**======================
* UPDATES
*========================**/
$routes->post("update/tarea", 'Ordentrabajo::update_orden_trabajo_tarea');
$routes->post("update/date", 'Ordentrabajo::update_orden_trabajo_date');
$routes->post("reset/date", 'Ordentrabajo::reset_orden_trabajo_date');
$routes->post("update/pedido/date", 'Ordentrabajo::update_orden_trabajo_pedido_date');
$routes->post("reset/pedido/date", 'Ordentrabajo::reset_orden_trabajo_pedido_date');
$routes->post("update/pod/pedido/date/(:num)",'Ordentrabajo::update_pod_pedido_dates/$1');
$routes->post("update/pedido", 'Ordentrabajo::update_orden_trabajo_pedido');
$routes->post("update/user", 'Ordentrabajo::update_orden_trabajo_user');
$routes->post("update", 'Ordentrabajo::update_orden_trabajo');
$routes->post("upload/portada", 'Ordentrabajo::upload_orden_trabajo_portada');
$routes->delete("portada/(:num)", 'Ordentrabajo::delete_orden_trabajo_portada/$1');
$routes->get("color/(:num)", 'Ordentrabajo::get_orden_trabajo_color_status/$1');
$routes->post("update/tarea/progress", "Ordentrabajo::store_orden_trabajo_progress_date");
$routes->post("update/tarea/pliegos", "Ordentrabajo::update_orden_trabajo_pliegos");
$routes->post("update/tarea/proveedor", "Ordentrabajo::update_presupuesto_tarea_proveedor");
$routes->delete("tarea/progress/(:num)", "Ordentrabajo::delete_orden_trabajo_progress_date/$1");
/**======================
* FILES
*========================**/
$routes->post('get_files', 'Ordentrabajo::get_files');
$routes->post('upload_files', 'Ordentrabajo::upload_files');
$routes->get('barcode/(:num)', 'Ordentrabajo::imprimir_codigo_safekat/$1', ['as' => "getOrdenTrabajoBarCode"]);
/**======================
* PDF
*========================**/
$routes->get('pdf/(:num)', 'Ordentrabajo::get_pdf/$1');
$routes->get('pdf/ferro/(:num)', 'Ordentrabajo::get_ferro_pdf/$1');
$routes->get('pdf/prototipo/(:num)', 'Ordentrabajo::get_prototipo_pdf/$1');
$routes->get('portada/(:num)', 'Ordentrabajo::get_portada_img/$1');
$routes->group('planning', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
$routes->get('select/maquina/rotativa', 'Ordentrabajo::select_maquina_planning_rot');
@ -770,15 +804,45 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func
$routes->get('rotativa/datatable', 'Ordentrabajo::planning_rotativa_datatable');
$routes->get('plana/datatable', 'Ordentrabajo::planning_plana_datatable');
$routes->post('tarea/toggle/corte/(:num)', 'Ordentrabajo::tarea_toggle_corte/$1');
});
$routes->group('maquinista', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
$routes->get('maquinas/view', 'Ordentrabajo::maquinista_maquinas_view', ['as' => 'viewProduccionMaquinistaMaquinas']);
$routes->get('maquinas/view/(:num)', 'Ordentrabajo::maquinista_maquina_tareas_list/$1', ['as' => 'viewProduccionMaquinaTareasList']);
$routes->get('maquinas/tareas/datatable/(:alpha)/(:num)', 'Ordentrabajo::maquinista_maquina_tareas_datatable/$1/$2', ['as' => 'viewMaquinistaMaquinaTareaDatatable']);
$routes->get('maquinas/view/tarea/(:num)', 'Ordentrabajo::maquinista_maquina_tarea_view/$1', ['as' => 'viewProduccionMaquinistaTareaView']);
$routes->get('colas/view', 'Ordentrabajo::maquinista_colas_view', ['as' => 'viewProduccionMaquinistaColas']);
});
});
});
$routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], function ($routes) {
$routes->get('print/label/test', 'LogisticaController::print_test_label');
$routes->get('panel', 'LogisticaController::panel', ['as' => 'LogisticaPanel']);
$routes->get('envios', 'LogisticaController::gestionEnvios', ['as' => 'gestionEnvios']);
$routes->get('enviosFerros', 'LogisticaController::gestionEnviosFerros', ['as' => 'gestionEnviosFerros']);
$routes->get('datatableEnvios', 'LogisticaController::datatable_envios');
$routes->get('datatableLineasEnvios/(:num)', 'LogisticaController::datatable_enviosEdit/$1');
$routes->get('envio/(:num)', 'LogisticaController::editEnvio/$1');
$routes->get('selectAddLinea', 'LogisticaController::selectAddEnvioLinea');
$routes->get('addLineaEnvio', 'LogisticaController::addEnvioLinea');
$routes->post('updateCajaLinea', 'LogisticaController::setCajaLinea');
$routes->post('deleteLineasEnvio', 'LogisticaController::deleteLineas');
$routes->post('updateLineaEnvio', 'LogisticaController::updateLineaEnvio');
$routes->post('updateComentariosEnvio', 'LogisticaController::saveComments');
$routes->post('updateCajasEnvio', 'LogisticaController::updateCajasEnvio');
$routes->post('updateCodigoSeguimiento', 'LogisticaController::updateCodigoSeguimiento');
$routes->post('updateProveedorEnvio', 'LogisticaController::updateProveedorEnvio');
$routes->post('finalizarEnvio', 'LogisticaController::finalizarEnvio');
$routes->post('generateEnvio', 'LogisticaController::generarEnvio');
$routes->post('generateEnvioFerro', 'LogisticaController::generarEnvioFerro');
$routes->get('selectForNewEnvio', 'LogisticaController::findForNewEnvio');
$routes->get('selectDireccionForEnvio', 'LogisticaController::selectDireccionForEnvio');
$routes->post('imprimirEtiquetas', 'LogisticaController::imprimirEtiquetas');
$routes->get('listAlbaranes', 'LogisticaController::listAlbaranes', ['as' => 'albaranesList']);
});
/*

0
ci4/app/Config/Routes/ApiRoutes.php Normal file → Executable file
View File

View File

@ -0,0 +1,29 @@
<?php
use CodeIgniter\Router\RouteCollection;
/** @var RouteCollection $routes */
/* Rutas para tarifas */
$routes->group('catalogo', ['namespace' => 'App\Controllers\Catalogo'], function ($routes) {
/* Libros */
$routes->group('libros', ['namespace' => 'App\Controllers\Catalogo'], function ($routes) {
/**======================
* CRUD
*========================**/
$routes->get('', 'CatalogoLibros::index', ['as' => 'catalogoLibrosList']);
$routes->get('gettarifas', 'CatalogoLibros::getSelect2');
$routes->match(['get', 'post'], 'add', 'CatalogoLibros::add', ['as' => 'catalogoLibrosAdd']);
$routes->match(['get', 'post'], 'edit/(:num)', 'CatalogoLibros::edit/$1', ['as' => 'catalogoLibrosEdit']);
$routes->get('delete/(:num)', 'CatalogoLibros::delete/$1', ['as' => 'catalogoLibrosDelete']);
$routes->get('datatable', 'CatalogoLibros::datatable', ['as' => 'catalogoLibrosDT']);
/**======================
* AJAX
*========================**/
$routes->get('clientlist', 'CatalogoLibros::getClientList', ['as' => 'catalogoLibrosClientList']);
});
});

1
ci4/app/Config/Routes/ComprasRoutes.php Normal file → Executable file
View File

@ -19,6 +19,7 @@ $routes->group('compras', ['namespace' => 'App\Controllers\Compras'], function (
$routes->get('delete/(:num)', 'Proveedores::delete/$1', ['as' => 'deleteProveedores']);
$routes->post('allmenuitems', 'Proveedores::allItemsSelect', ['as' => 'select2ItemsOfProveedores']);
$routes->post('menuitems', 'Proveedores::menuItems', ['as' => 'menuItemsOfProveedores']);
$routes->get('getProveedores', 'Proveedores::getForSelect');
});
});

13
ci4/app/Config/Routes/ConfiguracionRoutes.php Normal file → Executable file
View File

@ -53,7 +53,6 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
$routes->post('duplicate/(:num)', 'Papelesimpresion::duplicate/$1', ['as' => 'duplicatePapelImpresion']);
$routes->get('select', 'Papelesimpresion::papel_impresion_select', ['as' => 'papelImpresionSelect']);
$routes->get('show/(:num)', 'Papelesimpresion::papel_impresion_find/$1', ['as' => 'showPapelImpresion']);
});
/* Maquinas */
@ -149,5 +148,15 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
$routes->group("messages", ["namespace" => 'App\Controllers\Chat'], function ($routes) {
$routes->get('', 'ChatController::config_view', ['as' => 'configMessagesIndex']);
});
});
/* Festivos */
$routes->group("festivos", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('', 'FestivoController::index', ['as' => 'festivosList']);
$routes->post('', 'FestivoController::store_festivo_date', ['as' => 'storeFestivoDate']);
$routes->delete('(:num)', 'FestivoController::delete_festivo_date/$1', ['as' => 'deleteFestivoDate']);
$routes->get('all', 'FestivoController::find_all', ['as' => 'getFindAllFestivos']);
});
});

View File

@ -0,0 +1,38 @@
<?php
use CodeIgniter\Router\RouteCollection;
/** @var RouteCollection $routes */
/* Rutas para tarifas */
$routes->group('importador', ['namespace' => 'App\Controllers\Importadores'], function ($routes) {
/* Desde Catalogo */
$routes->group('catalogo', ['namespace' => 'App\Controllers\Importadores'], function ($routes) {
/**======================
* Tool
*========================**/
$routes->get('', 'ImportadorCatalogo::index', ['as' => 'importadorCatalogoTool']);
/**======================
* AJAX
*========================**/
$routes->post('validar-fila', 'ImportadorCatalogo::validarFila');
$routes->post('importar-fila', 'ImportadorCatalogo::importarFila');
});
/* Desde Cliente Bubok */
$routes->group('bubok', ['namespace' => 'App\Controllers\Importadores'], function ($routes) {
/**======================
* Tool
*========================**/
$routes->get('', 'ImportadorBubok::index', ['as' => 'importadorBubokTool']);
/**======================
* AJAX
*========================**/
$routes->post('importar-fila', 'ImportadorBubok::importarFila');
});
});

0
ci4/app/Config/Routes/PresupuestosRoutes.php Normal file → Executable file
View File

0
ci4/app/Config/Routes/TarifasRoutes.php Normal file → Executable file
View File

0
ci4/app/Config/Routing.php Normal file → Executable file
View File

0
ci4/app/Config/Safekat.php Normal file → Executable file
View File

0
ci4/app/Config/Session.php Normal file → Executable file
View File

0
ci4/app/Config/Toolbar.php Normal file → Executable file
View File

View File

@ -155,6 +155,17 @@ class Validation extends BaseConfig
],
];
public array $orden_trabajo_tarea_progress_date = [
"ot_tarea_id" => [
"rules" => "required|integer",
"label" => "tarea"
],
"estado" => [
"rules" => "required|in_list[P,I,S,D,F,E]",
"label" => "estado"
]
];
public array $orden_trabajo = [
"orden_trabajo_id" => [
"rules" => "required|integer",
@ -173,4 +184,15 @@ class Validation extends BaseConfig
"label" => "maquina",
],
];
public array $proveedor_tarea =
[
"proveedor_id" => [
"rules" => "required|integer",
"label" => "Proveedor",
],
"orden_trabajo_tarea_id" => [
"rules" => "required|integer",
"label" => "Tarea",
],
];
}

0
ci4/app/Config/Wiki/WikiRoutes.php Normal file → Executable file
View File

11
ci4/app/Controllers/API/ImprimelibrosApi.php Normal file → Executable file
View File

@ -5,22 +5,13 @@ namespace App\Controllers\API;
use App\Controllers\Presupuestos\Presupuestocliente;
use CodeIgniter\RESTful\ResourceController;
use CodeIgniter\API\ResponseTrait;
use App\Models\API\ItemModel;
class ImprimelibrosApi extends ResourceController
{
use ResponseTrait;
public function index()
{
$model = new ItemModel();
$data = $model->findAll();
return $this->respond($data);
}
public function calcular()
{
helper(['form']);

View File

@ -0,0 +1,615 @@
<?php
namespace App\Controllers\Albaranes;
use App\Entities\Albaranes\AlbaranEntity;
use App\Models\Albaranes\AlbaranModel;
use Hermawan\DataTables\DataTable;
class Albaran extends \App\Controllers\BaseResourceController
{
protected $modelName = AlbaranModel::class;
protected $format = 'json';
protected static $singularObjectNameCc = 'albaran';
protected static $singularObjectName = 'Albaran';
protected static $pluralObjectName = 'Albaranes';
protected static $controllerSlug = 'albaran';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
}
public function index()
{
}
public function delete($id = null)
{
if ($this->request->isAJAX()) {
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$model_linea = model('App\Models\Albaranes\AlbaranLineaModel');
$model_linea->where('albaran_id', $id)->delete();
$this->model->where('id', $id)->delete();
$data = [
'error' => 0,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function editAlbaran($albaran_id){
$albaran = $this->model->find($albaran_id);
if ($albaran == false) {
return redirect()->to(base_url('albaranesList'));
}
$this->viewData['boxTitle'] = lang('Albaran.editAlbaran') . ' ' . $albaran->numero_albaran;
$this->viewData['albaranId'] = $albaran_id;
return view('themes/vuexy/form/logistica/albaranes/viewAlbaranesEdit', $this->viewData);
}
public function addLinea($albaran_id)
{
if ($this->request->isAJAX()) {
$model_linea = model('App\Models\Albaranes\AlbaranLineaModel');
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
// si es un post, es el iva
if ($this->request->getPost()) {
$reqData = $this->request->getPost();
$albaran_id = $reqData['albaran_id'] ?? 0;
$albaran = $this->model->find($albaran_id);
if ($albaran == false) {
$data = [
'error' => 'Albaran no encontrado',
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
$presupuesto_model = model('App\Models\Presupuestos\PresupuestoModel');
$presupuesto = $presupuesto_model->find($albaran->presupuesto_id);
if ($presupuesto == false) {
$data = [
'error' => 'Presupuesto no encontrado',
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
$iva_reducido = $presupuesto->iva_reducido;
$lineas = $model_linea->where('albaran_id', $albaran_id)->findAll();
$total = 0;
foreach ($lineas as $linea) {
$total += $linea->total;
}
$iva = $iva_reducido ? $total * 4.0 / 100 : $total * 21.0 / 100;
$data_linea = [
'albaran_id' => $albaran_id,
'titulo' => $iva_reducido ? lang('Pedidos.iva4') : lang('Pedidos.iva21'),
'cantidad' => 1,
'precio_unidad' => round($iva, 2),
'total' => round($iva, 2),
'user_created_id' => auth()->user()->id,
'user_updated_id' => auth()->user()->id
];
$id_linea = $model_linea->insert($data_linea);
$linea = $model_linea->find($id_linea);
$data = [
'error' => 0,
'data' => $linea,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
$linea = [
'albaran_id' => $albaran_id,
'user_created_id' => auth()->user()->id,
'user_updated_id' => auth()->user()->id
];
$id_linea = $model_linea->insert($linea);
$data = $model_linea->find($id_linea);
$data = [
'error' => 0,
'data' => $data,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function add()
{
if ($this->request->isAJAX()) {
$user = auth()->user()->id;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$reqData = $this->request->getPost();
$pedido_id = $reqData['pedido_id'] ?? 0;
$presupuestos_id = $reqData['presupuestos_id'] ?? 0;
$return_data = $this->model->generarAlbaranes($pedido_id, $presupuestos_id, $user);
$data = [
'data' => $return_data,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function updateAlbaran()
{
if ($this->request->isAJAX()) {
$fieldName = $this->request->getPost('fieldName');
$fieldValue = $this->request->getPost('fieldValue');
$id = $this->request->getPost('albaranId');
if ($id == null) {
$data = [
'success' => false,
'message' => lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]),
];
return $this->respond($data);
}
$albaranEntity = $this->model->find($id);
if ($albaranEntity == false) {
$data = [
'success' => false,
'message' => lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]),
];
return $this->respond($data);
}
if($fieldName == 'fecha_albaran'){
if($fieldValue == null || $fieldValue == '')
$fieldValue = null;
else
$fieldValue = date('Y-m-d H:i:s', strtotime($fieldValue));
}
$albaranEntity->fill([
$fieldName => $fieldValue,
'user_updated_id' => auth()->user()->id,
]);
$successfulResult = $this->model->skipValidation(true)->update($id, $albaranEntity);
if ($successfulResult) {
$data = [
'success' => true,
'message' => lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.',
];
} else {
$data = [
'success' => false,
'message' => lang('Basic.global.updateError', [lang('Basic.global.record')]) . '.',
];
}
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function updateLinea($id = null)
{
if ($this->request->isAJAX()) {
$model_linea = model('App\Models\Albaranes\AlbaranLineaModel');
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
if ($id == null):
$data = [
'error' => 2,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif;
$id = filter_var($id, FILTER_SANITIZE_URL);
$albaranEntity = $model_linea->find($id);
if ($albaranEntity == false):
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
$data = [
'error' => $message,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif;
if ($this->request->getPost()):
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
$sanitizedData['user_updated_id'] = auth()->user()->id;
$noException = true;
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()):
try {
$successfulResult = $model_linea->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Pedidos.albaran'))]);
$this->session->setFlashdata('formErrors', $model_linea->errors());
endif;
$albaranEntity->fill($sanitizedData);
endif;
if ($noException && $successfulResult):
$id = $albaranEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
$data = [
'error' => 0,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$data = [
'error' => 1,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function getAlbaranes()
{
if ($this->request->isAJAX()) {
$envio_id = $this->request->getGet('envio_id');
$albaranes = $this->model->getAlbaranesEnvio($envio_id);
$data = [
'status' => true,
'data' => $albaranes,
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function getAlbaran()
{
if ($this->request->isAJAX()) {
$id = $this->request->getGet('id');
$albaran = $this->model->getAlbaranData($id);
$data = [
'success' => true,
'data' => $albaran,
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function generateAlbaran()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$envio_id = $reqData['envio_id'] ?? 0;
$envio_lineas = $reqData['envio_lineas'] ?? [];
$cajas = $reqData['cajas'] ?? 0;
$response = $this->model->generarAlbaranes($envio_id, $envio_lineas, $cajas);
return $this->respond($response);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function datatable(){
$pedidosFilter = $this->request->getGet('pedidosFilter');
$q = $this->model->getDatatableQuery();
if($pedidosFilter != null && !empty($pedidosFilter)) {
$q->groupStart();
$q->like('t4.id', $pedidosFilter);
$q->groupEnd();
}
$result = DataTable::of($q)
->add(
"action",
callback: function ($q) {
return '
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="' . $q->id . '"></i></a>
</div>
';
}
);
return $result->toJson(returnAsObject: true);
}
public function datatablesLineasAlbaran()
{
$albaranId = $this->request->getGet('albaranId');
$model = model('App\Models\Albaranes\AlbaranLineaModel');
$q = $model->getDatatableQuery($albaranId);
$result = DataTable::of($q)
->add(
"action",
callback: function ($q) {
return '
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-albaran-lineas mx-2" data-id="' . $q->id . '"></i></a>
</div>
';
}
)
->edit('pedido', function ($q) {
return '<a href="' . base_url('pedidos/edit/' . $q->pedido) . '" target="_blank">' . $q->pedido . '</a>';
})
->edit('unidades', function ($q) {
if(str_contains($q->titulo, 'IVA'))
return null;
else
return '<input type="number" class="form-control form-control-sm input-albaran-linea text-center"
value="' . $q->unidades . '" data-id="' . $q->id . '" data-field="cantidad" />';
})
->edit('titulo', function ($q) {
return '<input type="text" class="form-control form-control-sm input-albaran-linea" value="' . $q->titulo .
'" data-id="' . $q->id . '" data-field="titulo" />';
})
->edit('total', function ($q) {
return '<input class="form-control autonumeric-2 input-albaran-linea
form-control-sm text-center" value="' . $q->total . '" data-id="' . $q->id . '" data-field="total" />';
})
->edit('precio_unidad', function ($q) {
if(str_contains($q->titulo, 'IVA'))
return null;
else
return '<input class="form-control autonumeric-4 form-control-sm text-center input-albaran-linea" value="' .
number_format((float) $q->precio_unidad, 4, ',', '') .
'" data-id="' . $q->id . '" data-field="precio_unidad" />';
});
return $result->toJson(returnAsObject: true);
}
public function updateAlbaranLinea(){
if ($this->request->isAJAX()) {
$model_linea = model('App\Models\Albaranes\AlbaranLineaModel');
$fieldName = $this->request->getPost('fieldName');
$fieldValue = $this->request->getPost('fieldValue');
$id = $this->request->getPost('lineaId');
$linea = $model_linea->find($id);
if ($linea == false) {
$data = [
'success' => false,
'message' => lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]),
];
return $this->respond($data);
}
if($fieldName == 'cantidad') {
$linea->total = round($linea->precio_unidad * intval($fieldValue), 4);
$linea->cantidad = intval($fieldValue);
}
else if($fieldName == 'precio_unidad') {
$fieldValue2 = str_replace(',', '.', $fieldValue);
$linea->total = round(round(floatval($fieldValue2), 4) * intval($linea->cantidad), 2);
$linea->precio_unidad = round(floatval($fieldValue2), 4);
}
else if($fieldName == 'total') {
$linea->total = round(floatval($fieldValue), 2);
$linea->precio_unidad = round(floatval($fieldValue) / intval($linea->cantidad), 4);
}
else{
$linea->$fieldName = $fieldValue;
}
$linea->user_updated_id = auth()->user()->id;
$linea->updated_at = date('Y-m-d H:i:s');
$model_linea->update($id, $linea->toArray());
$data = [
'success' => true,
'message' => lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.',
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function addLineasIva(){
if ($this->request->isAJAX()) {
$albaran_id = $this->request->getPost('albaranId');
$model_linea = model('App\Models\Albaranes\AlbaranLineaModel');
$lineas_albaran = $model_linea->where('albaran_id', $albaran_id)->findAll();
$iva_reducido = 0;
$iva_no_reducido = 0;
foreach ($lineas_albaran as $linea) {
if($linea->iva_reducido == 1) {
$iva_reducido += round(floatval($linea->total)*0.04, 2);
} else {
$iva_no_reducido += round(floatval($linea->total)*0.21, 2);
}
}
$iva_reducido = round($iva_reducido, 2);
$iva_no_reducido = round($iva_no_reducido, 2);
if($iva_reducido > 0) {
$linea = [
'albaran_id' => $albaran_id,
'titulo' => lang('Albaran.iva4'),
'total' => round($iva_reducido, 2),
'user_created_id' => auth()->user()->id,
'user_updated_id' => auth()->user()->id
];
$model_linea->insert($linea);
}
if($iva_no_reducido > 0) {
$linea = [
'albaran_id' => $albaran_id,
'titulo' => lang('Albaran.iva21'),
'total' => round($iva_no_reducido, 2),
'user_created_id' => auth()->user()->id,
'user_updated_id' => auth()->user()->id
];
$model_linea->insert($linea);
}
$data = [
'success' => true,
'message' => lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.',
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function addBlankLineaAlbaran(){
if ($this->request->isAJAX()) {
$albaran_id = $this->request->getPost('albaranId');
$model_linea = model('App\Models\Albaranes\AlbaranLineaModel');
$linea = [
'albaran_id' => $albaran_id,
'user_created_id' => auth()->user()->id,
'user_updated_id' => auth()->user()->id
];
$id_linea = $model_linea->insert($linea);
$data = $model_linea->find($id_linea);
$data = [
'success' => true,
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function borrarLinea()
{
if ($this->request->isAJAX()) {
$model_linea = model('App\Models\Albaranes\AlbaranLineaModel');
$reqData = $this->request->getPost();
$id = $reqData['linea'] ?? 0;
$id = filter_var($id, FILTER_SANITIZE_URL);
$albaranLineaEntity = $model_linea->find($id);
if ($albaranLineaEntity == false):
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
$data = [
'success' => false,
'error' => $message,
];
return $this->respond($data);
endif;
$successfulResult = $model_linea->skipValidation(true)->update($id, ['deleted_at' => date('Y-m-d H:i:s')]);
if ($successfulResult):
$data = [
'success' => true,
];
else:
$data = [
'success' => false,
'error' => lang('Basic.global.deleteError', [lang('Basic.global.record')]) . '.',
];
endif;
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function borrarAlbaran()
{
if ($this->request->isAJAX()) {
$id = $this->request->getPost('albaranId');
$model_linea = model('App\Models\Albaranes\AlbaranLineaModel');
$model_linea->where('albaran_id', $id)->delete();
$this->model->where('id', $id)->delete();
$data = [
'success' => true
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

0
ci4/app/Controllers/BaseResourceController.php Normal file → Executable file
View File

View File

@ -0,0 +1,239 @@
<?php
namespace App\Controllers\Catalogo;
use App\Controllers\BaseResourceController;
use App\Entities\Catalogo\CatalogoLibroEntity;
use App\Models\Catalogo\CatalogoLibroModel;
use App\Models\Clientes\ClienteModel;
use Hermawan\DataTables\DataTable;
class CatalogoLibros extends BaseResourceController
{
protected $modelName = CatalogoLibroModel::class;
protected $format = 'json';
protected static $singularObjectName = 'Catalogo';
protected static $singularObjectNameCc = 'CatalogoLibros';
protected static $pluralObjectName = 'Catalogos';
protected static $pluralObjectNameCc = 'catalogos';
protected static $controllerSlug = 'catalogo';
protected static $viewPath = 'themes/vuexy/form/catalogo/';
protected $indexRoute = 'CatalogoLibrosList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Catalogo.listingPage');
$this->viewData['usingSweetAlert'] = true;
// Breadcrumbs (IMN)
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_catalogo"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_catalogo_libros"), 'route' => route_to('catalogoLibrosList'), 'active' => true]
];
parent::initController($request, $response, $logger);
}
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Catalogo.catalogo')]),
'catalogoLibrosEntity' => new CatalogoLibroEntity(),
'usingServerSideDataTable' => true,
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . 'viewCatalogoLibrosList', $viewData);
}
public function add()
{
if ($this->request->getPost()):
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, true);
$sanitizedData['user_created_id'] = auth()->user()->id;
unset($sanitizedData['isk']);
$noException = true;
if ($successfulResult = $this->canValidate()):
if ($this->canValidate()):
try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
endif;
if ($noException && $successfulResult):
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect):
if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
else:
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['catalogoLibrosEntity'] = isset($sanitizedData) ? new CatalogoLibroEntity($sanitizedData) : new CatalogoLibroEntity();
$this->viewData['formAction'] = route_to('catalogoLibrosAdd');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Catalogo.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null)
{
if ($requestedId == null):
return $this->redirect2listView();
endif;
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
$catalogoLibrosEntity = $this->model->find($id);
if ($catalogoLibrosEntity == false):
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Catalogo.pais')), $id]);
return $this->redirect2listView('sweet-error', $message);
endif;
if ($this->request->getPost()):
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, true);
unset($sanitizedData['isk']);
$sanitizedData['user_update_id'] = auth()->user()->id;
$noException = true;
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()):
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Catalogo.catalogo'))]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$catalogoLibrosEntity->fill($sanitizedData);
$thenRedirect = false;
endif;
if ($noException && $successfulResult):
$id = $catalogoLibrosEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect):
if (!empty($this->indexRoute)):
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
else:
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['catalogoLibrosEntity'] = $catalogoLibrosEntity;
$this->viewData['formAction'] = route_to('catalogoLibrosEdit', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Catalogo.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable()
{
$reqData = $this->request->getGet();
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$q = $this->model->getDatatableQuery()->limit($length, $start);
$result = DataTable::of($q)
->edit(
"portada",
function ($row, $meta) {
if (is_null($row->cubierta_archivo)) {
return '<img class="img-thumbnail" src="' . $row->portada . '" alt="Portada" style="max-height: 80px;">';
} else {
return '';
}
}
)
->add("actionBtns", callback: function ($q) {
$actions = '';
if (auth()->user()->can('catalogo.edit')) {
$actions .= '
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a>
</div>';
}
if (auth()->user()->can('catalogo.delete')) {
$actions .= '
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="' . $q->id . '"></i></a>
</div>';
}
return $actions;
});
return $result->toJson(returnAsObject: true);
}
/* IMN */
public function getClientList()
{
$search = $this->request->getGet("q") ?? "";
$data = (new ClienteModel())->getIdName($search);
return $this->response->setJSON($data);
}
}

36
ci4/app/Controllers/Chat/ChatController.php Normal file → Executable file
View File

@ -222,6 +222,25 @@ class ChatController extends BaseController
return view(static::$viewPath . 'messageChatInternal', $this->viewData);
}
}
public function get_chat_ot_view($chat_id)
{
$chat = $this->chatModel->find($chat_id);
$this->viewData['breadcrumb'] = [
['title' => lang("Chat.chat"), 'route' => route_to("mensajeriaView"), 'active' => false],
['title' => $chat->title, 'route' => 'javascript:void(0);', 'active' => true]
];
$this->viewData["modelId"] = $chat->orden_trabajo_id;
$this->viewData["type"] = "ot";
$auth_user = auth()->user();
$this->chatModel->setAsViewedChatUserNotifications($chat_id, $auth_user->id);
$this->chatModel->setAsUnviewedChatUserMessages($chat_id, $auth_user->id);
if ($chat->chat_department_id) {
return view(static::$viewPath . 'messageChatFactura', $this->viewData);
} else {
return view(static::$viewPath . 'messageChatInternal', $this->viewData);
}
}
public function get_chat(int $chat_id)
{
@ -502,6 +521,23 @@ class ChatController extends BaseController
->toJson(true);
}
public function datatable_ot_messages()
{
$auth_user_id = auth()->user()->id;
$isAdmin = auth()->user()->inGroup('admin');
$query = $this->chatModel->getQueryDatatableMessageOrdenTrabajo($auth_user_id);
return DataTable::of($query)
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
->edit('updated_at', fn($q) => $q->updated_at ? Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i") : "")
->edit("creator",fn($q) => $q->userId == $auth_user_id ? '<span class="badge text-bg-success w-100">'.lang("App.me").'</span>' : $q->creator)
->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->chatMessageId))
->add("action", fn($q) => ["type" => "ot", "modelId" => $q->id, "isAdmin" => $isAdmin,"chatMessageId" => $q->chatMessageId, "lang" => [
"view_chat" => lang('Chat.view_chat'),
"view_by_alt_message" => lang('Chat.view_by_alt_message')
]])
->toJson(true);
}
public function get_notifications_not_viewed_from_message(int $chat_message_id)
{
$unviewedNotifications = $this->chatModel->getUsersNotificationNotViewedFromChat($chat_message_id);

View File

@ -154,7 +154,6 @@ class Clienteplantillaprecioslineas extends \App\Controllers\BaseResourceControl
Field::inst( 'tipo_maquina' ),
Field::inst( 'tipo_impresion' ),
Field::inst( 'user_updated_id' ),
Field::inst( 'deleted_at' ),
Field::inst( 'updated_at' ),
Field::inst( 'tiempo_min' )
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')

0
ci4/app/Controllers/Clientes/Clienteusuarios.php Normal file → Executable file
View File

View File

@ -383,4 +383,26 @@ class Proveedores extends \App\Controllers\BaseResourceController {
}
}
public function getForSelect(){
if ($this->request->isAJAX()) {
$tipo_id = $this->request->getGet("tipo_id");
$query = $this->model->builder()->select(
[
"id",
"nombre as name"
]
)->where('tipo_id', $tipo_id)->where('deleted_at', null)->orderBy("nombre", "asc");
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("lg_proveedores.nombre", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

0
ci4/app/Controllers/Configuracion/ConfigErrores.php Normal file → Executable file
View File

0
ci4/app/Controllers/Configuracion/ConfigVariables.php Normal file → Executable file
View File

View File

@ -0,0 +1,103 @@
<?php
namespace App\Controllers\Configuracion;
use App\Controllers\BaseController;
use App\Controllers\BaseResourceController;
use App\Entities\Configuracion\FestivoEntity;
use App\Models\Collection;
use App\Entities\Configuracion\Imposicion;
use App\Models\Configuracion\FestivoModel;
use App\Models\Configuracion\ImposicionEsquemaModel;
use App\Models\Configuracion\ImposicionModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Validation\Validation;
use Hermawan\DataTables\DataTable;
use Psr\Log\LoggerInterface;
class FestivoController extends BaseController
{
protected $modelName = FestivoModel::class;
protected FestivoModel $model;
protected static $controllerSlug = 'festivos';
protected $format = 'json';
protected string $viewPath = 'themes/vuexy/form/configuracion/festivos/';
protected $indexRoute = 'festivoList';
protected array $viewData = [];
protected Validation $validation;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Festivos.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
$this->model = model($this->modelName);
$this->validation = service("validation");
parent::initController($request, $response, $logger);
}
public function index()
{
return view($this->viewPath . $this->indexRoute);
}
public function store_festivo_date()
{
$bodyData = $this->request->getPost();
$date = $bodyData['date'];
$count = $this->model->where('date',$date)->countAllResults();
if ($count) {
$status = $this->model->where('date', $date)->delete(purge: true);
return $this->response->setJSON([
"message" => lang("App.user_alert_delete"),
"status" => $status,
]);
} else {
$status = $this->model->insert($bodyData);
if ($status) {
$festivoEntity = $this->model->find($status);
return $this->response->setJSON([
"message" => lang("App.global_alert_save_success"),
"status" => $status,
"data" => $festivoEntity
]);
} else {
return $this->response->setJSON([
"message" => lang("App.global_alert_save_error"),
"errors" => $this->model->errors(),
"status" => true
])->setStatusCode(400);
}
}
}
public function delete_festivo_date($id)
{
$status = $this->model->delete($id, true);
if ($status) {
return $this->response->setJSON([
"message" => lang("App.user_alert_delete"),
"status" => $status,
]);
} else {
return $this->response->setJSON([
"message" => lang("App.global_alert_save_error"),
"errors" => $this->model->errors(),
"status" => true
])->setStatusCode(400);
}
}
public function find_all()
{
$festivos = $this->model->findAll();
return $this->response->setJSON([
"message" => lang("App.global_alert_fetch_success"),
"status" => true,
"data" => $festivos
]);
}
}

0
ci4/app/Controllers/Configuracion/FormasPago.php Normal file → Executable file
View File

View File

@ -2,37 +2,41 @@
namespace App\Controllers\Configuracion;
use App\Controllers\BaseController;
use App\Controllers\BaseResourceController;
use App\Models\Collection;
use App\Entities\Configuracion\Imposicion;
use App\Models\Configuracion\ImposicionEsquemaModel;
use App\Models\Configuracion\ImposicionModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Validation\Validation;
use Hermawan\DataTables\DataTable;
use Psr\Log\LoggerInterface;
class Imposiciones extends \App\Controllers\BaseResourceController
class Imposiciones extends BaseController
{
protected $modelName = ImposicionModel::class;
protected $format = 'json';
protected static $singularObjectName = 'Imposicion';
protected static $singularObjectNameCc = 'imposicion';
protected static $pluralObjectName = 'Imposiciones';
protected static $pluralObjectNameCc = 'imposiciones';
protected ImposicionModel $model;
protected ImposicionEsquemaModel $imposicionEsquemaModel;
protected static $controllerSlug = 'imposiciones';
protected $format = 'json';
protected static $viewPath = 'themes/vuexy/form/configuracion/imposiciones/';
protected $indexRoute = 'imposicionList';
protected array $viewData = [];
protected Validation $validation;
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Imposiciones.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
$this->model = model($this->modelName);
$this->validation = service("validation");
$this->imposicionEsquemaModel = model(ImposicionEsquemaModel::class);
parent::initController($request, $response, $logger);
}
@ -47,7 +51,10 @@ class Imposiciones extends \App\Controllers\BaseResourceController
'usingServerSideDataTable' => true,
];
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => true],
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . 'viewImposicionList', $viewData);
@ -56,234 +63,153 @@ class Imposiciones extends \App\Controllers\BaseResourceController
public function add()
{
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => true],
if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
endif;
if ($noException && $successfulResult) :
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
else:
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['imposicion'] = isset($sanitizedData) ? new Imposicion($sanitizedData) : new Imposicion();
$this->viewData['orientacionList'] = $this->getOrientacionOptions();
$this->viewData['formAction'] = route_to('createImposicion');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Imposiciones.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null)
];
return view(static::$viewPath . 'viewImposicionNewForm', $this->viewData);
}
public function add_esquema()
{
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => true],
];
$this->viewData["imposicion_esquema"] = null;
if ($requestedId == null) :
return $this->redirect2listView();
endif;
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
$imposicion = $this->model->find($id);
return view(static::$viewPath . 'viewImposicionEsquemaForm', $this->viewData);
}
public function edit($imposicion_id = null)
{
if ($imposicion_id) {
$this->viewData["imposicion"] = $this->model->find($imposicion_id);
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => false],
['title' => $this->viewData["imposicion"]->full_name, 'route' => route_to("updateImposicionForm", $imposicion_id), 'active' => true],
if ($imposicion == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Imposiciones.imposicion')), $id]);
return $this->redirect2listView('sweet-error', $message);
endif;
];
}
return view(static::$viewPath . 'viewImposicionForm', $this->viewData);
}
public function edit_imposicion_esquema($imposicion_esquema_id = null)
{
if ($imposicion_esquema_id) {
$this->viewData["imposicion_esquema"] = $this->imposicionEsquemaModel->find($imposicion_esquema_id);
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_imposiciones"), 'route' => route_to("imposicionList"), 'active' => false],
['title' => $this->viewData["imposicion_esquema"]->name, 'route' => route_to("updateImposicionEsquemaForm", $imposicion_esquema_id), 'active' => true],
if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Imposiciones.imposicion'))]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$imposicion->fill($sanitizedData);
$thenRedirect = false;
endif;
if ($noException && $successfulResult) :
$id = $imposicion->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
else:
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['imposicion'] = $imposicion;
$this->viewData['orientacionList'] = $this->getOrientacionOptions();
$this->viewData['formAction'] = route_to('updateImposicion', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Imposiciones.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
];
}
return view(static::$viewPath . 'viewImposicionEsquemaForm', $this->viewData);
}
public function update($imposicion_id = null)
{
if ($imposicion_id) {
$bodyData = $this->request->getPost();
if(isset($bodyData["imposicion_esquema_id"])){
if($bodyData["imposicion_esquema_id"] == ""){
$bodyData["imposicion_esquema_id"] = null;
}
}
$status = $this->model->update($imposicion_id, $bodyData);
if ($status) {
$imposicionEntity = $this->model->find($imposicion_id);
} else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "errors" => $this->model->errors(), "status" => true])->setStatusCode(400);
}
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status, "data" => $imposicionEntity]);
} else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "message" => "", "status" => false])->setStatusCode(400);
}
}
public function update_imposicion_esquema($imposicion_esquema_id = null)
{
if ($imposicion_esquema_id) {
$bodyData = $this->request->getPost();
$status = $this->imposicionEsquemaModel->update($imposicion_esquema_id, $bodyData);
if ($status) {
$imposicionEsquemaEntity = $this->imposicionEsquemaModel->find($imposicion_esquema_id);
} else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "errors" => $this->imposicionEsquemaModel->errors(), "status" => true])->setStatusCode(400);
}
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status, "data" => $imposicionEsquemaEntity]);
} else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "message" => "", "status" => false])->setStatusCode(400);
}
}
public function delete($imposicion_id = null)
{
$status = $this->model->delete($imposicion_id);
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true]);
}
public function delete_imposicion_esquema($imposicion_esquema_id = null)
{
$status = $this->imposicionEsquemaModel->delete($imposicion_esquema_id);
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => $status]);
}
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$search = $reqData['search']['value'];
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
$order = ImposicionModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
return $this->respond(Collection::datatable(
$resourceData,
$this->model->getResource()->countAllResults(),
$this->model->getResource($search)->countAllResults()
));
} else {
return $this->failUnauthorized('Invalid request', 403);
}
$q = $this->model->queryDatatable();
return DataTable::of($q)
->add('esquema', fn($q) => ["imposicionId" => $q->id,"esquemaId" => $q->esquemaId, "esquemaName" => $q->esquemaName])
->add(
'action',
fn($q) => "<div class='btn-group btn-group-md gap-2 w-100 d-flex justify-space-between'>" . ImposicionModel::datatable_buttons($q->id) . "</div>"
)
->toJson(true);
}
public function allItemsSelect()
public function datatable_imposicion_esquema()
{
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal . ', ancho', 'ancho', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->ancho = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function menuItems()
{
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
$reqText = goSanitize($this->request->getPost('text'))[0];
$onlyActiveOnes = false;
$columns2select = [$reqId ?? 'id', $reqText ?? 'ancho'];
$onlyActiveOnes = false;
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
array_unshift($menu, $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
$q = $this->imposicionEsquemaModel->queryDatatable();
return DataTable::of($q)
->add(
'action',
fn($q) => "<div class='btn-group btn-group-md gap-2'>" . ImposicionEsquemaModel::datatable_buttons($q->id) . "</div>"
)
->toJson(true);
}
protected function getOrientacionOptions()
{
$orientacionOptions = [
'' => lang('Basic.global.pleaseSelect'),
'H' => 'H',
'V' => 'V',
];
return $orientacionOptions;
}
public function selectImposicion()
{
$data = $this->model->querySelect($this->request->getGet('q'));
return $this->response->setJSON($data);
}
public function selectImposicionEsquema()
{
$data = $this->imposicionEsquemaModel->querySelect($this->request->getGet('q'));
return $this->response->setJSON($data);
}
public function find_imposicion(int $imposicion_id)
{
$imposicionEntity = $this->model->find($imposicion_id)->withImposicionEsquema();
return $this->response->setJSON($imposicionEntity);
}
public function find_imposicion_esquema(int $imposicion_esquema_id)
{
$imposicionEsquemaEntity = $this->imposicionEsquemaModel->find($imposicion_esquema_id);
return $this->response->setJSON($imposicionEsquemaEntity);
}
public function create()
{
$bodyData = $this->request->getPost();
$createdId = $this->model->insert($bodyData);
if ($createdId) {
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true]);
} else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "errors" => $this->model->errors(), "status" => true])->setStatusCode(400);
}
}
public function create_imposicion_esquema()
{
$bodyData = $this->request->getPost();
$createdId = $this->imposicionEsquemaModel->insert($bodyData);
if ($createdId) {
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true]);
} else {
return $this->response->setJSON(["message" => lang("App.global_alert_save_error"), "errors" => $this->imposicionEsquemaModel->errors(), "status" => true])->setStatusCode(400);
}
}
}

0
ci4/app/Controllers/Configuracion/MaquinaTarea.php Normal file → Executable file
View File

0
ci4/app/Controllers/Configuracion/SeriesFacturas.php Normal file → Executable file
View File

0
ci4/app/Controllers/Configuracion/Ubicaciones.php Normal file → Executable file
View File

View File

@ -1,4 +1,6 @@
<?php namespace App\Controllers\Configuracion;
<?php
namespace App\Controllers\Configuracion;
use App\Entities\Usuarios\UserEntity;
use App\Models\Chat\ChatDeparmentModel;
@ -54,7 +56,6 @@ class Users extends \App\Controllers\GoBaseController
];
parent::initController($request, $response, $logger);
}
public function index()
@ -87,7 +88,7 @@ class Users extends \App\Controllers\GoBaseController
// Marcar el username como NULL
$sanitizedData = $this->sanitized($postData, true);
$noException = true;
// Obtener proveedor de usuarios
@ -118,11 +119,10 @@ class Users extends \App\Controllers\GoBaseController
} // Email is not unique!
else {
$this->viewData['errorMessage'] = "El correo '". $sanitizedData['email'] ."' ya está registrado en el sistema";
$this->viewData['errorMessage'] = "El correo '" . $sanitizedData['email'] . "' ya está registrado en el sistema";
$this->session->setFlashdata('formErrors', $this->model->errors());
$successfulResult = false; // Hacked
}
} catch (\Exception $e) {
$noException = false;
$this->viewData['errorMessage'] = $e->getMessage();
@ -234,7 +234,6 @@ class Users extends \App\Controllers\GoBaseController
} else {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
}
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
@ -319,8 +318,6 @@ class Users extends \App\Controllers\GoBaseController
$message = "Usuario eliminado correctamente";
return $this->redirect2listView('successMessage', $message);
} // end function delete(...)
@ -374,9 +371,10 @@ class Users extends \App\Controllers\GoBaseController
}
}
public function datatable(){
public function datatable()
{
if($this->request->isAJAX()){
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
@ -405,7 +403,6 @@ class Users extends \App\Controllers\GoBaseController
$this->model->getResource([])->countAllResults(),
$this->model->getResource($searchValues)->countAllResults()
));
} else {
return $this->failUnauthorized('Invalid request', 403);
}
@ -447,4 +444,27 @@ class Users extends \App\Controllers\GoBaseController
return $data;
}
public function index_maquinista_change_user()
{
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_change_session"), 'route' => route_to('maquinistaUserChangeList'), 'active' => true]
];
$maquinistas = [];
$users = auth()->getProvider()->whereNotIn('id',[auth()->user()->id])->findAll();
foreach ($users as $key => $user) {
if ($user->inGroup('maquina') && !$user->inGroup('admin', 'comercial', 'cliente-editor', 'cliente-admin')) {
$maquinistas[] = $user;
}
}
$this->viewData['maquinistas'] = $maquinistas;
return view('/themes/vuexy/form/produccion/maquinista/viewMaquinistaCambioUserList.php', $this->viewData);
}
public function change_user_session(int $user_id)
{
// Check the credentials
$user = auth()->getProvider()->findById($user_id);
auth()->logout();
auth()->login($user);
return redirect("home");
}
}

0
ci4/app/Controllers/Excel/PrintGiros.php Normal file → Executable file
View File

0
ci4/app/Controllers/Excel/PrintLineas.php Normal file → Executable file
View File

View File

@ -787,6 +787,32 @@ class Facturas extends \App\Controllers\BaseResourceController
}
}
public function deleteLineaPago()
{
if ($this->request->isAJAX()) {
$postData = $this->request->getPost();
$factura_id = $postData['factura_id'] ?? 0;
$pago_id = $postData['pago_id'] ?? 0;
$model_factura_pago = model('\App\Models\Facturas\FacturaPagoModel');
$model_factura_pago->update($pago_id, [
'deleted_at' => date('Y-m-d H:i:s'),
'user_updated_id' => auth()->user()->id,
]);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function validar($factura_id)
{

178
ci4/app/Controllers/Facturacion/FacturasLineas.php Normal file → Executable file
View File

@ -16,14 +16,15 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
protected static $controllerSlug = 'factura-lineas';
public function datatable($factura_id = null){
public function datatable($factura_id = null)
{
if ($this->request->isAJAX() && $factura_id != null) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
@ -46,31 +47,32 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
}
public function deleteLinea($factura_linea_id = 0){
public function deleteLinea($factura_linea_id = 0)
{
if (!empty(static::$pluralObjectNameCc) && !empty(static::$singularObjectNameCc)) {
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc).'.'.static::$singularObjectNameCc));
$objName = mb_strtolower(lang(ucfirst(static::$pluralObjectNameCc) . '.' . static::$singularObjectNameCc));
} else {
$objName = lang('Basic.global.record');
}
if($factura_linea_id == 0){
if ($factura_linea_id == 0) {
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
}
$facturaLinea = $this->model->find($factura_linea_id);
if($facturaLinea == null){
if ($facturaLinea == null) {
return $this->failNotFound(lang('Basic.global.deleteError', [$objName]));
}
if($facturaLinea->pedido_linea_impresion_id != null){
$this->model->deleteFacturasLineasPedido($facturaLinea->factura_id, $facturaLinea->pedido_linea_impresion_id, $facturaLinea->cantidad);
if ($facturaLinea->pedido_linea_impresion_id != null) {
$this->model->deleteFacturasLineasPedido($facturaLinea->factura_id, $facturaLinea->pedido_linea_impresion_id, $facturaLinea->cantidad);
}
if($facturaLinea->pedido_maquetacion_id != null){
if ($facturaLinea->pedido_maquetacion_id != null) {
//$this->model->deleteFacturasLineasPedido($facturaLinea->factura_id, $facturaLinea->pedido_maquetacion_id, $facturaLinea->cantidad);
}
$facturaLinea = $this->model->delete($factura_linea_id);
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
$response = $this->respondDeleted(['id' => $factura_linea_id, 'msg' => $message]);
@ -78,51 +80,86 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
}
public function datatable_editor() {
public function datatable_editor()
{
if ($this->request->isAJAX()) {
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
// Build our Editor instance and process the data coming from _POST
$response = Editor::inst( $db, 'facturas_lineas' )
$response = Editor::inst($db, 'facturas_lineas')
->fields(
Field::inst( 'id' ),
Field::inst( 'base' ),
Field::inst( 'total_iva' ),
Field::inst( 'total' ),
Field::inst( 'cantidad' )
->validator('Validate::numeric', array(
'message' => lang('Facturas.validation.numerico'))
Field::inst('id'),
Field::inst('base'),
Field::inst('total_iva'),
Field::inst('total'),
Field::inst('cantidad')
->validator(
'Validate::numeric',
array(
'message' => lang('Facturas.validation.numerico')
)
)
->validator('Validate::notEmpty', array(
'message' => lang('Facturas.validation.requerido'))
->validator(
'Validate::notEmpty',
array(
'message' => lang('Facturas.validation.requerido')
)
),
Field::inst( 'descripcion' )
->validator('Validate::notEmpty', array(
'message' => lang('Facturas.validation.requerido'))
Field::inst('descripcion')
->validator(
'Validate::notEmpty',
array(
'message' => lang('Facturas.validation.requerido')
)
),
Field::inst( 'iva' )
->validator('Validate::numeric', array(
'message' => lang('Facturas.validation.numerico'))
Field::inst('iva')
->validator(
'Validate::numeric',
array(
'message' => lang('Facturas.validation.numerico')
)
)
->validator('Validate::notEmpty', array(
'message' => lang('Facturas.validation.requerido'))
->validator(
'Validate::notEmpty',
array(
'message' => lang('Facturas.validation.requerido')
)
),
Field::inst( 'pedido_linea_impresion_id' )
->setFormatter(function($val, $data, $opts) {
Field::inst('total')
->validator(
'Validate::numeric',
array(
'message' => lang('Facturas.validation.numerico')
)
)
->validator(
'Validate::notEmpty',
array(
'message' => lang('Facturas.validation.requerido')
)
),
Field::inst('pedido_linea_impresion_id')
->setFormatter(function ($val, $data, $opts) {
return $val === '' ? null : $val;
}),
Field::inst( 'factura_id' ),
Field::inst( 'user_updated_id' ),
Field::inst('pedido_maquetacion_id')
->setFormatter(function ($val, $data, $opts) {
return $val === '' ? null : $val;
}),
Field::inst('factura_id'),
Field::inst('user_updated_id'),
)
->on('preCreate', function ($editor, &$values) {
$totales = $this->generate_totales(
$values['factura_id'],
$values['pedido_linea_impresion_id'],
$values['total'],
$values['iva'],
$values['factura_id'],
$values['pedido_linea_impresion_id'],
$values['total'],
$values['iva'],
$values['cantidad'],
$values['old_cantidad']);
$values['old_cantidad'],
$values['base']
);
$editor
->field('user_updated_id')
->setValue(auth()->user()->id);
@ -141,12 +178,14 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
})
->on('preEdit', function ($editor, $id, &$values) {
$totales = $this->generate_totales(
$values['factura_id'],
$values['pedido_linea_impresion_id'],
$values['total'],
$values['iva'],
$values['factura_id'],
$values['pedido_linea_impresion_id'],
$values['total'],
$values['iva'],
$values['cantidad'],
$values['old_cantidad']);
$values['old_cantidad'],
$values['base']
);
$editor
->field('factura_id')
->setValue($values['factura_id']);
@ -185,8 +224,9 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
}
}
public function updateTotalesFactura($factura_id = 0){
if($factura_id == 0){
public function updateTotalesFactura($factura_id = 0)
{
if ($factura_id == 0) {
return;
}
@ -194,26 +234,42 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
$model->updateTotales($factura_id);
}
private function generate_totales($factura_id, $pedido_linea_id, $total, $iva, $cantidad, $old_cantidad)
private function generate_totales($factura_id, $pedido_linea_id, $total, $iva, $cantidad, $old_cantidad, $base_input)
{
// si es una linea que se refiere a pedido
if ($pedido_linea_id != null && $factura_id != null) {
// se actualiza la cantidad de la linea de pedido en la tabla pivote facturas_pedidos_lineas
$this->model->updateFacturaPedidoLinea($factura_id, $pedido_linea_id, $old_cantidad, $cantidad);
}
// se calcula y se actualiza el subtotal, total_iva y total
// redondeando a 4 decimales el precio_unidad y a dos el resto
$precio_unidad = round($total / $old_cantidad, 4);
$base = round($precio_unidad * $cantidad, 2);
$total_iva = round($base * $iva / 100, 2);
$total = round($base + $total_iva, 2);
$values = [];
$values['base'] = $base;
$values['total_iva'] = $total_iva;
$values['total'] = $total;
// Si es una linea añadida a mano, el total y el iva tienen que venir metidos a mano
if ($pedido_linea_id != null) {
// se calcula y se actualiza el subtotal, total_iva y total
// redondeando a 4 decimales el precio_unidad y a dos el resto
$precio_unidad = round($total / $old_cantidad, 4);
$base = round($precio_unidad * $cantidad, 2);
$total_iva = round($base * $iva / 100, 2);
$total = round($base + $total_iva, 2);
$values = [];
$values['base'] = $base;
$values['total_iva'] = $total_iva;
$values['total'] = $total;
}
else{
// se pasa la base y el iva
$total_iva = round($base_input * $iva / 100, 2);
$total = round($base_input + $total_iva, 2);
$values = [];
$values['base'] = $base_input;
$values['total_iva'] = $total_iva;
$values['total'] = $total;
}
return $values;
}
}

0
ci4/app/Controllers/Facturacion/FacturasPagos.php Normal file → Executable file
View File

View File

@ -0,0 +1,396 @@
<?php
namespace App\Controllers\Importadores;
use App\Controllers\BaseResourceController;
use App\Controllers\Presupuestos\Presupuestocliente;
use App\Services\PresupuestoService;
class ImportadorBubok extends BaseResourceController
{
protected $format = 'json';
protected static $singularObjectName = 'Importador';
protected static $singularObjectNameCc = 'ImportadorBubok';
protected static $pluralObjectName = 'Importadores';
protected static $pluralObjectNameCc = 'importadores';
protected static $controllerSlug = 'importador';
protected static $viewPath = 'themes/vuexy/form/importador/bubok/';
protected $indexRoute = 'ImportadorBubokTool';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Importador.listingPage');
$this->viewData['usingSweetAlert'] = true;
// Breadcrumbs (IMN)
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_importadores"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_importadores_bubok"), 'route' => route_to('importadorBubokTool'), 'active' => true]
];
parent::initController($request, $response, $logger);
}
public function index()
{
$viewData = [
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Importador.importadorCatalogoTitle')]),
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . 'viewImportadorBubokTool', $viewData);
}
public function importarFila()
{
$json = $this->request->getJSON();
// Validación mínima de datos comunes
$pedido = $json->pedido ?? null;
if (!$pedido || !isset($pedido->orderNumber)) {
return $this->respond([
'status' => 400,
'message' => 'Datos comunes del pedido ausentes o inválidos.'
]);
}
// Validación mínima de existencia del producto en la linea
if (!$json || !isset($json->producto)) {
return $this->respond([
'status' => 400,
'message' => 'Producto no proporcionado o inválido.'
]);
}
$producto = $json->producto;
// 1. Datos básicos:
// Referencia del cliente
$orderNumber = $pedido->orderNumber ?? null;
$productId = $producto->id ?? null;
if (is_null($orderNumber) || is_null($productId)) {
return $this->respond([
'status' => 400,
'message' => 'Número de orden o ID del producto no reconocidos.'
]);
}
$refCliente = "$orderNumber - $productId";
// Titulo
$titulo = $producto->title ?? null;
if (is_null($titulo)) {
return $this->respond([
'status' => 400,
'message' => 'Título del libro no reconocido.'
]);
}
// Validación de páginas y tirada
$paginas = isset($producto->body->pages) ? (int) $producto->body->pages : 0;
$tirada = isset($producto->amount) ? (int) $producto->amount : 0;
if ($paginas <= 0 || $tirada <= 0) {
$errores = [];
if ($paginas <= 0) {
$errores[] = 'Número de páginas inválido.';
}
if ($tirada <= 0) {
$errores[] = 'Tirada inválida.';
}
return $this->respond([
'status' => 400,
'message' => implode(' ', $errores)
]);
}
// Ancho y alto
$ancho = null;
$alto = null;
foreach ($producto->size as $key => $val) {
if ($val == 1) {
// ejemplo: size170x235
$size = str_replace('size', '', $key);
[$ancho, $alto] = explode('x', $size);
$ancho = (int) $ancho;
$alto = (int) $alto;
break;
}
}
if (!$ancho || !$alto) {
return $this->respond([
'status' => 400,
'message' => 'Tamaño del libro no reconocido.'
]);
}
/*$numGuardaPages = 4;
$hasGuarda = !empty($producto->cover->guarda);
if ($hasGuarda)
$paginas += $numGuardaPages;*/
// 2. Interior: color o negro
// Determinar tipo de impresión interior
$interiorTipo = null;
if (isset($producto->body->color->CMYK) && $producto->body->color->CMYK == '1') {
$interiorTipo = 'color';
} elseif (isset($producto->body->color->Monochrome) && $producto->body->color->Monochrome == '1') {
$interiorTipo = 'negro';
} elseif (isset($producto->body->color->Semicolor) && $producto->body->color->Semicolor == '1') {
return $this->respond([
'status' => 400,
'message' => 'Tipo de impresión "Semicolor" no soportado.'
]);
}
if (is_null($interiorTipo)) {
return $this->respond([
'status' => 400,
'message' => 'No se pudo determinar si el interior es en color o blanco y negro.'
]);
}
// Determinar tipo de papel interior
$papelInteriorId = null;
if (isset($producto->body->paperColor->white) && $producto->body->paperColor->white == '1') {
$papelInteriorId = 3; // Offset blanco 'OFF1'
} elseif (isset($producto->body->paperColor->cream) && $producto->body->paperColor->cream == '1') {
$papelInteriorId = 4; // Offset ahuesado 'OFF2'
} else {
return $this->respond([
'status' => 400,
'message' => 'Tipo de papel interior no definido.'
]);
}
// Determinar el gramaje del papel
$gramajePapelInterior = null;
foreach ($producto->body->paperWeight as $key => $val) {
if ($val == 1) {
$gramajePapelInterior = (int) str_replace(['weight', 'gr'], '', $key);
break;
}
}
if (!$gramajePapelInterior) {
return $this->respond([
'status' => 400,
'message' => 'Gramaje del papel no válido.'
]);
}
// 3. Encuadernación
// Tapa dura
$tapaDura = isset($producto->cover->type->tapadura) && $producto->cover->type->tapadura == '1';
// Solapas
$solapas = isset($producto->cover->type->consolapas) && $producto->cover->type->consolapas == '1';
// Doble cara (a veces se activa con tapa dura) una cara => 2; dos caras => 4
$doscara = false;
// Tipo de encuadernado
$encuadernadoId = null;
if (isset($producto->cover->coverType->SoftCover) && $producto->cover->coverType->SoftCover == '1') {
if ($tapaDura) {
$encuadernadoId = 1; // Libro fresado tapa dura
$doscara = true;
} else {
$encuadernadoId = 2; // Libro fresado tapa blanda
}
} elseif (isset($producto->cover->coverType->SaddleStitch) && $producto->cover->coverType->SaddleStitch == '1') {
if ($tapaDura) {
$encuadernadoId = 3; // Libro cosido tapa dura
$doscara = true;
} else {
$encuadernadoId = $solapas ? 20 : 4; // Libro cosido tapa blanda (solapas) : (sin solapas)
}
} elseif (isset($producto->cover->coverType->CoilBinding) && $producto->cover->coverType->CoilBinding == '1') {
if ($tapaDura) {
$encuadernadoId = 5; // Libro espiral tapa dura
$doscara = true;
} else {
$encuadernadoId = 6; // Libro espiral tapa blanda
}
}
if (!$encuadernadoId) {
return $this->respond([
'status' => 400,
'message' => 'Tipo de encuadernación no identificado.'
]);
}
// Determinar el acabado de la cubierta
$acabadoId = null;
if (isset($producto->cover->acabado->brillo) && $producto->cover->acabado->brillo == '1') {
$acabadoId = 1; // Plastificado brillo 1/c
} elseif (isset($producto->cover->acabado->mate) && $producto->cover->acabado->mate == '1') {
$acabadoId = 2; // Plastificado mate 1/c
} else {
return $this->respond([
'status' => 400,
'message' => 'Tipo de acabado de cubierta no definido.'
]);
}
// 4. ENVÍO: recuperamos la primera dirección del cliente BUBOK (ID 40)
$clienteDireccionModel = model('App\Models\Clientes\ClienteDireccionesModel');
$direccionCliente = $clienteDireccionModel
->where('cliente_id', 40)
->orderBy('id', 'asc')
->first();
if (!$direccionCliente) {
return $this->respond([
'status' => 400,
'message' => 'El cliente Bubok no tiene direcciones asociadas.'
]);
}
$direcciones = [
[
'direccion' => [
'id' => (int) $direccionCliente->id,
'cliente_id' => (int) $direccionCliente->cliente_id,
'cliente_nombre' => $direccionCliente->clienteNombre,
'att' => $direccionCliente->persona_contacto ?? '',
'alias' => $direccionCliente->alias ?? '',
'email' => $direccionCliente->email ?? '',
'direccion' => $direccionCliente->direccion,
'pais_id' => (int) $direccionCliente->pais_id,
'pais' => $direccionCliente->paisNombre,
'municipio' => $direccionCliente->municipio,
'provincia' => $direccionCliente->provincia,
'cp' => $direccionCliente->cp,
'telefono' => $direccionCliente->telefono,
],
'unidades' => $tirada,
'entregaPalets' => false
]
];
// Generamos el objeto a importar
$dataToImport = [
'selectedTirada' => $tirada,
'datosCabecera' => [
'titulo' => $titulo,
'autor' => null,
'isbn' => null,
'coleccion' => null,
'referenciaCliente' => $refCliente
],
'tirada' => [$tirada],
'tamanio' => [
'ancho' => $ancho,
'alto' => $alto
],
'tipo' => '',
'tipo_presupuesto_id' => $encuadernadoId,
'clienteId' => 40, // BUBOK ID
'isColor' => ($interiorTipo === 'color') ? 1 : 0,
'isHq' => 0,
'paginas' => $paginas,
'paginasColor' => ($interiorTipo === 'color') ? $paginas : 0,
'paginasCuadernillo' => 32,
'interior' => [
'papelInterior' => $papelInteriorId,
'gramajeInterior' => $gramajePapelInterior
],
'cubierta' => [
'papelCubierta' => 2, // 'EST2'
'carasCubierta' => $doscara ? 2 : 4,
'gramajeCubierta' => in_array($encuadernadoId, [1, 3]) ? 150 : 300, // 150 gramos para "fresado tapa dura" y "cosido tapa dura"
'solapas' => !empty($producto->cover->type->consolapas) ? 80 : 0,
'acabado' => $acabadoId,
'cabezada' => 'WHI',
'lomoRedondo' => 0
],
'guardas' => [],
'sobrecubierta' => [],
'faja' => null,
'entrega_taller' => 1,
//'direcciones' => $direcciones, las direcciones que aparecen no se añaden, ya que la recogida la hacen ellos con su empresa de mensajeria
'ivaReducido' => 1,
];
/*return $this->respond([
'status' => 400,
'message' => $dataToImport
]);*/
// 5. Guardar
try {
$presupuestocliente = new Presupuestocliente();
$response = $presupuestocliente->guardar($dataToImport);
// Guardar la URL de la portada y el cuerpo en los comentarios del presupuesto
$presupuestoModel = model('App\Models\Presupuestos\PresupuestoModel');
$presupuestoModel->update($response['sk_id'], [
'comentarios_safekat' => 'URL COVER: ' . $producto->cover->file . "\nURL BODY: " . $producto->body->file,
]);
// Ajuste del precio
$precio_compra = $json->producto->prices->unitPrice ?? null;
if ($precio_compra != null && $precio_compra > 0) {
$respuesta_ajuste = PresupuestoService::ajustarPresupuesto(
$response['sk_id'],
$precio_compra,
$tirada,
null,
true
);
if ($respuesta_ajuste['warning'] == true) {
$response['price_warning'] = [
'new_precio_unidad' => $respuesta_ajuste['new_precio_unidad'],
'new_total' => $respuesta_ajuste['new_total'],
];
}
}
// confirmar y crear pedido y ot
$presupuestoModel->confirmarPresupuesto($response['sk_id']);
PresupuestoService::crearPedido($response['sk_id']);
if (!isset($response['sk_id'])) {
return $this->respond([
'status' => 400,
'error' => 'Missing sk_id',
'message' => 'No se pudo crear el presupuesto.'
], 400);
}
return $this->respond([
'status' => 200,
'data' => [
'sk_id' => $response['sk_id'],
'sk_url' => $response['sk_url'] ?? null
]
]);
} catch (\Throwable $e) {
return $this->respond([
'status' => 500,
'error' => 'Server error',
'message' => 'Error inesperado',
'debug' => $e->getMessage()
]);
}
}
}

View File

@ -0,0 +1,322 @@
<?php
namespace App\Controllers\Importadores;
use App\Controllers\BaseResourceController;
use App\Entities\Catalogo\CatalogoLibroEntity;
use App\Models\Catalogo\CatalogoLibroModel;
use App\Controllers\Presupuestos\Presupuestocliente;
use App\Services\PresupuestoService;
class ImportadorCatalogo extends BaseResourceController
{
protected $modelName = CatalogoLibroModel::class;
protected $format = 'json';
protected static $singularObjectName = 'Importador';
protected static $singularObjectNameCc = 'ImportadorCatalogo';
protected static $pluralObjectName = 'Importadores';
protected static $pluralObjectNameCc = 'importadores';
protected static $controllerSlug = 'importador';
protected static $viewPath = 'themes/vuexy/form/importador/catalogo/';
protected $indexRoute = 'ImportadorCatalogoTool';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Importador.listingPage');
$this->viewData['usingSweetAlert'] = true;
// Breadcrumbs (IMN)
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_importadores"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_importadores_catalogo"), 'route' => route_to('importadorCatalogoTool'), 'active' => true]
];
parent::initController($request, $response, $logger);
}
public function index()
{
$viewData = [
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Importador.importadorCatalogoTitle')]),
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . 'viewImportadorCatalogoTool', $viewData);
}
public function validarFila()
{
$json = $this->request->getJSON();
if (!$json || !isset($json->fila[0])) {
return $this->response->setJSON([
'apto' => false,
'reason' => 'Datos inválidos'
]);
}
$input = trim($json->fila[0]); // Asumimos que 'input' es el primer campo de la fila
if (empty($input)) {
return $this->response->setJSON([
'apto' => false,
'reason' => 'ISBN no proporiconado'
]);
}
$catalogoModel = new CatalogoLibroModel();
// 1. Buscar por ISBN exacto
$libroPorIsbn = $catalogoModel->where('isbn', $input)->first();
if ($libroPorIsbn) {
return $this->response->setJSON([
'apto' => true
]);
}
// 2. Buscar por EAN sin guiones
$eanLimpio = str_replace('-', '', $input);
$libroPorEan = $catalogoModel->where('REPLACE(ean, "-", "")', $eanLimpio)->first();
if ($libroPorEan) {
return $this->response->setJSON([
'apto' => true
]);
}
// No encontrado
return $this->response->setJSON([
'apto' => false,
'reason' => 'No encontrado en catálogo'
]);
}
public function importarFila()
{
$json = $this->request->getJSON();
if (!$json || !isset($json->fila[0])) {
return $this->response->setJSON([
'success' => false,
'message' => 'Datos inválidos.'
]);
}
// Mapear cada columna a una variable
$isbn = isset($json->fila[0]) ? trim($json->fila[0]) : null;
$refCliente = isset($json->fila[1]) ? trim($json->fila[1]) : null;
//$descripcion = isset($json->fila[2]) ? trim($json->fila[2]) : null;
$tirada = isset($json->fila[3]) ? (float) $json->fila[3] : null;
$precio_compra = isset($json->fila[4]) ? (float) $json->fila[4] : null;
if (empty($isbn)) {
return $this->response->setJSON([
'success' => false,
'message' => 'Input vacío o no proporcionado.'
]);
}
$catalogoModel = new CatalogoLibroModel();
// 1. Buscar por ISBN exacto
$libro = $catalogoModel->where('isbn', $isbn)->first();
// 2. Si no, buscar por EAN sin guiones
if (!$libro) {
$eanLimpio = str_replace('-', '', $isbn);
$libro = $catalogoModel->where('REPLACE(ean, "-", "")', $eanLimpio)->first();
}
if (!$libro) {
return $this->response->setJSON([
'success' => false,
'message' => 'No se encontró el libro en el catálogo.'
]);
}
// Aquí ya tenemos el libro correcto.
// Ahora se prepara la "inserción" o el "registro" a importar
// Variables intermedias
$colorPaginas = (int) ($libro->color_paginas ?? 0);
$negroPaginas = (int) ($libro->negro_paginas ?? 0);
$papelInteriorDiferente = ($colorPaginas > 0 && $negroPaginas > 0) ? 1 : 0;
// --- Interior (lo que cambiamos ahora)
if ($papelInteriorDiferente) {
// Mixto: páginas en negro + color
$interior = [
'papelInterior' => [
'negro' => $libro->negro_papel_id,
'color' => $libro->color_papel_id,
],
'gramajeInterior' => [
'negro' => $libro->negro_gramaje,
'color' => $libro->color_gramaje,
]
];
} else {
// SOLO un tipo: negro O color
$colorPaginas = (int) ($libro->color_paginas ?? 0);
$negroPaginas = (int) ($libro->negro_paginas ?? 0);
if ($colorPaginas > 0 && $negroPaginas == 0) {
// Libro completamente en color
$interior = [
'papelInterior' => $libro->color_papel_id,
'gramajeInterior' => $libro->color_gramaje,
];
} else {
// Libro completamente en blanco y negro
$interior = [
'papelInterior' => $libro->negro_papel_id,
'gramajeInterior' => $libro->negro_gramaje,
];
}
}
// Sobrecubierta
$sobrecubierta = [];
if (!is_null($libro->sobrecubierta_paginas)) {
$sobrecubierta['papel'] = $libro->sobrecubierta_papel_id;
$sobrecubierta['gramaje'] = $libro->sobrecubierta_gramaje;
$sobrecubierta['solapas'] = $libro->sobrecubierta_solapas;
$sobrecubierta['acabado'] = $libro->sobrecubierta_acabado_id;
}
$dataToImport = [
'selectedTirada' => $tirada,
'datosCabecera' => [
'titulo' => $libro->titulo,
'autor' => $libro->autor,
'isbn' => $isbn,
'coleccion' => $libro->coleccion,
'referenciaCliente' => $refCliente
],
'tirada' => array_values(array_filter([
$tirada,
null,
null,
null,
])),
'tamanio' => [
'ancho' => $libro->ancho,
'alto' => $libro->alto
],
'tipo' => "",
'tipo_presupuesto_id' => $libro->encuadernacion_id,
'clienteId' => 251,
'isColor' => (in_array(strtolower($libro->tipo_impresion), ['color', 'colorhq']) ? 1 : 0),
'isHq' => (in_array(strtolower($libro->tipo_impresion), ['negrohq', 'colorhq']) ? 1 : 0),
'paginas' => $libro->paginas,
'paginasColor' => $colorPaginas,
'papelInteriorDiferente' => $papelInteriorDiferente,
'paginasCuadernillo' => 32,
'interior' => $interior,
'cubierta' => [
'papelCubierta' => $libro->cubierta_papel_id,
'gramajeCubierta' => $libro->cubierta_gramaje,
'solapas' => $libro->cubierta_ancho_solapas,
'acabado' => $libro->cubierta_acabado_id,
'cabezada' => 'WHI',
'lomoRedondo' => 0
],
'ivaReducido' => 1,
'guardas' => [],
'sobrecubierta' => $sobrecubierta,
//'faja' => null,
'entrega_taller' => 1,
];
/*return $this->response->setJSON([
'success' => true,
'message' => 'Libro encontrado y preparado para importar.',
'data' => $dataToImport
]);*/
// Procedemos a intentar guardar el presupuesto
// Instancia de presupuesto cliente
$presupuestocliente = new Presupuestocliente();
try {
$response = $presupuestocliente->guardar($dataToImport);
// DEBUG LINE
//return $this->respond($response);
if (!isset($response['sk_id'])) {
return $this->respond([
'status' => 400,
'error' => 'Missing sk_id',
'message' => 'El identificador sk_id es requerido pero no se recibió.'
], 400);
}
$response = [
'status' => 200,
'error' => null,
'data' => [
'sk_id' => $response['sk_id'],
'sk_url' => $response['sk_url'] ?? null
]
];
// Ajuste del precio a RAMA
$respuesta_ajuste = PresupuestoService::ajustarPresupuesto(
$response['data']['sk_id'],
$precio_compra,
$tirada,
null,
true
);
if ($respuesta_ajuste['warning'] == true) {
$response['price_warning'] = [
'new_precio_unidad' => $respuesta_ajuste['new_precio_unidad'],
'new_total' => $respuesta_ajuste['new_total'],
];
}
// confirmar y crear pedido y ot
model('App\Models\Presupuestos\PresupuestoModel')->confirmarPresupuesto($response['data']['sk_id']);
PresupuestoService::crearPedido($response['data']['sk_id']);
return $this->respond($response);
} catch (\Exception $e) {
return $this->respond([
'status' => 500,
'error' => 'Server error',
'message' => 'Error inesperado durante el procesado',
'debug' => $e->getMessage()
]);
}
}
}

517
ci4/app/Controllers/Logistica/LogisticaController.php Normal file → Executable file
View File

@ -4,9 +4,11 @@ namespace App\Controllers\Logistica;
use App\Controllers\BaseController;
use App\Services\ImpresoraEtiquetaService;
use App\Services\LogisticaService;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use Hermawan\DataTables\DataTable;
class LogisticaController extends BaseController
{
@ -15,11 +17,22 @@ class LogisticaController extends BaseController
protected string $locale;
protected array $viewData;
protected static $controllerSlug = 'logistica';
protected static $viewPath = 'themes/vuexy/form/logistica/';
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->impresoraEtiquetaService = service('impresora_etiqueta');
$this->locale = session()->get('lang');
$this->viewData['pageTitle'] = lang('Logistica.logistica');
// Breadcrumbs
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_logistica"), 'route' => route_to("LogisticaPanel"), 'active' => false],
];
parent::initController($request, $response, $logger);
}
public function print_test_label()
@ -28,4 +41,508 @@ class LogisticaController extends BaseController
$responseMessage = $etiquetaData["status"] ? "OK" : "ERROR";
return $this->response->setJSON(["message" => $responseMessage, "data" => $etiquetaData, "status" => $etiquetaData["status"]]);
}
public function panel()
{
$viewData = [
'currentModule' => static::$controllerSlug,
'boxTitle' => lang('Logistica.panel'),
'pageSubTitle' => 'Panel',
'usingServerSideDataTable' => true,
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . 'viewPanelLogistica', $viewData);
}
public function gestionEnvios()
{
$viewData = [
'currentModule' => static::$controllerSlug,
'boxTitle' => lang('Logistica.gestionEnvios'),
'usingServerSideDataTable' => true,
'tipo_envio' => 'estandar',
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . 'viewLogisticaSelectEnvios', $viewData);
}
public function gestionEnviosFerros()
{
$viewData = [
'currentModule' => static::$controllerSlug,
'boxTitle' => lang('Logistica.envioFerros'),
'usingServerSideDataTable' => true,
'tipo_envio' => 'ferro_prototipo',
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . 'viewLogisticaSelectEnvios', $viewData);
}
public function listAlbaranes(){
$viewData = [
'currentModule' => static::$controllerSlug,
'boxTitle' => lang('Albaran.albaranes'),
'usingServerSideDataTable' => true,
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . '/albaranes/viewAlbaranesList', $viewData);
}
public function findForNewEnvio()
{
if ($this->request->isAJAX()) {
$tipo_envio = $this->request->getGet('tipo_envio') ?? 'estandar';
if($tipo_envio == 'ferro_prototipo'){
$query = LogisticaService::findForNewEnvioFerro();
} else {
$query = LogisticaService::findForNewEnvio();
}
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("id", $this->request->getGet("q"))
->orLike("name", $this->request->getGet("q"))
->groupEnd();
}
$result = $query->orderBy("name", "asc")->get()->getResultObject();
return $this->response->setJSON($result);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function selectDireccionForEnvio(){
if ($this->request->isAJAX()) {
$ot = $this->request->getGet('ot_id');
if($ot == null || $ot == 0){
return [];
}
$searchVal = $this->request->getGet("q") ?? "";
$result = LogisticaService::findDireccionesNewEnvio($ot, $searchVal);
return $this->response->setJSON($result);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function generarEnvio()
{
if ($this->request->isAJAX()) {
$ot_id = $this->request->getPost('ot_id');
$direccion = $this->request->getPost('direccion') ?? "";
$result = LogisticaService::generateEnvio($ot_id, $direccion);
return $this->response->setJSON($result);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function generarEnvioFerro()
{
if ($this->request->isAJAX()) {
$ot_id = $this->request->getPost('ot_id');
$result = LogisticaService::generateEnvioFerro($ot_id);
return $this->response->setJSON($result);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function imprimirEtiquetas()
{
if ($this->request->isAJAX()) {
$envio_id = $this->request->getPost('envio_id');
$ids = $this->request->getPost('envio_lineas');
$cajas = $this->request->getPost('cajas');
$printer_id = $this->request->getPost('printer_id');
if($cajas == null || $cajas == 0){
return $this->response->setJSON([
'status' => false,
'message' => 'Cajas no válidas'
]);
}
$model = model('App\Models\Logistica\EnvioModel');
$envio = $model->select('envios.*, clientes.nombre as cliente')
->join('clientes', 'clientes.id = envios.cliente_id', 'left')
->where('envios.id', $envio_id)
->first();
if($envio == null){
return $this->response->setJSON([
'status' => false,
'message' => 'Envio no válido'
]);
}
$model = model('App\Models\Logistica\EnvioLineaModel');
$lineas = $model->select('envios_lineas.*, presupuestos.titulo as titulo, presupuestos.referencia_cliente as referencia_cliente')
->join('presupuestos', 'presupuestos.id = envios_lineas.presupuesto_id', 'left')
->whereIn('envios_lineas.id', $ids)->findAll();
if($lineas == null){
return $this->response->setJSON([
'status' => false,
'message' => 'Lineas no válidas'
]);
}
$modelImpresora = model('App\Models\Configuracion\ImpresoraEtiquetaModel');
$impresora = $modelImpresora->select('id, name, ip, port, user, pass')
->where('deleted_at', null)
->where('id', $printer_id)
->orderBy('name', 'asc')
->first();
if($impresora == null){
return $this->response->setJSON([
'status' => false,
'message' => 'Impresora no válida'
]);
}
$response = LogisticaService::generateEtiquetasTitulos($envio, $lineas, $impresora, $cajas);
return $this->response->setJSON($response);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function selectAddEnvioLinea()
{
if ($this->request->isAJAX()) {
$query = LogisticaService::findLineaEnvioPorEnvio($this->request->getGet('envio'));
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("id", $this->request->getGet("q"))
->orLike("name", $this->request->getGet("q"))
->groupEnd();
}
$result = $query->orderBy("name", "asc")->get()->getResultObject();
return $this->response->setJSON($result);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function addEnvioLinea()
{
if ($this->request->isAJAX()) {
$pedido_id = $this->request->getGet('pedido_id');
$envio_id = $this->request->getGet('envio_id');
$envioModel = model('App\Models\Logistica\EnvioModel');
$direccion = $envioModel->find($envio_id)->direccion;
$result = LogisticaService::addLineaEnvio($envio_id, $pedido_id, $direccion);
return $this->response->setJSON($result);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function datatable_envios()
{
$otsFilter = $this->request->getGetPost('otsFilter');
$tipo_envio = $this->request->getGetPost('tipo_envio') ?? 'estandar';
$model = model('App\Models\Logistica\EnvioModel');
$q = $model->getDatatableQuery($tipo_envio);
if (!empty($otsFilter)) {
$q->groupStart();
$q->like('t5.id', $otsFilter);
$q->groupEnd();
}
$result = DataTable::of($q)
->edit(
"finalizado",
function ($row, $meta) {
if ($row->finalizado == 1)
return '<i class="ti ti-check"></i>';
else
return '<i class="ti ti-x"></i>';
}
)
->add("action", callback: function ($q) {
return '
<div class="btn-group btn-group-sm">
<a href="javascript:void(0);"><i class="ti ti-eye ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a>
</div>
';
});
return $result->toJson(returnAsObject: true);
}
public function editEnvio($id = null)
{
if (empty($id)) {
return redirect()->to(base_url('logistica/selectEnvios/simple'))->with('error', lang('Logistica.errors.noEnvio'));
}
$model = model('App\Models\Logistica\EnvioModel');
$envioEntity = $model->select('envios.*, lg_paises.nombre as pais')
->join('lg_paises', 'lg_paises.id = envios.pais_id', 'left')
->where('envios.id', $id)
->first();
if (empty($envioEntity)) {
return redirect()->to(base_url('logistica/selectEnvios/simple'))->with('error', lang('Logistica.errors.noEnvio'));
}
$modelProveedor = model('App\Models\Compras\ProveedorModel');
$proveedor = $modelProveedor->select('id, nombre')
->where('deleted_at', null)
->where('id', $envioEntity->proveedor_id)
->orderBy('nombre', 'asc')
->first();
if(!empty($proveedor)){
$envioEntity->proveedor_nombre = $proveedor->nombre;
}
$modelImpresora = model('App\Models\Configuracion\ImpresoraEtiquetaModel');
$impresoras = $modelImpresora->select('id, name')
->where('deleted_at', null)
->where('tipo', 1)
->orderBy('name', 'asc')
->findAll();
$envioEntity->impresoras = $impresoras;
$viewData = [
'currentModule' => static::$controllerSlug,
'boxTitle' => '<i class="ti ti-truck ti-xl"></i>' . ' ' . lang('Logistica.envio') . ' [' . $envioEntity->id . ']: ' . $envioEntity->direccion,
'usingServerSideDataTable' => true,
'envioEntity' => $envioEntity,
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . 'viewEnvioEditForm', $viewData);
}
public function updateCajasEnvio()
{
if ($this->request->isAJAX()) {
$id = $this->request->getPost('id');
$cajas = $this->request->getPost('cajas');
$model = model('App\Models\Logistica\EnvioModel');
$result = $model->update($id, [
'cajas' => $cajas,
]);
return $this->response->setJSON([
"status" => $result,
]);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function finalizarEnvio()
{
if ($this->request->isAJAX()) {
$id = $this->request->getPost('id') ?? null;
$finalizar_ots = $this->request->getPost('finalizar_ots') ?? false;
$result = LogisticaService::finalizarEnvio($id, $finalizar_ots);
return $this->response->setJSON($result);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function datatable_enviosEdit($idEnvio)
{
$model = model('App\Models\Logistica\EnvioLineaModel');
$q = $model->getDatatableQuery($idEnvio);
$result = DataTable::of($q)
->add(
"rowSelected",
callback: function ($q) {
return '<input type="checkbox" class="form-check-input checkbox-linea-envio" name="row_selected[]" value="' . $q->id . '">';
}
)
->edit(
"pedido",
function ($row, $meta) {
return '<a href="' . base_url('pedidos/edit/' . $row->pedido) . '" target="_blank">' . $row->pedido . '</a>';
}
)
->edit(
"presupuesto",
function ($row, $meta) {
return '<a href="' . base_url('presupuestoadmin/edit/' . $row->presupuesto) . '" target="_blank">' . $row->presupuesto . '</a>';
}
)->edit(
"unidadesEnvio",
function ($row, $meta) {
if($row->finalizado == 1 || $row->tipo_envio == 'ferro_prototipo'){
return $row->unidadesEnvio;
}
return '<input type="number" class="form-control input-lineas input-unidades text-center"
data-id="'. $row->id.'" data-name="unidades_envio" value="' . $row->unidadesEnvio . '">';
}
);
return $result->toJson(returnAsObject: true);
}
public function setCajaLinea()
{
if ($this->request->isAJAX()) {
$id = $this->request->getPost('id');
$caja = $this->request->getPost('caja');
$model = model('App\Models\Logistica\EnvioLineaModel');
$result = $model->update($id, [
'cajas' => $caja,
]);
return $this->response->setJSON([
"status" => $result,
]);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function deleteLineas()
{
if ($this->request->isAJAX()) {
$ids = $this->request->getPost('ids');
$model = model('App\Models\Logistica\EnvioLineaModel');
$result = $model->delete($ids);
return $this->response->setJSON([
"status" => $result,
]);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function updateLineaEnvio()
{
$id = $this->request->getPost('id');
$fieldName = $this->request->getPost('name');
$fieldValue = $this->request->getPost('value');
if (!$id || !$fieldName || ($fieldName=='unidades_envio' && !$fieldValue)) {
return $this->response->setJSON([
'status' => false,
'message' => 'Datos inválidos'
]);
}
$model = model('App\Models\Logistica\EnvioLineaModel');
$updated = $model->update($id, [
"" . $fieldName => $fieldValue==""? null: $fieldValue,
]);
return $this->response->setJSON([
'status' => $updated,
'message' => $updated ? 'Actualizado' : 'Error al actualizar'
]);
}
public function updateCodigoSeguimiento()
{
$id = $this->request->getPost('id');
$fieldValue = $this->request->getPost('codigo_seguimiento');
if (!$id) {
return $this->response->setJSON([
'status' => false,
'message' => 'Datos inválidos'
]);
}
$model = model('App\Models\Logistica\EnvioModel');
$updated = $model->update($id, [
"codigo_seguimiento" => $fieldValue==""? null: $fieldValue,
]);
return $this->response->setJSON([
'status' => $updated,
'message' => $updated ? 'Actualizado' : 'Error al actualizar'
]);
}
public function updateProveedorEnvio()
{
$id = $this->request->getPost('id');
$fieldValue = $this->request->getPost('proveedor_id');
if (!$id) {
return $this->response->setJSON([
'status' => false,
'message' => 'Datos inválidos'
]);
}
$model = model('App\Models\Logistica\EnvioModel');
$updated = $model->update($id, [
"proveedor_id" => $fieldValue==""? null: $fieldValue,
]);
return $this->response->setJSON([
'status' => $updated,
'message' => $updated ? 'Actualizado' : 'Error al actualizar'
]);
}
public function saveComments()
{
$id = $this->request->getPost('id');
$comments = $this->request->getPost('comentarios');
if (!$id || !$comments) {
return $this->response->setJSON([
'status' => false,
'message' => 'Datos inválidos'
]);
}
$model = model('App\Models\Logistica\EnvioModel');
$updated = $model->update($id, [
'comentarios' => $comments,
]);
return $this->response->setJSON([
'status' => $updated,
'message' => $updated ? 'Actualizado' : 'Error al actualizar'
]);
}
}

0
ci4/app/Controllers/Mensajeria/MensajesDirectos.php Normal file → Executable file
View File

18
ci4/app/Controllers/Pdf/PrintAlbaranes.php Normal file → Executable file
View File

@ -11,8 +11,8 @@ class PrintAlbaranes extends BaseController
public function index($albaran_id)
{
$albaranModel = model('App\Models\Pedidos\AlbaranModel');
$lineasAlbaranModel = model('App\Models\Pedidos\AlbaranLineaModel');
$albaranModel = model('App\Models\Albaranes\AlbaranModel');
$lineasAlbaranModel = model('App\Models\Albaranes\AlbaranLineaModel');
$data['albaran'] = $albaranModel->getResourceForPdf($albaran_id)->get()->getRow();
$data['albaranLineas'] = $lineasAlbaranModel->getResourceForPdf($albaran_id)->get()->getResultObject();
@ -25,14 +25,22 @@ class PrintAlbaranes extends BaseController
{
// Cargar modelos
$albaranModel = model('App\Models\Pedidos\AlbaranModel');
$lineasAlbaranModel = model('App\Models\Pedidos\AlbaranLineaModel');
$albaranModel = model('App\Models\Albaranes\AlbaranModel');
$lineasAlbaranModel = model('App\Models\Albaranes\AlbaranLineaModel');
// Informacion del presupuesto
$data['albaran'] = $albaranModel->getResourceForPdf($albaran_id)->get()->getRow();
$data['albaranLineas'] = $lineasAlbaranModel->getResourceForPdf($albaran_id)->get()->getResultObject();
// Obtener contenido HTML de la vista
$html = view(getenv('theme.path') . 'pdfs/albaran', $data);
// Cargar CSS desde archivo local
$css = file_get_contents(FCPATH . 'themes/vuexy/css/pdf.albaran.css');
// Combinar CSS y HTML
$html_con_css = "<style>$css</style>" . $html;
// Crear una instancia de Dompdf
$options = new \Dompdf\Options();
$options->set('isHtml5ParserEnabled', true);
@ -41,7 +49,7 @@ class PrintAlbaranes extends BaseController
$dompdf = new \Dompdf\Dompdf($options);
// Contenido HTML del documento
$dompdf->loadHtml(view(getenv('theme.path').'pdfs/albaran', $data));
$dompdf->loadHtml($html_con_css);
// Establecer el tamaño del papel
$dompdf->setPaper('A4', 'portrait');

0
ci4/app/Controllers/Pdf/PrintFacturas.php Normal file → Executable file
View File

View File

@ -1,388 +0,0 @@
<?php
namespace App\Controllers\Pedidos;
use App\Entities\Pedidos\AlbaranEntity;
use App\Models\Pedidos\AlbaranModel;
class Albaran extends \App\Controllers\BaseResourceController
{
protected $modelName = AlbaranModel::class;
protected $format = 'json';
protected static $singularObjectNameCc = 'albaran';
protected static $singularObjectName = 'Albaran';
protected static $pluralObjectName = 'Albaranes';
protected static $controllerSlug = 'albaran';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
}
public function index()
{
}
public function delete($id = null)
{
if ($this->request->isAJAX()) {
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
$model_linea->where('albaran_id', $id)->delete();
$this->model->where('id', $id)->delete();
$data = [
'error' => 0,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function addLinea($albaran_id){
if ($this->request->isAJAX()) {
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
// si es un post, es el iva
if($this->request->getPost()){
$reqData = $this->request->getPost();
$albaran_id = $reqData['albaran_id'] ?? 0;
$albaran = $this->model->find($albaran_id);
if($albaran == false){
$data = [
'error' => 'Albaran no encontrado',
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
$presupuesto_model = model('App\Models\Presupuestos\PresupuestoModel');
$presupuesto = $presupuesto_model->find($albaran->presupuesto_id);
if($presupuesto == false){
$data = [
'error' => 'Presupuesto no encontrado',
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
$iva_reducido = $presupuesto->iva_reducido;
$lineas = $model_linea->where('albaran_id', $albaran_id)->findAll();
$total = 0;
foreach($lineas as $linea){
$total += $linea->total;
}
$iva = $iva_reducido? $total * 4.0 / 100: $total * 21.0 / 100;
$data_linea= [
'albaran_id' => $albaran_id,
'titulo' => $iva_reducido?lang('Pedidos.iva4'):lang('Pedidos.iva21'),
'cantidad' => 1,
'precio_unidad' => round($iva,2),
'total' => round($iva,2),
'user_created_id' => auth()->user()->id,
'user_updated_id' => auth()->user()->id
];
$id_linea = $model_linea->insert($data_linea);
$linea = $model_linea->find($id_linea);
$data = [
'error' => 0,
'data' => $linea,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
else{
$linea = [
'albaran_id' => $albaran_id,
'user_created_id' => auth()->user()->id,
'user_updated_id' => auth()->user()->id
];
$id_linea = $model_linea->insert($linea);
$data = $model_linea->find($id_linea);
$data = [
'error' => 0,
'data' => $data,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
}
else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function add()
{
if ($this->request->isAJAX()) {
$user = auth()->user()->id;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$reqData = $this->request->getPost();
$pedido_id = $reqData['pedido_id'] ?? 0;
$presupuestos_id = $reqData['presupuestos_id'] ?? 0;
$return_data = $this->model->generarAlbaranes($pedido_id, $presupuestos_id, $user);
$data = [
'data' => $return_data,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function update($id = null){
if ($this->request->isAJAX()) {
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
if ($id == null) :
$data = [
'error' => 2,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif;
$id = filter_var($id, FILTER_SANITIZE_URL);
$albaranEntity = $this->model->find($id);
if ($albaranEntity == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
$data = [
'error' => $message,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif;
if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
$sanitizedData['user_updated_id'] = auth()->user()->id;
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Pedidos.albaran'))]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$albaranEntity->fill($sanitizedData);
endif;
if ($noException && $successfulResult) :
$id = $albaranEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
$data = [
'error' => 0,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$data = [
'error' => 1,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function updateLinea($id = null){
if ($this->request->isAJAX()) {
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
if ($id == null) :
$data = [
'error' => 2,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif;
$id = filter_var($id, FILTER_SANITIZE_URL);
$albaranEntity = $model_linea->find($id);
if ($albaranEntity == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
$data = [
'error' => $message,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif;
if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
// JJO
$sanitizedData['user_updated_id'] = auth()->user()->id;
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
try {
$successfulResult = $model_linea->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Pedidos.albaran'))]);
$this->session->setFlashdata('formErrors', $model_linea->errors());
endif;
$albaranEntity->fill($sanitizedData);
endif;
if ($noException && $successfulResult) :
$id = $albaranEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
$data = [
'error' => 0,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$data = [
'error' => 1,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function borrarLinea(){
if ($this->request->isAJAX()) {
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$reqData = $this->request->getPost();
$id = $reqData['id'] ?? 0;
$id = filter_var($id, FILTER_SANITIZE_URL);
$albaranLineaEntity = $model_linea->find($id);
if ($albaranLineaEntity == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]);
$data = [
'error' => $message,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
endif;
$successfulResult = $model_linea->skipValidation(true)->update($id, ['deleted_at' => date('Y-m-d H:i:s')]);
if ($successfulResult) :
$data = [
'error' => 0,
$csrfTokenName => $newTokenHash
];
else:
$data = [
'error' => 1,
$csrfTokenName => $newTokenHash
];
endif;
return $this->respond($data);
}
else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function getAlbaranes($pedido_id = null){
if ($this->request->isAJAX()) {
$model_linea = model('App\Models\Pedidos\AlbaranLineaModel');
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$returnData = [];
$albaranes = $this->model->asArray()->where('pedido_id', $pedido_id)->findAll();
foreach($albaranes as $albaran){
$albaran['fecha_albaran'] = $albaran['updated_at'];
array_push($returnData,
[
'albaran' => $albaran,
'lineas' => $model_linea->asArray()->where('albaran_id', $albaran['id'])->findAll()]
);
}
$data = [
'data' => $returnData,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

0
ci4/app/Controllers/Presupuestos/Buscador.php Normal file → Executable file
View File

View File

49
ci4/app/Controllers/Presupuestos/Presupuestoadmin.php Normal file → Executable file
View File

@ -382,6 +382,16 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
'descripcion' => $linea_pedido->concepto
]);
// se actualiza el totalizador del pedido
$total_tirada = $pedidoModel
->selectSum('cantidad')
->where('pedido_id', $idPedido)
->first()->cantidad;
$pedidoModel = model('App\Models\Pedidos\PedidoModel');
$pedidoModel->update($idPedido, [
'total_tirada' => $total_tirada
]);
// se actualiza la factura
$linea_pedido = $this->model->generarLineaPedido($id, true, $idPedido)[0];
$facturaLineaModel = model('App\Models\Facturas\FacturaLineaModel');
@ -983,6 +993,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$reqData = $this->request->getPost();
$calcular_merma = $reqData['calcular_merma'] ?? 0;
$type = $reqData['type'] ?? null;
// por defecto, se deja cosido tapa blanda por ahora JJO
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
@ -1061,8 +1073,27 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
'a_favor_fibra' => $a_favor_fibra
);
$resourceData = PresupuestoService::obtenerComparadorPlana($input_data);
if($calcular_merma == 1 && count($resourceData) > 0 &&
count($resourceData[0]['fields']) >0 && $resourceData[0]['fields']['num_formas'] > 0) {
usort($resourceData, function ($a, $b) {
return $b['fields']['total_impresion'] <=> $a['fields']['total_impresion'];
});
$num_formas = [];
$formas_linea = $datosPedido->isCosido ? intval($resourceData[0]['fields']['num_formas']['value']) / 2 :
intval($resourceData[0]['fields']['num_formas']['value']);
array_push($num_formas, $formas_linea);
$POD = $this->getPOD();
$datosPedido->merma = PresupuestoService::calcular_merma($datosPedido->tirada,$POD, $num_formas);
$resourceData = PresupuestoService::obtenerComparadorPlana($input_data);
}
} else if ($type == 'interior_rot') {
$paginas = (object) array(
@ -1095,6 +1126,24 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$resourceData = PresupuestoService::obtenerComparadorRotativa($input_data);
if($calcular_merma == 1 && count($resourceData) > 0 &&
count($resourceData[0]['fields']) >0 && $resourceData[0]['fields']['num_formas'] > 0) {
usort($resourceData, function ($a, $b) {
return $b['fields']['total_impresion'] <=> $a['fields']['total_impresion'];
});
$num_formas = [];
$formas_linea = $datosPedido->isCosido ? intval($resourceData[0]['fields']['num_formas']['value']) / 2 :
intval($resourceData[0]['fields']['num_formas']['value']);
array_push($num_formas, $formas_linea);
$POD = $this->getPOD();
$datosPedido->merma = PresupuestoService::calcular_merma($datosPedido->tirada,$POD, $num_formas);
$resourceData = PresupuestoService::obtenerComparadorRotativa($input_data);
}
} else if ($type == 'cubierta' || $type == 'sobrecubierta' || $type == 'faja') {
$datosPedido->solapas = $reqData['solapas'];

View File

@ -323,17 +323,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datosPedido = (object) array(
'paginas' => $paginas,
'tirada' => $tirada[0],
'merma' => $this->calcular_merma($tirada[0], $POD),
'merma' => PresupuestoService::calcular_merma($tirada[0], $POD),
'ancho' => intval($tamanio['ancho']) ?? 100000,
'alto' => intval($tamanio['alto']) ?? 100000,
'isCosido' => $is_cosido,
'a_favor_fibra' => 1,
);
$cliente_model = model(('App\Models\Clientes\ClienteModel'));
$cliente = $cliente_model->find($cliente_id);
// Para POD siempre es HQ
if ($tirada[0] <= $POD) {
if ($tirada[0] <= $POD && !$cliente->forzar_rotativa_pod) {
$isHq = true;
}
$forzarRotativa = false;
if ($tirada[0] <= $POD && $cliente->forzar_rotativa_pod) {
$forzarRotativa = true;
}
$input_data = array(
'uso' => 'interior',
@ -346,7 +352,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'cliente_id' => $cliente_id,
'paginas_color' => $paginas_color,
'excluirRotativa' => $excluirRotativa,
'papelInteriorDiferente' => $papelInteriorDiferente
'papelInteriorDiferente' => $papelInteriorDiferente,
'forzarRotativa' => $forzarRotativa,
);
$interior = PresupuestoClienteService::obtenerInterior($input_data);
@ -460,6 +467,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$id = $reqData['id'] ?? 0;
$cliente_id = $reqData['clienteId'] ?? -1;
$noEnvioBase = model('App\Models\Clientes\ClienteModel')->find($cliente_id)->no_envio_base ?? false;
$tirada = $reqData['tirada'] ?? 0;
$selectedTirada = $reqData['selectedTirada'] ?? -1;
@ -609,6 +617,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
} else {
$coste = floatval($coste_direccion->coste);
$margen = $coste * (intval($coste_direccion->margen) / 100.0);
if ($noEnvioBase) {
$coste = 0.0;
$margen = 0.0;
}
$return_data['eb'][$i] = round($coste + $margen, 2);
}
}
@ -739,17 +751,23 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datosPedido = (object) array(
'paginas' => $paginas,
'tirada' => $tirada[0],
'merma' => $tirada[0] > $POD ? $this->calcular_merma($tirada[0], $POD) : 0,
'merma' => $tirada[0] > $POD ? PresupuestoService::calcular_merma($tirada[0], $POD) : 0,
'ancho' => intval($tamanio['ancho']) ?? 100000,
'alto' => intval($tamanio['alto']) ?? 100000,
'isCosido' => $is_cosido,
'a_favor_fibra' => 1,
);
$cliente_model = model(('App\Models\Clientes\ClienteModel'));
$cliente = $cliente_model->find($cliente_id);
// Para POD siempre es HQ
if ($tirada[0] <= $POD) {
if ($tirada[0] <= $POD && !$cliente->forzar_rotativa_pod) {
$isHq = true;
}
$forzarRotativa = false;
if ($tirada[0] <= $POD && $cliente->forzar_rotativa_pod) {
$forzarRotativa = true;
}
$input_data = array(
'uso' => 'interior',
@ -762,7 +780,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'cliente_id' => $cliente_id,
'paginas_color' => $paginas_color,
'excluirRotativa' => $excluirRotativa,
'papelInteriorDiferente' => $papelInteriorDiferente
'papelInteriorDiferente' => $papelInteriorDiferente,
'forzarRotativa' => $forzarRotativa,
);
$interior = PresupuestoClienteService::obtenerInterior($input_data);
@ -1126,6 +1145,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$peso_libro = $resultado_presupuesto['peso'][array_search($selected_tirada, $tirada)];
// calculo del envio base (tirada_maxima)
$noEnvioBase = model('App\Models\Clientes\ClienteModel')->find($cliente_id)->no_envio_base ?? false;
$resultado_presupuesto['eb'] = [];
$datos_presupuesto['envio_base'] = 0;
for ($i = 0; $i < count($tirada); $i++) {
@ -1139,6 +1159,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
);
if (intval($selected_tirada) == intval($tirada[$i])) {
if ($noEnvioBase) {
$coste_direccion->coste = 0.0;
$coste_direccion->margen = 0.0;
}
$datos_presupuesto['envio_base'] = round($coste_direccion->coste * (1 + $coste_direccion->margen / 100.0), 2);
}
@ -1160,6 +1184,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
];
return $resultado_presupuesto;
} else {
if ($noEnvioBase) {
$coste_direccion->coste = 0.0;
$coste_direccion->margen = 0.0;
}
$resultado_presupuesto['eb'][$i] = round($coste_direccion->coste, 2);
$resultado_presupuesto['eb_margen'][$i] = round($coste_direccion->margen, 2);
}
@ -1176,10 +1204,10 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
for ($i = 0; $i < count($tirada); $i++) {
$coste_envio = 0.0;
$coste_envio += ($resultado_presupuesto['eb'][$i] / $tirada[$i]);
$resultado_presupuesto['info']['totales'][$i]['envio_base_margen'] =
floatval($resultado_presupuesto['eb'][$i])*(floatval($resultado_presupuesto['eb_margen'][$i])/100.0);
$resultado_presupuesto['info']['totales'][$i]['envio_base_margen'] =
floatval($resultado_presupuesto['eb'][$i]) * (floatval($resultado_presupuesto['eb_margen'][$i]) / 100.0);
$resultado_presupuesto['info']['totales'][$i]['envio_base_coste'] = $resultado_presupuesto['eb'][$i];
$resultado_presupuesto['precio_u'][$i] = round(floatval($resultado_presupuesto['precio_u'][$i]) + $coste_envio, 4);
}
@ -1312,7 +1340,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datos_presupuesto['entrega_taller'] = $reqData['entrega_taller'] ?? 0;
$resultado_presupuesto['info']['merma'] = $this->calcular_merma($selected_tirada, $POD);
$resultado_presupuesto['info']['merma'] = PresupuestoService::calcular_merma($selected_tirada, $POD);
$datos_presupuesto['faja'] = $faja;
@ -1357,7 +1385,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
foreach ($serviciosAcabado as $service) {
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
$servicio = $model->getPrecioTarifa(
intval($service), intval($selected_tirada)+$resultado_presupuesto['info']['merma'], -1, $POD);
intval($service),
intval($selected_tirada) + $resultado_presupuesto['info']['merma'],
-1,
$POD
);
if (count($servicio) > 0) {
if ($servicio[0]->total > 0) {
@ -1375,8 +1407,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
foreach ($serviciosAcabado as $service) {
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
$servicio = $model->getPrecioTarifa(
intval($service),
intval($selected_tirada) + $resultado_presupuesto['info']['merma'], -1, $POD);
intval($service),
intval($selected_tirada) + $resultado_presupuesto['info']['merma'],
-1,
$POD
);
if (count($servicio) > 0) {
if ($servicio[0]->total > 0) {
@ -1393,8 +1428,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
foreach ($serviciosAcabado as $service) {
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
$servicio = $model->getPrecioTarifa(
intval($service),
intval($selected_tirada) + $resultado_presupuesto['info']['merma'], -1, $POD);
intval($service),
intval($selected_tirada) + $resultado_presupuesto['info']['merma'],
-1,
$POD
);
if (count($servicio) > 0) {
if ($servicio[0]->total > 0) {
@ -1407,7 +1445,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$tarifa_id = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_lomo_redondo')->value;
$serv_lomo = PresupuestoCLienteService::getServiciosManipulado([
'tarifa_id' => intval($tarifa_id),
'tirada' => $selected_tirada+$resultado_presupuesto['info']['merma'],
'tirada' => $selected_tirada + $resultado_presupuesto['info']['merma'],
'POD' => $POD,
])[0];
@ -2029,7 +2067,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$datosPedido = (object) array(
'paginas' => $paginas,
'tirada' => $tirada[$t],
'merma' => $this->calcular_merma($tirada[$t], $POD),
'merma' => PresupuestoService::calcular_merma($tirada[$t], $POD),
'ancho' => intval($tamanio['ancho']) ?? 100000,
'alto' => intval($tamanio['alto']) ?? 100000,
'isCosido' => $is_cosido,
@ -2039,10 +2077,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$info['merma'] = $datosPedido->merma;
}
$cliente_model = model(('App\Models\Clientes\ClienteModel'));
$cliente = $cliente_model->find($cliente_id);
// Para POD siempre es HQ
if ($tirada[$t] <= $POD) {
if ($tirada[$t] <= $POD && !$cliente->forzar_rotativa_pod) {
$isHq = true;
}
$forzarRotativa = false;
if ($tirada[$t] <= $POD && $cliente->forzar_rotativa_pod) {
$forzarRotativa = true;
}
$input_data = array(
'uso' => 'interior',
@ -2055,7 +2099,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'cliente_id' => $cliente_id,
'paginas_color' => $paginas_color,
'excluirRotativa' => $excluirRotativa,
'papelInteriorDiferente' => $papelInteriorDiferente
'papelInteriorDiferente' => $papelInteriorDiferente,
'forzarRotativa' => $forzarRotativa,
);
$interior = PresupuestoClienteService::obtenerInterior($input_data);
@ -2107,7 +2152,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
array_push($num_formas, $formas_linea);
}
}
$input_data['datosPedido']->merma = $this->calcular_merma($tirada[$t], $POD, $num_formas);
$input_data['datosPedido']->merma = PresupuestoService::calcular_merma($tirada[$t], $POD, $num_formas);
if ($extra_info) {
$info['merma'] = max($info['merma'], $input_data['datosPedido']->merma);
}
@ -3071,7 +3116,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$sumForFactor += round($linea['precio_pedido'], 2)
- round($linea['margen_papel_pedido'], 2);
$margenPapel += round($linea['margen_papel_pedido'], 2);
$totalImpresion += round($linea['precio_click_pedido'], 2);
$totalImpresion -= round($linea['margen_click_pedido'], 2);
$sumForFactor += round($linea['precio_click_pedido'], 2)
@ -3142,31 +3187,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
}
}
protected function calcular_merma($tirada, $POD, $formas_lineas_interior = [])
{
$merma = 0;
if ($tirada > $POD) {
$merma = $tirada * 0.1;
} else {
$merma_lineas = [];
foreach ($formas_lineas_interior as $formas_linea) {
if ($formas_linea > $tirada)
array_push($merma_lineas, $formas_linea - $tirada);
else
array_push($merma_lineas, $tirada % $formas_linea);
}
if (count($merma_lineas) > 0)
$merma = max($merma_lineas);
}
return round($merma, 0);
}
protected function getPapelFormatoListItems($selId = null)
{
$papelFormatoModel = model('App\Models\Configuracion\PapelFormatoModel');

View File

@ -54,6 +54,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
$proveedor = $reqData['proveedor'] ?? "";
$proveedor_id = $reqData['proveedor_id'] ?? "";
$entregaPieCalle = $reqData['entregaPieCalle'] ?? 0;
$is_ferro_prototipo = $reqData['is_ferro_prototipo'] ?? 0;
$data = [
"presupuesto_id" => $presupuesto_id,
@ -73,6 +74,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
"proveedor" => $proveedor,
"proveedor_id" => $proveedor_id,
"entregaPieCalle" => $entregaPieCalle,
"is_ferro_prototipo" => $is_ferro_prototipo
];
$response = $this->model->insert($data);

View File

View File

@ -3,6 +3,8 @@
namespace App\Controllers\Produccion;
use App\Controllers\BaseController;
use App\Models\Compras\ProveedorModel;
use App\Models\Configuracion\MaquinaModel;
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
use App\Models\OrdenTrabajo\OrdenTrabajoUser;
@ -27,6 +29,8 @@ class Ordentrabajo extends BaseController
protected OrdenTrabajoModel $otModel;
protected OrdenTrabajoUser $otUserModel;
protected OrdenTrabajoTarea $otTarea;
protected ProveedorModel $proveedorModel;
protected MaquinaModel $maquinaModel;
protected UserModel $userModel;
protected Validation $validation;
protected static $viewPath = 'themes/vuexy/form/produccion/';
@ -42,6 +46,8 @@ class Ordentrabajo extends BaseController
$this->userModel = model(UserModel::class);
$this->produccionService = new ProductionService();
$this->otTarea = model(OrdenTrabajoTarea::class);
$this->maquinaModel = model(MaquinaModel::class);
$this->proveedorModel = model(ProveedorModel::class);
$this->validation = service("validation");
helper("time");
parent::initController($request, $response, $logger);
@ -67,6 +73,11 @@ class Ordentrabajo extends BaseController
}
public function find_tarea($orden_trabajo_tarea_id)
{
$t = $this->otTarea->find($orden_trabajo_tarea_id);
return $this->response->setJSON($t);
}
public function get_orden_trabajo_summary($orden_trabajo_id)
{
try {
@ -97,10 +108,22 @@ class Ordentrabajo extends BaseController
public function update_orden_trabajo_tarea()
{
$bodyData = $this->request->getPost();
// return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]);
$validated = $this->validation->run($bodyData, "orden_trabajo_tarea");
if ($validated) {
$r = $this->produccionService->updateOrdenTrabajoTarea($bodyData["orden_trabajo_tarea_id"], $bodyData);
$tareaEntity = $this->otTarea->find($bodyData["orden_trabajo_tarea_id"]);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $tareaEntity]);
} else {
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
public function update_orden_trabajo_pliegos()
{
$bodyData = $this->request->getPost();
// return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]);
$validated = $this->validation->run($bodyData, "orden_trabajo");
if ($validated) {
$r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajoTareaPliegos($bodyData);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]);
} else {
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
@ -118,6 +141,31 @@ class Ordentrabajo extends BaseController
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
public function update_presupuesto_tarea_proveedor(){
$bodyData = $this->request->getPost();
$validated = $this->validation->run($bodyData, "proveedor_tarea");
if ($validated) {
$validatedData = $this->validation->getValidated();
$r = $this->produccionService->updateProveedorLinea($validatedData['orden_trabajo_tarea_id'], $validatedData['proveedor_id']);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r]);
} else {
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
public function reset_orden_trabajo_date()
{
$bodyData = $this->request->getPost();
// return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]);
$validated = $this->validation->run($bodyData, "orden_trabajo_date");
if ($validated) {
$validatedData = $bodyData;
$r = $this->produccionService->emptyOrdenTrabajoDate($validatedData['orden_trabajo_id'], $validatedData['name']);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "user" => auth()->user(), "data" => $bodyData]);
} else {
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
public function update_orden_trabajo_pedido_date()
{
try {
@ -128,6 +176,18 @@ class Ordentrabajo extends BaseController
return $this->response->setJSON(["errors" => $th->getMessage(), "status" => false])->setStatusCode(500);
}
}
public function reset_orden_trabajo_pedido_date()
{
$bodyData = $this->request->getPost();
$validated = $this->validation->run($bodyData, "orden_trabajo_date");
if ($validated) {
$validatedData = $bodyData;
$r = $this->produccionService->init($bodyData['orden_trabajo_id'])->emptyOrdenTrabajoPedidoDate($validatedData['name']);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "user" => auth()->user(), "data" => $bodyData]);
} else {
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
public function update_orden_trabajo_pedido()
{
try {
@ -152,8 +212,13 @@ class Ordentrabajo extends BaseController
$this->viewData["presupuesto"] = $this->produccionService->getPresupuesto();
$this->viewData["cliente"] = $this->produccionService->getCliente();
$this->viewData["ot"] = $this->produccionService->getOrdenTrabajo();
$this->viewData["is_finalizada"] = $this->produccionService->getOrdenTrabajo()->estado == "F";
$this->viewData["user_dates"] = $this->produccionService->userDates();
$this->viewData["pedido_user_dates"] = $this->produccionService->pedidoUserDates();
$this->viewData["colors"] = $this->produccionService->getPdfColors();
$this->viewData["tiempo_estimado"] = $this->produccionService->getTiempoProcesamientoHHMM();
$this->viewData["flags"] = $this->produccionService->getFlags();
return view(static::$viewPath . $this->editRoute, $this->viewData);
}
@ -165,7 +230,7 @@ class Ordentrabajo extends BaseController
$q = $this->otModel->getDatatableQuery()->where("ordenes_trabajo.estado", "F");
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
@ -180,7 +245,7 @@ class Ordentrabajo extends BaseController
$q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado", ["I", "PM"]);
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
@ -192,10 +257,10 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where("ferro_ok_at", null);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at", null);
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
@ -207,10 +272,66 @@ class Ordentrabajo extends BaseController
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where("ferro_ok_at is NOT NULL", NULL, FALSE);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
// return $this->response->setJSON($q->get()->getResultArray());
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name,"color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
)
->add("action", fn($q) => $q->id)
->toJson(true);
}
public function datatable_news()
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery();
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
)
->add("action", fn($q) => $q->id)
->toJson(true);
}
public function datatable_prod()
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
)
->add("action", fn($q) => $q->id)
->toJson(true);
}
public function datatable_waiting()
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.is_pedido_espera',1);
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
)
->add("action", fn($q) => $q->id)
->toJson(true);
}
public function datatable_revision_com()
{
$logo = config(LogoImpresion::class);
$q = $this->otModel->getDatatableQuery()->where('presupuestos.ferro',1)->where("ferro_ok_at is NOT NULL", NULL, FALSE);
return DataTable::of($q)
->add("logo", fn($q) => ["logo" => site_url($logo->get_logo_path($q->presupuesto_linea_tipo)), "imposicion" => $q->imposicion_name, "color" => $this->produccionService->init($q->id)->getOtColorStatus()])
->edit(
"fecha_encuadernado_at",
fn($q) => $q->fecha_encuadernado_at ? Time::createFromFormat("Y-m-d H:i:s", $q->fecha_encuadernado_at)->format("d/m/Y") : ""
@ -255,6 +376,7 @@ class Ordentrabajo extends BaseController
->edit("orden", fn($q) => ["id" => $q->id, "orden" => $q->orden])
->edit("tiempo_estimado", fn($q) => float_seconds_to_hhmm_string($q->tiempo_estimado))
->edit("tiempo_real", fn($q) => float_seconds_to_hhmm_string($q->tiempo_real))
->add("proveedor", fn($q) => $this->produccionService->getProveedorTarea($q->id))
->edit("maquina_tarea", fn($q) => ["id" => $q->id, "maquina_id" => $q->maquina_tarea, "maquina_name" => $q->maquina_nombre])
->add("imposicion", fn($q) => ["id" => $q->id, "imposicion_id" => $q->imposicion_id, "name" => $q->imposicion_name, "is_presupuesto_linea" => $q->presupuesto_linea_id ? true : false])
->toJson(true);
@ -263,6 +385,14 @@ class Ordentrabajo extends BaseController
{
return $this->produccionService->init($orden_trabajo_id)->getPdf();
}
public function get_ferro_pdf($orden_trabajo_id)
{
return $this->produccionService->init($orden_trabajo_id)->getFerroPdf();
}
public function get_prototipo_pdf($orden_trabajo_id)
{
return $this->produccionService->init($orden_trabajo_id)->getPrototipoPdf();
}
public function upload_orden_trabajo_portada()
{
try {
@ -349,7 +479,7 @@ class Ordentrabajo extends BaseController
->edit("tiempo_real_sum", fn($q) => $q->tiempo_real_sum)
->edit("fecha_entrega_real_at", fn($q) => $q->fecha_entrega_real_at ? Time::createFromFormat("Y-m-d", $q->fecha_entrega_real_at)->format("d/m/Y") : "")
->add("pliegos_check", fn($q) => $q->otId)
->add("action", fn($q) => ["data" => $q ])
->add("action", fn($q) => ["data" => $q])
->toJson(true);
}
public function select_maquina_planning_rot()
@ -438,4 +568,125 @@ class Ordentrabajo extends BaseController
$color = $this->produccionService->init($orden_trabajo_id)->getOtColorStatus();
return $this->response->setJSON(["color" => $color]);
}
public function imprimir_codigo_safekat(int $orden_trabajo_id)
{
helper('file');
$barcode = $this->produccionService->init($orden_trabajo_id)->getFileBarCode();
return $this->response
->setHeader('Content-Type', 'image/png')
->setHeader('Content-Disposition', "attachment; filename=CodigoBarrasOT_{$orden_trabajo_id}.png")
->setBody($barcode);
}
public function maquinista_maquinas_view()
{
// Breadcrumbs
$this->viewData['breadcrumb'] = [
['title' => lang("Produccion.maquinista.maquinas"), 'route' => route_to("viewProduccionMaquinistaMaquinas"), 'active' => true],
];
$data = [
"impresion" => $this->maquinaModel->queryViewMaquinistaMaquinas('impresion')->get()->getResultArray(),
"manipulado" => $this->maquinaModel->queryViewMaquinistaMaquinas('manipulado')->get()->getResultArray(),
"acabado" => $this->maquinaModel->queryViewMaquinistaMaquinas('acabado')->get()->getResultArray(),
];
$this->viewData["maquinas"] = $data;
return view(static::$viewPath . '/maquinista/viewMaquinistaMaquinaList', $this->viewData);
}
public function maquinista_maquina_tareas_list(int $maquina_id)
{
$maquina = $this->maquinaModel->find($maquina_id);
$this->viewData['breadcrumb'] = [
['title' => lang("Produccion.maquinista.maquinas"), 'route' => route_to("viewProduccionMaquinistaMaquinas"), 'active' => false],
['title' => $maquina->nombre, 'route' => route_to("viewProduccionMaquinistaMaquina", $maquina_id), 'active' => true],
];
$this->viewData["maquinaEntity"] = $maquina;
return view(static::$viewPath . '/maquinista/viewMaquinistaMaquinaTareas', $this->viewData);
}
public function maquinista_maquina_tarea_view(int $orden_trabajo_tarea_id)
{
$otTareaEntity = $this->otTarea->find($orden_trabajo_tarea_id);
$this->viewData['ot_tarea'] = $otTareaEntity;
$this->viewData['ot'] = $otTareaEntity->orden_trabajo();
$this->viewData['presupuesto'] = $this->viewData['ot']->presupuesto();
$this->viewData['breadcrumb'] = [
['title' => lang("Produccion.maquinista.maquinas"), 'route' => route_to("viewProduccionMaquinistaMaquinas"), 'active' => false],
['title' => $otTareaEntity->maquina_actual()->nombre, 'route' => route_to("viewProduccionMaquinaTareasList", $otTareaEntity?->maquina_actual()?->id), 'active' => true],
['title' => $otTareaEntity->nombre, 'route' => route_to("viewProduccionMaquinistaTareaView", $otTareaEntity->id), 'active' => true]
];
return view(static::$viewPath . '/maquinista/viewMaquinistaMaquinaTarea', $this->viewData);
}
public function maquinista_colas_view()
{
return view(static::$viewPath . '/maquinista/viewMaquinistaPlanningList', $this->viewData);
}
public function maquinista_maquina_tareas_datatable(string $content, int $maquina_id)
{
$pm = $this->produccionService->getMaquinaImpresionTareasList($maquina_id);
if ($content == 'today') {
$pm->like('pedidos.fecha_impresion', Time::now()->format('Y-m-d'));
}
return DataTable::of($pm)
->edit('fecha_impresion', fn($q) => $q->fecha_impresion ? Time::createFromFormat('Y-m-d H:i:s', $q->fecha_impresion)->format('d/m/Y') : '')
->add('action', fn($q) => $this->produccionService->buttonActionDatatableTareaList($q->ot_tarea_id))
->toJson(true);
}
public function store_orden_trabajo_progress_date()
{
try {
$bodyData = $this->request->getPost();
$validated = $this->validation->run($bodyData, "orden_trabajo_tarea_progress_date");
// return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $this->validation->getValidated(),"errors" => $this->validation->getErrors()]);
if ($validated) {
$validatedData = $this->validation->getValidated();
$r = $this->produccionService->storeOrdenTrabajoTareaProgressDate($validatedData);
$otTareaEntity = $this->otTarea->find($validatedData['ot_tarea_id']);
$data = [
"tiempo_trabajado" => float_seconds_to_hhmm_string($otTareaEntity->tiempo_trabajado()),
"tarea" => $otTareaEntity,
"estado" => $validatedData['estado'],
];
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $data]);
} else {
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
} catch (\Throwable $th) {
return $this->response->setJSON(["status" => false, "error" => $th->getMessage()])->setStatusCode(500);
}
}
public function delete_orden_trabajo_progress_date(int $orden_trabajo_tarea_id)
{
$status = $this->produccionService->deleteOrdenTrabajoTareaProgressDates($orden_trabajo_tarea_id);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status]);
}
public function get_orden_trabajo_progress_date(int $orden_trabajo_tarea_id)
{
$otTareaEntity = $this->otTarea->find($orden_trabajo_tarea_id);
$data = [
"tiempo_trabajado" => float_seconds_to_hhmm_string($otTareaEntity->tiempo_trabajado()),
"progress_dates" => $otTareaEntity->progress_dates(),
];
return $this->response->setJSON($data);
}
public function update_pod_pedido_dates($orden_trabajo_id)
{
$this->produccionService->init($orden_trabajo_id);
if($this->produccionService->isPOD){
$status = $this->produccionService->updatePodDates();
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status, "data" => $this->produccionService->getPedido()]);
}else{
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => false, "data" => $this->produccionService->getPedido()]);
}
}
public function get_orden_trabajo_tareas_dates($orden_trabajo_id)
{
$data = $this->produccionService->init($orden_trabajo_id)->getOrdenTrabajoTareaDates();
return $this->response->setJSON(["data" => $data ]);
}
}

0
ci4/app/Controllers/Sistema/Actividad.php Normal file → Executable file
View File

0
ci4/app/Controllers/Sistema/AuthAPIController.php Normal file → Executable file
View File

27
ci4/app/Controllers/Sistema/Intranet.php Normal file → Executable file
View File

@ -56,10 +56,33 @@ class Intranet extends Controller
}
}
function orden_trabajo($ot_id,$resource_name)
function orden_trabajo($ot_id, $resource_name)
{
helper('file');
$resource_path = WRITEPATH . 'uploads/orden_trabajo/'.$ot_id. '/' . $resource_name;
$resource_path = WRITEPATH . 'uploads/orden_trabajo/' . $ot_id . '/' . $resource_name;
if (file_exists($resource_path)) {
// Get the mime type of the file
$mime_type = mime_content_type($resource_path);
// Get an instance of the Response class
$response = service('response');
// Set the content type
$response->setContentType($mime_type);
// Set the output
$response->setBody(file_get_contents($resource_path));
// Send the response to the browser
$response->send();
}
}
function catalogo($catalogo_id, $resource_name)
{
helper('file');
$resource_path = WRITEPATH . 'uploads/catalogo/' . $catalogo_id . '/' . $resource_name;
if (file_exists($resource_path)) {
// Get the mime type of the file
$mime_type = mime_content_type($resource_path);

0
ci4/app/Controllers/Soporte/Ticketcontroller.php Normal file → Executable file
View File

View File

View File

View File

View File

View File

@ -11,7 +11,8 @@ use App\Models\Configuracion\MaquinaModel;
use App\Models\Presupuestos\ImportadorModel;
use App\Models\Presupuestos\PresupuestoModel;
use App\Models\Usuarios\GroupModel;
use App\Models\Usuarios\PermisosModel;
use App\Models\Catalogo\CatalogoLibroModel;
use App\Models\Catalogo\IdentificadorIskModel;
use App\Services\PresupuestoService;
use CodeIgniter\Shield\Entities\User;
@ -22,33 +23,48 @@ class Test extends BaseController
{
}
public function echo(){
public function echo()
{
echo "echo";
}
public function index()
private function index()
{
$emailService = service('emailService');
return $emailService->send("Hola mundo", "Hola mundo", "imnavajas@coit.es");
$modelCL = new CatalogoLibroModel();
$modelISK = new IdentificadorIskModel();
// Obtener todos los registros sin isk
$registros = $modelCL->where('isk', null)->findAll();
$i = 0;
foreach ($registros as $registro) {
$isk = $modelISK->newIsk();
$modelCL->update($registro->id, ['isk' => $isk]);
echo "[" . $i++ . "]Asignado ISK {$isk} a ID {$registro->id}<br>";
}
}
private function clonar_tarifa_encuadernacion($teOrigen, $teDestino){
private function clonar_tarifa_encuadernacion($teOrigen, $teDestino)
{
$tet_model = model('App\Models\Tarifas\TarifaEncuadernacionTiradaModel');
$tel_model = model('App\Models\Tarifas\TarifaEncuadernacionLineaModel');
$tarifasTiradas = $tet_model->asObject()->where('tarifa_encuadernacion_id',$teOrigen)->findAll();
$tarifasTiradas = $tet_model->asObject()->where('tarifa_encuadernacion_id', $teOrigen)->findAll();
foreach ($tarifasTiradas as $tarifasTirada){
foreach ($tarifasTiradas as $tarifasTirada) {
echo "--->" . $tarifasTirada->id . "<br>";
$tarifasLineas = $tel_model->asObject()->where('tirada_encuadernacion_id',$tarifasTirada->id)->findAll();
$tarifasLineas = $tel_model->asObject()->where('tirada_encuadernacion_id', $tarifasTirada->id)->findAll();
// Prepare the data
unset($tarifasTirada->id);
@ -61,7 +77,7 @@ class Test extends BaseController
$tet_model->insert($tarifasTirada);
$inserted_id = $tet_model->insertID();
foreach ($tarifasLineas as $tarifasLinea){
foreach ($tarifasLineas as $tarifasLinea) {
echo "------>" . $tarifasLinea->id . "<br>";
@ -82,10 +98,20 @@ class Test extends BaseController
private function test_get_tirada_alt($tirada, $merma, $tipo_impresion_id,
$json_data, $cliente_id, $ancho, $alto,
$solapas_cubierta, $solapas_ancho_cubierta, $solapas_sobrecubierta, $solapas_ancho_sobrecubierta, $lomo)
{
private function test_get_tirada_alt(
$tirada,
$merma,
$tipo_impresion_id,
$json_data,
$cliente_id,
$ancho,
$alto,
$solapas_cubierta,
$solapas_ancho_cubierta,
$solapas_sobrecubierta,
$solapas_ancho_sobrecubierta,
$lomo
) {
$values = [];
if ($json_data) {
@ -96,7 +122,7 @@ class Test extends BaseController
echo '------------------------------------<br>';
var_dump($linea);
// Se obtienen los valores de cada linea para el calculo del precio
$datosPedido = (object)array(
$datosPedido = (object) array(
'paginas' => intval($linea['paginas']) ?? 0,
'tirada' => intval($tirada) ?? 0,
'merma' => intval($merma) ?? 0,
@ -174,7 +200,7 @@ class Test extends BaseController
$datosTipolog = $linea['gotaNegro'] ?? null;
if (!is_null($datosTipolog)) {
$datosTipolog = [];
$data = (object)array(
$data = (object) array(
'negro' => intval($linea['cobNegro']) ?? 0,
'cyan' => intval($linea['cobCyan']) ?? 0,
'magenta' => intval($linea['cobMagenta']) ?? 0,
@ -193,7 +219,7 @@ class Test extends BaseController
$data['papel'] = $papel;
$data['opciones_papel'] = $opciones_papel;
$data['maquina'] = $maquina;
$data['papel_generico'] = (array)$papel_generico;
$data['papel_generico'] = (array) $papel_generico;
$data['isColor'] = $isColor;
$data['a_favor_fibra'] = $linea['aFavorFibra'] ?? null;
$data['datosTipolog'] = $datosTipolog;
@ -222,7 +248,7 @@ class Test extends BaseController
// Previo a ejecutar, vaciar la tabla clientes_precios (ojo si hay customizaciones)
$db = \Config\Database::connect();
$db = \Config\Database::connect();
$builder = $db->table('cliente_precios');
$plantillaDefectoId = 5;
@ -394,14 +420,14 @@ class Test extends BaseController
{
$paginas = 240;
$papel_impresion = (object)array(
$papel_impresion = (object) array(
'id' => 198,
'gramaje' => 90,
'precio_tonelada' => 1600
);
$maquina = (object)array(
$maquina = (object) array(
//'id' => 48,
'alto' => 800,
'ancho' => 520,
@ -430,7 +456,7 @@ class Test extends BaseController
{
$uso = 'interior';
$tipo = 'negro';
$datosPedido = (object)array(
$datosPedido = (object) array(
'paginas' => 200,
'tirada' => 500,
'merma' => 10,
@ -482,7 +508,7 @@ class Test extends BaseController
echo '<pre>';
$uso = 'cubierta';
$tipo = 'color';
$datosPedido = (object)array(
$datosPedido = (object) array(
'paginas' => 200,
'tirada' => 500,
'merma' => 10,
@ -542,7 +568,7 @@ class Test extends BaseController
$datosPedido = (object)array(
$datosPedido = (object) array(
'paginas' => 240,
'tirada' => 100,
'merma' => 10,
@ -552,10 +578,10 @@ class Test extends BaseController
'isCosido' => true,
);
$parametrosRotativa = (object)array(
$parametrosRotativa = (object) array(
'a_favor_fibra' => 0,
'bnPages' => 240,
'colorPages' => 0,
'bnPages' => 240,
'colorPages' => 0,
'rotativa_gota_negro' => 0,
'rotativa_gota_color' => 0,
);
@ -587,12 +613,12 @@ class Test extends BaseController
var_dump($datosTipologias);
echo '</pre>';
$parametrosRotativa->rotativa_gota_negro = $datosTipologias[0]->gota_negro;
$parametrosRotativa->rotativa_gota_color = $datosTipologias[0]->gota_color;
$parametrosRotativa->rotativa_negro = $datosTipologias[0]->negro;
$parametrosRotativa->rotativa_cyan = $datosTipologias[0]->cyan;
$parametrosRotativa->rotativa_magenta = $datosTipologias[0]->magenta;
$parametrosRotativa->rotativa_amarillo = $datosTipologias[0]->amarillo;
$parametrosRotativa->rotativa_gota_negro = $datosTipologias[0]->gota_negro;
$parametrosRotativa->rotativa_gota_color = $datosTipologias[0]->gota_color;
$parametrosRotativa->rotativa_negro = $datosTipologias[0]->negro;
$parametrosRotativa->rotativa_cyan = $datosTipologias[0]->cyan;
$parametrosRotativa->rotativa_magenta = $datosTipologias[0]->magenta;
$parametrosRotativa->rotativa_amarillo = $datosTipologias[0]->amarillo;
echo '-------------------------------';
$maquinas = $maquina_model->getMaquinaImpresionForPresupuesto(
@ -624,7 +650,7 @@ class Test extends BaseController
$uso = 'cubierta';
$tipo = 'color';
$datosPedido = (object)array(
$datosPedido = (object) array(
'paginas' => 240,
'tirada' => 100,
'merma' => 10,
@ -714,7 +740,7 @@ class Test extends BaseController
$uso = 'sobrecubierta';
$tipo = 'colorhq';
$datosPedido = (object)array(
$datosPedido = (object) array(
'paginas' => 240,
'tirada' => 100,
'merma' => 10,

0
ci4/app/Controllers/Utiles.php Normal file → Executable file
View File

0
ci4/app/Controllers/Wiki/WikiController.php Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

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