forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.5 KiB
48 lines
1.5 KiB
<?php |
|
|
|
|
|
function GetTypeRamal($type){ |
|
|
|
return match($type){ |
|
"user" => "user", |
|
"peer" => "peer", |
|
"friend" => "friend" |
|
}; |
|
} |
|
|
|
function numeroCadastroExiste($dbcon, $number, $org_id){ |
|
|
|
$queries = [ |
|
'ramal' => "SELECT '' FROM pbx_ramais WHERE nome = $1 AND org_id = $2", |
|
'fila' => "SELECT '' FROM pbx_dacs WHERE numero = $1 AND status = 'A' AND org_id = $2", |
|
'nome_fila' => "SELECT '' FROM pbx_dacs WHERE nome = $1 AND status = 'A' AND org_id = $2", |
|
'ura' => "SELECT '' FROM pbx_ura WHERE teste = $1 AND org_id = $2", |
|
'anuncio' => "SELECT '' FROM pbx_anuncios WHERE teste = $1 AND org_id = $2", |
|
'disa' => "SELECT '' FROM pbx_disa WHERE numero = $1 AND org_id = $2", |
|
'horario' => "SELECT '' FROM pbx_horarios Where discar = $1 and org_id = $2", |
|
'voicemail' => "SELECT '' FROM pbx_voicemail_usuarios Where caixa_postal = $1 and org_id = $2" |
|
]; |
|
|
|
foreach ($queries as $key => $query) { |
|
pg_prepare($dbcon, "existe_{$key}", $query); |
|
$result = pg_execute($dbcon, "existe_{$key}", array($number, $org_id)); |
|
|
|
if (pg_num_rows($result) > 0) { |
|
return $key; |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
function RamaisDisopsitivoExiste($dbcon, $coluna, $value, $org_id){ |
|
|
|
$query = "select '' from pbx_ramais where $coluna = $1 and org_id = $2"; |
|
pg_prepare( $dbcon, "check_ramais", $query); |
|
$result = pg_execute( $dbcon, "check_ramais", array($value, $org_id) ); |
|
|
|
if( pg_num_rows($result) > 0 ){ |
|
return true; |
|
} |
|
|
|
return false; |
|
}
|
|
|