mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 00:48:49 +00:00
aceptando ferro
This commit is contained in:
@ -40,4 +40,6 @@ databaseChangeLog:
|
||||
- include:
|
||||
file: db/changelog/changesets/0020-add-estados-pago-to-pedidos-lineas-2.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0021-add-email-and-is-palets-to-pedidos-direcciones.yml
|
||||
file: db/changelog/changesets/0021-add-email-and-is-palets-to-pedidos-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0022-add-estados-pago-to-pedidos-lineas-3.yml
|
||||
@ -51,4 +51,16 @@ pedido.table.estado=Estado
|
||||
pedido.table.acciones=Acciones
|
||||
|
||||
pedido.view.tirada=Tirada
|
||||
pedido.view.view-presupuesto=Ver presupuesto
|
||||
pedido.view.view-presupuesto=Ver presupuesto
|
||||
pedido.view.aceptar-ferro=Aceptar ferro
|
||||
pedido.view.ferro-download=Descargar ferro
|
||||
pedido.view.cub-download=Descargar cubierta
|
||||
pedido.view.tapa-download=Descargar tapa
|
||||
|
||||
pedido.errors.linea-not-found=No se ha encontrado la línea de pedido.
|
||||
pedido.errors.state-error=Estado de línea no válido.
|
||||
pedido.errors.update-server-error=Error al actualizar el estado desde el servidor externo.
|
||||
pedido.errors.connecting-server-error=Error al conectar con el servidor externo.
|
||||
pedido.errors.cannot-update=No se puede actualizar el estado de una línea con ese estado inicial.
|
||||
pedido.success.estado-actualizado=Estado del pedido actualizado correctamente.
|
||||
pedido.success.same-estado=Sin cambios en el estado.
|
||||
@ -1,4 +1,4 @@
|
||||
$(()=>{
|
||||
$(() => {
|
||||
const csrfToken = document.querySelector('meta[name="_csrf"]')?.getAttribute('content');
|
||||
const csrfHeader = document.querySelector('meta[name="_csrf_header"]')?.getAttribute('content');
|
||||
if (window.$ && csrfToken && csrfHeader) {
|
||||
@ -11,26 +11,131 @@ $(()=>{
|
||||
|
||||
const language = document.documentElement.lang || 'es-ES';
|
||||
|
||||
|
||||
$(document).on('click', '.update-status-item', function(){
|
||||
|
||||
$(document).on('click', '.update-status-item', function () {
|
||||
const lineaId = $(this).data('linea-id');
|
||||
if(!lineaId){
|
||||
if (!lineaId) {
|
||||
console.error('No se ha encontrado el ID de la línea del pedido.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Llamada AJAX para actualizar el estado del pedido
|
||||
$.ajax({
|
||||
url: `/imprimelibros/pedidos/linea/${lineaId}/update-status`,
|
||||
url: `/pedidos/linea/${lineaId}/update-status`,
|
||||
type: 'POST',
|
||||
success: function(response) {
|
||||
alert('Estado del pedido actualizado correctamente.');
|
||||
// Aquí puedes agregar lógica adicional, como actualizar la interfaz de usuario
|
||||
success: function (response) {
|
||||
if (!response || !response.success) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: response.message || "Error",
|
||||
timer: 1800,
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2',
|
||||
cancelButton: 'btn btn-light'
|
||||
},
|
||||
showConfirmButton: false
|
||||
});
|
||||
}
|
||||
else {
|
||||
const estadoSpan = $(`.estado-linea[data-linea-id='${lineaId}']`);
|
||||
if (estadoSpan.length) {
|
||||
estadoSpan.text(response.state);
|
||||
}
|
||||
if(response.stateKey === 'terminado' || response.stateKey === 'cancelado') {
|
||||
$(`.update-estado-button[data-linea-id='${lineaId}']`)
|
||||
.closest('.update-estado-button')
|
||||
.addClass('d-none');
|
||||
}
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: response.message || "Exito",
|
||||
timer: 1800,
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2',
|
||||
cancelButton: 'btn btn-light'
|
||||
},
|
||||
showConfirmButton: false
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
error: function (xhr, status, error) {
|
||||
console.error('Error al actualizar el estado del pedido:', error);
|
||||
alert('Hubo un error al actualizar el estado del pedido.');
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: xhr.responseJSON?.message || 'Error',
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2', // clases para el botón confirmar
|
||||
cancelButton: 'btn btn-light' // clases para cancelar
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.maquetacion-ok', function () {
|
||||
|
||||
const lineaId = $(this).data('linea-id');
|
||||
if (!lineaId) {
|
||||
console.error('No se ha encontrado el ID de la línea del pedido.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Llamada AJAX para marcar la maquetación como OK
|
||||
$.ajax({
|
||||
url: `/pedidos/linea/${lineaId}/update-maquetacion`,
|
||||
type: 'POST',
|
||||
success: function (response) {
|
||||
if (!response || !response.success) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: response.message || "Error",
|
||||
timer: 1800,
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2',
|
||||
cancelButton: 'btn btn-light'
|
||||
},
|
||||
showConfirmButton: false
|
||||
});
|
||||
}
|
||||
else {
|
||||
const estadoSpan = $(`.estado-linea[data-linea-id='${lineaId}']`);
|
||||
if (estadoSpan.length) {
|
||||
estadoSpan.text(response.state);
|
||||
// hide the maquetacion-ok button
|
||||
$(`.maquetacion-ok[data-linea-id='${lineaId}']`)
|
||||
.closest('.maquetacion-ok-button')
|
||||
.addClass('d-none');
|
||||
}
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: response.message || "Exito",
|
||||
timer: 1800,
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2',
|
||||
cancelButton: 'btn btn-light'
|
||||
},
|
||||
showConfirmButton: false
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error('Error al actualizar la maquetación del pedido:', error);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: xhr.responseJSON?.message || 'Error',
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2', // clases para el botón confirmar
|
||||
cancelButton: 'btn btn-light' // clases para cancelar
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
})
|
||||
@ -0,0 +1,81 @@
|
||||
$(() => {
|
||||
if ($(".btn-download-ferro").length) {
|
||||
$(document).on('click', '.btn-download-ferro', function () {
|
||||
const lineaId = $(this).data('linea-id');
|
||||
|
||||
window.open(`/pedidos/linea/${lineaId}/download-ferro`, '_blank');
|
||||
});
|
||||
}
|
||||
if ($(".btn-download-cub").length) {
|
||||
$(document).on('click', '.btn-download-cub', function () {
|
||||
const lineaId = $(this).data('linea-id');
|
||||
|
||||
window.open(`/pedidos/linea/${lineaId}/download-cub`, '_blank');
|
||||
});
|
||||
}
|
||||
if ($(".btn-download-tapa").length) {
|
||||
$(document).on('click', '.btn-download-tapa', function () {
|
||||
const lineaId = $(this).data('linea-id');
|
||||
|
||||
window.open(`/pedidos/linea/${lineaId}/download-tapa`, '_blank');
|
||||
});
|
||||
}
|
||||
|
||||
if ($(".btn-aceptar-ferro").length) {
|
||||
$(document).on('click', '.btn-aceptar-ferro', function () {
|
||||
const lineaId = $(this).data('linea-id');
|
||||
|
||||
$.ajax({
|
||||
url: `/pedidos/linea/${lineaId}/aceptar-ferro`,
|
||||
type: 'POST',
|
||||
success: function (response) {
|
||||
if (!response || !response.success) {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: response.message || "Error",
|
||||
timer: 1800,
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2',
|
||||
cancelButton: 'btn btn-light'
|
||||
},
|
||||
showConfirmButton: false
|
||||
});
|
||||
}
|
||||
else {
|
||||
const estadoSpan = $(`.estado-linea[data-linea-id='${lineaId}']`);
|
||||
if (estadoSpan.length) {
|
||||
estadoSpan.text(response.state);
|
||||
}
|
||||
$(`.btn-aceptar-ferro[data-linea-id='${lineaId}']`)
|
||||
.closest('.btn-aceptar-ferro')
|
||||
.addClass('d-none');
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: response.message || "Exito",
|
||||
timer: 1800,
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2',
|
||||
cancelButton: 'btn btn-light'
|
||||
},
|
||||
showConfirmButton: false
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error('Error al aceptar el ferro del pedido:', error);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: xhr.responseJSON?.message || 'Error',
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-secondary me-2', // clases para el botón confirmar
|
||||
cancelButton: 'btn btn-light' // clases para cancelar
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -62,10 +62,38 @@
|
||||
</h5>
|
||||
<p class="text-muted mt-4 mb-1" th:text="#{pedido.table.estado}">Estado</p>
|
||||
<h5 class="fs-14 mb-0">
|
||||
<span th:text="${item.estado != null} ?
|
||||
<span class="estado-linea" th:attr="data-linea-id=${item.lineaId}" th:text="${item.estado != null} ?
|
||||
#{__${'pedido.estado.' + item.estado}__} : '-'">
|
||||
</span>
|
||||
</h5>
|
||||
<div class="col-12 d-grid gap-2 mt-2">
|
||||
<button th:if="${item.estado.name == 'esperando_aceptacion_ferro'}" type="button"
|
||||
class="btn btn-secondary w-100 btn-aceptar-ferro" th:text="#{pedido.view.aceptar-ferro}"
|
||||
th:attr="data-linea-id=${item.lineaId}">
|
||||
Aceptar ferro
|
||||
</button>
|
||||
|
||||
<button th:if="${item.estado.priority >= 7 && item.estado.priority < 11 && item.buttons.ferro}"
|
||||
type="button" class="btn btn-light w-100 btn-download-ferro"
|
||||
th:text="#{pedido.view.ferro-download}"
|
||||
th:attr="data-linea-id=${item.lineaId}">
|
||||
Descargar ferro
|
||||
</button>
|
||||
|
||||
<button th:if="${item.estado.priority >= 7 && item.estado.priority < 11 && item.buttons.cub}"
|
||||
type="button" class="btn btn-light w-100 btn-download-cub"
|
||||
th:text="#{pedido.view.cub-download}"
|
||||
th:attr="data-linea-id=${item.lineaId}">
|
||||
Descargar cubierta
|
||||
</button>
|
||||
|
||||
<button th:if="${item.estado.priority >= 7 && item.estado.priority < 11 && item.buttons.tapa}"
|
||||
type="button" class="btn btn-light w-100 btn-download-tapa"
|
||||
th:text="#{pedido.view.tapa-download}"
|
||||
th:attr="data-linea-id=${item.lineaId}">
|
||||
Descargar tapa
|
||||
</button>
|
||||
</div>
|
||||
<th:block th:if="${item.fechaEntrega != null and item.fechaEntrega != ''}">
|
||||
<p class="text-muted mt-4 mb-1" th:text="#{pedido.fecha-entrega}">Fecha de entrega</p>
|
||||
<h5 class="fs-14 mb-0">
|
||||
@ -88,7 +116,8 @@
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row g-3">
|
||||
<div th:each="direccionEnvio : ${item.direccionesEntrega}" class="mb-3 col-xl-4 col-lg-6 col-md-12 col-sm-12">
|
||||
<div th:each="direccionEnvio : ${item.direccionesEntrega}"
|
||||
class="mb-3 col-xl-4 col-lg-6 col-md-12 col-sm-12">
|
||||
<div th:insert="~{imprimelibros/direcciones/direccionEnvioCard :: direccionEnvioCard(
|
||||
direccion=${direccionEnvio},
|
||||
pais=${direccionEnvio.paisNombre}
|
||||
@ -106,7 +135,7 @@
|
||||
<div class="col-sm">
|
||||
<div class="d-flex flex-wrap my-n1">
|
||||
<!-- Botón cancelar -->
|
||||
<div>
|
||||
<div th:if="${item.estado.name != 'cancelado' && item.estado.name != 'terminado'}">
|
||||
<a href="javascript:void(0);" class="d-block text-body p-1 px-2 cancel-item"
|
||||
th:attr="data-linea-id=${item.lineaId}">
|
||||
<i class="ri-delete-bin-fill text-muted align-bottom me-1"><span
|
||||
@ -114,14 +143,15 @@
|
||||
</a>
|
||||
</div>
|
||||
<!-- Actualizar estado-->
|
||||
<div>
|
||||
<div class="update-estado-button"
|
||||
th:if="${item.estado.name != 'cancelado' && item.estado.name != 'maquetacion' && item.estado.name != 'terminado'}">
|
||||
<a href="javascript:void(0);" class="d-block text-body p-1 px-2 update-status-item"
|
||||
th:attr="data-linea-id=${item.lineaId}">
|
||||
<i class="ri-refresh-line text-muted align-bottom me-1"><span
|
||||
th:text="#{pedido.update-estado}">Cancelar Pedido</span></i>
|
||||
th:text="#{pedido.update-estado}">Actualizar estado</span></i>
|
||||
</a>
|
||||
</div>
|
||||
<div th:if="${item.estado == 'maquetacion'}">
|
||||
<div class="maquetacion-ok-button" th:if="${item.estado.name == 'maquetacion'}">
|
||||
<a href="javascript:void(0);" class="d-block text-body p-1 px-2 maquetacion-ok"
|
||||
th:attr="data-linea-id=${item.lineaId}">
|
||||
<i class="ri-check-double-line text-muted align-bottom me-1"><span
|
||||
|
||||
Reference in New Issue
Block a user