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.
63 lines
2.3 KiB
63 lines
2.3 KiB
<?php |
|
|
|
$tpLayout = -1; |
|
/* |
|
* RECEBE VALORES! |
|
*/ |
|
$departamento = $_POST['nome']; |
|
$Finalizar = $_POST['concluir']; |
|
if ($Finalizar == "Inserir") { |
|
TrataValor($departamento); |
|
if (TrataValor($departamento) == 1) { |
|
/* |
|
* VERIFICA SE JA POSSUI ALGUM REGISTRO RELACIONADO AO DEPARTAMENTO! |
|
*/ |
|
$busca = "SELECT dpto_nome FROM rma_departamentos WHERE dpto_nome='$departamento'"; |
|
$result = pg_query($dbcon, $busca); |
|
if (pg_num_rows($result) >= 1) { |
|
/* |
|
* VERIFICA SE DEPARTAMENTO ESTÁ INATIVO! |
|
*/ |
|
$busca = pg_query($dbcon, "SELECT dpto_nome FROM rma_departamentos WHERE dpto_status!='1'"); |
|
if (pg_num_rows($busca) >= 1) { |
|
$mes = "<img src=\"imgSite/icone_alert.png\" width=\"16\" height=\"16\">Departamento ja existente,mas inativo!"; |
|
} else { |
|
$mes = "<img src=\"imgSite/icone_alert.png\" width=\"16\" height=\"16\">Departamento ja existente!"; |
|
} |
|
} else { |
|
|
|
/* |
|
* INSERI DEPARTAMENTO! |
|
*/ |
|
$insert = "INSERT INTO rma_departamentos (dpto_nome) VALUES ('$departamento')"; |
|
$query = pg_query($dbcon, $insert); |
|
/* |
|
* VERIFICA SE REGISTRO FOI INSERIDO! |
|
*/ |
|
$busca = "SELECT dpto_nome FROM rma_departamentos WHERE dpto_nome='$departamento'"; |
|
$result = pg_query($dbcon, $busca); |
|
if (pg_num_rows($result) >= 1) { |
|
$mes = "<img src=\"imgSite/stAprovado.png\">Departamento cadastrado com sucesso!"; |
|
$jsStartup[] = "window.opener.ResetForm(); window.close();"; |
|
} else { |
|
$mes = "<img src=\"imgSite/icone_alert.png\" width=\"16\" height=\"16\">Ocorreu um erro ao inserir o Departamento!"; |
|
} |
|
} |
|
} |
|
} |
|
|
|
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('mes', $mes); |
|
$smarty->assign('departamento', $departamento); |
|
$smarty->display("agendaRamais/depto/deptoRamaisInsert.html"); |
|
?>
|
|
|