mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/plantillas_clientes'
# Conflicts: # ci4/app/Entities/Clientes/ClientePreciosEntity.php # ci4/app/Models/Clientes/ClientePreciosModel.php
This commit is contained in:
@ -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);
|
||||
|
||||
@ -19,7 +19,8 @@ class Test extends BaseController
|
||||
{
|
||||
|
||||
echo '<pre>';
|
||||
$this->testLineasIntRotativa();
|
||||
$model = model('App\Models\Configuracion\TipoPresupuestoModel');
|
||||
var_dump($model->get_isCosido(25));
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
|
||||
19
ci4/app/Entities/Clientes/ClientePlantillaPreciosEntity.php
Executable file
19
ci4/app/Entities/Clientes/ClientePlantillaPreciosEntity.php
Executable file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace App\Entities\Cliente;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class ClientePlantillaPreciosEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"is_deleted" => 0,
|
||||
"deleted_at" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
29
ci4/app/Entities/Clientes/ClientePlantillaPreciosLineaEntity.php
Executable file
29
ci4/app/Entities/Clientes/ClientePlantillaPreciosLineaEntity.php
Executable file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace App\Entities\Cliente;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class ClientePreciosEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => 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",
|
||||
];
|
||||
}
|
||||
20
ci4/app/Entities/Configuracion/TipoPresupuestoEntity.php
Executable file
20
ci4/app/Entities/Configuracion/TipoPresupuestoEntity.php
Executable file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class TipoPresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"codigo" => null,
|
||||
"is_cosido" => null,
|
||||
"is_deleted" => 0,
|
||||
"deleted_at" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
@ -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',
|
||||
|
||||
],
|
||||
|
||||
22
ci4/app/Language/en/ClientePrecios.php
Executable file
22
ci4/app/Language/en/ClientePrecios.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'nombre' => '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',
|
||||
|
||||
],
|
||||
];
|
||||
@ -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' => [
|
||||
|
||||
22
ci4/app/Language/es/ClientePrecios.php
Executable file
22
ci4/app/Language/es/ClientePrecios.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'nombre' => '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',
|
||||
],
|
||||
|
||||
];
|
||||
@ -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' => [
|
||||
|
||||
102
ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php
Executable file
102
ci4/app/Models/Clientes/ClientePlantillaPreciosLineasModel.php
Executable file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Clientes;
|
||||
|
||||
class ClientePlantillaPreciosLineasModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "cliente_plantilla_precios_linea";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
|
||||
protected $allowedFields = [
|
||||
"plantilla_id",
|
||||
"tipo",
|
||||
"tipo_maquina",
|
||||
"tipo_impresion",
|
||||
"tiempo_min",
|
||||
"tiempo_max",
|
||||
"precio_hora",
|
||||
"margen",
|
||||
"is_deleted",
|
||||
"deleted_at",
|
||||
"created_at",
|
||||
"updated_at"];
|
||||
|
||||
protected $returnType = "App\Entities\Clientes\ClientePlantillaPreciosLineasEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "plantilla_id";
|
||||
|
||||
protected $validationRules = [
|
||||
"plantilla_id" => [
|
||||
"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",
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
44
ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php
Executable file
44
ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php
Executable file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Clientes;
|
||||
|
||||
class ClientePlantillaPreciosModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "cliente_plantilla_precios";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
|
||||
protected $allowedFields = ["nombre", "is_deleted", "deleted_at", "created_at", "updated_at"];
|
||||
protected $returnType = "App\Entities\Clientes\ClientePlantillaPreciosEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "ClientePrecios.nombre",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "ClientePrecios.validation.max_length",
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
38
ci4/app/Models/Configuracion/TipoPresupuestoModel.php
Executable file
38
ci4/app/Models/Configuracion/TipoPresupuestoModel.php
Executable file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class TipoPresupuestoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "tipos_presupuestos";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $allowedFields = ["codigo", "is_cosido", "is_deleted", 'deleted_at', 'updated_at', 'created_at'];
|
||||
protected $returnType = "App\Entities\Configuracion\TipoPresupuestoEntity";
|
||||
|
||||
public static $labelField = "codigo";
|
||||
|
||||
|
||||
public function get_isCosido(int $id){
|
||||
|
||||
$builder = $this->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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
<div id="accordionDatosLibroTip" class="accordion-collapse collapse show" data-bs-parent="#accordionDatosLibro">
|
||||
<div class="accordion-body">
|
||||
|
||||
<div id='alert-datosLibro'></div>
|
||||
<!-- Fila 1 -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-2 px-4">
|
||||
@ -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 = <?php echo $isCosido; ?>==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 = `
|
||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-bell ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2"><?= lang("Presupuestos.validation.no_lp_for_merma") ?></h5>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
merma = 0
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$('#mermacubierta').val(parseInt(merma))
|
||||
$('#merma').val(parseInt(merma))
|
||||
$('#alert-datosLibro').html(htmlString)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user