Example #1
0
function getUserTokens($ids)
{
    require_once 'praveenlib.php';
    $returnData = array('error' => 0);
    if (count($ids) == 0) {
        $returnData['error'] = 6;
        $returnData['status'] = "userid required";
        return $returnData;
    }
    $conn = connectSQL();
    if ($conn) {
        $idString = "" . $ids[0];
        for ($i = 1; $i < count($ids); $i++) {
            $idString .= "," . $ids[$i];
        }
        $query = "select userToken from users where id in ({$idString})";
        if ($result = $conn->query($query)) {
            $returnData['tokens'] = array();
            while ($row = $result->fetch_array()) {
                $returnData['tokens'][] = $row[0];
            }
        } else {
            $returnData["status"] = "SQL error";
            $returnData["SqlError"] = $conn->error;
            $returnData["errorCode"] = 4;
        }
    } else {
        $returnData["status"] = "SQL Connection error";
        $returnData["SqlError"] = $conn->error;
        $returnData["errorCode"] = 3;
    }
    return $returnData;
}
/**
 * Actualiza la cantidad de tramites en el cliente de la base de datos SQL
 * @param bool $idCliente
 * @param bool $count
 */
function setTramitesClientes($idCliente = false, $count = false)
{
    // conexion sql
    $dbSQL = connectSQL();
    // actualizo el campo
    //$query  = $dbSQL->query( "UPDATE SA1010 SET A1_XECALL='". $count ."' WHERE A1_COD='". $idCliente ."';" );
    $count = rand(1, 9999);
    $query = $dbSQL->query("UPDATE SA1010 SET A1_XECALL='" . $count . "' WHERE A1_COD='000001'");
}
/**
 * Trae los integrantes compuestos de un cliente del totvs de la base de datos SQL
 * Datos pasado por Ignacio Capurro
 * @param bool $id
 */
function getClientesCompuestos()
{
    // conexion sql
    $dbSQL = connectSQL();
    echo '<hr/>';
    $query = $dbSQL->prepare("SELECT Z21_CODCC, Z21_LOJACC, Z21_COD, Z21_LOJA, Z21_NOME FROM Z21010 WHERE Z21_CODCC = '012928'");
    $query->execute();
    echo 'componentes: <br/>';
    for ($i = 0; $row = $query->fetch(); $i++) {
        echo 'codcc: ' . $row["Z21_CODCC"] . ', lojacc: ' . $row["Z21_LOJACC"] . ', cod: ' . $row["Z21_COD"] . ', loja: ' . $row["Z21_loja"] . ', nome: ' . $row["Z21_NOME"] . '<br/>';
    }
    $clientes = array();
    for ($i = 0; $row = $query->fetch(); $i++) {
        $clientes[] = array('codcc' => trim($row['Z21_CODCC']), 'lojacc' => trim($row['Z21_LOJACC']), 'cod' => trim($row['Z21_COD']), 'loja' => trim($row['Z21_loja']), 'nome' => trim($row['Z21_NOME']));
    }
    return json_encode($clientes);
    /*
    echo '<hr/>';
    $query = $dbSQL->prepare( "SELECT A1_COD, A1_NOME, A1_TEL, A1_EMAIL, A1_END, A1_XESPROP, A1_XESINQU, A1_LOJA FROM SA1010 WHERE A1_COD='012928'" );
    $query->execute();
    echo 'propietario: <br/>';
    for ( $i=0; $row = $query->fetch(); $i++ ) {
        echo 'cod: '.$row["A1_COD"].', nome: '.$row["A1_NOME"].', loja: '.$row["A1_LOJA"].'<br/>';
    }
    echo '<hr/>';
    $query = $dbSQL->prepare( "SELECT A1_COD, A1_NOME, A1_TEL, A1_EMAIL, A1_END, A1_XESPROP, A1_XESINQU, A1_LOJA FROM SA1010 WHERE A1_COD='100034'" );
    $query->execute();
    echo 'inquilino: <br/>';
    for ( $i=0; $row = $query->fetch(); $i++ ) {
        echo 'cod: '.$row["A1_COD"].', nome: '.$row["A1_NOME"].', loja: '.$row["A1_LOJA"].'<br/>';
    }
    
    echo '<hr/>';
    $query = $dbSQL->prepare( "SELECT Z30_CODIGO, Z30_VERSIO, Z30_PROPIE, Z30_CLIECO, Z30_CLIENT, Z30_ACTIVO, Z30_ESTADO FROM Z30010 WHERE Z30_CLIECO='012928'" );
    $query->execute();
    echo 'contratos: <br/>';
    for ( $i=0; $row = $query->fetch(); $i++ ) {
        echo 'cod: '.$row["Z30_CODIGO"].', propie: '.$row["Z30_PROPIE"].', clieco: '.$row["Z30_CLIECO"].', client: '.$row["Z30_CLIENT"].', versio: '.$row["Z30_VERSIO"].'<br/>';
    }
    /*
    $propiedades = array();
    for ( $i=0; $row = $query->fetch(); $i++ ) {
        $propiedades[] =  array(
            'codigo'        => trim( $row['Z23_COD'] ),
            'nombre'        => trim( $row['Z23_NOME'] ),
            'direccion'     => trim( $row['Z23_END'] ),
            'propietario'   => trim( $row['Z23_PRCD'] ),
            'kardex'        => trim( $row['Z23_KDEX'] ),
            'puerta'        => trim( $row['Z23_NUMERO'] ),
        );
    }
    return json_encode( $propiedades );
    */
    die;
}
Example #4
0
 function listarPessoa($id_pessoa = null)
 {
     connectSQL();
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_PESSOAS . " WHERE ativo = 'S'");
     while ($row = mysql_fetch_array($query)) {
         if (in_array($row['id'], $id_pessoa)) {
             echo '<option selected="selected" value="' . $row['id'] . '">' . $row['nome_completo'] . '</option>';
         } else {
             echo '<option value="' . $row['id'] . '">' . $row['nome_completo'] . '</option>';
         }
     }
 }
Example #5
0
 function listarCheckList($arquivos = null)
 {
     connectSQL();
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_CHECK_LISTS . " WHERE ativo = 'S' ORDER BY nome_arquivo");
     while ($row = mysql_fetch_array($query)) {
         if (in_array($row['id'], $arquivos)) {
             echo '<option selected="selected" value="' . $row['id'] . '">' . $row['nome_arquivo'] . '</option>';
         } else {
             echo '<option value="' . $row['id'] . '">' . $row['nome_arquivo'] . '</option>';
         }
     }
 }
 function listarDocumentos($arquivos = null)
 {
     connectSQL();
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_DOCUMENTOS . " WHERE modulo IS NULL AND ativo = 'S'");
     while ($row = mysql_fetch_array($query)) {
         if (in_array($row['id'], $arquivos)) {
             echo '<option selected="selected" value="' . $row['id'] . '">' . $row['cod_documento'] . '</option>';
         } else {
             echo '<option value="' . $row['id'] . '">' . utf8_decode($row['cod_documento']) . '</option>';
         }
     }
 }
 function listarEmpresa($id = null)
 {
     connectSQL();
     $sql = "SELECT id, nome FROM " . MYSQL_BASE_EMPRESAS . " WHERE ativo = 'S' AND id IN (1,3,5,6) ORDER BY nome ASC";
     $res = mysql_query($sql);
     while ($row = mysql_fetch_assoc($res)) {
         if ($row['id'] == $id) {
             echo '<option selected="selected" value="' . $row['id'] . '">' . $row['nome'] . '</option>';
         } else {
             echo '<option value="' . $row['id'] . '">' . $row['nome'] . '</option>';
         }
     }
 }
Example #8
0
 function listarSetores($id = null)
 {
     connectSQL();
     $where = "";
     if ($id > 0) {
         $where = " AND id_setor != " . $id;
     }
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_SETOR . " WHERE status='S' AND id NOT IN (SELECT id_setor FROM " . MYSQL_BASE_SETOR_FINALIZA . " WHERE status = 'S' " . $where . ")");
     while ($row = mysql_fetch_array($query)) {
         if ($id == $row['id']) {
             echo '<option selected="selected" value="' . $row['id'] . '">' . $row['nome'] . '</option>';
         } else {
             echo '<option value="' . $row['id'] . '">' . $row['nome'] . '</option>';
         }
     }
 }
Example #9
0
 public function GravarPergunta($pedidoInformacao)
 {
     try {
         $query = "INSERT INTO " . MYSQL_BASE_PEDIDO_INFORMACAO_ARQUIVO . " (id, id_pedido_informacao, id_lista_arquivo, pergunta, file, dat_pergunta) ";
         $query .= "VALUES (NULL, ?, ?, ?, ?, NOW())";
         $stmt = $this->p->prepare($query);
         $stmt->bindValue(1, $pedidoInformacao->getPedidoInformacao());
         $stmt->bindValue(2, $pedidoInformacao->getListaArquivo());
         $stmt->bindValue(3, $pedidoInformacao->getPergunta());
         $stmt->bindValue(4, $pedidoInformacao->getFile());
         if (!$stmt->execute()) {
             return $stmt->errorInfo();
         } else {
             $DAO = new PedidoInformacaoDAO();
             connectSQL();
             // 				return $this->p->lastInsertId();
             $sql_remessa = mysql_query("SELECT\r\n\t\t\t\t\t\t\t\t\t\t \tA.id_remessa_lista, \r\n\t\t\t\t\t\t\t\t\t\t   \tB.id_nucleo, \r\n\t\t\t\t\t\t\t\t\t\t\tB.id_contrato, \r\n\t\t\t\t\t\t\t\t\t\t\tB.id_obra, \r\n\t\t\t\t\t\t\t\t\t\t\tB.id_trecho, \r\n\t\t\t\t\t\t\t\t\t\t\tB.id_fase_projeto,\r\n\t\t\t\t\t\t\t\t\t\t\tB.id_disciplina,\r\n\t\t\t\t\t\t\t\t\t\t\tB.id_tipo_documento,\r\n\t\t\t\t\t\t\t\t\t\t\tB.sequencial \r\n\t\t\t\t\t\t\t\t\t\tFROM " . MYSQL_BASE_REMESSA_ARQUIVOS . " A\r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_REMESSA_LISTAS . " B ON A.id_remessa_lista = B.id\r\n\t\t\t\t\t\t\t\t\tWHERE A.excluido IS NULL\r\n\t\t\t\t\t\t\t\t\tAND A.id = " . $pedidoInformacao->getListaArquivo());
             while ($item = mysql_fetch_array($sql_remessa)) {
                 $id_remessa_lista = $item['id_remessa_lista'];
                 $id_obra = $item['id_remessa_lista'];
                 $id_fase = $item['id_fase_projeto'];
                 $id_disciplina = $item['id_disciplina'];
                 $id_tipo_doc = $item['id_tipo_documento'];
                 $sequencial = $item['id_tipo_documento'];
             }
             $sql_pi = mysql_query("SELECT criado\r\n\t\t\t\t\t\t\t\t\tFROM " . MYSQL_BASE_PEDIDO_INFORMACAO . "\r\n\t\t\t\t\t\t\t\t\tWHERE excluido IS NULL\r\n\t\t\t\t\t\t\t\t\tAND id = " . $pedidoInformacao->getPedidoInformacao() . " LIMIT 1");
             while ($item = mysql_fetch_array($sql_pi)) {
                 $data_pi = $item['criado'];
             }
             $sql = mysql_query("SELECT id_cad_projeto \r\n\t\t\t\t\t\t\t\t\tFROM " . MYSQL_BASE_PROJETO_CADASTRO . "\r\n\t\t\t\t\t\t\t\t\tWHERE excluido IS NULL\r\n\t\t\t\t\t\t\t\t\tAND id_obra = " . $id_obra . "\r\n\t\t\t\t\t\t\t\t\tAND id_fase = " . $id_fase . "\r\n\t\t\t\t\t\t\t\t\tAND id_disciplina = " . $id_disciplina . "\r\n\t\t\t\t\t\t\t\t\tAND id_tipo_doc = " . $id_tipo_doc . "\r\n\t\t\t\t\t\t\t\t\tAND id_nucleo IS NULL\r\n\t\t\t\t\t\t\t\t\tAND numero = " . $sequencial . " LIMIT 1");
             while ($item = mysql_fetch_array($sql)) {
                 $id_projeto_cad = $item['id_cad_projeto'];
             }
             $resultado = $DAO->AtualizarProjetoTerceirizada($pedidoInformacao->getPedidoInformacao(), $data_pi, $id_projeto_cad);
             return 1;
         }
         // fecho a conex���o
         $this->p->__destruct();
         // caso ocorra um erro, retorna o erro;
     } catch (PDOException $ex) {
         echo "Mensagem de erro: " . $ex->getMessage();
     }
 }
Example #10
0
 function gravaTrimestre()
 {
     connectSQL();
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_MEDICAO . " WHERE finalizado = 'S' AND esta_trimestre = 'N' ORDER BY id ASC LIMIT 3");
     if (mysql_num_rows($query) == 3) {
         $q1 = "INSERT INTO " . MYSQL_BASE_MEDICAO_TRIMESTRE . " VALUES (NULL";
         while ($row = mysql_fetch_array($query)) {
             $q1 .= ", " . $row['id'];
             mysql_query("UPDATE " . MYSQL_BASE_MEDICAO . " SET esta_trimestre = 'S' WHERE id=" . $row['id']);
         }
         $q1 .= ", 'S', NOW(), NOW(), " . userId() . ")";
         $resultado = mysql_query($q1);
         $lastId = mysql_insert_id();
         $user = userId();
         mysql_query("INSERT INTO " . MYSQL_BASE_MEDICAO_TRIMESTRE_EMPRESA . " (id, id_medicao_trimestre, id_empresa, criado, status, id_usuario) VALUES \r\n\t\t\t\t\t(NULL, " . $lastId . ", 1, NOW(), 'S', " . $user . ")");
         mysql_query("INSERT INTO " . MYSQL_BASE_MEDICAO_TRIMESTRE_EMPRESA . " (id, id_medicao_trimestre, id_empresa, criado, status, id_usuario) VALUES\r\n\t\t\t\t\t(NULL, " . $lastId . ", 3, NOW(), 'S', " . $user . ")");
         mysql_query("INSERT INTO " . MYSQL_BASE_MEDICAO_TRIMESTRE_EMPRESA . " (id, id_medicao_trimestre, id_empresa, criado, status, id_usuario) VALUES \r\n\t\t\t\t\t(NULL, " . $lastId . ", 5, NOW(), 'S', " . $user . ")");
         mysql_query("INSERT INTO " . MYSQL_BASE_MEDICAO_TRIMESTRE_EMPRESA . " (id, id_medicao_trimestre, id_empresa, criado, status, id_usuario) VALUES \r\n\t\t\t\t\t(NULL, " . $lastId . ", 6, NOW(), 'S', " . $user . ")");
     }
 }
Example #11
0
 public function SubirArquivoComentado($fluxo)
 {
     connectSQL();
     $versao = 0;
     $query = mysql_query("SELECT versao FROM " . MYSQL_BASE_ARQUIVOS . " WHERE principal = 'S' AND id_documento = " . $fluxo->getIdDocumento());
     while ($row = mysql_fetch_array($query)) {
         $versao = $row['versao'] + 1;
     }
     $query = mysql_query("UPDATE " . MYSQL_BASE_ARQUIVOS . " SET principal = 'N' WHERE principal = 'S' AND id_documento = " . $fluxo->getIdDocumento());
     $uploadDir = '../../arquivos/';
     $name = sha1(date("d-m-Y H:i:s"));
     $uploadFile = $uploadDir . $name;
     $extension = pathinfo($fluxo->getArquivoComentado()['name'], PATHINFO_EXTENSION);
     $uploadFile = $uploadFile . '.' . $extension;
     if (!empty($fluxo->getArquivoComentado()['name'])) {
         $name = "../" . $name . '.' . $extension;
     } else {
         $name = NULL;
     }
     //Fazer o Upload do arquivo
     move_uploaded_file($fluxo->getArquivoComentado()['tmp_name'], $uploadFile);
     try {
         $query = "INSERT INTO " . MYSQL_BASE_ARQUIVOS . " VALUES (NULL, ?, ?, NOW(), ?, ?, 'S')";
         $stmt = $this->p->prepare($query);
         $stmt->bindValue(1, $fluxo->getIdDocumento());
         $stmt->bindValue(2, userId());
         $stmt->bindValue(3, $versao);
         $stmt->bindValue(4, $name);
         if (!$stmt->execute()) {
             return $stmt->errorInfo();
         } else {
             return 1;
         }
         // fecho a conex�o
         $this->p->__destruct();
         // caso ocorra um erro, retorna o erro;
     } catch (PDOException $ex) {
         echo "Mensagem de erro: " . $ex->getMessage();
     }
 }
Example #12
0
function getCambio($dataInicial, $dataFinal)
{
    connectSQL();
    $query = mysql_query("SELECT cambio, id FROM " . MYSQL_BASE_CAMBIO . " WHERE status = 'S' AND (data BETWEEN '{$dataInicial}' AND '{$dataFinal}')");
    $retorno = 1;
    while ($row = mysql_fetch_array($query)) {
        if ($row['id'] == 7) {
            $retorno = 0.02197;
        } elseif ($row['id'] == 1) {
            $retorno = 0.02188;
        } else {
            $retorno = $row['cambio'];
        }
    }
    return $retorno;
}
Example #13
0
 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>';
     }
 }
Example #14
0
 function listarCaixas($valor)
 {
     connectSQL();
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_LOCAIS . " WHERE ativo = 'S' AND id_modulo=2");
     while ($item = mysql_fetch_array($query)) {
         if ($valor == $item['id']) {
             echo '<option selected="selected" value="' . $item['id'] . '">' . $item['nome'] . ' - ' . $item['descricao'] . '</option>';
         } else {
             echo '<option value="' . $item['id'] . '">' . $item['nome'] . ' - ' . $item['descricao'] . '</option>';
         }
     }
 }
Example #15
0
 function ListarGRDDocumentoV($id)
 {
     $DAO = new DocumentoDAO();
     $resultado = $DAO->Listar("SELECT A.*, B.id AS id_doc, B.assunto, B.cod_documento AS codDocumento  \r\n\t\t\t\t\t\t\t\t\tFROM " . MYSQL_BASE_GRD_DOCUMENTOS . " A \r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_DOCUMENTOS . " B ON B.id = A.cod_documento \r\n\t\t\t\t\t\t\t\t   WHERE A.dat_excluido IS NULL AND A.id_grd=" . $id . " GROUP BY A.id ORDER BY B.cod_documento");
     $confirm = "return confirm('Deseja remover esse registro?');";
     $ordem = 1;
     foreach ($resultado as $item) {
         $res = $DAO->Listar("SELECT versao FROM " . MYSQL_BASE_DOCUMENTO_ARQUIVOS . " WHERE principal = 'S' AND id_documento =" . $item['id_doc']);
         connectSQL();
         $query = mysql_query("SELECT * FROM " . MYSQL_BASE_CHECK_LISTS . " WHERE ativo = 'S' AND nome_arquivo LIKE '" . $item['codDocumento'] . "%'");
         $titulo = "";
         while ($row = mysql_fetch_array($query)) {
             $titulo = $row['titulo'];
         }
         echo '<tr>';
         echo '	<td nowrap>' . $ordem . '</td>';
         echo '	<td nowrap>' . $item['codDocumento'] . '</td>';
         echo '	<td nowrap>' . $titulo . '</td>';
         echo '</tr>';
         $ordem = $ordem + 1;
         $this->p->__destruct();
     }
 }
<?php

require_once 'datas.php';
require_once 'praveenlib.php';
$conn = connectSQL($dbdetails);
if ($conn) {
    $username = safeString($conn, $_POST['username']);
    $password = safeString($conn, $_POST['password']);
    $sql = "select userid from login where username='******' and password='******'";
    //echo $sql."\n";
    $rs = $conn->query($sql);
    if ($rs) {
        if ($rs->num_rows === 1) {
            $row = $rs->fetch_array();
            echo "success`" . $row['userid'];
        } else {
            echo "fail";
        }
    } else {
        echo $conn->error;
    }
} else {
    echo $conn->error;
}
Example #17
0
 function salvarAcumulados($id)
 {
     connectSQL();
     //Pegando o total de despesas nao reembolsavel - Por empresa
     $query = mysql_query("SELECT\r\n\t\t\t\t\t\t\t\tNRI.id_empresa,\r\n\t\t\t\t\t\t\t\tNR.nome, \r\n\t\t\t\t\t\t\t\tNRI.* \r\n\t\t\t\t\t\t\tFROM \r\n\t\t\t\t\t\t\t\t" . MYSQL_BASE_MEDICAO_NAOREEMBOLSAVEL_ITEM . " NRI\r\n\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_MEDICAO_NAOREEMBOLSAVEL . " NR ON NR.id = NRI.id_naoreembolsavel\r\n\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_MEDICAO . " M ON M.id = NRI.id_medicao\r\n\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_PRESTACAO_CONTAS . " PC ON MONTH(PC.data_referencia) = MONTH(M.ref_inicio) AND YEAR(PC.data_referencia) = YEAR(M.ref_inicio)\r\n\t\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\t\tPC.id = " . $id . " AND \r\n\t\t\t\t\t\t\t\tNRI.excluido IS NULL");
     $total_nao_reem_cmat = 0;
     $total_nao_reem_vetec = 0;
     $table = "";
     while ($row = mysql_fetch_array($query)) {
         $total = round($row['quantidade'] * $row['valor'], 2);
         if ($row['id_empresa'] == 1) {
             $total_nao_reem_cmat += $total;
         } else {
             $total_nao_reem_vetec += $total;
         }
     }
     //Pegando o total de despesas reembolsavel - Por empresa
     $query = mysql_query("SELECT\r\n\t\t\t\t\t\t\t\t\tSUM(MAI.valor) total,\r\n\t\t\t\t\t\t\t\t\tMAI.id_empresa\r\n\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t\t" . MYSQL_BASE_MEDICAO_ANEXOS . " MA\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_MEDICAO_ANEXO_ITENS . " MAI ON MA.id = MAI.id_medicao_anexo\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_MEDICAO . " M ON M.id = MA.id_medicao\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_PRESTACAO_CONTAS . " PC ON MONTH(PC.data_referencia) = MONTH(M.ref_inicio) AND YEAR(PC.data_referencia) = YEAR(M.ref_inicio)\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tPC.id = " . $id . " AND\r\n\t\t\t\t\t\t\t\t\tMAI.status = 'S' AND\r\n\t\t\t\t\t\t\t\t\tMAI.id_empresa IN (1,3)\r\n\t\t\t\t\t\t\t\tGROUP BY MAI.id_empresa");
     $total_reembolsavel_cmat = 0;
     $total_reembolsavel_vetec = 0;
     while ($row = mysql_fetch_array($query)) {
         if ($row['id_empresa'] == 1) {
             $total_reembolsavel_cmat = $row['total'];
         } else {
             $total_reembolsavel_vetec = $row['total'];
         }
     }
     //Total por empresa e por tipo de contratacao
     $query = mysql_query("SELECT\r\n\t\t\t\t\t\t\t\t\tCI1.nome as cargo,\r\n\t\t\t\t\t\t\t\t\tP1.nome_completo,\r\n\t\t\t\t\t\t\t\t\tMIPE.quantidade,\r\n\t\t\t\t\t\t\t\t\tMIPE.salario,\r\n\t\t\t\t\t\t\t\t\tP1.tipo_contratacao,\r\n    \t\t\t\t\t\t\t\tMIPE.id_empresa,\r\n\t\t\t\t\t\t\t\t\t(SELECT COUNT(id) FROM tb_medicao_item_pessoa WHERE id_pessoa = MIPE.id_pessoa AND id_medicao = MIPE.id_medicao AND dat_excluido = '000-00-00 00:00:00') as contador\r\n\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t\t" . MYSQL_BASE_MEDICAO_ITEM_PESSOA_EXTERNA . " MIPE\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_PESSOAS . " P1 ON P1.id = MIPE.id_pessoa\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_CONTRATO_ITEM . " CI1 ON CI1.id = MIPE.id_medicao_item\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tMIPE.dat_excluido = '000-00-00 00:00:00' AND\r\n\t\t\t\t\t\t\t\t\tMIPE.id_medicao = " . $id . " AND\r\n\t\t\t\t\t\t\t\t\tMIPE.salario > 0\r\n\t\t\t\t\t\t\t\tORDER BY P1.tipo_contratacao DESC, MIPE.salario DESC;");
     $total_cmat_pj = 0;
     $total_cmat_ctl = 0;
     $total_vetec_pj = 0;
     $total_vetec_ctl = 0;
     while ($row = mysql_fetch_array($query)) {
         $salario = $row['salario'];
         $quantidade = $row['quantidade'];
         //populando CMAT CLT
         if ($row['id_empresa'] == 1 && $row['tipo_contratacao'] == 1) {
             $total_cmat_ctl += round($quantidade * $salario, 2);
         }
         //populando CMAT PJ
         if ($row['id_empresa'] == 1 && $row['tipo_contratacao'] == 2) {
             $total_cmat_pj += round($quantidade * $salario, 2);
         }
         //populando VETEC CLT
         if ($row['id_empresa'] == 3 && $row['tipo_contratacao'] == 1) {
             $total_vetec_ctl += round($quantidade * $salario, 2);
         }
         //populando VETEC PJ
         if ($row['id_empresa'] == 3 && $row['tipo_contratacao'] == 2) {
             $total_vetec_pj += round($quantidade * $salario, 2);
         }
     }
     /**
      * @author Anderson Freitas
      * @var unknown
      * Esse trecho do codigo e para calcular o saldo da fatura de cada empresa e salvar no banco de dados
      */
     //     	$query = mysql_query("SELECT
     // 							SUM(MAI.valor) total,
     // 							MAI.id_empresa
     // 						FROM
     // 							".MYSQL_BASE_MEDICAO_ANEXOS." MA
     // 							INNER JOIN ".MYSQL_BASE_MEDICAO_ANEXO_ITENS." MAI ON MA.id = MAI.id_medicao_anexo
     // 							INNER JOIN ".MYSQL_BASE_MEDICAO." M ON M.id = MA.id_medicao
     // 							INNER JOIN ".MYSQL_BASE_PRESTACAO_CONTAS." PC ON MONTH(PC.data_referencia) = MONTH(M.ref_inicio) AND YEAR(PC.data_referencia) = YEAR(M.ref_inicio)
     // 						WHERE
     // 							PC.id = ".$id." AND
     // 							MAI.status = 'S' AND
     // 							MAI.id_empresa IN (1,3)
     // 						GROUP BY MAI.id_empresa");
     //     	$total_reembolsavel_cmat = 0;
     //     	$total_reembolsavel_vetec = 0;
     //     	while($row = mysql_fetch_array($query)){
     //     		if($row['id_empresa'] == 1){
     //     			$total_reembolsavel_cmat = $row['total'];
     //     		}else{
     //     			$total_reembolsavel_vetec = $row['total'];
     //     		}
     //     	}
     $query = mysql_query("SELECT\r\n\t\t\t\t\t\t\tMIP.id_empresa,\r\n\t\t\t\t\t\t\tSUM(MIP.quantidade) as quantidade,\r\n\t\t\t\t\t\t\tSUM(ROUND(MIP.quantidade * CI.valor_unitario,2)) as valor,\r\n\t\t\t\t\t\t\tSUM(MIP.quantidade * CI.valor_unitario) as valor_total,\r\n    \t\t\t\t\t\tM.id_contrato\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t" . MYSQL_BASE_MEDICAO_ITEM_PESSOA . " MIP\r\n\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_PESSOAS . " P ON P.id = MIP.id_pessoa\r\n\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_CONTRATO_ITEM . " CI ON CI.id = MIP.id_medicao_item\r\n\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_MEDICAO . " M ON M.id = MIP.id_medicao\r\n\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_PRESTACAO_CONTAS . " PC ON MONTH(PC.data_referencia) = MONTH(M.ref_inicio) AND YEAR(PC.data_referencia) = YEAR(M.ref_inicio)\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\tMIP.dat_excluido = '000-00-00 00:00:00' AND\r\n\t\t\t\t\t\t\tMIP.id_empresa IN (1,3) AND\r\n\t\t\t\t\t\t\tPC.id = " . $id . "\r\n    \t\t\t\t\tGROUP BY MIP.id_medicao, MIP.id_empresa");
     $parcela_dedutivel_med_mes_cmat = 0;
     $remuneracao_pessoal_med_mes_cmat = 0;
     $remuneracao_pessoal_med_mes_vetec = 0;
     $total_fatura_cmat = 0;
     $total_fatura_vetec = 0;
     while ($row = mysql_fetch_array($query)) {
         if ($row['id_empresa'] == 1) {
             $remuneracao_pessoal_med_mes_cmat = round($row['valor'], 2);
             if ($id == 8 && $row['id_contrato'] == 1) {
                 $remuneracao_pessoal_med_mes_cmat += 0.01;
             }
             $total_fatura_cmat += $remuneracao_pessoal_med_mes_cmat + round($remuneracao_pessoal_med_mes_cmat * 0.1662, 2) + $total_reembolsavel_cmat;
         } else {
             $remuneracao_pessoal_med_mes_vetec = round($row['valor'], 2);
             $total_fatura_vetec += $remuneracao_pessoal_med_mes_vetec + round($remuneracao_pessoal_med_mes_vetec * 0.1662, 2) + $total_reembolsavel_vetec;
         }
     }
     if ($id == 16) {
         $total_fatura_cmat += 0.03;
         //esse
     }
     $total_fatura = $total_fatura_cmat + $total_fatura_vetec;
     $saldo_fatura_cmat = round($total_fatura_cmat - $total_fatura * 0.6263, 2);
     $saldo_fatura_vetec = round($total_fatura_vetec - $total_fatura * 0.3737, 2);
     /**
      * @author Anderson Freitas
      * @var unknown
      * Finalizando o codigo para salvar o saldo do faturamento por empresa
      */
     $taxa_coordenacao_consorcio = round($total_fatura * 0.03, 2);
     $indice_aplicados = 0.8825;
     $encargos_vetec = round($indice_aplicados * $total_vetec_ctl, 2);
     $encargos_cmat = round($indice_aplicados * $total_cmat_ctl, 2);
     $total_pessoa_cmat = $encargos_cmat + $total_cmat_pj + $total_cmat_ctl;
     $total_pessoa_vetec = $encargos_vetec + $total_vetec_pj + $total_vetec_ctl;
     $total_despesas_cmat = $total_pessoa_cmat + $total_nao_reem_cmat + $total_reembolsavel_cmat;
     $despesas_mes_cmat = $total_pessoa_cmat + $total_nao_reem_cmat + $total_reembolsavel_cmat + $taxa_coordenacao_consorcio;
     //novo
     $total_despesas_vetec = $total_pessoa_vetec + $total_nao_reem_vetec + $total_reembolsavel_vetec;
     $total_despesas_consorcio = $total_despesas_cmat + $total_despesas_vetec;
     //----mexer aqui-----//
     $saldo_desp_cmat = $total_despesas_cmat - round($total_despesas_consorcio * 0.6263, 2);
     $saldo_desp_vetec = $total_despesas_vetec - round($total_despesas_consorcio * 0.3737, 2);
     //-----fim----------//
     $update = mysql_query("UPDATE " . MYSQL_BASE_PRESTACAO_CONTAS . " \r\n    \t\t\t\t\t\t\tSET saldo_fatu_cmat \t= " . $saldo_fatura_cmat . ", \r\n    \t\t\t\t\t\t\t\tsaldo_fatu_vetec \t= " . $saldo_fatura_vetec . ", \r\n    \t\t\t\t\t\t\t\ttotal_desp_cmat \t= " . $total_despesas_cmat . ", \r\n    \t\t\t\t\t\t\t\ttotal_desp_vetec \t= " . $total_despesas_vetec . ", \r\n    \t\t\t\t\t\t\t\tsaldo_desp_cmat \t= " . $saldo_desp_cmat . ", \r\n    \t\t\t\t\t\t\t\tsaldo_desp_vetec \t= " . $saldo_desp_vetec . ",\r\n    \t\t\t\t\t\t\t\tfatura_mes_cmat \t= " . $total_fatura_cmat . ",\r\n    \t\t\t\t\t\t\t\tfatura_mes_vetec \t= " . $total_fatura_vetec . ",\r\n    \t\t\t\t\t\t\t\tdespesa_mes_cmat \t= " . $despesas_mes_cmat . ",\r\n    \t\t\t\t\t\t\t\tdespesa_mes_vetec \t= " . $total_despesas_vetec . "\r\n    \t\t\t\t\t\t\tWHERE id = " . $id);
 }
Example #18
0
 function listarTipoDeDocumento($id)
 {
     connectSQL();
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_FASE_PROJETOS . " WHERE ativo = 'S' ORDER BY nome");
     while ($row = mysql_fetch_array($query)) {
         if ($row['id'] == $id) {
             echo '<option selected="selected" value="' . $row['id'] . '">' . $row['nome'] . '</option>';
         } else {
             echo '<option value="' . $row['id'] . '">' . $row['nome'] . '</option>';
         }
     }
 }
Example #19
0
 public function ListarRemessa($query = null)
 {
     try {
         if ($query == null) {
             connectSQL();
             $query = mysql_query("SELECT * FROM " . MYSQL_BASE_RESPONSAVEL_DISCIPLINA . " \r\n\t\t\t\t\t\t\t\t\t  WHERE excluido IS NULL AND aprovador_verificador = 'V' AND verificador = " . userId());
             $array = array();
             while ($row = mysql_fetch_array($query)) {
                 $array[] = $row['id_disciplina'];
             }
             /*Lista todos os documentos entregues pelo terceiros que ainda n�o foram verificados pelo Consorcio*/
             $stmt = $this->p->query("SELECT \r\n\t\t\t\t\t\t\t\t\t\t\tA.id, \r\n\t\t\t\t\t\t\t\t\t\t\tA.id_remessa_lista AS lista, \r\n\t\t\t\t\t\t\t\t\t\t\tA.file AS nome_arquivo, \r\n\t\t\t\t\t\t\t\t\t\t\tB.nome AS nome_disciplina,\r\n\t\t\t\t\t\t\t\t\t\t\tA.id_disciplina,\r\n\t\t\t\t\t\t\t\t\t\t\tD.nome AS nome_fase,\r\n\t\t\t\t\t\t\t\t\t\t\tE.nome AS nome_obra,\r\n\t\t\t\t\t\t\t\t\t\t\tF.nome AS nome_tipo_documento,\r\n\t\t\t\t\t\t\t\t\t\t\tDATE_FORMAT(A.criado, '%d/%m/%Y') as data_entrada\r\n\t\t\t\t\t\t\t\t\t\tFROM " . MYSQL_BASE_REMESSA_ARQUIVOS . " \t\tA\r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_DISCIPLINAS . " \t\tB ON A.id_disciplina  = B.id\r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_REMESSA_LISTAS . " \tC ON A.id_remessa_lista = C.id\r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_FASE_PROJETOS . " \tD ON D.id = A.id_fase_projeto\r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_PROJETO_OBRA . " \t\tE ON E.id = A.id_obra\r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_TIPO_DOCUMENTOS . " \tF ON F.id = A.id_tipo_documento\r\n\t\t\t\t\t\t\t\t\t\tWHERE A.finalizado IS NULL\r\n\t\t\t\t\t\t\t\t\t\t  AND (A.titulo IS NOT NULL OR A.titulo != '')\r\n\t\t\t\t\t\t\t\t\t\t  AND A.excluido IS NULL\r\n\t\t\t\t\t\t\t\t\t\t  AND C.excluido IS NULL\r\n\t\t\t\t\t\t\t\t\t\t  AND A.id NOT IN (SELECT A.id \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . MYSQL_BASE_REMESSA_ARQUIVOS . " A\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_CHECK_LISTS . " B ON B.id_remessa_arquivo = A.id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE B.ativo='S')\r\n\t\t\t\t\t\t\t\t\t\tORDER BY A.id DESC");
             $confirm = "return confirm('Deseja remover esse registro?');";
             $ordem = 0;
             foreach ($stmt as $item) {
                 $nome_arquivo = explode(".", $item['nome_arquivo']);
                 if (in_array($item['id_disciplina'], $array) || userId() == 272) {
                     if (in_array($item['id_disciplina'], $array)) {
                         $btn_aprovar = ' <a data-rel="tooltip" title="Verificar" class="btn btn-success" href="new.php?id=' . $item['id'] . '"><i class="icon-ok icon-white"></i></a>';
                         $visualizar = '';
                     }
                     $btn_substituir = ' <a data-rel="tooltip" title="Substituir" class="btn btn-warning" href="substituir_projeto.php?id=' . $item['id'] . '&local=verificador"><i class="icon-refresh icon-white"></i></a>';
                 } else {
                     $btn_aprovar = '';
                     $btn_substituir = '';
                     $visualizar = ' <a data-rel="tooltip" title="Visualizar" class="btn btn-info" href="../../arquivos/remessa/' . $item['nome_arquivo'] . '" target="_blank"><i class="icon-eye-open icon-white"></i></a>';
                 }
                 echo '<tr>';
                 echo '	<td style="display:none">' . $ordem . '</td>';
                 echo '	<td>' . $item['id'] . '</td>';
                 echo '	<td><a href="../../arquivos/remessa/' . $item['nome_arquivo'] . '" target="_blank"> ' . $nome_arquivo[0] . '</a></td>';
                 echo '	<td>' . $item['lista'] . '</td>';
                 echo '	<td>' . $item['data_entrada'] . '</td>';
                 echo '	<td>' . $item['nome_disciplina'] . '</td>';
                 echo '	<td>' . $item['nome_tipo_documento'] . '</td>';
                 echo '	<td>' . $item['nome_fase'] . '</td>';
                 echo '	<td>' . $item['nome_obra'] . '</td>';
                 echo '	<td>';
                 if (in_array(12, listarAcesso())) {
                     echo $btn_aprovar;
                 }
                 if (in_array(12, listarAcesso())) {
                     echo $btn_substituir;
                 }
                 if (in_array(18, listarAcesso())) {
                     echo $visualizar;
                 }
                 echo '	</td>';
                 echo '</tr>';
                 $ordem = $ordem + 1;
             }
         } else {
             $stmt = $this->p->query($query);
             return $stmt;
         }
         $this->p = null;
     } catch (PDOException $ex) {
         echo "Erro 10: " . $ex->getMessage();
     }
 }
Example #20
0
 function zipar($id, $empresa = NULL)
 {
     $diretorio = INTERNAL_ROOT_PORTAL . '/arquivos/remessa/';
     $zip = new ZipArchive();
     if (file_exists($diretorio . "Lista_" . $id . ".zip")) {
         unlink($diretorio . "Lista_" . $id . ".zip");
     }
     if ($zip->open($diretorio . 'Lista_' . $id . '.zip', ZIPARCHIVE::CREATE) == TRUE) {
         connectSQL();
         $query = mysql_query("SELECT * FROM " . MYSQL_BASE_REMESSA_ARQUIVOS . " WHERE excluido IS NULL AND id_remessa_lista =" . $id);
         $count = 1;
         if (mysql_num_rows($query) > 0) {
             while ($row = mysql_fetch_array($query)) {
                 $explode = explode(".", $row['file']);
                 $ext = '.' . $explode[1];
                 //$zip->addFile($diretorio.$row['file'],$row['file'].$ext);
                 $zip->addFile($diretorio . $row['file'], str_replace('../', '', $row['file']));
                 $count += 1;
             }
             echo '<script language= "JavaScript">window.open("' . EXTERNAL_ROOT_PORTAL . '/arquivos/remessa/Lista_' . $id . '.zip","_blank");</script>';
         } else {
             $msg = "Não existe documentos cadastrados.";
             echo '<script language= "JavaScript">alert("' . $msg . '");</script>';
         }
     } else {
         echo '<script language= "JavaScript">alert("Erro ao baixar os comprovantes.");</script>';
     }
     $zip->close();
 }
Example #21
0
 public function Deletar($id)
 {
     connectSQL();
     try {
         $stmt = $this->p->prepare("UPDATE " . MYSQL_BASE_TRADUCAO_DOCUMENTOS . " SET excluido = NOW() WHERE id=? AND excluido IS NULL");
         $this->p->beginTransaction();
         $stmt->bindValue(1, $id);
         // executo a query preparada e verificando se ocorreu bem.
         if (!$stmt->execute()) {
             return $stmt->errorInfo();
         } else {
             $this->p->commit();
             return true;
         }
         // fecho a conex���o
         $this->p->__destruct();
         // caso ocorra um erro, retorna o erro;
     } catch (PDOException $ex) {
         echo "Erro: " . $ex->getMessage();
     }
 }
Example #22
0
 function listarPai($id)
 {
     connectSQL();
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_PROCEDIMENTO_LICITATORIO_ATIVIDADE . " WHERE excluido IS NULL");
     while ($item = mysql_fetch_array($query)) {
         if ($item['id'] == $id) {
             echo '<option selected="selected" value="' . $item['id'] . '">' . $item['nome'] . '</option>';
         } else {
             echo '<option value="' . $item['id'] . '">' . $item['nome'] . '</option>';
         }
     }
 }
Example #23
0
function getCliente()
{
    // conexion sql
    $dbSQL = connectSQL();
    // traigo todos los clientes
    $query = $dbSQL->prepare('SELECT A1_COD, A1_NOME, A1_TEL, A1_EMAIL, A1_END, A1_XESPROP, A1_XESINQU FROM SA1010 WHERE A1_COD = 103241');
    $query->execute();
    for ($i = 0; $row = $query->fetch(); $i++) {
        echo 'codigo:' . $row['A1_COD'] . ', nombre:' . utf8_decode(trim($row['A1_NOME'])) . ', telefono:' . $row['A1_TEL'] . ', email:' . $row['A1_EMAIL'] . ', direccion:' . $row['A1_END'] . ', propietario:' . $row['A1_XESPROP'] . ', inquilino:' . $row['A1_XESINQU'] . '<hr/>';
    }
}
Example #24
0
<?php

require_once "praveenlib.php";
require_once "applib.php";
$keys = array("eventId");
$respjson = array("status" => "unprocessed", "errorCode" => 1);
if (checkPOST($keys)) {
    $conn = connectSQL();
    if ($conn) {
        $eventId = safeString($conn, $_POST['eventId']);
        $sql = "delete from events  where eventId={$eventId}";
        if ($result = $conn->query($sql)) {
            $sql = "select userToken from users where id in (select userId from eventregistration where eventId={$eventId})";
            if ($result = $conn->query($sql)) {
                $ids = array();
                while ($row = $result->fetch_array()) {
                    $ids[] = $row[0];
                }
                $retJSON = sendPushNotification($ids, "Event Removed", $eventName . " is Removed");
                $respjson["pushReturn"] = $retJSON;
                $respjson["status"] = "Success";
                $respjson["errorCode"] = 0;
            } else {
                $respjson["status"] = "SQL error";
                $respjson["SqlError"] = $conn->error;
                $respjson["errorCode"] = 4;
            }
        } else {
            $respjson["status"] = "SQL error";
            $respjson["SqlError"] = $conn->error;
            $respjson['sql'] = $sql;
Example #25
0
 function getDataInicioDias($id_atividade, $dias)
 {
     $link = connectSQL();
     $pai = new Pai();
     $DAO = new PaiDAO();
     $query_r = mysql_query("SELECT dia FROM " . MYSQL_BASE_FERIADOS . " WHERE excluido IS NULL");
     $query_retorno = array();
     while ($row = mysql_fetch_array($query_r)) {
         $query_retorno[] = $row['dia'];
     }
     mysql_free_result($query_r);
     $query = mysql_query("SELECT ADDDATE(ADDDATE('" . $data_inicio . "', vencimento), (SELECT COUNT(*) FROM " . MYSQL_BASE_FERIADOS . " WHERE dia BETWEEN '" . $data_inicio . "' AND ADDDATE('" . $data_inicio . "', vencimento)) ) AS new_fim,\r\n\t\t\t\t\t\t\t\tdias_corridos\r\n\t\t\t\t\t\t\tFROM " . MYSQL_BASE_PROCEDIMENTO_LICITATORIO_ATIVIDADE . "\r\n\t\t\t\t\t\t\tWHERE excluido IS NULL\r\n\t\t\t\t\t\t\tAND dias_corridos = 'N'\r\n\t\t\t\t\t\t\tAND id = " . $id_atividade . "\r\n\t\t\t\t\t\t\t/*Consulta com calculo do Feriado + os dias Vencimentos*/\r\n\t\t\t\t\t\t\tUNION\r\n\t\t\t\t\t\t\tSELECT ADDDATE('" . $data_inicio . "', vencimento) AS new_fim,\r\n\t\t\t\t\t\t\t\tdias_corridos\r\n\t\t\t\t\t\t\tFROM " . MYSQL_BASE_PROCEDIMENTO_LICITATORIO_ATIVIDADE . "\r\n\t\t\t\t\t\t\tWHERE excluido IS NULL\r\n\t\t\t\t\t\t\tAND dias_corridos = 'S'\r\n\t\t\t\t\t\t\tAND id = " . $id_atividade);
     $res = array();
     // 		$dias_corridos = array();
     // 		$new_fim = array();
     while ($row = mysql_fetch_array($query)) {
         $new_fim[] = array();
         $dias_corridos[] = array();
         // 				'dias_corridos'	=> $row ['dias_corridos'],
         // 				'new_fim'		=> $row ['new_fim']
         $new_fim[] = $row['new_fim'];
         $dias_corridos[] = $row['dias_corridos'];
     }
     if ($dias_corridos == 'N') {
         //Se vencimento não são dias corridos, calcula feriados + sabados e domingos
         $fim = mysql_query("CALL sp_fim_de_semana (@retorno, '" . $data_inicio . "', '" . $new_fim . "');");
         while ($fim_semana = mysql_fetch_array($fim)) {
             $fim_de_semana = $fim_semana['qtd'];
             //Quantidade de Sabados e Domingos
         }
         mysql_free_result($fim);
         $data = date('Y/m/d', strtotime('+' . $fim_de_semana . ' days', strtotime($new_fim)));
         // Calculo Dias de Vencimentos + Feriados + Sabado e Domingos
         $new_data = $pai->verificaDataFim($data, $query_retorno);
     } else {
         $new_data = $new_fim;
         //Se vencimento são dias corridos, calcula data inicial + dias de vencimento
     }
     mysql_free_result($query);
     return $new_data;
 }
Example #26
0
 public function Listar($query = null)
 {
     try {
         $permissoes = listarAcesso();
         if ($query == null) {
             $stmt = $this->p->query("SELECT * FROM " . MYSQL_BASE_MEDICAO . " WHERE status = 'S' ORDER BY id DESC");
             $confirm = "return confirm('Deseja remover esse registro?');";
             $count = 1;
             foreach ($stmt as $item) {
                 connectSQL();
                 $query = mysql_query("SELECT ml.* FROM " . MYSQL_BASE_MEDICAO_LIBERACAO . " ml, " . MYSQL_BASE_PESSOAS . " p, " . MYSQL_BASE_USUARIOS . " u WHERE \r\n\t\t\t\t\t\t\tml.id_pessoa=p.id AND p.id = u.id_pessoa AND p.id = " . userId() . " AND ml.id_medicao = " . $item['id'] . " AND status = 'S' ORDER BY id DESC");
                 $explode = explode("-", $item['ref_inicio']);
                 if ($explode[1] == 1) {
                     $monthName = "Jan - " . $explode[0];
                 }
                 if ($explode[1] == 2) {
                     $monthName = "Fev - " . $explode[0];
                 }
                 if ($explode[1] == 3) {
                     $monthName = "Mar - " . $explode[0];
                 }
                 if ($explode[1] == 4) {
                     $monthName = "Abr - " . $explode[0];
                 }
                 if ($explode[1] == 5) {
                     $monthName = "Mai - " . $explode[0];
                 }
                 if ($explode[1] == 6) {
                     $monthName = "Jun - " . $explode[0];
                 }
                 if ($explode[1] == 7) {
                     $monthName = "Jul - " . $explode[0];
                 }
                 if ($explode[1] == 8) {
                     $monthName = "Ago - " . $explode[0];
                 }
                 if ($explode[1] == 9) {
                     $monthName = "Set - " . $explode[0];
                 }
                 if ($explode[1] == 10) {
                     $monthName = "Out - " . $explode[0];
                 }
                 if ($explode[1] == 11) {
                     $monthName = "Nov - " . $explode[0];
                 }
                 if ($explode[1] == 12) {
                     $monthName = "Dez - " . $explode[0];
                 }
                 //IF ELSE FEITO DE OUTRA FORMA
                 //$item['id_contrato'] == 1 ? $contrato = 'Contrato' : $contrato = 'Aditivo';
                 if ($item['id_contrato'] == 1) {
                     $contrato = 'Contrato';
                 } elseif ($item['id_contrato'] == 2) {
                     $contrato = 'Aditivo 2';
                 } else {
                     $contrato = 'Aditivo 3';
                 }
                 echo '<tr>';
                 echo '	<td style="display:none;">' . $count . '</td>';
                 echo '	<td>' . $item['numero'] . '</td>';
                 echo '	<td>' . $contrato . '</td>';
                 echo '	<td>' . $monthName . '</td>';
                 echo '	<td>' . dataBrasil($item['ref_inicio'], false) . ' - ' . dataBrasil($item['ref_fim'], false) . '</td>';
                 if ($item['finalizado'] == 'S') {
                     echo '<td><span class="label label-success">Fin. - Cad.</span></td>';
                 } else {
                     echo '<td><span class="label label-warning">Aberto - Cad.</span></td>';
                 }
                 echo '  <td>';
                 //Verifica se pode editar
                 if (1 > 2) {
                     echo '		<a class="btn btn-info" href="remuneracao.php?id=' . $item['id'] . '">';
                     echo '			<i class="icon-edit icon-white"></i> Remunera&ccedil;&atilde;o';
                     echo '		</a>';
                 }
                 //Verifica se pode editar
                 if (in_array(53, $permissoes)) {
                     echo '		<a class="btn btm btn-inverse" href="view.php?id=' . $item['id'] . '">';
                     echo '			<i class="icon-list icon-white"></i> Relat&oacute;rios';
                     echo '		</a>';
                 }
                 //Verifica se pode editar
                 if (in_array(84, $permissoes)) {
                     echo '		<a class="btn btn-inverse" href="index.php?cmd=compact&id=' . $item['id'] . '">';
                     echo '			<i class="icon-download-alt icon-white"></i> Comprovantes';
                     echo '		</a>';
                 }
                 //Botao pra reabrir a medicao
                 if (in_array(56, $permissoes) && $item['finalizado'] == 'S') {
                     echo '		<a data-rel="tooltip" title="Reabrir" class="btn btn-info" href="index.php?cmd=reabrir&id=' . $item['id'] . '">';
                     echo '<i class="icon-retweet icon-white"></i>';
                     echo '</a>';
                 }
                 if (mysql_num_rows($query) == 1) {
                     //Verifica se pode editar
                     if (in_array(54, $permissoes) && $item['finalizado'] != 'S') {
                         echo '		<a data-rel="tooltip" title="Rel. Pessoal" class="btn btn-info" href="rel_pessoal.php?id=' . $item['id'] . '">';
                         echo '			<i class="icon-user icon-white"></i>';
                         echo '		</a>';
                     }
                     //Verifica se pode editar
                     if (in_array(55, $permissoes) && $item['finalizado'] != 'S') {
                         echo '		<a data-rel="tooltip" title="Anexo" class="btn btn-warning" href="anexo.php?id=' . $item['id'] . '">';
                         echo '			<span class="icon icon-white icon-attachment"></span>';
                         echo '		</a>';
                     }
                     if (in_array(56, $permissoes) && $item['finalizado'] != 'S') {
                         // 							echo '		<a class="btn btn-success" href="finalizado.php?id=' . $item ['id'] . '">';
                         // 							echo '			<i class="icon-ok icon-white"></i> Finalizar';
                         // 							echo '		</a>';
                         echo '		<a  data-rel="tooltip" title="Atualizar" class="btn btn-success" href="index.php?cmd=atualizar&id=' . $item['id'] . '">';
                         echo '			<i class="icon-refresh icon-white"></i>';
                         echo '		</a>';
                         echo '		<a  data-rel="tooltip" title="Finalizar" class="btn btn-success" href="index.php?cmd=finalizar&id=' . $item['id'] . '">';
                         echo '			<i class="icon-ok icon-white"></i>';
                         echo '		</a>';
                     }
                     //Botao de aprovacao
                     if (in_array(55, $permissoes)) {
                         echo '		<a data-rel="tooltip" title="Comp. Remunera&ccedil;&atilde;o" class="btn btn-success" href="comprovante.php?id=' . $item['id'] . '">';
                         echo '<i class="icon-list-alt icon-white"></i>';
                         echo '</a>';
                     }
                     //Verifica se pode editar
                     if (in_array(24, $permissoes) && 1 > 2) {
                         echo '		<a  class="btn btn-danger" onclick="' . $confirm . '" href="index.php?cmd=del&id=' . $item['id'] . '">';
                         echo '			<i class="icon-trash icon-white"></i> Deletar';
                         echo '		</a>';
                     }
                     echo '	</td>';
                     echo '</tr>';
                     $count += 1;
                 }
             }
         } else {
             $stmt = $this->p->query($query);
             return $stmt;
         }
         $this->p->__destruct();
     } catch (PDOException $ex) {
         echo "Erro: " . $ex->getMessage();
     }
 }
Example #27
0
 function __construct()
 {
     switch (func_get_art(0)) {
         case 'tag':
             $sqlstr = "SELECT COUNT(*) FROM pache_tag WHERE tagname = " . "'" . mysql_escape_string(func_get_arg(1)) . "'";
             break;
         case 'class':
             $sqlstr = "SELECT COUNT(*) FROM pache_article WHERE class = " . "'" . mysql_escape_string(func_get_arg(1)) . "'";
             break;
         default:
         case 'id':
             $sqlstr = "SELECT COUNT(*) FROM pache_article";
             break;
     }
     $sql = connectSQL();
     $sqlresult = mysql_query($sqlstr, $sql->con);
     if (!$sqlresult) {
         die('SQLfail: ' + mysql_error($sqlresult));
         return NULL;
     }
     $row = mysql_fetch_array($sqlresult);
     mysql_close($sql->con);
     $this->result = $row[0];
 }
Example #28
0
 function inserirEmProjeto($id_documento, $id_work_flow)
 {
     connectSQL();
     $checkList = new CheckList();
     $cod = "";
     $id_projeto_cad = 0;
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_DOCUMENTOS . " WHERE id = " . $id_documento);
     while ($row = mysql_fetch_array($query)) {
         $cod = $row['cod_documento'];
     }
     $explode = explode("-", $cod);
     $checkList->setCodigoProjeto($explode[0]);
     $checkList->setNucleo($explode[1]);
     $checkList->setContrato($explode[2]);
     $checkList->setProjetoObra($explode[3]);
     $checkList->setTrecho($explode[4]);
     $checkList->setFaseProjeto($explode[5]);
     $checkList->setDisciplina($explode[6]);
     $checkList->setTipoDocumento($explode[7]);
     $checkList->setSequencial($explode[8]);
     $checkList->setRevisao($explode[9]);
     $query = mysql_query("SELECT * FROM " . MYSQL_BASE_PROJETO_CADASTRO . " WHERE id_cod_projeto = " . $checkList->getCodigoProjeto() . " AND id_nucleo = " . $checkList->getNucleo() . " AND \r\n\t\t\t\t\t\t\t\tid_contrato = " . $checkList->getContrato() . " AND id_obra = " . $checkList->getProjetoObra() . " AND id_trecho = " . $checkList->getTrecho() . " AND \r\n\t\t\t\t\t\t\t\tid_fase = " . $checkList->getFaseProjeto() . " AND id_disciplina = " . $checkList->getDisciplina() . " AND id_tipo_doc = " . $checkList->getTipoDocumento() . " AND\r\n\t\t\t\t\t\t\t\tnumero = " . $checkList->getSequencial() . " LIMIT 1");
     while ($row = mysql_fetch_array($query)) {
         $id_projeto_cad = $row['id'];
     }
     $query = mysql_query("INSERT INTO " . MYSQL_BASE_PROJETO_CADASTRO_CLIENTE . " (id, id_projeto_cad, cod_entrada, data_entrada, status, criado, id_usuario) VALUES (NULL, " . $id_projeto_cad . ", \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $id_work_flow . "-WF', NOW(), 'P', NOW(), " . userId() . ")");
 }
Example #29
0
<?php

if (!empty($_GET['download']) && $_GET['download'] == 's') {
    $nome_arquivo = 'relatorio_reembolsavel';
    header("Content-type: application/vnd.ms-excel");
    header("Content-type: application/force-download");
    header("Content-Disposition: attachment; filename={$nome_arquivo}.xls");
    header("Pragma: no-cache");
}
include_once '../../includes.sys/ini.php';
include_once INTERNAL_ROOT_PORTAL . '/includes.sys/metodos.php';
connectSQL();
$id = limpaTexto($_GET['id']);
if ($_GET['grupo'] == 1) {
    $grupo = 1;
    $moeda = "R\$";
    $moeda2 = "R\$";
    $casas = 2;
    $nome_grupo = "- GROUPS 1 AND 3";
} else {
    $grupo = 2;
    $moeda = "JPY";
    $moeda2 = "";
    $casas = 0;
    $nome_grupo = "- GROUP 2";
}
$query = mysql_query("SELECT * FROM " . MYSQL_BASE_MEDICAO . " WHERE id=" . $id);
while ($row = mysql_fetch_array($query)) {
    $dt_inicio = dataBrasil($row['ref_inicio'], false);
    $dt_fim = dataBrasil($row['ref_fim'], false);
    $numero_med = $row['numero'];
Example #30
0
 function setTipoDocumento($tipoDocumento)
 {
     connectSQL();
     $query = mysql_query("SELECT id FROM " . MYSQL_BASE_TIPO_DOCUMENTOS . " WHERE codigo='" . $tipoDocumento . "' LIMIT 1");
     $row = mysql_fetch_array($query);
     if (mysql_num_rows($query) == 1) {
         $this->tipoDocumento = $row['id'];
     } else {
         $this->tipoDocumento = 0;
     }
 }