diff --git a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php index 0620168e..74a3478d 100755 --- a/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php +++ b/ci4/app/Controllers/Presupuestos/Cosidotapablanda.php @@ -9,6 +9,7 @@ use App\Models\Collection; use App\Entities\Presupuestos\PresupuestoEntity; use App\Models\Presupuestos\PresupuestoDireccionesModel; use App\Models\Configuracion\PapelGenericoModel; +use App\Models\Configuracion\TipoPresupuestoModel; use App\Models\Presupuestos\PresupuestoModel; use App\Models\Presupuestos\PresupuestoEncuadernacionesModel; @@ -277,6 +278,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController $this->viewData['presupuestoEntity'] = $presupuestoEntity; + $this->viewData['isCosido'] = (new TipoPresupuestoModel())->get_isCosido($presupuestoEntity->tipo_impresion_id); if(!is_null($presupuestoEntity->comparador_json_data)) $this->viewData['comp_data'] = json_decode($presupuestoEntity->comparador_json_data); diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 7695138e..c914cfa0 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -19,7 +19,8 @@ class Test extends BaseController { echo '
';
-        $this->testLineasIntRotativa();
+        $model = model('App\Models\Configuracion\TipoPresupuestoModel');
+        var_dump($model->get_isCosido(25));
         echo '
'; } diff --git a/ci4/app/Entities/Clientes/ClientePlantillaPreciosEntity.php b/ci4/app/Entities/Clientes/ClientePlantillaPreciosEntity.php new file mode 100755 index 00000000..9221712f --- /dev/null +++ b/ci4/app/Entities/Clientes/ClientePlantillaPreciosEntity.php @@ -0,0 +1,19 @@ + null, + "nombre" => null, + "is_deleted" => 0, + "deleted_at" => null, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Entities/Clientes/ClientePlantillaPreciosLineaEntity.php b/ci4/app/Entities/Clientes/ClientePlantillaPreciosLineaEntity.php new file mode 100755 index 00000000..025e7e21 --- /dev/null +++ b/ci4/app/Entities/Clientes/ClientePlantillaPreciosLineaEntity.php @@ -0,0 +1,29 @@ + null, + "plantilla_id" => null, + "tipo" => null, + "tipo_maquina" => null, + "tipo_impresion" => null, + "tiempo_min" => null, + "tiempo_max" => null, + "margen" => null, + "is_deleted" => 0, + "deleted_at" => null, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "plantilla_id" => "int", + "tiempo_min" => "float", + "tiempo_max" => "float", + "margen" => "float", + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Entities/Clientes/ClientePreciosEntity.php b/ci4/app/Entities/Clientes/ClientePreciosEntity.php new file mode 100755 index 00000000..67d9cc97 --- /dev/null +++ b/ci4/app/Entities/Clientes/ClientePreciosEntity.php @@ -0,0 +1,33 @@ + null, + "cliente_id" => null, + "tipo" => null, + "tipo_maquina" => null, + "tipo_impresion" => null, + "tiempo_min" => null, + "tiempo_max" => null, + "margen" => null, + "is_deleted" => 0, + "deleted_at" => null, + "created_at" => null, + "updated_at" => null, + "user_updated_id" => null, + "user_created_id" => null, + ]; + protected $casts = [ + "cliente_id" => "int", + "tiempo_min" => "float", + "tiempo_max" => "float", + "margen" => "float", + "is_deleted" => "int", + "user_updated_id" => "int", + "user_created_id" => "int", + ]; +} diff --git a/ci4/app/Entities/Configuracion/TipoPresupuestoEntity.php b/ci4/app/Entities/Configuracion/TipoPresupuestoEntity.php new file mode 100755 index 00000000..13425d59 --- /dev/null +++ b/ci4/app/Entities/Configuracion/TipoPresupuestoEntity.php @@ -0,0 +1,20 @@ + null, + "codigo" => null, + "is_cosido" => null, + "is_deleted" => 0, + "deleted_at" => null, + "created_at" => null, + "updated_at" => null, + ]; + protected $casts = [ + "is_deleted" => "int", + ]; +} diff --git a/ci4/app/Language/en/ClienteDirecciones.php b/ci4/app/Language/en/ClienteDirecciones.php index a0329961..59c399f9 100755 --- a/ci4/app/Language/en/ClienteDirecciones.php +++ b/ci4/app/Language/en/ClienteDirecciones.php @@ -16,7 +16,7 @@ return [ 'telefono' => 'Phone', 'validation' => [ 'max_length' => 'Max. length ', - 'required' => 'Field required' + 'required' => 'Field required', 'valid_email' => 'The email is not valid', ], diff --git a/ci4/app/Language/en/ClientePrecios.php b/ci4/app/Language/en/ClientePrecios.php new file mode 100755 index 00000000..a6c941b7 --- /dev/null +++ b/ci4/app/Language/en/ClientePrecios.php @@ -0,0 +1,22 @@ + 'Name', + 'plantilla_id' => 'Template ID', + 'tipo' => 'Type', + 'tipo_maquina' => 'Machine type', + 'tipo_impresion' => 'Print type', + 'tiempo_min' => 'Min. Time', + 'tiempo_max' => 'Max. Time', + 'margen' => 'Margin', + 'cliente_id' => 'Customer', + 'user_updated_id' => 'User edition', + 'updated_at' => 'Date edition', + 'validation' => [ + 'max_length' => 'Max. length ', + 'required' => 'Field required', + + ], +]; \ No newline at end of file diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index c3115c84..ea54fe36 100755 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -155,6 +155,7 @@ return [ 'integer' => 'The {field} field must contain an integer.', 'requerido' => 'The {field} field is required.', 'max_length' => 'The {field} field cannot exceed {param} characters in length.', + 'no_lp_for_merma' => 'Insert budget lines to calculate shrink', ], 'errores' => [ diff --git a/ci4/app/Language/es/ClientePrecios.php b/ci4/app/Language/es/ClientePrecios.php new file mode 100755 index 00000000..69909dd3 --- /dev/null +++ b/ci4/app/Language/es/ClientePrecios.php @@ -0,0 +1,22 @@ + 'Nombre', + 'plantilla_id' => 'Plantilla ID', + 'tipo' => 'Tipo', + 'tipo_maquina' => 'Tipo de máquina', + 'tipo_impresion' => 'Tipo de impresión', + 'tiempo_min' => 'Tiempo Mín.', + 'tiempo_max' => 'Tiempo Máx.', + 'margen' => 'Margen', + 'cliente_id' => 'Cliente', + 'user_updated_id' => 'Usuario edición', + 'updated_at' => 'Fecha edición', + 'validation' => [ + 'max_length' => 'Max. valor caracteres alcanzado', + 'required' => 'Campo obligatorio', + ], + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 8a032efa..d5fe3128 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -215,6 +215,7 @@ return [ 'integer' => 'El campo {field} debe contener un número entero.', 'requerido' => 'El campo {field} es obligatorio.', 'max_length' => 'El campo {field} no puede exceder los {param} caracteres de longitud.', + 'no_lp_for_merma' => 'Inserte líneas de presupuesto para calcular la merma', ], 'errores' => [ diff --git a/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php b/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php new file mode 100755 index 00000000..2f1ed657 --- /dev/null +++ b/ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php @@ -0,0 +1,102 @@ + [ + "label" => "ClientePrecios.plantilla_id", + "rules" => "required", + ], + "tipo" => [ + "label" => "ClientePrecios.tipo", + "rules" => "required|in_list[interior,cubierta,sobrecubierta]", + ], + "tipo_maquina" => [ + "label" => "ClientePrecios.tipo_maquina", + "rules" => "required|in_list[toner,inkjet]", + ], + "tipo_impresion" => [ + "label" => "ClientePrecios.tipo_impresion", + "rules" => "required|in_list[negro,color,negrohq,colorhq]", + ], + "tiempo_min" => [ + "label" => "ClientePrecios.tiempo_min", + "rules" => "required|decimal", + ], + "tiempo_max" => [ + "label" => "ClientePrecios.tiempo_max", + "rules" => "required|decimal", + ], + "margen" => [ + "label" => "ClientePrecios.margen", + "rules" => "required|decimal", + ], + + + + ]; + + protected $validationMessages = [ + "plantilla_id" => [ + "required" => "ClientePrecios.validation.required", + + ], + "tipo" => [ + "required" => "ClientePrecios.validation.required", + ], + "tipo_maquina" => [ + "required" => "ClientePrecios.validation.required", + ], + "tipo_impresion" => [ + "required" => "ClientePrecios.validation.required", + ], + "tiempo_min" => [ + "required" => "ClientePrecios.validation.required", + ], + "tiempo_max" => [ + "required" => "ClientePrecios.validation.required", + ], + "margen" => [ + "required" => "ClientePrecios.validation.required", + ], + ]; + + +} diff --git a/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php b/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php new file mode 100755 index 00000000..869d7c81 --- /dev/null +++ b/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php @@ -0,0 +1,44 @@ + [ + "label" => "ClientePrecios.nombre", + "rules" => "trim|max_length[100]", + ], + + ]; + + protected $validationMessages = [ + "nombre" => [ + "max_length" => "ClientePrecios.validation.max_length", + ], + ]; + + +} diff --git a/ci4/app/Models/Clientes/ClientePreciosModel.php b/ci4/app/Models/Clientes/ClientePreciosModel.php new file mode 100755 index 00000000..a58dda43 --- /dev/null +++ b/ci4/app/Models/Clientes/ClientePreciosModel.php @@ -0,0 +1,104 @@ + [ + "label" => "ClientePrecios.cliente_id", + "rules" => "required", + ], + "tipo" => [ + "label" => "ClientePrecios.tipo", + "rules" => "required|in_list[interior,cubierta,sobrecubierta]", + ], + "tipo_maquina" => [ + "label" => "ClientePrecios.tipo_maquina", + "rules" => "required|in_list[toner,inkjet]", + ], + "tipo_impresion" => [ + "label" => "ClientePrecios.tipo_impresion", + "rules" => "required|in_list[negro,color,negrohq,colorhq]", + ], + "tiempo_min" => [ + "label" => "ClientePrecios.tiempo_min", + "rules" => "required|decimal", + ], + "tiempo_max" => [ + "label" => "ClientePrecios.tiempo_max", + "rules" => "required|decimal", + ], + "margen" => [ + "label" => "ClientePrecios.margen", + "rules" => "required|decimal", + ], + + + + ]; + + protected $validationMessages = [ + "cliente_id" => [ + "required" => "ClientePrecios.validation.required", + + ], + "tipo" => [ + "required" => "ClientePrecios.validation.required", + ], + "tipo_maquina" => [ + "required" => "ClientePrecios.validation.required", + ], + "tipo_impresion" => [ + "required" => "ClientePrecios.validation.required", + ], + "tiempo_min" => [ + "required" => "ClientePrecios.validation.required", + ], + "tiempo_max" => [ + "required" => "ClientePrecios.validation.required", + ], + "margen" => [ + "required" => "ClientePrecios.validation.required", + ], + ]; + + +} diff --git a/ci4/app/Models/Configuracion/TipoPresupuestoModel.php b/ci4/app/Models/Configuracion/TipoPresupuestoModel.php new file mode 100755 index 00000000..f26e4d3b --- /dev/null +++ b/ci4/app/Models/Configuracion/TipoPresupuestoModel.php @@ -0,0 +1,38 @@ +db + ->table($this->table . " t1") + ->select("t1.is_cosido AS is_cosido") + ->where('t1.id', $id) + ->where('t1.is_deleted', 0); + + $result = $builder->get()->getResultObject(); + if(count($result)>0){ + return $result[0]->is_cosido; + } + return null; + } + + + +} diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index b02e7383..7ed9f781 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -46,6 +46,7 @@ class PresupuestoService extends BaseService $formas = PresupuestoService::getNumFormasPlana($uso, $maquina, $datosPedido->ancho, $datosPedido->alto, $datosPedido->isCosido); $response['fields'] = $formas; } + if ($response['fields']['num_formas']['posicion_formas'] == 'n/a') { $response['error']['value'] = true; @@ -135,8 +136,6 @@ class PresupuestoService extends BaseService $response['fields']['dimensiones_maquina_click'] = [$maquina->ancho_impresion, $maquina->alto_click]; $response['fields']['dimensiones_libro'] = [$datosPedido->ancho, $datosPedido->alto]; - //$response['fields']['datos_rotativa'] = $datos_rotativa; - return $response; } @@ -260,17 +259,74 @@ class PresupuestoService extends BaseService $data['alto_click'] = $maquina->alto_click; - $data['num_formas']['posicion_formas'] = 'n/a'; + $formas = PresupuestoService::getNumFormasRot($maquina, $datosPedido->ancho, $datosPedido->alto, $datosPedido->isCosido); + $data['num_formas'] = $formas; + + /*$data['num_formas']['posicion_formas'] = 'n/a'; $data['num_formas']['num_formas_horizontales'] = 0; $data['num_formas']['num_formas_verticales'] = 0; $data['num_formas']['value'] = 0; - +*/ return $data; } + public static function getNumFormasRot($maquina, $ancho, $alto, $isCosido) + { + // El ancho si es cosido es el doble + $anchoForCalculo = $isCosido ? $ancho * 2 : $ancho; + + + $h1_temp = floor($maquina->ancho_impresion / $anchoForCalculo); + $h2_temp = floor($maquina->ancho_impresion / $alto); + + // horizontales + $calles = (new \App\Models\Configuracion\MaquinasCallesModel())->getCallesForMaquina($maquina->maquina_id, $h1_temp); + // Si son mas de 2 formas + if(count($calles)>0) + $h1 = ($h1_temp * $anchoForCalculo + 2 * $calles[0]->externas + ($h1_temp - 1) * $calles[0]->internas < ($maquina->ancho)) ? $h1_temp : $h1_temp - 1; + else + $h1 = $h1_temp; + + $v1 = floor($maquina->alto_click / $alto); + $formas_h = $h1 * $v1; //p1 + + + // verticales + $calles = (new \App\Models\Configuracion\MaquinasCallesModel())->getCallesForMaquina($maquina->maquina_id, $h2_temp); + if(count($calles)>0) + $h2 = ($h2_temp * $anchoForCalculo + 2 * $calles[0]->externas + ($h2_temp - 1) * $calles[0]->internas < ($maquina->ancho)) ? $h2_temp : $h2_temp - 1; + else + $h2 = $h2_temp; + $v2 = floor($maquina->alto_click / $anchoForCalculo); + $formas_v = $h2 * $v2; //p2 + + + $num_formas = $h1*$h2; + + + // si no hay formas se devuelve n/a + if ($num_formas == 0) { + $response['posicion_formas'] = 'n/a'; // not available + } else if ($formas_h > $formas_v) { + $response['posicion_formas'] = 'h'; + $response['num_formas_horizontales'] = $h1; + $response['num_formas_verticales'] = $v1; + $response['value'] = $num_formas; + } else { + $response['posicion_formas'] = 'v'; + $response['num_formas_horizontales'] = $h2; + $response['num_formas_verticales'] = $v2; + $response['value'] = $num_formas; + } + + return $response; + } public static function getNumFormasPlana($uso, $maquina, $ancho, $alto, $isCosido) { + $h1_temp = 0; + $h2_temp = 0; + // El ancho si es cosido es el doble if($uso != 'cubierta' && $uso != 'sobrecubierta'){ $anchoForCalculo = $isCosido ? $ancho * 2 : $ancho; @@ -290,14 +346,6 @@ class PresupuestoService extends BaseService $h2_temp = $maquina->forzar_num_formas_verticales_cubierta; //$num_formas = $h1_temp * $h2_temp; } - else{ - $h1_temp == 0; - $h2_temp == 0; - } - } - else{ - $h1_temp == 0; - $h2_temp == 0; } } // No es cubierta ni sobrecubierta diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index 280f83c2..f0de6254 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -9,6 +9,7 @@
+
@@ -287,20 +288,37 @@ function calcular_mermas(){ merma_lineas = [] $('#tableLineasPresupuesto tbody tr:visible ').each(function(){ if(!this.id.includes('_data') && !this.id.endsWith('_cubierta') && !this.id.endsWith('_sobrecubierta')){ - const formas_linea = parseInt($('#' + this.id + '_formas').val()) + const formas_linea = ==0?parseInt($('#' + this.id + '_formas').val()):parseInt($('#' + this.id + '_formas').val())/2 if(formas_linea > tirada) merma_lineas.push(formas_linea-tirada) else merma_lineas.push(tirada%formas_linea) } }) + + htmlString = '' if(merma_lineas.length>0) merma = Math.max(...merma_lineas) - else + else{ + htmlString = ` + `; + + merma = 0 + + } + } $('#mermacubierta').val(parseInt(merma)) $('#merma').val(parseInt(merma)) + $('#alert-datosLibro').html(htmlString) } 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 74a24efe..b238560f 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -2724,7 +2724,7 @@ $('#lp_rot_color_defecto').on("click", function () { function fill_lp_rot_color(row, fromComparador=false){ if(fromComparador){ - console.log(row) + //console.log(row) $('#lp_rot_color_paginas').val(row.paginas) $('#lp_rot_color_papel').val(row.papelGenericoId) $('#lp_rot_color_gramaje').empty()