presupuesto cliente para perfil cliente

This commit is contained in:
2024-10-31 08:42:41 +01:00
parent d0ee0b27bc
commit 83c8628645
5 changed files with 50 additions and 77 deletions

View File

@ -99,6 +99,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Se obtiene el cliente ID a partir del usuario de la sesion
$model_user = model('App\Models\Usuarios\UserModel');
$user = $model_user->find(auth()->user()->id);
$clienteId = $user->cliente_id;

View File

@ -16,14 +16,15 @@
<label for="autor" class="form-label">
<?= lang('Presupuestos.autor') ?>
</label>
<input type="text" id="autor" placeholder="Autor" name="autor" maxLength="150" class="form-control text-center" value="">
<input type="text" id="autor" placeholder="Autor" name="autor" maxLength="150" class="form-control text-center"
value="">
</div>
<div class="row justify-content-center">
<div class="col-sm-4 mb-3">
<label for="isbn" class="form-label">
<?=lang('Presupuestos.isbn') ?>
<?= lang('Presupuestos.isbn') ?>
</label>
<input type="text" id="isbn" name="isbn" placeholder="ISBN" maxLength="50" class="form-control" value="">
</div>
@ -32,35 +33,44 @@
<label for="coleccion" class="form-label">
<?= lang('Presupuestos.coleccion') ?>
</label>
<input type="text" id="coleccion" name="coleccion" placeholder="Coleccion" maxLength="255" class="form-control" value="">
<input type="text" id="coleccion" name="coleccion" placeholder="Coleccion" maxLength="255"
class="form-control" value="">
</div>
<div class="col-sm-4 mb-3">
<label for="referenciaCliente" class="form-label">
<?=lang('Presupuestos.referenciaCliente') ?>
<?= lang('Presupuestos.referenciaCliente') ?>
</label>
<input type="text" id="referenciaCliente" name="referencia_cliente" placeholder="Referencia cliente" maxLength="100" class="form-control" value="">
</div>
<input type="text" id="referenciaCliente" name="referencia_cliente" placeholder="Referencia cliente"
maxLength="100" class="form-control" value="">
</div>
</div>
<div class="col-sm-5 mb-3 d-flex flex-column align-items-center">
<label id="label_clienteId" for="clienteId" class="form-label">
<label <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
id="label_clienteId" for="clienteId" class="form-label">
Cliente*
</label>
<select id="clienteId" name="cliente_id" class="form-control select2bs2 calcular-presupuesto"
<select <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
id="clienteId" name="cliente_id" class="form-control select2bs2 calcular-presupuesto"
style="width: 100%;">
<?php if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')): ?>
<option value="<?= $clienteId ?>" selected>cliente</option>
<?php endif; ?>
</select>
</div>
<div class="row col-sm-5 mb-3 d-flex flex-column align-items-center">
<div class="form-check form-switch mb-2">
<input class="calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa"
name="excluir_rotativa" value="1">
<label class="form-check-label" for="excluirRotativa">Excluir rotativa</label>
<input <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
class="calcular-presupuesto form-check-input" type="checkbox" id="excluirPortada"
name="excluir_portada" value="1">
<label <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
class="form-check-label" for="excluirRotativa">Excluir rotativa</label>
</div>
</div>

View File

@ -64,7 +64,9 @@ class DatosGenerales {
// Selects
this.formatoLibro.init();
this.cliente.init();
if (this.excluirRotativa.length != 0) {
this.cliente.init();
}
// Inicializa el tipo de impresion
this.#handlePaginas();
@ -100,6 +102,8 @@ class DatosGenerales {
message: window.translations["validation"].cliente,
callback: function (input) {
// Get the selected options
if(this.excluirRotativa.length == 0)
return true;
const options = $("#clienteId").select2('data');
const hasValidOption = options.some(option => parseInt(option.id) > 0);
return options !== null && options.length > 0 && hasValidOption;
@ -382,9 +386,11 @@ class DatosGenerales {
this.coleccion.val(datos.coleccion);
this.referenciaCliente.val(datos.referenciaCliente);
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
this.cliente.setVal(datos.clienteId);
$(this.cliente).trigger('change');
if (this.excluirRotativa.length != 0) {
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
this.cliente.setVal(datos.clienteId);
$(this.cliente).trigger('change');
}
if (datos.excluirRotativa) {
this.excluirRotativa.prop('checked', true);
@ -434,6 +440,12 @@ class DatosGenerales {
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
}
getCliente(){
if (this.excluirRotativa.length == 0)
return $('#clienteId').val();
return this.cliente.getVal();
}
getDimensionLibro() {
let ancho = 0;

View File

@ -37,7 +37,7 @@ class Direcciones {
init() {
$("#clienteId").on('change', this.handleChangeCliente.bind(this));
$("#clienteId").on('change', this.handleChangeCliente.bind(this));
this.direccionesCliente.init();
this.btnAdd.on('click', this.#insertDireccion.bind(this));

View File

@ -62,6 +62,11 @@ class PresupuestoCliente {
this.disenioCubierta.init();
this.direcciones.init();
if(this.datosGenerales.excluirRotativa.length == 0){
this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() })
}
this.btnNext.on('click', this.#nextStep.bind(this));
this.btnPrev.on('click', this.#prevtStep.bind(this));
@ -189,63 +194,6 @@ class PresupuestoCliente {
}
/*RELLENAR_PRESUPUESTO(finalizar) {
if (finalizar) {
$("#titulo").val("Titulo del libro");
$("#titulo").trigger('change');
const clienteId = $("#clienteId");
const newOption = new Option("Cliente Potencial", "1817", true, true);
clienteId.append(newOption).trigger('change');
const papelFormatoId = $("#papelFormatoId");
const newOption2 = new Option("148 x 210", "1", true, true);
papelFormatoId.append(newOption2).trigger('change');
$("#paginasColor").val("6");
$("#paginasColor").trigger('change');
$("#fresado").trigger("click");
$("#colorPremium").trigger("click");
$("#offsetBlanco").trigger("click");
setTimeout(function () {
$("#gramaje90").trigger("click");
}, 0);
setTimeout(function () {
$("#tapaDura").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#unidadesEnvio").val("50");
}, 0);
}
else {
$("#titulo").trigger('change');
}
}*/
#handleTitulosMenu(event) {
$('.titulos-menu').removeClass('crossed');
@ -266,7 +214,7 @@ class PresupuestoCliente {
}
#goToForm(form) {
switch (form) {
case '#datos-generales':
this.validationStepper.to(1);
@ -439,7 +387,7 @@ class PresupuestoCliente {
}
}
else {
if(response.error){
if (response.error) {
popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial.");
}
else
@ -546,7 +494,7 @@ class PresupuestoCliente {
this.datos = {
clienteId: this.datosGenerales.cliente.getVal(),
clienteId: this.datosGenerales.getCliente(),
tamanio: this.datosGenerales.getDimensionLibro(),
tirada: this.datosGenerales.getTiradas(),
@ -651,7 +599,9 @@ class PresupuestoCliente {
this.calcularPresupuesto = false;
this.datosGenerales.cargarDatos(response.data.datosGenerales);
this.direcciones.handleChangeCliente();
if (this.datosGenerales.excluirRotativa.length !== 0) {
this.direcciones.handleChangeCliente();
}
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);