Exemplo n.º 1
0
include_once INTERNAL_ROOT_PORTAL . '/head.php';
$DAO = new MedicaoDAO();
$medicao = new Medicao();
$item_medicao = new Item();
$id = limpaTexto($_GET['id']);
$medicao->setId($id);
$monthName = "";
if (!in_array(54, listarAcesso())) {
    echo '<script language= "JavaScript">location.href="index.php";</script>';
}
if (ChecarAcessoMedicao($medicao->getId()) != 1) {
    echo '<script language= "JavaScript">location.href="index.php";</script>';
}
//Verifica se foi executado a acao de salvar todos os itens
if (!empty($_POST['cmd']) && $_POST['cmd'] == 'editar') {
    $medicao->setComprovanteCmatCLT($medicao->ComprovanteRemuneracao($_FILES['cmat_clt'], "1", $medicao->getId(), "1"));
    $medicao->setComprovanteCmatPJ($medicao->ComprovanteRemuneracao($_FILES['cmat_pj'], "1", $medicao->getId(), "2"));
    $medicao->setComprovanteVetecCLT($medicao->ComprovanteRemuneracao($_FILES['vetec_clt'], "3", $medicao->getId(), "1"));
    $medicao->setComprovanteVetecPJ($medicao->ComprovanteRemuneracao($_FILES['vetec_pj'], "3", $medicao->getId(), "2"));
    $retorno = $DAO->AtualizarComprovanteRemuneracao($medicao);
    if ($retorno == 1) {
        echo '<script language= "JavaScript">alert("Registro alterado com sucesso");</script>';
        echo '<script language= "JavaScript">location.href="index.php";</script>';
    } else {
        print_r($retorno);
        echo '<script language= "JavaScript">alert("Erro ao atualizar os registro.");</script>';
    }
} else {
    $retorno = $DAO->Listar("SELECT * FROM " . MYSQL_BASE_MEDICAO . " WHERE id = " . $medicao->getId());
    foreach ($retorno as $item) {
        !empty($item['comp_cmat_clt']) ? $medicao->setComprovanteCmatCLT('<p class="help-block"><a target="_blank" href="' . EXTERNAL_ROOT_PORTAL . '/arquivos/medicao/remuneracao/' . $item['comp_cmat_clt'] . '">Arquivo</a></p>') : $medicao->setComprovanteCmatCLT("");