mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
bug para presupuesto cliente (en direcciones)
This commit is contained in:
@ -164,8 +164,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if ($presupuestoEntity->is_duplicado) {
|
||||
$this->model->removeIsDuplicado($presupuestoEntity->id);
|
||||
}
|
||||
|
||||
|
||||
$this->viewData['presupuestoId'] = $presupuestoEntity->id;
|
||||
$this->viewData['state'] = intval($presupuestoEntity->estado_id);
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
@ -626,6 +627,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
$datosCabecera = $reqData['datosCabecera'] ?? [];
|
||||
|
||||
$confirmar = $reqData['confirmar'] ?? 0;
|
||||
$confirmar = intval($confirmar);
|
||||
|
||||
$cliente_id = $reqData['clienteId'] ?? -1;
|
||||
|
||||
@ -928,17 +930,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$modelPapelGenerico = new PapelGenericoModel();
|
||||
$modelPapelFormato = new PapelFormatoModel();
|
||||
$modelCliente = new ClienteModel();
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
|
||||
$presupuesto = $this->model->find($id);
|
||||
$data = [];
|
||||
if ($presupuesto) {
|
||||
$data['lc'] = $presupuesto->lomo_cubierta;
|
||||
$data['lsc'] = $presupuesto->lomo_sobrecubierta;
|
||||
$data['state'] = intval($presupuesto->estado_id);
|
||||
$data['datosGenerales']['titulo'] = $presupuesto->titulo;
|
||||
$data['datosGenerales']['autor'] = $presupuesto->autor;
|
||||
$data['datosGenerales']['isbn'] = $presupuesto->isbn;
|
||||
@ -1005,6 +1006,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
|
||||
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
|
||||
|
||||
if(intval($presupuesto->estado_id) == 2){
|
||||
$data['resumen']['base'] = $presupuesto->total_aceptado;
|
||||
$data['resumen']['precio_unidad'] = $presupuesto->total_precio_unidad;
|
||||
}
|
||||
|
||||
$tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data);
|
||||
for ($i = 0; $i < count($tiradas_alternativas); $i++) {
|
||||
$tirada = $tiradas_alternativas[$i];
|
||||
|
||||
@ -1,30 +1,36 @@
|
||||
<div class="col-12" style="min-height: 50px;">
|
||||
<div id="btnsDiv" class="d-flex w-100 position-relative" style="margin-top: 40px;">
|
||||
<div id="btnsDiv" class="d-flex w-100 position-relative" style="margin-top: 40px;">
|
||||
|
||||
<div class="me-auto">
|
||||
<div id="btnPrint" class="btn mt-3 btn-secondary waves-effect waves-light ml-2 d-none">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_print2') ?></span>
|
||||
<div class="me-auto">
|
||||
<div id="btnPrint" class="btn mt-3 btn-secondary waves-effect waves-light ml-2 d-none">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_print2') ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="position-absolute start-50 translate-middle-x">
|
||||
<?php if ($state != 2): ?>
|
||||
<div id="btnPrev" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_prev') ?></span>
|
||||
</div>
|
||||
<div id="btnNext" class="btn mt-3 btn-primary waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_next') ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="ms-auto">
|
||||
|
||||
<?php if ($state != 2): ?>
|
||||
|
||||
<div id="btnConfirm" class="btn mt-3 btn-success waves-effect waves-light ml-2 d-none">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_confirm') ?></span>
|
||||
</div>
|
||||
|
||||
<div id="btnSave" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_save') ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="position-absolute start-50 translate-middle-x">
|
||||
<div id="btnPrev" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_prev') ?></span>
|
||||
</div>
|
||||
<div id="btnNext" class="btn mt-3 btn-primary waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_next') ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ms-auto">
|
||||
<div id="btnConfirm" class="btn mt-3 btn-success waves-effect waves-light ml-2 d-none">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_confirm') ?></span>
|
||||
</div>
|
||||
|
||||
<div id="btnSave" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_save') ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -182,4 +182,25 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if ($state == 2): ?>
|
||||
<div class="row mb-3">
|
||||
<h3>Ficheros</h3>
|
||||
<div class="col-12">
|
||||
<div class="dropzone needsclick" id="dropzone-multi">
|
||||
<div class="dz-message needsclick">
|
||||
Arrastre aquí los ficheros o haga click
|
||||
</div>
|
||||
<div class="fallback">
|
||||
<input name="file" type="file" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button id="submit-all-files" class="btn mt-3 btn-primary btn-submit waves-effect waves-light ml-2">
|
||||
<span class="align-middle d-sm-inline-block d-none me-sm-1">Actualizar ficheros</span>
|
||||
<i class="ti ti-upload ti-xs"></i>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
@ -12,7 +12,7 @@
|
||||
<?= view("themes/vuexy/components/modals/modalDireccion") ?>
|
||||
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
|
||||
|
||||
<div class="col-12">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
<?= csrf_field() ?>
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
<div class="bs-stepper-header">
|
||||
|
||||
<div class="step active titulos-menu" data-target="#datos-generales">
|
||||
<div <?= ($state == 2)? 'hidden': '' ?> class="step active titulos-menu" data-target="#datos-generales">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-info-circle ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -38,7 +38,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="step titulos-menu" data-target="#interior-libro">
|
||||
<div <?= ($state == 2)? 'hidden': '' ?> class="step titulos-menu" data-target="#interior-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-book ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -47,7 +47,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="step titulos-menu" data-target="#cubierta-libro">
|
||||
<div <?= ($state == 2)? 'hidden': '' ?> class="step titulos-menu" data-target="#cubierta-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-books ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -56,7 +56,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="step titulos-menu" data-target="#direcciones-libro">
|
||||
<div <?= ($state == 2)? 'hidden': '' ?> class="step titulos-menu" data-target="#direcciones-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-map-pins ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -65,7 +65,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="step titulos-menu" data-target="#resumen-libro">
|
||||
<div id="menu_resumen_button" class="step titulos-menu" data-target="#resumen-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-checkbox ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -87,26 +87,30 @@
|
||||
|
||||
<form id="presupuesto-cliente-form" onsubmit="return false">
|
||||
|
||||
<div id="datos-generales" class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div <?= ($state == 2) ? 'hidden' : '' ?> id="datos-generales"
|
||||
class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
|
||||
<div class="row g-3">
|
||||
<?= view("themes/vuexy/form/presupuestos/cliente/items/_datosGenerales") ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="interior-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div <?= ($state == 2) ? 'hidden' : '' ?> id="interior-libro"
|
||||
class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div class="row g-3">
|
||||
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioInterior") ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="cubierta-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div <?= ($state == 2) ? 'hidden' : '' ?> id="cubierta-libro"
|
||||
class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div class="row g-3">
|
||||
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta") ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="direcciones-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div <?= ($state == 2) ? 'hidden' : '' ?> id="direcciones-libro"
|
||||
class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div class="row g-3">
|
||||
<?= view("themes/vuexy/form/presupuestos/cliente/items/_direcciones") ?>
|
||||
</div>
|
||||
@ -132,8 +136,8 @@
|
||||
<div id="form_buttons" class="row col-sm-12 justify-content-center" style="display: none;">
|
||||
|
||||
</div>
|
||||
<?php if($formAction == 'edit'): ?>
|
||||
<?= view("themes/vuexy/components/chat_internal_presupuesto",data:["modelId" => $presupuestoId,"type" => "presupuesto"]) ?>
|
||||
<?php if ($formAction == 'edit'): ?>
|
||||
<?= view("themes/vuexy/components/chat_internal_presupuesto", data: ["modelId" => $presupuestoId, "type" => "presupuesto"]) ?>
|
||||
<?php endif; ?>
|
||||
</div><!--//.row -->
|
||||
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
|
||||
@ -166,5 +170,5 @@
|
||||
|
||||
<script type="module"
|
||||
src="<?= site_url('assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js') ?>"></script>
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -64,9 +64,8 @@ class DatosGenerales {
|
||||
|
||||
// Selects
|
||||
this.formatoLibro.init();
|
||||
if (!$(this.excluirRotativa).prop('hidden')){
|
||||
this.cliente.init();
|
||||
}
|
||||
this.cliente.init();
|
||||
|
||||
|
||||
// Inicializa el tipo de impresion
|
||||
this.#handlePaginas();
|
||||
@ -386,11 +385,9 @@ class DatosGenerales {
|
||||
this.coleccion.val(datos.coleccion);
|
||||
this.referenciaCliente.val(datos.referenciaCliente);
|
||||
|
||||
if (!$(this.excluirRotativa).prop('hidden')){
|
||||
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
|
||||
this.cliente.setVal(datos.clienteId);
|
||||
$(this.cliente).trigger('change');
|
||||
}
|
||||
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
|
||||
this.cliente.setVal(datos.clienteId);
|
||||
$(this.cliente).trigger('change');
|
||||
|
||||
if (datos.excluirRotativa) {
|
||||
this.excluirRotativa.prop('checked', true);
|
||||
@ -440,7 +437,7 @@ class DatosGenerales {
|
||||
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
|
||||
}
|
||||
|
||||
getCliente(){
|
||||
getCliente() {
|
||||
if ($(this.excluirRotativa).prop('hidden'))
|
||||
return $('#clienteId').val();
|
||||
return this.cliente.getVal();
|
||||
|
||||
@ -61,8 +61,15 @@ class PresupuestoCliente {
|
||||
this.disenioInterior.init();
|
||||
this.disenioCubierta.init();
|
||||
this.direcciones.init();
|
||||
if (window.location.href.includes("edit")) {
|
||||
this.resumen.init(window.location.href.split("/").pop());
|
||||
}
|
||||
else {
|
||||
this.resumen.init();
|
||||
}
|
||||
|
||||
|
||||
if(this.datosGenerales.excluirRotativa.length == 0){
|
||||
if (this.datosGenerales.excluirRotativa.length == 0) {
|
||||
|
||||
this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() })
|
||||
}
|
||||
@ -71,6 +78,7 @@ class PresupuestoCliente {
|
||||
this.btnNext.on('click', this.#nextStep.bind(this));
|
||||
this.btnPrev.on('click', this.#prevtStep.bind(this));
|
||||
this.btnSave.on('click', this.#savePresupuesto.bind(this));
|
||||
this.btnConfirm.on('click', this.#confirmPresupuesto.bind(this));
|
||||
|
||||
this.titulosMenu.on('click', this.#handleTitulosMenu.bind(this));
|
||||
|
||||
@ -88,7 +96,6 @@ class PresupuestoCliente {
|
||||
}
|
||||
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -362,10 +369,27 @@ class PresupuestoCliente {
|
||||
}
|
||||
|
||||
|
||||
#confirmPresupuesto() {
|
||||
|
||||
this.#solicitudGuardarPresupuesto(true);
|
||||
}
|
||||
|
||||
|
||||
#savePresupuesto() {
|
||||
|
||||
this.#solicitudGuardarPresupuesto(false);
|
||||
}
|
||||
|
||||
|
||||
#solicitudGuardarPresupuesto(confirmar = false) {
|
||||
|
||||
this.#getDatos(true);
|
||||
|
||||
if (confirmar) {
|
||||
this.datos["confirmar"] = 1;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$('#loader').modal('show');
|
||||
|
||||
@ -599,17 +623,28 @@ class PresupuestoCliente {
|
||||
this.calcularPresupuesto = false;
|
||||
|
||||
this.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
if (!$(this.datosGenerales.excluirRotativa).prop("hidden")) {
|
||||
this.direcciones.handleChangeCliente();
|
||||
}
|
||||
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);
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
$('#loader').modal('hide');
|
||||
this.calcularPresupuesto = true;
|
||||
this.checkForm({ target: { id: 'tirada' } });
|
||||
|
||||
if (response.data.state != 2) {
|
||||
|
||||
this.calcularPresupuesto = true;
|
||||
this.checkForm({ target: { id: 'tirada' } });
|
||||
}
|
||||
else {
|
||||
$('#menu_resumen_button').trigger('click');
|
||||
setTimeout(() => {
|
||||
this.resumen.init_dropzone();
|
||||
this.resumen.generate_total(response.data.resumen.base, response.data.resumen.precio_unidad);
|
||||
}, 0);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
|
||||
@ -53,13 +53,133 @@ class Resumen {
|
||||
this.divPreview = $(this.domItem.find("#pv_ec_shape"));
|
||||
this.btnPreviewCubierta = $(this.domItem.find("#btnPreviewCubierta"));
|
||||
|
||||
this.init();
|
||||
this.submitFiles = $(this.domItem.find("#submit-all-files"));
|
||||
|
||||
this.dropzone = null;
|
||||
this.presupuesto_id = -1;
|
||||
}
|
||||
|
||||
|
||||
init() {
|
||||
init(presupuesto_id = -1) {
|
||||
|
||||
this.btnPreviewCubierta.on('click', this.#btnPreview.bind(this));
|
||||
|
||||
this.submitFiles.on('click', this.#btnUploadFiles.bind(this));
|
||||
|
||||
if (presupuesto_id != -1) {
|
||||
this.presupuesto_id = presupuesto_id;
|
||||
}
|
||||
}
|
||||
|
||||
init_dropzone(presupuesto_id) {
|
||||
|
||||
Dropzone.autoDiscover = false;
|
||||
|
||||
const previewTemplate = `<div class="dz-preview dz-file-preview">
|
||||
<div class="dz-details">
|
||||
<div class="dz-thumbnail">
|
||||
<!---<img data-dz-thumbnail>
|
||||
<span class="dz-nopreview">No preview</span> --->
|
||||
<div class="dz-success-mark"></div>
|
||||
<div class="dz-error-mark"></div>
|
||||
<div class="dz-error-message"><span data-dz-errormessage></span></div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-primary" role="progressbar" aria-valuemin="0" aria-valuemax="100" data-dz-uploadprogress></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dz-filename" data-dz-name></div>
|
||||
<div class="dz-size" data-dz-size></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
this.dropzone = new Dropzone('#dropzone-multi', {
|
||||
url: "/presupuestos/presupuestocliente/upload_files",
|
||||
addRemoveLinks: true,
|
||||
previewTemplate: previewTemplate,
|
||||
paramName: "file",
|
||||
uploadMultiple: true,
|
||||
parallelUploads: 4, // Ajusta este número al máximo número de archivos que esperas subir a la vez
|
||||
maxFiles: 5, // Ajusta este número al máximo número de archivos que esperas subir a la vez
|
||||
autoProcessQueue: true,
|
||||
dictRemoveFile: "Eliminar",
|
||||
acceptedFiles: 'image/*, application/pdf',
|
||||
maxFilesize: 5e+7, // Bytes
|
||||
init: function () {
|
||||
let thisDropzone = this;
|
||||
$('#loader').show();
|
||||
|
||||
$.ajax({
|
||||
url: "/presupuestos/presupuestocliente/get_files",
|
||||
type: 'POST',
|
||||
data: { presupuesto_id: presupuesto_id },
|
||||
|
||||
}).done(function (response) {
|
||||
if (response == null || response == "") {
|
||||
return;
|
||||
}
|
||||
let values = JSON.parse(response);
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
var mockFile = { name: values[i].name, size: values[i].size, hash: values[i].hash };
|
||||
|
||||
thisDropzone.files.push(mockFile); // add to files array
|
||||
thisDropzone.emit("addedfile", mockFile);
|
||||
thisDropzone.emit("thumbnail", mockFile, window.location.host + "/sistema/intranet/presupuestos/" + values[i].hash);
|
||||
thisDropzone.emit("complete", mockFile);
|
||||
thisDropzone.options.success.call(thisDropzone, mockFile);
|
||||
};
|
||||
}).always(function () {
|
||||
$('#loader').hide();
|
||||
});
|
||||
|
||||
this.on("addedfile", function (file) {
|
||||
if (file.hash) {
|
||||
var viewButton = Dropzone.createElement("<span class='dz-remove'>Ver</span>");
|
||||
file.previewElement.appendChild(viewButton);
|
||||
// Listen to the view button click event
|
||||
viewButton.addEventListener("click", function (e) {
|
||||
|
||||
window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/presupuestos/" + file.hash, '_blank');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#btnUploadFiles() {
|
||||
|
||||
var files = this.dropzone.files;
|
||||
$('#loader').show();
|
||||
|
||||
var formData = new FormData();
|
||||
var oldFiles = [];
|
||||
var counter = 0;
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
|
||||
if (files[i].upload) {
|
||||
var file = files[i];
|
||||
formData.append('file[' + counter + ']', file);
|
||||
counter += 1;
|
||||
}
|
||||
else {
|
||||
oldFiles.push(files[i].name);
|
||||
}
|
||||
}
|
||||
formData.append('oldFiles', JSON.stringify(oldFiles));
|
||||
|
||||
formData.append('presupuesto_id', this.presupuesto_id);
|
||||
|
||||
$.ajax({
|
||||
url: "/presupuestos/presupuestocliente/upload_files",
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false, // Indicar a jQuery que no procese los datos
|
||||
contentType: false // Indicar a jQuery que no establezca el tipo de contenido
|
||||
}).done(function (response) {
|
||||
|
||||
}).always(function () {
|
||||
$('#loader').hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -178,15 +298,15 @@ class Resumen {
|
||||
const tarjetaPrecio = $('.tarjeta-tiradas-precios').filter(function () {
|
||||
return parseInt($(this).find('.tarjeta-tiradas-precios-tirada').attr('data')) == unidades;
|
||||
});
|
||||
|
||||
|
||||
let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text();
|
||||
|
||||
let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text();
|
||||
precio_u_text = precio_u_text.replace('€/u', '');
|
||||
precio_u_text = this.#changeDecimalFormat(precio_u_text);
|
||||
|
||||
|
||||
const base = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio').attr('data');
|
||||
let base_text = this.#changeDecimalFormat(base);
|
||||
|
||||
|
||||
const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04;
|
||||
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
|
||||
let iva_text = this.#changeDecimalFormat(iva);
|
||||
@ -202,6 +322,28 @@ class Resumen {
|
||||
|
||||
}
|
||||
|
||||
generate_total(base, precio_u) {
|
||||
|
||||
let precio_u_text = String(precio_u);
|
||||
precio_u_text = precio_u_text.replace('€/u', '');
|
||||
precio_u_text = this.#changeDecimalFormat(precio_u_text);
|
||||
|
||||
let base_text = this.#changeDecimalFormat(String(base));
|
||||
|
||||
const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04;
|
||||
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
|
||||
let iva_text = this.#changeDecimalFormat(iva);
|
||||
|
||||
const total = (parseFloat(base) + parseFloat(iva)).toFixed(2);
|
||||
let total_text = this.#changeDecimalFormat(total);
|
||||
|
||||
this.precio_unidad.text(precio_u_text);
|
||||
this.total_base.text(base_text);
|
||||
this.iva_porcentaje.text(this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? '21' : '4');
|
||||
this.iva.text(iva_text);
|
||||
this.total.text(total_text);
|
||||
}
|
||||
|
||||
|
||||
#capitalizeFirstLetter(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
@ -209,7 +351,7 @@ class Resumen {
|
||||
|
||||
|
||||
#changeDecimalFormat(number) {
|
||||
|
||||
|
||||
let cleanedNumber = String(number).replace(/[^\d.]/g, '');
|
||||
let partes = cleanedNumber.split('.');
|
||||
partes[0] = partes[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');
|
||||
|
||||
Reference in New Issue
Block a user