mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
customizada vista de peiddos y facturas cliente
This commit is contained in:
@ -72,7 +72,7 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
|
||||
public static $labelField = "id";
|
||||
|
||||
public function getResource(string $search = "")
|
||||
public function getResource(string $search = "", $cliente_id=-1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -90,8 +90,16 @@ class FacturaModel extends \App\Models\BaseModel {
|
||||
$builder->join("formas_pago t4", "t3.forma_pago_id = t4.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
if(auth()->user()->inGroup("cliente-admin") || auth()->user()->inGroup("cliente-editor")) {
|
||||
$builder->where("t1.estado", "validada");
|
||||
}
|
||||
|
||||
if($cliente_id != -1) {
|
||||
$builder->where("t1.cliente_id", $cliente_id);
|
||||
}
|
||||
|
||||
$builder->groupBy("t1.id"); // Agrupa por id de la factura
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
|
||||
Reference in New Issue
Block a user