+ `,
+ focusConfirm: false,
+ showCancelButton: true,
+ buttonsStyling: false,
+ customClass: {
+ confirmButton: 'btn btn-secondary me-2',
+ cancelButton: 'btn btn-light'
+ },
+ confirmButtonText: window.languageBundle['app.aceptar'] || 'Aceptar',
+ cancelButtonText: window.languageBundle['app.cancelar'] || 'Cancelar',
+
+ preConfirm: () => {
+ const selected = document.querySelector('input[name="paymentMethod"]:checked');
+ if (!selected) {
+ Swal.showValidationMessage(
+ window.languageBundle['checkout.error.select-method'] || 'Selecciona un método de pago'
+ );
+ return false;
+ }
+ return selected.value;
+ }
+ });
+ }
+
+
+})
\ No newline at end of file
diff --git a/src/main/resources/static/assets/js/pages/imprimelibros/pedidos/pedidos-view-admin.js b/src/main/resources/static/assets/js/pages/imprimelibros/pedidos/pedidos-view-admin.js
new file mode 100644
index 0000000..ddc23ae
--- /dev/null
+++ b/src/main/resources/static/assets/js/pages/imprimelibros/pedidos/pedidos-view-admin.js
@@ -0,0 +1,146 @@
+$(() => {
+ const csrfToken = document.querySelector('meta[name="_csrf"]')?.getAttribute('content');
+ const csrfHeader = document.querySelector('meta[name="_csrf_header"]')?.getAttribute('content');
+ if (window.$ && csrfToken && csrfHeader) {
+ $.ajaxSetup({
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader(csrfHeader, csrfToken);
+ }
+ });
+ }
+
+ const language = document.documentElement.lang || 'es-ES';
+
+
+ $(document).on('click', '.update-status-item', 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 actualizar el estado del pedido
+ $.ajax({
+ url: `/pedidos/linea/${lineaId}/update-status`,
+ 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);
+ }
+ 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
+ }).then((result) => {
+ if (result.dismiss === Swal.DismissReason.timer) {
+ location.reload();
+ }
+ });
+ ;
+ }
+ },
+ error: function (xhr, status, error) {
+ console.error('Error al actualizar el estado 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
+ }
+ });
+ }
+ });
+ });
+
+ $(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
+ }
+ });
+ }
+ });
+
+ });
+})
\ No newline at end of file
diff --git a/src/main/resources/static/assets/js/pages/imprimelibros/pedidos/pedidos-view.js b/src/main/resources/static/assets/js/pages/imprimelibros/pedidos/pedidos-view.js
new file mode 100644
index 0000000..17afcaf
--- /dev/null
+++ b/src/main/resources/static/assets/js/pages/imprimelibros/pedidos/pedidos-view.js
@@ -0,0 +1,86 @@
+$(() => {
+ 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
+ }).then((result) => {
+ if (result.dismiss === Swal.DismissReason.timer) {
+ location.reload();
+ }
+ });
+ ;
+ }
+ },
+ 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
+ }
+ });
+ }
+ });
+ });
+ }
+});
\ No newline at end of file
diff --git a/src/main/resources/static/assets/js/pages/imprimelibros/pedidos/pedidos.js b/src/main/resources/static/assets/js/pages/imprimelibros/pedidos/pedidos.js
new file mode 100644
index 0000000..714e19d
--- /dev/null
+++ b/src/main/resources/static/assets/js/pages/imprimelibros/pedidos/pedidos.js
@@ -0,0 +1,68 @@
+import { normalizeNumericFilter } from '../utils.js';
+
+$(() => {
+
+ const csrfToken = document.querySelector('meta[name="_csrf"]')?.getAttribute('content');
+ const csrfHeader = document.querySelector('meta[name="_csrf_header"]')?.getAttribute('content');
+ if (window.$ && csrfToken && csrfHeader) {
+ $.ajaxSetup({
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader(csrfHeader, csrfToken);
+ }
+ });
+ }
+
+ const language = document.documentElement.lang || 'es-ES';
+
+ const tablePedidos = $('#pedidos-datatable').DataTable({
+ processing: true,
+ serverSide: true,
+ orderCellsTop: true,
+ pageLength: 50,
+ lengthMenu: [10, 25, 50, 100, 500],
+ order: [[5, 'desc']], // Ordena por fecha por defecto
+ language: { url: '/assets/libs/datatables/i18n/' + language + '.json' },
+ responsive: true,
+ dom: 'lBrtip',
+ buttons: {
+ dom: {
+ button: {
+ className: 'btn btn-sm btn-outline-primary me-1'
+ },
+ buttons: [
+ { extend: 'copy' },
+ { extend: 'csv' },
+ { extend: 'excel' },
+ { extend: 'pdf' },
+ { extend: 'print' },
+ { extend: 'colvis' }
+ ],
+ }
+ },
+ ajax: {
+ url: '/pedidos/datatable',
+ method: 'GET',
+ },
+ order: [[0, 'desc']],
+ columns: [
+ { data: 'id', name: 'id', orderable: true },
+ { data: 'created_at', name: 'createdAt', orderable: true },
+ { data: 'total', name: 'total', orderable: true },
+ { data: 'estado', name: 'estado', orderable: true },
+ { data: 'actions', name: 'actions', orderable: false, searchable: false }
+
+ ],
+ });
+
+ tablePedidos.on("keyup change", ".input-filter", function () {
+ const colName = $(this).data("col");
+ const colIndex = tablePedidos.settings()[0].aoColumns.findIndex(c => c.name === colName);
+
+ if (colIndex >= 0) {
+ tablePedidos
+ .column(colIndex)
+ .search(normalizeNumericFilter(this.value))
+ .draw();
+ }
+ });
+})
\ No newline at end of file
diff --git a/src/main/resources/static/assets/js/pages/imprimelibros/presupuestador/text-editor.js b/src/main/resources/static/assets/js/pages/imprimelibros/presupuestador/text-editor.js
new file mode 100644
index 0000000..edf997d
--- /dev/null
+++ b/src/main/resources/static/assets/js/pages/imprimelibros/presupuestador/text-editor.js
@@ -0,0 +1,82 @@
+$(() => {
+ var snowEditor = document.querySelectorAll(".snow-editor");
+ if (snowEditor) {
+ Array.from(snowEditor).forEach(function (item) {
+ var snowEditorData = {};
+ var issnowEditorVal = item.classList.contains("snow-editor");
+ if (issnowEditorVal == true) {
+ snowEditorData.theme = 'snow',
+ snowEditorData.modules = {
+ 'toolbar': [
+ [{
+ 'font': []
+ }, {
+ 'size': []
+ }],
+ ['bold', 'italic', 'underline', 'strike'],
+ [{
+ 'color': []
+ }, {
+ 'background': []
+ }],
+ [{
+ 'script': 'super'
+ }, {
+ 'script': 'sub'
+ }],
+ [{
+ 'header': [false, 1, 2, 3, 4, 5, 6]
+ }, 'blockquote', 'code-block'],
+ [{
+ 'list': 'ordered'
+ }, {
+ 'list': 'bullet'
+ }, {
+ 'indent': '-1'
+ }, {
+ 'indent': '+1'
+ }],
+ ['direction', {
+ 'align': []
+ }]
+ ]
+ }
+ }
+ var quill = new Quill(item, snowEditorData);
+
+ var initialContent = item.dataset.contenido || "";
+ // Contenido inicial desde Thymeleaf
+ var initialContent = item.dataset.contenido || "";
+ if (initialContent) {
+ if(initialContent.trim() !== "" && initialContent.trim() !== "
diff --git a/src/main/resources/templates/imprimelibros/direcciones/direccionEnvioCard.html b/src/main/resources/templates/imprimelibros/direcciones/direccionEnvioCard.html
new file mode 100644
index 0000000..bc12b5e
--- /dev/null
+++ b/src/main/resources/templates/imprimelibros/direcciones/direccionEnvioCard.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/imprimelibros/direcciones/direccionFacturacionCard.html b/src/main/resources/templates/imprimelibros/direcciones/direccionFacturacionCard.html
new file mode 100644
index 0000000..9a4a251
--- /dev/null
+++ b/src/main/resources/templates/imprimelibros/direcciones/direccionFacturacionCard.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/imprimelibros/partials/sidebar.html b/src/main/resources/templates/imprimelibros/partials/sidebar.html
index e811ed6..a972ae7 100644
--- a/src/main/resources/templates/imprimelibros/partials/sidebar.html
+++ b/src/main/resources/templates/imprimelibros/partials/sidebar.html
@@ -43,6 +43,11 @@
Presupuestos
+
+
+