forked from strk/sinx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconf_dati_pnota.php
114 lines (97 loc) · 3.54 KB
/
conf_dati_pnota.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
111
112
113
114
<?php
/*======================================================================+
File name : conf_dati_pnota.php
Begin : 2010-08-04
Last Update : 2011-04-08
Description : Check and confirm data prior notice
Author: Sergio Capretta
(c) Copyright:
Sergio Capretta
ITALY
www.sinx.it
Sinx for Association - Gestionale per Associazioni no-profit
Copyright (C) 2011 by Sergio Capretta
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=========================================================================+*/
session_start();
$user = $_SESSION['utente'];
if ($user) {
$data = $_POST['data'];
if($data == FALSE){
$data = date('d-m-Y');
}
$contoec = $_POST['contoec'];
$noperazione = $_POST['operazione'];
$valore = $_POST['valore'];
$conto = $_POST['conto'];
$soperazione = htmlspecialchars($noperazione, ENT_NOQUOTES, "UTF-8");
$operazione = mysql_escape_string($soperazione);
switch ($conto) {
case 'entrata':
$entrata = $valore;
break;
case 'uscita':
$uscita = $valore;
break;
case 'entratab':
$entratab = $valore;
break;
case 'uscitab':
$uscitab = $valore;
break;
}
//Funzione per il redirect
function redirect($url,$tempo = FALSE ){
if(!headers_sent() && $tempo == FALSE ){
header('Location:' . $url);
}elseif(!headers_sent() && $tempo != FALSE ){
header('Refresh:' . $tempo . ';' . $url);
}else{
if($tempo == FALSE ){
$tempo = 0;
}
echo "<meta http-equiv=\"refresh\" content=\"" . $tempo . ";" . $url . "\">";
}
}
//Controllo campi compilati
if ($operazione == "")
{
echo "<center><b>Il campo Operazione è obbligatorio</b></center>";
redirect('./InsPrimanota.php' ,2);
break;
}
include ('./dati_db.inc');
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//Inserisco dati nella tabella primanota
$tb_primanota = ('tb_primanota(data_registr, descrizione, entrata, uscita, entratab, uscitab)');
if ($operazione){
$sql="insert into $tb_primanota values('$data', '$operazione', ".($entrata ? "'$entrata'" : "null").", ".($uscita ? "'$uscita'" : "null").", ".($entratab ? "'$entratab'" : "null").", ".($uscitab ? "'$uscitab'" : "null").")"; //inserisco i valori nel database
$result=mysql_query($sql);
header('location: ./conferma.html'); //Vado alla pagina di conferma
}else{
header('location: ./errore.html'); //Vado alla pagina di errore
}
// Aggiornamento tabella conto economico
//Recupero il valore originale e lo aggiorno
$query = "SELECT valore FROM tb_conto_economico WHERE descrizione = '$contoec'";
$result = mysql_query($query);
$valoreorig = mysql_fetch_row($result);
$nuovovalore = ($valoreorig[0] + $valore);
$sql="UPDATE tb_conto_economico SET valore = '$nuovovalore' WHERE descrizione = '$contoec'"; //inserisco i valori nel database
$result=mysql_query($sql);
mysql_close();
} else {
header('Location: ./index.php');
}
?>