falta comprobar que se puede cambiar el tipo de presupuesto

This commit is contained in:
2024-06-18 15:26:15 +02:00
parent c476c9a938
commit e235165499
14 changed files with 222 additions and 186 deletions

View File

@ -16,7 +16,7 @@
</div>
<div class="row">
<div class="col-sm-6 mb-3">
<div class="col-sm-6 mb-3" <?= $clienteId != 0 ?' style="display:none;"':''?>>
<label for="clienteId" class="form-label">
<?= lang('Presupuestos.clienteId') ?>*
</label>
@ -24,7 +24,7 @@
<?php if (isset($datosPresupuesto->clienteList) && is_array($datosPresupuesto->clienteList) && !empty($datosPresupuesto->clienteList)) :
foreach ($datosPresupuesto->clienteList as $k => $v) : ?>
<option value="<?= $k ?>" <?= $k == $presupuestoEntity->cliente_id ? ' selected' : '' ?>>
<option value="<?= $k ?>" <?= $k == $clienteId ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
@ -35,7 +35,11 @@
<div class="col-sm-6 mb-3">
<label for="referenciaCliente" class="form-label">
<?= lang('Presupuestos.referenciaCliente') ?>
<?php if($clienteId == 0): ?>
<?= lang('Presupuestos.referenciaCliente') ?>
<?php else: ?>
<?= lang('Presupuestos.referenciaCliente2') ?>
<?php endif; ?>
</label>
<input type="text" id="referenciaCliente" name="referencia_cliente" maxLength="100" class="form-control" value="<?= old('referencia_cliente', $presupuestoEntity->referencia_cliente) ?>">
</div>
@ -82,33 +86,35 @@
<div>No puede mezclar tiradas mayores de 30 unidades con tiradas menores de 30 unidades</div>
</div>
<div class="col-sm-3 mb-3">
<label for="tirada" class="form-label">
<?= lang('Presupuestos.tirada') ?> 1
</label>
<input type="number" class="calcular-presupuesto" id="tirada" name="tirada" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada) ?>">
</div><!--//.mb-3 -->
<div class="row">
<div class="col-sm-3 mb-3">
<label for="tirada" class="form-label">
<?= lang('Presupuestos.tirada') ?> 1
</label>
<input type="number" class="calcular-presupuesto" id="tirada" name="tirada" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-3 mb-3">
<label for="tirada2" class="form-label">
<?= lang('Presupuestos.tirada') ?> 2
</label>
<input type="number" class="calcular-presupuesto" id="tirada2" name="tirada2" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada2) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-3 mb-3">
<label for="tirada2" class="form-label">
<?= lang('Presupuestos.tirada') ?> 2
</label>
<input type="number" class="calcular-presupuesto" id="tirada2" name="tirada2" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada2) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-3 mb-3">
<label for="tirada3" class="form-label">
<?= lang('Presupuestos.tirada') ?> 3
</label>
<input type="number" class="calcular-presupuesto" id="tirada3" name="tirada3" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada3) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-3 mb-3">
<label for="tirada3" class="form-label">
<?= lang('Presupuestos.tirada') ?> 3
</label>
<input type="number" class="calcular-presupuesto" id="tirada3" name="tirada3" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada3) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-3 mb-3">
<label for="tirada4" class="form-label">
<?= lang('Presupuestos.tirada') ?> 4
</label>
<input type="number" class="calcular-presupuesto" id="tirada4" name="tirada4" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada4) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-3 mb-3">
<label for="tirada4" class="form-label">
<?= lang('Presupuestos.tirada') ?> 4
</label>
<input type="number" class="calcular-presupuesto" id="tirada4" name="tirada4" maxLength="8" step="1" class="form-control" value="<?= old(0, $presupuestoEntity->tirada4) ?>">
</div><!--//.mb-3 -->
</div> <!--//.row -->
</div> <!--//.row -->
@ -177,33 +183,64 @@
</div>
<h6> Color del interior </h6>
<div class="row">
<div class="col col-sm-2 d-flex justify-content-center">
<div id="colorNegroDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorNegro">
<span class="custom-option-body">
<img style="height:120px;width:120px" src="<?= site_url("assets/img/grises.png") ?>" alt="">
</span>
</label>
<input name="colorNegro" class="form-check-input calcular-presupuesto" type="radio" value="colorNegro" id="colorNegro"
<?php echo ($datosPresupuesto->color_impresion == 'negro' ? ' checked=""': ''); ?> >
<div class="row-color">
<div class="row mb-2 col-sm-6">
<div class="container col col-sm-3 d-flex justify-content-center">
<div id="colorNegroDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorNegro">
<span class="custom-option-body">
<img style="height:150px;width:240px" src="<?= site_url("assets/img/bn.png") ?>" alt="">
</span>
</label>
<input name="colorNegro" class="form-check-input calcular-presupuesto" type="radio" value="colorNegro" id="colorNegro"
<?php echo ($datosPresupuesto->color_impresion == 'negro' ? ' checked=""': ''); ?> >
</div>
</div>
</div>
<div class="col col-sm-2 d-flex justify-content-center">
<div id="colorColorDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorColor">
<span class="custom-option-body">
<img style="height:120px;width:120px" src="<?= site_url("assets/img//gamacolor.png") ?>" alt="">
</span>
</label>
<input name="colorColor" class="form-check-input calcular-presupuesto" type="radio" value="colorColor" id="colorColor"
<?php echo ($datosPresupuesto->color_impresion == 'color' ? ' checked=""': ''); ?> >
<div class="container col col-sm-3 d-flex justify-content-center">
<div id="colorNegroHqDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorNegroHq">
<span class="custom-option-body">
<img style="height:150px;width:240px" src="<?= site_url("assets/img//bn_hq.png") ?>" alt="">
</span>
</label>
<input name="colorNegroHq" class="form-check-input calcular-presupuesto" type="radio" value="colorNegroHq" id="colorNegroHq"
<?php echo ($datosPresupuesto->color_impresion == 'negroHq' ? ' checked=""': ''); ?> >
</div>
</div>
</div>
</div> <!--//.row -->
</div> <!--//.row -->
<div class="row col-sm-6">
<div class="container col col-sm-3 d-flex justify-content-center">
<div id="colorColorDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorColor">
<span class="custom-option-body">
<img style="height:150px;width:240px" src="<?= site_url("assets/img/color.png") ?>" alt="">
</span>
</label>
<input name="colorColor" class="form-check-input calcular-presupuesto" type="radio" value="colorColor" id="colorColor"
<?php echo ($datosPresupuesto->color_impresion == 'color' ? ' checked=""': ''); ?> >
</div>
</div>
<div class="container col col-sm-3 d-flex justify-content-center">
<div id="colorColorHqDiv" class="form-check change-tipo-impresion custom-option-color custom-option custom-option-image custom-option-image-radio">
<label class="form-check-label custom-option-content" for="colorColorHq">
<span class="custom-option-body">
<img style="height:150px;width:240px" src="<?= site_url("assets/img//color_hq.png") ?>" alt="">
</span>
</label>
<input name="colorColorHq" class="form-check-input calcular-presupuesto" type="radio" value="colorColorHq" id="colorColorHq"
<?php echo ($datosPresupuesto->color_impresion == 'colorHq' ? ' checked=""': ''); ?> >
</div>
</div>
</div> <!--//.row -->
</div> <!--//.row-color -->
<div id="pagColorDiv" class="row">
<div class="col-sm-3 mb-3">
@ -214,36 +251,6 @@
</div><!--//.mb-3 -->
</div>
<h6> Calidad </h6>
<div class="row">
<div class="col-sm-3 mb-md-0 mb-2">
<div id="calidadEstandarDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic
<?php echo ($datosPresupuesto->calidad_impresion == 'estandar' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="calidadEstandar">
<input name="calidadEstandar" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadEstandar"
<?php echo ($datosPresupuesto->calidad_impresion == 'estandar' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Estándar</span>
</span>
</label>
</div>
</div>
<div class="col-sm-3">
<div id="calidadPremiumDiv" class="form-check change-tipo-impresion custom-option custom-option-calidad custom-option-basic"
<?php echo ($datosPresupuesto->calidad_impresion == 'premium' ? ' checked"': '"'); ?> >
<label class="form-check-label custom-option-content" for="calidadPremium">
<input name="calidadPremium" class="form-check-input calcular-presupuesto" type="radio" value="" id="calidadPremium"
<?php echo ($datosPresupuesto->calidad_impresion == 'premium' ? ' checked=""': ''); ?> >
<span class="custom-option-header">
<span class="h6 mb-0">Premium</span>
</span>
</label>
</div>
</div>
</div> <!--//.row -->
<h6> Papel </h6>
<div class="row">
@ -262,7 +269,7 @@
<h6> Opciones extra </h6>
<div class="row">
<div class="row" <?= $clienteId != 0 ?' style="display:none;"':' '?>>
<div class="col-sm-3 mb-3 d-flex align-items-end">
<div class="form-check form-switch mb-2">
<input class="form-check-input calcular-presupuesto" type="checkbox" id="excluirRotativa" name="excluir_rotativa" value="0" <?= $presupuestoEntity->excluir_rotativa == true ? 'checked' : ''; ?>>

View File

@ -71,7 +71,7 @@ function updateColorCheck(el) {
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-color'))
const customRadioOptionList = [].slice.call(el.closest('.row-color').querySelectorAll('.custom-option-color'))
customRadioOptionList.map(function (customRadioOptionEL) {
customRadioOptionEL.closest('.custom-option-color').classList.remove('checked')
})
@ -79,11 +79,27 @@ function updateColorCheck(el) {
el.closest('.custom-option-color').classList.add('checked')
if (el.closest('.custom-option-color').id == 'colorNegroDiv') {
$('#colorNegro').prop('checked', true);
$('#colorNegroHq').prop('checked', false);
$('#colorColor').prop('checked', false);
$('#colorColorHq').prop('checked', false);
}
else if (el.closest('.custom-option-color').id == 'colorNegroHqDiv') {
$('#colorNegro').prop('checked', false);
$('#colorNegroHq').prop('checked', true);
$('#colorColor').prop('checked', false);
$('#colorColorHq').prop('checked', false);
}
else if (el.closest('.custom-option-color').id == 'colorColorDiv') {
$('#colorNegro').prop('checked', false);
$('#colorNegroHq').prop('checked', false);
$('#colorColor').prop('checked', true);
$('#colorColorHq').prop('checked', false);
}
else {
$('#colorNegro').prop('checked', false);
$('#colorColor').prop('checked', true);
$('#colorNegroHq').prop('checked', false);
$('#colorColor').prop('checked', false);
$('#colorColorHq').prop('checked', true);
}
} else {
@ -92,44 +108,6 @@ function updateColorCheck(el) {
}
function initCalidadCheck() {
const _this = this
const calidadOptionList = [].slice.call(document.querySelectorAll('.custom-option-calidad .form-check-input'))
calidadOptionList.map(function (customOptionEL) {
// Update custom options check on page load
_this.updateCalidadCheck(customOptionEL)
// Update custom options check on click
customOptionEL.addEventListener('click', e => {
_this.updateCalidadCheck(customOptionEL)
})
})
}
function updateCalidadCheck(el) {
if (el.checked) {
// If custom option element is radio, remove checked from the siblings (closest `.row`)
if (el.type === 'radio') {
const customRadioOptionList = [].slice.call(el.closest('.row').querySelectorAll('.custom-option-calidad'))
customRadioOptionList.map(function (customRadioOptionEL) {
customRadioOptionEL.closest('.custom-option-calidad').classList.remove('checked')
})
}
el.closest('.custom-option-calidad').classList.add('checked')
if (el.closest('.custom-option-calidad').id == 'calidadEstandarDiv') {
$('#calidadEstandar').prop('checked', true);
$('#calidadPremium').prop('checked', false);
}
else {
$('#calidadEstandar').prop('checked', false);
$('#calidadPremium').prop('checked', true);
}
} else {
el.closest('.custom-option-calidad').classList.remove('checked')
}
}
$('#enableSobrecubierta').on('change', function () {
if ($(this).is(":checked")) {
$('.enable-sobrecubierta').show();
@ -147,7 +125,6 @@ $('#enableSobrecubierta').on('change', function () {
function initDisenioLibro() {
initTapaCheck();
initColorCheck();
initCalidadCheck();
$('.elementos-libro').trigger('change');
$('.change-tipo-impresion').trigger('change');
@ -180,8 +157,12 @@ function initDisenioLibro() {
$('.change-tipo-impresion').on('change', function () {
isColor = $('#colorNegroDiv').hasClass('checked') ? false : true;
isHq = $('#calidadEstandarDiv').hasClass('checked') ? false : true;
let isColor = false;
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isColor = true;
let isHq = false;
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isHq = true;
//si es color hay que mostrar el numero de paginas a color
if (isColor) {
@ -238,8 +219,13 @@ $('#tirada').on('change', function () {
$('#papelInterior').on('change', function () {
isColor = $('#colorNegroDiv').hasClass('checked') ? false : true;
isHq = $('#calidadEstandarDiv').hasClass('checked') ? false : true;
let isColor = false;
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isColor = true;
let isHq = false;
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isHq = true;
if ($('#papelInterior option:selected').val() != undefined) {
var uso = 'bn';
@ -293,8 +279,8 @@ $('#papelInterior').on('change', function () {
$('#papelCubierta').on('change', function () {
isColor = true;
isHq = true;
let isColor = true;
let isHq = true;
if ($('#papelCubierta option:selected').val() != undefined) {
var uso = 'cubierta';
@ -331,8 +317,8 @@ $('#papelCubierta').on('change', function () {
$('#papelSobrecubierta').on('change', function () {
isColor = true;
isHq = true;
let isColor = true;
let isHq = true;
if ($('#papelSobrecubierta option:selected').val() != undefined) {
var uso = 'sobrecubierta';
@ -616,6 +602,13 @@ $('#clienteId').on('select2:change', function () {
async function calcularPresupuesto() {
let isColor = false;
if($('#colorColorDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isColor = true;
let isHq = false;
if($('#colorNegroDiv').hasClass('checked') || $('#colorColorHqDiv').hasClass('checked'))
isHq = true;
if(!comprobarTiradasPOD()){
$('#errorTiradas').show();
return;
@ -639,8 +632,8 @@ async function calcularPresupuesto() {
paginasColor: $('#paginasColor').val(),
tipo: $('.custom-option-tipo.checked').attr('id').replace('Div', ''),
tapa: $('#tapaDura').is(':checked') ? 'dura' : 'blanda',
isColor: $('#colorNegroDiv').hasClass('checked') ? 0 : 1,
isHq: $('#calidadEstandarDiv').hasClass('checked') ? 0 : 1,
isColor: isColor ? 1 : 0,
isHq: isHq ? 1 : 0,
papelInterior: $('#papelInterior option:selected').val(),
papelInteriorNombre: $('#papelInterior option:selected').text().trim(),
gramajeInterior: $('#gramajeInterior option:selected').text(),

View File

@ -19,9 +19,11 @@ function generarResumen(){
$('#resumenFerro').text('Ferro: ' + (($('#ferro').is(':checked'))?'Sí':'No'));
$('#tipoImpresion').text('Impresión: ' +
($('#colorNegroDiv').hasClass('checked')?'Negro ':'Color ') +
($('#calidadEstandarDiv').hasClass('checked')?'Estándar': 'Premium'));
if($('#colorNegroDiv').hasClass('checked')){
($('#colorNegroDiv').hasClass('checked')?'Negro estándar':
$('#colorNegroHqDiv').hasClass('checked')?'Negro premium':
$('#colorColorDiv').hasClass('checked')?'Color estándar':'Color premium'));
if($('#colorNegroDiv').hasClass('checked') || $('#colorNegroHqDiv').hasClass('checked')){
$('#pResumenPaginasColor').hide();
}
else{
@ -279,13 +281,11 @@ function finalizarPresupuesto(confirmar){
data: datos,
success: function(response) {
if(confirmar){
if(Object.keys(response).length > 0) {
if(response.status > 0){
window.location.href = response.url + '/' + response.status;
}
if(Object.keys(response).length > 0) {
if(response.status > 0){
window.location.href = response.url + '/' + response.status;
}
}
$('#loader').hide();

View File

@ -212,12 +212,6 @@ theTable = $('#tableOfPresupuestos').DataTable({
searchable: false,
targets: [lastColNr]
},
<?php if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')): ?>
{
target: 3,
visible: false
}
<?php endif; ?>
],
columns : [
@ -270,8 +264,9 @@ theTable = $('#tableOfPresupuestos').DataTable({
}
},
},
{ 'data': 'cliente'},
<?php if ($clienteId == 0): ?>
{ 'data': 'cliente'},
<?php endif; ?>
{ 'data': 'titulo' },
{ 'data': 'paginas' },
@ -293,7 +288,11 @@ theTable = $('#tableOfPresupuestos').DataTable({
theTable.on( 'draw.dt', function () {
const dateCols = [1];
<?php if ($clienteId == 0): ?>
const priceCols = [7];
<?php else: ?>
const priceCols = [6];
<?php endif; ?>
for (let coln of dateCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {