mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado
This commit is contained in:
@ -8,7 +8,7 @@ class TicketModel extends \App\Models\BaseModel
|
||||
|
||||
protected $table = 'tickets';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = ['usuario_id', 'user_soporte_id', 'seccion_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;
|
||||
|
||||
@ -29,8 +29,8 @@ class TicketModel extends \App\Models\BaseModel
|
||||
public function getEstados()
|
||||
{
|
||||
$values = $this->db->table('tickets_estados')->get()->getResultArray();
|
||||
|
||||
for($i = 0; $i < count($values); $i++){
|
||||
|
||||
for ($i = 0; $i < count($values); $i++) {
|
||||
$values[$i]['text'] = lang("Tickets." . $values[$i]['keyword']);
|
||||
}
|
||||
|
||||
@ -40,8 +40,8 @@ class TicketModel extends \App\Models\BaseModel
|
||||
public function getCategorias()
|
||||
{
|
||||
$values = $this->db->table('tickets_categorias')->get()->getResultArray();
|
||||
|
||||
for($i = 0; $i < count($values); $i++){
|
||||
|
||||
for ($i = 0; $i < count($values); $i++) {
|
||||
$values[$i]['text'] = lang("Tickets." . $values[$i]['keyword']);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ class TicketModel extends \App\Models\BaseModel
|
||||
{
|
||||
$values = $this->db->table('tickets_secciones')->get()->getResultArray();
|
||||
|
||||
for($i = 0; $i < count($values); $i++){
|
||||
for ($i = 0; $i < count($values); $i++) {
|
||||
$values[$i]['text'] = lang("Tickets." . $values[$i]['keyword']);
|
||||
}
|
||||
|
||||
@ -100,13 +100,44 @@ class TicketModel extends \App\Models\BaseModel
|
||||
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]);
|
||||
if ($col_search[1] == "seccion_id") {
|
||||
$id = $this->getIdFromKeyword("tickets_secciones", $col_search[2]);
|
||||
$builder->where("t1." . $col_search[1], $id);
|
||||
} else if ($col_search[1] == "categoria_id") {
|
||||
$id = $this->getIdFromKeyword("tickets_categorias", $col_search[2]);
|
||||
$builder->where("t1." . $col_search[1], $id);
|
||||
} else if ($col_search[1] == "estado_id") {
|
||||
$id = $this->getIdFromKeyword("tickets_estados", $col_search[2]);
|
||||
$builder->where("t1." . $col_search[1], $id);
|
||||
} else if ($col_search[1] == "prioridad") {
|
||||
$builder->where("t1." . $col_search[1], $col_search[2]);
|
||||
} else if ($col_search[1] == "created_at") {
|
||||
$dates = explode(" ", $col_search[2]);
|
||||
$builder->where("t1." . $col_search[1] . ">=", $dates[0]);
|
||||
$builder->where("t1." . $col_search[1] . "<=", $dates[1]);
|
||||
} else if ($col_search[1] == "usuario_id") {
|
||||
$builder->like("t2.first_name", $col_search[2]);
|
||||
$builder->orLike("t2.last_name", $col_search[2]);
|
||||
} else if ($col_search[1] == "user_soporte_id") {
|
||||
$builder->like("t6.first_name", $col_search[2]);
|
||||
$builder->orLike("t6.last_name", $col_search[2]);
|
||||
}
|
||||
else
|
||||
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
|
||||
$builder->like("t1." . $col_search[1], $col_search[2]);
|
||||
}
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function getIdFromKeyword($table, $keyword)
|
||||
{
|
||||
$subquery = $this->db->table($table)
|
||||
->select('id')
|
||||
->where('keyword', $keyword)
|
||||
->get()
|
||||
->getRow();
|
||||
return $subquery->id;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user