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.
46 lines
1.1 KiB
46 lines
1.1 KiB
#!/usr/bin/php -q |
|
<?php |
|
include('bd.php'); |
|
include('funcoes/shared.php'); |
|
include('util/util.php'); |
|
|
|
|
|
|
|
$dddPadrao = GetDddPadrao(); |
|
|
|
|
|
$query = 'select trr_id, trr_destino from pbx_tarif_registra where trr_tipo_dispositivo is null order by trr_id'; |
|
$result = pg_query($query); |
|
|
|
if (!$result) { |
|
echo "Erro ao consultar o banco de dados!\n"; |
|
exit; |
|
} |
|
|
|
$erros = 0; |
|
$sucesso = 0; |
|
while ($row = pg_fetch_array($result)) { |
|
$trrId = $row['trr_id']; |
|
$trrDest = $row['trr_destino']; |
|
|
|
$tpChamada = GetTipoChamada($trrDest, $dddPadrao); |
|
$dispositivo = $tpChamada[0]; |
|
$tipoChamada = $tpChamada[1]; |
|
|
|
$query = "update pbx_tarif_registra set trr_tipo_dispositivo = '$dispositivo', trr_chamada = '$tipoChamada' where trr_id = '$trrId'"; |
|
$resultUpd = pg_query($query); |
|
|
|
if (!$resultUpd) { |
|
$erros++; |
|
} else { |
|
$sucesso++; |
|
} |
|
} |
|
|
|
if ($erros && !$sucesso) { |
|
echo "Ocorreram erros na atualização!\n"; |
|
} else if (!$erros && $sucesso) { |
|
echo "Registros atualizados com sucesso!\n"; |
|
} else { |
|
echo "Nenhum registro foi atualizado!\n"; |
|
} |