예제 #1
0
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once 'banco.php';
try {
    executa($sql);
    echo 0;
} catch (Exception $e) {
    echo 'Erro ao tentar executar o comando: +' . $sql . '\\n\\nErro capturado: ' . $e->getMessage();
}
예제 #2
0
<?php

include_once 'banco.php';
/* 
 *
 * ARQUIVO VÁLIDO APENAS PARA MYSQL E FIREBIRD!
 * PARA SQLITE CONSULTE sqlite.php.
 * 
 */
$tipo = isset($tipo) ? base64_decode($tipo) : 'consulta';
isset($sql) ? $comando = $sql : exit('<hr><h1 style="background-color:red;color:white;text-align:center">Tchau!!!</h1><hr>');
//echo $banco.' - ', $comando;die();
$tipo === 'consulta' ? $dados = consulta($comando) : executa($comando);
if (isset($dados)) {
    $th = array();
    foreach ($dados as $d) {
        foreach ($d as $chave => $valor) {
            //var_dump($d);
            $valor = trim($valor);
            if (!in_array($valor, $th)) {
                array_push($th, $valor);
            }
        }
    }
    $i = 0;
    while ($i < count($th)) {
        if ($th[$i] == $th[count($th) - 1]) {
            echo $th[$i] . "\n";
        } else {
            echo $th[$i] . ', ';
        }
    header('location:.');
} else {
    $descricao = $_POST['descricao'];
    $valor = $_POST['valor'];
    $data = $_POST['data'];
    $user = $_POST['usuario'];
    $pessoa = $_POST['pessoa'];
    $observacao = $_POST['observacao'];
    $pes = consulta('pessoas', 'idpessoa', "nome = '{$pessoa}'");
    foreach ($pes as $p) {
        $idpessoa = $p[0];
    }
    try {
        $comando = "insert into lancamentos (descricao, usuariocadastro, debito, data, pessoa, observacao) ";
        $comando .= "values ('{$descricao}', {$user}, {$valor}, '{$data}', {$idpessoa}, '{$observacao}')";
        executa($comando);
        echo '<p class="text-success text-center">cadastro efetuado com sucesso!</p>';
        echo '<p class="text-success text-center"><a href="#" id="ok">OK!</a></p>';
    } catch (Exception $ex) {
        echo '<p class="text-success text-center">não foi possível efetuar o cadastro!</p>';
        echo '<p class="text-success text-center"><a href="#" id="ok">OK!</a></p>';
    }
}
?>
<script>
$('#ok').click(function(event){
    event.preventDefault();
    $("#envelope").load("incluilancamentos.php");
});
</script>
예제 #4
0
</head>

<body>
<?php 
include_once 'banco.php';
if (isset($_POST['id'])) {
    $id = $_POST['id'];
    $contas = consulta('contas', 'idconta,nome', 'idconta = ' . $id);
    $linha = '';
    foreach ($contas as $c) {
        $linha .= '<tr>' . '<td>' . $c[0] . '</td>' . '<td>' . $c[1] . '</td>' . '<td>' . '<a class="btn btn-primary btn-xs" href="" id="editar">Editar</a> ' . '<a class="btn btn-success btn-xs" href="" id="baixar">Baixar</a> ' . '<a class="btn btn-danger btn-xs" href="" id="cancelar">Cancelar</a> ' . '<a class="btn btn-default btn-xs" href="" id="voltar">Voltar</a>' . '</td>' . '</tr>';
    }
}
if (isset($_POST['sql'])) {
    executa($_POST['sql']);
    echo '<script>alert("Conta cancelada com sucesso!");</script>';
}
?>
    
                    
                        <div class="panel-heading">
                            <i class="fa fa-calculator fa-fw"></i> Contas
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
											<th>Conta</th>