include_once '../DAO/AnexoItemDAO.php'; include_once '../AnexoItem.class.php'; include_once '../Item.class.php'; checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true'); include_once '../../head.php'; $DAO = new AnexoItemDAO(); $anexoItem = new AnexoItem(); connectSQL(); $anexoItem->setId(limpaTexto($_GET['id'])); $anexoItem->setIdMedicao(limpaTexto($_GET['medicao'])); //Verifica se foi executado a acao de salvar if (!empty($_POST['cmd']) && $_POST['cmd'] == 'salvar') { $id_contrato_item = $_POST['id_contrato_item']; $anexoItem->setDataViagem($_POST['data']); $anexoItem->setDataVolta($_POST['data_volta']); $anexoItem->setEmpresa($_POST['empresa']); $anexoItem->setIdEmpresa($_POST['consorcio']); $anexoItem->setGrupo($_POST['item']); $anexoItem->setMoeda($_POST['moeda']); $anexoItem->setNfRecibo($_POST['nf']); $anexoItem->setPessoa($_POST['pessoa']); $anexoItem->setProduto($_POST['produto']); $anexoItem->setQuantidade($_POST['quantidade']); $anexoItem->setValor($_POST['valor']); $anexoItem->setMedicaoItem($_POST['medicao_item']); $anexoItem->setDataNF($_POST['data_nf']); $anexoItem->setIdAnexo($_POST['anexo']); //$query = mysql_query("CALL sp_alterar_item_medicao(".$anexoItem->getMedicaoItem().", ".$anexoItem->getValor().", ".$anexoItem->getQuantidade().", TRUE, ".$anexoItem->getId().")"); if ($_FILES['files']['error'] != UPLOAD_ERR_NO_FILE) { $uploadDir = '../../arquivos/medicao/'; $name = sha1(date("d-m-Y H:i:s"));
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>'; } }
<?php include_once '../../includes.sys/ini.php'; include_once INTERNAL_ROOT_PORTAL . '/includes.sys/metodos.php'; include_once INTERNAL_ROOT_PORTAL . "/medicao/DAO/AnexoItemDAO.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'; $anexoItem = new AnexoItem(); $DAO = new AnexoItemDAO(); if (!empty($_POST['cmd']) && $_POST['cmd'] == 'pesquisar') { $anexoItem->setIdMedicao(limpaTexto($_POST['medicao'])); $anexoItem->setPessoa(limpaTexto($_POST['pessoa'])); $anexoItem->setEmpresa(limpaTexto($_POST['empresa'])); $anexoItem->setNfRecibo(limpaTexto($_POST['notafiscal'])); $anexoItem->setEstabelecimento(limpaTexto($_POST['estabelecimento'])); $anexoItem->setGrupo(limpaTexto($_POST['grupo'])); $anexoItem->setValor(limpaTexto(str_replace(",", ".", $_POST['valor']))); $query = "SELECT \r\n\t\t\t\t\tMAI.*,\r\n\t\t\t\t\tMA.titulo, \r\n\t\t\t\t\tMA.grupo,\r\n\t\t\t\t\tIF(MAI.nf_recibo != '',MAI.nf_recibo,'RECIBO') as nota_fiscal, \r\n\t\t\t\t\tM.numero as medicao \r\n\t\t\t\tFROM \r\n\t\t\t\t\t" . MYSQL_BASE_MEDICAO_ANEXO_ITENS . " MAI\r\n\t\t\t\t\tINNER JOIN " . MYSQL_BASE_MEDICAO_ANEXOS . " MA ON MAI.id_medicao_anexo = MA.id\r\n\t\t\t\t\tINNER JOIN " . MYSQL_BASE_MEDICAO . " M ON M.id = MA.id_medicao\r\n\t\t\t\tWHERE \r\n\t\t\t\t\tMAI.status = 'S'"; $confirm = "return confirm('Deseja remover esse registro?');"; //Verifica se foi digitado a Medicao if ($anexoItem->getIdMedicao() != null) { $query .= " AND MA.id_medicao = " . $anexoItem->getIdMedicao() . " "; } // //Verifica se foi digitado Pessoa if ($anexoItem->getPessoa() != null) { $query .= " AND MAI.id_pessoa = " . $anexoItem->getPessoa() . " "; } // //Verifica se foi escolhido Empresa if ($anexoItem->getEmpresa() != 0) { $query .= " AND MAI.id_empresa = " . $anexoItem->getEmpresa();