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.
79 lines
2.5 KiB
79 lines
2.5 KiB
<?php |
|
|
|
$tpLayout = -1; |
|
/* |
|
* RECEBE ID DO DEPARTAMENTO! |
|
*/ |
|
if (empty($_GET['dpto'])) { |
|
|
|
/* |
|
* RECEBE VALORES VIA POST DO FORMULARIO! |
|
*/ |
|
$departamento = $_POST['nome']; |
|
$id = $_POST['dpto']; |
|
$Finalizar = $_POST['concluir']; |
|
if ($departamento == "") { |
|
$mes = "<img src=\"imgSite/icone_alert.png\" width=\"16\" height=\"16\">Por favor preencha todos os campos!"; |
|
} |
|
if ($Finalizar == "Alterar") { |
|
$id = $_POST['dpto']; |
|
TrataValor($departamento); |
|
if (TrataValor($departamento) == 1) { |
|
/* |
|
* FAZ UPDATE DO REGISTRO! |
|
*/ |
|
$update = "UPDATE rma_departamentos SET dpto_nome='$departamento' WHERE dpto_id='$id'"; |
|
$result = pg_query($dbcon, $update); |
|
|
|
/* |
|
* VERIFICA SE REGISTRO FOI ATUALIZADO COM SUCESSO! |
|
*/ |
|
$busca = "SELECT dpto_nome FROM rma_departamentos WHERE dpto_nome='$departamento' AND dpto_id='$id'"; |
|
$result = pg_query($dbcon, $busca); |
|
if (pg_num_rows($result) >= 1) { |
|
$mes = "<img src=\"imgSite/stAprovado.png\">Departamento Atualizado com sucesso!"; |
|
} else { |
|
$mes = "<img src=\"imgSite/icone_alert.png\" width=\"16\" height=\"16\">Não foi possivel atualizar departamento!"; |
|
} |
|
} |
|
} |
|
} else { |
|
$id = $_GET['dpto']; |
|
/* |
|
* VERIFICA SE DEPARTAMENTO É EXISTENTE! |
|
*/ |
|
|
|
$busca = "SELECT dpto_nome,dpto_id FROM rma_departamentos WHERE dpto_status='1' AND dpto_id='$id'"; |
|
$result = pg_query($dbcon, $busca); |
|
if (pg_num_rows($result) >= 1) { |
|
/* |
|
* SE DEPARTAMENTO FOR EXISTENE, ESTE LOOP MONTA UM COMBO! |
|
*/ |
|
while ($rowDepto = pg_fetch_array($result)) { |
|
$departamento = $rowDepto['dpto_nome']; |
|
$id = $rowDepto['dpto_id']; |
|
$option .= "<option value=\"" . $id . "\">" . $nome . "</option>"; |
|
} |
|
} else { |
|
$mes = "<img src=\"imgSite/icone_alert.png\" width=\"16\" height=\"16\">Departamento não encontrado!"; |
|
} |
|
} |
|
|
|
function TrataValor($departamento) { |
|
if (empty($departamento)) { |
|
return "Por favor preencha o campo nome!"; |
|
} else { |
|
return 1; |
|
} |
|
} |
|
|
|
if (TrataValor($departamento) != 1) { |
|
$mes = TrataValor($departamento); |
|
} |
|
|
|
|
|
$smarty->assign('nome', $departamento); |
|
$smarty->assign('mes', $mes); |
|
$smarty->assign('id', $id); |
|
$smarty->display("agendaRamais/depto/deptoRamaisUpdate.html"); |
|
?>
|
|
|