mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
filtros columna en pedidos hecho
This commit is contained in:
@ -14,12 +14,20 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.id",
|
||||
1 => "t1.estado",
|
||||
2 => "t1.total_precio",
|
||||
3 => "t1.total_tirada",
|
||||
0 => "t2.id",
|
||||
1 => "t2.updated_at",
|
||||
2 => "t2.fecha_entrega_real",
|
||||
3 => "t4.nombre",
|
||||
4 => "CONCAT(t5.first_name, ' ', t5.last_name)",
|
||||
5 => "t3.titulo",
|
||||
6 => "t6.nombre",
|
||||
7 => "t3.inc_rei",
|
||||
8 => "t3.paginas",
|
||||
9 => "t3.tirada",
|
||||
10 => "t3.total_aceptado",
|
||||
11 => "t2.estado"
|
||||
];
|
||||
|
||||
|
||||
protected $allowedFields = [
|
||||
"pedido_id",
|
||||
"presupuesto_id",
|
||||
@ -40,7 +48,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
public static $labelField = "id";
|
||||
|
||||
|
||||
public function getResource(string $search = "", $estado="")
|
||||
public function getResource($search = [], $estado="")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -67,14 +75,22 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
// Falta implementar la busqueda por grupos
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->groupEnd();
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if ($col_search[0] != 1 && $col_search[0] != 2)
|
||||
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||
else {
|
||||
$dates = explode(" ", $col_search[2]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
|
||||
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
|
||||
}
|
||||
}
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user