mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
corregidos varios fallos en el importador. Añadidos avisos de error y success al importar
This commit is contained in:
@ -201,7 +201,7 @@ class Importadorpresupuestos extends \App\Controllers\BaseResourceController
|
|||||||
'libroFresadoTapaDura' => 'Tapa Dura al Cromo Fresada',
|
'libroFresadoTapaDura' => 'Tapa Dura al Cromo Fresada',
|
||||||
'libroFresadoTapaBlanda' => 'Rústica Fresada',
|
'libroFresadoTapaBlanda' => 'Rústica Fresada',
|
||||||
'libroCosidoTapaDura' => 'Tapa Dura al Cromo Cosida Hilo',
|
'libroCosidoTapaDura' => 'Tapa Dura al Cromo Cosida Hilo',
|
||||||
'libroCosidoTapaBlanda' => 'Rústica Cosida Hilo vegetal',
|
'libroCosidoTapaBlanda' => 'Rústica Cosido Hilo vegetal',
|
||||||
'libroEspiralTapaDura' => 'Espiral',
|
'libroEspiralTapaDura' => 'Espiral',
|
||||||
'libroGrapado' => 'Cosido a caballete 2 grapas'
|
'libroGrapado' => 'Cosido a caballete 2 grapas'
|
||||||
];
|
];
|
||||||
|
|||||||
@ -478,7 +478,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$direcciones = $reqData['direcciones'] ?? [];
|
$direcciones = $reqData['direcciones'] ?? [];
|
||||||
|
|
||||||
$tipo_impresion_id = intval($reqData['tipo_presupuesto_id'] ?? 0) == 0?
|
$tipo_impresion_id = intval($reqData['tipo_presupuesto_id'] ?? 0) == 0 ?
|
||||||
$this->getTipoImpresion($tipo, $cubierta['tipoCubierta']) : intval($reqData['tipo_presupuesto_id']);
|
$this->getTipoImpresion($tipo, $cubierta['tipoCubierta']) : intval($reqData['tipo_presupuesto_id']);
|
||||||
$lomoRedondo = $cubierta['lomoRedondo'] ?? 0;
|
$lomoRedondo = $cubierta['lomoRedondo'] ?? 0;
|
||||||
|
|
||||||
@ -1002,7 +1002,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$direcciones = $reqData['direcciones'] ?? [];
|
$direcciones = $reqData['direcciones'] ?? [];
|
||||||
|
|
||||||
if($tipo != "")
|
if ($tipo != "")
|
||||||
$tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']);
|
$tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']);
|
||||||
else
|
else
|
||||||
$tipo_impresion_id = $reqData['tipo_presupuesto_id'] ?? 0;
|
$tipo_impresion_id = $reqData['tipo_presupuesto_id'] ?? 0;
|
||||||
@ -1087,19 +1087,28 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$errors = $resultado_presupuesto['errors'];
|
$errors = $resultado_presupuesto['errors'];
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $error) {
|
||||||
if (!empty($error)) {
|
if (!empty($error)) {
|
||||||
return $this->respond([
|
if ($this->request) {
|
||||||
'error' => $error,
|
return $this->respond([
|
||||||
]);
|
'error' => $error,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (isset($resultado_presupuesto['exception'])) {
|
} else if (isset($resultado_presupuesto['exception'])) {
|
||||||
return $this->respond([
|
if($this->request) {
|
||||||
'error' => $resultado_presupuesto['exception'],
|
return $this->respond([
|
||||||
'file' => $resultado_presupuesto['file'],
|
'error' => $resultado_presupuesto['exception'],
|
||||||
'line' => $resultado_presupuesto['line'],
|
'file' => $resultado_presupuesto['file'],
|
||||||
]);
|
'line' => $resultado_presupuesto['line'],
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return $resultado_presupuesto['exception'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// seleccionamos el peso de la tirada seleccionada
|
// seleccionamos el peso de la tirada seleccionada
|
||||||
$peso_libro = $resultado_presupuesto['peso'][array_search($selected_tirada, $tirada)];
|
$peso_libro = $resultado_presupuesto['peso'][array_search($selected_tirada, $tirada)];
|
||||||
|
|
||||||
@ -1893,14 +1902,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
return $current->precio < $previous->precio ? $current : $previous;
|
return $current->precio < $previous->precio ? $current : $previous;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (count($tarifas_envio) > 0){
|
if (count($tarifas_envio) > 0) {
|
||||||
$tarifa_envio_final = $tarifas_envio[0];
|
$tarifa_envio_final = $tarifas_envio[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$coste = $tarifa_envio_final->precio;
|
$coste = $tarifa_envio_final->precio;
|
||||||
$margen = $tarifa_envio_final->margen;
|
$margen = $tarifa_envio_final->margen;
|
||||||
|
|
||||||
if(!isset($return_data['id'])){
|
if (!isset($return_data['id'])) {
|
||||||
$return_data['id'] = $tarifa_envio_final->id;
|
$return_data['id'] = $tarifa_envio_final->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -251,7 +251,23 @@ $("#fecha_entrega_externo").flatpickr({
|
|||||||
|
|
||||||
<?php if ($pedidoEntity->estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?>
|
<?php if ($pedidoEntity->estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?>
|
||||||
$('.buton-estado').on('click', function() {
|
$('.buton-estado').on('click', function() {
|
||||||
var id = <?=$pedidoEntity->id ?>;
|
Swal.fire({
|
||||||
|
title: '¿Estás seguro?',
|
||||||
|
text: "Esta acción no se puede deshacer",
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
cancelButtonColor: '#d33',
|
||||||
|
confirmButtonText: 'Sí',
|
||||||
|
cancelButtonText: 'Cancelar',
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary me-1',
|
||||||
|
cancelButton: 'btn btn-label-secondary'
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
var id = <?=$pedidoEntity->id ?>;
|
||||||
var estado = $(this).attr('id').split('_')[1];
|
var estado = $(this).attr('id').split('_')[1];
|
||||||
var url = '<?= route_to('cambiarEstadoPedido') ?>';
|
var url = '<?= route_to('cambiarEstadoPedido') ?>';
|
||||||
var data = {
|
var data = {
|
||||||
@ -273,6 +289,10 @@ $('.buton-estado').on('click', function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||||
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||||
|
|
||||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||||
|
|
||||||
|
|
||||||
@ -370,33 +369,31 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3 mb-3">
|
<div class="col-md-3 mb-3">
|
||||||
<button id="makeImport" class="btn btn-primary waves-effect waves-light mt-auto w-100">
|
<button id="makeImport" class="btn btn-primary waves-effect waves-light mt-auto w-100" disabled>
|
||||||
Importar presupuesto
|
Importar presupuesto
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div><!--//.card -->
|
</div><!--//.card -->
|
||||||
|
|
||||||
</div><!--//.card-body -->
|
</div><!--//.card-body -->
|
||||||
|
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
</div><!--//.card-footer -->
|
</div><!--//.card-footer -->
|
||||||
|
|
||||||
</div><!--//.card -->
|
</div><!--//.card -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
</div><!--//.row -->
|
</div><!--//.row -->
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
<?= $this->section('css') ?>
|
||||||
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||||
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
<?= $this->section('additionalExternalJs') ?>
|
||||||
<?= $this->section('css') ?>
|
<script type="module"
|
||||||
|
src="<?= site_url('assets/js/safekat/pages/importadorPresupuestos/importador.js') ?>"></script>
|
||||||
<?= $this->endSection() ?>
|
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||||
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
<?= $this->section('additionalExternalJs') ?>
|
|
||||||
<script type="module"
|
|
||||||
src="<?= site_url('assets/js/safekat/pages/importadorPresupuestos/importador.js') ?>"></script>
|
|
||||||
<?= $this->endSection() ?>
|
|
||||||
@ -126,7 +126,7 @@ class Importador {
|
|||||||
this.makeImport.on('click', this.importPresupuesto.bind(this));
|
this.makeImport.on('click', this.importPresupuesto.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
importPresupuesto(){
|
importPresupuesto() {
|
||||||
|
|
||||||
if ($("#clienteId").val() != '' && $("#presupuesto").val() != '') {
|
if ($("#clienteId").val() != '' && $("#presupuesto").val() != '') {
|
||||||
let data = this.collectData();
|
let data = this.collectData();
|
||||||
@ -137,11 +137,45 @@ class Importador {
|
|||||||
(response) => {
|
(response) => {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
const urlObj = new URL(window.location.href);
|
const urlObj = new URL(window.location.href);
|
||||||
window.open(`${urlObj.origin}` + '/presupuestoadmin/edit/' + response.id);
|
Swal.fire({
|
||||||
|
title: 'Atención!',
|
||||||
|
text: 'Esto es una importación básica, por favor revisa los datos para comprobar que no hay errores. ' +
|
||||||
|
'Tenga en cuenta que no todos los servicios se pueden importar.',
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: false,
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
confirmButtonText: 'Ok',
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary me-1',
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
}).then(() => {
|
||||||
|
window.open(`${urlObj.origin}` + '/presupuestoadmin/edit/' + response.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Error',
|
||||||
|
text: 'No ha sido posible importar el presupuesto. Póngase en contacto con el administrador.',
|
||||||
|
icon: 'error',
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary'
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
console.error(error);
|
Swal.fire({
|
||||||
|
title: 'Error',
|
||||||
|
text: 'Ha habido un error al intentar importar el presupuesto. Asegúrese de que están todos los campos rellenos.',
|
||||||
|
icon: 'error',
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary'
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
).post();
|
).post();
|
||||||
}
|
}
|
||||||
@ -158,7 +192,7 @@ class Importador {
|
|||||||
data.paginas = $('#paginas').val();
|
data.paginas = $('#paginas').val();
|
||||||
data.tirada = $('#tirada').val();
|
data.tirada = $('#tirada').val();
|
||||||
data.papel_formato_id = $('#tamanio').val();
|
data.papel_formato_id = $('#tamanio').val();
|
||||||
data.papel_formato_personalizado = $('#papelFormatoPersonalizado').prop('checked')?1:0;
|
data.papel_formato_personalizado = $('#papelFormatoPersonalizado').prop('checked') ? 1 : 0;
|
||||||
data.papel_formato_ancho = $('#papelFormatoAncho').val();
|
data.papel_formato_ancho = $('#papelFormatoAncho').val();
|
||||||
data.papel_formato_alto = $('#papelFormatoAlto').val();
|
data.papel_formato_alto = $('#papelFormatoAlto').val();
|
||||||
|
|
||||||
@ -186,17 +220,17 @@ class Importador {
|
|||||||
data.acabado_sobrecubierta = this.acabadosSobrecubierta.getVal();
|
data.acabado_sobrecubierta = this.acabadosSobrecubierta.getVal();
|
||||||
|
|
||||||
data.servicios = {
|
data.servicios = {
|
||||||
marcapaginas: $('#marcapaginas').prop('checked')?1:0,
|
marcapaginas: $('#marcapaginas').prop('checked') ? 1 : 0,
|
||||||
serviciosExtra: []
|
serviciosExtra: []
|
||||||
};
|
};
|
||||||
|
|
||||||
if($('#ferro').prop('checked')){
|
if ($('#ferro').prop('checked')) {
|
||||||
data.servicios.serviciosExtra.push(30);
|
data.servicios.serviciosExtra.push(30);
|
||||||
}
|
}
|
||||||
if($('#ferroDigital').prop('checked')){
|
if ($('#ferroDigital').prop('checked')) {
|
||||||
data.servicios.serviciosExtra.push(29);
|
data.servicios.serviciosExtra.push(29);
|
||||||
}
|
}
|
||||||
if($('#prototipo').prop('checked')){
|
if ($('#prototipo').prop('checked')) {
|
||||||
data.servicios.serviciosExtra.push(9);
|
data.servicios.serviciosExtra.push(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +276,6 @@ class Importador {
|
|||||||
|
|
||||||
fillInitialData(data) {
|
fillInitialData(data) {
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
$('#paginas').val(data.datosGenerales.paginas);
|
$('#paginas').val(data.datosGenerales.paginas);
|
||||||
$('#tirada').val(data.datosGenerales.tirada);
|
$('#tirada').val(data.datosGenerales.tirada);
|
||||||
if (data.datosGenerales.papel_formato_personalizado) {
|
if (data.datosGenerales.papel_formato_personalizado) {
|
||||||
@ -386,8 +419,8 @@ class Importador {
|
|||||||
$('#prototipo').prop('checked', false);
|
$('#prototipo').prop('checked', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.makeImport.prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user