Se puede seleccionar como admin el cliente del presupuesto como borrador

This commit is contained in:
2025-12-29 20:05:35 +01:00
parent 982423d766
commit 47866ddead
12 changed files with 6112 additions and 56 deletions

View File

@ -49,6 +49,7 @@ presupuesto.comentario-administrador=Comentarios
presupuesto.informacion-libro=Información del libro
presupuesto.datos-generales-descripcion=Datos generales del presupuesto
presupuesto.titulo=Título*
presupuesto.cliente=Cliente*
presupuesto.autor=Autor
presupuesto.isbn=ISBN
presupuesto.tirada=Tirada

View File

@ -332,7 +332,7 @@ export default class PresupuestoWizard {
servicios: this.formData.servicios.servicios,
datosMaquetacion: this.formData.servicios.datosMaquetacion,
datosMarcapaginas: this.formData.servicios.datosMarcapaginas,
cliente_id: $('#cliente_id').val() || null,
cliente_id: $('#user_id').val() || null,
};
try {
@ -1696,7 +1696,7 @@ export default class PresupuestoWizard {
const body = {
presupuesto: this.#getPresupuestoData(),
save: this.opts.canSave,
save: this.opts.mode == 'public' ? true : this.opts.canSave,
mode: this.opts.mode,
servicios: servicios,
datosMaquetacion: this.formData.servicios.datosMaquetacion,

View File

@ -0,0 +1,43 @@
$(() => {
// Inicializar select2 para el campo de cliente en el formulario de presupuesto
if ($('#user_id').length) {
$('#user_id').select2({
allowClear: false,
width: '100%',
ajax: {
url: '/users/api/get-users',
dataType: 'json',
data: function (params) {
return {
q: params.term, // término de búsqueda
page: params.page || 1,
size: 10,
showUsername: true
};
},
delay: 250,
processResults: function (data) {
return {
results: data.results || [],
pagination: data.pagination || { more: false }
};
},
cache: true
},
minimumInputLength: 0
});
// Si hay un valor inicial, cargar y establecer el usuario seleccionado
const initialUserId = $('#user_id').val();
if (initialUserId) {
$.ajax({
url: `/users/api/get-user/${initialUserId}`,
dataType: 'json'
}).then(function (data) {
const option = new Option(`${data.fullName} (${data.userName})`, data.id, true, true);
$('#user_id').append(option).trigger('change');
});
}
}
});

View File

@ -46,7 +46,7 @@
url: '/presupuesto/datatable/clientes',
method: 'GET',
},
order: [[0, 'asc']],
order: [[0, 'desc']],
columns: [
{ data: 'id', name: 'id', orderable: true },
{ data: 'titulo', name: 'titulo', orderable: true },

View File

@ -48,7 +48,7 @@ import { preguntarTipoPresupuesto, duplicar, reimprimir } from './presupuesto-ut
url: '/presupuesto/datatable/anonimos',
method: 'GET',
},
order: [[0, 'asc']],
order: [[0, 'desc']],
columns: [
{ data: 'id', name: 'id', orderable: true },
{ data: 'titulo', name: 'titulo', orderable: true },
@ -174,7 +174,7 @@ import { preguntarTipoPresupuesto, duplicar, reimprimir } from './presupuesto-ut
url: '/presupuesto/datatable/clientes',
method: 'GET',
},
order: [[0, 'asc']],
order: [[0, 'desc']],
columns: [
{ data: 'id', name: 'id', orderable: true },
{ data: 'user', name: 'user.fullName', orderable: true },

View File

@ -18,6 +18,28 @@
</div>
<div class="px-2">
<th:block th:if="${presupuesto?.user != null}">
<div sec:authorize="isAuthenticated() and hasAnyRole('SUPERADMIN','ADMIN')" class="row">
<div class="col-sm-12">
<div class="mb-3">
<label for="user_id" class="form-label" th:text="#{presupuesto.cliente}">
>Cliente*</label>
<select class="form-select select2 datos-generales-data" id="user_id">
<option
th:value="${presupuesto?.user.id} ?: ''"
th:text="${presupuesto.user != null ? presupuesto.user.fullName + ' (' + presupuesto.user.userName + ')' : ''}"
selected>
</option>
</select>
</div>
</div>
</div>
<div sec:authorize="isAuthenticated() and !hasAnyRole('SUPERADMIN','ADMIN')">
<input type="hidden" class="datos-generales-data" id="user_id"
th:value="${presupuesto?.user.id} ?: ''">
</div>
</th:block>
<div class="row">
<div class="col-sm-12">
<div class="mb-3">

View File

@ -89,6 +89,8 @@
th:src="@{/assets/libs/quill/quill.min.js}"></script>
<script sec:authorize="isAuthenticated() and hasAnyRole('SUPERADMIN','ADMIN')"
th:src="@{/assets/js/pages/imprimelibros/presupuestador/text-editor.js}"></script>
<script sec:authorize="isAuthenticated() and hasAnyRole('SUPERADMIN','ADMIN')"
th:src="@{/assets/js/pages/imprimelibros/presupuestos/admin-utils.js}"></script>
<script type="module" th:src="@{/assets/js/pages/imprimelibros/presupuestos/duplicate-reprint.js}"></script>
</th:block>