-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacao.php
110 lines (95 loc) · 3.36 KB
/
acao.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
include 'conf/conf.inc.php';
include 'connect/connect.php';
$acao = '';
if (isset($_GET["acao"]))
$acao = $_GET["acao"];
if (isset($_GET["tabela"]))
$tabela = $_GET["tabela"];
$tb_tabela = isset($_GET['tabela'])?$_GET['tabela']:0;
$campos = isset($_GET['campos'])?$_GET['campos']:0;
$pagina = isset($_GET['pagina'])?$_GET['pagina']:0;
$numero = isset($_GET['numero'])?$_GET['numero']:0;
$parentesa = "(";
$parentesf = ")";
if (isset($_GET["nome"]))
$nome = $_GET["nome"];
if ($acao == "excluir"){
$codigo = 0;
if (isset($_GET["acao"])){
$codigo = $_GET["codigo"];
$sql = "DELETE FROM $tb_tabela WHERE codigo = $codigo";
echo $sql;
$result = mysqli_query($conexao, $sql);
header ("location:".$nome);
}
}
if ($acao == "excluirestrangeiro"){
$codigoCompra = 0;
if (isset($_GET["acao"])){
$codigoCompra = $_GET["codigoCompra"];
$sql = "DELETE FROM $tb_tabela WHERE codigoCompra = $codigoCompra";
echo $sql;
$result = mysqli_query($conexao, $sql);
header ("location:".$nome);
}
}
if ($acao == 'salvar') {
$tb_tabela = isset($_GET['tabela'])?$_GET['tabela']:0;
$pagina = isset($_GET['pagina'])?$_GET['pagina']:0;
$numero = isset($_GET['numero'])?$_GET['numero']:0;
if (isset($_GET['n1'])) {
for ($i= 1; $i <= $numero ; $i++) {
$lugares[$i] = isset($_GET['n'.$i])?$_GET['n'.$i]:0;
}
$sql = "INSERT INTO ".$tb_tabela." ".$campos." VALUES ".$parentesa;
$i=1;
while ($i <= $numero) {
$data = DateTime::createfromFormat('d/m/Y', $lugares[$i]);
if ($data && $data->format('d/m/Y')) {
$lugares[$i] = str_replace("/", "-", $lugares[$i]);
$sql.= ",'".date("Y-m-d", strtotime($lugares[$i]))."'";
} else {
if ($i==$numero) {
$sql.= "'".$lugares[$i]."'";
}else
$sql.= "'".$lugares[$i]."', ";
}
$i++;
}
$sql.= $parentesf;
echo $sql;
$resultado = mysqli_query($conexao, $sql);
header("location:".$pagina);
}
}
if ($acao == 'salvarestrangeiro') {
$tb_tabela = isset($_GET['tabela'])?$_GET['tabela']:0;
$pagina = isset($_GET['pagina'])?$_GET['pagina']:0;
$numero = isset($_GET['numero'])?$_GET['numero']:0;
if (isset($_GET['n1'])) {
for ($i= 1; $i <= $numero ; $i++) {
$lugares[$i] = isset($_GET['n'.$i])?$_GET['n'.$i]:0;
}
$sql = "INSERT INTO ".$tb_tabela." ".$campos." VALUES ".$parentesa;
$i=1;
while ($i <= $numero) {
$data = DateTime::createfromFormat('d/m/Y', $lugares[$i]);
if ($data && $data->format('d/m/Y')) {
$lugares[$i] = str_replace("/", "-", $lugares[$i]);
$sql.= ",'".date("Y-m-d", strtotime($lugares[$i]))."'";
} else {
if ($i==$numero) {
$sql.= "'".$lugares[$i]."'";
}else
$sql.= "'".$lugares[$i]."', ";
}
$i++;
}
$sql.= $parentesf;
echo $sql;
$resultado = mysqli_query($conexao, $sql);
header("location:".$pagina."?tabela=$tb_tabela");
}
}
?>