From 2f38df48860541ca64846c7fc2266ee06910bd00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Mon, 13 Nov 2023 15:05:45 +0100 Subject: [PATCH] leyendo lp y pasandolas a las tablas --- .../Presupuestos/Cosidotapablanda.php | 55 +-- ci4/app/Controllers/Test.php | 26 +- .../Presupuestos/PresupuestoLineaEntity.php | 123 +++++++ ci4/app/Language/en/Presupuestos.php | 3 +- ci4/app/Language/es/Presupuestos.php | 3 +- .../Presupuestos/PresupuestoLineaModel.php | 332 ++++++++++++++++++ .../Models/Presupuestos/PresupuestoModel.php | 4 +- .../_datosPresupuestoItems.php | 2 +- .../_lineasPresupuestoItems.php | 90 ++++- .../viewCosidotapablandaForm.php | 7 +- .../viewCosidotapablandaList.php | 13 +- 11 files changed, 604 insertions(+), 54 deletions(-) create mode 100644 ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php create mode 100644 ci4/app/Models/Presupuestos/PresupuestoLineaModel.php diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index 8e98b6af..68206afd 100644 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -116,6 +116,9 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $id = $this->model->db->insertID(); + $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $lp_model->createForPresupuesto($id); + $message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : @@ -137,21 +140,6 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); $this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo')); $this->viewData['paisList'] = $this->getPaisListItems(); - $this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); - $this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro(); - $this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ(); - $this->viewData['papelGenericoColorList'] = $this->getPapelGenericoColor(); - $this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ(); - $this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta(); - $this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta(); - $this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro(); - $this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor(); - - // Tarifas - $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); - $this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion(); - $this->viewData['serviciosAcabado'] = $this->getServiciosAcabado(); - $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); $this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO @@ -310,34 +298,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['presupuestoEntity'] = $presupuestoEntity; $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); - //$this->viewData['formaPagoList'] = $this->getFormaPagoListItems(); - //$this->viewData['tiposImpresionList'] = $this->getTiposImpresionListItems($presupuestoEntity->tipo_impresion_id ?? null); - //$this->viewData['tipologiasLibroList'] = $this->getTipologiasLibroListItems($presupuestoEntity->tipologia_id ?? null); $this->viewData['paisList'] = $this->getPaisListItems(); - //$this->viewData['ubicacionLibroList'] = $this->getUbicacionLibroListItems($presupuestoEntity->ubicacion_id ?? null); - //$this->viewData['presupuestoEstadoList'] = $this->getPresupuestoEstadoListItems($presupuestoEntity->estado_id ?? null); - //$this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null); - //$this->viewData['papelGenericoList'] = $this->getPapelGenericoListItems($presupuestoEntity->paginas_negro_papel_id ?? null); - //$this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($presupuestoEntity->paginas_negro_papel_impresion_id ?? null); - //$this->viewData['maquinaList'] = $this->getMaquinaListItems($presupuestoEntity->paginas_negro_maquina_id ?? null); - //$this->viewData['maquinasTarifasImpresionList'] = $this->getMaquinasTarifasImpresionListItems($presupuestoEntity->paginas_negro_tarifa_impresion_id ?? null); - //$this->viewData['papelGenericoList2'] = $this->getPapelGenericoListItems2($presupuestoEntity->paginas_color_papel_id ?? null); - /*$this->viewData['papelImpresionList2'] = $this->getPapelImpresionListItems2($presupuestoEntity->paginas_color_papel_impresion_id ?? null); - $this->viewData['maquinaList2'] = $this->getMaquinaListItems2($presupuestoEntity->paginas_color_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList2'] = $this->getMaquinasTarifasImpresionListItems2($presupuestoEntity->paginas_color_tarifa_impresion_id ?? null); - $this->viewData['papelGenericoList3'] = $this->getPapelGenericoListItems3($presupuestoEntity->paginas_portada_papel_id ?? null); - $this->viewData['papelImpresionList3'] = $this->getPapelImpresionListItems3($presupuestoEntity->paginas_portada_papel_impresion_id ?? null); - $this->viewData['maquinaList3'] = $this->getMaquinaListItems3($presupuestoEntity->paginas_portada_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList3'] = $this->getMaquinasTarifasImpresionListItems3($presupuestoEntity->paginas_portada_tarifa_impresion_id ?? null); - $this->viewData['papelGenericoList4'] = $this->getPapelGenericoListItems4($presupuestoEntity->paginas_cubierta_papel_id ?? null); - $this->viewData['papelImpresionList4'] = $this->getPapelImpresionListItems4($presupuestoEntity->paginas_cubierta_papel_impresion_id ?? null); - $this->viewData['maquinaList4'] = $this->getMaquinaListItems4($presupuestoEntity->paginas_cubierta_maquina_id ?? null); - $this->viewData['maquinasTarifasImpresionList4'] = $this->getMaquinasTarifasImpresionListItems4($presupuestoEntity->paginas_cubierta_tarifa_impresion_id ?? null); - $this->viewData['userList'] = $this->getUserListItems($presupuestoEntity->total_confirmado_user_id ?? null); - $this->viewData['userList2'] = $this->getUserListItems2($presupuestoEntity->aprobado_user_id ?? null); - $this->viewData['userList3'] = $this->getUserListItems3($presupuestoEntity->pedido_espera_user_id ?? null); - $this->viewData['paginasCubiertaList'] = $this->getPaginasCubiertaOptions(); - $this->viewData['paginasPortadaList'] = $this->getPaginasPortadaOptions();*/ $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); $this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo')); @@ -352,12 +313,14 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro(); $this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor(); + // Lineas Presupuesto + $this->viewData['lineasPresupuesto'] = $this->getLineasPresupuestoActivas($id); + // Tarifas $this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion(); $this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion(); $this->viewData['serviciosAcabado'] = $this->getServiciosAcabado(); $this->viewData['serviciosManipulado'] = $this->getServiciosManipulado(); - $this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO @@ -1041,7 +1004,11 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController return $data; } - + protected function getLineasPresupuestoActivas($presupuesto_id) + { + $model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + return $model->getLineasPresupuesto($presupuesto_id); + } } diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index f6f20f20..5e9404a0 100644 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -17,7 +17,31 @@ class Test extends BaseController public function index() { - $this->testLineasIntPlana(); + $time = '99:59:59'; + + $time_parts = explode(":", $time); + $seconds = $time_parts[2] + $time_parts[1] * 60 + $time_parts[0] * 3600; + echo "Time in seconds: " . $seconds; + } + + public function timeToSeconds(){ + $time = '99:59:59'; + + $time_parts = explode(":", $time); + $seconds = $time_parts[2] + $time_parts[1] * 60 + $time_parts[0] * 3600; + echo "Time in seconds: " . $seconds; + } + + public function getLP(){ + $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $data = $lp_model->getLineasPresupuesto(8); + foreach($data as $linea) + var_dump($linea->tipo); + } + + public function createLP(){ + $lp_model = model('App\Models\Presupuestos\PresupuestoLineaModel'); + $lp_model->createForPresupuesto(8); } public function getPapelesHQ(){ diff --git a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php new file mode 100644 index 00000000..8fcc6c21 --- /dev/null +++ b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php @@ -0,0 +1,123 @@ + null, + "presupuesto_id" => null, + "tipo" => null, + "paginas" => 0, + "paginas_color_posicion" => null, + "solapas_ancho" => 0.0, + "papel_id" => null, + "papel_impresion_id" => null, + "formas" => null, + "gramaje" => null, + "pliegos_libro" => null, + "pliegos_pedido" => null, + "pliegos_precio" => null, + "libro" => null, + "pedido" => null, + "mano" => null, + "peso" => null, + "maquina_id" => null, + "tarifa_impresion_id" => null, + "click" => null, + "precio" => null, + "rotativa_impresion" => null, + "rotativa_pag_color" => 0, + "rotativa_set_values" => false, + "rotativa_negro" => 0.0, + "rotativa_cyan" => 0.0, + "rotativa_magenta" => 0.0, + "rotativa_amarillo" => 0.0, + "rotativa_gota_negro" => 0.0, + "rotativa_gota_color" => 0.0, + "rotativa_saturacion" => 100.0, + "rotativa_a_favor_fibra" => true, + "rotativa_mxm" => null, + "rotativa_area_paginas" => null, + "rotativa_num_gotas_negro" => 0, + "rotativa_num_gotas_cyan" => 0, + "rotativa_num_gotas_magenta" => 0, + "rotativa_num_gotas_amarillo" => 0, + "rotativa_peso_gotas_negro" => 0, + "rotativa_peso_gotas_cyan" => 0, + "rotativa_peso_gotas_magenta" => 0, + "rotativa_peso_gotas_amarillo" => 0, + "rotativa_precio_pag_negro" => null, + "rotativa_precio_pag_color" => null, + "rotativa_factor_altura" => null, + "rotativa_factor_anchura" => null, + "rotativa_pag_por_pliego" => null, + "rotativa_metros_libro" => null, + "rotativa_metros_total" => null, + "rotativa_clicks_libro" => null, + "rotativa_clicks_total" => null, + "rotativa_precio_tinta" => null, + "rotativa_total_impresion" => null, + "rotativa_velocidad_corte" => 0, + "rotativa_tiempo_corte" => 0, + "rotativa_precio_hora_corte" => 0, + "rotativa_total_corte" => 0, + "isActiva" => false, + ]; + protected $casts = [ + "presupuesto_id" => "int", + "paginas" => "int", + "solapas_ancho" => "float", + "papel_id" => "?int", + "papel_impresion_id" => "?int", + "gramaje" => "?float", + "pliegos_libro" => "?float", + "pliegos_pedido" => "?float", + "pliegos_precio" => "?float", + "libro" => "?float", + "pedido" => "?float", + "mano" => "?float", + "peso" => "?float", + "maquina_id" => "?int", + "tarifa_impresion_id" => "?int", + "click" => "?float", + "precio" => "?float", + "rotativa_pag_color" => "int", + "rotativa_set_values" => "boolean", + "rotativa_negro" => "float", + "rotativa_cyan" => "float", + "rotativa_magenta" => "float", + "rotativa_amarillo" => "float", + "rotativa_gota_negro" => "float", + "rotativa_gota_color" => "float", + "rotativa_saturacion" => "float", + "rotativa_a_favor_fibra" => "boolean", + "rotativa_mxm" => "?float", + "rotativa_area_paginas" => "float", + "rotativa_num_gotas_negro" => "float", + "rotativa_num_gotas_cyan" => "float", + "rotativa_num_gotas_magenta" => "float", + "rotativa_num_gotas_amarillo" => "float", + "rotativa_peso_gotas_negro" => "float", + "rotativa_peso_gotas_cyan" => "float", + "rotativa_peso_gotas_magenta" => "float", + "rotativa_peso_gotas_amarillo" => "float", + "rotativa_precio_pag_negro" => "float", + "rotativa_precio_pag_color" => "float", + "rotativa_factor_altura" => "float", + "rotativa_factor_anchura" => "float", + "rotativa_pag_por_pliego" => "float", + "rotativa_metros_libro" => "float", + "rotativa_metros_total" => "float", + "rotativa_clicks_libro" => "float", + "rotativa_clicks_total" => "float", + "rotativa_precio_tinta" => "float", + "rotativa_total_impresion" => "float", + "rotativa_velocidad_corte" => "float", + "rotativa_tiempo_corte" => "float", + "rotativa_precio_hora_corte" => "float", + "rotativa_total_corte" => "float", + "isActiva" => "boolean", + ]; +} diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index 571c6720..aa954702 100644 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -22,7 +22,8 @@ return [ 'incRei' => 'Incident \ Reprint', 'paginas' => 'Pages', 'tirada' => 'Print', - 'totalPapelPedido' => 'Total paper budget', + 'totalPedido' => 'Total paper budget', + 'totalPresupuesto' => 'Total Budget', 'presupuestoEstado' => 'State', 'presupuestoEstadoBorrador' => 'Draft', 'presupuestoEstadoAceptado' => 'Acepted', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index d3be5e1c..b71dd428 100644 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -21,7 +21,8 @@ return [ 'incRei' => 'Incidencia \ Reimpresión', 'paginas' => 'Paginas', 'tirada' => 'Tirada', - 'totalPedido' => 'Total Presupuesto', + 'totalPedido' => 'Total Pedido', + 'totalPresupuesto' => 'Total Presupuesto', 'presupuestoEstado' => 'Estado', 'presupuestoEstadoBorrador' => 'Borrador', 'presupuestoEstadoAceptado' => 'Aceptado', diff --git a/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php new file mode 100644 index 00000000..fabf40a5 --- /dev/null +++ b/ci4/app/Models/Presupuestos/PresupuestoLineaModel.php @@ -0,0 +1,332 @@ + [ + "label" => "PresupuestoLineas.click", + "rules" => "decimal|permit_empty", + ], + "formas" => [ + "label" => "PresupuestoLineas.formas", + "rules" => "trim|max_length[16313]", + ], + "gramaje" => [ + "label" => "PresupuestoLineas.gramaje", + "rules" => "decimal|permit_empty", + ], + "libro" => [ + "label" => "PresupuestoLineas.libro", + "rules" => "decimal|permit_empty", + ], + "mano" => [ + "label" => "PresupuestoLineas.mano", + "rules" => "decimal|permit_empty", + ], + "paginas" => [ + "label" => "PresupuestoLineas.paginas", + "rules" => "required|integer", + ], + "paginas_color_posicion" => [ + "label" => "PresupuestoLineas.paginasColorPosicion", + "rules" => "trim|max_length[16313]", + ], + "pedido" => [ + "label" => "PresupuestoLineas.pedido", + "rules" => "decimal|permit_empty", + ], + "peso" => [ + "label" => "PresupuestoLineas.peso", + "rules" => "decimal|permit_empty", + ], + "pliegos_libro" => [ + "label" => "PresupuestoLineas.pliegosLibro", + "rules" => "decimal|permit_empty", + ], + "pliegos_pedido" => [ + "label" => "PresupuestoLineas.pliegosPedido", + "rules" => "decimal|permit_empty", + ], + "pliegos_precio" => [ + "label" => "PresupuestoLineas.pliegosPrecio", + "rules" => "decimal|permit_empty", + ], + "precio" => [ + "label" => "PresupuestoLineas.precio", + "rules" => "decimal|permit_empty", + ], + "rotativa_amarillo" => [ + "label" => "PresupuestoLineas.rotativaAmarillo", + "rules" => "required|decimal", + ], + "rotativa_area_paginas" => [ + "label" => "PresupuestoLineas.rotativaAreaPaginas", + "rules" => "required|decimal", + ], + "rotativa_clicks_libro" => [ + "label" => "PresupuestoLineas.rotativaClicksLibro", + "rules" => "required|decimal", + ], + "rotativa_clicks_total" => [ + "label" => "PresupuestoLineas.rotativaClicksTotal", + "rules" => "required|decimal", + ], + "rotativa_cyan" => [ + "label" => "PresupuestoLineas.rotativaCyan", + "rules" => "required|decimal", + ], + "rotativa_factor_altura" => [ + "label" => "PresupuestoLineas.rotativaFactorAltura", + "rules" => "required|decimal", + ], + "rotativa_factor_anchura" => [ + "label" => "PresupuestoLineas.rotativaFactorAnchura", + "rules" => "required|decimal", + ], + "rotativa_gota_color" => [ + "label" => "PresupuestoLineas.rotativaGotaColor", + "rules" => "required|decimal", + ], + "rotativa_gota_negro" => [ + "label" => "PresupuestoLineas.rotativaGotaNegro", + "rules" => "required|decimal", + ], + "rotativa_impresion" => [ + "label" => "PresupuestoLineas.rotativaImpresion", + "rules" => "required|in_list[negro,color]", + ], + "rotativa_magenta" => [ + "label" => "PresupuestoLineas.rotativaMagenta", + "rules" => "required|decimal", + ], + "rotativa_metros_libro" => [ + "label" => "PresupuestoLineas.rotativaMetrosLibro", + "rules" => "required|decimal", + ], + "rotativa_metros_total" => [ + "label" => "PresupuestoLineas.rotativaMetrosTotal", + "rules" => "required|decimal", + ], + "rotativa_mxm" => [ + "label" => "PresupuestoLineas.rotativaMxm", + "rules" => "decimal|permit_empty", + ], + "rotativa_negro" => [ + "label" => "PresupuestoLineas.rotativaNegro", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_amarillo" => [ + "label" => "PresupuestoLineas.rotativaNumGotasAmarillo", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_cyan" => [ + "label" => "PresupuestoLineas.rotativaNumGotasCyan", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_magenta" => [ + "label" => "PresupuestoLineas.rotativaNumGotasMagenta", + "rules" => "required|decimal", + ], + "rotativa_num_gotas_negro" => [ + "label" => "PresupuestoLineas.rotativaNumGotasNegro", + "rules" => "required|decimal", + ], + "rotativa_pag_color" => [ + "label" => "PresupuestoLineas.rotativaPagColor", + "rules" => "required|integer", + ], + "rotativa_pag_por_pliego" => [ + "label" => "PresupuestoLineas.rotativaPagPorPliego", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_amarillo" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasAmarillo", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_cyan" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasCyan", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_magenta" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasMagenta", + "rules" => "required|decimal", + ], + "rotativa_peso_gotas_negro" => [ + "label" => "PresupuestoLineas.rotativaPesoGotasNegro", + "rules" => "required|decimal", + ], + "rotativa_precio_hora_corte" => [ + "label" => "PresupuestoLineas.rotativaPrecioHoraCorte", + "rules" => "required|decimal", + ], + "rotativa_precio_pag_color" => [ + "label" => "PresupuestoLineas.rotativaPrecioPagColor", + "rules" => "required|decimal", + ], + "rotativa_precio_pag_negro" => [ + "label" => "PresupuestoLineas.rotativaPrecioPagNegro", + "rules" => "required|decimal", + ], + "rotativa_precio_tinta" => [ + "label" => "PresupuestoLineas.rotativaPrecioTinta", + "rules" => "required|decimal", + ], + "rotativa_saturacion" => [ + "label" => "PresupuestoLineas.rotativaSaturacion", + "rules" => "required|decimal", + ], + "rotativa_tiempo_corte" => [ + "label" => "PresupuestoLineas.rotativaTiempoCorte", + "rules" => "required|decimal", + ], + "rotativa_total_corte" => [ + "label" => "PresupuestoLineas.rotativaTotalCorte", + "rules" => "required|decimal", + ], + "rotativa_total_impresion" => [ + "label" => "PresupuestoLineas.rotativaTotalImpresion", + "rules" => "required|decimal", + ], + "rotativa_velocidad_corte" => [ + "label" => "PresupuestoLineas.rotativaVelocidadCorte", + "rules" => "required|decimal", + ], + "solapas_ancho" => [ + "label" => "PresupuestoLineas.solapasAncho", + "rules" => "required|decimal", + ], + "tipo" => [ + "label" => "PresupuestoLineas.tipo", + "rules" => "required|in_list[bn,bnhq,color,colorhq,cubierta,sobrecubierta,rot_bn,rot_color]", + ], + ]; + + + public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0) + { + $sql = + "SELECT t1." . + $selcols . + ", t2.id AS presupuesto, t3.nombre AS papel, t4.nombre AS papel_impresion, t5.nombre AS maquina, t6.tipo AS tarifa_impresion FROM " . + $this->table . + " t1 LEFT JOIN presupuestos t2 ON t1.presupuesto_id = t2.id LEFT JOIN lg_papel_generico t3 ON t1.papel_id = t3.id LEFT JOIN lg_papel_impresion t4 ON t1.papel_impresion_id = t4.id LEFT JOIN lg_maquinas t5 ON t1.maquina_id = t5.id LEFT JOIN lg_maquinas_tarifas_impresion t6 ON t1.tarifa_impresion_id = t6.id"; + if (!is_null($limit) && intval($limit) > 0) { + $sql .= " LIMIT " . intval($limit); + } + + if (!is_null($offset) && intval($offset) > 0) { + $sql .= " OFFSET " . intval($offset); + } + + $query = $this->db->query($sql); + $result = $query->getResultObject(); + return $result; + } + + public function createForPresupuesto($presupuesto_id){ + + $tipos = ['bn','bnhq','color','colorhq','cubierta','sobrecubierta','rot_bn','rot_color']; + foreach($tipos as $tipo){ + $builder = $this->db + ->table($this->table . " t1"); + $data = [ + 'presupuesto_id' => $presupuesto_id, + 'tipo' => $tipo, + ]; + + $builder->insert($data); + } + } + + public function getLineasPresupuesto($presupuesto_id = -1) + { + /* + Todos los servicios de manipulado activas que se pueden usar en presupuestos + */ + $builder = $this->db + ->table($this->table . " t1") + ->select( + "*" + ) + ->where("t1.presupuesto_id", $presupuesto_id) + ->where("t1.isActiva", 1); + + + return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); + } +} + + diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index 31fb0400..e31afc8b 100644 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -313,13 +313,15 @@ class PresupuestoModel extends \App\Models\GoBaseModel "t1.id AS id, t1.created_at AS fecha, t2.nombre AS cliente, CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t1.titulo AS titulo, t5.nombre AS pais, t1.inc_rei AS inc_rei, t1.paginas AS paginas, t1.tirada AS tirada, - t1.total_pedido AS total_pedido, t6.estado AS estado" + t1.total_pedido AS total_pedido, t1.total_presupuesto AS total_presupuesto, t6.estado AS estado" ); $builder->join("clientes t2", "t1.cliente_id = t2.id", "left"); $builder->join("auth_user t3", "t1.user_update_id = t3.id_user", "left"); $builder->join("lg_paises t5", "t1.pais_id = t5.id", "left"); $builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left"); + $builder->where("t1.is_deleted", 0); + return empty($search) ? $builder : $builder diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php index b61e1d61..6b0f405a 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems.php @@ -34,7 +34,7 @@ - diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index da35d90b..418809c3 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -2924,8 +2924,96 @@ function fill_lp_cubierta(row, fromComparador=false){ } - $('.lp_cubierta').css('display', '') $("#tableLineasPresupuesto").DataTable().columns.adjust(); } + + +fill_lp_from_bbdd() + +function fill_lp_from_bbdd(){ + + const lineasPresupuestoList = ; + lineasPresupuestoList.forEach(function(lp) { + console.log(lp.tipo) + $('#lp_' + lp.tipo + '_paginas').val(lp.paginas) + + var date = new Date(0); + date.setSeconds(lp.tiempo_maquina); // specify value for SECONDS here + var timeString = date.toISOString().substring(11, 19); + $('#lp_' + lp.tipo + '_tiempo').val(timeString) + + $('#lp_' + lp.tipo + '_numeroPliegos').val(isNaN(parseFloat(lp.pliegos_libro)) ? "" : parseFloat(lp.pliegos_libro).toFixed(2)) + $('#lp_' + lp.tipo + '_pliegosPedido').val(isNaN(parseFloat(lp.pliegos_pedido)) ? "" : parseFloat(lp.pliegos_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_precioPliego').val(isNaN(parseFloat(lp.pliegos_precio)) ? "" : parseFloat(lp.pliegos_precio).toFixed(6)) + $('#lp_' + lp.tipo + '_libro').val(isNaN(parseFloat(lp.libro)) ? "" : parseFloat(lp.libro).toFixed(2)) + $('#lp_' + lp.tipo + '_totalPapelPedido').val(isNaN(parseFloat(lp.total_papel_pedido)) ? "" : parseFloat(lp.total_papel_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_lomo').val(isNaN(parseFloat(lp.mano)) ? "" : parseFloat(lp.mano).toFixed(2)) + $('#lp_' + lp.tipo + '_peso').val(isNaN(parseFloat(lp.peso)) ? "" : parseFloat(lp.peso).toFixed(2)) + $('#lp_' + lp.tipo + '_click').val(isNaN(parseFloat(lp.precio_click)) ? "" : parseFloat(lp.precio_click).toFixed(6)) + $('#lp_' + lp.tipo + '_totalClicks').val(isNaN(parseFloat(lp.precio_click_pedido)) ? "" : parseFloat(lp.precio_click_pedido).toFixed(2)) + + $('#lp_' + lp.tipo + '_checkPapel').prop('checked', lp.check_papel_total==0?false:true) + $('#lp_' + lp.tipo + '_checkClicks').prop('checked', lp.check_impresion_total==0?false:true) + + + /* + + + + + $('#lp_' + lp.tipo + '_totalLinea').val(isNaN(parseFloat(lp.total_impresion)) ? "" : parseFloat(lp.total_impresion).toFixed(2)) + $('#lp_' + lp.tipo + '_aFavorFibra').prop('checked', lp.a_favor_fibra==0?false:true) + + $('#lp_' + lp.tipo + '_cobNegro').val(isNaN(parseFloat(lp.datosTipologias.negro)) ? "" : parseFloat(lp.datosTipologias.negro).toFixed(0)) + $('#lp_' + lp.tipo + '_cobCyan').val(isNaN(parseFloat(lp.datosTipologias.cyan)) ? "" : parseFloat(lp.datosTipologias.cyan).toFixed(0)) + $('#lp_' + lp.tipo + '_cobMagenta').val(isNaN(parseFloat(lp.datosTipologias.magenta)) ? "" : parseFloat(lp.datosTipologias.magenta).toFixed(0)) + $('#lp_' + lp.tipo + '_cobAmarillo').val(isNaN(parseFloat(lp.datosTipologias.amarillo)) ? "" : parseFloat(lp.datosTipologias.amarillo).toFixed(0)) + $('#lp_' + lp.tipo + '_gotaNegro').val(isNaN(parseFloat(lp.datosTipologias.gota_negro)) ? "" : parseFloat(lp.datosTipologias.gota_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_gotaColor').val(isNaN(parseFloat(lp.datosTipologias.gota_color)) ? "" : parseFloat(lp.datosTipologias.gota_color).toFixed(0)) + + $('#lp_' + lp.tipo + '_metrosMinuto').val(isNaN(parseFloat(lp.maquina_velocidad)) ? "" : parseFloat(lp.maquina_velocidad).toFixed(2)) + $('#lp_' + lp.tipo + '_resolucion').val(isNaN(parseFloat(lp.resolucion)) ? "" : parseFloat(lp.resolucion).toFixed(0)) + $('#lp_' + lp.tipo + '_areaPaginas').val(isNaN(parseFloat(lp.superficie)) ? "" : parseFloat(lp.superficie).toFixed(2)) + $('#lp_' + lp.tipo + '_gotasNegro').val(isNaN(parseFloat(lp.num_gotas_negro)) ? "" : parseFloat(lp.num_gotas_negro).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasCyan').val(isNaN(parseFloat(lp.num_gotas_cyan)) ? "" : parseFloat(lp.num_gotas_cyan).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasMagenta').val(isNaN(parseFloat(lp.num_gotas_magenta)) ? "" : parseFloat(lp.num_gotas_magenta).toFixed(0)) + $('#lp_' + lp.tipo + '_gotasAmarillo').val(isNaN(parseFloat(lp.num_gotas_amarillo)) ? "" : parseFloat(lp.num_gotas_amarillo).toFixed(0)) + $('#lp_' + lp.tipo + '_precioPagNegro').val(isNaN(parseFloat(lp.precio_pagina_negro)) ? "" : parseFloat(lp.precio_pagina_negro).toFixed(6)) + $('#lp_' + lp.tipo + '_precioPagColor').val(isNaN(parseFloat(lp.precio_pagina_color)) ? "" : parseFloat(lp.precio_pagina_color).toFixed(6)) + $('#lp_' + lp.tipo + '_factorAltura').val(isNaN(parseFloat(lp.factor_altura)) ? "" : parseFloat(lp.factor_altura).toFixed(2)) + $('#lp_' + lp.tipo + '_factorAnchura').val(isNaN(parseFloat(lp.factor_anchura)) ? "" : parseFloat(lp.factor_anchura).toFixed(2)) + $('#lp_' + lp.tipo + '_paginasPliego').val(isNaN(parseFloat(lp.paginas_por_pliego)) ? "" : parseFloat(lp.paginas_por_pliego).toFixed(2)) + + $('#lp_' + lp.tipo + '_metrosPapelLibro').val(isNaN(parseFloat(lp.metros_papel_libro)) ? "" : parseFloat(lp.metros_papel_libro).toFixed(2)) + $('#lp_' + lp.tipo + '_metrosPapelTotal').val(isNaN(parseFloat(lp.metros_papel_total)) ? "" : parseFloat(lp.metros_papel_total).toFixed(2)) + $('#lp_' + lp.tipo + '_clicksLibro').val(isNaN(parseFloat(lp.clicks_libro)) ? "" : parseFloat(lp.clicks_libro).toFixed(0)) + $('#lp_' + lp.tipo + '_gTintaNegro').val(isNaN(parseFloat(lp.peso_gotas_negro)) ? "" : parseFloat(lp.peso_gotas_negro).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaCyan').val(isNaN(parseFloat(lp.peso_gotas_cyan)) ? "" : parseFloat(lp.peso_gotas_cyan).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaMagenta').val(isNaN(parseFloat(lp.peso_gotas_magenta)) ? "" : parseFloat(lp.peso_gotas_magenta).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaAmarillo').val(isNaN(parseFloat(lp.peso_gotas_amarillo)) ? "" : parseFloat(lp.peso_gotas_amarillo).toFixed(2)) + $('#lp_' + lp.tipo + '_clicksPedido').val(isNaN(parseFloat(lp.clicks_pedido)) ? "" : parseFloat(lp.clicks_pedido).toFixed(0)) + $('#lp_' + lp.tipo + '_totalClicksPedido').val(isNaN(parseFloat(lp.precio_click_pedido)) ? "" : parseFloat(lp.precio_click_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_totalTinta').val(isNaN(parseFloat(lp.precio_tinta)) ? "" : parseFloat(lp.precio_tinta).toFixed(2)) + $('#lp_' + lp.tipo + '_totalCorte').val(isNaN(parseFloat(lp.total_corte)) ? "" : parseFloat(lp.total_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_totalImpresion').val(isNaN(parseFloat(lp.precio_click_pedido+lp.precio_tinta+lp.total_corte)) ? "" : parseFloat(lp.precio_click_pedido+lp.precio_tinta+lp.total_corte).toFixed(2)) + + $('#lp_' + lp.tipo + '_velocidadCorte').val(isNaN(parseFloat(lp.velocidad_corte)) ? "" : parseFloat(lp.velocidad_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_precioHoraCorte').val(isNaN(parseFloat(lp.precio_hora_corte)) ? "" : parseFloat(lp.precio_hora_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_tiempoCorte').val(isNaN(parseFloat(lp.tiempo_corte)) ? "" : parseFloat(lp.tiempo_corte).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaNegroPed').val(isNaN(parseFloat(lp.peso_gotas_negro_pedido)) ? "" : parseFloat(lp.peso_gotas_negro_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaCyanPed').val(isNaN(parseFloat(lp.peso_gotas_cyan_pedido)) ? "" : parseFloat(lp.peso_gotas_cyan_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaMagentaPed').val(isNaN(parseFloat(lp.peso_gotas_magenta_pedido)) ? "" : parseFloat(lp.peso_gotas_magenta_pedido).toFixed(2)) + $('#lp_' + lp.tipo + '_gTintaAmarilloPed').val(isNaN(parseFloat(lp.peso_gotas_amarillo_pedido)) ? "" : parseFloat(lp.peso_gotas_amarillo_pedido).toFixed(2)) + */ + $('.lp_' + lp.tipo).css('display', '') + + }) + + $("#tableLineasPresupuesto").DataTable().draw(); + //$("#tableLineasPresupuesto").DataTable().columns.adjust(); +} + + + endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php index 7d20aa28..b73d397e 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaForm.php @@ -25,6 +25,8 @@ + +
; + - //const papelGenericoNegroList = ; + endSection() ?> diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php index 0deb4f39..ea91cb8f 100644 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/viewCosidotapablandaList.php @@ -27,7 +27,7 @@ - + @@ -104,8 +104,15 @@ { 'data': 'inc_rei' }, { 'data': 'paginas' }, { 'data': 'tirada' }, - { 'data': 'total_pedido' }, - { 'data': 'estado' }, + { 'data': 'total_presupuesto' }, + { 'data': 'estado' , + 'render': function ( data, type, row, meta ) { + if(data=='borrador') + return ''; + else if(data=='aceptado') + return ''; + } + }, { 'data': actionBtns } ] });