comparador cubiertas terminado

This commit is contained in:
Jaime Jimenez
2023-10-18 21:26:04 +02:00
parent 453226b811
commit 721e234849
5 changed files with 230 additions and 86 deletions

View File

@ -90,6 +90,8 @@ class PresupuestoService extends BaseService
else if (($cubierta == 1 || $sobrecubierta == 1) && $rotativa == 0) {
// precio papel
$pliegos_libro = 1.0 / $response['fields']['num_formas']['value'];
// En cubierta y sobrecubierta siempre el mínimo pliego es 1
$pliegos_libro = $pliegos_libro<1?1:$pliegos_libro;
$pliegos_pedido = $pliegos_libro * ($datosPedido->tirada + $datosPedido->merma);
$precio_libro = $pliegos_libro * $precio_pliego_impresion;
$precio_pedido = $precio_libro * ($datosPedido->tirada + $datosPedido->merma);
@ -104,6 +106,11 @@ class PresupuestoService extends BaseService
if ($tarifa) {
$precio_click = $tarifa;
$precio_click_pedido = $pliegos_pedido * $precio_click;
// dos caras
if($datosPedido->paginas > 2) {
$precio_click_pedido *= 2.0;
}
}
}
@ -246,6 +253,14 @@ class PresupuestoService extends BaseService
private static function getNumFormasPlana($uso, $maquina, $ancho, $alto, $isCosido)
{
// El ancho si es cosido es el doble
if($uso != 'cubierta' && $uso != 'sobrecubierta'){
$anchoForCalculo = $isCosido ? $ancho * 2 : $ancho;
}
else{
$anchoForCalculo = $ancho;
}
if($uso == 'cubierta' || $uso == 'sobrecubierta') {
if(property_exists($maquina, 'forzar_num_formas_horizontales_cubierta') &&
property_exists($maquina, 'forzar_num_formas_horizontales_cubierta')){
@ -253,57 +268,59 @@ class PresupuestoService extends BaseService
if($maquina->forzar_num_formas_horizontales_cubierta > 0 &&
$maquina->forzar_num_formas_horizontales_cubierta > 0){
$h1 = $maquina->forzar_num_formas_horizontales_cubierta;
$h2 = $maquina->forzar_num_formas_verticales_cubierta;
$num_formas = $h1 * $h2;
$h1_temp = $maquina->forzar_num_formas_horizontales_cubierta;
$h2_temp = $maquina->forzar_num_formas_verticales_cubierta;
//$num_formas = $h1_temp * $h2_temp;
}
else{
$num_formas == 0;
$h1_temp == 0;
$h2_temp == 0;
}
}
else{
$num_formas == 0;
$h1_temp == 0;
$h2_temp == 0;
}
}
// No es cubierta ni sobrecubierta
else{
// horizontales
$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_impresion / $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_impresion / $anchoForCalculo);
$formas_v = $h2 * $v2; //p2
// Se calcula el numero de formas
if($uso != 'cubierta' && $uso != 'sobrecubierta'){
$num_formas = ($formas_h > $formas_v) ? $formas_h : $formas_v;
$num_formas = $isCosido ? $num_formas * 2 : $num_formas;
}
else{
if($uso != 'cubierta' && $uso != 'sobrecubierta'){
$anchoForCalculo = $isCosido ? $ancho * 2 : $ancho;
}
else{
$anchoForCalculo = $ancho;
}
// horizontales
$h1_temp = floor($maquina->ancho_impresion / $anchoForCalculo);
$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_impresion / $alto);
$formas_h = $h1 * $v1; //p1
// verticales
$h2_temp = floor($maquina->ancho_impresion / $alto);
$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_impresion / $anchoForCalculo);
$formas_v = $h2 * $v2; //p2
$num_formas = ($formas_h > $formas_v) ? $formas_h : $formas_v;
if($uso != 'cubierta' && $uso != 'sobrecubierta'){
$num_formas = $isCosido ? $num_formas * 2 : $num_formas;
}
$num_formas = $h1*$h2;
}
// si no hay formas se devuelve n/a
if ($num_formas == 0) {
$response['num_formas']['posicion_formas'] = 'n/a'; // not available
@ -319,6 +336,14 @@ class PresupuestoService extends BaseService
$response['num_formas']['value'] = $num_formas;
}
if($uso == 'cubierta' || $uso == 'sobrecubierta') {
if(property_exists($maquina, 'forzar_num_formas_horizontales_cubierta') &&
property_exists($maquina, 'forzar_num_formas_horizontales_cubierta')){
$response['num_formas']['num_formas_verticales'] = $h2;
}
}
return $response;
}