mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
presupuesto cliente para perfil cliente
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
<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">
|
||||
@ -32,14 +33,16 @@
|
||||
<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') ?>
|
||||
</label>
|
||||
<input type="text" id="referenciaCliente" name="referencia_cliente" placeholder="Referencia cliente" maxLength="100" class="form-control" value="">
|
||||
<input type="text" id="referenciaCliente" name="referencia_cliente" placeholder="Referencia cliente"
|
||||
maxLength="100" class="form-control" value="">
|
||||
</div>
|
||||
|
||||
|
||||
@ -47,20 +50,27 @@
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
@ -64,7 +64,9 @@ class DatosGenerales {
|
||||
|
||||
// Selects
|
||||
this.formatoLibro.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);
|
||||
|
||||
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;
|
||||
|
||||
@ -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');
|
||||
@ -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);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user