author | viric@llimona |
Thu, 11 May 2006 00:00:15 +0200 | |
changeset 2 | eb656142f039 |
permissions | -rw-r--r-- |
2
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
2 |
<html> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
3 |
<head> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
4 |
<title>Ètxelon - Estadístiques</title> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
5 |
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
6 |
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
7 |
</head> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
8 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
9 |
<body> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
10 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
11 |
<H1 ALIGN=center>Ètxelon</H1> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
12 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
13 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
14 |
<?php |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
15 |
include("getdb.inc"); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
16 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
17 |
// Fem la connexió |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
18 |
$connexio = mysql_connect($mysql_server, $mysql_user, $mysql_password); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
19 |
mysql_select_db($mysql_db, $connexio); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
20 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
21 |
// Crides a funcions per obtenir parametres |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
22 |
$habitants = obtenir_habitants($connexio); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
23 |
$num_habitants = count($habitants); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
24 |
$altres = obtenir_altres($connexio); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
25 |
$gent = obtenir_gent($connexio); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
26 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
27 |
if (!isset($_POST["demanar"])) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
28 |
{ |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
29 |
?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
30 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
31 |
<h2>Estadístiques de consum - Formulari</h2> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
32 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
33 |
<form action="stats" method="post"> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
34 |
<table> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
35 |
<tr> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
36 |
<th>Data d'inici: |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
37 |
<td><input type=text name="data_inici" value="<?php echo date("d/m/Y", |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
38 |
time() - 365*24*3600); ?>"size=20> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
39 |
<tr> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
40 |
<th>Data final: |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
41 |
<td><input type=text name="data_final" value="<?php echo date("d/m/Y"); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
42 |
?>"size=20> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
43 |
<tr> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
44 |
<th>Usuaris: |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
45 |
<td><?php select_gent_multi("gent_stats"); ?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
46 |
<tr> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
47 |
<th>Botigues: |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
48 |
<td><?php select_botigues_multi("botigues",$connexio); ?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
49 |
<tr> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
50 |
<td> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
51 |
<td><input type=submit name="demanar" value="Demanar" size=20> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
52 |
</table> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
53 |
</form> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
54 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
55 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
56 |
<?php |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
57 |
} |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
58 |
else |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
59 |
{ // ************** CALCULEM SEGONS L'ENTRAT AL FORMULARI *********** |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
60 |
// Dates |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
61 |
$i = preg_split("/[^0-9]/", $_POST["data_inici"]); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
62 |
$data_inici = mktime(0,0,0,$i[1],$i[0], $i[2]); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
63 |
$i = preg_split("/[^0-9]/", $_POST["data_final"]); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
64 |
$data_final = mktime(23,59,0,$i[1],$i[0], $i[2]); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
65 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
66 |
$dies = (int)(($data_final - $data_inici) / (24*3600)); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
67 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
68 |
// Iniciem els deutes de cadascun |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
69 |
$total_a_pagar = 0; |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
70 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
71 |
// Obtenim totes les compres |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
72 |
$compres = obtenir_compres($connexio); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
73 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
74 |
// Per cada compra... |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
75 |
foreach($compres as $data => $compra) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
76 |
{ |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
77 |
if ($data > $data_inici and $data < $data_final and |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
78 |
in_array($compra["botiga"], $_POST["botigues"])) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
79 |
{ |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
80 |
$compradors = obtenir_compradors($data, $connexio); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
81 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
82 |
// Calcul dels compradors globals |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
83 |
foreach($compradors as $persona => $dades) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
84 |
{ |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
85 |
if (in_array($persona, $_POST["gent_stats"])) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
86 |
$total_a_pagar += $dades["toca_pagar"]; |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
87 |
} |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
88 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
89 |
$excepcions = obtenir_excepcions($data, $connexio); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
90 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
91 |
$max_compradors_ex = 0; |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
92 |
if ($excepcions != 0) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
93 |
foreach($excepcions as $key => $value) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
94 |
{ |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
95 |
$compradors_excepcions[$key] = obtenir_compradors_excepcions($key, $connexio); |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
96 |
foreach($compradors_excepcions[$key] as $persona => $dades) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
97 |
{ |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
98 |
if (in_array($persona, $_POST["gent_stats"])) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
99 |
$total_a_pagar += $dades["toca_pagar"]; |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
100 |
} |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
101 |
} |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
102 |
} |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
103 |
} |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
104 |
?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
105 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
106 |
<H2>Estadístiques</H2> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
107 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
108 |
<!-- Taula de compradors globals --> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
109 |
<TABLE BORDER=1> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
110 |
<TR> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
111 |
<TH>Persones |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
112 |
<TD><?php |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
113 |
foreach ($_POST["gent_stats"] as $id) |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
114 |
$gent_stats[] = $gent[$id]["nom"]; |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
115 |
echo implode(",", $gent_stats); ?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
116 |
<TR> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
117 |
<TH>Botigues |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
118 |
<TD><?php |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
119 |
echo implode(",", $_POST["botigues"]); ?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
120 |
<TR> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
121 |
<TH>Díes en el període |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
122 |
<TD><?php echo $dies;?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
123 |
<TR> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
124 |
<TH>Toca pagar en el període |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
125 |
<TD><?php echo $total_a_pagar; ?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
126 |
<TR> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
127 |
<TH>Mitjana de consum al dia |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
128 |
<TD><?php echo $total_a_pagar / $dies; ?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
129 |
<TR> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
130 |
<TH>Mitjana de consum en 30 dies |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
131 |
<TD><?php echo 30* $total_a_pagar / $dies; ?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
132 |
</TABLE> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
133 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
134 |
<HR WIDTH="70%"> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
135 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
136 |
<H2>Llegenda</H2> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
137 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
138 |
<!-- |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
139 |
<ul> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
140 |
<li>El percentatge es calcula segons el que <em>toca pagar</em> respecte al |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
141 |
<em>total a pagar</em>. |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
142 |
<li>Els pagaments negatius són cobraments del grup. Els positius són pagaments |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
143 |
al grup. |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
144 |
<li>La suma del <em>percentatge</em> ha de ser <strong>100</strong>. |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
145 |
<li>El <em>total pagat</em> ha de ser igual al <em>total a pagar</em>. |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
146 |
<li>La suma dels pagaments ha de ser <strong>0</strong> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
147 |
(pagaments = cobraments). |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
148 |
<li>El <em>balanç positiu</em> indica diners que s'han de cobrar en un futur, |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
149 |
i el <em>negatiu</em> diners que s'han de pagar. |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
150 |
<LI>És important <strong>no confondre</strong> el que s'ha <em>pagat</em> (que |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
151 |
fa referència a les <em>compres</em>), i els <em>pagaments</em>, que fan |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
152 |
referència als préstecs o saldades de deutes. |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
153 |
</ul> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
154 |
--> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
155 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
156 |
<?php |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
157 |
} |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
158 |
?> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
159 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
160 |
<HR WIDTH="70%"> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
161 |
<BR> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
162 |
<A HREF="index">Tornar al menú d'inici</A> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
163 |
|
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
164 |
</body> |
eb656142f039
Updating to the development version done in vicerveza.
viric@llimona
parents:
diff
changeset
|
165 |
</html> |