-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStampa_Anno.php
504 lines (438 loc) · 15.8 KB
/
Stampa_Anno.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<?php
/*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 == 'admin') {
include('./Intestazione.php');
include ('./dati_db.inc');
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
?>
<p align="center"><b>*** Libro soci ***</b></p><br>
<?php
$classe = $_POST['classi'];
$Query_nome = "SELECT * FROM tb_anagrafe WHERE tipologia = 'Ins' OR tipologia = 'Stud' ORDER BY nome";
$rs=mysql_query($Query_nome)
or die("Errore nella query $query: " . mysql_error()); //die("<b>Errore:</b> Impossibile eseguire la query della Combo");
{
echo <<<EOM
<table align='center' border='0' cellpadding='0' cellspacing='2' width='90%'>
<tr>
<td width='150'><small><b>nome </b></small></td>
<td width='150'><small><b>indirizzo </b></small></td>
<td width='150'><small><b>Citta </b></small></td>
<td width='150'><small><b>provincia </b></small></td>
<td width='150'><small><b>Cod Fisc </b></small></td>
<td width='150'><small><b>Tipo </b></small></td>
<td width='150'><small><b>Funzione </b></small></td>
</tr>
<tr><td></td></tr>
EOM;
}
while ($row=mysql_fetch_array($rs))
{
echo <<<EOM
<tr>
<td width='150'><small>$row[nome]</small></td>
<td width='150'><small>$row[indirizzo]</small></td>
<td width='150'><small>$row[citta]</small></td>
<td width='150'><small>$row[provincia]</small></td>
<td width='150'><small>$row[nomerif]</small></td>
<td width='150'><small>$row[materia]</small></td>
<td width='150'><small>$row[classe]</small></td>
</tr>
EOM;
}
echo <<<EOT
</table>
EOT;
// **** STAMPA PRIMA NOTA CASSA ****
?>
<BR><HR><BR>
<p align="center"><b>*** Registro prima nota semplice ***</b></p><br>
<?php
// popolo la tabella della primanota
$Query_nome = "SELECT * FROM tb_primanota ORDER BY id_primanota";
$rs=mysql_query($Query_nome)
or die("<b>Errore:</b> Impossibile eseguire la query della Combo");
{
echo <<<EOM
<table style="position: absolute; right: 70px;" width='38%' border='0' bgcolor="#D1D1D1">
<tr>
<td height='35px' align='center' width='200'><small><b>Cassa</b></small></td>
<td height='35px' align='center' width='200'><small><b>Banca</b></small></td>
</tr>
</table>
<br><br>
<table align='center' border='0' cellpadding='0' cellspacing='0' width='90%' bgcolor="#D1D1D1">
<tr>
<td width='125'><small><b>data_registr</b></small></td>
<td width='150'><small><b>descrizione</b></small></td>
<td width='100' align='right'><small><b>entrata</b></small></td>
<td width='100' align='right'><small><b>uscita</b></small></td>
<td width='100' align='right'><small><b>entratab</b></small></td>
<td width='100' align='right'><small><b>uscitab</b></small></td>
</tr>
<tr><td></td></tr>
</table>
EOM;
}
while ($row=mysql_fetch_array($rs))
{
echo <<<EOM
<table align='center' border='0' cellpadding='0' cellspacing='0' width='90%'>
<tr>
<td height='15px' width='125'><small>$row[data_registr]</small></td>
<td height='15px' width='150'><small>$row[descrizione]</small></td>
<td height='15px' width='100' align='right'><small>$row[entrata]</small></td>
<td height='15px' width='100' align='right'><small>$row[uscita]</small></td>
<td height='15px' width='100' align='right'><small>$row[entratab]</small></td>
<td height='15px' width='100' align='right'><small>$row[uscitab]</small></td>
</tr>
</table>
EOM;
}
//Calcolo delle somme di Cassa
$query = "SELECT SUM(entrata) FROM tb_primanota";
$result = mysql_query($query);
$entrata_tot = mysql_fetch_row($result);
?>
<table>
<table border='0' cellpadding='0' cellspacing='0' width='95%'>
<tr>
<td width='80%'></td>
<td height='30px' width='10%'><small>Entrata Cassa</small></td>
<td height='30px' align='right' width='10%'><small><?php echo $entrata_tot[0]; ?></small></td>
</tr>
<?php
$query = "SELECT SUM(uscita) FROM tb_primanota";
$result = mysql_query($query);
$uscita_tot = mysql_fetch_row($result);
?>
<tr>
<td width='80%'></td>
<td height='30px' width='10%'><small>Uscite Cassa</small></td>
<td height='30px' align='right' width='10%'><small><?php echo $uscita_tot[0]; ?></small></td>
</tr>
<tr>
<td width='80%'></td>
<td height='30px' width='10%'><small><b>Guad/Perdita</b></small></td>
<td height='30px' align='right' width='10%'><small><b><?php echo ($entrata_tot[0]-$uscita_tot[0]); ?></b></small></td>
</tr></table><br>
<?php
//Calcolo delle somme di Banca
$query = "SELECT SUM(entratab) FROM tb_primanota";
$result = mysql_query($query);
$entratab_tot = mysql_fetch_row($result);
?>
<table border='0' cellpadding='0' cellspacing='0' width='95%'>
<tr>
<td width='80%'></td>
<hr style="width: 20%; height: 2px; position: absolute; right: 60px"><br>
<td height='30px' width='10%'><small>Entrata Banca</small></td>
<td height='30px' align='right' width='150'><small><?php echo $entratab_tot[0]; ?></small></td>
</tr>
<?php
$query = "SELECT SUM(uscitab) FROM tb_primanota";
$result = mysql_query($query);
$uscitab_tot = mysql_fetch_row($result);
?>
<tr>
<td width='80%'></td>
<td height='30px' width='150'><small>Uscite Banca</small></td>
<td height='30px' align='right' width='150'><small><?php echo $uscitab_tot[0]; ?></small></td>
</tr>
<tr>
<td width='80%'></td>
<td height='30px' width='150'><small><b>Guad/Perdita</b></small></td>
<td height='30px' align='right' width='150'><small><b><?php echo ($entratab_tot[0]-$uscitab_tot[0]); ?></b></small></td>
</tr><br>
</table>
<!-- popolo la tabella delle fatture -->
<BR><HR><BR>
<p align="center"><b>*** Elenco Fatture ***</b></p>
<table align='center' border='0' cellpadding='0' cellspacing='0' width='80%'>
<tr>
<td height='25px' width='125' align='center'><small><b>num</b></small></td>
<td width='125'><small><b>data</b></small></td>
<td width='100'><small><b>nome</b></small></td>
<td width='100' align='right'><small><b>Tot Iva inclusa</b></small></td>
</tr>
<?php
$a = '1';
do {
$Query = "SELECT id_tot_fatture, tot_fattura, nome, data
FROM tb_tot_fatture
WHERE id_tot_fatture = $a
ORDER BY tot_fattura DESC, id_tot_fatture
LIMIT 1";
$rs=mysql_query($Query)
or die('' . mysql_error());
while ($row=mysql_fetch_array($rs))
{
echo <<<EOM
<tr>
<td height='25px' width='125' align='center'><small>$row[id_tot_fatture]</small></td>
<td height='25px' width='125'><small>$row[data]</small></td>
<td height='25px' width='100'><small>$row[nome]</small></td>
<td height='25px' width='100' align='right'><small>$row[tot_fattura]</small></td>
</tr>
EOM;
}
$a++;
} while ($a <= 1000);
echo <<<EOT
</table><p></p>
EOT;
?>
<BR><HR><BR>
<p align="center"><b>*** Elenco ricevute ***</b></p>
<table align='center' border='0' cellpadding='0' cellspacing='0' width='80%'>
<tr>
<td height='25px' width='125' align='center'><small><b>num ricevuta</b></small></td>
<td width='125'><small><b>data</b></small></td>
<td width='150'><small><b>nome</b></small></td>
<td width='100' align='right'><small><b>euro</b></small></td>
<td width='100' align='right'><small><b>descr</b></small></td>
</tr>
<?php
// popolo la tabella delle ricevute
$Query = "SELECT * FROM tb_ricevute ORDER BY id_ric";
$rs=mysql_query($Query)
or die('' . mysql_error());
while ($row=mysql_fetch_array($rs))
{
echo <<<EOM
<tr>
<td height='25px' width='10%' align='center'><small>$row[id_ric]</small></td>
<td height='25px' width='20%'><small>$row[data]</small></td>
<td height='25px' width='30%'><small>$row[nome]</small></td>
<td height='25px' width='10%' align='right'><small>$row[euro]</small></td>
<td height='25px' width='30%' align='right'><small>$row[descr]</small></td>
</tr>
EOM;
}
echo <<<EOT
</table><p></p>
EOT;
?>
<!-- **** STAMPA CONTO ECONOMICO **** -->
<BR><HR><BR>
<p align="center"><b>*** Conto economico ***</b></p>
<?php
// popolo la tabella della conto economico
{
echo <<<EOM
<table width='80%' border='0' align='center'>
<tr>
<td height='35px' align='center' width='50%' bgcolor="#D1D1D1"><small><b>Proventi e ricavi</b></small></td>
<td height='35px' align='center' width='50%' bgcolor="#D1D1D1"><small><b>Costi e Oneri</b></small></td>
</tr>
</table>
<table align='center' border='0' cellpadding='0' cellspacing='0' width='80%' >
<tr>
<td height='25px' width='5%' align='center'><small><b>id</b></small></td>
<td height='25px' width='30%'><small><b>descrizione</b></small></td>
<td height='25px' width='15%'><small><b>Importo</b></small></td>
<td height='25px' width='5%' align='center'><small><b>id</b></small></td>
<td height='25px' width='30%'><small><b>descrizione</b></small></td>
<td height='25px' width='15%'><small><b>Importo</b></small></td>
</tr>
</table>
EOM;
}
?>
<!-- Creo la tabella costi/ricavo -->
<table align='center' border='0' cellpadding='0' cellspacing='0' width='80%' >
<tr>
<td width="50%">
<?php
$Query_nome = "SELECT * FROM tb_conto_economico WHERE costoricavo = 'ricavi' ORDER BY id";
$rs=mysql_query($Query_nome)
or die("<b>Errore:</b> Impossibile eseguire la query della Combo");
while ($row=mysql_fetch_array($rs))
{
echo <<<EOM
<table align='center' border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr >
<td height='25px' width='5%' align='center'><small>$row[id]</small></td>
<td height='25px' width='30%'><small>$row[descrizione]</small></td>
<td height='25px' width='15%'><small>$row[valore]</small></td>
</tr>
</table>
EOM;
}
?>
</td>
<td width="50%">
<?php
$Query = "SELECT * FROM tb_conto_economico WHERE costoricavo = 'oneri' ORDER BY id";
$ros=mysql_query($Query)
or die("<b>Errore:</b> Impossibile eseguire la query della Combo");
while ($riga=mysql_fetch_array($ros))
{
echo <<<EOM
<table align='center' border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr >
<td height='25px' width='5%' align='center'><small>$riga[id]</small></td>
<td height='25px' width='30%'><small>$riga[descrizione]</small></td>
<td height='25px' width='15%'><small>$riga[valore]</small></td>
</tr>
</table>
EOM;
}
?>
</td>
</tr>
</table>
<?php
//Calcolo delle somme
$query = "SELECT SUM(valore) FROM tb_conto_economico where costoricavo = 'ricavi'";
$result = mysql_query($query);
$entrata = mysql_fetch_row($result);
$query = "SELECT SUM(valore) FROM tb_conto_economico where costoricavo = 'oneri'";
$result = mysql_query($query);
$uscita = mysql_fetch_row($result);
?>
<hr style="width: 20%; height: 2px; position: center;"><br>
<table width='80%' border='0' align ='center'>
<tr>
<td height='30px' width='20%'><small>Totale Proventi</small></td>
<td height='30px' align='right' width='20%'><small><?php echo $entrata[0]; ?> €</small></td>
<td width='20%'></td>
<td height='30px' width='20%'><small>Totale spese</small></td>
<td height='30px' align='right' width='20%'><small><?php echo $uscita[0]; ?> €</small></td>
</tr>
<tr>
<td height='30px' width='20%'></td>
<td height='30px' width='20%'></td>
<td height='30px' width='20%'></td>
<td height='30px' width='20%'><small><b>Avanzo di Gestione</b></small></td>
<td height='30px' align='right' width='20%'><small><b><?php echo ($entrata[0]-$uscita[0]); ?> €</b></small></td>
</tr>
<tr>
<td height='30px' width='20%'><small>Totale a pareggio</small></td>
<td height='30px' align='right' width='20%'><small><?php echo $entrata[0]; ?> €</small></td>
<td width='20%'></td>
<td height='30px' width='20%'><small>Totale a pareggio</small></td>
<td height='30px' align='right' width='20%'><small><?php echo (($entrata[0]-$uscita[0])+$uscita[0]); ?> €</small></td>
</table><br>
<!-- Visualizzazione Stato Patrimoniale -->
<BR><HR><BR>
<p align="center"><b>*** Stato Patrimoniale ***</b></p>
<?php
// popolo la tabella
{
echo <<<EOM
<table width='80%' border='0' align='center'>
<tr>
<td height='35px' align='center' width='50%' bgcolor="#D1D1D1"><small><b>Attività</b></small></td>
<td height='35px' align='center' width='50%' bgcolor="#D1D1D1"><small><b>Passività</b></small></td>
</tr>
</table>
<table align='center' border='0' cellpadding='0' cellspacing='0' width='80%' >
<tr>
<td height='25px' width='5%' align='center'><small><b>id</b></small></td>
<td height='25px' width='30%'><small><b>descrizione</b></small></td>
<td height='25px' width='15%'><small><b>Importo</b></small></td>
<td height='25px' width='5%' align='center'><small><b>id</b></small></td>
<td height='25px' width='30%'><small><b>descrizione</b></small></td>
<td height='25px' width='15%'><small><b>Importo</b></small></td>
</tr>
</table>
EOM;
}
?>
<!-- Creo la tabella attività/passività -->
<table align='center' border='0' cellpadding='0' cellspacing='0' width='80%' >
<tr>
<td width="50%">
<?php
$Query_nome = "SELECT * FROM tb_stato_patrimoniale WHERE costoricavo = 'attivita' ORDER BY id";
$rs=mysql_query($Query_nome)
or die("<b>Errore:</b> Impossibile eseguire la query della Combo");
while ($row=mysql_fetch_array($rs))
{
echo <<<EOM
<table align='center' border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr >
<td height='25px' width='5%' align='center'><small>$row[id]</small></td>
<td height='25px' width='30%'><small>$row[descrizione]</small></td>
<td height='25px' width='15%'><small>$row[valore]</small></td>
</tr>
</table>
EOM;
}
?>
</td>
<td width="50%">
<?php
$Query = "SELECT * FROM tb_stato_patrimoniale WHERE costoricavo = 'passivita' ORDER BY id";
$ros=mysql_query($Query)
or die("<b>Errore:</b> Impossibile eseguire la query della Combo");
while ($riga=mysql_fetch_array($ros))
{
echo <<<EOM
<table align='center' border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr >
<td height='25px' width='5%' align='center'><small>$riga[id]</small></td>
<td height='25px' width='30%'><small>$riga[descrizione]</small></td>
<td height='25px' width='15%'><small>$riga[valore]</small></td>
</tr>
</table>
EOM;
}
?>
</td>
</tr>
</table>
<?php
//Calcolo delle somme
$query = "SELECT SUM(valore) FROM tb_stato_patrimoniale where costoricavo = 'attivita'";
$result = mysql_query($query);
$entrata = mysql_fetch_row($result);
$query = "SELECT SUM(valore) FROM tb_stato_patrimoniale where costoricavo = 'passivita'";
$result = mysql_query($query);
$uscita = mysql_fetch_row($result);
?>
<hr style="width: 20%; height: 2px; position: center;"><br>
<table width='80%' border='0' align ='center'>
<tr>
<td height='30px' width='20%'><small>Totale Proventi</small></td>
<td height='30px' align='right' width='20%'><small><?php echo $entrata[0]; ?> €</small></td>
<td width='20%'></td>
<td height='30px' width='20%'><small>Totale spese</small></td>
<td height='30px' align='right' width='20%'><small><?php echo $uscita[0]; ?> €</small></td>
</tr>
<tr>
<td height='30px' width='20%'></td>
<td height='30px' width='20%'></td>
<td height='30px' width='20%'></td>
<td height='30px' width='20%'><small><b>Avanzo di Gestione</b></small></td>
<td height='30px' align='right' width='20%'><small><b><?php echo ($entrata[0]-$uscita[0]); ?> €</b></small></td>
</tr>
<tr>
<td height='30px' width='20%'><small>Totale a pareggio</small></td>
<td height='30px' align='right' width='20%'><small><?php echo $entrata[0]; ?> €</small></td>
<td width='20%'></td>
<td height='30px' width='20%'><small>Totale a pareggio</small></td>
<td height='30px' align='right' width='20%'><small><?php echo (($entrata[0]-$uscita[0])+$uscita[0]); ?> €</small></td>
</table><br>
<?php
mysql_close();
} else {
header('Location: ./index.php');
}
?>