mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Compare commits
95 Commits
feat/view-
...
feat/revis
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ce6859a2f | |||
| 2bfdd89085 | |||
| 305eea00e6 | |||
| 8ea6128109 | |||
| 7b645539e3 | |||
| fb7f2a28d9 | |||
| 39639d9ff8 | |||
| 3f90665c39 | |||
| 71e70bf551 | |||
| db70c57fb3 | |||
| 91b044bbae | |||
| a88ffda50d | |||
| 746955c3b1 | |||
| 8ca0a40b2b | |||
| 20c009f445 | |||
| 5138681718 | |||
| 9283059f9d | |||
| b75278f449 | |||
| 3fb944ff97 | |||
| c7250cb8fd | |||
| 7a9b2af8a6 | |||
| cf5a42de8d | |||
| a259d76e5e | |||
| f696153d74 | |||
| 9181905233 | |||
| 0ec7dff479 | |||
| b0fb0f18fb | |||
| cf4c4df80a | |||
| 36c9227586 | |||
| 4e9dfb51c7 | |||
| 5aab9a33ac | |||
| ea762a09c0 | |||
| 21014d029f | |||
| 9c31f2bbc5 | |||
| b288ca498c | |||
| 96a6845c0c | |||
| eed5c0994e | |||
| e2ab42cd84 | |||
| 7da76af866 | |||
| bf1e66d746 | |||
| adccc414be | |||
| 95fa192cb9 | |||
| 9310d2dabd | |||
| 3abf45ca6e | |||
| 6ea22066c2 | |||
| bf21a336b1 | |||
| d1e5731d1d | |||
| 029757bb40 | |||
| bb4c9690b9 | |||
| 6d45a950df | |||
| 6f8890a8b1 | |||
| c093c01c00 | |||
| a4532a7ff6 | |||
| 31a12ff343 | |||
| 1d6f5fe53e | |||
| 0b767c63e9 | |||
| e464652fe2 | |||
| dd20f2a20e | |||
| 97554bffc9 | |||
| 73e9e941ed | |||
| 05720cf1ce | |||
| 04e9e3ee6f | |||
| 9804a6a927 | |||
| 3402e67fb2 | |||
| b1932e6f85 | |||
| 13ae70236e | |||
| 4d8332e625 | |||
| c75d08b3c3 | |||
| a0b5f3b4df | |||
| 0e444295e3 | |||
| ae7707057a | |||
| ff115f4f20 | |||
| 45e41c77e4 | |||
| ae456c8890 | |||
| e8958dc893 | |||
| b0ac132e59 | |||
| b50e564641 | |||
| 894770d6ce | |||
| 367c7c2ea8 | |||
| 9375b9b624 | |||
| 9a6a4f89a2 | |||
| 7f31e65960 | |||
| 5aa2a2e6c9 | |||
| dfbcb13ba5 | |||
| 033184cfa2 | |||
| 25b6d14423 | |||
| 96bd24ae8b | |||
| b5b86b4164 | |||
| ef173ab0fc | |||
| f473caf06c | |||
| 5e8a7f8bd4 | |||
| 905112334f | |||
| d0f37cb714 | |||
| 151e4a2d7a | |||
| 05ebfa06df |
@ -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,7 +27,6 @@ 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",
|
||||
@ -65,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"],
|
||||
];
|
||||
@ -100,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"],
|
||||
@ -116,6 +121,14 @@ class OrdenTrabajo extends BaseConfig
|
||||
"default" => ["bg" => "white", "color" => "black"],
|
||||
];
|
||||
|
||||
public array $OT_TAREA_STATUS_COLOR = [
|
||||
"P" => '#FFB22C',
|
||||
"F" => '#67AE6E',
|
||||
"S" => '#EB5B00',
|
||||
"I" => '#3A59D1',
|
||||
"E" => '#FF0B55',
|
||||
"D" => '#FFA725',
|
||||
];
|
||||
|
||||
|
||||
public function __construct()
|
||||
|
||||
Binary file not shown.
@ -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']);
|
||||
@ -522,6 +524,9 @@ $routes->group('albaranes', ['namespace' => 'App\Controllers\Albaranes'], functi
|
||||
$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']);
|
||||
|
||||
@ -639,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']);
|
||||
@ -649,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,18 +742,28 @@ $routes->group('soporte', ['namespace' => 'App\Controllers\Soporte'], function (
|
||||
|
||||
$routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
|
||||
$routes->group('ordentrabajo', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
|
||||
/** VIEWS */
|
||||
$routes->get('', 'Ordentrabajo::index', ['as' => 'viewOrdenTrabajoIndex']);
|
||||
$routes->get('edit/(:num)', 'Ordentrabajo::edit/$1', ['as' => 'viewOrdenTrabajoEdit']);
|
||||
$routes->delete('reset/tareas/(:num)', 'Ordentrabajo::reset_tareas/$1');
|
||||
$routes->delete('tareas/(:num)', 'Ordentrabajo::delete_tarea/$1');
|
||||
|
||||
/** GET */
|
||||
$routes->get('summary/(:num)', 'Ordentrabajo::get_orden_trabajo_summary/$1', ['as' => 'getOrdenTrabajoSumary']);
|
||||
$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');
|
||||
$routes->get('tareas/maquina/(:num)/(:num)','Ordentrabajo::get_tareas_ot_maquina/$1/$2');
|
||||
/** DATATABLES */
|
||||
$routes->get('datatable', 'Ordentrabajo::datatable');
|
||||
$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('maquinas/ots/datatable/(:num)','Ordentrabajo::datatable_maquina_ordenes_trabajo/$1');
|
||||
$routes->get('maquinas/ots/(:num)','Ordentrabajo::get_maquina_ots/$1');
|
||||
/**======================
|
||||
* UPDATES
|
||||
*========================**/
|
||||
@ -754,26 +772,41 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func
|
||||
$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->delete("tarea/progress/(:num)","Ordentrabajo::delete_orden_trabajo_progress_date/$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->post("fa/tareas/finish", 'Ordentrabajo::update_orden_trabajo_fa_tareas');
|
||||
$routes->post('maquinas/ots','Ordentrabajo::store_maquina_ordenes_trabajo');
|
||||
$routes->post('maquinas/ots/estado','Ordentrabajo::update_maquina_ordenes_trabajo_estado');
|
||||
|
||||
|
||||
/**DELETES */
|
||||
$routes->delete("portada/(:num)", 'Ordentrabajo::delete_orden_trabajo_portada/$1');
|
||||
$routes->delete("tarea/progress/(:num)", "Ordentrabajo::delete_orden_trabajo_progress_date/$1");
|
||||
$routes->delete('reset/tareas/(:num)', 'Ordentrabajo::reset_tareas/$1');
|
||||
$routes->delete('tareas/(:num)', 'Ordentrabajo::delete_tarea/$1');
|
||||
$routes->delete('maquinas/ots/(:num)', 'Ordentrabajo::delete_maquina_orden_trabajo_tarea/$1');
|
||||
$routes->delete('maquinas/ots/all/(:num)', 'Ordentrabajo::delete_maquina_orden_trabajo_all/$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"]);
|
||||
$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');
|
||||
/** PLANNING */
|
||||
$routes->group('planning', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
|
||||
$routes->get('select/maquina/rotativa', 'Ordentrabajo::select_maquina_planning_rot');
|
||||
$routes->get('select/papel/rotativa', 'Ordentrabajo::select_papel_planning_rot');
|
||||
@ -789,12 +822,21 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func
|
||||
});
|
||||
|
||||
$routes->group('maquinista', ['namespace' => 'App\Controllers\Produccion'], function ($routes) {
|
||||
/**
|
||||
* VIEWS
|
||||
*/
|
||||
$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/auto/(:num)', 'Ordentrabajo::maquinista_maquina_tareas_fichaje_automatico/$1', ['as' => 'viewMaquinistaFichajeAutomatico']);
|
||||
$routes->get('maquinas/view/scan/(:num)', 'Ordentrabajo::maquinista_maquina_tareas_scan/$1', ['as' => 'viewMaquinistaTareaScan']);
|
||||
$routes->get('maquinas/view/tarea/(:num)', 'Ordentrabajo::maquinista_maquina_tarea_view/$1', ['as' => 'viewProduccionMaquinistaTareaView']);
|
||||
$routes->get('maquinas/view/maquina/ot/tareas/(:num)', 'Ordentrabajo::maquinista_maquina_ot_tareas_view/$1', ['as' => 'viewProduccionMaquinistaOtTareasView']);
|
||||
|
||||
$routes->get('colas/view', 'Ordentrabajo::maquinista_colas_view', ['as' => 'viewProduccionMaquinistaColas']);
|
||||
|
||||
/** DATATABLE */
|
||||
$routes->get('maquinas/tareas/datatable/(:alpha)/(:num)', 'Ordentrabajo::maquinista_maquina_tareas_datatable/$1/$2', ['as' => 'viewMaquinistaMaquinaTareaDatatable']);
|
||||
$routes->get('maquinas/tareas/aplazadas/datatable/(:num)', 'Ordentrabajo::maquinista_maquina_tareas_aplazada_datatable/$1', ['as' => 'viewMaquinistaMaquinaTareaAplazadaDatatable']);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -803,6 +845,8 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi
|
||||
$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('etiquetasLogistica', 'LogisticaController::etiquetasLogistica', ['as' => 'etiquetasLogistica']);
|
||||
$routes->get('datatableEnvios', 'LogisticaController::datatable_envios');
|
||||
$routes->get('datatableLineasEnvios/(:num)', 'LogisticaController::datatable_enviosEdit/$1');
|
||||
$routes->get('envio/(:num)', 'LogisticaController::editEnvio/$1');
|
||||
@ -817,8 +861,31 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi
|
||||
$routes->post('updateProveedorEnvio', 'LogisticaController::updateProveedorEnvio');
|
||||
$routes->post('finalizarEnvio', 'LogisticaController::finalizarEnvio');
|
||||
$routes->post('generateEnvio', 'LogisticaController::generarEnvio');
|
||||
$routes->get('selectPedidosForEnvio', 'LogisticaController::findPedidosNewEnvio');
|
||||
$routes->get('selectDireccionForEnvio', 'LogisticaController::selectDireccionForEnvio');
|
||||
$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']);
|
||||
});
|
||||
|
||||
$routes->group('etiquetasTitulos', ['namespace' => 'App\Controllers\Logistica'], function ($routes) {
|
||||
|
||||
$routes->get('otList', 'EtiquetasTitulosController::findOTs');
|
||||
$routes->get('addList', 'EtiquetasTitulosController::findAddresses');
|
||||
$routes->post('newEtiquetaTitulos', 'EtiquetasTitulosController::addEtiqueta');
|
||||
$routes->get('datatable', 'EtiquetasTitulosController::datatable');
|
||||
$routes->post('delete', 'EtiquetasTitulosController::deleteEtiqueta');
|
||||
$routes->get('edit/(:num)', 'EtiquetasTitulosController::edit/$1');
|
||||
$routes->get('datatableLineas/(:num)', 'EtiquetasTitulosController::datatableLineasEtiquetas/$1');
|
||||
$routes->get('findOts', 'EtiquetasTitulosController::findOtsWithAddress');
|
||||
$routes->post('addLineas', 'EtiquetasTitulosController::addLineasEtiqueta');
|
||||
$routes->post('deleteLineas', 'EtiquetasTitulosController::deleteLineasEtiqueta');
|
||||
$routes->post('updateLineas', 'EtiquetasTitulosController::updateLineasEtiqueta');
|
||||
$routes->post('updateComentarios', 'EtiquetasTitulosController::updateComentarios');
|
||||
$routes->post('updateOrdenCajas', 'EtiquetasTitulosController::updateOrdenCajas');
|
||||
$routes->post('renumber', 'EtiquetasTitulosController::renumberCajas');
|
||||
$routes->post('imprimirEtiquetas', 'EtiquetasTitulosController::imprimirEtiquetas');
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
@ -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']);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
38
ci4/app/Config/Routes/ImportadoresRoutes.php
Normal file
38
ci4/app/Config/Routes/ImportadoresRoutes.php
Normal 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');
|
||||
|
||||
});
|
||||
});
|
||||
@ -172,6 +172,40 @@ class Validation extends BaseConfig
|
||||
"label" => "Orden trabajo"
|
||||
],
|
||||
|
||||
];
|
||||
public array $orden_trabajo_fichaje_auto = [
|
||||
"orden_trabajo_id" => [
|
||||
"rules" => "required|integer",
|
||||
"label" => "Orden trabajo"
|
||||
],
|
||||
"maquina_id" => [
|
||||
"rules" => "required|integer",
|
||||
"label" => "Máquina"
|
||||
],
|
||||
"tareas" => [
|
||||
"rules" => "required",
|
||||
"label" => "Tareas"
|
||||
],
|
||||
"click_init" => [
|
||||
"rules" => "required|integer",
|
||||
"label" => "Click init"
|
||||
],
|
||||
"click_end" => [
|
||||
"rules" => "required|integer",
|
||||
"label" => "Click end"
|
||||
],
|
||||
|
||||
];
|
||||
public array $maquina_ordenes_trabajo = [
|
||||
"ordenes_trabajo" => [
|
||||
"rules" => "required",
|
||||
"label" => "Orden trabajo"
|
||||
],
|
||||
"maquina_id" => [
|
||||
"rules" => "required|integer",
|
||||
"label" => "Máquina"
|
||||
],
|
||||
|
||||
];
|
||||
public array $chat_department =
|
||||
[
|
||||
@ -184,4 +218,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",
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -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']);
|
||||
|
||||
@ -47,6 +47,18 @@ class Albaran extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@ -305,6 +317,23 @@ class Albaran extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
@ -324,6 +353,32 @@ class Albaran extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
Portada Id Cliente Título Edición Autor Archivo ISBN EAN Páginas Acciones
|
||||
Lo que hay que listar
|
||||
@ -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);
|
||||
|
||||
103
ci4/app/Controllers/Configuracion/FestivoController.php
Normal file
103
ci4/app/Controllers/Configuracion/FestivoController.php
Normal 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
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
396
ci4/app/Controllers/Importadores/ImportadorBubok.php
Normal file
396
ci4/app/Controllers/Importadores/ImportadorBubok.php
Normal 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()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
322
ci4/app/Controllers/Importadores/ImportadorCatalogo.php
Normal file
322
ci4/app/Controllers/Importadores/ImportadorCatalogo.php
Normal 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()
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
467
ci4/app/Controllers/Logistica/EtiquetasTitulosController.php
Normal file
467
ci4/app/Controllers/Logistica/EtiquetasTitulosController.php
Normal file
@ -0,0 +1,467 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Logistica;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Services\ImpresoraEtiquetaService;
|
||||
use App\Services\EtiquetasTitulosService;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
|
||||
class EtiquetasTitulosController extends BaseController
|
||||
{
|
||||
|
||||
protected ImpresoraEtiquetaService $impresoraEtiquetaService;
|
||||
protected string $locale;
|
||||
protected array $viewData;
|
||||
|
||||
protected static $controllerSlug = 'etiquetas_titulos';
|
||||
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->model = model('App\Models\Etiquetas\EtiquetasTitulosModel');
|
||||
|
||||
$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 findOTs()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$query = EtiquetasTitulosService::getOtsWithTitulos();
|
||||
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("ot.id", $this->request->getGet("q"))
|
||||
->orLike("pr.titulo)", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
$result = $query->orderBy("id", "DESC")->get()->getResultObject();
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function findAddresses()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$ot_id = $this->request->getGet("ot_id");
|
||||
|
||||
$query = EtiquetasTitulosService::getDireccionesOT($ot_id);
|
||||
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("pd.direccion", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
$result = $query->orderBy("pd.direccion", "ASC")->get()->getResultObject();
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function addEtiqueta()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$data = [];
|
||||
$data['user_id'] = auth()->user()->id;
|
||||
$data['ot_id'] = $this->request->getPost('ot_id') ?? null;
|
||||
$data['direccion'] = $this->request->getPost('direccion') ?? null;
|
||||
$data['unidades_caja'] = $this->request->getPost('unidades_caja') ?? null;
|
||||
|
||||
if (
|
||||
$this->request->getPost('ot_id') == null ||
|
||||
$this->request->getPost('direccion') == null ||
|
||||
$this->request->getPost('unidades_caja') == null
|
||||
) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errorMissingData')
|
||||
];
|
||||
}
|
||||
|
||||
$result = EtiquetasTitulosService::addEtiqueta($data);
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteEtiqueta($id = null)
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$id = $this->request->getPost('id') ?? null;
|
||||
|
||||
if ($id == null) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errorMissingData')
|
||||
];
|
||||
}
|
||||
|
||||
$modelLineas = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
$ids = $modelLineas->where('etiqueta_titulos_id', $id)->findColumn('id');
|
||||
if ($ids) {
|
||||
$modelLineas->delete($ids);
|
||||
}
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosModel');
|
||||
$id = $model->where('id', $id)->findColumn('id');
|
||||
if ($id) {
|
||||
$model->delete($id);
|
||||
}
|
||||
$result = [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.jhn<successDeleteEtiqueta'),
|
||||
];
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function edit($id = null)
|
||||
{
|
||||
|
||||
if (empty($id)) {
|
||||
return redirect()->to(base_url('logistica/selectEnvios/simple'))->with('error', lang('Logistica.errors.noEnvio'));
|
||||
}
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosModel');
|
||||
$etiquetaEntity = $model->select('etiquetas_titulos.*, clientes.nombre as cliente')
|
||||
->join('clientes', 'clientes.id = etiquetas_titulos.cliente_id', 'left')
|
||||
->where('etiquetas_titulos.id', $id)
|
||||
->first();
|
||||
if (empty($etiquetaEntity)) {
|
||||
return redirect()->to(base_url('logistica/etiquetasLogistica'))->with('error', lang('Logistica.errors.noEnvio'));
|
||||
}
|
||||
|
||||
|
||||
$modelImpresora = model('App\Models\Configuracion\ImpresoraEtiquetaModel');
|
||||
$impresoras = $modelImpresora->select('id, name')
|
||||
->where('deleted_at', null)
|
||||
->where('tipo', 1)
|
||||
->orderBy('name', 'asc')
|
||||
->findAll();
|
||||
$etiquetaEntity->impresoras = $impresoras;
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'boxTitle' => '<i class="ti ti-ticket ti-xl"></i>' . ' ' . lang('Logistica.EtiquetasTitulos') . ' [' . $etiquetaEntity->id . ']: ' . $etiquetaEntity->direccion,
|
||||
'usingServerSideDataTable' => true,
|
||||
'etiquetaEntity' => $etiquetaEntity,
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewEtiquetasTitulosEdit', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
$q = $this->model->getEtiquetasTitulos();
|
||||
|
||||
if (!empty($otsFilter)) {
|
||||
$q->groupStart();
|
||||
$q->like('etl.ot_id', $otsFilter);
|
||||
$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" data-id="' . $q->id . '"></i></a>
|
||||
</div>
|
||||
';
|
||||
});
|
||||
|
||||
return $result->toJson(returnAsObject: true);
|
||||
}
|
||||
|
||||
public function findOtsWithAddress()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$id = $this->request->getGet('id') ?? null;
|
||||
|
||||
$query = EtiquetasTitulosService::findOTsWithAddress($id);
|
||||
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("name", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
$result = $query->orderBy("id", "DESC")->get()->getResultObject();
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function addLineasEtiqueta()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$etiqueta_id = $this->request->getPost('etiqueta_id') ?? null;
|
||||
$ot_id = $this->request->getPost('ot_id') ?? null;
|
||||
$unidades = $this->request->getPost('unidades') ?? null;
|
||||
$cajas = $this->request->getPost('cajas') ?? null;
|
||||
|
||||
$result = EtiquetasTitulosService::addLineasEtiqueta($etiqueta_id, $ot_id, $unidades, $cajas);
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function datatableLineasEtiquetas($id = null)
|
||||
{
|
||||
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
|
||||
$id = $this->request->getGet('id') ?? null;
|
||||
$direccion = $this->request->getGet('direccion') ?? null;
|
||||
|
||||
$q = $model->getDatatableQuery($id, $direccion);
|
||||
|
||||
|
||||
$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(
|
||||
"ot",
|
||||
function ($row, $meta) {
|
||||
return '<a href="' . base_url('produccion/ordentrabajo/edit/' . $row->ot) . '" target="_blank">' . $row->ot . '</a>';
|
||||
}
|
||||
)
|
||||
->edit(
|
||||
"unidades",
|
||||
function ($row, $meta) {
|
||||
return '<input type="number" class="form-control input-lineas input-unidades text-center"
|
||||
data-id="' . $row->id . '" data-name="unidades" value="' . $row->unidades . '">';
|
||||
}
|
||||
)
|
||||
->edit(
|
||||
"numero_caja",
|
||||
function ($row, $meta) {
|
||||
return '<input type="number" class="form-control input-lineas input-cajas text-center"
|
||||
data-id="' . $row->id . '" data-name="numero_caja" value="' . $row->numero_caja . '">';
|
||||
}
|
||||
)
|
||||
->add("unidades_raw", fn($row) => $row->unidades)
|
||||
->add("pesoUnidad_raw", fn($row) => $row->pesoUnidad)
|
||||
->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" data-id="' . $q->id . '"></i></a>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
);
|
||||
|
||||
return $result->toJson(returnAsObject: true);
|
||||
}
|
||||
|
||||
public function deleteLineasEtiqueta()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$ids = $this->request->getPost('ids') ?? [];
|
||||
|
||||
if ($ids == [] || $ids == null) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.errorMissingData')
|
||||
];
|
||||
}
|
||||
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
for ($i = 0; $i < count($ids); $i++) {
|
||||
$model->delete($ids[$i]);
|
||||
}
|
||||
|
||||
|
||||
$result = [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.successDeleteLines'),
|
||||
];
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateLineasEtiqueta()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$id = $this->request->getPost('id') ?? null;
|
||||
$name = $this->request->getPost('name') ?? null;
|
||||
$value = $this->request->getPost('value') ?? null;
|
||||
|
||||
if ($id == null || $name == null || $value == null) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.errorMissingData')
|
||||
];
|
||||
}
|
||||
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
$model->update($id, [$name => $value]);
|
||||
|
||||
$result = [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.successUpdateLine'),
|
||||
];
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateComentarios()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$id = $this->request->getPost('id') ?? null;
|
||||
$comentarios = $this->request->getPost('comentarios') ?? null;
|
||||
|
||||
if ($id == null || $comentarios == null) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.errorMissingData')
|
||||
];
|
||||
}
|
||||
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosModel');
|
||||
$model->update($id, ['comentarios' => $comentarios]);
|
||||
|
||||
$result = [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.comentariosUpdated'),
|
||||
];
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateOrdenCajas()
|
||||
{
|
||||
$rawInput = $this->request->getBody();
|
||||
$data = json_decode($rawInput, true);
|
||||
$orden = $data['orden'] ?? [];
|
||||
|
||||
if (!is_array($orden)) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Datos inválidos'
|
||||
]);
|
||||
}
|
||||
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
|
||||
foreach ($orden as $item) {
|
||||
if (isset($item['id'], $item['numero_caja'])) {
|
||||
$model->update($item['id'], [
|
||||
'numero_caja' => $item['numero_caja'],
|
||||
'updated_at' => date('Y-m-d H:i:s') // opcional
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
'message' => 'Orden de cajas actualizado correctamente'
|
||||
]);
|
||||
}
|
||||
|
||||
public function renumberCajas()
|
||||
{
|
||||
$id = $this->request->getPost('id') ?? null;
|
||||
|
||||
if ($id == null) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.errorMissingData')
|
||||
];
|
||||
}
|
||||
|
||||
$result = EtiquetasTitulosService::reordenarCajas($id);
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
}
|
||||
|
||||
public function imprimirEtiquetas()
|
||||
{
|
||||
$etiqueta_id = $this->request->getPost('etiqueta_id') ?? null;
|
||||
$ids = $this->request->getPost('ids') ?? [];
|
||||
$impresora_id = $this->request->getPost('impresora_id') ?? null;
|
||||
|
||||
$modelImpresora = model('App\Models\Configuracion\ImpresoraEtiquetaModel');
|
||||
$impresora = $modelImpresora->select('id, name, ip, port, user, pass')
|
||||
->where('deleted_at', null)
|
||||
->where('id', $impresora_id)
|
||||
->orderBy('name', 'asc')
|
||||
->first();
|
||||
if ($impresora == null) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Impresora no válida'
|
||||
]);
|
||||
}
|
||||
|
||||
if ($etiqueta_id == null || $ids == []) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.errorMissingData')
|
||||
];
|
||||
}
|
||||
|
||||
$result = EtiquetasTitulosService::imprimirEtiquetas($etiqueta_id, $ids, $impresora);
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
}
|
||||
|
||||
}
|
||||
@ -62,6 +62,7 @@ class LogisticaController extends BaseController
|
||||
'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
|
||||
@ -70,11 +71,57 @@ class LogisticaController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
public function findPedidosNewEnvio()
|
||||
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 etiquetasLogistica()
|
||||
{
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'boxTitle' => lang('Logistica.etiquetasTitulos'),
|
||||
'usingServerSideDataTable' => true,
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewImpresionEtiquetas', $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()) {
|
||||
$query = LogisticaService::findPedidosNewEnvio();
|
||||
|
||||
$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"))
|
||||
@ -94,12 +141,12 @@ class LogisticaController extends BaseController
|
||||
public function selectDireccionForEnvio(){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$pedido_id = $this->request->getGet('pedido_id');
|
||||
if($pedido_id == null || $pedido_id == 0){
|
||||
$ot = $this->request->getGet('ot_id');
|
||||
if($ot == null || $ot == 0){
|
||||
return [];
|
||||
}
|
||||
$searchVal = $this->request->getGet("q") ?? "";
|
||||
$result = LogisticaService::findDireccionesNewEnvio($pedido_id, $searchVal);
|
||||
$result = LogisticaService::findDireccionesNewEnvio($ot, $searchVal);
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
@ -109,34 +156,91 @@ class LogisticaController extends BaseController
|
||||
|
||||
|
||||
|
||||
public function searchPedidoOrISBN($search = "", $envio_id = null)
|
||||
{
|
||||
|
||||
if (empty($search)) {
|
||||
$result = [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noDataToFind'),
|
||||
];
|
||||
return $this->response->setJSON($result);
|
||||
}
|
||||
$result = LogisticaService::findPedidoOrISBN($search);
|
||||
return $this->response->setJSON($result);
|
||||
}
|
||||
|
||||
|
||||
public function generarEnvio()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$pedido_id = $this->request->getPost('pedido_id');
|
||||
$direccion = $this->request->getPost('direccion');
|
||||
$result = LogisticaService::generateEnvio($pedido_id, $direccion);
|
||||
$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()
|
||||
{
|
||||
|
||||
@ -176,8 +280,18 @@ class LogisticaController extends BaseController
|
||||
|
||||
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();
|
||||
$q = $model->getDatatableQuery($tipo_envio);
|
||||
|
||||
if (!empty($otsFilter)) {
|
||||
$q->groupStart();
|
||||
$q->like('t5.id', $otsFilter);
|
||||
$q->groupEnd();
|
||||
}
|
||||
|
||||
|
||||
$result = DataTable::of($q)
|
||||
@ -227,6 +341,14 @@ class LogisticaController extends BaseController
|
||||
$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,
|
||||
@ -298,7 +420,7 @@ class LogisticaController extends BaseController
|
||||
)->edit(
|
||||
"unidadesEnvio",
|
||||
function ($row, $meta) {
|
||||
if($row->finalizado == 1){
|
||||
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"
|
||||
|
||||
@ -993,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;
|
||||
@ -1071,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(
|
||||
@ -1105,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'];
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
namespace App\Controllers\Produccion;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Compras\ProveedorModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\Configuracion\MaquinaOtTareaModel;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoUser;
|
||||
@ -28,7 +30,9 @@ class Ordentrabajo extends BaseController
|
||||
protected OrdenTrabajoModel $otModel;
|
||||
protected OrdenTrabajoUser $otUserModel;
|
||||
protected OrdenTrabajoTarea $otTarea;
|
||||
protected ProveedorModel $proveedorModel;
|
||||
protected MaquinaModel $maquinaModel;
|
||||
protected MaquinaOtTareaModel $maquinaOtTareaModel;
|
||||
protected UserModel $userModel;
|
||||
protected Validation $validation;
|
||||
protected static $viewPath = 'themes/vuexy/form/produccion/';
|
||||
@ -45,6 +49,8 @@ class Ordentrabajo extends BaseController
|
||||
$this->produccionService = new ProductionService();
|
||||
$this->otTarea = model(OrdenTrabajoTarea::class);
|
||||
$this->maquinaModel = model(MaquinaModel::class);
|
||||
$this->maquinaOtTareaModel = model(MaquinaOtTareaModel::class);
|
||||
$this->proveedorModel = model(ProveedorModel::class);
|
||||
$this->validation = service("validation");
|
||||
helper("time");
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -70,6 +76,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 {
|
||||
@ -100,10 +111,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);
|
||||
@ -121,6 +144,18 @@ 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();
|
||||
@ -128,7 +163,7 @@ class Ordentrabajo extends BaseController
|
||||
$validated = $this->validation->run($bodyData, "orden_trabajo_date");
|
||||
if ($validated) {
|
||||
$validatedData = $bodyData;
|
||||
$r = $this->produccionService->emptyOrdenTrabajoDate($validatedData['orden_trabajo_id'],$validatedData['name']);
|
||||
$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);
|
||||
@ -210,7 +245,7 @@ class Ordentrabajo extends BaseController
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado", ["I", "PM"]);
|
||||
$q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado", ["I", "PM"])->where('ordenes_trabajo.preimpresion_revisada', true);
|
||||
// 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()])
|
||||
@ -225,7 +260,7 @@ 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()])
|
||||
@ -240,7 +275,7 @@ 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()])
|
||||
@ -251,6 +286,62 @@ class Ordentrabajo extends BaseController
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function datatable_news()
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.preimpresion_revisada', 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_prod()
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
|
||||
$q = $this->otModel->getDatatableQuery()->where('ordenes_trabajo.preimpresion_revisada', true)->where('pedidos.estado', 'produccion');
|
||||
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") : ""
|
||||
)
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
public function papel_gramaje_datatable()
|
||||
{
|
||||
|
||||
@ -286,8 +377,10 @@ class Ordentrabajo extends BaseController
|
||||
return DataTable::of($q)
|
||||
->add("action", fn($q) => $q)
|
||||
->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("tarea_estado", fn($q) => $this->produccionService->getTitleTareaEstado($q->id))
|
||||
->edit("tiempo_estimado", fn($q) => float_seconds_to_hhmmss_string($q->tiempo_estimado))
|
||||
->edit("tiempo_real", fn($q) => float_seconds_to_hhmmss_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);
|
||||
@ -296,6 +389,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 {
|
||||
@ -503,8 +604,26 @@ class Ordentrabajo extends BaseController
|
||||
['title' => $maquina->nombre, 'route' => route_to("viewProduccionMaquinistaMaquina", $maquina_id), 'active' => true],
|
||||
];
|
||||
$this->viewData["maquinaEntity"] = $maquina;
|
||||
return view(static::$viewPath . '/maquinista/viewMaquinistaMaquinaTareas', $this->viewData);
|
||||
$tareasRunning = $this->maquinaOtTareaModel->queryDatatableJoinOrdenTrabajo($maquina->id)->countAllResults();
|
||||
if ($tareasRunning) {
|
||||
return view(static::$viewPath . '/maquinista/viewProduccionMaquinistaOtTareasView', $this->viewData);
|
||||
} else {
|
||||
return view(static::$viewPath . '/maquinista/viewMaquinistaMaquinaTareas', $this->viewData);
|
||||
}
|
||||
}
|
||||
public function maquinista_maquina_tareas_fichaje_automatico(int $maquina_id)
|
||||
{
|
||||
$maquina = $this->maquinaModel->find($maquina_id);
|
||||
$this->viewData["maquinaEntity"] = $maquina;
|
||||
return view(static::$viewPath . '/maquinista/viewMaquinistaFichajeAutomatico', $this->viewData);
|
||||
}
|
||||
public function maquinista_maquina_tareas_scan(int $maquina_id)
|
||||
{
|
||||
$maquina = $this->maquinaModel->find($maquina_id);
|
||||
$this->viewData["maquinaEntity"] = $maquina;
|
||||
return view(static::$viewPath . '/maquinista/viewMaquinistaTareaScan', $this->viewData);
|
||||
}
|
||||
|
||||
public function maquinista_maquina_tarea_view(int $orden_trabajo_tarea_id)
|
||||
{
|
||||
$otTareaEntity = $this->otTarea->find($orden_trabajo_tarea_id);
|
||||
@ -517,21 +636,41 @@ class Ordentrabajo extends BaseController
|
||||
['title' => $otTareaEntity->nombre, 'route' => route_to("viewProduccionMaquinistaTareaView", $otTareaEntity->id), 'active' => true]
|
||||
|
||||
];
|
||||
|
||||
return view(static::$viewPath . '/maquinista/viewMaquinistaMaquinaTarea', $this->viewData);
|
||||
}
|
||||
public function maquinista_maquina_ot_tareas_view(int $maquina_id)
|
||||
{
|
||||
$maquinaEntity = $this->maquinaModel->find($maquina_id);
|
||||
$this->viewData['maquinaEntity'] = $maquinaEntity;
|
||||
$tareasRunning = $this->maquinaOtTareaModel->queryDatatableJoinOrdenTrabajo($maquina_id)->countAllResults();
|
||||
if ($tareasRunning) {
|
||||
return view(static::$viewPath . '/maquinista/viewProduccionMaquinistaOtTareasView', $this->viewData);
|
||||
} else {
|
||||
return view(static::$viewPath . '/maquinista/viewMaquinistaMaquinaTareas', $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)
|
||||
public function maquinista_maquina_tareas_datatable(string $content, int $maquina_id)
|
||||
{
|
||||
$pm = $this->produccionService->getMaquinaImpresionTareasList($maquina_id);
|
||||
if($content == 'today'){
|
||||
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("tareaEstado", fn($q) => $this->produccionService->getTitleTareaEstado($q->ot_tarea_id))
|
||||
->add('action', fn($q) => $this->produccionService->buttonActionDatatableTareaList($q->ot_tarea_id))
|
||||
->toJson(true);
|
||||
}
|
||||
public function maquinista_maquina_tareas_aplazada_datatable(int $maquina_id)
|
||||
{
|
||||
$pm = $this->produccionService->getMaquinaImpresionTareasList($maquina_id)->where("tarea_progress.estado", '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("tareaEstado", fn($q) => $this->produccionService->getTitleTareaEstado($q->ot_tarea_id))
|
||||
->add('action', fn($q) => $this->produccionService->buttonActionDatatableTareaList($q->ot_tarea_id))
|
||||
->toJson(true);
|
||||
}
|
||||
@ -542,10 +681,16 @@ class Ordentrabajo extends BaseController
|
||||
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) {
|
||||
$r = $this->produccionService->storeOrdenTrabajoTareaProgressDate($this->validation->getValidated());
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]);
|
||||
$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_real),
|
||||
"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);
|
||||
}
|
||||
@ -555,7 +700,6 @@ class Ordentrabajo extends BaseController
|
||||
}
|
||||
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]);
|
||||
}
|
||||
@ -568,4 +712,183 @@ class Ordentrabajo extends BaseController
|
||||
];
|
||||
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]);
|
||||
}
|
||||
public function get_tareas_ot_maquina(int $orden_trabajo_id, int $maquina_id)
|
||||
{
|
||||
$tareasWithMaquina = $this->produccionService->init($orden_trabajo_id)->getTareasWithMaquina($maquina_id, ['P', 'I', 'S', 'D']);
|
||||
if ($tareasWithMaquina) {
|
||||
$data = [
|
||||
'tareas' => $tareasWithMaquina,
|
||||
'ot' => $this->produccionService->getOrdenTrabajo(),
|
||||
'presupuesto' => $this->produccionService->getPresupuesto()
|
||||
];
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_fetch_success"), "data" => $data]);
|
||||
} else {
|
||||
$tareasWithMaquina = $this->produccionService->init($orden_trabajo_id)->getTareasWithMaquina($maquina_id, ['F']);
|
||||
if ($tareasWithMaquina) {
|
||||
return $this->response->setJSON(["message" => lang("Produccion.errors.tareas_finalizadas"), "data" => $tareasWithMaquina])->setStatusCode(400);
|
||||
} else {
|
||||
return $this->response->setJSON(["message" => lang("Produccion.errors.maquina_not_in_ot"), "data" => null])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function update_orden_trabajo_fa_tareas()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "orden_trabajo_fichaje_auto");
|
||||
if ($validated) {
|
||||
$validatedData = $this->validation->getValidated();
|
||||
$this->produccionService->init($validatedData['orden_trabajo_id']);
|
||||
foreach ($validatedData['tareas'] as $key => $tareaId) {
|
||||
$this->produccionService->storeOrdenTrabajoTareaProgressDate(
|
||||
[
|
||||
'estado' => 'F',
|
||||
'ot_tarea_id' => $tareaId
|
||||
]
|
||||
);
|
||||
$tareaEntity = $this->otTarea->find($tareaId);
|
||||
$tiempo_trabajado = $tareaEntity->tiempo_trabajado();
|
||||
$tareaEntity->tiempo_real = $tiempo_trabajado / count($validatedData['tareas']);
|
||||
$tareaEntity->click_init = $validatedData['click_init'] / count($validatedData['tareas']);
|
||||
$tareaEntity->click_end = $validatedData['click_end'] / count($validatedData['tareas']);
|
||||
|
||||
$this->otTarea->save($tareaEntity);
|
||||
}
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $validatedData]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function store_maquina_ordenes_trabajo()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "maquina_ordenes_trabajo");
|
||||
if ($validated) {
|
||||
$validatedData = $this->validation->getValidated();
|
||||
|
||||
foreach ($validatedData['ordenes_trabajo'] as $key => $orden_trabajo_id) {
|
||||
$maquinaOtTarea = $this->maquinaOtTareaModel->where('orden_trabajo_id', $orden_trabajo_id)->where('maquina_id', $validatedData['maquina_id'])->where('deleted_at',null)->countAllResults();
|
||||
if ($maquinaOtTarea) {
|
||||
continue;
|
||||
}
|
||||
$this->maquinaOtTareaModel->insert(['maquina_id' => $validatedData['maquina_id'], 'orden_trabajo_id' => $orden_trabajo_id]);
|
||||
}
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $validatedData]);
|
||||
} else {
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function update_maquina_ordenes_trabajo_estado()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$maquina_id = $bodyData['maquina_id'];
|
||||
$estado = $bodyData['estado'];
|
||||
$maquina_ots = $this->maquinaOtTareaModel->where('maquina_id', $maquina_id)->findAll();
|
||||
$totalTareas = [];
|
||||
|
||||
foreach ($maquina_ots as $key => $maquina_ot) {
|
||||
$tareas = $this->produccionService->init($maquina_ot->orden_trabajo_id)
|
||||
->getTareasWithMaquina($maquina_id, ['P', 'I', 'S', 'D']);
|
||||
foreach ($tareas as $key => $tarea) {
|
||||
$this->produccionService->storeOrdenTrabajoTareaProgressDate(
|
||||
[
|
||||
'estado' => $estado,
|
||||
'ot_tarea_id' => $tarea->id
|
||||
]
|
||||
);
|
||||
$tarea->click_init = $bodyData['click_init'];
|
||||
$tarea->click_end = $bodyData['click_end'];
|
||||
$totalTareas[] = $tarea;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
foreach ($totalTareas as $key => $tarea) {
|
||||
$tiempo_trabajado = $tarea->tiempo_trabajado();
|
||||
$tarea->tiempo_real = $tiempo_trabajado / count($totalTareas);
|
||||
$tarea->click_init = $tarea->click_init / count($totalTareas);
|
||||
$tarea->click_end = $tarea->click_end / count($totalTareas);
|
||||
|
||||
$this->otTarea->save($tarea);
|
||||
}
|
||||
if ($estado == "F") {
|
||||
$this->maquinaOtTareaModel->where('maquina_id', $maquina_id)->delete();
|
||||
}
|
||||
|
||||
return $this->response->setJSON(["message" => lang("Produccion.responses.update_maquina_ordenes_trabajo_estado")]);
|
||||
}
|
||||
public function delete_maquina_orden_trabajo_tarea($maquina_orden_trabajo_tarea_id)
|
||||
{
|
||||
|
||||
$status = $this->maquinaOtTareaModel->delete($maquina_orden_trabajo_tarea_id);
|
||||
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => $status]);
|
||||
}
|
||||
public function delete_maquina_orden_trabajo_all($maquina_id)
|
||||
{
|
||||
$maquina_ots = $this->maquinaOtTareaModel->where('maquina_id', $maquina_id)->findAll();
|
||||
foreach ($maquina_ots as $key => $maquina_ot) {
|
||||
$tareas = $this->produccionService->init($maquina_ot->orden_trabajo_id)
|
||||
->getTareasWithMaquina($maquina_id, ['P', 'I', 'S', 'D']);
|
||||
foreach ($tareas as $key => $tarea) {
|
||||
$this->produccionService->deleteOrdenTrabajoTareaProgressDates($tarea->id);
|
||||
}
|
||||
}
|
||||
$status = $this->maquinaOtTareaModel->where('maquina_id',$maquina_id)->delete();
|
||||
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => $status]);
|
||||
}
|
||||
|
||||
public function datatable_maquina_ordenes_trabajo($maquina_id)
|
||||
{
|
||||
$query = $this->maquinaOtTareaModel->queryDatatableJoinOrdenTrabajo($maquina_id);
|
||||
return DataTable::of($query)
|
||||
->add('action', fn($q) => $q->otId)
|
||||
->add('titulo', fn($q) => $this->otModel->find($q->otId)->presupuesto()->titulo)
|
||||
->add('barcode', fn($q) => $this->otModel->find($q->otId)->getBarCode())
|
||||
->toJson(true);
|
||||
}
|
||||
public function get_maquina_ots($maquina_id)
|
||||
{
|
||||
$responseData = [
|
||||
"tiempo_total_estimado" => 0,
|
||||
"tiempo_total_real" => 0,
|
||||
"clicks_total" => 0,
|
||||
"tirada_total" => 0,
|
||||
"estado" => "P",
|
||||
];
|
||||
$maquina_ots = $this->maquinaOtTareaModel->where('maquina_id', $maquina_id)->findAll();
|
||||
foreach ($maquina_ots as $key => $maquina_ot) {
|
||||
$tareas = $this->produccionService->init($maquina_ot->orden_trabajo_id)
|
||||
->getTareasWithMaquina($maquina_id, ['P', 'I', 'S', 'D']);
|
||||
foreach ($tareas as $key => $tarea) {
|
||||
$responseData['tiempo_total_estimado']+= $tarea->tiempo_estimado;
|
||||
$responseData['tiempo_total_real']+= $tarea->tiempo_real;
|
||||
$responseData["estado"] = $tarea->lastState()->estado;
|
||||
if($tarea->presupuesto_linea_id){
|
||||
$responseData["clicks_total"] += $tarea->presupuesto_linea()->rotativa_clicks_total;
|
||||
$responseData["tirada_total"] += $tarea->orden_trabajo()->presupuesto()->tirada;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$responseData['tiempo_total_estimado'] = float_seconds_to_hhmmss_string($responseData['tiempo_total_estimado']);
|
||||
$responseData['tiempo_total_real'] = float_seconds_to_hhmmss_string($responseData['tiempo_total_real']);
|
||||
return $this->response->setJSON($responseData);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,10 +30,17 @@ class Test extends BaseController
|
||||
|
||||
}
|
||||
|
||||
private function index()
|
||||
public function index()
|
||||
{
|
||||
|
||||
$modelCL = new CatalogoLibroModel();
|
||||
|
||||
$this->emailService = service('emailService');
|
||||
|
||||
$a= $this->emailService->send('prueba', 'Esto es una prueba', ['imnavajas@coit.es','imnavajas@gmail.com']);
|
||||
|
||||
echo var_dump($a);
|
||||
|
||||
/*$modelCL = new CatalogoLibroModel();
|
||||
$modelISK = new IdentificadorIskModel();
|
||||
|
||||
// Obtener todos los registros sin isk
|
||||
@ -46,7 +53,7 @@ class Test extends BaseController
|
||||
$modelCL->update($registro->id, ['isk' => $isk]);
|
||||
|
||||
echo "[" . $i++ . "]Asignado ISK {$isk} a ID {$registro->id}<br>";
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -11,76 +11,85 @@ class CreateCatalogoLibros extends Migration
|
||||
$this->db->query('SET foreign_key_checks = 0');
|
||||
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'auto_increment' => true],
|
||||
'cliente_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'proveedor_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'user_created_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'default' => 1],
|
||||
'user_update_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'default' => 1],
|
||||
'cubierta_archivo' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'cubierta_url' => ['type' => 'VARCHAR', 'constraint' => 500, 'null' => true],
|
||||
'ancho' => ['type' => 'DOUBLE', 'constraint' => '8,2'],
|
||||
'alto' => ['type' => 'DOUBLE', 'constraint' => '8,2'],
|
||||
'peso' => ['type' => 'DOUBLE', 'constraint' => '8,2', 'null' => true],
|
||||
'titulo' => ['type' => 'VARCHAR', 'constraint' => 300],
|
||||
'autor' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'autor_entidad' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'traductor' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'ilustrador' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'idioma' => ['type' => 'VARCHAR', 'constraint' => 3, 'default' => 'spa'],
|
||||
'num_edic' => ['type' => 'INT', 'default' => 1, 'null' => true],
|
||||
'fecha_disponibilidad' => ['type' => 'DATE', 'null' => true],
|
||||
'fecha_public' => ['type' => 'DATE', 'null' => true],
|
||||
'num_fotos' => ['type' => 'INT', 'default' => 0],
|
||||
'num_ilustr' => ['type' => 'INT', 'default' => 0],
|
||||
'num_ilustr_color' => ['type' => 'INT', 'default' => 0],
|
||||
'num_ilustr_bn' => ['type' => 'INT', 'default' => 0],
|
||||
'coleccion' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'isk' => ['type' => 'VARCHAR', 'constraint' => 64, 'null' => true],
|
||||
'isbn' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'ean' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'editorial' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'resumen' => ['type' => 'TEXT', 'null' => true],
|
||||
'resumen_breve' => ['type' => 'TEXT', 'null' => true],
|
||||
'sello' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'paginas' => ['type' => 'INT'],
|
||||
'tipo_impresion' => ['type' => 'ENUM', 'constraint' => ['negro','negrohq','color','colorhq'], 'null' => true],
|
||||
'comentarios' => ['type' => 'TEXT', 'null' => true],
|
||||
'negro_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'negro_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'negro_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'negro_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'negro_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'color_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'color_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'color_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'color_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'color_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'cubierta_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'cubierta_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'cubierta_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'cubierta_acabado_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'cubierta_ancho_solapas' => ['type' => 'DOUBLE', 'constraint' => '8,2', 'default' => 0.00, 'unsigned' => true],
|
||||
'cubierta_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'cubierta_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'sobrecubierta_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'sobrecubierta_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'sobrecubierta_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'auto_increment' => true],
|
||||
'cliente_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'proveedor_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'user_created_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'default' => 1],
|
||||
'user_update_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'default' => 1],
|
||||
'cubierta_archivo' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'cubierta_url' => ['type' => 'VARCHAR', 'constraint' => 500, 'null' => true],
|
||||
'ancho' => ['type' => 'DOUBLE', 'constraint' => '8,2'],
|
||||
'alto' => ['type' => 'DOUBLE', 'constraint' => '8,2'],
|
||||
'peso' => ['type' => 'DOUBLE', 'constraint' => '8,2', 'null' => true],
|
||||
'titulo' => ['type' => 'VARCHAR', 'constraint' => 300],
|
||||
'autor' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'autor_entidad' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'traductor' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'ilustrador' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'idioma' => ['type' => 'VARCHAR', 'constraint' => 3, 'default' => 'spa'],
|
||||
'num_edic' => ['type' => 'INT', 'default' => 1, 'null' => true],
|
||||
'fecha_disponibilidad' => ['type' => 'DATE', 'null' => true],
|
||||
'fecha_public' => ['type' => 'DATE', 'null' => true],
|
||||
'num_fotos' => ['type' => 'INT', 'default' => 0],
|
||||
'num_ilustr' => ['type' => 'INT', 'default' => 0],
|
||||
'num_ilustr_color' => ['type' => 'INT', 'default' => 0],
|
||||
'num_ilustr_bn' => ['type' => 'INT', 'default' => 0],
|
||||
'coleccion' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'isk' => ['type' => 'VARCHAR', 'constraint' => 64, 'null' => true],
|
||||
'isbn' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'ean' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'editorial' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'resumen' => ['type' => 'TEXT', 'null' => true],
|
||||
'resumen_breve' => ['type' => 'TEXT', 'null' => true],
|
||||
'sello' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'paginas' => ['type' => 'INT'],
|
||||
'tipo_impresion' => ['type' => 'ENUM', 'constraint' => ['negro', 'negrohq', 'color', 'colorhq'], 'null' => true],
|
||||
'comentarios' => ['type' => 'TEXT', 'null' => true],
|
||||
'negro_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'negro_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'negro_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'negro_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'negro_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'color_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'color_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'color_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'color_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'color_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'cubierta_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'cubierta_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'cubierta_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'cubierta_acabado_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'cubierta_ancho_solapas' => ['type' => 'DOUBLE', 'constraint' => '8,2', 'default' => 0.00, 'unsigned' => true],
|
||||
'cubierta_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'cubierta_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'sobrecubierta_paginas' => ['type' => 'INT', 'null' => true],
|
||||
'sobrecubierta_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'sobrecubierta_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'sobrecubierta_acabado_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'sobrecubierta_ancho_solapas' => ['type' => 'DOUBLE', 'constraint' => '8,2', 'default' => 0.00, 'unsigned' => true],
|
||||
'sobrecubierta_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'sobrecubierta_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'encuadernacion_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'ubicacion' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'created_at' => ['type' => 'TIMESTAMP', 'default' => 'CURRENT_TIMESTAMP'],
|
||||
'updated_at' => ['type' => 'TIMESTAMP', 'null' => true],
|
||||
'deleted_at' => ['type' => 'TIMESTAMP', 'null' => true],
|
||||
'sobrecubierta_pod_papel_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'sobrecubierta_pod_gramaje' => ['type' => 'DOUBLE', 'null' => true],
|
||||
'encuadernacion_id' => ['type' => 'INT', 'constraint' => 10, 'unsigned' => true, 'null' => true],
|
||||
'ubicacion' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'created_at' => [
|
||||
'type' => 'TIMESTAMP',
|
||||
'default' => new \CodeIgniter\Database\RawSql('CURRENT_TIMESTAMP'),
|
||||
],
|
||||
'updated_at' => [
|
||||
'type' => 'TIMESTAMP',
|
||||
'null' => true,
|
||||
],
|
||||
'deleted_at' => [
|
||||
'type' => 'TIMESTAMP',
|
||||
'null' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->addUniqueKey('isk');
|
||||
$this->forge->addForeignKey('cliente_id', 'clientes', 'id');
|
||||
|
||||
$this->forge->createTable('catalogo_libros');
|
||||
$this->forge->createTable('catalogo_libros',true);
|
||||
|
||||
$this->db->query('SET foreign_key_checks = 1');
|
||||
}
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class AddFerroProtoPresupuestoDirecciones extends Migration
|
||||
{
|
||||
|
||||
protected array $COLUMNS = [
|
||||
"is_ferro_prototipo" => [
|
||||
"type" => "TINYINT",
|
||||
"unsigned" => true,
|
||||
"default" => 0,
|
||||
"comment" => "Indica si es una direccion para el prototipo o ferro",
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addColumn('presupuesto_direcciones', $this->COLUMNS);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropColumn('presupuesto_direcciones', array_keys($this->COLUMNS));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class AddTipoEnvioEnvios extends Migration
|
||||
{
|
||||
|
||||
protected array $COLUMNS = [
|
||||
"tipo_envio" => [
|
||||
"type" => "enum",
|
||||
"constraint" => ['estandar', 'ferro_prototipo'],
|
||||
"default" => 'estandar',
|
||||
"comment" => "Indica el tipo de envio",
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addColumn('envios', $this->COLUMNS);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropColumn('envios', array_keys($this->COLUMNS));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddPliegoColumnOrdenTrabajoTarea extends Migration
|
||||
{
|
||||
|
||||
protected array $COLUMNS = [
|
||||
"pliego_1" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"default" => 0,
|
||||
],
|
||||
"pliego_1_total" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"default" => 0,
|
||||
],
|
||||
"pliego_2" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"default" => 0,
|
||||
],
|
||||
"pliego_2_total" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"default" => 0,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addColumn('orden_trabajo_tareas', $this->COLUMNS);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropColumn('orden_trabajo_tareas', array_keys($this->COLUMNS));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AlterFkOrdenTrabajoTareaProgressDates extends Migration
|
||||
{
|
||||
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->forge->dropForeignKey('orden_trabajo_tarea_progress_dates','orden_trabajo_tarea_progress_dates_ot_tarea_id_foreign');
|
||||
$this->forge->addForeignKey("ot_tarea_id","orden_trabajo_tareas","id",'CASCADE','CASCADE');
|
||||
$this->forge->processIndexes('orden_trabajo_tarea_progress_dates');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropForeignKey('orden_trabajo_tarea_progress_dates','orden_trabajo_tarea_progress_dates_ot_tarea_id_foreign');
|
||||
$this->forge->addForeignKey("ot_tarea_id","orden_trabajo_tareas","id");
|
||||
$this->forge->processIndexes('orden_trabajo_tarea_progress_dates');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\RawSql;
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateTableFestivos extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"auto_increment" => true
|
||||
],
|
||||
"date" => [
|
||||
"type" => "DATE",
|
||||
"unique" => true,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->createTable("festivos", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
$this->forge->dropTable("festivos", true);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\RawSql;
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddClienteNoBasePODnoHQ extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"no_envio_base" => [
|
||||
"type" => "TINYINT",
|
||||
"default" => 0,
|
||||
],
|
||||
"forzar_rotativa_pod" => [
|
||||
"type" => "TINYINT",
|
||||
"default" => 0,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addColumn('clientes', $this->COLUMNS);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
$this->forge->dropColumn('clientes', array_keys($this->COLUMNS));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AlterTarifasAcabadoAddBoleanColumns extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
'plastificado' => [
|
||||
'type' => 'BOOLEAN',
|
||||
'default' => false,
|
||||
],
|
||||
'plakene' => [
|
||||
'type' => 'BOOLEAN',
|
||||
'default' => false,
|
||||
],
|
||||
'rectractilado' => [
|
||||
'type' => 'BOOLEAN',
|
||||
'default' => false,
|
||||
],
|
||||
'estampado' => [
|
||||
'type' => 'BOOLEAN',
|
||||
'default' => false,
|
||||
],
|
||||
'uvi' => [
|
||||
'type' => 'BOOLEAN',
|
||||
'default' => false,
|
||||
],
|
||||
'plastificado_tipo' => [
|
||||
'type' => 'ENUM',
|
||||
'constraint' => ['BRILLO','MATE','SANDY','GOFRADO','SOFT','ANTIRAYADO'],
|
||||
'null' => true,
|
||||
],
|
||||
'plakene_tipo' => [
|
||||
'type' => 'ENUM',
|
||||
'constraint' => ['TRASLUCIDO','MATE','NEGRO'],
|
||||
'null' => true,
|
||||
],
|
||||
'rectractilado_tipo' => [
|
||||
'type' => 'ENUM',
|
||||
'constraint' => ['1','3','5'],
|
||||
'null' => true,
|
||||
],
|
||||
'estampado_tipo' => [
|
||||
'type' => 'ENUM',
|
||||
'constraint' => ['ORO','PLATA','COBRE','BRONCE'],
|
||||
'null' => true,
|
||||
],
|
||||
'uvi_tipo' => [
|
||||
'type' => 'ENUM',
|
||||
'constraint' => ['2D','3D','BRAILLE'],
|
||||
'null' => true,
|
||||
]
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
|
||||
$this->forge->addColumn('lg_tarifa_acabado',$this->COLUMNS);
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropColumn('lg_tarifa_acabado',array_keys($this->COLUMNS));
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AlterOrdenesTrabajoAddCommentColumns extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
'comment_interior' => [
|
||||
'type' => 'LONGTEXT',
|
||||
'null' => true
|
||||
],
|
||||
'comment_cubierta' => [
|
||||
'type' => 'LONGTEXT',
|
||||
'null' => true
|
||||
],
|
||||
'comment_encuadernacion' => [
|
||||
'type' => 'LONGTEXT',
|
||||
'null' => true
|
||||
],
|
||||
'comment_logistica' => [
|
||||
'type' => 'LONGTEXT',
|
||||
'null' => true
|
||||
],
|
||||
"info_solapa_guillotina" => [
|
||||
'type' => 'LONGTEXT',
|
||||
'null' => true
|
||||
]
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
|
||||
$this->forge->addColumn('ordenes_trabajo',$this->COLUMNS);
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropColumn('ordenes_trabajo',array_keys($this->COLUMNS));
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class AddOrdenTrabajoDatesManipuladoImpresion extends Migration
|
||||
{
|
||||
protected array $DATES = [
|
||||
"sobrecubierta_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"guarda_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"plakene_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"estampado_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
"uvi_at" => [
|
||||
"type" => "DATE",
|
||||
"null" => true,
|
||||
],
|
||||
|
||||
];
|
||||
protected array $USERS = [
|
||||
"sobrecubierta_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"guarda_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"plakene_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"estampado_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
"uvi_user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"constraint" => 10,
|
||||
"null" => true,
|
||||
],
|
||||
];
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addColumn("orden_trabajo_dates", $this->DATES);
|
||||
$this->forge->addColumn("orden_trabajo_users", $this->USERS);
|
||||
foreach ($this->USERS as $key => $value) {
|
||||
$this->forge->addForeignKey([$key],"users",["id"]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropColumn("orden_trabajo_dates", array_keys($this->DATES));
|
||||
$this->forge->dropColumn("orden_trabajo_users", array_keys($this->USERS));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AlterOrdenesTrabajoAddCommentColumns extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
'preimpresion_revisada' => [
|
||||
'type' => 'BOOL',
|
||||
'default' => false
|
||||
],
|
||||
'preimpresion_revisada_by' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'constraint' => 11,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
|
||||
$this->forge->addColumn('ordenes_trabajo',$this->COLUMNS);
|
||||
$this->forge->addForeignKey('preimpresion_revisada_by','users','id','NULL','NULL');
|
||||
$this->forge->processIndexes('ordenes_trabajo');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropForeignKey('ordenes_trabajo','ordenes_trabajo_preimpresion_revisada_by_foreign');
|
||||
$this->forge->dropColumn('ordenes_trabajo',array_keys($this->COLUMNS));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateEtiquetasTitulos extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
// Tabla: etiquetas_titulos
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
||||
'comentarios' => ['type' => 'TEXT', 'null' => true],
|
||||
'direccion' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
|
||||
'att' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
|
||||
'cliente_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
||||
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'user_created_at' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
||||
'user_updated_at' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
||||
'user_deleted_at' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
||||
]);
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->addForeignKey('user_created_at', 'users', 'id', 'SET NULL', 'CASCADE');
|
||||
$this->forge->addForeignKey('user_updated_at', 'users', 'id', 'SET NULL', 'CASCADE');
|
||||
$this->forge->addForeignKey('user_deleted_at', 'users', 'id', 'SET NULL', 'CASCADE');
|
||||
$this->forge->addForeignKey('cliente_id', 'clientes', 'id', 'SET NULL', 'CASCADE');
|
||||
$this->forge->createTable('etiquetas_titulos');
|
||||
|
||||
// Tabla: etiquetas_titulos_lineas
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
||||
'etiqueta_titulos_id' => ['type' => 'INT', 'unsigned' => true],
|
||||
'ot_id' => ['type' => 'INT', 'unsigned' => true],
|
||||
'unidades' => ['type' => 'INT', 'unsigned' => true],
|
||||
'numero_caja' => ['type' => 'INT', 'unsigned' => true],
|
||||
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'user_created_at' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
||||
'user_updated_at' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
||||
'user_deleted_at' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
||||
]);
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->addForeignKey('etiqueta_titulos_id', 'etiquetas_titulos', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->addForeignKey('ot_id', 'ordenes_trabajo', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->addForeignKey('user_created_at', 'users', 'id', 'SET NULL', 'CASCADE');
|
||||
$this->forge->addForeignKey('user_updated_at', 'users', 'id', 'SET NULL', 'CASCADE');
|
||||
$this->forge->addForeignKey('user_deleted_at', 'users', 'id', 'SET NULL', 'CASCADE');
|
||||
$this->forge->createTable('etiquetas_titulos_lineas');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable('etiquetas_titulos_lineas', true);
|
||||
$this->forge->dropTable('etiquetas_titulos', true);
|
||||
}
|
||||
}
|
||||
58
ci4/app/Database/Migrations/2025-05-04-172900_MaquinaOtTareasTable.php
Executable file
58
ci4/app/Database/Migrations/2025-05-04-172900_MaquinaOtTareasTable.php
Executable file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class MaquinaOtTareasTable extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
|
||||
'id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
'maquina_id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'constraint' => 11
|
||||
],
|
||||
'orden_trabajo_id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql('CURRENT_TIMESTAMP');
|
||||
$this->forge->addField([
|
||||
'created_at' => [
|
||||
'type' => 'TIMESTAMP',
|
||||
'default' => $currenttime,
|
||||
],
|
||||
'updated_at' => [
|
||||
'type' => 'TIMESTAMP',
|
||||
'null' => true,
|
||||
],
|
||||
'deleted_at' => [
|
||||
'type' => 'TIMESTAMP',
|
||||
'null' => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey('maquina_id','lg_maquinas','id','CASCADE','CASCADE','maquina_ot_tareas_maquina_id_fk');
|
||||
$this->forge->addForeignKey('orden_trabajo_id','ordenes_trabajo','id','CASCADE','CASCADE','maquina_ot_tareas_ot_id_fk');
|
||||
$this->forge->createTable("maquina_ot_tareas");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("maquina_ot_tareas");
|
||||
}
|
||||
}
|
||||
43
ci4/app/Database/Seeds/PedidoPodSeeder.php
Normal file
43
ci4/app/Database/Seeds/PedidoPodSeeder.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Seeds;
|
||||
|
||||
use App\Models\Configuracion\ConfigVariableModel;
|
||||
use App\Models\Configuracion\MaquinaTareaModel;
|
||||
use CodeIgniter\Database\Seeder;
|
||||
|
||||
class PedidoPodSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$m = model(ConfigVariableModel::class);
|
||||
$data = [
|
||||
[
|
||||
"name" => "pod_impresion_dias_tras_confirmacion",
|
||||
"value" => 1,
|
||||
"description" => "Días a los que se establece la fecha de impresion en pedido tras confirmación"
|
||||
],
|
||||
[
|
||||
"name" => "pod_encuadernacion_dias_tras_confirmacion",
|
||||
"value" => 2,
|
||||
"description" => "Días a los que se establece la fecha de encuadernación en pedido tras confirmación"
|
||||
],
|
||||
[
|
||||
"name" => "pod_entrega_real_dias_tras_confirmacion",
|
||||
"value" => 5,
|
||||
"description" => "Días a los que se establece la fecha entrega real en pedido tras confirmación"
|
||||
],
|
||||
[
|
||||
"name" => "pod_embalaje_dias_tras_confirmacion",
|
||||
"value" => 4,
|
||||
"description" => "Días a los que se establece la fecha de encuadernación en pedido tras confirmación"
|
||||
],
|
||||
];
|
||||
foreach ($data as $key => $row) {
|
||||
if($m->getVariable($row['name']) == null)
|
||||
{
|
||||
$m->insert($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace App\Entities\Cliente;
|
||||
namespace App\Entities\Clientes;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
use App\Models\Configuracion\PaisModel;
|
||||
|
||||
class ClienteDireccionesEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
@ -23,4 +25,29 @@ class ClienteDireccionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"pais_id" => "int",
|
||||
"cp" => "int",
|
||||
];
|
||||
|
||||
public function getClienteNombre(): ?string
|
||||
{
|
||||
if (!$this->cliente_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$clienteModel = model(ClienteModel::class);
|
||||
$cliente = $clienteModel->find($this->cliente_id);
|
||||
|
||||
return $cliente ? $cliente->nombre : null;
|
||||
}
|
||||
|
||||
public function getPaisNombre(): ?string
|
||||
{
|
||||
if (!$this->pais_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$paisModel = model(PaisModel::class);
|
||||
$pais = $paisModel->find($this->pais_id);
|
||||
|
||||
return $pais ? $pais->nombre : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -48,6 +48,8 @@ class ClienteEntity extends \CodeIgniter\Entity\Entity
|
||||
"updated_at" => null,
|
||||
"user_created_id" => 1,
|
||||
"user_update_id" => 1,
|
||||
"no_envio_base" => 0,
|
||||
"forzar_rotativa_pod" => 0,
|
||||
];
|
||||
protected $casts = [
|
||||
"comunidad_autonoma_id" => "?int",
|
||||
@ -70,6 +72,8 @@ class ClienteEntity extends \CodeIgniter\Entity\Entity
|
||||
"is_deleted" => "int",
|
||||
"user_created_id" => "int",
|
||||
"user_update_id" => "int",
|
||||
"no_envio_base" => "boolean",
|
||||
"forzar_rotativa_pod" => "boolean",
|
||||
];
|
||||
|
||||
public function comercial() : ?UserEntity
|
||||
|
||||
14
ci4/app/Entities/Configuracion/FestivoEntity.php
Normal file
14
ci4/app/Entities/Configuracion/FestivoEntity.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class FestivoEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"date" => null,
|
||||
];
|
||||
protected $casts = [];
|
||||
}
|
||||
17
ci4/app/Entities/Etiquetas/EtiquetaTitulo.php
Normal file
17
ci4/app/Entities/Etiquetas/EtiquetaTitulo.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Etiquetas;
|
||||
use App\Models\Etiquetas\EtiquetasTitulosLineasModel;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class EtiquetaTitulo extends Entity
|
||||
{
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
public function getLineas()
|
||||
{
|
||||
$model = new EtiquetasTitulosLineasModel();
|
||||
return $model->where('etiqueta_titulos_id', $this->id)->findAll();
|
||||
}
|
||||
}
|
||||
10
ci4/app/Entities/Etiquetas/EtiquetaTituloLinea.php
Normal file
10
ci4/app/Entities/Etiquetas/EtiquetaTituloLinea.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Etiquetas;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class EtiquetaTituloLinea extends Entity
|
||||
{
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
}
|
||||
@ -31,5 +31,6 @@ class EnvioEntity extends Entity
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'cajas' => 'int',
|
||||
'tipo_envio' => 'string',
|
||||
];
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace App\Entities\Presupuestos;
|
||||
|
||||
use App\Entities\Compras\ProveedorEntity;
|
||||
use App\Entities\Tarifas\Acabados\TarifaAcabadoEntity;
|
||||
use App\Models\Compras\ProveedorModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\Tarifas\Acabados\TarifaAcabadoModel;
|
||||
use App\Models\Tarifas\Maquinas\TarifaAcabadoMaquinaModel;
|
||||
@ -54,5 +56,13 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity
|
||||
$m = model(TarifaAcabadoModel::class);
|
||||
return $m->find($this->attributes["tarifa_acabado_id"]);
|
||||
}
|
||||
|
||||
public function proveedor(): ?ProveedorEntity
|
||||
{
|
||||
$proveedor = null;
|
||||
$m = model(ProveedorModel::class);
|
||||
if ($this->attributes["proveedor_id"]) {
|
||||
$proveedor = $m->find($this->attributes["proveedor_id"]);
|
||||
}
|
||||
return $proveedor;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"proveedor_id" => null,
|
||||
"margen" => null,
|
||||
"entregaPieCalle" => null,
|
||||
"is_ferro_prototipo" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"presupuesto_id" => "int",
|
||||
@ -38,6 +39,7 @@ class PresupuestoDireccionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"margen" => "float",
|
||||
"proveedor_id" => "int",
|
||||
"entregaPieCalle" => "int",
|
||||
"is_ferro_prototipo" => "int",
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Presupuestos;
|
||||
|
||||
use App\Entities\Compras\ProveedorEntity;
|
||||
use App\Entities\Tarifas\TarifaEncuadernacionEntity;
|
||||
use App\Models\Compras\ProveedorModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\Tarifas\Maquinas\TarifaEncuadernacionMaquinaModel;
|
||||
use App\Models\Tarifas\TarifaEncuadernacionModel;
|
||||
@ -32,10 +35,10 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
"precio_total" => "float",
|
||||
"margen" => "float",
|
||||
];
|
||||
public function maquinas() : array
|
||||
public function maquinas(): array
|
||||
{
|
||||
$m = model(TarifaEncuadernacionMaquinaModel::class);
|
||||
$tarifa_maquinas = $m->where("tarifa_encuadernacion_id",$this->attributes["tarifa_encuadernado_id"])->findAll();
|
||||
$tarifa_maquinas = $m->where("tarifa_encuadernacion_id", $this->attributes["tarifa_encuadernado_id"])->findAll();
|
||||
$maquinaModel = model(MaquinaModel::class);
|
||||
$maquinas = [];
|
||||
foreach ($tarifa_maquinas as $key => $tarifa_maquina) {
|
||||
@ -43,9 +46,18 @@ class PresupuestoEncuadernacionesEntity extends \CodeIgniter\Entity\Entity
|
||||
}
|
||||
return $maquinas;
|
||||
}
|
||||
public function tarifa() : TarifaEncuadernacionEntity
|
||||
public function tarifa(): TarifaEncuadernacionEntity
|
||||
{
|
||||
$m = model(TarifaEncuadernacionModel::class);
|
||||
return $m->find($this->attributes["tarifa_encuadernado_id"]);
|
||||
}
|
||||
public function proveedor(): ?ProveedorEntity
|
||||
{
|
||||
$proveedor = null;
|
||||
$m = model(ProveedorModel::class);
|
||||
if ($this->attributes["proveedor_id"]) {
|
||||
$proveedor = $m->find($this->attributes["proveedor_id"]);
|
||||
}
|
||||
return $proveedor;
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,35 +210,35 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->findAll();
|
||||
|
||||
return $q ?? [];
|
||||
}
|
||||
/**
|
||||
* Obtiene las lineas de presupuesto del actual presupuesto
|
||||
*
|
||||
* @return ?PresupuestoLineaEntity
|
||||
*/
|
||||
public function presupuestoLineaImpresion(): ?PresupuestoLineaEntity
|
||||
{
|
||||
$model = model(PresupuestoLineaModel::class);
|
||||
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_rot_bn", "lp_rot_color", "lp_color", "lp_colorhq", "lp_bn", "lp_bnhq"])->first();
|
||||
|
||||
return $q;
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* Obtiene las lineas de presupuesto del actual presupuesto
|
||||
*
|
||||
* @return PresupuestoLineaEntity
|
||||
*/
|
||||
public function presupuestoLineaImpresion(): PresupuestoLineaEntity
|
||||
public function presupuestoLineaCubierta(): ?PresupuestoLineaEntity
|
||||
{
|
||||
$model = model(PresupuestoLineaModel::class);
|
||||
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_rot_bn","lp_rot_color","lp_color","lp_colorhq","lp_bn","lp_bnhq"])->first();
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_cubierta"])->first();
|
||||
|
||||
return $q;
|
||||
}
|
||||
/**
|
||||
* Obtiene las lineas de presupuesto del actual presupuesto
|
||||
*
|
||||
* @return PresupuestoLineaEntity
|
||||
*/
|
||||
public function presupuestoLineaCubierta(): PresupuestoLineaEntity
|
||||
{
|
||||
$model = model(PresupuestoLineaModel::class);
|
||||
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_cubierta"])->first();
|
||||
|
||||
return $q;
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* Obtiene las lineas de presupuesto del actual presupuesto
|
||||
*
|
||||
* @return PresupuestoLineaEntity
|
||||
@ -247,70 +247,81 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
$model = model(PresupuestoLineaModel::class);
|
||||
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_sobrecubierta"])->first();
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_sobrecubierta"])->first();
|
||||
|
||||
return $q;
|
||||
}
|
||||
public function hasSobrecubierta() : bool
|
||||
public function presupuestoLineaGuarda(): ?PresupuestoLineaEntity
|
||||
{
|
||||
$model = model(PresupuestoLineaModel::class);
|
||||
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_guardas"])->first();
|
||||
|
||||
return $q;
|
||||
}
|
||||
public function hasSobrecubierta(): bool
|
||||
{
|
||||
$hasSobrecubierta = false;
|
||||
$model = model(PresupuestoLineaModel::class);
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_sobrecubierta"])->countAllResults();
|
||||
if($q > 0){
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo", ["lp_sobrecubierta"])->countAllResults();
|
||||
if ($q > 0) {
|
||||
$hasSobrecubierta = true;
|
||||
}
|
||||
return $hasSobrecubierta;
|
||||
}
|
||||
public function cliente() : ClienteEntity
|
||||
public function cliente(): ?ClienteEntity
|
||||
{
|
||||
$m = model(ClienteModel::class);
|
||||
return $m->find($this->attributes["cliente_id"]);
|
||||
if ($this->attributes['cliente_id']) {
|
||||
|
||||
return $m->find($this->attributes["cliente_id"]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public function encuadernaciones(): array
|
||||
{
|
||||
$m = model(PresupuestoEncuadernacionesModel::class);
|
||||
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
|
||||
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
|
||||
}
|
||||
public function acabados(): array
|
||||
{
|
||||
$m = model(PresupuestoAcabadosModel::class);
|
||||
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
|
||||
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
|
||||
}
|
||||
public function preimpresiones(): array
|
||||
{
|
||||
$m = model(PresupuestoPreimpresionesModel::class);
|
||||
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
|
||||
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
|
||||
}
|
||||
public function manipulados(): array
|
||||
{
|
||||
$m = model(PresupuestoManipuladosModel::class);
|
||||
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
|
||||
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
|
||||
}
|
||||
public function extras(): array
|
||||
{
|
||||
$m = model(PresupuestoServiciosExtraModel::class);
|
||||
return $m->where("presupuesto_id",$this->attributes["id"])->findAll();
|
||||
return $m->where("presupuesto_id", $this->attributes["id"])->findAll();
|
||||
}
|
||||
public function papel_formato() : PapelFormatoEntity
|
||||
public function papel_formato(): PapelFormatoEntity
|
||||
{
|
||||
$m = model(PapelFormatoModel::class);
|
||||
return $m->find($this->attributes["papel_formato_id"]);
|
||||
}
|
||||
public function files(): array
|
||||
public function files(): array
|
||||
{
|
||||
$m = model(PresupuestoFicheroModel::class);
|
||||
$files = $m->where('presupuesto_id',$this->attributes['id'])->findAll();
|
||||
$files = $m->where('presupuesto_id', $this->attributes['id'])->findAll();
|
||||
return $files ?? [];
|
||||
}
|
||||
public function tipo_presupuesto() : ?TipoPresupuestoEntity
|
||||
public function tipo_presupuesto(): ?TipoPresupuestoEntity
|
||||
{
|
||||
$tipo_presupuesto = null;
|
||||
$m = model(TipoPresupuestoModel::class);
|
||||
if($this->attributes["tipo_impresion_id"]){
|
||||
if ($this->attributes["tipo_impresion_id"]) {
|
||||
$tipo_presupuesto = $m->find($this->attributes['tipo_impresion_id']);
|
||||
}
|
||||
return $tipo_presupuesto;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -194,39 +194,76 @@ class PresupuestoLineaEntity extends \CodeIgniter\Entity\Entity
|
||||
return $m->find($this->attributes['tarifa_impresion_id']);
|
||||
}
|
||||
|
||||
public function get_impresion_logo(){
|
||||
public function get_impresion_logo()
|
||||
{
|
||||
$logo = config(LogoImpresion::class);
|
||||
return $logo->get_logo_path($this->attributes["tipo"]);
|
||||
}
|
||||
public function get_nombre_tarea() : ?string
|
||||
public function get_nombre_tarea(): ?string
|
||||
{
|
||||
$nombre = null;
|
||||
$impresion_bn = ["lp_bn","lp_bnhq","lp_rot_bn"];
|
||||
$impresion_color = ["lp_color","lp_colorhq","lp_rot_color"];
|
||||
$impresion_bn = ["lp_bn", "lp_bnhq", "lp_rot_bn"];
|
||||
$impresion_color = ["lp_color", "lp_colorhq", "lp_rot_color"];
|
||||
$impresion_cubierta = ["lp_cubierta"];
|
||||
$impresion_guardas = ["lp_guardas"];
|
||||
$impresion_sobrecubierta = ["lp_sobrecubierta"];
|
||||
|
||||
$is_bn = in_array($this->attributes["tipo"],$impresion_bn);
|
||||
$is_color = in_array($this->attributes["tipo"],$impresion_color);
|
||||
$is_impresion_cubierta = in_array($this->attributes["tipo"],$impresion_cubierta);
|
||||
$is_impresion_guarda = in_array($this->attributes["tipo"],$impresion_guardas);
|
||||
$is_impresion_sobrecubierta = in_array($this->attributes["tipo"],$impresion_sobrecubierta);
|
||||
$is_bn = in_array($this->attributes["tipo"], $impresion_bn);
|
||||
$is_color = in_array($this->attributes["tipo"], $impresion_color);
|
||||
$is_impresion_cubierta = in_array($this->attributes["tipo"], $impresion_cubierta);
|
||||
$is_impresion_guarda = in_array($this->attributes["tipo"], $impresion_guardas);
|
||||
$is_impresion_sobrecubierta = in_array($this->attributes["tipo"], $impresion_sobrecubierta);
|
||||
|
||||
if($is_bn) $nombre ="Impresión B/N";
|
||||
if($is_color) $nombre ="Impresión color";
|
||||
if($is_impresion_cubierta) $nombre ="Impresión cubierta";
|
||||
if($is_impresion_guarda) $nombre ="Impresión guarda";
|
||||
if($is_impresion_sobrecubierta) $nombre ="Impresión sobrecubierta";
|
||||
if ($is_bn) $nombre = "Impresión B/N";
|
||||
if ($is_color) $nombre = "Impresión color";
|
||||
if ($is_impresion_cubierta) $nombre = "Impresión cubierta";
|
||||
if ($is_impresion_guarda) $nombre = "Impresión guarda";
|
||||
if ($is_impresion_sobrecubierta) $nombre = "Impresión sobrecubierta";
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
public function isRotativa() : bool
|
||||
{
|
||||
return in_array($this->attributes['tipo'],['lp_rot_color','lp_rot_bn']);
|
||||
|
||||
public function isGuarda(): bool
|
||||
{
|
||||
return in_array($this->attributes["tipo"], ["lp_guardas"]);
|
||||
}
|
||||
public function isColor():bool {
|
||||
return in_array($this->attributes['tipo'],['lp_color','lp_colorhq','lp_rot_color']);
|
||||
|
||||
public function isCubierta(): bool
|
||||
{
|
||||
return in_array($this->attributes["tipo"], ["lp_cubierta"]);
|
||||
}
|
||||
public function isSobreCubierta(): bool
|
||||
{
|
||||
return in_array($this->attributes["tipo"], ["lp_sobrecubierta"]);
|
||||
}
|
||||
public function isRotativa(): bool
|
||||
{
|
||||
return in_array($this->attributes['tipo'], ['lp_rot_color', 'lp_rot_bn']);
|
||||
}
|
||||
public function isColor(): bool
|
||||
{
|
||||
return in_array($this->attributes['tipo'], ['lp_color', 'lp_colorhq', 'lp_rot_color']);
|
||||
}
|
||||
public function isBN(): bool
|
||||
{
|
||||
return in_array($this->attributes['tipo'], ["lp_bn", "lp_bnhq", "lp_rot_bn"]);
|
||||
}
|
||||
|
||||
public function tinta(): string
|
||||
{
|
||||
$tinta = "";
|
||||
if ($this->isCubierta()) {
|
||||
$paginas = $this->attributes['paginas'];
|
||||
if ($paginas / 2 == 1) {
|
||||
$tinta = '4/0';
|
||||
}
|
||||
if ($paginas / 2 == 2) {
|
||||
$tinta = '4/4';
|
||||
}
|
||||
} elseif ($this->isColor()) {
|
||||
$tinta = '4/4';
|
||||
} elseif ($this->isBN()) {
|
||||
$tinta = '4/0';
|
||||
}
|
||||
return $tinta;
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,8 +15,15 @@ class OrdenTrabajoDateEntity extends Entity
|
||||
"interior_bn_at" => null,
|
||||
"interior_color_at" => null,
|
||||
"cubierta_at" => null,
|
||||
"sobrecubierta_at" => null, //TODO
|
||||
"guarda_at" => null, //TODO
|
||||
//ACABADO
|
||||
"plastificado_at" => null,
|
||||
"plakene_at" => null, //TODO
|
||||
"retractilado_at"=> null,
|
||||
"estampado_at" => null, //TODO
|
||||
"uvi_at" => null, //TODO
|
||||
//MANIPULADO
|
||||
"encuadernacion_at" => null,
|
||||
"corte_at" => null,
|
||||
"preparacion_interiores_at" => null,
|
||||
@ -24,9 +31,8 @@ class OrdenTrabajoDateEntity extends Entity
|
||||
"cosido_at" => null,
|
||||
"solapa_at" => null,
|
||||
"grapado_at" => null,
|
||||
"retractilado_at"=> null,
|
||||
"retractilado5_at"=> null,
|
||||
"prototipo_at"=> null,
|
||||
"retractilado5_at"=> null, // !DELETE
|
||||
"prototipo_at"=> null, // !DELETE
|
||||
"marcapaginas_at"=> null,
|
||||
"espiral_at"=> null,
|
||||
//FERRO
|
||||
|
||||
@ -30,6 +30,11 @@ class OrdenTrabajoEntity extends Entity
|
||||
"progreso" => 0.00,
|
||||
"estado" => "I",
|
||||
"comentarios" => null,
|
||||
"comment_interior" => null,
|
||||
"comment_cubierta" => null,
|
||||
"comment_encuadernacion" => null,
|
||||
"comment_logistica" => null,
|
||||
"info_solapa_guillotina" => null,
|
||||
"revisar_formato" => null,
|
||||
"revisar_lomo" => null,
|
||||
"revisar_solapa" => null,
|
||||
@ -40,6 +45,9 @@ class OrdenTrabajoEntity extends Entity
|
||||
"portada_path" => null,
|
||||
"is_pedido_espera" => null,
|
||||
"pedido_espera_by" => null,
|
||||
"preimpresion_revisada" => false,
|
||||
"preimpresion_revisada_by" => null,
|
||||
|
||||
];
|
||||
protected $casts = [
|
||||
"pedido_id" => "integer",
|
||||
@ -52,7 +60,12 @@ class OrdenTrabajoEntity extends Entity
|
||||
"tipo_entrada" => "string",
|
||||
"progreso" => "float",
|
||||
"estado" => "string",
|
||||
"comentarios" => "string",
|
||||
"comentarios" => "?string",
|
||||
"comment_interior" => "?string",
|
||||
"comment_cubierta" => "?string",
|
||||
"comment_encuadernacion" => "?string",
|
||||
"comment_logistica" => "?string",
|
||||
"info_solapa_guillotina" => "?string",
|
||||
"revisar_formato" => "bool",
|
||||
"revisar_lomo" => "bool",
|
||||
"revisar_solapa" => "bool",
|
||||
@ -62,13 +75,14 @@ class OrdenTrabajoEntity extends Entity
|
||||
"enviar_impresion" => "bool",
|
||||
"portada_path" => "string",
|
||||
"is_pedido_espera" => "bool",
|
||||
"preimpresion_revisada" => "bool",
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Devuelve las tareas de la orden de trabajo.
|
||||
*
|
||||
* @return array<OrdenTrabajoTarea>
|
||||
* @return array<OrdenTrabajoTareaEntity>
|
||||
*/
|
||||
public function tareas(): array
|
||||
{
|
||||
@ -80,7 +94,22 @@ class OrdenTrabajoEntity extends Entity
|
||||
$m = model(OrdenTrabajoTarea::class);
|
||||
return $m->where("orden_trabajo_id", $this->attributes["id"])->where("presupuesto_linea_id IS NOT NULL", NULL, FALSE)->findAll() ?? [];
|
||||
}
|
||||
/**
|
||||
public function tareas_acabado(): array
|
||||
{
|
||||
$m = model(OrdenTrabajoTarea::class);
|
||||
return $m->where("orden_trabajo_id", $this->attributes["id"])->where("presupuesto_acabado_id IS NOT NULL", NULL, FALSE)->findAll() ?? [];
|
||||
}
|
||||
public function tareas_encuadernado(): array
|
||||
{
|
||||
$m = model(OrdenTrabajoTarea::class);
|
||||
return $m->where("orden_trabajo_id", $this->attributes["id"])->where("presupuesto_encuadernado_id IS NOT NULL", NULL, FALSE)->findAll() ?? [];
|
||||
}
|
||||
public function tareas_manipulado(): array
|
||||
{
|
||||
$m = model(OrdenTrabajoTarea::class);
|
||||
return $m->where("orden_trabajo_id", $this->attributes["id"])->where("presupuesto_manipulado_id IS NOT NULL", NULL, FALSE)->findAll() ?? [];
|
||||
}
|
||||
/**
|
||||
* Devuelve el presupuesto de la orden de trabajo
|
||||
*
|
||||
* @return PresupuestoEntity
|
||||
@ -153,10 +182,23 @@ class OrdenTrabajoEntity extends Entity
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public function preimpresionRevisadaUser(): ?UserEntity
|
||||
{
|
||||
$m = model(UserModel::class);
|
||||
if ($this->attributes['preimpresion_revisada_by']) {
|
||||
return $m->findById($this->attributes['preimpresion_revisada_by']);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public function getPedidoEsperaBy(): ?UserEntity
|
||||
{
|
||||
return $this->pedidoEsperaBy();
|
||||
}
|
||||
public function getPreimpresionRevisadaBy(): ?UserEntity
|
||||
{
|
||||
return $this->preimpresionRevisadaUser();
|
||||
}
|
||||
public function getFullPath(): ?string
|
||||
{
|
||||
helper('filesystem');
|
||||
@ -183,4 +225,5 @@ class OrdenTrabajoEntity extends Entity
|
||||
];
|
||||
return $estados[$this->attributes["estado"]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ namespace App\Entities\Produccion;
|
||||
use App\Entities\Configuracion\Imposicion;
|
||||
use App\Entities\Configuracion\Maquina;
|
||||
use App\Entities\Presupuestos\PresupuestoAcabadosEntity;
|
||||
use App\Entities\Presupuestos\PresupuestoEncuadernacionesEntity;
|
||||
use App\Entities\Presupuestos\PresupuestoLineaEntity;
|
||||
use App\Entities\Presupuestos\PresupuestoManipuladosEntity;
|
||||
use App\Models\Configuracion\ImposicionModel;
|
||||
@ -12,6 +13,7 @@ use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoTareaProgressDate;
|
||||
use App\Models\Presupuestos\PresupuestoAcabadosModel;
|
||||
use App\Models\Presupuestos\PresupuestoEncuadernacionesModel;
|
||||
use App\Models\Presupuestos\PresupuestoLineaModel;
|
||||
use App\Models\Presupuestos\PresupuestoManipuladosModel;
|
||||
use CodeIgniter\Entity\Entity;
|
||||
@ -23,6 +25,11 @@ class OrdenTrabajoTareaEntity extends Entity
|
||||
"id" => null,
|
||||
"orden_trabajo_id" => null,
|
||||
"presupuesto_linea_id" => null,
|
||||
"presupuesto_acabado_id" => null,
|
||||
"presupuesto_preimpresion_id" => null,
|
||||
"presupuesto_encuadernado_id" => null,
|
||||
"presupuesto_extra_id" => null,
|
||||
"presupuesto_manipulado_id" => null,
|
||||
"nombre" => null,
|
||||
"orden" => null,
|
||||
"maquina_id" => null,
|
||||
@ -34,8 +41,11 @@ class OrdenTrabajoTareaEntity extends Entity
|
||||
"comment" => null,
|
||||
"click_init" => null,
|
||||
"click_end" => null,
|
||||
"pliego_1" => null,
|
||||
"pliego_1_total" => null,
|
||||
"pliego_2" => null,
|
||||
"pliego_2_total" => null,
|
||||
];
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [
|
||||
"id" => "integer",
|
||||
@ -52,6 +62,10 @@ class OrdenTrabajoTareaEntity extends Entity
|
||||
"comment" => "?string",
|
||||
"click_init" => "integer",
|
||||
"click_end" => "integer",
|
||||
"pliego_1" => "integer",
|
||||
"pliego_1_total" => "integer",
|
||||
"pliego_2" => "integer",
|
||||
"pliego_2_total" => "integer",
|
||||
];
|
||||
|
||||
/**
|
||||
@ -89,10 +103,15 @@ class OrdenTrabajoTareaEntity extends Entity
|
||||
*
|
||||
* @return PresupuestoLineaEntity
|
||||
*/
|
||||
public function presupuesto_linea(): PresupuestoLineaEntity
|
||||
public function presupuesto_linea(): ?PresupuestoLineaEntity
|
||||
{
|
||||
$presupuesto_linea = null;
|
||||
$m = model(PresupuestoLineaModel::class);
|
||||
return $m->find($this->attributes["presupuesto_linea_id"]);
|
||||
if ($this->attributes['presupuesto_linea_id']) {
|
||||
|
||||
$presupuesto_linea = $m->find($this->attributes["presupuesto_linea_id"]);
|
||||
}
|
||||
return $presupuesto_linea;
|
||||
}
|
||||
/**
|
||||
* Devuelve la maquina original del presupuesto linea
|
||||
@ -101,17 +120,49 @@ class OrdenTrabajoTareaEntity extends Entity
|
||||
*/
|
||||
public function maquina_presupuesto_linea(): Maquina
|
||||
{
|
||||
return $this->presupuesto_linea()->maquina();
|
||||
return $this->presupuesto_linea()?->maquina();
|
||||
}
|
||||
/**
|
||||
* Devuelve el presupuesto acabado origen de esta tarea
|
||||
*
|
||||
* @return PresupuestoAcabadosEntity
|
||||
*/
|
||||
public function presupuesto_acabado(): PresupuestoAcabadosEntity
|
||||
public function presupuesto_acabado(): ?PresupuestoAcabadosEntity
|
||||
{
|
||||
$presupuesto_acabado = null;
|
||||
$m = model(PresupuestoAcabadosModel::class);
|
||||
return $m->find($this->attributes["presupuesto_linea_id"]);
|
||||
if ($this->attributes["presupuesto_acabado_id"]) {
|
||||
$presupuesto_acabado = $m->find($this->attributes["presupuesto_acabado_id"]);
|
||||
}
|
||||
return $presupuesto_acabado;
|
||||
}
|
||||
/**
|
||||
* Devuelve el presupuesto enducadernacion origen de esta tarea
|
||||
*
|
||||
* @return PresupuestoEncuadernacionesEntity
|
||||
*/
|
||||
public function presupuesto_encuadernacion(): ?PresupuestoEncuadernacionesEntity
|
||||
{
|
||||
$presupuesto_encuadernacion = null;
|
||||
$m = model(PresupuestoEncuadernacionesModel::class);
|
||||
if ($this->attributes["presupuesto_encuadernado_id"]) {
|
||||
$presupuesto_encuadernacion = $m->find($this->attributes["presupuesto_encuadernado_id"]);
|
||||
}
|
||||
return $presupuesto_encuadernacion;
|
||||
}
|
||||
/**
|
||||
* Devuelve el presupuesto acabado origen de esta tarea
|
||||
*
|
||||
* @return ?PresupuestoManipuladosEntity
|
||||
*/
|
||||
public function presupuesto_manipulado(): ?PresupuestoManipuladosEntity
|
||||
{
|
||||
$m = model(PresupuestoManipuladosModel::class);
|
||||
$p = null;
|
||||
if ($this->attributes['presupuesto_manipulado_id']) {
|
||||
$p = $m->find($this->attributes["presupuesto_manipulado_id"]);
|
||||
}
|
||||
return $p;
|
||||
}
|
||||
public function imposicion(): ?Imposicion
|
||||
{
|
||||
@ -127,21 +178,27 @@ class OrdenTrabajoTareaEntity extends Entity
|
||||
$m = model(OrdenTrabajoTareaProgressDate::class);
|
||||
return $m->where('ot_tarea_id', $this->attributes["id"])->findAll() ?? [];
|
||||
}
|
||||
public function lastState(): ?OrdenTrabajoTareaProgressDateEntity
|
||||
{
|
||||
$m = model(OrdenTrabajoTareaProgressDate::class);
|
||||
$progressDates = $m->where('ot_tarea_id', $this->attributes["id"])->orderBy('action_at', 'DESC')->first();
|
||||
return $progressDates;
|
||||
}
|
||||
public function tiempo_trabajado()
|
||||
{
|
||||
$dates = $this->progress_dates();
|
||||
$intervals = [];
|
||||
$init = [];
|
||||
$end = [];
|
||||
$init = null;
|
||||
$end = null;
|
||||
foreach ($dates as $key => $date) {
|
||||
if ($date->estado == "I") {
|
||||
if ($date->action_at) {
|
||||
$init = Time::createFromFormat('Y-m-d H:i:s', $date->action_at);
|
||||
$init = $date->action_at;
|
||||
}
|
||||
}
|
||||
if ($date->estado == "S" || $date->estado == "F") {
|
||||
if ($date->action_at) {
|
||||
$end = Time::createFromFormat('Y-m-d H:i:s', $date->action_at);
|
||||
if ($date->action_at && $init) {
|
||||
$end = $date->action_at;
|
||||
$intervals[] = $init->difference($end)->getSeconds();
|
||||
}
|
||||
}
|
||||
@ -152,5 +209,33 @@ class OrdenTrabajoTareaEntity extends Entity
|
||||
{
|
||||
return $this->attributes['click_end'] - $this->attributes['click_init'];
|
||||
}
|
||||
|
||||
public function isCosido(): bool
|
||||
{
|
||||
$isTareaCosido = false;
|
||||
$pm = $this->presupuesto_manipulado();
|
||||
if ($pm) {
|
||||
$isTareaCosido = $pm->tarifa()->isCosido();
|
||||
}
|
||||
return $isTareaCosido;
|
||||
}
|
||||
public function isImpresion(): bool
|
||||
{
|
||||
return $this->attributes['presupuesto_linea_id'] != null;
|
||||
}
|
||||
public function isAcabado(): bool
|
||||
{
|
||||
return $this->attributes['presupuesto_acabado_id'] != null;
|
||||
}
|
||||
public function isManipulado(): bool
|
||||
{
|
||||
return $this->attributes['presupuesto_manipulado_id'] != null;
|
||||
}
|
||||
public function isEncuadernado(): bool
|
||||
{
|
||||
return $this->attributes['presupuesto_encuadernado_id'] != null;
|
||||
}
|
||||
public function isCorte(): bool
|
||||
{
|
||||
return $this->attributes['is_corte'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Entities\Produccion;
|
||||
|
||||
use App\Entities\Usuarios\UserEntity;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoTarea;
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
@ -20,12 +21,21 @@ class OrdenTrabajoTareaProgressDateEntity extends Entity
|
||||
/**
|
||||
* Orden de trabajo de la tarea
|
||||
*
|
||||
* @return OrdenTrabajoEntity
|
||||
* @return OrdenTrabajoTareaEntity
|
||||
*/
|
||||
public function orden_trabajo_tarea() : OrdenTrabajoTareaEntity
|
||||
{
|
||||
$m = model(OrdenTrabajoTarea::class);
|
||||
return $m->find($this->attributes["ot_tarea_id"]);
|
||||
}
|
||||
public function user() : ?UserEntity
|
||||
{
|
||||
$user = null;
|
||||
if($this->attributes['action_user_id'])
|
||||
{
|
||||
$user = auth()->getProvider()->findById($this->attributes['action_user_id']);
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,8 +19,13 @@ class OrdenTrabajoUserEntity extends Entity
|
||||
"interior_bn_user_id" => null,
|
||||
"interior_color_user_id" => null,
|
||||
"cubierta_user_id" => null,
|
||||
"sobrecubierta_user_id" => null,
|
||||
"guarda_user_id" => null,
|
||||
//ACABADO
|
||||
"plastificado_user_id" => null,
|
||||
"plakene_user_id" => null,
|
||||
"estampado_user_id" => null,
|
||||
"uvi_user_id" => null,
|
||||
"encuadernacion_user_id" => null,
|
||||
"corte_user_id" => null,
|
||||
"preparacion_interior_user_id" => null,
|
||||
|
||||
@ -24,6 +24,16 @@ class TarifaAcabadoEntity extends \CodeIgniter\Entity\Entity
|
||||
"deleted_at" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
'plastificado' => null,
|
||||
'plakene' => null,
|
||||
'rectractilado' => null,
|
||||
'estampado' => null,
|
||||
'uvi' => null,
|
||||
'plastificado_tipo' => null,
|
||||
'plakene_tipo' => null,
|
||||
'rectractilado_tipo' => null,
|
||||
'estampado_tipo' => null,
|
||||
'uvi_tipo' => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"precio_min" => "float",
|
||||
@ -33,6 +43,16 @@ class TarifaAcabadoEntity extends \CodeIgniter\Entity\Entity
|
||||
"user_created_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
'plastificado' => 'boolean',
|
||||
'plakene' => 'boolean',
|
||||
'rectractilado' => 'boolean',
|
||||
'estampado' => 'boolean',
|
||||
'uvi' => 'boolean',
|
||||
'plastificado_tipo' => '?string',
|
||||
'plakene_tipo' => '?string',
|
||||
'rectractilado_tipo' => '?string',
|
||||
'estampado_tipo' => '?string',
|
||||
'uvi_tipo' => '?string',
|
||||
];
|
||||
/**
|
||||
* Devuelve las maquinas asociadas a esta tarifa de acabado
|
||||
@ -48,6 +68,7 @@ class TarifaAcabadoEntity extends \CodeIgniter\Entity\Entity
|
||||
|
||||
public function isUVI(): bool
|
||||
{
|
||||
return in_array($this->attributes["code"],["R3D","R2D"]);
|
||||
return $this->attributes['uvi'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
45
ci4/app/Entities/Tarifas/Maquinas/MaquinaOtTareaEntity.php
Executable file
45
ci4/app/Entities/Tarifas/Maquinas/MaquinaOtTareaEntity.php
Executable file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Tarifas\Maquinas;
|
||||
|
||||
use App\Entities\Configuracion\Maquina;
|
||||
use App\Entities\Produccion\OrdenTrabajoEntity;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
|
||||
class MaquinaOtTareaEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"maquina_id" => null,
|
||||
"orden_trabajo_id" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"id" => "integer",
|
||||
"maquina_id" => "integer",
|
||||
"orden_trabajo_id" => "integer",
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
/**
|
||||
* Orden de trabajo
|
||||
*
|
||||
* @return OrdenTrabajoEntity
|
||||
*/
|
||||
public function orden_trabajo_tarea(): OrdenTrabajoEntity
|
||||
{
|
||||
$m = model(OrdenTrabajoModel::class);
|
||||
return $m->find($this->attributes["orden_trabajo_id"]);
|
||||
}
|
||||
/**
|
||||
* Maquina
|
||||
*
|
||||
* @return Maquina
|
||||
*/
|
||||
public function maquina(): Maquina
|
||||
{
|
||||
$m = model(MaquinaModel::class);
|
||||
return $m->find($this->attributes["maquina_id"]);
|
||||
}
|
||||
}
|
||||
@ -33,4 +33,9 @@ class TarifaManipuladoEntity extends \CodeIgniter\Entity\Entity
|
||||
"user_updated_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
|
||||
public function isCosido(): bool
|
||||
{
|
||||
return in_array($this->attributes['id'], [3, 17]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,17 @@ function float_seconds_to_hhmm_string(?float $time):?string
|
||||
}
|
||||
return $time_str;
|
||||
}
|
||||
|
||||
function float_seconds_to_hhmmss_string(?float $time): ?string
|
||||
{
|
||||
$time_str = null;
|
||||
if ($time !== null) {
|
||||
$hours = floor($time / 3600);
|
||||
$minutes = floor(($time % 3600) / 60);
|
||||
$seconds = floor($time % 60);
|
||||
$time_str = sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds);
|
||||
}
|
||||
return $time_str;
|
||||
}
|
||||
function week_day_humanize(int $week_day,bool $upper = false) : string
|
||||
{
|
||||
$week_days = ["Lunes","Martes","Miércoles","Jueves","Viernes","Sábado","Domingo"];
|
||||
|
||||
@ -676,6 +676,7 @@ return [
|
||||
"menu_tarifacliente" => "Fees",
|
||||
|
||||
"menu_configuration" => "Settings",
|
||||
"menu_config_holidays" => "Holidays",
|
||||
"menu_calendario" => "Calendar",
|
||||
"menu_paises" => "Countries",
|
||||
"menu_correo" => "Mail",
|
||||
@ -699,7 +700,7 @@ return [
|
||||
|
||||
"menu_digitalizacion" => "Digitalisation",
|
||||
|
||||
"menu_importacion" => "Import",
|
||||
"menu_importadores" => "Import",
|
||||
|
||||
"menu_catalogo" => "Catalogue",
|
||||
"menu_catalogo_libros" => "Books",
|
||||
@ -761,6 +762,7 @@ return [
|
||||
"menu_tarifaimpresion" => "Printing",
|
||||
|
||||
"menu_users" => "Users",
|
||||
"menu_change_session" => "Seleccionar turno",
|
||||
"menu_permission_group" => "Roles and permissions",
|
||||
|
||||
"menu_registration" => "Registration",
|
||||
|
||||
7
ci4/app/Language/en/Festivos.php
Normal file
7
ci4/app/Language/en/Festivos.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
return [
|
||||
'date' => 'Date',
|
||||
'moduleTitle' => 'Holidays'
|
||||
];
|
||||
@ -1,13 +1,19 @@
|
||||
<?php
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'fechaCreacion' => 'Fecha de creación',
|
||||
"fechaAlbaran" => 'Fecha de albarán',
|
||||
'numEnvio' => 'Número de envío',
|
||||
'cliente' => 'Cliente',
|
||||
'albaran' => 'Albarán',
|
||||
'numAlbaran' => 'Número de albarán',
|
||||
'numPedidos' => 'Número de Pedidos',
|
||||
'unidadesTotal' => 'Unidades Totales',
|
||||
'albaranes' => 'Albaranes',
|
||||
'att' => 'Att',
|
||||
'direccion' => 'Dirección',
|
||||
'cajas' => 'Cajas',
|
||||
'acciones' => 'Acciones',
|
||||
|
||||
'unidades' => 'Unidades',
|
||||
'titulo' => 'Título',
|
||||
@ -28,4 +34,6 @@ return [
|
||||
|
||||
'iva4' => 'IVA 4%',
|
||||
'iva21' => 'IVA 21%',
|
||||
|
||||
'editAlbaran' => 'Editar albarán',
|
||||
];
|
||||
@ -690,6 +690,7 @@ return [
|
||||
"menu_configuration" => "Configuración",
|
||||
"menu_variables" => "Variables sistema",
|
||||
"menu_config_messages" => "Mensajería",
|
||||
"menu_config_holidays" => "Festivos",
|
||||
"menu_error_presupuesto" => "Errores presupuesto",
|
||||
"menu_calendario" => "Calendario",
|
||||
"menu_paises" => "Paises",
|
||||
@ -719,7 +720,9 @@ return [
|
||||
|
||||
"menu_digitalizacion" => "Digitalización",
|
||||
|
||||
"menu_importacion" => "Importación",
|
||||
"menu_importadores" => "Importadores",
|
||||
"menu_importadores_catalogo" => "Desde catálogo",
|
||||
"menu_importadores_bubok" => "Bubok",
|
||||
|
||||
"menu_catalogo" => "Catálogo",
|
||||
"menu_catalogo_libros" => "Libros",
|
||||
@ -750,7 +753,7 @@ return [
|
||||
"menu_informes" => "Informes",
|
||||
|
||||
"menu_pedidos" => "Pedidos",
|
||||
"menu_pedidos_validacion" => "Validación",
|
||||
"menu_pedidos_validacion" => "Aprobación",
|
||||
"menu_pedidos_activos" => "Producción",
|
||||
"menu_pedidos_finalizados" => "Finalizados",
|
||||
"menu_pedidos_cancelados" => "Cancelados",
|
||||
|
||||
@ -46,6 +46,8 @@ return [
|
||||
'userCreatedId' => 'User Created ID',
|
||||
'userUpdateId' => 'User Update ID',
|
||||
'vencimiento' => 'Vencimiento',
|
||||
'removeEnvioBase' => 'No añadir Envio Base',
|
||||
'forzarRotativaPod' => 'Forzar rotativa en POD',
|
||||
|
||||
'direccionesEnvio' => 'Direcciones de Envío',
|
||||
|
||||
|
||||
7
ci4/app/Language/es/Festivos.php
Normal file
7
ci4/app/Language/es/Festivos.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
return [
|
||||
'date' => 'Fecha',
|
||||
'moduleTitle' => 'Festivos'
|
||||
];
|
||||
82
ci4/app/Language/es/Importador.php
Normal file
82
ci4/app/Language/es/Importador.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'moduleTitle' => 'Importadores',
|
||||
'importadorCatalogoTitle' => 'Importador RA-MA Ediciones S.L.',
|
||||
'importadorBubokTitle' => 'Importador BUBOK Publishing S.L.',
|
||||
'catalogo' => 'catálogo',
|
||||
'input' => 'ISBN',
|
||||
'descripcion' => 'Título',
|
||||
'idlinea' => 'Ref. cliente',
|
||||
'cnt_pedida' => 'Unidades',
|
||||
'precio_compra' => 'Precio Compra',
|
||||
'importar' => 'Importar',
|
||||
'subirArchivoRama' => 'Cargar Excel proporcionado por RA-MA',
|
||||
'subirArchivoBubok' => 'Cargar XML proporcionado por BUBOK',
|
||||
|
||||
'libro' => 'libro',
|
||||
'id' => 'ID',
|
||||
'clienteId' => 'Cliente',
|
||||
'cliente' => 'Cliente',
|
||||
'userCreatedId' => 'Usuario Creador',
|
||||
'userUpdateId' => 'Usuario Actualizador',
|
||||
'portada' => 'Portada',
|
||||
'ancho' => 'Ancho',
|
||||
'alto' => 'Alto',
|
||||
'peso' => 'Peso',
|
||||
'titulo' => 'Título',
|
||||
'autor' => 'Autor',
|
||||
'autorEntidad' => 'Entidad del Autor',
|
||||
'traductor' => 'Traductor',
|
||||
'ilustrador' => 'Ilustrador',
|
||||
'idioma' => 'Idioma',
|
||||
'numEdic' => 'Número de Edición',
|
||||
'edicion' => 'Edición',
|
||||
'fechaDisponibilidad' => 'Fecha de Disponibilidad',
|
||||
'fechaPublic' => 'Fecha de Publicación',
|
||||
'numFotos' => 'Número de Fotos',
|
||||
'numIlustr' => 'Número de Ilustraciones',
|
||||
'numIlustrColor' => 'Ilustraciones a Color',
|
||||
'numIlustrBn' => 'Ilustraciones en Blanco y Negro',
|
||||
'coleccion' => 'Colección',
|
||||
'isbn' => 'ISBN',
|
||||
'ean' => 'EAN',
|
||||
'editorial' => 'Editorial',
|
||||
'resumen' => 'Resumen',
|
||||
'resumenBreve' => 'Resumen Breve',
|
||||
'sello' => 'Sello',
|
||||
'paginas' => 'Páginas',
|
||||
'tipoImpresion' => 'Tipo de Impresión',
|
||||
'seleccionarTipoImpresion' => 'Seleccionar tipo de impresión',
|
||||
'solapasAncho' => 'Ancho de Solapas',
|
||||
'cubiertasAncho' => 'Ancho de Cubiertas',
|
||||
'comentarios' => 'Comentarios',
|
||||
'negroPaginas' => 'Páginas Negras',
|
||||
'negroPapel' => 'Papel Negro',
|
||||
'negroGramaje' => 'Gramaje Negro',
|
||||
'colorPaginas' => 'Páginas a Color',
|
||||
'colorPapel' => 'Papel a Color',
|
||||
'colorGramaje' => 'Gramaje Color',
|
||||
'portadaPaginas' => 'Páginas de Portada',
|
||||
'portadaPapel' => 'Papel de Portada',
|
||||
'portadaGramaje' => 'Gramaje Portada',
|
||||
'portadaAcabado' => 'Acabado Portada',
|
||||
'cubiertaPaginas' => 'Páginas de Cubierta',
|
||||
'cubiertaPapel' => 'Papel de Cubierta',
|
||||
'cubiertaGramaje' => 'Gramaje Cubierta',
|
||||
'cubiertaAcabado' => 'Acabado Cubierta',
|
||||
'encuardenacion' => 'Encuadernación',
|
||||
'ubicacion' => 'Ubicación',
|
||||
'createdAt' => 'Fecha de Creación',
|
||||
'updatedAt' => 'Fecha de Actualización',
|
||||
'deletedAt' => 'Fecha de Eliminación',
|
||||
|
||||
'catalogoLibro' => 'Libro',
|
||||
'catalogoLibroList' => 'Lista de Libros',
|
||||
'datosGenerales' => 'Datos generales del libro',
|
||||
'otrosDatosLibro' => 'Otros datos del libro',
|
||||
'configuracionLibro' => 'Configuración del libro',
|
||||
'ficherosLibro' => 'Ficheros',
|
||||
'created_by_at' => 'Creado:',
|
||||
'updated_by_at' => 'Actualizado:',
|
||||
];
|
||||
@ -9,12 +9,13 @@ return [
|
||||
'albaranes' => 'Albaranes',
|
||||
'envioSimpleMultiple' => 'Envío simple/múltiple',
|
||||
'nuevoEnvio' => 'Nuevo envío',
|
||||
'buscadorPedidosTitle' => 'Código Pedido o ISBN',
|
||||
'buscadorPedidosTitle2' => 'Código Pedido o título',
|
||||
'buscadorPedidosTitle' => 'Código OT o ISBN',
|
||||
'buscadorPedidosTitle2' => 'Código OT o título',
|
||||
'selectDirecciones' => 'Dirección de envio',
|
||||
'listadoEnvios' => 'Listado de envíos',
|
||||
'idEnvio' => 'ID Envío',
|
||||
'numeroPedidos' => 'Nº Pedidos',
|
||||
'numeroOts' => 'Nº OTs',
|
||||
'numeroLineas' => 'Nº Líneas',
|
||||
'att' => 'Att',
|
||||
'direccion' => 'Dirección',
|
||||
@ -28,6 +29,8 @@ return [
|
||||
'backToPanel' => 'Volver al panel',
|
||||
'no' => 'No',
|
||||
'si' => 'Sí',
|
||||
'todos' => 'Todos',
|
||||
'impresoraEtiquetas' => 'Impresora de etiquetas',
|
||||
|
||||
'envio' => 'Envío',
|
||||
'addLineasEnvio' => 'Añadir líneas al envío',
|
||||
@ -62,16 +65,42 @@ return [
|
||||
'finalizarEnvio' => 'Finalizar envío',
|
||||
'finalizarEnvioYOTs' => 'Finalizar envío y OTS',
|
||||
|
||||
|
||||
'EtiquetasTitulos' => 'Etiquetas de títulos',
|
||||
'id' => 'ID',
|
||||
'otId' => 'OT ID',
|
||||
'num_caja' => 'Nº Caja',
|
||||
'unidadesTotalesOt' => 'Unidades totales OT',
|
||||
'numeroCajas' => 'Nº Cajas',
|
||||
'unidadesEnCaja' => 'Unidades en caja',
|
||||
'listadoEtiquetas' => 'Listado de etiquetas',
|
||||
'nuevaEtiqueta' => 'Nueva etiqueta',
|
||||
'cliente' => 'Cliente',
|
||||
'comentariosEtiqueta' => 'Comentarios etiqueta',
|
||||
'addLineaEtiqueta' => 'Añadir líneas a la etiqueta',
|
||||
'renumber' => 'Renumerar etiquetas',
|
||||
|
||||
'errors' => [
|
||||
'noEnvio' => 'No se ha encontrado el envio',
|
||||
'noEnvioLineas' => 'No se han encontrado líneas de envío',
|
||||
'noDataToFind' => 'No se ha introducido ningún dato para buscar',
|
||||
'notFound' => 'No se encuentra el pedido o ISBN, el pedido no está en producción o finalizado o no tiene envíos pendientes',
|
||||
'noAddresses' => 'El pedido no tiene direcciones de envío',
|
||||
'errorMissingData' => 'Faltan datos para crear la etiqueta',
|
||||
'errorInsertarEtiqueta' => 'Error al insertar la etiqueta',
|
||||
'noEtiqueta' => 'No se ha encontrado la etiqueta',
|
||||
'noEtiquetaLineas' => 'No se han encontrado líneas de etiqueta',
|
||||
],
|
||||
'success' => [
|
||||
'finalizado' => 'El envío se ha finalizado correctamente',
|
||||
'finalizadoOTs' => 'El envío se ha finalizado correctamente.\nSe han creado las OTs siguientes OTs: {ots}',
|
||||
'successDeleteEtiqueta' => 'Etiqueta eliminada correctamente',
|
||||
'successInsertLines' => 'Lineas de etiqueta insertadas correctamente',
|
||||
'successDeleteLines' => 'Lineas de etiqueta eliminadas correctamente',
|
||||
'successUpdateLine' => 'Linea de etiqueta actualizadas correctamente',
|
||||
'comentariosUpdated' => 'Comentarios actualizados correctamente',
|
||||
'successReordenarCajas' => 'Cajas reordenadas correctamente',
|
||||
'imprimirEtiquetas' => 'Etiquetas impresas correctamente',
|
||||
],
|
||||
|
||||
];
|
||||
@ -1,15 +1,27 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
"navs" => [
|
||||
'finalizadas' => 'Finalizadas',
|
||||
'pendientes' => 'Pendientes',
|
||||
'pendientes_ferro' => 'Ferro pendiente',
|
||||
'ferro_ok' => 'Ferro/Prototipo OK',
|
||||
'news' => 'Nuevas',
|
||||
'waiting' => 'En espera',
|
||||
'revision_com' => 'Revisión comercial',
|
||||
'prod' => 'Producción'
|
||||
],
|
||||
"datatable" => [
|
||||
"pedido_id"=> "Pedido ID",
|
||||
"fecha_encuadernacion"=> "Fecha encuadernación",
|
||||
"fecha_impresion"=> "Fecha impresión",
|
||||
"cliente"=> "Cliente",
|
||||
"titulo"=> "Título",
|
||||
"ubicacion"=> "Ubicación",
|
||||
"tirada"=> "Tirada",
|
||||
"impresion"=> "Impresión",
|
||||
"ot_id" => "OT ID",
|
||||
"barcode" => "Código",
|
||||
"pedido_id" => "Pedido ID",
|
||||
"fecha_encuadernacion" => "Fecha encuadernación",
|
||||
"fecha_impresion" => "Fecha impresión",
|
||||
"cliente" => "Cliente",
|
||||
"titulo" => "Título",
|
||||
"ubicacion" => "Ubicación",
|
||||
"tirada" => "Tirada",
|
||||
"impresion" => "Impresión",
|
||||
"fecha_entrega_at" => "Fecha entrega prevista",
|
||||
"maquina" => "Máquina",
|
||||
"ancho" => "Ancho",
|
||||
@ -31,8 +43,6 @@ return [
|
||||
"pliegos" => "Pliegos",
|
||||
"pliegos_libro" => "Pliegos",
|
||||
"fecha" => "fecha"
|
||||
|
||||
|
||||
],
|
||||
"task" => [
|
||||
"order" => "Orden",
|
||||
@ -43,13 +53,15 @@ return [
|
||||
"maquina_actual" => "Máquina actual",
|
||||
"tiempo_estimado" => "Tiempo estimado",
|
||||
"tiempo" => "Tiempo",
|
||||
"proveedor" => "Proveedor",
|
||||
"imposicion" => "Imposición"
|
||||
],
|
||||
"finalizadas" => "Finalizadas",
|
||||
"pendiente_ferro" => "Ferro pendiente",
|
||||
"pendientes" => "Pendientes",
|
||||
"ferro_ok" => "Ferro ok",
|
||||
"ferro_ok" => "Ferro/Prototipo ok",
|
||||
"envio" => "Envío",
|
||||
"ferro" => "Ferro",
|
||||
"ot" => "Orden trabajo",
|
||||
"ots" => "Órdenes trabajo",
|
||||
"tiempo_procesamiento" => "Tiempo procesamiento",
|
||||
@ -69,6 +81,7 @@ return [
|
||||
"portada" => "portada",
|
||||
"plakene_traslucido" => "Plakene traslúcido",
|
||||
"plastificado_mate" => "Plastificado mate",
|
||||
"plastificado" => "Plastificado",
|
||||
"espiral" => "Espiral",
|
||||
"embalaje" => "Embalaje",
|
||||
"tiempo_consumido" => "Tiempo consumido",
|
||||
@ -79,12 +92,14 @@ return [
|
||||
"preview_pdf" => "Previsualizar PDF",
|
||||
"imprimir_codigo_safekat" => "Imprimir código SAFEKAT",
|
||||
"imprimir_ferro" => "Imprimir ferro",
|
||||
"imprimir_prototipo" => "Prototipo",
|
||||
"planning_rotativa" => "Planificación rotativa",
|
||||
"planning_plana" => "Planificación plana",
|
||||
"solapa" => "Solapa",
|
||||
"papel_gramajes" => "Papel y gramajes",
|
||||
"estado" => "Estado",
|
||||
"pedido_espera" => "Pedido en espera",
|
||||
"preimpresion_revisada" => "Preimpresión revisada",
|
||||
"imposicion_no_label" => "Sin etiqueta",
|
||||
"pliegos_de" => "pliegos de",
|
||||
"size" => "Tamaño",
|
||||
@ -96,19 +111,23 @@ return [
|
||||
"grapado" => "Grapado",
|
||||
"solapa" => "Solapas",
|
||||
"retractilado" => "Retractilado",
|
||||
"manipulado" => "Entrada manipulado",
|
||||
"retractilado5" => "Retractilado 5",
|
||||
"prototipo" => "Prototipo",
|
||||
"marcapaginas" => "Marcapáginas",
|
||||
//IMPRESION
|
||||
"impresion_bn" => "Impresión BN",
|
||||
"cubierta" => "Cubierta/Portada",
|
||||
"guarda" => "Guarda",
|
||||
"encuadernacion" => "Encuadernación",
|
||||
|
||||
//PREIMPRESION
|
||||
"pre_formato" => "Revisión formato",
|
||||
"pre_lomo" => "Revisión lomo",
|
||||
"pre_solapa" => "Revisión solapa",
|
||||
"pre_codbarras" => "Revisión código barras",
|
||||
"pre_imposicion" => "Revisión imposición",
|
||||
|
||||
|
||||
"iniciada" => "Iniciada",
|
||||
"finalizada" => "Finalizada",
|
||||
"error" => "Error",
|
||||
@ -120,9 +139,10 @@ return [
|
||||
"attr_not_exist" => "El atributo {0,string} no pertenece al modelo Pedido"
|
||||
|
||||
],
|
||||
|
||||
|
||||
"progress_ferro" => "Ferro",
|
||||
"progress_preimpresion" => "Preimpresión",
|
||||
"progress_logistica" => "Ferro/Logística",
|
||||
"progress_logistica" => "Logística",
|
||||
"progress_impresion" => "Impresión",
|
||||
"progress_manipulado" => "Manipulado/Acabado",
|
||||
|
||||
@ -130,18 +150,54 @@ return [
|
||||
"maquinas" => "Máquinas",
|
||||
"tareas_hoy" => "Tareas para HOY",
|
||||
"tareas_all" => "Todas",
|
||||
"tareas_delay" => "Aplazadas",
|
||||
"play_tarea" => "Continuar",
|
||||
"play_pause" => "Pausar",
|
||||
"play_stop" => "Aplazar",
|
||||
"play_end" => "Finalizar",
|
||||
"cancel" => "Cancelar",
|
||||
"fichaje_auto" => "F.auto",
|
||||
"scan" => "Escanear",
|
||||
"tarea_list" => "Lista de tareas",
|
||||
"fichaje_auto_alert_text" => "Cada vez que introduza un nº de pedido se iniciará la tarea y se finalizará la tarea actual (del pedido anterior)",
|
||||
"next_ot" => "SIGUIENTE OT",
|
||||
"placeholder_ot_id" => "Introduce el ID de la OT",
|
||||
"fa_ot_input_form_text" => "Introduce una OT para terminar la actual e iniciar la siguiente.",
|
||||
"scan_ot_input_form_text" => "Introduce una OT para añadirla al proceso",
|
||||
"next_scan_ot" => "Comenzar",
|
||||
"reset" => "Resetear"
|
||||
|
||||
|
||||
],
|
||||
'tarea_estados' => [
|
||||
'P' => 'Pendiente',
|
||||
'I' => 'Iniciada',
|
||||
'F' => 'Finalizada',
|
||||
'S' => 'Pausada',
|
||||
'D' => 'Aplazada',
|
||||
'E' => 'Error'
|
||||
],
|
||||
'duplicate_estado_tarea_progress' => "Último estado de la tarea repetido",
|
||||
'task_already_finished' => "La tarea se ha marcado como finalizada.",
|
||||
'print_label' => "Imprimir etiqueta",
|
||||
'click_init' => "Clicks al inicio",
|
||||
'click_end' => "Clicks al final",
|
||||
"comentarios" => "Comentarios",
|
||||
"comentariosOt" => "Comentarios orden",
|
||||
"comentariosImpresionInterior" => "Comentarios interior",
|
||||
"comentariosCubierta" => "Comentarios cubierta",
|
||||
"comentariosEncuadernacion" => "Comentarios encuadernación",
|
||||
"comentariosLogistica" => "Comentarios logística",
|
||||
"info_solapa_guillotina" => "Datos solapa y preparación guillotina",
|
||||
"responses" => [
|
||||
"finish_maquina_ordenes_trabajo" => "Tareas finalizadas correctamente",
|
||||
"update_maquina_ordenes_trabajo_estado" => "Tareas actualizadas correctamente",
|
||||
|
||||
],
|
||||
"errors" => [
|
||||
"maquina_not_in_ot" => "Esta OT no tiene ninguna tarea con esta máquina",
|
||||
"tareas_finalizadas" => "Las tareas de esta OT y máquina están marcadas como finalizadas",
|
||||
"ot_not_found" => "La orden de trabajo número {ot_id} no existe"
|
||||
|
||||
];
|
||||
]
|
||||
];
|
||||
|
||||
@ -67,6 +67,12 @@ return [
|
||||
'vencimientosPermission' => 'Vencimientos',
|
||||
"ticketsSection" => "Tickets",
|
||||
'produccionSection' => 'Producción',
|
||||
'catalogoSection' => 'Catálogo',
|
||||
'importadoresSection' => 'Importadores',
|
||||
'catalogoPermission' => 'Desde catálogo',
|
||||
'bubokPermission' => 'Bubok',
|
||||
|
||||
|
||||
|
||||
'validation' => [
|
||||
'id' => [
|
||||
|
||||
@ -173,6 +173,37 @@ class AlbaranModel extends \App\Models\BaseModel
|
||||
return $albaran_data;
|
||||
}
|
||||
|
||||
|
||||
public function getAlbaranData($albaran_id=null){
|
||||
if (!$albaran_id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$albaran_data = $this->db->table('albaranes t1')
|
||||
->select("
|
||||
t1.id,
|
||||
t1.att_albaran AS att,
|
||||
t1.direccion_albaran AS direccion,
|
||||
t1.envio_id,
|
||||
t1.numero_albaran AS numero_albaran,
|
||||
DATE_FORMAT(t1.created_at, '%d/%m/%Y') AS fecha_creacion,
|
||||
DATE_FORMAT(t1.fecha_albaran, '%d/%m/%Y') AS fecha_albaran,
|
||||
t1.mostrar_precios AS mostrar_precios,
|
||||
t2.nombre AS cliente,
|
||||
t1.cajas AS cajas
|
||||
")
|
||||
->join('clientes t2', 't1.cliente_id = t2.id', 'left')
|
||||
->where('t1.id', $albaran_id)
|
||||
->where('t1.deleted_at IS NULL')
|
||||
->get()
|
||||
->getResultObject();
|
||||
if (count($albaran_data) == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $albaran_data[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
@ -203,4 +234,25 @@ class AlbaranModel extends \App\Models\BaseModel
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getDatatableQuery()
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id, t1.numero_albaran as numero_albaran, t1.envio_id as envio_id, GROUP_CONCAT(DISTINCT t4.id) AS pedidos,
|
||||
t5.nombre as cliente, t1.att_albaran as att, t1.direccion_albaran as direccion, SUM(t2.cantidad) as unidades_total,
|
||||
t1.cajas as cajas"
|
||||
)
|
||||
->join("albaranes_lineas t2", "t1.id = t2.albaran_id", "left")
|
||||
->join("pedidos_linea t3", "t2.pedido_linea_id = t3.id", "left")
|
||||
->join("pedidos t4", "t3.pedido_id = t4.id", "left")
|
||||
->join("clientes t5", "t1.cliente_id = t5.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->where("t2.deleted_at IS NULL");
|
||||
$builder->groupBy("t1.id");
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
@ -61,6 +61,8 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
"comentarios",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
"no_envio_base",
|
||||
"forzar_rotativa_pod",
|
||||
];
|
||||
protected $returnType = ClienteEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
|
||||
@ -214,4 +214,12 @@ class ProveedorModel extends \App\Models\BaseModel
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
public function querySelect(?string $q)
|
||||
{
|
||||
$query = $this->builder()->select(['id','nombre as name']);
|
||||
if($q){
|
||||
$query->like('nombre',$q);
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
72
ci4/app/Models/Configuracion/FestivoModel.php
Executable file
72
ci4/app/Models/Configuracion/FestivoModel.php
Executable file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
use App\Entities\Configuracion\FestivoEntity;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class FestivoModel extends BaseModel
|
||||
{
|
||||
protected $table = "festivos";
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $allowedFields = ["date"];
|
||||
protected $returnType = FestivoEntity::class;
|
||||
protected $useAutoIncrement = true;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
|
||||
|
||||
|
||||
protected $validationRules = [
|
||||
|
||||
"date" => [
|
||||
"label" => "Festivos.date",
|
||||
"rules" => "required|valid_date[Y-m-d]",
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"date" => [
|
||||
"valid_date" => "Validation.valid_date",
|
||||
],
|
||||
];
|
||||
|
||||
public function isFestivo($date)
|
||||
{
|
||||
return $this->where('date',$date)->countAllResults() > 0 ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -404,7 +404,9 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
->select([
|
||||
'lg_maquinas.id as maquinaId',
|
||||
'lg_maquinas.nombre',
|
||||
'COUNT(tarea_progress.ot_tarea_id) as countTareas'
|
||||
'COUNT(tarea_progress.ot_tarea_id) as countTareas',
|
||||
'COUNT(maquina_ot_tareas.orden_trabajo_id) as countMaquinaTareas'
|
||||
|
||||
])
|
||||
->join('orden_trabajo_tareas', 'orden_trabajo_tareas.maquina_id = lg_maquinas.id', 'left')
|
||||
->join(
|
||||
@ -420,6 +422,14 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
'tarea_progress.ot_tarea_id = orden_trabajo_tareas.id',
|
||||
'left'
|
||||
)
|
||||
->join(
|
||||
"(SELECT orden_trabajo_id,deleted_at,maquina_id
|
||||
FROM maquina_ot_tareas
|
||||
WHERE deleted_at is NULL
|
||||
) as maquina_ot_tareas",
|
||||
'maquina_ot_tareas.maquina_id = lg_maquinas.id',
|
||||
'left'
|
||||
)
|
||||
->join('ordenes_trabajo', 'ordenes_trabajo.id = orden_trabajo_tareas.orden_trabajo_id', 'left')
|
||||
->join('pedidos', 'pedidos.id = ordenes_trabajo.pedido_id', 'left')
|
||||
->where('lg_maquinas.tipo', $maquina_tipo)
|
||||
@ -427,6 +437,9 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
->where('tarea_progress.deleted_at', null)
|
||||
->groupBy('lg_maquinas.id')
|
||||
->orderBy('countTareas','DESC');
|
||||
if($maquina_tipo == "impresion"){
|
||||
$query->where('orden_trabajo_tareas.is_corte',0);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
66
ci4/app/Models/Configuracion/MaquinaOtTareaModel.php
Executable file
66
ci4/app/Models/Configuracion/MaquinaOtTareaModel.php
Executable file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
use App\Entities\Tarifas\Maquinas\MaquinaOtTareaEntity;
|
||||
use App\Entities\Tarifas\Maquinas\TareaMaquinaEntity;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class MaquinaOtTareaModel extends Model
|
||||
{
|
||||
protected $table = 'maquina_ot_tareas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = MaquinaOtTareaEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"maquina_id",
|
||||
"orden_trabajo_id",
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
public function queryDatatableJoinOrdenTrabajo($maquina_id){
|
||||
return $this->builder()
|
||||
->select([
|
||||
'maquina_ot_tareas.id as maquinaOtTareaId',
|
||||
'ordenes_trabajo.id as otId'
|
||||
])
|
||||
->join('ordenes_trabajo','ordenes_trabajo.id = maquina_ot_tareas.orden_trabajo_id','left')
|
||||
->where('maquina_ot_tareas.maquina_id',$maquina_id)
|
||||
->where('maquina_ot_tareas.deleted_at',null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
108
ci4/app/Models/Etiquetas/EtiquetasTitulosLineasModel.php
Normal file
108
ci4/app/Models/Etiquetas/EtiquetasTitulosLineasModel.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Etiquetas;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Entities\Etiquetas\EtiquetaTituloLinea;
|
||||
|
||||
class EtiquetasTitulosLineasModel extends Model
|
||||
{
|
||||
protected $table = 'etiquetas_titulos_lineas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $returnType = EtiquetaTituloLinea::class;
|
||||
protected $useSoftDeletes = true;
|
||||
|
||||
protected $allowedFields = [
|
||||
'etiqueta_titulos_id',
|
||||
'ot_id',
|
||||
'unidades',
|
||||
'numero_caja',
|
||||
'user_created_at',
|
||||
'user_updated_at',
|
||||
'user_deleted_at',
|
||||
];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
|
||||
protected $beforeDelete = ['addUserDeleted'];
|
||||
protected $beforeUpdate = ['addUserUpdated'];
|
||||
|
||||
protected function addUserDeleted(array $data)
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
|
||||
if (!isset($data['data'])) {
|
||||
$data['data'] = [];
|
||||
}
|
||||
|
||||
if (!empty($data['id'])) {
|
||||
$builder = $this->builder();
|
||||
$builder->whereIn($this->primaryKey, (array) $data['id'])
|
||||
->update(['user_deleted_at' => $userId]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function addUserUpdated(array $data)
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
|
||||
if (!isset($data['data'])) {
|
||||
$data['data'] = [];
|
||||
}
|
||||
|
||||
if (!empty($data['id'])) {
|
||||
$builder = $this->builder();
|
||||
$builder->whereIn($this->primaryKey, (array) $data['id'])
|
||||
->update(['user_updated_at' => $userId]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDatatableQuery($etiqueta_id, $direccion = null)
|
||||
{
|
||||
$direccionNormalizada = str_replace(' ', '', strtolower(trim($direccion)));
|
||||
|
||||
// Subconsulta: suma de pesos por presupuesto
|
||||
$subPeso = $this->db->table('presupuesto_linea')
|
||||
->select('presupuesto_id, ROUND(SUM(peso)/1000, 2) as pesoUnidad')
|
||||
->groupBy('presupuesto_id');
|
||||
|
||||
$builder = $this->db->table('etiquetas_titulos_lineas etl')
|
||||
->select('
|
||||
etl.id as id,
|
||||
etl.ot_id as ot,
|
||||
pr.titulo as titulo,
|
||||
etl.unidades as unidades,
|
||||
etl.numero_caja as numero_caja,
|
||||
etl.numero_caja as numero_caja_raw,
|
||||
pd.cantidad as unidadesTotal,
|
||||
etl.id as id,
|
||||
etl.unidades as unidadesRaw,
|
||||
peso_sub.pesoUnidad
|
||||
')
|
||||
->join('etiquetas_titulos et', 'et.id = etl.etiqueta_titulos_id')
|
||||
->join('ordenes_trabajo ot', 'ot.id = etl.ot_id')
|
||||
->join('pedidos p', 'p.id = ot.pedido_id')
|
||||
->join('pedidos_linea pl', 'pl.pedido_id = p.id')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||
->join("({$subPeso->getCompiledSelect()}) as peso_sub", 'peso_sub.presupuesto_id = pr.id', 'left')
|
||||
->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id')
|
||||
->where('etl.deleted_at IS NULL')
|
||||
->where('et.id', $etiqueta_id)
|
||||
->where("REPLACE(LOWER(TRIM(pd.direccion)), ' ', '') = '{$direccionNormalizada}'", null, false)
|
||||
->orderBy('etl.numero_caja');
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
}
|
||||
82
ci4/app/Models/Etiquetas/EtiquetasTitulosModel.php
Normal file
82
ci4/app/Models/Etiquetas/EtiquetasTitulosModel.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Etiquetas;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Entities\Etiquetas\EtiquetaTitulo;
|
||||
|
||||
class EtiquetasTitulosModel extends Model
|
||||
{
|
||||
protected $table = 'etiquetas_titulos';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $returnType = EtiquetaTitulo::class;
|
||||
protected $useSoftDeletes = true;
|
||||
|
||||
protected $allowedFields = [
|
||||
'comentarios',
|
||||
'direccion',
|
||||
'att',
|
||||
'cliente_id',
|
||||
'user_created_at',
|
||||
'user_updated_at',
|
||||
'user_deleted_at',
|
||||
];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
|
||||
|
||||
protected $beforeDelete = ['addUserDeleted'];
|
||||
protected $beforeUpdate = ['addUserUpdated'];
|
||||
|
||||
protected function addUserDeleted(array $data)
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
|
||||
if (!isset($data['data'])) {
|
||||
$data['data'] = [];
|
||||
}
|
||||
|
||||
if (!empty($data['id'])) {
|
||||
$builder = $this->builder();
|
||||
$builder->whereIn($this->primaryKey, (array) $data['id'])
|
||||
->update(['user_deleted_at' => $userId]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function addUserUpdated(array $data)
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
|
||||
if (!isset($data['data'])) {
|
||||
$data['data'] = [];
|
||||
}
|
||||
|
||||
if (!empty($data['id'])) {
|
||||
$builder = $this->builder();
|
||||
$builder->whereIn($this->primaryKey, (array) $data['id'])
|
||||
->update(['user_updated_at' => $userId]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getEtiquetasTitulos()
|
||||
{
|
||||
return $this->db->table('etiquetas_titulos et')
|
||||
->select('et.id, GROUP_CONCAT(DISTINCT etl.ot_id ORDER BY etl.ot_id ASC SEPARATOR ", ") as lista_ots')
|
||||
->select('COUNT(DISTINCT etl.numero_caja) as cajas, et.att, et.direccion')
|
||||
->join('etiquetas_titulos_lineas etl', 'etl.etiqueta_titulos_id = et.id')
|
||||
->where('et.deleted_at IS NULL')
|
||||
->where('etl.deleted_at IS NULL')
|
||||
->groupBy('et.id, et.att, et.direccion');
|
||||
}
|
||||
}
|
||||
@ -37,7 +37,7 @@ class EnvioLineaModel extends Model
|
||||
->select(
|
||||
"t1.id, t1.pedido_id as pedido, t3.id as presupuesto,
|
||||
t3.titulo as titulo, t1.unidades_envio as unidadesEnvio, t1.unidades_envio as unidadesEnvioRaw,
|
||||
t1.unidades_total as unidadesTotal,
|
||||
t1.unidades_total as unidadesTotal, t2.tipo_envio as tipo_envio,
|
||||
IFNULL((
|
||||
SELECT SUM(t_sub.unidades_envio)
|
||||
FROM envios_lineas t_sub
|
||||
|
||||
@ -32,23 +32,44 @@ class EnvioModel extends Model
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'cajas',
|
||||
'tipo_envio',
|
||||
];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
public function getDatatableQuery(): BaseBuilder
|
||||
public function getDatatableQuery($tipo_envio = "estandar"): BaseBuilder
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id, GROUP_CONCAT(DISTINCT t2.pedido_id) AS pedidos,
|
||||
"t1.id, GROUP_CONCAT(DISTINCT t5.id) AS ots,
|
||||
COUNT(t2.id) AS num_lineas,
|
||||
t1.att, t1.direccion, t1.ciudad, t3.nombre as pais, t1.cp, t1.email, t1.telefono, t1.finalizado"
|
||||
);
|
||||
$builder->join("envios_lineas t2", "t2.envio_id = t1.id", "left");
|
||||
$builder->join("lg_paises t3", "t3.id = t1.pais_id", "left");
|
||||
$builder->join("pedidos t4", "t4.id = t2.pedido_id", "left");
|
||||
$builder->join('ordenes_trabajo t5', 't5.pedido_id = t4.id');
|
||||
$builder->where("t1.tipo_envio", $tipo_envio);
|
||||
|
||||
$builder->groupBy("t1.id");
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getDatatableQueryFerroPrototipo(): BaseBuilder
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id, GROUP_CONCAT(DISTINCT t5.id) AS ots,
|
||||
t1.att, t1.direccion, t1.ciudad, t3.nombre as pais, t1.cp, t1.email, t1.telefono, t1.finalizado"
|
||||
);
|
||||
$builder->join("lg_paises t3", "t3.id = t1.pais_id", "left");
|
||||
$builder->join("pedidos t4", "t4.id = t2.pedido_id", "left");
|
||||
$builder->join('ordenes_trabajo t5', 't5.pedido_id = t4.id');
|
||||
$builder->whereIn("t1.tipo_envio", ["estandar"]);
|
||||
|
||||
$builder->groupBy("t1.id");
|
||||
return $builder;
|
||||
|
||||
@ -22,8 +22,14 @@ class OrdenTrabajoDate extends Model
|
||||
"interior_bn_at",
|
||||
"interior_color_at",
|
||||
"cubierta_at",
|
||||
"sobrecubierta_at", //TODO
|
||||
"guarda_at", //TODO
|
||||
//ACABADO
|
||||
"plastificado_at",
|
||||
"plakene_at", //TODO
|
||||
"retractilado_at",
|
||||
"estampado_at", //TODO
|
||||
"uvi_at", //TODO
|
||||
"encuadernacion_at",
|
||||
"corte_at",
|
||||
"preparacion_interiores_at",
|
||||
@ -31,7 +37,6 @@ class OrdenTrabajoDate extends Model
|
||||
"cosido_at",
|
||||
"solapa_at",
|
||||
"grapado_at",
|
||||
"retractilado_at",
|
||||
"retractilado5_at",
|
||||
"prototipo_at",
|
||||
"marcapaginas_at",
|
||||
|
||||
@ -5,6 +5,7 @@ namespace App\Models\OrdenTrabajo;
|
||||
use App\Entities\Produccion\OrdenTrabajoEntity;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class OrdenTrabajoModel extends Model
|
||||
{
|
||||
protected $table = 'ordenes_trabajo';
|
||||
@ -25,6 +26,11 @@ class OrdenTrabajoModel extends Model
|
||||
"progreso",
|
||||
"estado",
|
||||
"comentarios",
|
||||
"comment_interior",
|
||||
"comment_cubierta",
|
||||
"comment_encuadernacion",
|
||||
"comment_logistica",
|
||||
"info_solapa_guillotina",
|
||||
"revisar_formato",
|
||||
"revisar_lomo",
|
||||
"revisar_solapa",
|
||||
@ -34,7 +40,10 @@ class OrdenTrabajoModel extends Model
|
||||
"enviar_impresion",
|
||||
"portada_path",
|
||||
"is_pedido_espera",
|
||||
"pedido_espera_by"
|
||||
"pedido_espera_by",
|
||||
"preimpresion_revisada",
|
||||
"preimpresion_revisada_by",
|
||||
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
@ -67,41 +76,71 @@ class OrdenTrabajoModel extends Model
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
public function getDatatableQuery() : BaseBuilder
|
||||
public function getDatatableQuery(): BaseBuilder
|
||||
{
|
||||
$q = $this->builder()
|
||||
->select([
|
||||
"ordenes_trabajo.id",
|
||||
"ordenes_trabajo.pedido_id",
|
||||
"pedidos.fecha_encuadernado as fecha_encuadernado_at",
|
||||
"clientes.nombre as cliente_nombre",
|
||||
"presupuestos.titulo as presupuesto_titulo",
|
||||
"ordenes_trabajo.estado",
|
||||
"ubicaciones.nombre as ubicacion_nombre",
|
||||
"pedidos.total_tirada",
|
||||
"tipos_presupuestos.codigo as tipo_presupuesto_impresion",
|
||||
"ordenes_trabajo.progreso",
|
||||
"presupuesto_linea.tipo as presupuesto_linea_tipo",
|
||||
"orden_trabajo_dates.ferro_ok_at",
|
||||
"CONCAT(lg_imposiciones.ancho,'x',lg_imposiciones.alto,'_',COALESCE(lg_imposiciones.unidades,'NULL'),'_',COALESCE(lg_imposiciones.orientacion,'NULL')) as imposicion_name"
|
||||
->select([
|
||||
"ordenes_trabajo.id",
|
||||
"ordenes_trabajo.pedido_id",
|
||||
"pedidos.fecha_encuadernado as fecha_encuadernado_at",
|
||||
"clientes.nombre as cliente_nombre",
|
||||
"presupuestos.titulo as presupuesto_titulo",
|
||||
"ordenes_trabajo.estado",
|
||||
"ubicaciones.nombre as ubicacion_nombre",
|
||||
"pedidos.total_tirada",
|
||||
"tipos_presupuestos.codigo as tipo_presupuesto_impresion",
|
||||
"ordenes_trabajo.progreso",
|
||||
"presupuesto_linea.tipo as presupuesto_linea_tipo",
|
||||
"orden_trabajo_dates.ferro_ok_at",
|
||||
"CONCAT(lg_imposiciones.ancho,'x',lg_imposiciones.alto,'_',COALESCE(lg_imposiciones.unidades,'NULL'),'_',COALESCE(lg_imposiciones.orientacion,'NULL')) as imposicion_name"
|
||||
|
||||
])
|
||||
->join("orden_trabajo_dates","orden_trabajo_dates.orden_trabajo_id = ordenes_trabajo.id","left")
|
||||
->join("pedidos","pedidos.id = ordenes_trabajo.pedido_id","left")
|
||||
->join("pedidos_linea","pedidos.id = pedidos_linea.pedido_id","left")
|
||||
->join("presupuestos","presupuestos.id = pedidos_linea.presupuesto_id","left")
|
||||
->join("presupuesto_linea","presupuestos.id = presupuesto_linea.presupuesto_id","left")
|
||||
->join("clientes","clientes.id = presupuestos.cliente_id","left")
|
||||
->join("tipos_presupuestos","presupuestos.tipo_impresion_id = tipos_presupuestos.id","left")
|
||||
->join("ubicaciones","ubicaciones.id = pedidos_linea.ubicacion_id","left")
|
||||
->join("orden_trabajo_tareas","orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id","left")
|
||||
->join("lg_imposiciones","lg_imposiciones.id = orden_trabajo_tareas.imposicion_id","left")
|
||||
])
|
||||
->join("orden_trabajo_dates", "orden_trabajo_dates.orden_trabajo_id = ordenes_trabajo.id", "left")
|
||||
->join("pedidos", "pedidos.id = ordenes_trabajo.pedido_id", "left")
|
||||
->join("pedidos_linea", "pedidos.id = pedidos_linea.pedido_id", "left")
|
||||
->join("presupuestos", "presupuestos.id = pedidos_linea.presupuesto_id", "left")
|
||||
->join("presupuesto_linea", "presupuestos.id = presupuesto_linea.presupuesto_id", "left")
|
||||
->join("clientes", "clientes.id = presupuestos.cliente_id", "left")
|
||||
->join("tipos_presupuestos", "presupuestos.tipo_impresion_id = tipos_presupuestos.id", "left")
|
||||
->join("ubicaciones", "ubicaciones.id = pedidos_linea.ubicacion_id", "left")
|
||||
->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left")
|
||||
->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left")
|
||||
|
||||
->whereIn("presupuesto_linea.tipo",["lp_bn","lp_bnhq","lp_rot_bn","lp_color","lp_colorhq","lp_rot_color"])
|
||||
->where("ordenes_trabajo.deleted_at",null)
|
||||
->groupBy("ordenes_trabajo.id");
|
||||
->whereIn("presupuesto_linea.tipo", ["lp_bn", "lp_bnhq", "lp_rot_bn", "lp_color", "lp_colorhq", "lp_rot_color"])
|
||||
->where("ordenes_trabajo.deleted_at", null)
|
||||
->groupBy("ordenes_trabajo.id");
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
public function queryMaquinaTareas(int $maquina_id, ?array $tareaEstados = null)
|
||||
{
|
||||
$query = $this->builder()->select([
|
||||
'orden_trabajo_tareas.*',
|
||||
'tarea_progress.estado'
|
||||
])
|
||||
->join('orden_trabajo_tareas', 'orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id', 'left')
|
||||
->join('lg_maquinas', 'orden_trabajo_tareas.maquina_id = lg_maquinas.id', 'left');
|
||||
//* Obtener el ultimo estado de la tarea
|
||||
if ($tareaEstados) {
|
||||
$query->join(
|
||||
'(SELECT ot_tarea_id, estado
|
||||
FROM orden_trabajo_tarea_progress_dates
|
||||
WHERE (ot_tarea_id, created_at) IN (
|
||||
SELECT ot_tarea_id, MAX(created_at)
|
||||
FROM orden_trabajo_tarea_progress_dates
|
||||
GROUP BY ot_tarea_id
|
||||
)
|
||||
) as tarea_progress',
|
||||
'tarea_progress.ot_tarea_id = orden_trabajo_tareas.id',
|
||||
'left'
|
||||
)
|
||||
->groupStart()
|
||||
->whereIn('tarea_progress.estado', $tareaEstados)
|
||||
->orWhere('tarea_progress.estado',null)
|
||||
->groupEnd();
|
||||
}
|
||||
$query->where('orden_trabajo_tareas.deleted_at', null)
|
||||
->where('lg_maquinas.id', $maquina_id)
|
||||
->groupBy('orden_trabajo_tareas.id');
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,11 @@ class OrdenTrabajoTarea extends Model
|
||||
"tipo_corte",
|
||||
"comment",
|
||||
"click_init",
|
||||
"click_end"
|
||||
"click_end",
|
||||
"pliego_1",
|
||||
"pliego_1_total",
|
||||
"pliego_2",
|
||||
"pliego_2_total"
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Models\OrdenTrabajo;
|
||||
|
||||
use App\Entities\Produccion\OrdenTrabajoTareaEntity;
|
||||
use App\Entities\Produccion\OrdenTrabajoTareaProgressDateEntity;
|
||||
use CodeIgniter\Database\MySQLi\Builder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
@ -11,7 +12,7 @@ class OrdenTrabajoTareaProgressDate extends Model
|
||||
protected $table = 'orden_trabajo_tarea_progress_dates';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = OrdenTrabajoTareaEntity::class;
|
||||
protected $returnType = OrdenTrabajoTareaProgressDateEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
|
||||
@ -23,11 +23,18 @@ class OrdenTrabajoUser extends Model
|
||||
"interior_bn_user_id",
|
||||
"interior_color_user_id",
|
||||
"cubierta_user_id",
|
||||
"sobrecubierta_user_id",
|
||||
"guarda_user_id",
|
||||
//ACABADO
|
||||
"plastificado_user_id",
|
||||
"plakene_user_id",
|
||||
"retractilado_user_id",
|
||||
"estampado_user_id",
|
||||
"uvi_user_id",
|
||||
//ENCUADERNADO
|
||||
"encuadernacion_user_id",
|
||||
"corte_user_id",
|
||||
"preparacion_interior_user_id",
|
||||
"corte_user_id",
|
||||
"entrada_manipulado_user_id",
|
||||
"cosido_user_id",
|
||||
"solapa_user_id",
|
||||
|
||||
@ -45,6 +45,7 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel
|
||||
"proveedor_id",
|
||||
"proveedor",
|
||||
"entregaPieCalle",
|
||||
"is_ferro_prototipo"
|
||||
];
|
||||
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoDireccionesEntity";
|
||||
@ -69,7 +70,8 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel
|
||||
t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t2.nombre AS pais,
|
||||
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono,
|
||||
t1.peso AS peso, t1.cantidad AS cantidad, t1.precio AS precio, t1.margen AS margen,
|
||||
t1.proveedor_id AS proveedor_id, t1.proveedor AS proveedor, t1.entregaPieCalle AS entregaPieCalle"
|
||||
t1.proveedor_id AS proveedor_id, t1.proveedor AS proveedor, t1.entregaPieCalle AS entregaPieCalle,
|
||||
t1.is_ferro_prototipo AS is_ferro_prototipo"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tarifas\Acabados;
|
||||
|
||||
class TarifaAcabadoModel extends \App\Models\BaseModel
|
||||
@ -33,6 +34,16 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_updated_id",
|
||||
'plastificado',
|
||||
'plakene',
|
||||
'rectractilado',
|
||||
'estampado',
|
||||
'uvi',
|
||||
'plastificado_tipo',
|
||||
'plakene_tipo',
|
||||
'rectractilado_tipo',
|
||||
'estampado_tipo',
|
||||
'uvi_tipo'
|
||||
];
|
||||
protected $returnType = 'App\Entities\Tarifas\Acabados\TarifaAcabadoEntity';
|
||||
|
||||
@ -96,9 +107,9 @@ class TarifaAcabadoModel extends \App\Models\BaseModel
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->groupEnd();
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function getServiciosAcabadoSelector()
|
||||
|
||||
@ -9,11 +9,11 @@ class EmailService
|
||||
public function send(string $subject, string $body, $recipient): bool
|
||||
{
|
||||
|
||||
$skEnv = env('sk_environment', 'production'); // fallback a producción si no está definido
|
||||
$skEnv = env('SK_ENVIRONMENT', 'production'); // fallback a producción si no está definido
|
||||
|
||||
// Si no estamos en producción, forzar el destinatario a uno fijo
|
||||
if ($skEnv !== 'production') {
|
||||
$recipient = 'imnavajas@coit.es'; // <-- Cambia por el correo de pruebas
|
||||
$recipient = env('MAIL_DEV_RECIPIENT', 'imnavajas@coit.es'); // fallback opcional
|
||||
}
|
||||
|
||||
$settings_model = model('App\Models\Configuracion\ConfigVariableModel');
|
||||
|
||||
364
ci4/app/Services/EtiquetasTitulosService.php
Normal file
364
ci4/app/Services/EtiquetasTitulosService.php
Normal file
@ -0,0 +1,364 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Config\Services;
|
||||
|
||||
class EtiquetasTitulosService
|
||||
{
|
||||
|
||||
public static function getOtsWithTitulos()
|
||||
{
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// 3. Subconsulta principal
|
||||
$builder = $db->table('ordenes_trabajo ot')
|
||||
->select("
|
||||
ot.id AS id,
|
||||
CONCAT('[', ot.id, '] - ', pr.titulo) AS name")
|
||||
->join('pedidos p', 'p.id = ot.pedido_id')
|
||||
->join('pedidos_linea pl', 'p.id = pl.pedido_id')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||
->join('orden_trabajo_dates ot_dates', 'ot_dates.orden_trabajo_id = ot.id')
|
||||
->whereIn('p.estado', ['finalizado', 'produccion']);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public static function getDireccionesOT($ot_id)
|
||||
{
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// 3. Subconsulta principal
|
||||
$builder = $db->table('presupuesto_direcciones pd')
|
||||
->select("
|
||||
pd.id AS id,
|
||||
pd.direccion AS name")
|
||||
->join('presupuestos pr', 'pr.id = pd.presupuesto_id')
|
||||
->join('pedidos_linea pl', 'pr.id = pl.presupuesto_id')
|
||||
->join('pedidos p', 'p.id = pl.pedido_id')
|
||||
->join('ordenes_trabajo ot', 'ot.pedido_id = p.id')
|
||||
->join('orden_trabajo_dates ot_dates', 'ot_dates.orden_trabajo_id = ot.id')
|
||||
->whereIn('p.estado', ['finalizado', 'produccion'])
|
||||
->where('ot.id', $ot_id);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public static function addEtiqueta($data)
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$builder = $db->table('presupuesto_direcciones pd');
|
||||
$builder->select('pd.att, pd.direccion, pd.cantidad, pr.cliente_id');
|
||||
$builder->join('presupuestos pr', 'pr.id = pd.presupuesto_id');
|
||||
$builder->join('pedidos_linea pl', 'pr.id = pl.presupuesto_id');
|
||||
$builder->join('pedidos p', 'p.id = pl.pedido_id');
|
||||
$builder->join('ordenes_trabajo ot', 'ot.pedido_id = p.id');
|
||||
$builder->where('ot.id', $data['ot_id']);
|
||||
$builder->where('pd.direccion', $data['direccion']);
|
||||
|
||||
$result = $builder->get()->getRow();
|
||||
$data['att'] = $result->att;
|
||||
$data['direccion'] = $result->direccion;
|
||||
$data['cantidad'] = $result->cantidad;
|
||||
$data['cliente_id'] = $result->cliente_id;
|
||||
|
||||
$modelEtiquetasTitulos = model('App\Models\Etiquetas\EtiquetasTitulosModel');
|
||||
$modelEtiquetasTitulos->insert([
|
||||
'direccion' => $data['direccion'],
|
||||
'att' => $data['att'],
|
||||
'cliente_id' => $data['cliente_id'],
|
||||
'user_created_at' => $data['user_id'],
|
||||
]);
|
||||
$etiquetaId = $modelEtiquetasTitulos->getInsertID();
|
||||
|
||||
if ($etiquetaId == null) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errorInsertarEtiqueta'),
|
||||
];
|
||||
}
|
||||
|
||||
$cantidad_restante = intval($data['cantidad']);
|
||||
$numero_caja = 1;
|
||||
while ($cantidad_restante > 0) {
|
||||
$modelEtiquetasTitulosLineas = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
$modelEtiquetasTitulosLineas->insert([
|
||||
'etiqueta_titulos_id' => $etiquetaId,
|
||||
'ot_id' => $data['ot_id'],
|
||||
'unidades' => $cantidad_restante - intval($data['unidades_caja']) < 0 ? $cantidad_restante : intval($data['unidades_caja']),
|
||||
'numero_caja' => $numero_caja,
|
||||
'user_created_at' => $data['user_id'],
|
||||
]);
|
||||
$cantidad_restante -= $data['unidades_caja'];
|
||||
$numero_caja++;
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'status' => true,
|
||||
'etiqueta' => $etiquetaId,
|
||||
];
|
||||
}
|
||||
|
||||
public static function findOTsWithAddress(int $etiqueta_id)
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// 1. Dirección del envío actual
|
||||
$etiqueta = $db->table('etiquetas_titulos')->select('direccion')->where('id', $etiqueta_id)->get()->getRow();
|
||||
if (!$etiqueta) {
|
||||
return $db->table('(SELECT NULL AS id, NULL AS name, NULL as unidades) AS empty')->where('1 = 0');
|
||||
}
|
||||
|
||||
$direccionNormalizada = str_replace(' ', '', strtolower(trim($etiqueta->direccion)));
|
||||
$direccionSQL = $db->escape($direccionNormalizada);
|
||||
|
||||
// 2. Obtener presupuestos con esa dirección
|
||||
$presupuestosConEsaDireccion = $db->table('presupuesto_direcciones')
|
||||
->select('presupuesto_id')
|
||||
->where("REPLACE(LOWER(TRIM(direccion)), ' ', '') = $direccionSQL", null, false)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$presupuestoIds = array_column($presupuestosConEsaDireccion, 'presupuesto_id');
|
||||
if (empty($presupuestoIds)) {
|
||||
return $db->table('(SELECT NULL AS id, NULL AS name, NULL as unidades) AS empty')->where('1 = 0');
|
||||
}
|
||||
|
||||
// 3. Subconsulta principal
|
||||
$subBuilder = $db->table('pedidos_linea pl')
|
||||
->select("
|
||||
ot.id AS id,
|
||||
CONCAT('[', ot.id, '] - ', pr.titulo) AS name,
|
||||
pd.cantidad AS description
|
||||
")
|
||||
->join('pedidos p', 'p.id = pl.pedido_id')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||
->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id')
|
||||
->join('ordenes_trabajo ot', 'ot.pedido_id = p.id')
|
||||
->join('orden_trabajo_dates ot_dates', 'ot_dates.orden_trabajo_id = ot.id')
|
||||
->whereIn('pr.id', $presupuestoIds)
|
||||
->whereIn('p.estado', ['finalizado', 'produccion'])
|
||||
->groupBy('pl.id');
|
||||
|
||||
// 4. Envolver y filtrar por unidades pendientes
|
||||
$builder = $db->table("({$subBuilder->getCompiledSelect(false)}) AS sub");
|
||||
$builder->select('id, name, description');
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public static function addLineasEtiqueta($etiqueta_id, $ot_id, $unidades, $cajas)
|
||||
{
|
||||
|
||||
$unidades_caja = intdiv($unidades, $cajas);
|
||||
$unidades_caja = $unidades_caja == 0 ? $unidades : $unidades_caja;
|
||||
|
||||
$unidades_restantes = $unidades;
|
||||
|
||||
$modelEtitquetaLinea = model('\App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
$next_caja = $modelEtitquetaLinea
|
||||
->selectMax('numero_caja')
|
||||
->where('etiqueta_titulos_id', $etiqueta_id)
|
||||
->first();
|
||||
$next_caja = $next_caja->numero_caja ?? 0;
|
||||
$next_caja++;
|
||||
|
||||
$user_id = auth()->user()->id;
|
||||
|
||||
while ($unidades_restantes > 0) {
|
||||
$modelEtitquetaLinea->insert([
|
||||
'etiqueta_titulos_id' => $etiqueta_id,
|
||||
'ot_id' => $ot_id,
|
||||
'unidades' => $unidades_restantes - $unidades_caja < 0 ? $unidades_restantes : intval($unidades_caja),
|
||||
'numero_caja' => $next_caja,
|
||||
'user_created_at' => $user_id,
|
||||
]);
|
||||
$unidades_restantes -= $unidades_caja;
|
||||
$next_caja++;
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.successInsertLines'),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public static function reordenarCajas($etiqueta_id)
|
||||
{
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
|
||||
// 1. Obtener todas las líneas ordenadas por numero_caja e id
|
||||
$lineas = $model
|
||||
->where('etiqueta_titulos_id', $etiqueta_id)
|
||||
->orderBy('numero_caja ASC')
|
||||
->orderBy('id ASC')
|
||||
->findAll();
|
||||
|
||||
// 2. Agrupar por caja
|
||||
$grupos = [];
|
||||
foreach ($lineas as $linea) {
|
||||
$grupos[$linea->numero_caja][] = $linea;
|
||||
}
|
||||
|
||||
// 3. Reasignar números de caja de forma consecutiva
|
||||
$nuevoNumeroCaja = 1;
|
||||
foreach ($grupos as $grupo) {
|
||||
foreach ($grupo as $linea) {
|
||||
$model->update($linea->id, ['numero_caja' => $nuevoNumeroCaja]);
|
||||
|
||||
}
|
||||
$nuevoNumeroCaja++;
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.successReordenarCajas'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function imprimirEtiquetas($etiqueta_id = null, $ids = [], $printer = null){
|
||||
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosModel');
|
||||
$modelLineas = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
|
||||
if ($etiqueta_id) {
|
||||
$etiquetas = $model->where('id', $etiqueta_id)->first();
|
||||
$etiquetas_lineas = $modelLineas->whereIn('id', $ids)->orderBy('numero_caja', 'ASC')->findAll();
|
||||
}
|
||||
|
||||
// buscar el maximo numero_cajas en el array de objetos etiquetas_lineas
|
||||
$max_num_cajas = 0;
|
||||
foreach ($etiquetas_lineas as $linea) {
|
||||
if ($linea->numero_caja > $max_num_cajas) {
|
||||
$max_num_cajas = $linea->numero_caja;
|
||||
}
|
||||
}
|
||||
|
||||
// se obtienen los numero_caja diferentes en un array
|
||||
$numero_cajas = [];
|
||||
foreach ($etiquetas_lineas as $linea) {
|
||||
if (!in_array($linea->numero_caja, $numero_cajas)) {
|
||||
$numero_cajas[] = $linea->numero_caja;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($etiquetas)) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noEtiqueta'),
|
||||
];
|
||||
}
|
||||
if (empty($etiquetas_lineas)) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noEtiquetaLineas'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
"printer" => $printer->name,
|
||||
"header" => [
|
||||
"_FORMAT" => "E:MULTI.ZPL",
|
||||
"_QUANTITY" => 1,
|
||||
"_PRINBTERNAME" => $printer->name,
|
||||
"_JOBNAME" => "LBL101"
|
||||
],
|
||||
'direccion' => $etiquetas->direccion,
|
||||
'grupos' => [],
|
||||
'notas' => $etiquetas->comentarios,
|
||||
'nombre' => $etiquetas->att,
|
||||
];
|
||||
|
||||
|
||||
$index_etiqueta = 0;
|
||||
foreach ($numero_cajas as $caja) {
|
||||
|
||||
array_push($data['grupos'], [
|
||||
]);
|
||||
|
||||
$prefix = 1;
|
||||
$lineas = array_filter($etiquetas_lineas, function ($linea) use ($caja) {
|
||||
return $linea->numero_caja == $caja;
|
||||
});
|
||||
|
||||
$lineaCounter = 0;
|
||||
foreach($lineas as $linea){
|
||||
|
||||
|
||||
if($lineaCounter >= 5){
|
||||
$lineaCounter = 0;
|
||||
$index_etiqueta++;
|
||||
array_push($data['grupos'], []);
|
||||
}
|
||||
|
||||
$modelPresupuestos = model('App\Models\OrdenTrabajo\OrdenTrabajoModel');
|
||||
$datos_etiqueta = $modelPresupuestos->select('
|
||||
pr.titulo as titulo,
|
||||
pr.isbn as isbn,
|
||||
pr.referencia_cliente as referencia_cliente,
|
||||
p.id as id_pedido,
|
||||
ordenes_trabajo.total_tirada as total_tirada,')
|
||||
->join('pedidos p', 'p.id = ordenes_trabajo.pedido_id')
|
||||
->join('pedidos_linea pl', 'pl.pedido_id = p.id')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||
->where('ordenes_trabajo.id',$linea->ot_id)->first();
|
||||
|
||||
|
||||
|
||||
$data['grupos'][$index_etiqueta][] = [
|
||||
'prefix' => $caja,
|
||||
'titulo' => mb_substr($datos_etiqueta->titulo, 0, 40),
|
||||
'cantidad' => $linea->unidades,
|
||||
'tirada' => $datos_etiqueta->total_tirada,
|
||||
'ean' => str_replace('-', '', $datos_etiqueta->isbn),
|
||||
'npedido' => $datos_etiqueta->id,
|
||||
'refcliente' => $datos_etiqueta->referencia_cliente,
|
||||
];
|
||||
|
||||
$lineaCounter++;
|
||||
}
|
||||
$index_etiqueta++;
|
||||
}
|
||||
|
||||
$servicioImpresora = new ImpresoraEtiquetaService();
|
||||
$xml = $servicioImpresora->createEtiquetaTitulos($data);
|
||||
if ($xml == null) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noEtiquetas'),
|
||||
];
|
||||
}
|
||||
$sk_environment = getenv('SK_ENVIRONMENT');
|
||||
if ($sk_environment == 'production') {
|
||||
|
||||
$status = $servicioImpresora->sendToImpresoraEtiqueta("ETIQUETA", $xml, $printer);
|
||||
if ($status) {
|
||||
return [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.imprimirEtiquetas'),
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noEtiquetas'),
|
||||
];
|
||||
}
|
||||
|
||||
} else {
|
||||
return [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.imprimirEtiquetas'),
|
||||
'data' => $xml
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -24,9 +24,9 @@ class ImpresoraEtiquetaService extends BaseService
|
||||
"labels" => [
|
||||
[
|
||||
"cliente" => "Cliente Potencial",
|
||||
"titulo" => "[1234] TEST OLIVEROS",
|
||||
"titulo" => "[1234] TEST OLIVEROS",
|
||||
"cantidad" => 100,
|
||||
"tirada" => 50,
|
||||
"tirada" => 50,
|
||||
"cajas" => 1,
|
||||
"ean" => null,
|
||||
"nombre" => "___Nombre___",
|
||||
@ -57,7 +57,7 @@ class ImpresoraEtiquetaService extends BaseService
|
||||
return ["impresora" => $impresora, "content" => $th->getMessage(), "status" => $status];
|
||||
}
|
||||
}
|
||||
protected function createEtiqueta(array $data_label = []): ?string
|
||||
public function createEtiqueta(array $data_label = []): ?string
|
||||
{
|
||||
$xml = new DOMDocument('1.0', 'utf-8');
|
||||
$labels = $xml->createElement("labels");
|
||||
@ -76,7 +76,67 @@ class ImpresoraEtiquetaService extends BaseService
|
||||
$xml->appendChild($labels);
|
||||
return $xml->saveXML();
|
||||
}
|
||||
protected function sendToImpresoraEtiqueta(string $name, string $content, ImpresoraEtiquetaEntity $impresoraEtiqueta): bool
|
||||
|
||||
|
||||
public function createEtiquetaTitulos(array $data_label = []): ?string
|
||||
{
|
||||
$xml = new DOMDocument('1.0', 'utf-8');
|
||||
|
||||
// Crear nodo raíz "labels"
|
||||
$labels = $xml->createElement("labels");
|
||||
|
||||
// Establecer atributos de "labels" desde "header"
|
||||
foreach ($data_label["header"] as $key => $value) {
|
||||
$labels->setAttribute($key, $value);
|
||||
}
|
||||
|
||||
// Recorrer grupos de etiquetas
|
||||
foreach ($data_label["grupos"] as $grupo) {
|
||||
$labelChild = $xml->createElement('label');
|
||||
|
||||
// Crear variables específicas del grupo
|
||||
foreach ($grupo as $libro) {
|
||||
$prefix = $libro['prefix'];
|
||||
|
||||
$variables = [
|
||||
"titulo$prefix" => $libro['titulo'],
|
||||
"tirada$prefix" => $libro['tirada'],
|
||||
"ean$prefix" => $libro['ean'],
|
||||
"npedido$prefix" => $libro['npedido'],
|
||||
"refcliente$prefix" => $libro['refcliente'],
|
||||
"textpedido$prefix" => 'Pedido',
|
||||
"textcantidad$prefix" => 'Cantidad:',
|
||||
"textref$prefix" => 'Ref:',
|
||||
"textean$prefix" => 'ISBN',
|
||||
];
|
||||
|
||||
foreach ($variables as $varName => $varValue) {
|
||||
$variableChild = $xml->createElement('variable');
|
||||
$variableChild->setAttribute("name", $varName);
|
||||
$variableChild->appendChild($xml->createTextNode((string) $varValue));
|
||||
$labelChild->appendChild($variableChild);
|
||||
}
|
||||
}
|
||||
|
||||
// Variables comunes del grupo
|
||||
$nombreVariable = $xml->createElement('variable', htmlspecialchars($data_label['nombre']));
|
||||
$nombreVariable->setAttribute('name', 'nombre');
|
||||
$labelChild->appendChild($nombreVariable);
|
||||
|
||||
$direccionVariable = $xml->createElement('variable', htmlspecialchars($data_label['direccion']));
|
||||
$direccionVariable->setAttribute('name', 'direccion');
|
||||
$labelChild->appendChild($direccionVariable);
|
||||
|
||||
$labels->appendChild($labelChild);
|
||||
}
|
||||
|
||||
$xml->appendChild($labels);
|
||||
return $xml->saveXML();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function sendToImpresoraEtiqueta(string $name, string $content, ImpresoraEtiquetaEntity $impresoraEtiqueta): bool
|
||||
{
|
||||
$tmpFile = tmpfile();
|
||||
|
||||
@ -84,8 +144,8 @@ class ImpresoraEtiquetaService extends BaseService
|
||||
rewind($tmpFile);
|
||||
|
||||
$tmpMetaData = stream_get_meta_data($tmpFile);
|
||||
$conn = @ftp_connect($impresoraEtiqueta->ip,$impresoraEtiqueta->port);
|
||||
if(!$conn){
|
||||
$conn = @ftp_connect($impresoraEtiqueta->ip, $impresoraEtiqueta->port);
|
||||
if (!$conn) {
|
||||
throw new Exception('Error al establecer conexión FTP');
|
||||
}
|
||||
$isLoginSuccess = @ftp_login($conn, $impresoraEtiqueta->user, $impresoraEtiqueta->pass);
|
||||
@ -99,10 +159,10 @@ class ImpresoraEtiquetaService extends BaseService
|
||||
if (ftp_put($conn, $name, $tmpMetaData['uri'], FTP_ASCII) === FALSE) {
|
||||
$status = false;
|
||||
ftp_close($conn);
|
||||
}else{
|
||||
} else {
|
||||
$status = true;
|
||||
}
|
||||
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,111 +7,6 @@ use Config\Services;
|
||||
|
||||
class LogisticaService
|
||||
{
|
||||
public static function findPedidoOrISBN($search)
|
||||
{
|
||||
$multienvio = false;
|
||||
$direcciones = [];
|
||||
|
||||
$modelPedido = model('App\Models\Pedidos\PedidoModel');
|
||||
|
||||
$search = trim($search);
|
||||
$searchClean = str_replace('-', '', $search);
|
||||
$modelPedido = model('App\Models\Pedidos\PedidoModel');
|
||||
|
||||
$builder = $modelPedido->builder();
|
||||
|
||||
$builder->select([
|
||||
'pedidos.id as pedido_id',
|
||||
'pedidos_linea.id as linea_id',
|
||||
'pedidos_linea.cantidad as cantidad_linea',
|
||||
'presupuestos.id as presupuesto_id',
|
||||
]);
|
||||
|
||||
$builder->join('pedidos_linea', 'pedidos_linea.pedido_id = pedidos.id', 'left');
|
||||
$builder->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left');
|
||||
$builder->join('envios_lineas', 'envios_lineas.pedido_id = pedidos_linea.pedido_id', 'left');
|
||||
|
||||
$builder->groupStart()
|
||||
->where('pedidos.id', $search)
|
||||
->whereIn('pedidos.estado', ['finalizado', 'produccion'])
|
||||
->orWhere("REPLACE(presupuestos.isbn, '-', '')", $searchClean)
|
||||
->groupEnd();
|
||||
|
||||
$builder->groupBy('pedidos_linea.id');
|
||||
$builder->having('IFNULL(SUM(envios_lineas.unidades_envio), 0) < cantidad_linea', null, false);
|
||||
|
||||
|
||||
$result = $builder->get()->getResult();
|
||||
|
||||
if (empty($result)) {
|
||||
$response = [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.notFound'),
|
||||
];
|
||||
return $response;
|
||||
}
|
||||
|
||||
$PresupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$numDirecciones = $PresupuestoDireccionesModel->where('presupuesto_id', $result[0]->presupuesto_id)
|
||||
->countAllResults();
|
||||
if ($numDirecciones == 0) {
|
||||
$response = [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noAddresses'),
|
||||
];
|
||||
return $response;
|
||||
} else if ($numDirecciones > 1) {
|
||||
$multienvio = true;
|
||||
$dirs = $PresupuestoDireccionesModel->select('direccion')->where('presupuesto_id', $result[0]->presupuesto_id)
|
||||
->findAll();
|
||||
foreach ($dirs as $key => $direccion) {
|
||||
$modelEnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
||||
$unidades_en_direccion = $modelEnvioLineasModel->select('SUM(envios_lineas.unidades_envio) as unidades_enviadas,
|
||||
envios_lineas.unidades_total')
|
||||
->join('envios', 'envios.id = envios_lineas.envio_id')
|
||||
->where('pedido_id', $result[0]->pedido_id)
|
||||
->where('envios.direccion', $direccion->direccion)
|
||||
->where('envios.finalizado', 1)
|
||||
->groupBy('pedido_id')->get()->getResult();
|
||||
if (count($unidades_en_direccion) == 0 || $unidades_en_direccion[0]->unidades_enviadas < $unidades_en_direccion[0]->unidades_total) {
|
||||
array_push($direcciones, $direccion->direccion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $result[0],
|
||||
];
|
||||
|
||||
if ($multienvio) {
|
||||
$response_envio = [
|
||||
'status' => true,
|
||||
'multienvio' => true,
|
||||
'direcciones' => $direcciones,
|
||||
'pedido_id' => $result[0]->pedido_id,
|
||||
];
|
||||
return $response_envio;
|
||||
}
|
||||
|
||||
|
||||
$direccion = $PresupuestoDireccionesModel->select('direccion')->where('presupuesto_id', $result[0]->presupuesto_id)
|
||||
->first()->direccion;
|
||||
$response_envio = LogisticaService::generateEnvio($result[0]->pedido_id, $direccion);
|
||||
if ($response_envio['status'] == false) {
|
||||
$response = [
|
||||
'status' => false,
|
||||
'message' => $response_envio['message'],
|
||||
];
|
||||
return $response;
|
||||
} else {
|
||||
$response['data']->id_envio = $response_envio['data']['id_envio'];
|
||||
$response['data']->multienvio = false;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function findLineaEnvioPorEnvio(int $envio_id)
|
||||
@ -142,8 +37,8 @@ class LogisticaService
|
||||
// 3. Subconsulta principal
|
||||
$subBuilder = $db->table('pedidos_linea pl')
|
||||
->select("
|
||||
pl.id AS id,
|
||||
CONCAT('[', p.id, '] - ', pr.titulo) AS name,
|
||||
ot.id AS id,
|
||||
CONCAT('[', ot.id, '] - ', pr.titulo) AS name,
|
||||
(
|
||||
SELECT IFNULL(SUM(el.unidades_envio), 0)
|
||||
FROM envios_lineas el
|
||||
@ -183,15 +78,16 @@ class LogisticaService
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public static function findPedidosNewEnvio()
|
||||
|
||||
public static function findForNewEnvio()
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// 3. Subconsulta principal
|
||||
$subBuilder = $db->table('pedidos_linea pl')
|
||||
->select("
|
||||
pl.id AS id,
|
||||
CONCAT('[', p.id, '] - ', pr.titulo) AS name,
|
||||
ot.id AS id,
|
||||
CONCAT('[', ot.id, '] - ', pr.titulo) AS name,
|
||||
(
|
||||
SELECT IFNULL(SUM(el.unidades_envio), 0)
|
||||
FROM envios_lineas el
|
||||
@ -199,6 +95,7 @@ class LogisticaService
|
||||
WHERE el.pedido_id = p.id
|
||||
AND el.presupuesto_id = pr.id
|
||||
AND e.finalizado = 1
|
||||
AND e.tipo_envio = 'estandar'
|
||||
) AS unidades_enviadas,
|
||||
pd.cantidad AS cantidad
|
||||
")
|
||||
@ -220,7 +117,47 @@ class LogisticaService
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public static function findDireccionesNewEnvio($pedido_id, $searchVal = "")
|
||||
public static function findForNewEnvioFerro()
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// 3. Subconsulta principal
|
||||
$subBuilder = $db->table('pedidos_linea pl')
|
||||
->select("
|
||||
ot.id AS id,
|
||||
CONCAT('[', ot.id, '] - ', pr.titulo) AS name,
|
||||
p.id as pedido_id,
|
||||
pr.id as presupuesto_id
|
||||
")
|
||||
->join('pedidos p', 'p.id = pl.pedido_id')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||
->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id')
|
||||
->join('ordenes_trabajo ot', 'ot.pedido_id = p.id')
|
||||
->join('orden_trabajo_dates ot_dates', 'ot_dates.orden_trabajo_id = ot.id')
|
||||
->whereIn('p.estado', ['finalizado', 'produccion'])
|
||||
->where('ot_dates.pendiente_ferro_at IS NOT NULL')
|
||||
->where('pd.is_ferro_prototipo', 1)
|
||||
->groupBy('pl.id');
|
||||
|
||||
// 4. Envolver y filtrar por unidades pendientes
|
||||
$builder = $db->table("({$subBuilder->getCompiledSelect(false)}) AS sub");
|
||||
$builder->select('id, name');
|
||||
$builder->orderBy('name', 'ASC');
|
||||
|
||||
$builder->where("
|
||||
NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM envios e
|
||||
INNER JOIN envios_lineas le ON le.envio_id = e.id
|
||||
WHERE e.tipo_envio = 'ferro_prototipo'
|
||||
AND (le.pedido_id = sub.pedido_id OR le.presupuesto_id = sub.presupuesto_id)
|
||||
)
|
||||
", null, false);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public static function findDireccionesNewEnvio($ot_id, $searchVal = "")
|
||||
{
|
||||
|
||||
$direcciones = [];
|
||||
@ -231,7 +168,9 @@ class LogisticaService
|
||||
->join('presupuestos pr', 'pr.id=presupuesto_direcciones.presupuesto_id')
|
||||
->join('pedidos_linea pl', 'pl.presupuesto_id = pr.id')
|
||||
->join('pedidos p', 'pl.pedido_id=p.id')
|
||||
->where('p.id', $pedido_id);
|
||||
->join('ordenes_trabajo ot', 'ot.pedido_id = p.id')
|
||||
->where('ot.id', $ot_id)
|
||||
->where("presupuesto_direcciones.is_ferro_prototipo", 0);
|
||||
if ($searchVal != "") {
|
||||
$dirs = $dirs->groupStart()
|
||||
->Like("id", $searchVal)
|
||||
@ -243,10 +182,13 @@ class LogisticaService
|
||||
$unidades_en_direccion = $modelEnvioLineasModel->select('SUM(envios_lineas.unidades_envio) as unidades_enviadas,
|
||||
envios_lineas.unidades_total')
|
||||
->join('envios', 'envios.id = envios_lineas.envio_id')
|
||||
->where('pedido_id', $pedido_id)
|
||||
->join('pedidos_linea', 'pedidos_linea.pedido_id = envios_lineas.pedido_id')
|
||||
->join('pedidos', 'pedidos.id = pedidos_linea.pedido_id')
|
||||
->join('ordenes_trabajo', 'ordenes_trabajo.pedido_id = pedidos.id')
|
||||
->where('ordenes_trabajo.id', $ot_id)
|
||||
->where('envios.direccion', $direccion->direccion)
|
||||
->where('envios.finalizado', 1)
|
||||
->groupBy('pedido_id')->get()->getResult();
|
||||
->groupBy('ordenes_trabajo.pedido_id')->get()->getResult();
|
||||
if (count($unidades_en_direccion) == 0 || $unidades_en_direccion[0]->unidades_enviadas < $unidades_en_direccion[0]->unidades_total) {
|
||||
array_push(
|
||||
$direcciones,
|
||||
@ -301,6 +243,7 @@ class LogisticaService
|
||||
->join('pedidos p', 'p.id = pl.pedido_id')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||
->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id')
|
||||
->where('pd.is_ferro_prototipo', 0)
|
||||
->where('p.id', $pedido_id)
|
||||
->whereIn('p.estado', ['finalizado', 'produccion'])
|
||||
->where("TRIM(LOWER(pd.direccion)) = '$direccionNormalizada'", null, false)
|
||||
@ -347,7 +290,7 @@ class LogisticaService
|
||||
|
||||
|
||||
|
||||
public static function generateEnvio($pedido_id, $direccion = null)
|
||||
public static function generateEnvio($ot_id, $direccion = null)
|
||||
{
|
||||
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$direccionNormalizada = strtolower(trim($direccion));
|
||||
@ -364,6 +307,7 @@ class LogisticaService
|
||||
presupuesto_direcciones.pais_id,
|
||||
presupuesto_direcciones.cantidad as cantidad_total,
|
||||
presupuestos.cliente_id as cliente_id,
|
||||
ordenes_trabajo.pedido_id as pedido_id,
|
||||
|
||||
(
|
||||
presupuesto_direcciones.cantidad - IFNULL((
|
||||
@ -380,7 +324,9 @@ class LogisticaService
|
||||
->join('pedidos_linea', 'pedidos_linea.presupuesto_id = presupuesto_direcciones.presupuesto_id')
|
||||
->join('pedidos', 'pedidos.id = pedidos_linea.pedido_id')
|
||||
->join('presupuestos', 'pedidos_linea.presupuesto_id = presupuestos.id')
|
||||
->where('pedidos.id', $pedido_id)
|
||||
->join('ordenes_trabajo', 'ordenes_trabajo.pedido_id = pedidos.id')
|
||||
->where('ordenes_trabajo.id', $ot_id)
|
||||
->where('presupuesto_direcciones.is_ferro_prototipo', 0)
|
||||
->like('presupuesto_direcciones.direccion', $direccion)
|
||||
->groupBy('presupuesto_direcciones.id')
|
||||
->first();
|
||||
@ -416,7 +362,7 @@ class LogisticaService
|
||||
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
||||
$EnvioLineasModel->save([
|
||||
'envio_id' => $idEnvio,
|
||||
'pedido_id' => $pedido_id,
|
||||
'pedido_id' => $datosEnvio->pedido_id,
|
||||
'unidades_envio' => $datosEnvio->cantidad,
|
||||
'unidades_total' => $datosEnvio->cantidad_total,
|
||||
'cajas' => 1,
|
||||
@ -437,6 +383,95 @@ class LogisticaService
|
||||
}
|
||||
|
||||
|
||||
public static function generateEnvioFerro($ot_id)
|
||||
{
|
||||
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
|
||||
$datosEnvio = $presupuestoDireccionesModel
|
||||
->select("
|
||||
presupuestos.id as presupuesto_id,
|
||||
presupuesto_direcciones.att,
|
||||
presupuesto_direcciones.direccion,
|
||||
presupuesto_direcciones.provincia as ciudad,
|
||||
presupuesto_direcciones.cp,
|
||||
presupuesto_direcciones.telefono,
|
||||
presupuesto_direcciones.email,
|
||||
presupuesto_direcciones.pais_id,
|
||||
presupuesto_direcciones.cantidad as cantidad_total,
|
||||
presupuestos.cliente_id as cliente_id,
|
||||
ordenes_trabajo.pedido_id as pedido_id,
|
||||
")
|
||||
->join('pedidos_linea', 'pedidos_linea.presupuesto_id = presupuesto_direcciones.presupuesto_id')
|
||||
->join('pedidos', 'pedidos.id = pedidos_linea.pedido_id')
|
||||
->join('presupuestos', 'pedidos_linea.presupuesto_id = presupuestos.id')
|
||||
->join('ordenes_trabajo', 'ordenes_trabajo.pedido_id = pedidos.id')
|
||||
->where('ordenes_trabajo.id', $ot_id)
|
||||
->where('presupuesto_direcciones.is_ferro_prototipo', 1)
|
||||
->where("
|
||||
NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM envios e
|
||||
INNER JOIN envios_lineas el ON el.envio_id = e.id
|
||||
WHERE e.tipo_envio = 'ferro_prototipo'
|
||||
AND (el.pedido_id = pedidos.id OR el.presupuesto_id = presupuestos.id)
|
||||
)
|
||||
", null, false) // <= Esta es la parte nueva, importante
|
||||
->groupBy('presupuesto_direcciones.id')
|
||||
->first();
|
||||
|
||||
// Validación si no hay datos o no quedan unidades
|
||||
if (empty($datosEnvio)) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noAddresses')
|
||||
];
|
||||
}
|
||||
|
||||
// Crear envío
|
||||
$EnvioModel = model('App\Models\Logistica\EnvioModel');
|
||||
$EnvioModel->set([
|
||||
'cliente_id' => $datosEnvio->cliente_id,
|
||||
'att' => $datosEnvio->att,
|
||||
'direccion' => $datosEnvio->direccion,
|
||||
'ciudad' => $datosEnvio->ciudad,
|
||||
'cp' => $datosEnvio->cp,
|
||||
'telefono' => $datosEnvio->telefono,
|
||||
'email' => $datosEnvio->email,
|
||||
'pais_id' => $datosEnvio->pais_id,
|
||||
'cantidad' => 1,
|
||||
'cajas' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'tipo_envio' => 'ferro_prototipo',
|
||||
]);
|
||||
$EnvioModel->insert();
|
||||
$idEnvio = $EnvioModel->insertID();
|
||||
|
||||
// Crear línea de envío
|
||||
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
||||
$EnvioLineasModel->save([
|
||||
'envio_id' => $idEnvio,
|
||||
'pedido_id' => $datosEnvio->pedido_id,
|
||||
'unidades_envio' => 1,
|
||||
'unidades_total' => 1,
|
||||
'cajas' => 1,
|
||||
'unidades_cajas' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
'presupuesto_id' => (int) $datosEnvio->presupuesto_id
|
||||
]);
|
||||
|
||||
return [
|
||||
'status' => true,
|
||||
'data' => [
|
||||
'id_envio' => $idEnvio,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function finalizarEnvio($envio_id, $finalizar_ot = false)
|
||||
{
|
||||
@ -489,24 +524,36 @@ class LogisticaService
|
||||
$cantidad_enviada = $cantidad_enviada[0]->unidades_enviadas;
|
||||
}
|
||||
|
||||
if ($cantidad_enviada + $linea->unidades_envio == $pedido->total_tirada) {
|
||||
if ($envio->tipo_envio == 'ferro_prototipo') {
|
||||
$otModel = model('App\Models\OrdenTrabajo\OrdenTrabajoModel');
|
||||
$ot = $otModel->where('pedido_id', $linea->pedido_id)
|
||||
->first();
|
||||
$ps = (new ProductionService())->init($ot->id);
|
||||
$ps->updateOrdenTrabajoDate([
|
||||
"name" => "envio_at",
|
||||
"envio_at" => date('Y-m-d H:i:s')
|
||||
"name" => "ferro_en_cliente_at",
|
||||
"ferro_en_cliente_at" => date('Y-m-d H:i:s')
|
||||
]);
|
||||
if ($finalizar_ot) {
|
||||
$ps->updateOrdenTrabajo(
|
||||
[
|
||||
"estado" => 'F'
|
||||
]
|
||||
);
|
||||
array_push($ots, $ot->id);
|
||||
} else {
|
||||
if ($cantidad_enviada + $linea->unidades_envio == $pedido->total_tirada) {
|
||||
$otModel = model('App\Models\OrdenTrabajo\OrdenTrabajoModel');
|
||||
$ot = $otModel->where('pedido_id', $linea->pedido_id)
|
||||
->first();
|
||||
$ps = (new ProductionService())->init($ot->id);
|
||||
$ps->updateOrdenTrabajoDate([
|
||||
"name" => "envio_at",
|
||||
"envio_at" => date('Y-m-d H:i:s')
|
||||
]);
|
||||
if ($finalizar_ot) {
|
||||
$ps->updateOrdenTrabajo(
|
||||
[
|
||||
"estado" => 'F'
|
||||
]
|
||||
);
|
||||
array_push($ots, $ot->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$EnvioModel->update($envio_id, ['finalizado' => 1]);
|
||||
@ -524,4 +571,66 @@ class LogisticaService
|
||||
}
|
||||
return $data_return;
|
||||
}
|
||||
|
||||
public static function generateEtiquetasTitulos($envio, $lineas, $printer, $cajas)
|
||||
{
|
||||
$data = [
|
||||
"printer" => $printer->name,
|
||||
"header" => [
|
||||
"_FORMAT" => "E:PEDIDO.ZPL",
|
||||
"_QUANTITY" => 1,
|
||||
"_PRINBTERNAME" => $printer->name,
|
||||
"_JOBNAME" => "LBL101"
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($lineas as $linea) {
|
||||
$data["labels"][] = [
|
||||
"cliente" => $envio->cliente,
|
||||
"titulo" => "[" . $linea->pedido_id . "] - " . $linea->titulo,
|
||||
"cantidad" => $linea->unidades_envio,
|
||||
"tirada" => $linea->unidades_total,
|
||||
"cajas" => $cajas,
|
||||
"ean" => null,
|
||||
"nombre" => $envio->att,
|
||||
"direccion" => $envio->direccion,
|
||||
"notas" => "",
|
||||
"refcliente" => $linea->refcliente,
|
||||
"npedido" => $linea->pedido_id
|
||||
];
|
||||
}
|
||||
|
||||
$servicioImpresora = new ImpresoraEtiquetaService();
|
||||
$xml = $servicioImpresora->createEtiqueta($data);
|
||||
if ($xml == null) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noEtiquetas'),
|
||||
];
|
||||
}
|
||||
$sk_environment = getenv('SK_ENVIRONMENT');
|
||||
if ($sk_environment == 'production') {
|
||||
|
||||
$status = $servicioImpresora->sendToImpresoraEtiqueta("ETIQUETA", $xml, $printer);
|
||||
if ($status) {
|
||||
return [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.imprimirEtiquetas'),
|
||||
'data' => $xml
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noEtiquetas'),
|
||||
];
|
||||
}
|
||||
|
||||
} else {
|
||||
return [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.imprimirEtiquetas'),
|
||||
'data' => $xml
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ class PresupuestoClienteService extends BaseService
|
||||
if ($total_plana < 0 && $total_rotativa < 0)
|
||||
return [];
|
||||
else {
|
||||
if ($total_plana > $total_rotativa)
|
||||
if ($total_plana > $total_rotativa && $data['forzarRotativa'] == 0)
|
||||
return $plana;
|
||||
else
|
||||
return [$rotativa];
|
||||
|
||||
@ -253,8 +253,7 @@ class PresupuestoService extends BaseService
|
||||
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $linea['fields']['precios_pliegos'];
|
||||
// Precio papel pedido
|
||||
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
|
||||
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);
|
||||
;
|
||||
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);;
|
||||
|
||||
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
|
||||
$linea['fields']['maquina'] = $maquina->maquina;
|
||||
@ -615,9 +614,9 @@ class PresupuestoService extends BaseService
|
||||
// precio tinta
|
||||
$data['precio_tinta'] = round(
|
||||
round(($data['peso_gotas_negro_pedido'] / 1000.0) * $maquina->precio_tinta_negro, 2) +
|
||||
round(($data['peso_gotas_cyan_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||
round(($data['peso_gotas_magenta_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||
round(($data['peso_gotas_amarillo_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2),
|
||||
round(($data['peso_gotas_cyan_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||
round(($data['peso_gotas_magenta_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||
round(($data['peso_gotas_amarillo_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2),
|
||||
2
|
||||
);
|
||||
|
||||
@ -1907,8 +1906,8 @@ class PresupuestoService extends BaseService
|
||||
$pedido = $modelPedido->find($pedido_id);
|
||||
$serviceProduction->setPedido($pedido);
|
||||
if (!$pedido->orden_trabajo()) {
|
||||
|
||||
$r = $serviceProduction->createOrdenTrabajo();
|
||||
|
||||
$r = $serviceProduction->createOrdenTrabajo(true);
|
||||
$modelPedido->set(['estado' => 'produccion'])->where('id', $pedido_id)->update();
|
||||
}
|
||||
}
|
||||
@ -1983,4 +1982,94 @@ class PresupuestoService extends BaseService
|
||||
|
||||
return $peso;
|
||||
}
|
||||
|
||||
public static function ajustarPresupuesto($id, $precio_unidad = null, $unidades = null, $precio_total = null, $forzar_descuento = false)
|
||||
{
|
||||
|
||||
$precio_total_asignado = 0;
|
||||
$precio_unidad_asignado = $precio_unidad;
|
||||
$warning = false;
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoModel');
|
||||
if ($precio_unidad != null && $unidades != null) {
|
||||
$precio_total_asignado = round(floatval($precio_unidad) * intval($unidades), 2);
|
||||
} else {
|
||||
$precio_total_asignado = floatval($precio_total);
|
||||
}
|
||||
$presupuesto = $model->find($id);
|
||||
$costes = floatval($presupuesto->total_costes);
|
||||
$envio_base = floatval($presupuesto->envio_base);
|
||||
|
||||
$total_descuento = 0;
|
||||
$total_descuentoPercent = 0;
|
||||
if ($costes + $envio_base > $precio_total_asignado) {
|
||||
|
||||
if ($forzar_descuento) {
|
||||
$total_descuento = $costes + $envio_base - $precio_total_asignado;
|
||||
$total_descuentoPercent = round($total_descuento / ($costes + $envio_base) * 100, 2);
|
||||
} else {
|
||||
$precio_total_asignado = round($costes + $envio_base, 2);
|
||||
$precio_unidad_asignado = round($precio_total_asignado / intval($unidades), 4);
|
||||
}
|
||||
$warning = true;
|
||||
}
|
||||
$total_margenes = $precio_total_asignado - $costes - $envio_base < 0 ?
|
||||
0 :
|
||||
$precio_total_asignado - $costes - $envio_base;
|
||||
|
||||
$sumForFactor = floatval($presupuesto->total_coste_papel) + floatval($presupuesto->total_coste_impresion);
|
||||
$sumForFactorPonderado = $sumForFactor + floatval($presupuesto->total_coste_servicios);
|
||||
|
||||
$factor = ($precio_total_asignado - floatval($presupuesto->envio_base)
|
||||
- floatval($presupuesto->total_coste_envios) - floatval($presupuesto->total_margen_envios)) / $sumForFactor;
|
||||
|
||||
$factorPonderado = ($precio_total_asignado - floatval($presupuesto->envio_base)
|
||||
- floatval($presupuesto->total_coste_envios) - floatval($presupuesto->total_margen_envios)) / $sumForFactorPonderado;
|
||||
|
||||
if ($presupuesto) {
|
||||
|
||||
$presupuesto->total_margenes = $total_margenes;
|
||||
$presupuesto->total_aceptado = $precio_total_asignado;
|
||||
$presupuesto->total_aceptado_revisado = $precio_total_asignado;
|
||||
$presupuesto->total_presupuesto = $precio_total_asignado;
|
||||
$presupuesto->total_antes_descuento = $precio_total_asignado - $costes - $envio_base < 0 ?
|
||||
$costes + $envio_base :
|
||||
$precio_total_asignado;
|
||||
$presupuesto->total_precio_unidad = $precio_unidad_asignado;
|
||||
$presupuesto->total_descuento = $total_descuento;
|
||||
$presupuesto->total_descuentoPercent = $total_descuentoPercent;
|
||||
$presupuesto->total_factor = round($factor, 2);
|
||||
$presupuesto->total_factor_ponderado = round($factorPonderado, 2);
|
||||
$model->update($id, $presupuesto);
|
||||
}
|
||||
return [
|
||||
"success" => true,
|
||||
"warning" => $warning,
|
||||
"new_total" => $precio_total_asignado,
|
||||
"new_precio_unidad" => $precio_unidad_asignado,
|
||||
];
|
||||
}
|
||||
|
||||
public static 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);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<div class="col-md-6 mb-2">
|
||||
<p class="mb-0">Clicks</p>
|
||||
<h4 class="mb-0" id="clicks-info"><?= $ot_tarea->click_tarea ?></h4>
|
||||
<h4 class="mb-0" id="clicks-info"><?= $ot_tarea->click_end - $ot_tarea->click_init ?></h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
<div class="card h-100">
|
||||
<div class="card-body">
|
||||
<div class="row h-100">
|
||||
<div class="col-9">
|
||||
<div class="d-flex flex-column justify-content-evenly gap-2 h-100">
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12">
|
||||
<h4 class="alert-heading d-flex align-items-center gap-1">
|
||||
<span id="ot-id-header" style="color:red"></span>
|
||||
<span id="presupuesto-id" class="fs-bold"></span>
|
||||
<span id="ot-title" class="fs-bold"></span></h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p class="mb-0">Tiempo estimado</p>
|
||||
<h4 class="mb-0" id="tiempo-estimado-info">00:00:00</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p class="mb-0">Tiempo real</p>
|
||||
<h4 class="mb-0" id="tiempo-real-info">00:00:00</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 form-group form-group-lg">
|
||||
<label for="input-click-init" class="form-label"><?= lang('Produccion.click_init') ?></label>
|
||||
<input class="form-control input-lg ot-tarea-click" min="0" name="click_init" id="input-click-init" placeholder="<?= lang('Produccion.click_init') ?>" value="0">
|
||||
</div>
|
||||
<div class="col-md-12 form-group form-group-lg">
|
||||
<label for="input-click-init" class="form-label input-lg"><?= lang('Produccion.click_end') ?></label>
|
||||
<input class="form-control ot-tarea-click" min="0" name="click_end" id="input-click-end" placeholder="<?= lang('Produccion.click_end') ?>" value="0">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-3 h-100">
|
||||
<div class="d-flex flex-column justify-content-evenly gap-2 h-100">
|
||||
<button type="button" id="btn-cancel-tarea" class="maquina-btn btn btn-danger w-100 d-flex justify-content-evenly"><span class="ti ti-square-x ti-lg"></span><?= lang('Produccion.maquinista.cancel') ?></button>
|
||||
<button type="button" id="btn-finish-tarea" class="maquina-btn btn btn-primary w-100 d-flex justify-content-evenly action-btn"><span class="ti ti-player-eject ti-lg"></span><?= lang('Produccion.maquinista.play_end') ?></button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,55 @@
|
||||
<div class="card h-100">
|
||||
<div class="card-body">
|
||||
<div class="row h-100">
|
||||
<div class="col-6">
|
||||
<div class="d-flex flex-column justify-content-evenly gap-2 h-100">
|
||||
|
||||
<div class="row mb-2">
|
||||
|
||||
<div class="col-md-6 mb-2">
|
||||
<p class="mb-0">Tirada</p>
|
||||
<h5 class="mb-0" id="tirada-info"></h5>
|
||||
</div>
|
||||
<div class="col-md-6 mb-2 <?= $maquinaEntity->tipo != "impresion" ? "d-none" : "" ?>" >
|
||||
<p class="mb-0">Clicks</p>
|
||||
<h5 class="mb-0" id="clicks-info"></h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<p class="mb-0 text-truncate">Tiempo estimado</p>
|
||||
<h5 class="mb-0" id="tiempo-estimado-info"></h5>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p class="mb-0 text-truncate">Tiempo real</p>
|
||||
<h5 class="mb-0" id="tiempo-real-info"></h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" <?= $maquinaEntity->tipo != "impresion" ? "disabled" : "" ?>>
|
||||
<div class="col-md-12 form-group form-group-lg">
|
||||
<label for="input-click-init" class="form-label"><?= lang('Produccion.click_init') ?></label>
|
||||
<input class="form-control input-lg ot-tarea-click" min="0" name="click_init" id="input-click-init" placeholder="<?= lang('Produccion.click_init') ?>" value="0">
|
||||
</div>
|
||||
<div class="col-md-12 form-group form-group-lg">
|
||||
<label for="input-click-init" class="form-label input-lg"><?= lang('Produccion.click_end') ?></label>
|
||||
<input class="form-control ot-tarea-click" min="0" name="click_end" id="input-click-end" placeholder="<?= lang('Produccion.click_end') ?>" value="0">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-6 h-100">
|
||||
<div class="d-flex flex-column justify-content-evenly gap-2 h-100">
|
||||
<button type="button" data-estado="I" id="btn-start-tarea" class="maquina-btn btn btn-success w-100 d-flex justify-content-evenly action-btn"><span class="ti ti-player-play ti-lg"></span><?= lang('Produccion.maquinista.play_tarea') ?></button>
|
||||
<button type="button" data-estado="S" id="btn-pause-tarea" class="maquina-btn btn btn-info w-100 d-flex justify-content-evenly d-none action-btn"><span class="ti ti-player-pause ti-lg"></span><?= lang('Produccion.maquinista.play_pause') ?></button>
|
||||
<button type="button" data-estado="D" id="btn-stop-tarea" class="maquina-btn btn btn-warning w-100 d-flex justify-content-evenly"><span class="ti ti-player-stop ti-lg"></span><?= lang('Produccion.maquinista.play_stop') ?></button>
|
||||
<button type="button" data-estado="F" id="btn-finish-tarea" class="maquina-btn btn btn-primary w-100 d-flex justify-content-evenly action-btn d-none"><span class="ti ti-player-eject ti-lg"></span><?= lang('Produccion.maquinista.play_end') ?></button>
|
||||
<button type="button" id="btn-delete-tarea" class="maquina-btn btn btn-danger w-100 d-flex justify-content-evenly"><span class="ti ti-square-x ti-lg"></span><?= lang('Produccion.maquinista.cancel') ?></button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -1,14 +1,11 @@
|
||||
<div class="table-maquinista table-responsive">
|
||||
|
||||
<table id="maquinista-tarea-table" class="table table-hover text-dark" style="width: 100%;">
|
||||
<table id="<?= $id ?>" class="table table-hover text-dark" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('ID') ?></th>
|
||||
<th><?= lang('OT ID') ?></th>
|
||||
<th><?= lang('Produccion.task.task') ?></th>
|
||||
<th><?= lang('Produccion.task.estado') ?></th>
|
||||
<th><?= lang('Produccion.datatable.titulo') ?></th>
|
||||
<th><?= lang('Produccion.datatable.papel') ?></th>
|
||||
<th><?= lang('Produccion.datatable.gramaje') ?></th>
|
||||
<th><?= lang('Produccion.datatable.fecha_impresion') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
<div class="table-responsive">
|
||||
|
||||
<table id="<?= $id ?>" class="table table-hover">
|
||||
<table id="<?= $id ?>" class="table table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Produccion.task.order') ?></th>
|
||||
<th><?= lang('Produccion.task.task') ?></th>
|
||||
<th><?= lang('Produccion.task.estado') ?></th>
|
||||
<th><?= lang('Produccion.task.maquina_presupuesto') ?></th>
|
||||
<th><?= lang('Produccion.task.maquina_actual') ?></th>
|
||||
<th><?= lang('Produccion.task.imposicion') ?></th>
|
||||
<th><?= lang('Produccion.task.proveedor') ?></th>
|
||||
<th><?= lang('Produccion.task.tiempo_estimado') ?></th>
|
||||
<th><?= lang('Produccion.task.tiempo') ?></th>
|
||||
<th></th>
|
||||
|
||||
@ -521,6 +521,28 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-check">
|
||||
<label for="removeEnvioBase" class="form-check-label">
|
||||
<input type="checkbox" id="removeEnvioBase"
|
||||
name="no_envio_base" value="1"
|
||||
class="form-check-input"<?= $clienteEntity->no_envio_base == true ? 'checked' : ''; ?>>
|
||||
<?= lang('Clientes.removeEnvioBase') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-check">
|
||||
<label for="rotativaPOD" class="form-check-label">
|
||||
<input type="checkbox" id="rotativaPOD"
|
||||
name="forzar_rotativa_pod" value="1"
|
||||
class="form-check-input"<?= $clienteEntity->forzar_rotativa_pod == true ? 'checked' : ''; ?>>
|
||||
<?= lang('Clientes.forzarRotativaPod') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-3 mb-3">
|
||||
<div class="col-md-3">
|
||||
<div class="form-check">
|
||||
<label for="tiradaFlexible" class="form-check-label">
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="container-fluid h-100">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= lang('Festivos.moduleTitle') ?></h3>
|
||||
</div>
|
||||
<!--//.card-header -->
|
||||
<div class="card-body m-10 section-block" id="festivoCard">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
<div id="calendar"></div>
|
||||
<!--//.card-footer -->
|
||||
</div>
|
||||
<!--//.card -->
|
||||
</div>
|
||||
<!--//.col -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!--//.row -->
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/formvalidation/dist/css/formValidation.min.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/notiflix/notiflix.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
|
||||
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/notiflix/notiflix.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/fullcalendar/dist/index.global.min.js') ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/fullcalendar/packages/core/locales-all.global.min.js') ?>"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="module" src="<?= site_url("/assets/js/safekat/pages/configuracion/festivo/index.js") ?>"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
0
ci4/app/Views/themes/vuexy/form/importador/.delete
Normal file
0
ci4/app/Views/themes/vuexy/form/importador/.delete
Normal file
@ -0,0 +1,103 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= lang('Importador.importadorBubokTitle') ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
|
||||
<form id="catalogoLibroForm" class="card-body" method="post" action="#">
|
||||
<?= csrf_field() ?>
|
||||
|
||||
<!-- card-body -->
|
||||
<div class="card-body">
|
||||
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="xmlFile"
|
||||
class="form-label"><?= lang('Importador.subirArchivoBubok') ?? 'Subir archivo XML' ?></label>
|
||||
<input type="file" id="xmlFile" accept=".xml" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3 d-flex align-items-end">
|
||||
<button type="button" id="importBtn" class="btn btn-success w-100">
|
||||
<i class="fas fa-file-import me-2"></i> <?= lang('Importador.importar') ?? 'Importar' ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 mb-3">
|
||||
|
||||
<table id="xmlTable" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" id="selectAll" /></th>
|
||||
<th>Referencia</th>
|
||||
<th>Título</th>
|
||||
<th>Tamaño</th>
|
||||
<th>Páginas</th>
|
||||
<th>Tirada</th>
|
||||
<th>Interior</th>
|
||||
<th>Notas</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th> <!-- No filtro para checkbox -->
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th> <!-- No filtro para notas -->
|
||||
<th></th> <!-- No filtro para acciones -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet"
|
||||
href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
<script
|
||||
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
|
||||
<script
|
||||
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>"
|
||||
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/importadores/bubok/bubok_tool.js") ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,106 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= lang('Importador.importadorCatalogoTitle') ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
|
||||
<form id="catalogoLibroForm" class="card-body" method="post" action="#">
|
||||
<?= csrf_field() ?>
|
||||
|
||||
<!-- card-body -->
|
||||
<div class="card-body">
|
||||
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="excelFile"
|
||||
class="form-label"><?= lang('Importador.subirArchivoRama') ?? 'Subir archivo Excel' ?></label>
|
||||
<input type="file" class="form-control" id="excelFile" name="excelFile"
|
||||
accept=".xlsx, .xls">
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 mb-3 d-flex align-items-end">
|
||||
<button type="button" id="importBtn" class="btn btn-success w-100">
|
||||
<i class="fas fa-file-import me-2"></i> <?= lang('Importador.importar') ?? 'Importar' ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 mb-3">
|
||||
|
||||
<table id="excelTable" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" id="selectAll"></th> <!-- Checkbox general -->
|
||||
<th><?= lang('Importador.input') ?></th>
|
||||
<th><?= lang('Importador.idlinea') ?></th>
|
||||
<th><?= lang('Importador.descripcion') ?></th>
|
||||
<th><?= lang('Importador.cnt_pedida') ?></th>
|
||||
<th><?= lang('Importador.precio_compra') ?></th>
|
||||
<th>Notas</th> <!-- Comentarios -->
|
||||
<th><?= lang('Basic.global.Action') ?></th>
|
||||
<!-- Acciones (importar/eliminar) -->
|
||||
</tr>
|
||||
<tr> <!-- Segunda fila para filtros -->
|
||||
<th></th> <!-- No filtro en checkbox -->
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th> <!-- No filtro en notas -->
|
||||
<th></th> <!-- No filtro en acciones -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div><!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div><!--//.card-footer -->
|
||||
</div><!--//.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet"
|
||||
href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
<script
|
||||
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
|
||||
<script
|
||||
src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>"
|
||||
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
<script src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js"></script>
|
||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/importadores/catalogo/catalogo_tool.js") ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,35 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4><?= $boxTitle ?></h4>
|
||||
</div>
|
||||
<div id="albaranContainer" class="card-body">
|
||||
|
||||
<input type="hidden" id="id" value="<?= $albaranId ?>">
|
||||
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/albaranes/edit.js") ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user