Ejemplo n.º 1
0
include_once '../Taxa.class.php';
checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true');
include_once '../../head.php';
if (!in_array(7, listarAcesso())) {
    echo '<script language= "JavaScript">location.href="index.php";</script>';
}
$taxa = new Taxa();
$DAO = new TaxaDAO();
// Verifica se a acao de salvar foi iniciada
if (!empty($_POST['cmd']) && $_POST['cmd'] == 'edit') {
    $taxa->setTaxaPTAX($_POST['ptax']);
    $taxa->setTaxaCasadaIene($_POST['ienes']);
    $taxa->setTaxaUSD1($_POST['usd1']);
    $taxa->setTaxaUSD2($_POST['usd2']);
    $taxa->setData($_POST['data']);
    $taxa->setId($_POST['id']);
    $resultado = $DAO->Atualizar($taxa);
    if ($resultado == 1) {
        echo '<script language= "JavaScript">alert("Registro alterado com sucesso");</script>';
        // 		echo '<script language= "JavaScript">location.href="index.php";</script>';
    } else {
        echo '<script language= "JavaScript">alert("Erro ao salvar o registro.");</script>';
        print_r($resultado);
    }
} else {
    $taxa->setId(limpaTexto($_GET['id']));
    $resultado = $DAO->Listar("SELECT * FROM " . MYSQL_BASE_FINANCEIRO_TAXA . " WHERE id = " . $taxa->getId());
    foreach ($resultado as $item) {
        $taxa->setTaxaPTAX($item['taxa_ptax_d2']);
        $taxa->setTaxaCasadaIene($item['taxa_casada_iene']);
        $taxa->setTaxaUSD1($item['taxa_usd1']);