forked from SimplesIP/pabx-app
Claudio Zimmermann Junior
3 months ago
committed by
Gitea
18 changed files with 155 additions and 153 deletions
@ -0,0 +1,48 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace app\Repositories; |
||||||
|
|
||||||
|
use app\core\Repository; |
||||||
|
|
||||||
|
class Bilhetes extends Repository |
||||||
|
{ |
||||||
|
protected static string $table = 'pbx_bilhetes'; |
||||||
|
|
||||||
|
public static function getBilhetes(array $data): array |
||||||
|
{ |
||||||
|
$query = "SELECT |
||||||
|
a.id_bilhetes AS id, a.calldate AS data_hora, |
||||||
|
a.src AS origem, a.dst AS destino, a.billsec AS tempo_conversacao, |
||||||
|
a.duration AS tempo_atendimento, a.accountcode AS id_transfer, |
||||||
|
a.uniqueid AS uniqueid, a.userfield AS nome_audio, |
||||||
|
a.data_bilhete AS data, a.fora_horario AS fora_horario, |
||||||
|
a.org_id |
||||||
|
FROM pbx_bilhetes a |
||||||
|
WHERE a.lastapp <> 'Transferred Call' "; |
||||||
|
|
||||||
|
foreach ($data as $k => $v) { |
||||||
|
if (!$v) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
if (in_array($k, ['src', 'dst', 'entry'])) { |
||||||
|
$query .= " AND $k LIKE '%:$k%'"; |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
if ($k === 'i_date') { |
||||||
|
$query .= " AND data_bilhete >= :$k"; |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
if ($k === 'f_date') { |
||||||
|
$query .= " AND data_bilhete <= :$k"; |
||||||
|
continue; |
||||||
|
} |
||||||
|
$query .= " AND $k = :$k"; |
||||||
|
} |
||||||
|
|
||||||
|
$query .= " ORDER BY data_bilhete"; |
||||||
|
return self::query($query, $data); |
||||||
|
} |
||||||
|
} |
@ -1,10 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace app\models; |
|
||||||
|
|
||||||
use app\core\Repository; |
|
||||||
|
|
||||||
class Bilhetes extends Repository |
|
||||||
{ |
|
||||||
protected static $table = 'pbx_bilhetes'; |
|
||||||
} |
|
Loading…
Reference in new issue