update-moviment.php
changeset 0 c270c8b5ddea
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/update-moviment.php	Thu May 18 23:47:03 2006 +0200
@@ -0,0 +1,198 @@
+<?php
+/***** Informació de LOCALE *****/
+echo setlocale(LC_ALL, 'ca_XX');
+$textdomain = "butxaques";
+bindtextdomain($textdomain, "./locale");
+textdomain($textdomain);
+bind_textdomain_codeset($textdomain, "utf-8");
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<html>
+<head>
+<title><?php echo _("Control de butxaques")." - "._("Nou moviment");?></title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
+</head>
+
+<body>
+<?php
+echo "<h1 align=center>" . _("Control de butxaques") . "</h1>\n";
+
+include("./getdb.inc");
+include("./classes.inc");
+
+// Fem la connexió
+$connexio = mysql_connect($mysql_server, $mysql_user,
+$mysql_password);
+mysql_select_db($mysql_db, $connexio);
+
+$butxaques = obtenir_butxaques($connexio);
+
+if (!isset($_POST["afegir"]) && !isset($_GET["eliminar"]) &&
+	!isset($_POST["modificar"]))
+{
+	if (!isset($_GET["id"]))
+	{
+		$formulari = new moviment();
+		echo "<h2>" . _("Nou moviment") . "</h2>\n";
+	}
+	else
+	{
+		echo "<h2>" . _("Modificar moviment") . "</h2>\n";
+		$formulari = new moviment($connexio, $_GET["id"]);
+	}
+?>
+
+<p><?php echo _("Dades del moviment");?></p>
+
+<FORM method=post action="update-moviment">
+<table>
+<tr>
+<th><?php echo _("Data");?>
+<td>
+<input type="text" name="dia" size=2 maxlength=2 value="<?php
+	    echo $formulari->dia;
+         ?>">
+      <input type="text" name="mes" size=2 maxlength=2 value="<?php
+	    echo $formulari->mes;
+         ?>">
+      <input type="text" name="any" size=4 maxlength=4 value="<?php
+	    echo $formulari->any;
+         ?>">
+<tr>
+<th><?php echo _("Hora");?>
+<td>
+<input type="text" name="hora" size=2 maxlength=2 value="<?php
+	    echo $formulari->hora;
+        ?>">
+      <input type="text" name="minut" size=2 maxlength=2
+      value="<?php
+	    echo $formulari->minut;
+         ?>">
+<?php
+	if (isset($_GET["id"])) // Modificació
+	{
+		//*** Truquilllo
+		echo "<input type=hidden name=data_vella value=\"".
+			$formulari->data(). "\">";
+		echo "<tr>\n";
+		echo "<th>". _("Data de la última modificació"). "\n";
+		echo "<td>" . date("d/m/Y H:i", $formulari->modificat) . "\n";
+	}
+?>
+
+<tr>
+	<th><?php echo _("Butxaca origen");?>
+	<td><?php select_butxaques("butxaca_origen", $formulari->butxaca_origen);?>
+<tr>
+	<th><?php echo _("Butxaca destí");?>
+	<td><?php select_butxaques("butxaca_desti", $formulari->butxaca_desti);?>
+<tr>
+	<th><?php echo _("Diners") ?>
+	<td><input type="text" name="diners" size=10 maxlength=20 value="<?php
+		echo $formulari->diners; ?>">
+<tr>
+	<th><?php echo _("Raó") ?>
+	<td><input type="text" name="rao" size=30 maxlength=250 value="<?php
+		echo $formulari->rao; ?>">
+<tr>
+	<th><?php echo _("Comentari") ?>
+	<td><textarea type="text" name="comentari" rows=3 cols=40><?php
+		echo $formulari->comentari;
+	?></textarea>
+</table>
+<center>
+<?php
+	if (isset($_GET["id"])) // Modificació
+	{
+		echo "<input type=submit value=\"";
+		echo _("Modificar");
+		echo "\" name=modificar>";
+	}
+	else
+	{
+		echo "<input type=submit value=\"";
+		echo _("Afegir");
+		echo "\" name=afegir>";
+	}
+?>
+<input type=reset value="<?php echo _("Ressetejar formulari");?>">
+</center>
+
+<?php
+}
+elseif (isset($_POST["afegir"])) // if afegir, afegim
+{
+	$formulari = new moviment();
+	$formulari->dia = $_POST[dia];
+	$formulari->mes = $_POST[mes];
+	$formulari->any = $_POST[any];
+	$formulari->hora = $_POST[hora];
+	$formulari->minut = $_POST[minut];
+	$formulari->rao = $_POST[rao];
+	$formulari->comentari = $_POST[comentari];
+	$formulari->diners = $_POST[diners];
+	$formulari->butxaca_origen = $_POST[butxaca_origen];
+	$formulari->butxaca_desti = $_POST[butxaca_desti];
+
+	if ($formulari->diners == 0)
+	{
+		echo "<p>". _("<strong>Error:</strong> La quantitat de diners ha de ser diferent de zero.") . "</p>";
+	}
+	else
+	if ($formulari->butxaca_origen == $formulari->butxaca_desti)
+	{
+		echo "<p>". _("<strong>Error:</strong> Les butxaques orígen i destí han de ser diferents.") . "</p>";
+	}
+	else
+	if($formulari->DBAfegir($connexio) == 0)
+		echo "<p>". _("Inserció efectuada correctament") . "</p>";
+	else
+		echo "<p>". _("<strong>Error insertant.</strong>") . "</p>";
+	
+
+}
+elseif (isset($_POST["modificar"]))
+{
+
+	$formulari = new moviment($connexio, $_POST["data_vella"]);
+	$formulari->dia = $_POST[dia];
+	$formulari->mes = $_POST[mes];
+	$formulari->any = $_POST[any];
+	$formulari->hora = $_POST[hora];
+	$formulari->minut = $_POST[minut];
+	$formulari->rao = $_POST[rao];
+	$formulari->comentari = $_POST[comentari];
+	$formulari->diners = $_POST[diners];
+	$formulari->butxaca_origen = $_POST[butxaca_origen];
+	$formulari->butxaca_desti = $_POST[butxaca_desti];
+
+	if($formulari->DBModificar($connexio,$_POST["data_vella"]) == 0)
+		echo "<p>". _("Modificació efectuada correctament") . "</p>";
+	else
+		echo "<p>". _("<strong>Error modificant.</strong>") . "</p>";
+}
+elseif (isset($_GET["eliminar"])) // if eliminar, borrem
+{
+	$formulari = new moviment($connexio, $_GET["id"]);
+	if ($formulari->DBBorrar($connexio) == 0)
+		echo "<p>". _("Entrada eliminada correctament") . "</p>";
+	else
+		echo "<p>". _("<strong>Error eliminant.</strong>") . "</p>";
+}
+mysql_close($connexio);
+?>
+
+<p><A HREF="index"><?php echo _("Tornar al menú principal");?></A></p>
+<?php
+	if (isset($_GET["id"]) && !isset($_GET["eliminar"])) // Modificació
+	{
+		echo "<p align=right><a href=\"update-moviment?eliminar=1&id=".
+			$formulari->data(). "\">";
+		echo _("[ELIMINAR]");
+		echo "</A></p>";
+	}
+?>
+
+</body>
+</html>