# HG changeset patch
# User viric@vicerveza
# Date 1147988823 -7200
# Node ID c270c8b5ddea95421708bd8eefd4f62d8edb4f57
Initial release. Usable.
diff -r 000000000000 -r c270c8b5ddea .hgignore
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Thu May 18 23:47:03 2006 +0200
@@ -0,0 +1,1 @@
+\.mo$
diff -r 000000000000 -r c270c8b5ddea classes.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/classes.inc Thu May 18 23:47:03 2006 +0200
@@ -0,0 +1,292 @@
+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);
+}
+
+function DBAfegir($connexio)
+{
+ $query = "INSERT INTO ingressos
+ (data,data_modif,rao,quantitat,
+ butxaca,comentari)
+ VALUES(";
+ $query .= "FROM_UNIXTIME(" . mktime($this->hora,
+ $this->minut,
+ 0,
+ $this->mes,
+ $this->dia,
+ $this->any) . "), ";
+ $query .= "FROM_UNIXTIME(". time() . "), ";
+ $query .= "'" . strtosql( $this->rao) . "', ";
+ if($this->tipus == "ingres")
+ $query .= $this->diners . ", ";
+ else
+ $query .= "-". $this->diners . ", ";
+ $query .= $this->butxaca . ", ";
+ $query .= "'" . strtosql( $this->comentari) . "'); ";
+
+
+ $resultat = mysql_query($query, $connexio);
+
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()."
";
+ return 1;
+ }
+
+ return 0;
+}
+
+function DBModificar($connexio, $data_vella)
+{
+ $query = "UPDATE ingressos SET ";
+ $query .= "data=FROM_UNIXTIME(" . $this->data() . "), ";
+ $query .= "data_modif=FROM_UNIXTIME(". time() . "), ";
+ $query .= "rao='" . strtosql( $this->rao) . "', ";
+ $query .= "quantitat=";
+ if($this->tipus == "ingres")
+ $query .= $this->diners . ", ";
+ else
+ $query .= "-". $this->diners . ", ";
+ $query .= "butxaca=" . $this->butxaca . ", ";
+ $query .= "comentari='" . strtosql( $this->comentari) . "' ";
+ $query .= "WHERE data=FROM_UNIXTIME(" . $data_vella . ");";
+
+
+ $resultat = mysql_query($query, $connexio);
+
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()."
";
+ return 1;
+ }
+
+ return 0;
+}
+
+function DBBorrar($connexio)
+{
+ $query = "DELETE FROM ingressos WHERE UNIX_TIMESTAMP(data) = ";
+ $query .= $this->data() . ";";
+
+ $resultat = mysql_query($query,$connexio);
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()."
";
+ return 1;
+ }
+ return 0;
+
+}
+
+function ingres($connexio=-1, $data=0)
+{
+ // De nul
+ if ($connexio==-1)
+ {
+ $this->dia = date('d');
+ $this->mes = date('m');
+ $this->any = date('Y');
+ $this->hora = date('H');
+ $this->minut = date('i');
+ $this->rao = "";
+ $this->butxaca = -1;
+ $this->tipus = "despesa";
+ $this->diners = 0;
+ $this->comentari = "";
+ }
+ else
+ {
+ $query = "SELECT UNIX_TIMESTAMP(data),
+ UNIX_TIMESTAMP(data_modif), rao, butxaca, quantitat,
+ comentari FROM ingressos WHERE UNIX_TIMESTAMP(data) = ";
+ $query .= $data . ";";
+
+ $resultat = mysql_query($query,$connexio);
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()."
";
+ return 1; // Què passa amb un return aquí?
+ }
+
+ // Només hi haurà un resultat
+ $fila = mysql_fetch_row($resultat);
+
+ settype($fila[4], float);
+
+ $this->dia = date('d',$fila[0]);
+ $this->mes = date('m',$fila[0]);
+ $this->any = date('Y',$fila[0]);
+ $this->hora = date('H',$fila[0]);
+ $this->minut = date('i',$fila[0]);
+ $this->modificat = $fila[1];
+ $this->rao = $fila[2];
+ $this->butxaca = $fila[3];
+ if ($fila[4] > 0)
+ $this->tipus = "ingres";
+ else
+ $this->tipus = "despesa";
+ $this->diners = abs($fila[4]);
+ $this->comentari = $fila[5];
+
+ }
+}
+
+}
+
+class moviment
+{
+var $dia;
+var $mes;
+var $any;
+var $hora;
+var $minut;
+var $modificat; // Timestamp
+var $rao;
+var $butxaca_origen;
+var $butxaca_desti;
+var $diners;
+var $comentari;
+
+
+function data()
+{
+ return mktime($this->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);
+}
+
+function DBAfegir($connexio)
+{
+ $query = "INSERT INTO moviments
+ (data,data_modif,rao,quantitat,
+ butxaca_origen,butxaca_desti,comentari)
+ VALUES(";
+ $query .= "FROM_UNIXTIME(" . $this->data() . "), ";
+ $query .= "FROM_UNIXTIME(". time() . "), ";
+ $query .= "'" . strtosql( $this->rao) . "', ";
+ $query .= $this->diners . ", ";
+ $query .= $this->butxaca_origen . ", ";
+ $query .= $this->butxaca_desti . ", ";
+ $query .= "'" . strtosql( $this->comentari) . "'); ";
+
+
+ $resultat = mysql_query($query, $connexio);
+
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()."
";
+ return 1;
+ }
+
+ return 0;
+}
+
+function DBBorrar($connexio)
+{
+ $query = "DELETE FROM moviments WHERE UNIX_TIMESTAMP(data) = ";
+ $query .= mktime($this->hora,
+ $this->minut,
+ 0,
+ $this->mes,
+ $this->dia,
+ $this->any) . ";";
+
+ $resultat = mysql_query($query,$connexio);
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()."
";
+ return 1;
+ }
+ return 0;
+
+}
+
+function moviment($connexio=-1, $data=0)
+{
+ // De nul
+ if ($connexio==-1)
+ {
+ $this->dia = date('d');
+ $this->mes = date('m');
+ $this->any = date('Y');
+ $this->hora = date('H');
+ $this->minut = date('i');
+ $this->rao = "";
+ $this->butxaca_origen = -1;
+ $this->butxaca_desti = -1;
+ $this->diners = 0;
+ $this->comentari = "";
+ }
+ else
+ {
+ $query = "SELECT UNIX_TIMESTAMP(data),
+ UNIX_TIMESTAMP(data_modif), rao, butxaca_origen, butxaca_desti,
+ quantitat,
+ comentari FROM moviments WHERE UNIX_TIMESTAMP(data) = ";
+ $query .= $data . ";";
+
+ $resultat = mysql_query($query,$connexio);
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()."
";
+ return 1; // Què passa amb un return aquí?
+ }
+
+ // Només hi haurà un resultat
+ $fila = mysql_fetch_row($resultat);
+
+ settype($fila[4], float);
+
+ $this->dia = date('d',$fila[0]);
+ $this->mes = date('m',$fila[0]);
+ $this->any = date('Y',$fila[0]);
+ $this->hora = date('H',$fila[0]);
+ $this->minut = date('i',$fila[0]);
+ $this->modificat = $fila[1];
+ $this->rao = $fila[2];
+ $this->butxaca_origen = $fila[3];
+ $this->butxaca_desti = $fila[4];
+ $this->diners = abs($fila[5]);
+ $this->comentari = $fila[6];
+
+ }
+}
+
+}
+
+?>
diff -r 000000000000 -r c270c8b5ddea db-config.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/db-config.inc Thu May 18 23:47:03 2006 +0200
@@ -0,0 +1,6 @@
+
diff -r 000000000000 -r c270c8b5ddea db.sql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/db.sql Thu May 18 23:47:03 2006 +0200
@@ -0,0 +1,44 @@
+-- use prova_pis;
+drop table if exists moviments ;
+drop table if exists ingressos ;
+drop table if exists butxaques ;
+
+CREATE TABLE butxaques (
+ id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ nom VARCHAR(50) NOT NULL,
+ principal BOOL,
+
+ PRIMARY KEY (id)
+ ) TYPE = InnoDB;
+
+-- ingressos i despeses
+CREATE TABLE ingressos (
+ data TIMESTAMP NOT NULL,
+ data_modif TIMESTAMP NOT NULL,
+ rao TINYTEXT NULL,
+ quantitat DECIMAL(18,10) SIGNED NOT NULL,
+ butxaca MEDIUMINT UNSIGNED NOT NULL,
+ comentari TEXT,
+
+ PRIMARY KEY (data),
+ INDEX (butxaca),
+ FOREIGN KEY (butxaca) REFERENCES butxaques (id)
+ ) TYPE = InnoDB;
+
+-- moviments de diners entre butxaques
+CREATE TABLE moviments (
+ data TIMESTAMP NOT NULL,
+ data_modif TIMESTAMP NOT NULL,
+ rao TINYTEXT NOT NULL,
+ quantitat DECIMAL(18,10) SIGNED NOT NULL,
+ comentari TEXT,
+ butxaca_origen MEDIUMINT UNSIGNED NOT NULL,
+ butxaca_desti MEDIUMINT UNSIGNED NOT NULL,
+
+ PRIMARY KEY (data),
+ INDEX (butxaca_origen),
+ INDEX (butxaca_desti),
+ FOREIGN KEY (butxaca_origen) REFERENCES butxaques (id),
+ FOREIGN KEY (butxaca_desti) REFERENCES butxaques (id)
+ ) TYPE = InnoDB;
+
diff -r 000000000000 -r c270c8b5ddea getdb.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/getdb.inc Thu May 18 23:47:03 2006 +0200
@@ -0,0 +1,55 @@
+
+
ERROR: Error al obtenir + gent!
+"; + } + + while ($fila = mysql_fetch_row($resultat)) + $butxaques[$fila[0]] = $fila[1]; + return $butxaques; + } + + // FUNCIONS PER GENERAR CODI HTML + + function select_butxaques($variable, $default=-1) + { + global $butxaques; + + echo ""; + } + + function strforquotes($cadena) + { + $new= ereg_replace("\"", ""es;", $cadena); + + return $new; + } + + function strfromquotes($cadena) + { + $new= ereg_replace(""es;", "\"", $cadena); + + return $new; + } + +?> diff -r 000000000000 -r c270c8b5ddea index.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/index.php Thu May 18 23:47:03 2006 +0200 @@ -0,0 +1,49 @@ + + + + ++ | + | + |
---|---|---|
+ | + | + |
+ | + | + |
+ |
+ | +\n"; + echo "\t | " . $i . "\n"; + echo "\t | " . strtohtml($butxaques[$i]) . "\n"; + } + + +?> + + |
---|
+ | + | + | + | + | +"; + return 1; + } + + while ($fila = mysql_fetch_row($resultat)) + { + echo " |
---|---|---|---|---|---|
" . date("d/m/Y H:i",$fila[0]) . + "\n"; + echo "\t | ". date("d/m/Y H:i",$fila[1]) ."\n"; + echo "\t | " . strtohtml($butxaques[$fila[2]]) . "\n"; + echo "\t | " . strtohtml($butxaques[$fila[3]]) . "\n"; + echo "\t | " . sprintf("%.2f", $fila[4]) . "\n"; + echo "\t | " . strtohtml($fila[5]) . "\n"; + } + + +?> + + |
+ | + | + | + | +"; + return 1; + } + + while ($fila = mysql_fetch_row($resultat)) + { + echo " |
---|---|---|---|---|
" . date("d/m/Y H:i",$fila[0]) . + "\n"; + echo "\t | ". date("d/m/Y H:i",$fila[1]) ."\n"; + echo "\t | " . strtohtml($butxaques[$fila[2]]) . "\n"; + echo "\t | " . pricetohtml( $fila[3]) . "\n"; + echo "\t | " . strtohtml($fila[4]) . "\n"; + "\n"; + } + + +?> + + |
+ | + | + | + | + | +"; + echo " | " . $butxaques[$i]. "\n";
+
+ // Ingressos
+ $query ="SELECT SUM(quantitat) FROM ingressos WHERE
+ butxaca =" . $i. " AND quantitat > 0;";
+ $resultat = mysql_query($query, $connexio);
+
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()." "; + return 1; + } + + $fila = mysql_fetch_row($resultat); + $ingressos = $fila[0]; + echo " | " . pricetohtml($fila[0]). "\n";
+
+ // Despeses
+ $query ="SELECT SUM(quantitat) FROM ingressos WHERE
+ butxaca =" . $i. " AND quantitat < 0;";
+ $resultat = mysql_query($query, $connexio);
+
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()." "; + return 1; + } + + $fila = mysql_fetch_row($resultat); + echo " | " . pricetohtml($fila[0]). "\n";
+ $ingressos = $ingressos + $fila[0];
+
+ // Moviments negatius
+ $query ="SELECT SUM(quantitat) FROM moviments WHERE
+ butxaca_origen =" . $i. ";";
+ $resultat = mysql_query($query, $connexio);
+
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()." "; + return 1; + } + + $fila = mysql_fetch_row($resultat); + echo " | " . pricetohtml(-$fila[0]). "\n";
+ $ingressos = $ingressos - $fila[0];
+
+ // Moviments positius
+ $query ="SELECT SUM(quantitat) FROM moviments WHERE
+ butxaca_desti =" . $i. ";";
+ $resultat = mysql_query($query, $connexio);
+
+ if (!$resultat)
+ {
+ echo mysql_errno().": ".mysql_error()." "; + return 1; + } + + $fila = mysql_fetch_row($resultat); + echo " | " . pricetohtml($fila[0]). "\n"; + $ingressos = $ingressos + $fila[0]; + + echo " | " . pricetohtml($ingressos) . "\n"; + $total = $total + $ingressos; + } + + echo " |
---|---|---|---|---|---|---|---|---|---|---|---|
". _("Total"). " | " . pricetohtml($total). + "\n"; + + +?> + + |
Inserció efectuada correctament.
" +msgstr "" + +#: ../update-ingres.php:41 +msgid "Modificar ingrés/despesa" +msgstr "" + +#: ../update-ingres.php:46 +msgid "Dades de l'ingrés/despesa" +msgstr "" + +#: ../update-ingres.php:63 ../update-moviment.php:63 +msgid "Hora" +msgstr "" + +#: ../update-ingres.php:80 ../update-moviment.php:79 +msgid "Data de la última modificació" +msgstr "" + +#: ../update-ingres.php:90 +msgid "Ingrés o despesa" +msgstr "" + +#: ../update-ingres.php:94 +msgid "Ingrés" +msgstr "" + +#: ../update-ingres.php:100 +msgid "Despesa" +msgstr "" + +#: ../update-ingres.php:110 ../update-moviment.php:99 +msgid "Comentari" +msgstr "" + +#: ../update-ingres.php:120 ../update-moviment.php:109 +msgid "Modificar" +msgstr "" + +#: ../update-ingres.php:126 ../update-moviment.php:115 +msgid "Afegir" +msgstr "" + +#: ../update-ingres.php:150 ../update-moviment.php:139 +msgid "Inserció efectuada correctament" +msgstr "" + +#: ../update-ingres.php:152 ../update-moviment.php:141 +msgid "Error insertant." +msgstr "" + +#: ../update-ingres.php:170 ../update-moviment.php:161 +msgid "Modificació efectuada correctament" +msgstr "" + +#: ../update-ingres.php:172 ../update-moviment.php:163 +msgid "Error modificant." +msgstr "" + +#: ../update-ingres.php:180 ../update-moviment.php:169 +msgid "Entrada eliminada correctament" +msgstr "" + +#: ../update-ingres.php:182 ../update-moviment.php:171 +msgid "Error eliminant." +msgstr "" + +#: ../update-ingres.php:193 ../update-moviment.php:182 +msgid "[ELIMINAR]" +msgstr "" + +#: ../update-moviment.php:12 ../update-moviment.php:37 +msgid "Nou moviment" +msgstr "" + +#: ../update-moviment.php:41 +msgid "Modificar moviment" +msgstr "" + +#: ../update-moviment.php:46 +msgid "Dades del moviment" +msgstr "" + +#: ../update-moviment.php:85 +msgid "Butxaca origen" +msgstr "" + +#: ../update-moviment.php:88 +msgid "Butxaca destí" +msgstr "" diff -r 000000000000 -r c270c8b5ddea locale/ca/LC_MESSAGES/butxaques.po --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locale/ca/LC_MESSAGES/butxaques.po Thu May 18 23:47:03 2006 +0200 @@ -0,0 +1,24 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHORInserció efectuada correctament.
" +msgstr "" + +#: ../update-ingres.php:41 +msgid "Modificar ingrés/despesa" +msgstr "" + +#: ../update-ingres.php:46 +msgid "Dades de l'ingrés/despesa" +msgstr "" + +#: ../update-ingres.php:63 ../update-moviment.php:63 +msgid "Hora" +msgstr "" + +#: ../update-ingres.php:80 ../update-moviment.php:79 +msgid "Data de la última modificació" +msgstr "" + +#: ../update-ingres.php:90 +msgid "Ingrés o despesa" +msgstr "" + +#: ../update-ingres.php:94 +msgid "Ingrés" +msgstr "" + +#: ../update-ingres.php:100 +msgid "Despesa" +msgstr "" + +#: ../update-ingres.php:110 ../update-moviment.php:99 +msgid "Comentari" +msgstr "" + +#: ../update-ingres.php:120 ../update-moviment.php:109 +msgid "Modificar" +msgstr "" + +#: ../update-ingres.php:126 ../update-moviment.php:115 +msgid "Afegir" +msgstr "" + +#: ../update-ingres.php:150 ../update-moviment.php:139 +msgid "Inserció efectuada correctament" +msgstr "" + +#: ../update-ingres.php:152 ../update-moviment.php:141 +msgid "Error insertant." +msgstr "" + +#: ../update-ingres.php:170 ../update-moviment.php:161 +msgid "Modificació efectuada correctament" +msgstr "" + +#: ../update-ingres.php:172 ../update-moviment.php:163 +msgid "Error modificant." +msgstr "" + +#: ../update-ingres.php:180 ../update-moviment.php:169 +msgid "Entrada eliminada correctament" +msgstr "" + +#: ../update-ingres.php:182 ../update-moviment.php:171 +msgid "Error eliminant." +msgstr "" + +#: ../update-ingres.php:193 ../update-moviment.php:182 +msgid "[ELIMINAR]" +msgstr "[FORIGI]" + +#: ../update-moviment.php:12 ../update-moviment.php:37 +msgid "Nou moviment" +msgstr "Nova movo" + +#: ../update-moviment.php:41 +msgid "Modificar moviment" +msgstr "" + +#: ../update-moviment.php:46 +msgid "Dades del moviment" +msgstr "" + +#: ../update-moviment.php:85 +msgid "Butxaca origen" +msgstr "" + +#: ../update-moviment.php:88 +msgid "Butxaca destí" +msgstr "" diff -r 000000000000 -r c270c8b5ddea readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/readme.txt Thu May 18 23:47:03 2006 +0200 @@ -0,0 +1,21 @@ +Instruccions per a instal·lar-ho... + +Crees un usuari de mysql, que tingui accés a una base de dades. +Aquesta mateixa configuració l'escrius en un fitxer així, anomenat +db-config.inc: + + +(sense línies en blanc abans i després) + +Llavors, crees les taules així: +mysql -u usuari -p base_de_dades < db.sql + +i ja pots fer servir el programa. Primer crees una 'Butxaca'. I llavors ja va +tot. + +Apa! diff -r 000000000000 -r c270c8b5ddea status-butxaques.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/status-butxaques.php Thu May 18 23:47:03 2006 +0200 @@ -0,0 +1,39 @@ + + + + +Inserció efectuada correctament.
"); +} +?> + + + + + diff -r 000000000000 -r c270c8b5ddea update-ingres.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/update-ingres.php Thu May 18 23:47:03 2006 +0200 @@ -0,0 +1,209 @@ + + + + +