function salvar($post, $file, $tipo) { if (!empty($post['consorcio']) && !empty($post['empresa']) && !empty($post['valor'])) { $DAO = new AnexoItemDAO(); $anexoItem = new AnexoItem(); $anexoItem->setEmpresa($post['empresa']); $anexoItem->setIdAnexo($post['anexo']); $anexoItem->setIdEmpresa($post['consorcio']); $anexoItem->setMedicaoItem($post['item']); $anexoItem->setPessoa($post['pessoa']); $anexoItem->setProduto($post['produto']); $anexoItem->setDataViagem($post['data']); $anexoItem->setNfRecibo($post['nf']); $anexoItem->setValor($post['valor']); $anexoItem->setMoeda($post['moeda']); $anexoItem->setDataVolta($post['data_volta']); $anexoItem->setQuantidade($_POST['quantidade']); $anexoItem->setDataNF($post['data_nf']); $anexoItem->setTipo($tipo); $uploadDir = '../../arquivos/medicao/'; $name = sha1(date("d-m-Y H:i:s")); $uploadFile = $uploadDir . $name; $extension = pathinfo($file['name'], PATHINFO_EXTENSION); $uploadFile = $uploadFile . '.' . $extension; $name = $name . '.' . $extension; $anexoItem->setFile($name); //Fazer o Upload do arquivo if (move_uploaded_file($file['tmp_name'], $uploadFile)) { $anexoItem->getTipo() == 'A' ? $anexoItem->setStatus('S') : $anexoItem->setStatus('N'); $request = $DAO->Gravar($anexoItem); if ($request) { // $request = $DAO->AtualizarValorAcumulado($anexoItem, TRUE); n�o est� atualizando o item da medi��o connectSQL(); $query = mysql_query("CALL sp_alterar_item_medicao(" . $anexoItem->getMedicaoItem() . ", " . $anexoItem->getValor() . ", " . $anexoItem->getQuantidade() . ", TRUE, 0)"); if ($anexoItem->getTipo() == 'A') { echo '<script language= "JavaScript">alert("Registro gravado com sucesso.");</script>'; } else { $msg = utf8_encode("O comprovante foi cadastrado, por�m est� bloqueado para aprova��o de um superior.."); echo '<script language= "JavaScript">alert("' . $msg . '");</script>'; } echo '<script language= "JavaScript">location.href="anexoItem.php?id=' . $post['anexo'] . '&medicao=' . $post['medicao'] . '";</script>'; } else { echo '<script language= "JavaScript">alert("Error ao salvar, entre em contato com a TI.");</script>'; } } else { echo '<script language= "JavaScript">alert("Error so subir o arquivo");</script>'; } } else { echo '<script language= "JavaScript">alert("Error ");</script>'; echo '<script language= "JavaScript">location.href="anexoItem.php?id=' . $post['anexo'] . '&medicao=' . $post['medicao'] . '";</script>'; } }
include_once INTERNAL_ROOT_PORTAL . '/medicao/DAO/BloqueadaDAO.php'; include_once INTERNAL_ROOT_PORTAL . '/medicao/AnexoItem.class.php'; checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true'); include_once INTERNAL_ROOT_PORTAL . '/head.php'; $acesso = listarAcesso(); if (!in_array(176, $acesso) && !in_array(215, $acesso)) { echo '<script language= "JavaScript">location.href="' . EXTERNAL_ROOT_PORTAL . '/modulos.php";</script>'; } $anexoItem = new AnexoItem(); $DAO = new BloqueadaDao(); $ref_medicao = ""; $grupo = ""; $anexoItem->setId(limpaTexto($_GET['id'])); //Verifica se a opcao de salvar foi iniciada if (!empty($_POST['cmd']) && $_POST['cmd'] == 'liberar') { $anexoItem->setStatus($_POST['status']); $anexoItem->setDescricao($_POST['descricao']); $anexoItem->setId(limpaTexto($_POST['id'])); if ($anexoItem->getDescricao() != "") { $resultado = $DAO->Aprovacao($anexoItem); if ($resultado == 1) { echo '<script language= "JavaScript">alert("Registro foi alterado com sucesso.");</script>'; echo '<script language= "JavaScript">location.href="view.php?id=' . $anexoItem->getId() . '";</script>'; } else { $msg = "Ocorreu um problema para salvar as informações, por favor entrar em contato com a TI.'"; echo '<script language= "JavaScript">alert("' . $msg . '");</script>'; echo '<script language= "JavaScript">location.href="view.php?id=' . $anexoItem->getId() . '";</script>'; } } else { $msg = "É necessário preencher o campo 'Consideração'"; echo '<script language= "JavaScript">alert("' . $msg . '");</script>';