mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
comparador cubiertas terminado
This commit is contained in:
@ -514,12 +514,14 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
if( $uso == 'cubierta' ){
|
||||
$opciones_papel = array(
|
||||
'cubierta' => 1,
|
||||
'color' => 1,
|
||||
'rotativa' => 0,
|
||||
);
|
||||
}
|
||||
else if ( $uso == 'sobrecubierta' ){
|
||||
$opciones_papel = array(
|
||||
'sobrecubierta' => 1,
|
||||
'color' => 1,
|
||||
'rotativa' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->testLineasIntPlanaCubierta();
|
||||
$this->testLineasCubierta();
|
||||
}
|
||||
|
||||
public function testGetPrecioPliegoRotativa()
|
||||
@ -248,5 +248,97 @@ class Test extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function testLineasCubierta()
|
||||
{
|
||||
$uso = 'cubierta';
|
||||
$tipo = 'color';
|
||||
|
||||
$datosPedido = (object)array(
|
||||
'paginas' => 240,
|
||||
'tirada' => 100,
|
||||
'merma' => 10,
|
||||
'merma_portada' => 10,
|
||||
'ancho' => 150,
|
||||
'alto' => 210,
|
||||
'isCosido' => true,
|
||||
'solapas' => false,
|
||||
);
|
||||
|
||||
$opciones_papel = array(
|
||||
'color' => 1,
|
||||
'cubierta' => 1,
|
||||
);
|
||||
|
||||
|
||||
// Se obtienen los papeles disponibles
|
||||
$papelimpresionmodel = new \App\Models\Configuracion\PapelImpresionModel();
|
||||
$papeles = $papelimpresionmodel->getIdPapelesImpresionForPresupuesto(
|
||||
papel_generico_id: 3, // Blanco offset
|
||||
gramaje: 100,
|
||||
options: $opciones_papel
|
||||
);
|
||||
|
||||
echo '<pre>';
|
||||
var_dump($papeles);
|
||||
echo '</pre>';
|
||||
|
||||
$lineas = array();
|
||||
// Para cada papel, se obtienen las maquinas disponibles
|
||||
foreach ($papeles as $papel) {
|
||||
|
||||
$maquinamodel = new \App\Models\Configuracion\MaquinaModel();
|
||||
$maquinas = $maquinamodel->getMaquinaImpresionForPresupuesto(
|
||||
is_rotativa: 0,
|
||||
tarifa_tipo: $tipo,
|
||||
tirada: $datosPedido->tirada + $datosPedido->merma,
|
||||
papel_impresion_id: $papel->id,
|
||||
);
|
||||
|
||||
echo '<pre>';
|
||||
echo '-------------------------------';
|
||||
echo '</pre>';
|
||||
|
||||
echo '<pre>';
|
||||
var_dump($maquinas);
|
||||
echo '</pre>';
|
||||
|
||||
// Se recorren las máquinas y se calcula el coste de linea por cada una
|
||||
foreach ($maquinas as $maquina) {
|
||||
|
||||
echo '<pre>';
|
||||
echo '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$';
|
||||
echo '</pre>';
|
||||
|
||||
$tarifamodel = new \App\Models\Configuracion\MaquinasTarifasImpresionModel();
|
||||
$tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, $tipo);
|
||||
|
||||
echo '<pre>';
|
||||
var_dump($tarifa);
|
||||
echo '</pre>';
|
||||
|
||||
if(!is_float($tarifa)){
|
||||
continue;
|
||||
}
|
||||
$linea = PresupuestoService::getCostesLinea($uso, $datosPedido, $maquina, $papel, $opciones_papel, $tarifa);
|
||||
$linea['fields']['maquina'] = $maquina->maquina;
|
||||
$linea['fields']['maquina_id'] = $maquina->maquina_id;
|
||||
$linea['fields']['papel_impresion'] = $papel->nombre;
|
||||
$linea['fields']['papel_impresion_id'] = $papel->id;
|
||||
$linea['fields']['paginas'] = $datosPedido->paginas;
|
||||
$linea['fields']['gramaje'] = 100;
|
||||
$linea['fields']['papel_generico_id'] = 3;
|
||||
$linea['fields']['papel_generico'] = 'Blanco offset';
|
||||
|
||||
array_push($lineas, $linea);
|
||||
}
|
||||
}
|
||||
|
||||
echo '<pre>';
|
||||
var_dump($lineas);
|
||||
echo '</pre>';
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -86,39 +86,6 @@ $("#solapas").on("click", function () {
|
||||
}
|
||||
});
|
||||
|
||||
$('#tipoImpresion').on("change", function () {
|
||||
updatePapelesComparador();
|
||||
$('#paginas').change();
|
||||
|
||||
|
||||
if (($('#tipoImpresion').select2('data')[0].id == 'negro' ||
|
||||
$('#tipoImpresion').select2('data')[0].id == 'color')){
|
||||
|
||||
$('#tableCompIntRotativa').DataTable().clear().draw();
|
||||
$('#total_comp_rot').html("0.00");
|
||||
|
||||
if( $('#tableCompIntPlana').DataTable().rows().count() > 0 &&
|
||||
$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) {
|
||||
|
||||
$('#tableCompIntPlana').DataTable().clear().draw();
|
||||
$('#total_comp_plana').html("0.00");
|
||||
}
|
||||
|
||||
}
|
||||
else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
|
||||
$('#tipoImpresion').select2('data')[0].id == 'colorhq')){
|
||||
|
||||
$('#tableCompIntRotativa').DataTable().clear().draw();
|
||||
$('#total_comp_rot').html("0.00");
|
||||
|
||||
if($('#tableCompIntPlana').DataTable().rows().count() > 0 &&
|
||||
!$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) {
|
||||
|
||||
$('#tableCompIntPlana').DataTable().clear().draw();
|
||||
$('#total_comp_plana').html("0.00");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#compRetractilado').on("change", function () {
|
||||
@ -441,6 +408,21 @@ function selectIntRotLineas(){
|
||||
$('#total_comp_rot').html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
function selectCubiertaLineas(){
|
||||
|
||||
$("#tableCompCubierta").DataTable().rows( '.selected' ).deselect();
|
||||
|
||||
let value_total = 0.00;
|
||||
|
||||
if($("#tableCompCubierta").DataTable().rows().count()>0) {
|
||||
|
||||
$("#tableCompCubierta").DataTable().row( 0 ).nodes().to$().toggleClass( 'selected' );
|
||||
value_total = parseFloat($("#tableCompCubierta").DataTable().rows( 0 ).data()[0]['total'])
|
||||
};
|
||||
|
||||
|
||||
$('#total_comp_cubierta').html(value_total.toFixed(2));
|
||||
}
|
||||
|
||||
function getIDsComparador(is_color, is_hq){
|
||||
|
||||
@ -549,6 +531,7 @@ function fillIntRot(data){
|
||||
}
|
||||
|
||||
function fillCubierta(data, is_color, is_hq){
|
||||
|
||||
let sorted = data.lineas.sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido+p1.fields.precio_click_pedido) < (p2.fields.precio_pedido+p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido+p1.fields.precio_click_pedido) > (p2.fields.precio_pedido+p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
|
||||
@ -273,14 +273,10 @@
|
||||
columns: [
|
||||
{ 'data': 'tipo',
|
||||
'render': function ( data, type, row, meta ) {
|
||||
if(data=='bn')
|
||||
return '<?= lang('Presupuestos.bn') ?>';
|
||||
else if(data=='bnhq')
|
||||
return '<?= lang('Presupuestos.bnhq') ?>';
|
||||
else if(data=='color')
|
||||
return '<?= lang('Presupuestos.color') ?>';
|
||||
else if(data=='colorhq')
|
||||
return '<?= lang('Presupuestos.colorhq') ?>';
|
||||
if(data=='cubierta')
|
||||
return '<?= lang('Presupuestos.cubierta') ?>';
|
||||
else if(data=='sobrecubierta')
|
||||
return '<?= lang('Presupuestos.sobrecubierta') ?>';
|
||||
}
|
||||
},
|
||||
{ 'data': 'paginas' },
|
||||
@ -393,6 +389,9 @@
|
||||
selectIntLineas();
|
||||
$('#title_int_plana').html('<?= lang("Presupuestos.compInteriorPlana") ?>' + ' (' + tableCompIntPlana.rows().count() + ')');
|
||||
}
|
||||
else{
|
||||
$('#title_int_plana').html('<?= lang("Presupuestos.compInteriorPlana") ?>');
|
||||
}
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
return true;
|
||||
},
|
||||
@ -442,6 +441,9 @@
|
||||
selectIntRotLineas();
|
||||
$('#title_int_rot').html('<?= lang("Presupuestos.compInteriorRotativa") ?>' + ' (' + tableCompIntRotativa.rows().count() + ')');
|
||||
}
|
||||
else{
|
||||
$('#title_int_rot').html('<?= lang("Presupuestos.compInteriorRotativa") ?>');
|
||||
}
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
return true;
|
||||
},
|
||||
@ -454,7 +456,7 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$('.comp_cubierta_items').on('change', function (){
|
||||
|
||||
if ($('#compCarasCubierta').select2('data').length > 0 &&
|
||||
@ -491,8 +493,11 @@
|
||||
console.log(data.lineas);
|
||||
|
||||
fillCubierta(data);
|
||||
//selectIntLineas();
|
||||
//$('#title_int_plana').html('<?= lang("Presupuestos.compInteriorPlana") ?>' + ' (' + tableCompIntPlana.rows().count() + ')');
|
||||
selectCubiertaLineas();
|
||||
$('#title_cubierta').html('<?= lang("Presupuestos.cubierta") ?>' + ' (' + tableCompCubierta.rows().count() + ')');
|
||||
}
|
||||
else{
|
||||
$('#title_cubierta').html('<?= lang("Presupuestos.cubierta") ?>');
|
||||
}
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
return true;
|
||||
@ -509,6 +514,43 @@
|
||||
});
|
||||
|
||||
|
||||
$('#tipoImpresion').on("change", function () {
|
||||
updatePapelesComparador();
|
||||
$('#title_int_rot').html('<?= lang("Presupuestos.compInteriorRotativa") ?>');
|
||||
$('#title_int_plana').html('<?= lang("Presupuestos.compInteriorPlana") ?>');
|
||||
$('#paginas').change();
|
||||
|
||||
|
||||
if (($('#tipoImpresion').select2('data')[0].id == 'negro' ||
|
||||
$('#tipoImpresion').select2('data')[0].id == 'color')){
|
||||
|
||||
$('#tableCompIntRotativa').DataTable().clear().draw();
|
||||
$('#total_comp_rot').html("0.00");
|
||||
|
||||
if( $('#tableCompIntPlana').DataTable().rows().count() > 0 &&
|
||||
$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) {
|
||||
|
||||
$('#tableCompIntPlana').DataTable().clear().draw();
|
||||
$('#total_comp_plana').html("0.00");
|
||||
}
|
||||
|
||||
}
|
||||
else if (($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
|
||||
$('#tipoImpresion').select2('data')[0].id == 'colorhq')){
|
||||
|
||||
$('#tableCompIntRotativa').DataTable().clear().draw();
|
||||
$('#total_comp_rot').html("0.00");
|
||||
|
||||
if($('#tableCompIntPlana').DataTable().rows().count() > 0 &&
|
||||
!$('#tableCompIntPlana').DataTable().cell(0, 0).data().includes('hq')) {
|
||||
|
||||
$('#tableCompIntPlana').DataTable().clear().draw();
|
||||
$('#total_comp_plana').html("0.00");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function checkComparadorInt(is_color, is_hq) {
|
||||
|
||||
elementos = getIDsComparador(is_color, is_hq)
|
||||
|
||||
Reference in New Issue
Block a user