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"