# HG changeset patch
# User viric@llimona
# Date 1147298415 -7200
# Node ID eb656142f039bb4a97592610571332bb472be5cf
# Parent 5c3469118f32ae0970badec3553e9aa1cd2cee26
Updating to the development version done in vicerveza.
diff -r 5c3469118f32 -r eb656142f039 README
--- a/README Wed May 10 23:58:52 2006 +0200
+++ b/README Thu May 11 00:00:15 2006 +0200
@@ -2,3 +2,9 @@
conté els passwords d'accés a la base de dades.
El fitxer db.sql conté les ordres per inicialitzar la base de dades necessà ria.
+
+Recomano un fitxer .htaccess que no permeti veure els '*.inc':
+
+Deny from all
+
+
diff -r 5c3469118f32 -r eb656142f039 TODO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TODO Thu May 11 00:00:15 2006 +0200
@@ -0,0 +1,2 @@
+* Al llistar amb "list-persona", s'haurien de donar totes les compres en una sola crida. Això es fa amb un UNION, i el mysql 3.23 no ho soporta.
+* És possible que al llistar amb "list-persona", surti llistada tot i que l'entrada a "compradors", a "compradors_excepcions" o a "pagadors" sigui de 0 euros.
diff -r 5c3469118f32 -r eb656142f039 classes.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/classes.inc Thu May 11 00:00:15 2006 +0200
@@ -0,0 +1,148 @@
+hora, $this->minut, 0, $this->mes, $this->dia,
+ $this->any);
+}
+
+function setData($data)
+{
+ $this->dia = date('d',$data);
+ $this->mes = date('m',$data);
+ $this->any = date('Y',$data);
+ $this->hora = date('H',$data);
+ $this->minut = date('i',$data);
+}
+
+}
+
+class comprador
+{
+var $persona;
+var $pagat;
+var $toca_pagar;
+
+// Valors de lligam
+var $data;
+
+function comprador($data, $persona, $pagat, $toca_pagar)
+{
+ $this->persona = $persona;
+ $this->data = $data;
+ $this->pagat = $pagat;
+ $this->toca_pagar = $toca_pagar;
+}
+}
+
+class comprador_excepcio
+{
+var $persona;
+var $toca_pagar;
+
+// Valors de lligam
+var $id_excepcio;
+}
+
+class excepcio
+{
+var $article;
+var $preu;
+
+// Valors de lligam
+var $data;
+// Calculats o llegits de la DB
+var $id;
+
+}
+
+class compra extends accio
+{
+var $botiga;
+var $motiu;
+var $comentari;
+var $preu; // Segur?
+var $compradors; // Array d'objectes
+var $excepcions;
+
+// Calculades
+var $preu_per_compradors
+
+function compra($connexio=-1, $data=0)
+{
+ if ($connexio == -1)
+ {
+ $this->setData(time());
+ $this->botiga = "";
+ $this->motiu = "";
+ $this->comentari = "";
+ $this->preu = 0;
+ $this->compradors = array();
+ $this->excepcions = array();
+ }
+ else
+ {
+ $query="SELECT UNIX_TIMESTAMP(data),botiga,motiu,preu,comentari FROM compres WHERE data=FROM_UNIXTIME(" . $data . ")";
+ $resultat = db->($query);
+
+ // ****** Cal comprovar que existeix
+ $fila = mysql_fetch_row($resultat)
+ $this->setData($fila[0]);
+ $this->botiga = $fila[1];
+ $this->motiu = $fila[2];
+ $this->preu = $fila[3];
+ $this->comentari = $fila[4];
+
+ $query = "SELECT persona,pagat,toca_pagar FROM compradors
+ WHERE compradors.data=FROM_UNIXTIME($date);";
+ $resultat = db->($query);
+
+ $this->compradors = array();
+ while($fila = mysql_fetch_row($resultat))
+ {
+ $this->comprador[] = new comprador($this->data,
+ $fila[0], $fila[1], $fila[2] );
+ }
+
+ }
+}
+
+function numCompradors()
+{
+ return count($this->compradors);
+}
+
+function numExcepcions()
+{
+ return count($this->excepcions);
+}
+
+}
+
+class pagament extends accio
+{
+var $comentari;
+var $motiu;
+
+}
+
+class pagador
+{
+var $persona;
+var $pagat;
+var $cobrat;
+
+// Valor de lligam
+var $data;
+
+}
+?>
diff -r 5c3469118f32 -r eb656142f039 db-class.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/db-class.inc Thu May 11 00:00:15 2006 +0200
@@ -0,0 +1,25 @@
+connexio = mysql_connect($server, $user, $password);
+ mysql_select_db($database, $connexio);
+}
+
+function query($query)
+{
+ return mysql_query($query, $this->connexio);
+}
+
+function close($query)
+{
+ mysql_close($this->connexio);
+}
+}
+?>
diff -r 5c3469118f32 -r eb656142f039 getdb.inc
--- a/getdb.inc Wed May 10 23:58:52 2006 +0200
+++ b/getdb.inc Thu May 11 00:00:15 2006 +0200
@@ -56,7 +56,8 @@
while ($fila = mysql_fetch_row($resultat))
$gent[$fila[0]] = array( "nom" => $fila[1],
- "habitant" => $fila[2]);
+ "habitant" => $fila[2],
+ "id" => $fila[0]);
return $gent;
}
@@ -192,9 +193,44 @@
echo "";
}
+ function select_gent_multi($variable)
+ {
+ $num_gent = count($GLOBALS["gent"]);
+
+ echo "";
+ }
+
+ function select_botigues_multi($variable, $connection)
+ {
+ $resultat = mysql_query("SELECT botiga FROM compres GROUP BY botiga ORDER BY botiga ASC;", $connection);
+
+ while ($fila = mysql_fetch_row($resultat))
+ $botigues[] = $fila[0];
+ $num_botigues = count($botigues);
+
+ echo "";
+ }
+
+
function strtosql($cadena)
{
- return ereg_replace("\'", "\'", $cadena);
+ return ereg_replace("'", "'", $cadena);
}
function strtohtml($cadena)
@@ -206,6 +242,20 @@
return $new;
}
+ function strforquotes($cadena)
+ {
+ $new= ereg_replace("\"", ""es;", $cadena);
+
+ return $new;
+ }
+
+ function strfromquotes($cadena)
+ {
+ $new= ereg_replace(""es;", "\"", $cadena);
+
+ return $new;
+ }
+
function pricetohtml($price)
{
if ($price < 0)
diff -r 5c3469118f32 -r eb656142f039 index.html
--- a/index.html Wed May 10 23:58:52 2006 +0200
+++ b/index.html Thu May 11 00:00:15 2006 +0200
@@ -28,6 +28,8 @@
Afegir nova
|
Calcular deutes
+ |
+ Estadístiques de consum
diff -r 5c3469118f32 -r eb656142f039 list-compres.php
--- a/list-compres.php Wed May 10 23:58:52 2006 +0200
+++ b/list-compres.php Thu May 11 00:00:15 2006 +0200
@@ -3,6 +3,7 @@
Ètxelon - Consulta de compres
+
diff -r 5c3469118f32 -r eb656142f039 list-gent.php
--- a/list-gent.php Wed May 10 23:58:52 2006 +0200
+++ b/list-gent.php Thu May 11 00:00:15 2006 +0200
@@ -3,6 +3,7 @@
Ètxelon - Llistat de gent
+
diff -r 5c3469118f32 -r eb656142f039 list-pagaments.php
--- a/list-pagaments.php Wed May 10 23:58:52 2006 +0200
+++ b/list-pagaments.php Thu May 11 00:00:15 2006 +0200
@@ -3,6 +3,7 @@
Ètxelon - Consulta de pagaments
+
diff -r 5c3469118f32 -r eb656142f039 list-persona.php
--- a/list-persona.php Wed May 10 23:58:52 2006 +0200
+++ b/list-persona.php Thu May 11 00:00:15 2006 +0200
@@ -3,6 +3,7 @@
Ètxelon - Consulta de compres
+
diff -r 5c3469118f32 -r eb656142f039 stats.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/stats.php Thu May 11 00:00:15 2006 +0200
@@ -0,0 +1,165 @@
+
+
+
+ Ètxelon - Estadístiques
+
+
+
+
+
+
+Ètxelon
+
+
+
+
+Estadístiques de consum - Formulari
+
+
+
+
+ $compra)
+ {
+ if ($data > $data_inici and $data < $data_final and
+ in_array($compra["botiga"], $_POST["botigues"]))
+ {
+ $compradors = obtenir_compradors($data, $connexio);
+
+ // Calcul dels compradors globals
+ foreach($compradors as $persona => $dades)
+ {
+ if (in_array($persona, $_POST["gent_stats"]))
+ $total_a_pagar += $dades["toca_pagar"];
+ }
+
+ $excepcions = obtenir_excepcions($data, $connexio);
+
+ $max_compradors_ex = 0;
+ if ($excepcions != 0)
+ foreach($excepcions as $key => $value)
+ {
+ $compradors_excepcions[$key] = obtenir_compradors_excepcions($key, $connexio);
+ foreach($compradors_excepcions[$key] as $persona => $dades)
+ {
+ if (in_array($persona, $_POST["gent_stats"]))
+ $total_a_pagar += $dades["toca_pagar"];
+ }
+ }
+ }
+ }
+?>
+
+Estadístiques
+
+
+
+
+ Persones
+ |
+ |
+ Botigues
+ |
+ |
+ Díes en el període
+ |
+ |
+ Toca pagar en el període
+ |
+ |
+ Mitjana de consum al dia
+ |
+ |
+ Mitjana de consum en 30 dies
+ |
+ |
+
+
+
+Llegenda
+
+
+
+
+
+
+
+Tornar al menú d'inici
+
+
+
diff -r 5c3469118f32 -r eb656142f039 update-compra.php
--- a/update-compra.php Wed May 10 23:58:52 2006 +0200
+++ b/update-compra.php Thu May 11 00:00:15 2006 +0200
@@ -3,6 +3,7 @@
Edició de les compres
+
@@ -446,6 +447,7 @@
echo $query . " ";
// Obtenim l'ID de la excepció
+
$query = "SELECT id FROM excepcions WHERE data = FROM_UNIXTIME($data) AND article = '" . strtosql($_POST["earticle"][$i]) .
"' AND preu = ". $_POST["epreu"][$i] . ";";
$resultat = 1; // Per si no es fa la query, assumim que no hi ha errors
diff -r 5c3469118f32 -r eb656142f039 update-gent.php
--- a/update-gent.php Wed May 10 23:58:52 2006 +0200
+++ b/update-gent.php Thu May 11 00:00:15 2006 +0200
@@ -3,6 +3,7 @@
Edició dels pagaments
+
diff -r 5c3469118f32 -r eb656142f039 update-pagament.php
--- a/update-pagament.php Wed May 10 23:58:52 2006 +0200
+++ b/update-pagament.php Thu May 11 00:00:15 2006 +0200
@@ -3,6 +3,7 @@
Edició dels pagaments
+
diff -r 5c3469118f32 -r eb656142f039 view-compra.php
--- a/view-compra.php Wed May 10 23:58:52 2006 +0200
+++ b/view-compra.php Thu May 11 00:00:15 2006 +0200
@@ -3,6 +3,7 @@
Ètxelon - Veure compra
+
diff -r 5c3469118f32 -r eb656142f039 view-pagament.php
--- a/view-pagament.php Wed May 10 23:58:52 2006 +0200
+++ b/view-pagament.php Thu May 11 00:00:15 2006 +0200
@@ -3,6 +3,7 @@
Ètxelon - Veure pagament
+
|