mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en la lista de tickets
This commit is contained in:
@ -8,44 +8,52 @@ class TicketModel extends \App\Models\BaseModel
|
||||
|
||||
protected $table = 'tickets';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = ['usuario_id', 'tecnico_id', 'categoria_id', 'estado_id', 'prioridad', 'titulo', 'descripcion', 'created_at', 'updated_at'];
|
||||
protected $allowedFields = ['usuario_id', 'user_soporte_id', 'seccion_id' ,'categoria_id', 'estado_id', 'prioridad', 'titulo', 'descripcion', 'created_at', 'updated_at'];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.categoria_id",
|
||||
1 => "t1.seccion_id",
|
||||
2 => "t1.estado_id",
|
||||
3 => "t1.prioridad",
|
||||
4 => "t1.titulo",
|
||||
5 => "t1.usuario_id",
|
||||
6 => "t1.usuario_soporte_id",
|
||||
7 => "t1.created_at",
|
||||
];
|
||||
|
||||
public function getEstados()
|
||||
{
|
||||
$values = $this->db->table('tickets_estados')->get()->getResultArray();
|
||||
$data = [];
|
||||
|
||||
foreach ($values as $value) {
|
||||
$data[$value['keyword']] = lang("Tickets." . $value['keyword']);
|
||||
|
||||
for($i = 0; $i < count($values); $i++){
|
||||
$values[$i]['text'] = lang("Tickets." . $values[$i]['keyword']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
return $values;
|
||||
}
|
||||
|
||||
public function getCategorias()
|
||||
{
|
||||
$values = $this->db->table('tickets_categorias')->get()->getResultArray();
|
||||
$data = [];
|
||||
|
||||
foreach ($values as $value) {
|
||||
$data[$value['keyword']] = lang("Tickets." . $value['keyword']);
|
||||
|
||||
for($i = 0; $i < count($values); $i++){
|
||||
$values[$i]['text'] = lang("Tickets." . $values[$i]['keyword']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
return $values;
|
||||
}
|
||||
|
||||
public function getSecciones()
|
||||
{
|
||||
$values = $this->db->table('tickets_secciones')->get()->getResultArray();
|
||||
$data = [];
|
||||
|
||||
foreach ($values as $value) {
|
||||
$data[$value['keyword']] = lang("Tickets." . $value['keyword']);
|
||||
for($i = 0; $i < count($values); $i++){
|
||||
$values[$i]['text'] = lang("Tickets." . $values[$i]['keyword']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
return $values;
|
||||
}
|
||||
|
||||
public function getTickets($id = null)
|
||||
@ -60,4 +68,37 @@ class TicketModel extends \App\Models\BaseModel
|
||||
|
||||
return $this->find($id);
|
||||
}
|
||||
|
||||
public function getResource($search = [], )
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.usuario_id AS usuario_id, CONCAT(t2.first_name, ' ', t2.last_name) AS usuario,
|
||||
t1.user_soporte_id AS user_soporte_id, CONCAT(t2.first_name, ' ', t2.last_name) AS user_soporte,
|
||||
t1.categoria_id AS categoria_id, t3.keyword AS categoria, t1.seccion_id AS seccion_id, t1.estado_id AS estado_id,
|
||||
t1.prioridad AS prioridad, t1.titulo AS titulo, t1.created_at AS created_at
|
||||
"
|
||||
);
|
||||
|
||||
$builder->join("users t2", "t1.usuario_id = t2.id", "left");
|
||||
$builder->join("users t2", "t1.user_soporte_id = t2.id", "left");
|
||||
$builder->join("tickets_categorias t3", "t1.categoria_id = t3.id", "left");
|
||||
$builder->join("tickets_estados t4", "t1.estado_id = t4.id", "left");
|
||||
$builder->join("tickets_secciones t5", "t1.seccion_id = t5.id", "left");
|
||||
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if ($col_search[0] > 0 && $col_search[0] < 4)
|
||||
$builder->where(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||
else
|
||||
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||
}
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user