From 793f378f98286186aff03cc0998d22a67d4d38e1 Mon Sep 17 00:00:00 2001 From: Jaime Jimenez Date: Thu, 27 Mar 2025 12:23:49 +0100 Subject: [PATCH 1/4] cambiado controlador test para evitar errores en el merge --- ci4/app/Controllers/Test.php | 51 +++++------------------------------- 1 file changed, 7 insertions(+), 44 deletions(-) diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index b96eb56c..dfb723d3 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -29,53 +29,16 @@ class Test extends BaseController } - public function index() + private function index() { - $modelCliente = model('App\Models\Clientes\ClienteModel'); - var_dump($modelCliente->getPendienteCobro(1284)); - } - - private function sendMail($subject, $body, $recipient) - { - $settings_model = new SettingsModel(); - $config = $settings_model->first()->toArray(); - $gateway = $config['email_gateway']; - $body = html_entity_decode($body); - - if ($gateway == 'smtp') { - try { - //https://codeigniter.com/user_guide/libraries/email.html - $email = \Config\Services::email(); - $config['protocol'] = $config['email_gateway']; - $config['SMTPHost'] = $config['email_smtp']; - $config['SMTPUser'] = $config['email_address']; - $config['SMTPPass'] = $config['email_pass']; - $config['SMTPPort'] = intval($config['email_port']); - $config['SMTPCrypto'] = $config['email_cert'] == 'none' ? '' : $config['email_cert']; - $config['SMTPTimeout'] = 15; - $config['mailType'] = 'html'; - $config['wordWrap'] = true; - - $email->initialize($config); - - $email->setFrom($config['email_address'], $config['email_name']); - $email->setTo($recipient); - - $email->setSubject($subject); - $email->setMessage($body); - - if (!$email->send()) { - return false; - } else { - return true; - } - } catch (\Exception $ex) { - return false; - } - } - return false; + $this->emailService = service('emailService'); + + $a= $this->emailService->send('prueba', 'Esto es una prueba', ['imnavajas@coit.es','imnavajas@gmail.com']); + + echo var_dump($a); } + private function clonar_tarifa_encuadernacion($teOrigen, $teDestino){ $tet_model = model('App\Models\Tarifas\TarifaEncuadernacionTiradaModel'); From e3c494e68d48e16899bdd063fab988631a888b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 27 Mar 2025 17:38:42 +0100 Subject: [PATCH 2/4] =?UTF-8?q?modificado=20select=20de=20a=C3=B1adir=20pe?= =?UTF-8?q?didos=20en=20facturas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Models/Pedidos/PedidoLineaModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci4/app/Models/Pedidos/PedidoLineaModel.php b/ci4/app/Models/Pedidos/PedidoLineaModel.php index 19eef0d0..0072f4b8 100644 --- a/ci4/app/Models/Pedidos/PedidoLineaModel.php +++ b/ci4/app/Models/Pedidos/PedidoLineaModel.php @@ -208,7 +208,7 @@ class PedidoLineaModel extends \App\Models\BaseModel ->join("tipos_presupuestos t4", "t4.id = t3.tipo_impresion_id", "left") ->join("($subquery) fpl", "fpl.pedido_linea_id = t1.id", "left") ->where("t3.cliente_id", $cliente_id) - ->where("t2.estado", "finalizado") + ->whereIn("t2.estado", ["produccion", "enviado","finalizado"]) ->where("(t3.tirada > IFNULL(fpl.total_cantidad, 0))"); // Ejecutar la consulta y devolver resultados From 33ce64df0f0cf870b8287a041dc3b6c977f948b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Fri, 28 Mar 2025 00:52:49 +0100 Subject: [PATCH 3/4] terminada revision de pedidos --- ci4/app/Config/RBAC/permissionMatrix.php | 2 + ci4/app/Config/RBAC/permissions.php | 2 + ci4/app/Config/Routes.php | 4 +- ci4/app/Controllers/Pedidos/Pedido.php | 49 +- .../Presupuestos/Presupuestoadmin.php | 11 + .../Controllers/Produccion/Ordentrabajo.php | 4 +- ci4/app/Language/es/App.php | 3 +- ci4/app/Language/es/RolesPermisos.php | 3 +- .../Models/OrdenTrabajo/OrdenTrabajoDate.php | 4 +- ci4/app/Models/Pedidos/PedidoLineaModel.php | 39 +- .../Presupuestos/PresupuestoAcabadosModel.php | 2 +- .../Maquinas/TarifaExtraMaquinaModel.php | 2 +- ci4/app/Services/ChatService.php | 4 +- ci4/app/Services/PresupuestoService.php | 31 +- .../vuexy/form/pedidos/viewPedidoForm.php | 15 +- .../vuexy/form/pedidos/viewPedidosList.php | 119 +- .../admin/viewPresupuestoadminForm.php | 24 +- .../viewTarifaEncuadernacionForm.php | 1437 +++++++++-------- .../themes/vuexy/main/menus/pedidos_menu.php | 7 + .../presupuestoAdmin/presupuestoAdminEdit.js | 4 +- 20 files changed, 960 insertions(+), 806 deletions(-) diff --git a/ci4/app/Config/RBAC/permissionMatrix.php b/ci4/app/Config/RBAC/permissionMatrix.php index e0b0fec1..db81f0ce 100644 --- a/ci4/app/Config/RBAC/permissionMatrix.php +++ b/ci4/app/Config/RBAC/permissionMatrix.php @@ -21,6 +21,8 @@ const SK_PERMISSION_MATRIX = [ "presupuesto-cliente.edit", "presupuesto-cliente.delete", "presupuesto-cliente.menu", + "pedidos-validacion.view", + "pedidos-validacion.menu", "pedidos-activos.view", "pedidos-activos.menu", "pedidos-finalizados.view", diff --git a/ci4/app/Config/RBAC/permissions.php b/ci4/app/Config/RBAC/permissions.php index b38701ba..fe9506f3 100644 --- a/ci4/app/Config/RBAC/permissions.php +++ b/ci4/app/Config/RBAC/permissions.php @@ -21,6 +21,8 @@ const SK_PERMISSIONS = [ 'presupuesto-cliente.edit' => 'Can edit', 'presupuesto-cliente.delete' => 'Can delete', 'presupuesto-cliente.menu' => 'Menu shall be visualize', + 'pedidos-validacion.view' => 'Can view', + 'pedidos-validacion.menu' => 'Menu shall be visualize', 'pedidos-activos.view' => 'Can view', 'pedidos-activos.menu' => 'Menu shall be visualize', 'pedidos-finalizados.view' => 'Can view', diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index a894926d..e53d3c53 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -743,8 +743,8 @@ $routes->group('presupuestotiradasalternativas', ['namespace' => 'App\Controller }); $routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function ($routes) { - $routes->get('list', 'Pedido::todos', ['as' => 'listaPresupuestos']); - $routes->get('listActivos', 'Pedido::activos', ['as' => 'listaPresupuestosActivos']); + $routes->get('list', 'Pedido::todos', ['as' => 'listaPedidos']); + $routes->get('listActivos', 'Pedido::activos', ['as' => 'listaPedidosActivos']); $routes->get('listFinalizados', 'Pedido::finalizados', ['as' => 'listaFinalizados']); $routes->get('listCancelados', 'Pedido::cancelados', ['as' => 'listaCancelados']); $routes->post('datatable', 'Pedido::datatable', ['as' => 'dataTableOfPedidos']); diff --git a/ci4/app/Controllers/Pedidos/Pedido.php b/ci4/app/Controllers/Pedidos/Pedido.php index 0cefa80a..e17c26ef 100755 --- a/ci4/app/Controllers/Pedidos/Pedido.php +++ b/ci4/app/Controllers/Pedidos/Pedido.php @@ -68,7 +68,7 @@ class Pedido extends \App\Controllers\BaseResourceController 'pedidoEntity' => new PedidoEntity(), 'usingServerSideDataTable' => true, 'pageTitle' => lang('Pedidos.Pedidos'), - 'estadoPedidos' => 'activo', + 'estadoPedidos' => 'produccion', ['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true] ]; @@ -112,6 +112,32 @@ class Pedido extends \App\Controllers\BaseResourceController return view(static::$viewPath . 'viewPedidosList', $viewData); } + public function validacion() + { + $viewData = [ + 'currentModule' => static::$controllerSlug, + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]), + 'pedidoEntity' => new PedidoEntity(), + 'usingServerSideDataTable' => true, + 'pageTitle' => lang('Pedidos.Pedidos'), + 'estadoPedidos' => 'validacion', + ['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true] + ]; + + if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) { + // Se obtiene el cliente ID a partir del usuario de la sesion + $model_user = model('App\Models\Usuarios\UserModel'); + $user = $model_user->find(auth()->user()->id); + $clienteId = $user->cliente_id; + } else { + $clienteId = -1; + } + + $viewData['cliente_id'] = $clienteId; + + return view(static::$viewPath . 'viewPedidosList', $viewData); + } + public function cancelados() { $viewData = [ @@ -283,6 +309,12 @@ class Pedido extends \App\Controllers\BaseResourceController $pendiente = $pendiente[0] + $pendiente[1]; $this->viewData['importePendiente'] = $pendiente; } + + $modelOrden = new \App\Models\OrdenTrabajo\OrdenTrabajoModel(); + $orden = $modelOrden->where('pedido_id', $pedidoEntity->id)->first(); + if($orden){ + $this->viewData['orden_id'] = $orden->id; + } $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3'); @@ -317,23 +349,22 @@ class Pedido extends \App\Controllers\BaseResourceController $resourceData = $model_linea->getResource($searchValues, $estado, $cliente_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); $totalTirada = $model_linea->getSumOfTirada($searchValues, $estado, $cliente_id, $start, $length); $total = $model_linea->getSumOfTotalAceptado($searchValues, $estado, $cliente_id, $start, $length); + $extra_data['total_tirada'] = $totalTirada; + $extra_data['total'] = $total; $total2 = 0; if($showTotal){ - $total2 = $model_linea->getTotalOfTotalAceptado(); + $total2 = $model_linea->getTotalOfTotalAceptado($estado); + $tirada2 = $model_linea->getTotalTirada($estado); + $extra_data['total2'] = $total2; + $extra_data['total_tirada2'] = $tirada2; } - if($total2 != 0){ - $total = "" . $total . " \n(" . $total2 . ")"; - } return $this->respond(Collection::datatable( $resourceData, $model_linea->getResource("", $estado)->countAllResults(), $model_linea->getResource($searchValues, $estado)->countAllResults(), "", - [ - 'total_tirada' => $totalTirada, - 'total' => $total - ] + $extra_data )); } else { return $this->failUnauthorized('Invalid request', 403); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php index 86986a9e..1814caca 100644 --- a/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestoadmin.php @@ -401,6 +401,17 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController $this->viewData['cliente_id'] = $presupuestoEntity->cliente_id; + $modelPedidoLinea = new \App\Models\Pedidos\PedidoLineaModel(); + $linea = $modelPedidoLinea->where('presupuesto_id', $id)->first(); + if($linea){ + $this->viewData['pedido_id'] = $linea->pedido_id; + $modelOrden = new \App\Models\OrdenTrabajo\OrdenTrabajoModel(); + $orden = $modelOrden->where('pedido_id', $linea->pedido_id)->first(); + if($orden){ + $this->viewData['orden_id'] = $orden->id; + } + } + // Si se ha llamado a esta funcion porque se ha duplicado el presupuesto // se actualiza la bbdd para que sólo ejecute algunas funciones una vez if ($presupuestoEntity->is_duplicado) { diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 6834ecf0..bafb454b 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -153,7 +153,7 @@ class Ordentrabajo extends BaseController ->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo))) ->edit( "fecha_encuadernado_at", - fn($q) => Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") + fn($q) => $q->fecha_encuadernado_at? Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y"):"" ) ->add("action", fn($q) => $q->id) ->toJson(true); @@ -168,7 +168,7 @@ class Ordentrabajo extends BaseController ->add("logo", fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo))) ->edit( "fecha_encuadernado_at", - fn($q) => Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y") + fn($q) => $q->fecha_encuadernado_at?Time::createFromFormat("Y-m-d", $q->fecha_encuadernado_at)->format("d/m/Y"):"" ) ->add("action", fn($q) => $q->id) ->toJson(true); diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index db627a10..13ea3d6d 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -749,7 +749,8 @@ return [ "menu_informes" => "Informes", "menu_pedidos" => "Pedidos", - "menu_pedidos_activos" => "Activos", + "menu_pedidos_validacion" => "Validación", + "menu_pedidos_activos" => "Producción", "menu_pedidos_finalizados" => "Finalizados", "menu_pedidos_cancelados" => "Cancelados", "menu_pedidos_todos" => "Todos", diff --git a/ci4/app/Language/es/RolesPermisos.php b/ci4/app/Language/es/RolesPermisos.php index 9964d943..859e8c50 100644 --- a/ci4/app/Language/es/RolesPermisos.php +++ b/ci4/app/Language/es/RolesPermisos.php @@ -33,7 +33,8 @@ return [ 'direccionesSection' => 'Direcciones', 'presupuestoSection' => 'Presupuestos', 'presupuestoClienteSection' => 'Presupuestos de Cliente', - 'pedidosActivosSection' => 'Activos', + 'pedidosValidacionSection' => 'Validación', + 'pedidosActivosSection' => 'Producción', 'pedidosFinalizadosSection' => 'Finalizados', 'pedidosCanceladosSection' => 'Cancelados', 'pedidosTodosSection' => 'Todos', diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php index bd7ff3a0..e0f92923 100644 --- a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoDate.php @@ -61,9 +61,9 @@ class OrdenTrabajoDate extends Model // Callbacks protected $allowCallbacks = true; protected $beforeInsert = []; - protected $afterInsert = ["updateOrdenTrabajoUser"]; + protected $afterInsert = []; protected $beforeUpdate = []; - protected $afterUpdate = ["updateOrdenTrabajoUser"]; + protected $afterUpdate = []; protected $beforeFind = []; protected $afterFind = []; protected $beforeDelete = []; diff --git a/ci4/app/Models/Pedidos/PedidoLineaModel.php b/ci4/app/Models/Pedidos/PedidoLineaModel.php index 0072f4b8..ca0e9b56 100644 --- a/ci4/app/Models/Pedidos/PedidoLineaModel.php +++ b/ci4/app/Models/Pedidos/PedidoLineaModel.php @@ -75,7 +75,7 @@ class PedidoLineaModel extends \App\Models\BaseModel } } - if($cliente_id != -1) { + if($cliente_id != -1 && $cliente_id != "-1") { $builder->where("t3.cliente_id", $cliente_id); } @@ -106,9 +106,11 @@ class PedidoLineaModel extends \App\Models\BaseModel $builder->join("pedidos t2", "t2.id = t1.pedido_id", "left"); $builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left"); - + $builder->join("clientes t4", "t4.id = t3.cliente_id", "left"); + $builder->join("users t5", "t5.id = t4.comercial_id", "left"); + $builder->join("ubicaciones t6", "t6.id = t1.ubicacion_id", "left"); - if($cliente_id != -1) { + if($cliente_id != -1 && $cliente_id != "-1") { $builder->where("t3.cliente_id", $cliente_id); } @@ -128,7 +130,7 @@ class PedidoLineaModel extends \App\Models\BaseModel } if ($estado !== '') { - $builder->where('estado', $estado); + $builder->where('t2.estado', $estado); } // Aplicar el orden y el límite @@ -146,8 +148,11 @@ class PedidoLineaModel extends \App\Models\BaseModel $builder->join("pedidos t2", "t2.id = t1.pedido_id", "left"); $builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left"); + $builder->join("clientes t4", "t4.id = t3.cliente_id", "left"); + $builder->join("users t5", "t5.id = t4.comercial_id", "left"); + $builder->join("ubicaciones t6", "t6.id = t1.ubicacion_id", "left"); - if($cliente_id != -1) { + if($cliente_id != -1 && $cliente_id != "-1") { $builder->where("t3.cliente_id", $cliente_id); } @@ -167,7 +172,7 @@ class PedidoLineaModel extends \App\Models\BaseModel } if ($estado !== '') { - $builder->where('estado', $estado); + $builder->where('t2.estado', $estado); } // Aplicar el orden y el límite @@ -177,7 +182,7 @@ class PedidoLineaModel extends \App\Models\BaseModel return $builder->get()->getRow()->total; } - public function getTotalOfTotalAceptado() + public function getTotalOfTotalAceptado($estado = "") { $builder = $this->db @@ -187,10 +192,30 @@ class PedidoLineaModel extends \App\Models\BaseModel $builder->join("pedidos t2", "t2.id = t1.pedido_id", "left"); $builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left"); + if ($estado !== '') { + $builder->where('t2.estado', $estado); + } return $builder->get()->getRow()->total; } + public function getTotalTirada($estado = "") + { + + $builder = $this->db + ->table($this->table . " t1") + ->selectSum('t3.tirada', 'total_tirada'); + + $builder->join("pedidos t2", "t2.id = t1.pedido_id", "left"); + $builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left"); + + if ($estado !== '') { + $builder->where('t2.estado', $estado); + } + + return $builder->get()->getRow()->total_tirada; + } + public function obtenerLineasPedidoSinFacturar($cliente_id) { $resultaArray = []; diff --git a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php index 2d134ae4..562c40fc 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoAcabadosModel.php @@ -193,7 +193,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel ->table($this->table . " t1") ->set('presupuesto_id', $presupuesto_id) ->set('tarifa_acabado_id', $tarifa->tarifa_id) - ->set('proveedor_id', $proveedor, false) + ->set('proveedor_id', $proveedor) ->set('precio_unidad', $tarifa->precio_unidad) ->set('precio_total', $tarifa->precio_total) ->set('margen', $tarifa->margen) diff --git a/ci4/app/Models/Tarifas/Maquinas/TarifaExtraMaquinaModel.php b/ci4/app/Models/Tarifas/Maquinas/TarifaExtraMaquinaModel.php index 1ee4be1e..8cb8d36d 100644 --- a/ci4/app/Models/Tarifas/Maquinas/TarifaExtraMaquinaModel.php +++ b/ci4/app/Models/Tarifas/Maquinas/TarifaExtraMaquinaModel.php @@ -9,7 +9,7 @@ use CodeIgniter\Model; class TarifaExtraMaquinaModel extends Model { - protected $table = 'tarifa_acabado_maquinas'; + protected $table = 'tarifa_extra_maquinas'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; protected $returnType = TarifaExtraMaquinaEntity::class; diff --git a/ci4/app/Services/ChatService.php b/ci4/app/Services/ChatService.php index 97d88a65..c619167b 100644 --- a/ci4/app/Services/ChatService.php +++ b/ci4/app/Services/ChatService.php @@ -17,12 +17,12 @@ use App\Models\Configuracion\ConfigVariableModel; use App\Models\Presupuestos\PresupuestoModel; use App\Models\Usuarios\UserModel; use CodeIgniter\Config\BaseService; -use CodeIgniter\Email\Email; +use App\Services\EmailService; class ChatService extends BaseService { protected ?ChatEntity $chatEntity; - protected Email $emailService; + protected EmailService $emailService; protected UserModel $userModel; protected ChatModel $chatModel; protected ChatMessageModel $chatMessageModel; diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index 1cf7524c..894259a1 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -253,7 +253,8 @@ 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; @@ -614,9 +615,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 ); @@ -890,17 +891,16 @@ class PresupuestoService extends BaseService if ($lomoRedondo) { $ancho_total += 6; } - } - else if ($uso == 'faja' || $uso == 'sobrecubierta') { + } else if ($uso == 'faja' || $uso == 'sobrecubierta') { if ($datosPedido->solapas) { // 7 es el vuelo de la tapa dura sobre el interior - $ancho_total += (floatval($datosPedido->solapas_ancho) * 2) + (2 * self::SANGRE_FORMAS) + 2*7; + $ancho_total += (floatval($datosPedido->solapas_ancho) * 2) + (2 * self::SANGRE_FORMAS) + 2 * 7; } } // si es sobrecubierta // Se añaden 5mm de sangre por cada lado + 2 * 7mm de vuelo portada y contraportada -> total 52 - else{ + else { $ancho_total += (2 * 7 + 2 * self::SANGRE_FORMAS); } } @@ -963,7 +963,7 @@ class PresupuestoService extends BaseService // Se añaden 5mm de sangre por cada lado else if ($uso == 'sobrecubierta') $alto_total += (7 + 2 * self::SANGRE_FORMAS); - else if ($uso == 'faja') + else if ($uso == 'faja') $alto_total += (2 * self::SANGRE_FORMAS); } // Tapa dura (espiral y wire-0) @@ -1897,8 +1897,17 @@ class PresupuestoService extends BaseService } if ($id_linea != 0 && $pedido_id != 0) { - if($data_pedido['estado'] == "produccion"){ - $response = (new Pedido())->to_produccion($pedido_id); + if ($data_pedido['estado'] == "produccion") { + + $serviceProduction = service('production'); + $modelPedido = model('App\Models\Pedidos\PedidoModel'); + $pedido = $modelPedido->find($pedido_id); + $serviceProduction->setPedido($pedido); + if (!$pedido->orden_trabajo()) { + + $r = $serviceProduction->createOrdenTrabajo(); + $modelPedido->set(['estado' => 'produccion'])->where('id', $pedido_id)->update(); + } } return true; } diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php index be518321..5f9ea491 100644 --- a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php +++ b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php @@ -13,9 +13,20 @@
-
+
getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+
+
'" > + Orden + +
+
+
+ user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))) : ?> @@ -29,7 +40,7 @@
- "btn btn-secondary float-start"]) ?> + "btn btn-secondary float-start"]) ?>
diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php index 1bbb709e..971dc8dd 100644 --- a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php +++ b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php @@ -72,10 +72,10 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) { var title = $(this).text(); if($(this).hasClass("totalizador")){ if(i==9){ - $(this).html(''); + $(this).html('
'); } else if(i==10){ - $(this).html(''); + $(this).html('
'); } } else{ @@ -125,25 +125,31 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) { } else if (i == 11) { - // Agregar un selector en la tercera columna - $(this).html(''); - // Agregar opciones al selector - var selector = $('select', this); + if("" == "" || "" == "todos"){ - selector.append(''); // Opción vacía - selector.append(''); - selector.append(''); - selector.append(''); - selector.append(''); - selector.append(''); - - selector.on('change', function () { - var val = $.fn.dataTable.util.escapeRegex( - $(this).val() - ); - theTable.column(i).search(val).draw(); - }); + $(this).html(''); + + // Agregar opciones al selector + var selector = $('select', this); + + selector.append(''); // Opción vacía + selector.append(''); + selector.append(''); + selector.append(''); + selector.append(''); + selector.append(''); + + selector.on('change', function () { + var val = $.fn.dataTable.util.escapeRegex( + $(this).val() + ); + theTable.column(i).search(val).draw(); + }); + } + else{ + $(this).html(''); + } } else{ $(this).html(''); @@ -189,7 +195,7 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) { } ], stateSave: false, - order: [[0, 'asc']], + order: [[0, 'desc']], language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, @@ -256,38 +262,53 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) { { 'data': actionBtns } ], drawCallback: function (settings) { - $('#total_tirada').text(settings.json.extra.total_tirada); - $('#total_aceptado').text(settings.json.extra.total); - } - }); - theTable.on( 'draw.dt', function () { - const dateCols = [1,2]; - const priceCols = [10]; + var api = this.api(); + + $('#total_tirada').text(settings.json.extra.total_tirada??0); + $('#total_tirada_2').text(settings.json.extra.total_tirada2??0); + $('#total_aceptado').text(settings.json.extra.total??0); + $('#total_aceptado_2').text(settings.json.extra.total2??0); + AutoNumeric.multiple('.autonumeric', { decimalPlaces: 2 }); + AutoNumeric.multiple('.autonumeric-int', { decimalPlaces: 0 }); - for (let coln of dateCols) { - theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { - const datestr = cell.innerHTML; - const dateStrLen = datestr.toString().trim().length; - if (dateStrLen > 0) { - let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values - dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one - const d = new Date(...dateTimeParts); // new Date(datestr); - cell.innerHTML = d.toLocaleDateString(); + const dateCols = [1,2]; + const priceCols = [10]; + + for (let coln of dateCols) { + api.column(coln, { page: 'current' }).nodes().each( function (cell, i) { + const datestr = cell.innerHTML; + const dateStrLen = datestr.toString().trim().length; + if (dateStrLen > 0) { + let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values + dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one + const d = new Date(...dateTimeParts); // new Date(datestr); + cell.innerHTML = d.toLocaleDateString(); + } + }); + } + if( != -1){ + api.column(3).visible(false); + } + else{ + api.column(3).visible(true); + } + }, + "rowCallback": function(row, data, index) { + if('' == 'todos'){ + if (data['estado'] === "cancelado") { + $(row).css('background-color', '#ffcccc'); // Rojo claro + } else if (data['estado'] === "validacion") { + $(row).css('background-color', '#fff5cc'); // Amarillo claro + } else if (data['estado'] === "finalizado") { + $(row).css('background-color', '#ccffcc'); // Verde claro } - }); - } - - - if( != -1){ - // Se oculta la columna de cliente (3) - theTable.column(3).visible(false); - } - else{ - theTable.column(3).visible(true); + } } }); + + $(document).on('click', '.btn-edit', function(e) { @@ -301,6 +322,12 @@ $('#tableOfPedidos thead tr:eq(1) th').each(function (i) { }); $('#showTotal').on('change', function() { + if($('#showTotal').is(':checked')){ + $('.mostrar-totales').removeClass('d-none'); + } + else{ + $('.mostrar-totales').addClass('d-none'); + } theTable.clearPipeline(); theTable.ajax.reload(null, false); //theTable.draw(); diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php index 5a2e0ec7..26988708 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/viewPresupuestoadminForm.php @@ -30,7 +30,29 @@ - + + +
+ +
+
'" > + + +
+
+ + +
+
'" > + Orden + +
+
+ +
+ diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php index 1a9ddab1..a8c1bd81 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php @@ -292,792 +292,797 @@ id = -1; - - - - section("additionalInlineJs") ?> + + + +section("additionalInlineJs") ?> - const lastColNr3 = $('#tableOfTarifaencuadernacionlineasHoras').find("tr:first th").length - 1; +const lastColNr3 = $('#tableOfTarifaencuadernacionlineasHoras').find("tr:first th").length - 1; - var editor3 = new $.fn.dataTable.Editor( { +var editor3 = new $.fn.dataTable.Editor({ ajax: { - url: "", - headers: { - : v, - }, + url: "", + headers: { + : v, + }, }, table : "#tableOfTarifaencuadernacionlineasHoras", idSrc: 'id', - fields: [ - {name: "id", - "type": "readonly"}, - { - name: "tiempo_min", - attr: { - type: "text", - name : "tiempo_min", - class :"autonumeric" - } - }, { - name: "tiempo_max", - attr: { - type: "text", - name : "tiempo_max", - class :"autonumeric" - } - }, { - name: "precio_hora", - attr: { - type: "text", - name : "precio_hora", - class :"autonumeric" - } - }, { - name: "total_min", - attr: { - type: "text", - name : "total_min", - class :"autonumeric" - } - }, { - name: "margen", - attr: { - type: "text", - name : "margen", - class :"autonumeric" - } - }, { - "name": "tirada_encuadernacion_id", - "type": "hidden" - },{ - "name": "deleted_at", - "type": "hidden" - },{ - "name": "is_deleted", - "type": "hidden" - }, + fields: [ + { + name: "id", + "type": "readonly" + }, + { + name: "tiempo_min", + attr: { + type: "text", + name: "tiempo_min", + class: "autonumeric" + } + }, { + name: "tiempo_max", + attr: { + type: "text", + name: "tiempo_max", + class: "autonumeric" + } + }, { + name: "precio_hora", + attr: { + type: "text", + name: "precio_hora", + class: "autonumeric" + } + }, { + name: "total_min", + attr: { + type: "text", + name: "total_min", + class: "autonumeric" + } + }, { + name: "margen", + attr: { + type: "text", + name: "margen", + class: "autonumeric" + } + }, { + "name": "tirada_encuadernacion_id", + "type": "hidden" + }, { + "name": "deleted_at", + "type": "hidden" + }, { + "name": "is_deleted", + "type": "hidden" + }, ] - } ); - editor3.on('open', (event) => { - $("input.autonumeric").each(function () { - let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) - if (autoNumericInstance) { - autoNumericInstance.remove() +}); - } - new AutoNumeric(this, { - decimalCharacter: ",", - digitGroupSeparator: ".", - allowDecimalPadding : 'floats', - decimalPlaces: 2, - unformatOnSubmit: true, - }); - }) +editor3.on('open', (event) => { + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + autoNumericInstance.remove() + + } + new AutoNumeric(this, { + decimalCharacter: ",", + digitGroupSeparator: ".", + allowDecimalPadding: 'floats', + decimalPlaces: 2, + unformatOnSubmit: true, + }); }) - editor3.on('preSubmit', (e, d, type) => { - if (d.data) { - Object.keys(d.data).forEach(function (key) { - // Find all elements with class .autonumeric - $("input.autonumeric").each(function () { - let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) - if (autoNumericInstance) { - // Get raw value and update the corresponding field - let rawValue = autoNumericInstance.getNumericString(); - d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used - } - }); - }); - } - }) - editor3.on( 'preSubmit', function ( e, d, type ) { - if ( type === 'create'){ - d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id; +}) + +editor3.on('preSubmit', (e, d, type) => { + if (d.data) { + Object.keys(d.data).forEach(function (key) { + // Find all elements with class .autonumeric + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + // Get raw value and update the corresponding field + let rawValue = autoNumericInstance.getNumericString(); + d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used + } + }); + }); } - else if(type === 'edit' ) { - for (v in d.data){ - d.data[v]['tirada_encuadernacion_id'] = selected_tirada_id; +}) + +editor3.on('preSubmit', function (e, d, type) { + if (type === 'create') { + d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id; } + else if (type === 'edit') { + for (v in d.data) { + d.data[v]['tirada_encuadernacion_id'] = selected_tirada_id; + } } - }); +}); - editor3.on( 'postSubmit', function ( e, json, data, action ) { +editor3.on('postSubmit', function (e, json, data, action) { yeniden(json.); - }); +}); - editor3.on( 'submitSuccess', function ( e, json, data, action ) { +editor3.on('submitSuccess', function (e, json, data, action) { theTable3.clearPipeline(); theTable3.draw(); - }); +}); - var theTable3 = $('#tableOfTarifaencuadernacionlineasHoras').DataTable( { - draw:3, +var theTable3 = $('#tableOfTarifaencuadernacionlineasHoras').DataTable({ + draw: 3, serverSide: true, processing: true, autoWidth: true, responsive: true, - lengthMenu: [ 5, 10, 25], - order: [[ 0, "asc" ], [ 1, "asc" ]], + lengthMenu: [5, 10, 25], + order: [[0, "asc"], [1, "asc"]], pageLength: 10, lengthChange: true, searching: false, paging: true, info: false, dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', - ajax : $.fn.dataTable.pipeline( { - url: '', - data: function ( d ) { - d.tirada_id = selected_tirada_id; - }, - method: 'POST', - headers: {'X-Requested-With': 'XMLHttpRequest'}, - async: true, - }), - columns: [ - { 'data': 'id' }, - { 'data': 'tiempo_min',render : (d) => `${d}` }, - { 'data': 'tiempo_max',render : (d) => `${d}` }, - { 'data': 'precio_hora',render : (d) => `${d}` }, - { 'data': 'total_min',render : (d) => `${d}` }, - { 'data': 'margen',render : (d) => `${d}` }, - { - data: actionBtns, - className: 'row-edit dt-center' - } - ], - columnDefs: [ - { - orderable: false, - searchable: false, - targets: [lastColNr3] - }, - {"orderData": [ 0, 1 ], "targets": 0 }, + ajax: $.fn.dataTable.pipeline({ + url: '', + data: function (d) { + d.tirada_id = selected_tirada_id; + }, + method: 'POST', + headers: { 'X-Requested-With': 'XMLHttpRequest' }, + async: true, + }), + columns: [ + { 'data': 'id' }, + { 'data': 'tiempo_min', render: (d) => `${d}` }, + { 'data': 'tiempo_max', render: (d) => `${d}` }, + { 'data': 'precio_hora', render: (d) => `${d}` }, + { 'data': 'total_min', render: (d) => `${d}` }, + { 'data': 'margen', render: (d) => `${d}` }, + { + data: actionBtns, + className: 'row-edit dt-center' + } + ], + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr3] + }, + { "orderData": [0, 1], "targets": 0 }, - ], - language: { - url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" - }, - buttons: [ - { - extend: 'collection', - text: 'Exportar', - buttons:[ - 'copy', 'csv', 'excel', 'print', { - extend: 'pdfHtml5', - orientation: 'landscape', - pageSize: 'A4' - } - ] - }, - { - className: 'btn btn-primary float-end me-sm-3 me-1', - extend: "createInline", - editor: editor3, - formOptions: { + ], + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + buttons: [ + { + extend: 'collection', + text: 'Exportar', + buttons: [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ] + }, + { + className: 'btn btn-primary float-end me-sm-3 me-1', + extend: "createInline", + editor: editor3, + formOptions: { + submitTrigger: -1, + submitHtml: '' + + }, + action: function (e, dt, node, config) { + if (selected_tirada_id == -1) { + popErrorAlert(""); + } + else { + formOptions = { submitTrigger: -1, submitHtml: '' - }, - action: function ( e, dt, node, config ) { - if(selected_tirada_id == -1){ - popErrorAlert(""); - } - else{ - formOptions= { + }; + editor3.inlineCreate(config.position, formOptions); + } + }, + } + ] +}); + + +// Activate an inline edit on click of a table cell +$('#tableOfTarifaencuadernacionlineasHoras').on('click', 'tbody span.edit', function (e) { + editor3.inline( + theTable3.cells(this.parentNode.parentNode, '*').nodes(), + { + cancelHtml: '', + cancelTrigger: 'span.cancel', + submitHtml: '', + submitTrigger: 'span.edit', + submit: 'allIfChanged' + } + ); +}); + +// Delete row +function remove_lineas_horas(dataId, row) { + + $.ajax({ + url: `/tarifas/tarifaencuadernacionlineashoras/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable3.clearPipeline(); + theTable3.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }); + +} + +endSection() ?> + + + + + +section("additionalInlineJs") ?> + +const lastColNr = $('#tableOfTarifaencuadernacionlineas').find("tr:first th").length - 1; + +var editor = new $.fn.dataTable.Editor({ + ajax: { + url: "", + headers: { + : v, + }, + }, + table : "#tableOfTarifaencuadernacionlineas", + idSrc: 'id', + fields: [ + { + name: "id", + "type": "readonly" + }, + { + name: "dimensiones_id", + "type": "select" + }, + { + name: "paginas_libro_min", + attr: { + type: "text", + name: "paginas_libro_min", + class: "autonumeric" + } + }, { + name: "precio_min", + attr: { + type: "text", + name: "precio_min", + class: "autonumeric" + } + }, { + name: "paginas_libro_max", + attr: { + type: "text", + name: "paginas_libro_max", + class: "autonumeric" + } + }, { + name: "precio_max", + attr: { + type: "text", + name: "precio_min", + class: "autonumeric" + } + }, { + name: "total_min", + attr: { + type: "text", + name: "total_min", + class: "autonumeric" + } + }, { + name: "margen", + attr: { + type: "text", + name: "margen", + class: "autonumeric" + } + }, { + "name": "tirada_encuadernacion_id", + "type": "hidden" + }, { + "name": "deleted_at", + "type": "hidden" + }, { + "name": "is_deleted", + "type": "hidden" + }, +] + } ); + +// Generación de la lista de proveedores (id, nombre) para encuadernación +const dimensionesList = ; +editor.field('dimensiones_id').update(dimensionesList); +editor.on('open', (event) => { + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + autoNumericInstance.remove() + + } + new AutoNumeric(this, { + alwaysAllowDecimalCharacter: true, + decimalCharacter: ",", + decimalPlaces: 2, + allowDecimalPadding: 'floats', + digitGroupSeparator: ".", + unformatOnSubmit: true, + }); + }) +}) +editor.on('preSubmit', function (e, d, type) { + if (d.data) { + Object.keys(d.data).forEach(function (key) { + // Find all elements with class .autonumeric + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + // Get raw value and update the corresponding field + let rawValue = autoNumericInstance.getNumericString(); + d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used + } + }); + }); + } + if (type === 'create') { + d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id; + } + else if (type === 'edit') { + for (v in d.data) { + d.data[v]['tirada_encuadernacion_id'] = selected_tirada_id; + } + } +}); + + +editor.on('postSubmit', function (e, json, data, action) { + + yeniden(json.); +}); + + +editor.on('submitSuccess', function (e, json, data, action) { + + theTable.clearPipeline(); + theTable.draw(); +}); + + +var theTable = $('#tableOfTarifaencuadernacionlineas').DataTable({ + draw: 2, + serverSide: true, + processing: true, + autoWidth: true, + responsive: true, + lengthMenu: [5, 10, 25], + order: [[0, "asc"], [1, "asc"]], + pageLength: 10, + lengthChange: true, + searching: false, + paging: true, + info: false, + dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', + ajax: $.fn.dataTable.pipeline({ + url: '', + data: function (d) { + d.tirada_id = selected_tirada_id; + }, + method: 'POST', + headers: { 'X-Requested-With': 'XMLHttpRequest' }, + async: true, + }), + columns: [ + { 'data': 'id' }, + { + 'data': 'dimensiones_id', + render: function (data, type, row, meta) { + var value = dimensionesList.find(element => element.value === data); + return value['label']; + }, + }, + { 'data': 'paginas_libro_min', render: (d) => `${d}` }, + { 'data': 'precio_max', render: (d) => `${d}` }, + { 'data': 'paginas_libro_max', render: (d) => `${d}` }, + { 'data': 'precio_min', render: (d) => `${d}` }, + { 'data': 'total_min', render: (d) => `${d}` }, + { 'data': 'margen', render: (d) => `${d}` }, + { + data: actionBtns, + className: 'row-edit dt-center' + } + ], + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr] + }, + { "orderData": [0, 1], "targets": 0 }, + + ], + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + buttons: [ + { + extend: 'collection', + text: 'Exportar', + buttons: [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ] + }, + { + className: 'btn btn-primary float-end me-sm-3 me-1', + extend: "createInline", + editor: editor, + formOptions: { + submitTrigger: -1, + submitHtml: '' + + }, + action: function (e, dt, node, config) { + if (selected_tirada_id == -1) { + popErrorAlert(""); + } + else { + formOptions = { submitTrigger: -1, submitHtml: '' - }; - editor3.inlineCreate(config.position, formOptions); - } - }, - } - ] - } ); + }; + editor.inlineCreate(config.position, formOptions); + } + }, + } + ] +}); - // Activate an inline edit on click of a table cell - $('#tableOfTarifaencuadernacionlineasHoras').on( 'click', 'tbody span.edit', function (e) { - editor3.inline( - theTable3.cells(this.parentNode.parentNode, '*').nodes(), - { - cancelHtml: '', - cancelTrigger: 'span.cancel', - submitHtml: '', - submitTrigger: 'span.edit', - submit: 'allIfChanged' - } - ); - } ); +// Activate an inline edit on click of a table cell +$('#tableOfTarifaencuadernacionlineas').on('click', 'tbody span.edit', function (e) { + editor.inline( + theTable.cells(this.parentNode.parentNode, '*').nodes(), + { + cancelHtml: '', + cancelTrigger: 'span.cancel', + submitHtml: '', + submitTrigger: 'span.edit', + submit: 'allIfChanged' + } + ); +}); - // Delete row - function remove_lineas_horas(dataId, row){ +// Delete row +function remove_lineas(dataId, row) { - $.ajax({ - url: `/tarifas/tarifaencuadernacionlineashoras/delete/${dataId}`, - method: 'GET', - }).done((data, textStatus, jqXHR) => { - $('#confirm2delete').modal('toggle'); - theTable3.clearPipeline(); - theTable3.row($(row)).invalidate().draw(); - popSuccessAlert(data.msg ?? jqXHR.statusText); - }).fail((jqXHR, textStatus, errorThrown) => { - popErrorAlert(jqXHR.responseJSON.messages.error) - }); + $.ajax({ + url: `/tarifas/tarifaencuadernacionlineas/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable.clearPipeline(); + theTable.row($(row)).invalidate().draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }); - } +} +endSection() ?> - endSection() ?> + + + +section("additionalInlineJs") ?> +// Definicion de la ultima columna de la tabla +const lastColNr2 = $('#tableOfTarifaencuadernaciontiradas').find("tr:first th").length - 1; - - - - section("additionalInlineJs") ?> - - const lastColNr = $('#tableOfTarifaencuadernacionlineas').find("tr:first th").length - 1; - - var editor = new $.fn.dataTable.Editor( { - ajax: { - url: "", - headers: { - : v, - }, - }, - table : "#tableOfTarifaencuadernacionlineas", - idSrc: 'id', - fields: [ - {name: "id", - "type": "readonly"}, - { - name: "dimensiones_id", - "type": "select" - }, - { - name: "paginas_libro_min", - attr: { - type: "text", - name : "paginas_libro_min", - class :"autonumeric" - } - }, { - name: "precio_min", - attr: { - type: "text", - name : "precio_min", - class :"autonumeric" - } - }, { - name: "paginas_libro_max", - attr: { - type: "text", - name : "paginas_libro_max", - class :"autonumeric" - } - }, { - name: "precio_max", - attr: { - type: "text", - name : "precio_min", - class :"autonumeric" - } - }, { - name: "total_min", - attr: { - type: "text", - name : "total_min", - class :"autonumeric" - } - }, { - name: "margen", - attr: { - type: "text", - name : "margen", - class :"autonumeric" - } - }, { - "name": "tirada_encuadernacion_id", - "type": "hidden" - },{ - "name": "deleted_at", - "type": "hidden" - },{ - "name": "is_deleted", - "type": "hidden" - }, - ] - } ); - - // Generación de la lista de proveedores (id, nombre) para encuadernación - const dimensionesList = ; - editor.field( 'dimensiones_id' ).update( dimensionesList ); - editor.on('open',(event)=>{ - $("input.autonumeric").each(function () { - let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) - if(autoNumericInstance){ - autoNumericInstance.remove() - - } - new AutoNumeric(this, { - alwaysAllowDecimalCharacter: true, - decimalCharacter: ",", - decimalPlaces : 2, - allowDecimalPadding : 'floats', - digitGroupSeparator: ".", - unformatOnSubmit : true, - }); - }) - }) - editor.on( 'preSubmit', function ( e, d, type ) { - if (d.data) { - Object.keys(d.data).forEach(function (key) { - // Find all elements with class .autonumeric - $("input.autonumeric").each(function () { - let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) - if (autoNumericInstance) { - // Get raw value and update the corresponding field - let rawValue = autoNumericInstance.getNumericString(); - d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used - } - }); - }); - } - if ( type === 'create'){ - d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id; - } - else if(type === 'edit' ) { - for (v in d.data){ - d.data[v]['tirada_encuadernacion_id'] = selected_tirada_id; - } - } - }); - - - editor.on( 'postSubmit', function ( e, json, data, action ) { - - yeniden(json.); - }); - - - editor.on( 'submitSuccess', function ( e, json, data, action ) { - - theTable.clearPipeline(); - theTable.draw(); - }); - - - var theTable = $('#tableOfTarifaencuadernacionlineas').DataTable( { - draw:2, - serverSide: true, - processing: true, - autoWidth: true, - responsive: true, - lengthMenu: [ 5, 10, 25], - order: [[ 0, "asc" ], [ 1, "asc" ]], - pageLength: 10, - lengthChange: true, - searching: false, - paging: true, - info: false, - dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', - ajax : $.fn.dataTable.pipeline( { - url: '', - data: function ( d ) { - d.tirada_id = selected_tirada_id; - }, - method: 'POST', - headers: {'X-Requested-With': 'XMLHttpRequest'}, - async: true, - }), - columns: [ - { 'data': 'id' }, - { 'data': 'dimensiones_id', - render: function(data, type, row, meta) { - var value = dimensionesList.find(element => element.value === data); - return value['label']; - }, - }, - { 'data': 'paginas_libro_min',render : (d) => `${d}` }, - { 'data': 'precio_max',render : (d) => `${d}` }, - { 'data': 'paginas_libro_max',render : (d) => `${d}` }, - { 'data': 'precio_min',render : (d) => `${d}` }, - { 'data': 'total_min',render : (d) => `${d}` }, - { 'data': 'margen' ,render : (d) => `${d}`}, - { - data: actionBtns, - className: 'row-edit dt-center' - } - ], - columnDefs: [ - { - orderable: false, - searchable: false, - targets: [lastColNr] - }, - {"orderData": [ 0, 1 ], "targets": 0 }, - - ], - language: { - url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" - }, - buttons: [ - { - extend: 'collection', - text: 'Exportar', - buttons:[ - 'copy', 'csv', 'excel', 'print', { - extend: 'pdfHtml5', - orientation: 'landscape', - pageSize: 'A4' - } - ] - }, - { - className: 'btn btn-primary float-end me-sm-3 me-1', - extend: "createInline", - editor: editor, - formOptions: { - submitTrigger: -1, - submitHtml: '' - - }, - action: function ( e, dt, node, config ) { - if(selected_tirada_id == -1){ - popErrorAlert(""); - } - else{ - formOptions= { - submitTrigger: -1, - submitHtml: '' - - }; - editor.inlineCreate(config.position, formOptions); - } - }, - } - ] +// Datatables Editor +var editor2 = new $.fn.dataTable.Editor({ + ajax: { + url: "", + headers: { + : v, + }, + }, + table : "#tableOfTarifaencuadernaciontiradas", + idSrc: 'id', + fields: [{ + name: "proveedor_id", + "type": "select" + }, { + name: "tirada_min", + attr: { + type: "text", + name: "tirada_min", + class: "autonumeric" + } + }, { + name: "tirada_max", + attr: { + type: "text", + name: "tirada_max", + class: "autonumeric" + } + }, { + name: "importe_fijo", + attr: { + type: "text", + name: "importe_fijo", + class: "autonumeric" + } + }, { + "name": "tarifa_encuadernacion_id", + "type": "hidden" + }, { + name: "proveedor", + "type": "hidden" + }, { + "name": "deleted_at", + "type": "hidden" + }, { + "name": "is_deleted", + "type": "hidden" + }, +] } ); - // Activate an inline edit on click of a table cell - $('#tableOfTarifaencuadernacionlineas').on( 'click', 'tbody span.edit', function (e) { - editor.inline( - theTable.cells(this.parentNode.parentNode, '*').nodes(), - { - cancelHtml: '', - cancelTrigger: 'span.cancel', - submitHtml: '', - submitTrigger: 'span.edit', - submit: 'allIfChanged' - } - ); - } ); - - // Delete row - function remove_lineas(dataId, row){ +// Generación de la lista de proveedores (id, nombre) para encuadernación +const suppliersList = ; +editor2.field('proveedor_id').update(suppliersList); - $.ajax({ - url: `/tarifas/tarifaencuadernacionlineas/delete/${dataId}`, - method: 'GET', - }).done((data, textStatus, jqXHR) => { - $('#confirm2delete').modal('toggle'); - theTable.clearPipeline(); - theTable.row($(row)).invalidate().draw(); - popSuccessAlert(data.msg ?? jqXHR.statusText); - }).fail((jqXHR, textStatus, errorThrown) => { - popErrorAlert(jqXHR.responseJSON.messages.error) - }); +editor2.on('open', (event) => { + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + autoNumericInstance.remove() - } + } + new AutoNumeric(this, { + decimalCharacter: ",", + digitGroupSeparator: ".", + allowDecimalPadding: 'floats', + decimalPlaces: 2, + unformatOnSubmit: true, + }); + }) +}) +editor2.on('preSubmit', (e, d, type) => { + if (d.data) { + Object.keys(d.data).forEach(function (key) { + // Find all elements with class .autonumeric + $("input.autonumeric").each(function () { + let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) + if (autoNumericInstance) { + // Get raw value and update the corresponding field + let rawValue = autoNumericInstance.getNumericString(); + d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used + } + }); + }); + } +}) +editor2.on('preSubmit', function (e, d, type) { + if (type === 'create') { + d.data[0]['tarifa_encuadernacion_id'] = id; + } + else if (type === 'edit') { + for (v in d.data) { + d.data[v]['tarifa_encuadernacion_id'] = id; + } + } +}); +editor2.on('postSubmit', function (e, json, data, action) { - endSection() ?> - - - - - section("additionalInlineJs") ?> - - // Definicion de la ultima columna de la tabla - const lastColNr2 = $('#tableOfTarifaencuadernaciontiradas').find("tr:first th").length - 1; + yeniden(json.); +}); - // Datatables Editor - var editor2 = new $.fn.dataTable.Editor( { - ajax: { - url: "", - headers: { - : v, - }, - }, - table : "#tableOfTarifaencuadernaciontiradas", - idSrc: 'id', - fields: [ { - name: "proveedor_id", - "type": "select" - }, { - name: "tirada_min", - attr: { - type: "text", - name : "tirada_min", - class :"autonumeric" - } - }, { - name: "tirada_max", - attr: { - type: "text", - name : "tirada_max", - class :"autonumeric" - } - }, { - name: "importe_fijo", - attr: { - type: "text", - name : "importe_fijo", - class :"autonumeric" - } - }, { - "name": "tarifa_encuadernacion_id", - "type": "hidden" - },{ - name: "proveedor", - "type": "hidden" - }, { - "name": "deleted_at", - "type": "hidden" - },{ - "name": "is_deleted", - "type": "hidden" - }, - ] - } ); +editor2.on('submitSuccess', function (e, json, data, action) { + + theTable2.clearPipeline(); + theTable2.draw(); +}); - // Generación de la lista de proveedores (id, nombre) para encuadernación - const suppliersList = ; - editor2.field( 'proveedor_id' ).update( suppliersList ); +// Tabla de tiradas +var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable({ + draw: 1, + serverSide: true, + processing: true, + autoWidth: true, + responsive: true, + lengthMenu: [5, 10, 25], + order: [0, "asc"], + pageLength: 10, + lengthChange: true, + searching: false, + paging: true, + select: true, + info: false, + dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', + ajax: $.fn.dataTable.pipeline({ + url: '', + data: { + id_tarifaencuadernacion: id, + }, + method: 'POST', + headers: { 'X-Requested-With': 'XMLHttpRequest' }, + async: true, + }), + columns: [ + { + 'data': 'proveedor_id', + render: function (data, type, row, meta) { + var value = suppliersList.find(element => element.value === data); + return value['label']; + }, + }, + { 'data': 'tirada_min', render: (d) => `${d}` }, + { 'data': 'tirada_max', render: (d) => `${d}` }, + { 'data': 'importe_fijo', render: (d) => `${d}` }, + { + data: actionBtns, + className: 'row-edit dt-center' + } + ], + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [lastColNr2] + }, - editor2.on('open', (event) => { - $("input.autonumeric").each(function () { - let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) - if (autoNumericInstance) { - autoNumericInstance.remove() - - } - new AutoNumeric(this, { - decimalCharacter: ",", - digitGroupSeparator: ".", - allowDecimalPadding : 'floats', - decimalPlaces: 2, - unformatOnSubmit: true, - }); - }) - }) - editor2.on('preSubmit', (e, d, type) => { - if (d.data) { - Object.keys(d.data).forEach(function (key) { - // Find all elements with class .autonumeric - $("input.autonumeric").each(function () { - let autoNumericInstance = AutoNumeric.getAutoNumericElement(this) - if (autoNumericInstance) { - // Get raw value and update the corresponding field - let rawValue = autoNumericInstance.getNumericString(); - d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used - } - }); - }); - } - }) - editor2.on( 'preSubmit', function ( e, d, type ) { - if ( type === 'create'){ - d.data[0]['tarifa_encuadernacion_id'] = id; - } - else if(type === 'edit' ) { - for (v in d.data){ - d.data[v]['tarifa_encuadernacion_id'] = id; - } - } - }); + ], + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + buttons: [ + { + extend: 'collection', + text: 'Exportar', + buttons: [ + 'copy', 'csv', 'excel', 'print', { + extend: 'pdfHtml5', + orientation: 'landscape', + pageSize: 'A4' + } + ] + }, + { + className: 'btn btn-primary float-end me-sm-3 me-1', + extend: "createInline", + editor: editor2, + formOptions: { + submitTrigger: -1, + submitHtml: '' + } + }] +}); - editor2.on( 'postSubmit', function ( e, json, data, action ) { +// Obtener la id de la fila seleccionada o ponerla a -1 cuando no haya ninguna seleccionada +var selected_tirada_id = -1; +theTable2.on('select', function (e, dt, type, indexes) { + if (type === 'row') { - yeniden(json.); - }); + selected_tirada_id = parseInt(theTable2.rows(indexes).data().pluck('id')[0]); + if ($('#por_horas').is(':checked')) { + theTable3.clearPipeline(); + theTable3.draw(); + } + else { + theTable.clearPipeline(); + theTable.draw(); + } + } +}); + +theTable2.on('deselect', function (e, dt, type, indexes) { + if (theTable2.rows('.selected').count() == 0) { + selected_tirada_id = -1; + if ($('#por_horas').is(':checked')) { + theTable3.clearPipeline(); + theTable3.draw(); + } + else { + theTable.clearPipeline(); + theTable.draw(); + } + } +}); - editor2.on( 'submitSuccess', function ( e, json, data, action ) { - - theTable2.clearPipeline(); - theTable2.draw(); - }); +// Activate an inline edit on click of a table cell +$('#tableOfTarifaencuadernaciontiradas').on('click', 'tbody span.edit', function (e) { + editor2.inline( + theTable2.cells(this.parentNode.parentNode, '*').nodes(), + { + cancelHtml: '', + cancelTrigger: 'span.cancel', + submitHtml: '', + submitTrigger: 'span.edit', + submit: 'allIfChanged' + } + ); +}); - // Tabla de tiradas - var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable( { - draw:1, - serverSide: true, - processing: true, - autoWidth: true, - responsive: true, - lengthMenu: [ 5, 10, 25], - order: [ 0, "asc" ], - pageLength: 10, - lengthChange: true, - searching: false, - paging: true, - select: true, - info: false, - dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', - ajax : $.fn.dataTable.pipeline( { - url: '', - data: { - id_tarifaencuadernacion: id, - }, - method: 'POST', - headers: {'X-Requested-With': 'XMLHttpRequest'}, - async: true, - }), - columns: [ - { 'data': 'proveedor_id', - render: function(data, type, row, meta) { - var value = suppliersList.find(element => element.value === data); - return value['label']; - }, - }, - { 'data': 'tirada_min',render : (d) => `${d}` }, - { 'data': 'tirada_max',render : (d) => `${d}` }, - { 'data': 'importe_fijo',render : (d) => `${d}` }, - { - data: actionBtns, - className: 'row-edit dt-center' - } - ], - columnDefs: [ - { - orderable: false, - searchable: false, - targets: [lastColNr2] - }, +// Delete row +function remove_tiradas(dataId, row) { - ], - language: { - url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" - }, - buttons: [ - { - extend: 'collection', - text: 'Exportar', - buttons:[ - 'copy', 'csv', 'excel', 'print', { - extend: 'pdfHtml5', - orientation: 'landscape', - pageSize: 'A4' - } - ] - }, - { - className: 'btn btn-primary float-end me-sm-3 me-1', - extend: "createInline", - editor: editor2, - formOptions: { - submitTrigger: -1, - submitHtml: '' - } - } ] - } ); + $.ajax({ + url: `/tarifas/tarifaencuadernaciontiradas/delete/${dataId}`, + method: 'GET', + }).done((data, textStatus, jqXHR) => { + $('#confirm2delete').modal('toggle'); + theTable2.clearPipeline(); + theTable2.row($(row)).invalidate().draw(); + theTable.clearPipeline(); + theTable.draw(); + popSuccessAlert(data.msg ?? jqXHR.statusText); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.statusText) + }); +} + +endSection() ?> + + + +section('css') ?> + +"> +endSection() ?> - // Obtener la id de la fila seleccionada o ponerla a -1 cuando no haya ninguna seleccionada - var selected_tirada_id = -1; - theTable2.on( 'select', function ( e, dt, type, indexes ) { - if ( type === 'row' ) { - - selected_tirada_id = parseInt(theTable2.rows( indexes ).data().pluck( 'id' )[0]); - if($('#por_horas').is(':checked')){ - theTable3.clearPipeline(); - theTable3.draw(); - } - else{ - theTable.clearPipeline(); - theTable.draw(); - } - } - } ); - - theTable2.on( 'deselect', function ( e, dt, type, indexes ) { - if ( theTable2.rows( '.selected' ).count() == 0 ) { - selected_tirada_id = -1; - if($('#por_horas').is(':checked')){ - theTable3.clearPipeline(); - theTable3.draw(); - } - else{ - theTable.clearPipeline(); - theTable.draw(); - } - } - } ); - - - // Activate an inline edit on click of a table cell - $('#tableOfTarifaencuadernaciontiradas').on( 'click', 'tbody span.edit', function (e) { - editor2.inline( - theTable2.cells(this.parentNode.parentNode, '*').nodes(), - { - cancelHtml: '', - cancelTrigger: 'span.cancel', - submitHtml: '', - submitTrigger: 'span.edit', - submit: 'allIfChanged' - } - ); - } ); - - - // Delete row - function remove_tiradas(dataId, row){ - - $.ajax({ - url: `/tarifas/tarifaencuadernaciontiradas/delete/${dataId}`, - method: 'GET', - }).done((data, textStatus, jqXHR) => { - $('#confirm2delete').modal('toggle'); - theTable2.clearPipeline(); - theTable2.row($(row)).invalidate().draw(); - theTable.clearPipeline(); - theTable.draw(); - popSuccessAlert(data.msg ?? jqXHR.statusText); - }).fail((jqXHR, textStatus, errorThrown) => { - popErrorAlert(jqXHR.statusText) - }); - } - - endSection() ?> - - - - section('css') ?> - - "> - endSection() ?> - - - section('additionalExternalJs') ?> - - - - - - - - - - endSection() ?> \ No newline at end of file +section('additionalExternalJs') ?> + + + + + + + + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/main/menus/pedidos_menu.php b/ci4/app/Views/themes/vuexy/main/menus/pedidos_menu.php index 7601ec50..e3960862 100644 --- a/ci4/app/Views/themes/vuexy/main/menus/pedidos_menu.php +++ b/ci4/app/Views/themes/vuexy/main/menus/pedidos_menu.php @@ -16,6 +16,13 @@ if (