Añadido datatable de cliente_contactos

This commit is contained in:
imnavajas
2023-08-08 12:22:50 +02:00
parent 1db71f8564
commit 7d61213f28
7 changed files with 175 additions and 27 deletions

View File

@ -1,4 +1,5 @@
<?php
namespace App\Models\Clientes;
class ClienteContactoModel extends \App\Models\GoBaseModel
@ -13,14 +14,12 @@ class ClienteContactoModel extends \App\Models\GoBaseModel
protected $useAutoIncrement = true;
const SORTABLE = [
1 => "t1.id",
2 => "t1.cliente_id",
3 => "t1.cargo",
4 => "t1.nombre",
5 => "t1.apellidos",
6 => "t1.telefono",
7 => "t1.email",
8 => "t2.nombre",
0 => "t1.cargo",
1 => "t1.nombre",
2 => "t1.apellidos",
3 => "t1.telefono",
4 => "t1.email",
5 => "t2.nombre",
];
protected $allowedFields = ["cliente_id", "cargo", "nombre", "apellidos", "telefono", "email"];
@ -105,13 +104,20 @@ class ClienteContactoModel extends \App\Models\GoBaseModel
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource(string $search = "")
public function getResource(string $search = "", $cliente_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.cargo AS cargo, t1.nombre AS nombre, t1.apellidos AS apellidos, t1.telefono AS telefono, t1.email AS email, t2.nombre AS cliente_id"
);
// IMN
if ($cliente_id != -1) {
$builder->where('cliente_id', $cliente_id);
}
$builder->where("t1.is_deleted", 0);
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
return empty($search)