mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en el comparador
This commit is contained in:
@ -33,13 +33,6 @@ class Js_loader extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function datosLibro_js()
|
|
||||||
{
|
|
||||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
|
||||||
return view('themes/vuexy/form/presupuestos/admin/_datosLibroItems.js');
|
|
||||||
}
|
|
||||||
|
|
||||||
function previsualizador_js()
|
function previsualizador_js()
|
||||||
{
|
{
|
||||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||||
|
|||||||
@ -528,7 +528,6 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
} else {
|
} else {
|
||||||
$data['datosLibro']['acabadoSobrecubierta']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre;
|
$data['datosLibro']['acabadoSobrecubierta']['text'] = $modelAcabado->find($presupuesto->acabado_sobrecubierta_id)->nombre;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['datosLibro']['prototipo'] = $presupuesto->prototipo;
|
$data['datosLibro']['prototipo'] = $presupuesto->prototipo;
|
||||||
$data['datosLibro']['ferro'] = $presupuesto->ferro;
|
$data['datosLibro']['ferro'] = $presupuesto->ferro;
|
||||||
$data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital;
|
$data['datosLibro']['ferroDigital'] = $presupuesto->ferro_digital;
|
||||||
@ -537,6 +536,9 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
|||||||
$data['datosLibro']['retractilado5'] = $presupuesto->retractilado5;
|
$data['datosLibro']['retractilado5'] = $presupuesto->retractilado5;
|
||||||
$data['datosLibro']['fajaColor'] = $presupuesto->faja_color;
|
$data['datosLibro']['fajaColor'] = $presupuesto->faja_color;
|
||||||
|
|
||||||
|
$data['comparador']['tipo_impresion'] = $presupuesto->comp_tipo_impresion;
|
||||||
|
$data['comparador']['json_data'] = $presupuesto->comparador_json_data;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color;
|
$data['datosGenerales']['posPaginasColor'] = $presupuesto->comp_pos_paginas_color;
|
||||||
$data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente;
|
$data['datosGenerales']['papelInteriorDiferente'] = $presupuesto->papel_interior_diferente;
|
||||||
|
|||||||
@ -1,144 +0,0 @@
|
|||||||
$('#paginas').on("change", function () {
|
|
||||||
|
|
||||||
const url2 = window.location.href;
|
|
||||||
const url_parts2 = url2.split('/');
|
|
||||||
|
|
||||||
if($('#tipo_impresion_id').val() == 21){
|
|
||||||
if(parseInt($('#paginas').val()) > 80){
|
|
||||||
$('#paginas').val(80)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(url_parts2[url_parts2.length-2] == 'edit'){
|
|
||||||
|
|
||||||
checkPaginasPresupuesto()
|
|
||||||
|
|
||||||
// Si es negro o color
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
|
|
||||||
$('#tipoImpresion').select2('data')[0].id == 'color') {
|
|
||||||
$('#compPaginasNegro').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColor').val()));
|
|
||||||
$('#compPaginasNegro').trigger('change')
|
|
||||||
}
|
|
||||||
// Si es negrohq o colorhq
|
|
||||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
|
|
||||||
$('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
|
||||||
$('#compPaginasNegrohq').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColorhq').val()));
|
|
||||||
$('#compPaginasNegrohq').trigger('change');
|
|
||||||
}
|
|
||||||
|
|
||||||
//update_servicios(false)
|
|
||||||
//updateLineasPresupuesto()
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: true,
|
|
||||||
update_servicios: true,
|
|
||||||
update_envios: true,
|
|
||||||
update_resumen: true,
|
|
||||||
update_tiradas_alternativas: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$('#tirada').on("change", function (update_tiradas_alternativas = true) {
|
|
||||||
|
|
||||||
calcular_mermas()
|
|
||||||
|
|
||||||
const url2 = window.location.href;
|
|
||||||
const url_parts2 = url2.split('/');
|
|
||||||
|
|
||||||
if(url_parts2[url_parts2.length-2] == 'edit'){
|
|
||||||
//update_servicios(false)
|
|
||||||
//updateLineasPresupuesto()
|
|
||||||
if(update_tiradas_alternativas)
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: true,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: false,
|
|
||||||
update_tiradas_alternativas: false
|
|
||||||
})
|
|
||||||
else
|
|
||||||
updatePresupuesto({
|
|
||||||
update_lineas: true,
|
|
||||||
update_servicios: false,
|
|
||||||
update_envios: false,
|
|
||||||
update_resumen: false,
|
|
||||||
update_tiradas_alternativas: false
|
|
||||||
})
|
|
||||||
checkInsertar()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function calcular_mermas(){
|
|
||||||
|
|
||||||
const tirada = parseInt($('#tirada').val())
|
|
||||||
var merma = 0
|
|
||||||
htmlString = ''
|
|
||||||
|
|
||||||
if(tirada> parseInt($('#POD').val())){
|
|
||||||
merma = tirada*0.1<=30 ? tirada*0.1 : 30
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
merma_lineas = []
|
|
||||||
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){
|
|
||||||
const formas_linea = parseInt($('#isCosido').val())==0?parseInt(rowData.formas):parseInt(rowData.formas)/2
|
|
||||||
if(formas_linea > tirada)
|
|
||||||
merma_lineas.push(formas_linea-tirada)
|
|
||||||
else
|
|
||||||
merma_lineas.push(tirada%formas_linea)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if(merma_lineas.length>0)
|
|
||||||
merma = Math.max(...merma_lineas)
|
|
||||||
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">` +
|
|
||||||
window.Presupuestos.validation.no_lp_for_merma +
|
|
||||||
`</h5>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
|
|
||||||
|
|
||||||
merma = 0
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
$('#mermacubierta').val(parseInt(merma))
|
|
||||||
$('#merma').val(parseInt(merma))
|
|
||||||
$('#alert-datosLibro').html(htmlString)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$('#papelFormatoPersonalizado').on("click",function(){
|
|
||||||
|
|
||||||
if($('#papelFormatoPersonalizado').is(':checked')){
|
|
||||||
document.getElementById("papelFormatoAncho").style.display = "block";
|
|
||||||
document.getElementById("papelFormatoAlto").style.display = "block";
|
|
||||||
$('#papelFormatoId').hide();
|
|
||||||
$('#papelFormatoId').val(0).change();
|
|
||||||
document.getElementById("label_papelFormatoId").innerHTML =
|
|
||||||
window.Presupuestos.papelFormatoId + " (" +
|
|
||||||
window.Presupuestos.papelFormatoAncho + " x " + window.Presupuestos.papelFormatoAncho + ")*";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
document.getElementById("papelFormatoAncho").value= "";
|
|
||||||
document.getElementById("papelFormatoAlto").value= "";
|
|
||||||
document.getElementById("papelFormatoAncho").style.display = "none";
|
|
||||||
document.getElementById("papelFormatoAlto").style.display = "none";
|
|
||||||
$('#papelFormatoId').show();
|
|
||||||
document.getElementById("label_papelFormatoId").innerHTML =
|
|
||||||
window.Presupuestos.papelFormatoId + '*';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
@ -38,14 +38,15 @@
|
|||||||
|
|
||||||
<div class="col-md-12 col-lg-4 px-4">
|
<div class="col-md-12 col-lg-4 px-4">
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
<div class="tamanio-estandar">
|
<label id="label_papelFormatoId" for="papelFormatoId" class="form-label">
|
||||||
<label id="label_papelFormatoId" for="papelFormatoId" class="form-label">
|
<?= lang('Presupuestos.papelFormatoId') ?>*
|
||||||
<?= lang('Presupuestos.papelFormatoId') ?>*
|
</label>
|
||||||
</label>
|
<div class="row tamanio-estandar">
|
||||||
<select id="papelFormatoId" name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
<select id="papelFormatoId" name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-lg-6 tamanio-personalizado d-none">
|
<div class="col-md-12 col-lg-6 tamanio-personalizado d-none">
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<div id="divAlarmasComparador"></div>
|
<div id="divAlarmasComparador"></div>
|
||||||
<!----------------------------------------------------------------------------->
|
<!----------------------------------------------------------------------------->
|
||||||
|
|
||||||
<input type="hidden" name="comparador_json_data" id="comparador_json_data" class="form-control" value="<?= isset($presupuestoEntity->comparador_json_data)?$presupuestoEntity->comparador_json_data:'' ?>"></input>
|
<input type="hidden" name="comparador_json_data" id="comparador_json_data" class="form-control" value=""></input>
|
||||||
|
|
||||||
<div class="divider divider-dark text-start mb-1">
|
<div class="divider divider-dark text-start mb-1">
|
||||||
<div class="divider-text">
|
<div class="divider-text">
|
||||||
@ -23,16 +23,16 @@
|
|||||||
<div class="col-md-12 col-lg-3 px-4 mt-1">
|
<div class="col-md-12 col-lg-3 px-4 mt-1">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<select id="tipoImpresion" name="comp_tipo_impresion" class="form-control select2bs2" style="width: 100%;">
|
<select id="tipoImpresion" name="comp_tipo_impresion" class="form-control select2bs2" style="width: 100%;">
|
||||||
<option id="tipoImpresionNegro" value="negro" <?= isset($presupuestoEntity->comp_tipo_impresion) ? ("negro" == $presupuestoEntity->comp_tipo_impresion ? ' selected' : '') : '' ?>>
|
<option id="tipoImpresionNegro" value="negro" >
|
||||||
<?= lang('MaquinasTarifasImpresions.negro') ?>
|
<?= lang('MaquinasTarifasImpresions.negro') ?>
|
||||||
</option>
|
</option>
|
||||||
<option value="negrohq" <?= isset($presupuestoEntity->comp_tipo_impresion) ? ("negrohq" == $presupuestoEntity->comp_tipo_impresion ? ' selected' : '') : '' ?>>
|
<option value="negrohq" >
|
||||||
<?= lang('MaquinasTarifasImpresions.negrohq') ?>
|
<?= lang('MaquinasTarifasImpresions.negrohq') ?>
|
||||||
</option>
|
</option>
|
||||||
<option value="color" <?= isset($presupuestoEntity->comp_tipo_impresion) ? ("color" == $presupuestoEntity->comp_tipo_impresion ? ' selected' : '') : '' ?>>
|
<option value="color" >
|
||||||
<?= lang('MaquinasTarifasImpresions.color') ?>
|
<?= lang('MaquinasTarifasImpresions.color') ?>
|
||||||
</option>
|
</option>
|
||||||
<option value="colorhq" <?= isset($presupuestoEntity->comp_tipo_impresion) ? ("colorhq" == $presupuestoEntity->comp_tipo_impresion ? ' selected' : '') : '' ?>>
|
<option value="colorhq" >
|
||||||
<?= lang('MaquinasTarifasImpresions.colorhq') ?>
|
<?= lang('MaquinasTarifasImpresions.colorhq') ?>
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@ -303,7 +303,6 @@
|
|||||||
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
|
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
|
||||||
<script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script>
|
<script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script>
|
||||||
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
|
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
|
||||||
<script src="<?= site_url('js_loader/datosLibro_js') ?>"></script>
|
|
||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
<?php if (str_contains($formAction, 'edit')): ?>
|
||||||
<script src="<?= site_url('js_loader/datosEnvios_js') ?>"></script>
|
<script src="<?= site_url('js_loader/datosEnvios_js') ?>"></script>
|
||||||
<script src="<?= site_url('js_loader/resumenPresupuestos_js') ?>"></script>
|
<script src="<?= site_url('js_loader/resumenPresupuestos_js') ?>"></script>
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import Ajax from '../../components/ajax.js';
|
|||||||
|
|
||||||
import DatosGenerales from './sections/datosGenerales.js';
|
import DatosGenerales from './sections/datosGenerales.js';
|
||||||
import DatosLibro from './sections/datosLibro.js';
|
import DatosLibro from './sections/datosLibro.js';
|
||||||
|
import Comparador from './sections/comparador.js';
|
||||||
|
|
||||||
class PresupuestoAdminEdit {
|
class PresupuestoAdminEdit {
|
||||||
|
|
||||||
@ -26,6 +27,7 @@ class PresupuestoAdminEdit {
|
|||||||
removeService: this.removeService,
|
removeService: this.removeService,
|
||||||
checkPaginasPresupuesto: this.checkPaginasPresupuesto,
|
checkPaginasPresupuesto: this.checkPaginasPresupuesto,
|
||||||
}));
|
}));
|
||||||
|
this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip'));
|
||||||
|
|
||||||
this.calcularPresupuesto = false;
|
this.calcularPresupuesto = false;
|
||||||
}
|
}
|
||||||
@ -39,6 +41,7 @@ class PresupuestoAdminEdit {
|
|||||||
|
|
||||||
this.datosGenerales.init();
|
this.datosGenerales.init();
|
||||||
this.datosLibro.init();
|
this.datosLibro.init();
|
||||||
|
this.comparador.init();
|
||||||
|
|
||||||
if (window.location.href.includes("edit")) {
|
if (window.location.href.includes("edit")) {
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,44 @@
|
|||||||
|
import ClassSelect from '../../../components/select2.js';
|
||||||
|
import { getToken } from '../../../common/common.js';
|
||||||
|
|
||||||
|
class Comparador {
|
||||||
|
|
||||||
|
constructor(domItem) {
|
||||||
|
|
||||||
|
this.domItem = domItem;
|
||||||
|
|
||||||
|
this.csrf_token = getToken();
|
||||||
|
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||||
|
|
||||||
|
this.comparador_json = this.domItem.find("#comparador_json_data");
|
||||||
|
this.tipo_impresion = $("#tipoImpresion");
|
||||||
|
|
||||||
|
this.paginasNegro = $('#compPaginasNegro');
|
||||||
|
this.papelNegro = new ClassSelect($('#compPapelNegro'),
|
||||||
|
'/papelesgenericos/getpapelcliente', 'Seleccione papel', false,
|
||||||
|
{
|
||||||
|
[this.csrf_token]: this.csrf_hash,
|
||||||
|
tirada: $('#tirada').val(),
|
||||||
|
tipo: 'negro',
|
||||||
|
cubierta: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.gramajeNegro = $('#compGramajeNegro');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this.papelNegro.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
cargarDatos(datos) {
|
||||||
|
|
||||||
|
this.tipo_impresion.val(datos.tipo_impresion);
|
||||||
|
this.comparador_json.val(JSON.stringify(datos.json_data));
|
||||||
|
|
||||||
|
//if (datos.json_data.bn)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Comparador;
|
||||||
@ -16,7 +16,7 @@ class DatosLibro {
|
|||||||
|
|
||||||
this.paginas = this.domItem.find('#paginas');
|
this.paginas = this.domItem.find('#paginas');
|
||||||
this.tirada = this.domItem.find('#tirada');
|
this.tirada = this.domItem.find('#tirada');
|
||||||
this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language["formatoLibro"]);
|
this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language.Presupuestos.formatoLibro);
|
||||||
this.tamanioPersonalizado = this.domItem.find('#papelFormatoPersonalizado');
|
this.tamanioPersonalizado = this.domItem.find('#papelFormatoPersonalizado');
|
||||||
this.anchoPersonalizado = this.domItem.find('#papelFormatoAncho');
|
this.anchoPersonalizado = this.domItem.find('#papelFormatoAncho');
|
||||||
this.altoPersonalizado = this.domItem.find('#papelFormatoAlto');
|
this.altoPersonalizado = this.domItem.find('#papelFormatoAlto');
|
||||||
@ -24,8 +24,8 @@ class DatosLibro {
|
|||||||
this.mermaCubierta = this.domItem.find('#mermacubierta');
|
this.mermaCubierta = this.domItem.find('#mermacubierta');
|
||||||
this.solapasCubierta = this.domItem.find('#solapas');
|
this.solapasCubierta = this.domItem.find('#solapas');
|
||||||
this.solapasSobrecubierta = this.domItem.find('#solapas_sobrecubierta');
|
this.solapasSobrecubierta = this.domItem.find('#solapas_sobrecubierta');
|
||||||
this.anchoSolapasCubierta = this.domItem.find('#anchoSolapasCubierta');
|
this.anchoSolapasCubierta = this.domItem.find('#solapas_ancho');
|
||||||
this.anchoSolapasSobrecubierta = this.domItem.find('#anchoSolapasSobrecubierta');
|
this.anchoSolapasSobrecubierta = this.domItem.find('#solapas_ancho_sobrecubierta');
|
||||||
|
|
||||||
this.divSolapasCubierta = this.domItem.find('#div_solapas_ancho');
|
this.divSolapasCubierta = this.domItem.find('#div_solapas_ancho');
|
||||||
this.divSolapasSobrecubierta = this.domItem.find('#div_solapas_ancho_sobrecubierta');
|
this.divSolapasSobrecubierta = this.domItem.find('#div_solapas_ancho_sobrecubierta');
|
||||||
@ -81,6 +81,10 @@ class DatosLibro {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.solapasSobrecubierta.on('change', this.changeSolapasSobrecubierta.bind(this));
|
this.solapasSobrecubierta.on('change', this.changeSolapasSobrecubierta.bind(this));
|
||||||
|
this.tamanioPersonalizado.on('change', this.changeTipoTamanio.bind(this));
|
||||||
|
|
||||||
|
this.paginas.on('change', this.changePaginas.bind(this));
|
||||||
|
this.tirada.on('change', this.changeTirada.bind(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,9 +170,31 @@ class DatosLibro {
|
|||||||
})*/
|
})*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
changeTipoTamanio(){
|
||||||
|
|
||||||
|
if(this.tamanioPersonalizado.prop('checked')){
|
||||||
|
$('.tamanio-personalizado').removeClass('d-none');
|
||||||
|
$('.tamanio-estandar').addClass('d-none');
|
||||||
|
this.tamanio.setVal('');
|
||||||
|
$("#label_papelFormatoId").text(
|
||||||
|
window.language.Presupuestos.papelFormatoId + " (" +
|
||||||
|
window.language.Presupuestos.papelFormatoAncho + " x " + window.language.Presupuestos.papelFormatoAncho + ")*");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.anchoPersonalizado.val("");
|
||||||
|
this.altoPersonalizado.val("");
|
||||||
|
$('.tamanio-personalizado').addClass('d-none');
|
||||||
|
$('.tamanio-estandar').removeClass('d-none');
|
||||||
|
$("#label_papelFormatoId").text(
|
||||||
|
window.language.Presupuestos.papelFormatoId + '*');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
changeSolapasCubierta() {
|
changeSolapasCubierta() {
|
||||||
|
|
||||||
if (this.solapasCubierta.prop('checked', true)) {
|
if (this.solapasCubierta.prop('checked')) {
|
||||||
this.divSolapasCubierta.removeClass('d-none');
|
this.divSolapasCubierta.removeClass('d-none');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -181,7 +207,7 @@ class DatosLibro {
|
|||||||
|
|
||||||
changeSolapasSobrecubierta() {
|
changeSolapasSobrecubierta() {
|
||||||
|
|
||||||
if (this.solapasSobrecubierta.prop('checked', true)) {
|
if (this.solapasSobrecubierta.prop('checked')) {
|
||||||
this.divSolapasSobrecubierta.removeClass('d-none');
|
this.divSolapasSobrecubierta.removeClass('d-none');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -191,6 +217,125 @@ class DatosLibro {
|
|||||||
$('#serv_default').trigger('click');
|
$('#serv_default').trigger('click');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changePaginas() {
|
||||||
|
|
||||||
|
if($('#tipo_impresion_id').val() == 21){
|
||||||
|
if(parseInt($('#paginas').val()) > 80){
|
||||||
|
$('#paginas').val(80)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(window.location.href.includes('edit')){
|
||||||
|
|
||||||
|
checkPaginasPresupuesto()
|
||||||
|
|
||||||
|
// Si es negro o color
|
||||||
|
if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
|
||||||
|
$('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||||
|
$('#compPaginasNegro').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColor').val()));
|
||||||
|
$('#compPaginasNegro').trigger('change')
|
||||||
|
}
|
||||||
|
// Si es negrohq o colorhq
|
||||||
|
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
|
||||||
|
$('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||||
|
$('#compPaginasNegrohq').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColorhq').val()));
|
||||||
|
$('#compPaginasNegrohq').trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO-DO
|
||||||
|
/*
|
||||||
|
updatePresupuesto({
|
||||||
|
update_lineas: true,
|
||||||
|
update_servicios: true,
|
||||||
|
update_envios: true,
|
||||||
|
update_resumen: true,
|
||||||
|
update_tiradas_alternativas: true
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
changeTirada(update_tiradas_alternativas = true) {
|
||||||
|
|
||||||
|
this.calcular_mermas()
|
||||||
|
|
||||||
|
const url2 = window.location.href;
|
||||||
|
const url_parts2 = url2.split('/');
|
||||||
|
|
||||||
|
if(url_parts2[url_parts2.length-2] == 'edit'){
|
||||||
|
//update_servicios(false)
|
||||||
|
//updateLineasPresupuesto()
|
||||||
|
if(update_tiradas_alternativas)
|
||||||
|
updatePresupuesto({
|
||||||
|
update_lineas: true,
|
||||||
|
update_servicios: false,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: false,
|
||||||
|
update_tiradas_alternativas: false
|
||||||
|
})
|
||||||
|
else
|
||||||
|
updatePresupuesto({
|
||||||
|
update_lineas: true,
|
||||||
|
update_servicios: false,
|
||||||
|
update_envios: false,
|
||||||
|
update_resumen: false,
|
||||||
|
update_tiradas_alternativas: false
|
||||||
|
})
|
||||||
|
checkInsertar()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
calcular_mermas(){
|
||||||
|
|
||||||
|
const tirada = parseInt($('#tirada').val())
|
||||||
|
var merma = 0
|
||||||
|
htmlString = ''
|
||||||
|
|
||||||
|
if(tirada> parseInt($('#POD').val())){
|
||||||
|
merma = tirada*0.1<=30 ? tirada*0.1 : 30
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
merma_lineas = []
|
||||||
|
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||||
|
var rowData = this.data();
|
||||||
|
if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){
|
||||||
|
const formas_linea = parseInt($('#isCosido').val())==0?parseInt(rowData.formas):parseInt(rowData.formas)/2
|
||||||
|
if(formas_linea > tirada)
|
||||||
|
merma_lineas.push(formas_linea-tirada)
|
||||||
|
else
|
||||||
|
merma_lineas.push(tirada%formas_linea)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
if(merma_lineas.length>0)
|
||||||
|
merma = Math.max(...merma_lineas)
|
||||||
|
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">` +
|
||||||
|
window.Presupuestos.validation.no_lp_for_merma +
|
||||||
|
`</h5>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
|
||||||
|
merma = 0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$('#mermacubierta').val(parseInt(merma))
|
||||||
|
$('#merma').val(parseInt(merma))
|
||||||
|
$('#alert-datosLibro').html(htmlString)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cargarDatos(datos) {
|
cargarDatos(datos) {
|
||||||
|
|
||||||
@ -217,14 +362,14 @@ class DatosLibro {
|
|||||||
$(".impresion-con-solapas").addClass('d-none');
|
$(".impresion-con-solapas").addClass('d-none');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (datos.solapas) {
|
if (datos.solapasCubierta) {
|
||||||
this.solapasCubierta.val(datos.solapas);
|
this.solapasCubierta.prop('checked', true);
|
||||||
this.anchoSolapasCubierta.val(datos.ancho_solapas);
|
this.anchoSolapasCubierta.val(datos.solapasCubiertaAncho);
|
||||||
$('#div_solapas_ancho').removeClass('d-none');
|
$('#div_solapas_ancho').removeClass('d-none');
|
||||||
}
|
}
|
||||||
if (datos.solapas_sobrecubierta) {
|
if (datos.solapasSobrecubierta) {
|
||||||
this.solapasSobrecubierta.prop('checked', true);
|
this.solapasSobrecubierta.prop('checked', true);
|
||||||
this.anchoSolapasSobrecubierta.val(datos.ancho_solapas_sobrecubierta);
|
this.anchoSolapasSobrecubierta.val(datos.solapasSobrecubiertaAncho);
|
||||||
$('#div_solapas_ancho_sobrecubierta').removeClass('d-none');
|
$('#div_solapas_ancho_sobrecubierta').removeClass('d-none');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user