arreglado carga de cliente

This commit is contained in:
2024-11-04 23:58:18 +01:00
parent 83c8628645
commit 315d2a3acd
4 changed files with 20 additions and 10 deletions

View File

@ -99,10 +99,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
// Se obtiene el cliente ID a partir del usuario de la sesion
$model_user = model('App\Models\Usuarios\UserModel');
$user = $model_user->find(auth()->user()->id);
$clienteId = $user->cliente_id;
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
if ($clienteId === false || $clienteId === null) {
return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.');
}
}
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$this->viewData['breadcrumb'] = [
@ -140,6 +146,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$user = $model_user->find(auth()->user()->id);
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
$clienteId = $user->cliente_id;
if ($clienteId === false || $clienteId === null) {
return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.');
}
} else {
$clienteId = $presupuestoEntity->cliente_id;
}
@ -375,7 +384,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if (array_key_exists('exception', $return_data)) {
return $this->failServerError(
$return_data['exception'] . ' - ' .
$return_data['file'] . ' - ' . $return_data['line']
$return_data['file'] . ' - ' . $return_data['line']
);
}
@ -2135,7 +2144,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$color = 'negro';
$model = model('App\Models\Presupuestos\PresupuestoLineaModel');
$data = $model->where('presupuesto_id', $presupuestoId)->findAll();;
$data = $model->where('presupuesto_id', $presupuestoId)->findAll();
;
foreach ($data as $linea) {
if (strpos($linea->tipo, "hq") !== false) { // $linea->tipo contains the substring "hq"

View File

@ -67,8 +67,8 @@
<div class="row col-sm-5 mb-3 d-flex flex-column align-items-center">
<div class="form-check form-switch mb-2">
<input <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
class="calcular-presupuesto form-check-input" type="checkbox" id="excluirPortada"
name="excluir_portada" value="1">
class="calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa"
name="excluir_rotativa" value="1">
<label <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
class="form-check-label" for="excluirRotativa">Excluir rotativa</label>
</div>

View File

@ -64,7 +64,7 @@ class DatosGenerales {
// Selects
this.formatoLibro.init();
if (this.excluirRotativa.length != 0) {
if (!$(this.excluirRotativa).prop('hidden')){
this.cliente.init();
}
@ -102,7 +102,7 @@ class DatosGenerales {
message: window.translations["validation"].cliente,
callback: function (input) {
// Get the selected options
if(this.excluirRotativa.length == 0)
if (!$(this.excluirRotativa).prop('hidden'))
return true;
const options = $("#clienteId").select2('data');
const hasValidOption = options.some(option => parseInt(option.id) > 0);
@ -386,7 +386,7 @@ class DatosGenerales {
this.coleccion.val(datos.coleccion);
this.referenciaCliente.val(datos.referenciaCliente);
if (this.excluirRotativa.length != 0) {
if (!$(this.excluirRotativa).prop('hidden')){
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
this.cliente.setVal(datos.clienteId);
$(this.cliente).trigger('change');
@ -441,7 +441,7 @@ class DatosGenerales {
}
getCliente(){
if (this.excluirRotativa.length == 0)
if ($(this.excluirRotativa).prop('hidden'))
return $('#clienteId').val();
return this.cliente.getVal();
}

View File

@ -599,7 +599,7 @@ class PresupuestoCliente {
this.calcularPresupuesto = false;
this.datosGenerales.cargarDatos(response.data.datosGenerales);
if (this.datosGenerales.excluirRotativa.length !== 0) {
if (!$(this.datosGenerales.excluirRotativa).prop("hidden")) {
this.direcciones.handleChangeCliente();
}
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);