update-ingres.php
author viric@vicerveza
Thu, 18 May 2006 23:47:03 +0200
changeset 0 c270c8b5ddea
permissions -rw-r--r--
Initial release. Usable.
viric@0
     1
<?php
viric@0
     2
/***** Informació de LOCALE *****/
viric@0
     3
echo setlocale(LC_ALL, 'ca_XX');
viric@0
     4
$textdomain = "butxaques";
viric@0
     5
bindtextdomain($textdomain, "./locale");
viric@0
     6
textdomain($textdomain);
viric@0
     7
bind_textdomain_codeset($textdomain, "utf-8");
viric@0
     8
?>
viric@0
     9
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
viric@0
    10
<html>
viric@0
    11
<head>
viric@0
    12
<title><?php echo _("Control de butxaques")." - "._("Nou ingrés/despesa");?></title>
viric@0
    13
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
viric@0
    14
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
viric@0
    15
</head>
viric@0
    16
viric@0
    17
<body>
viric@0
    18
<?php
viric@0
    19
echo "<h1 align=center>" . _("Control de butxaques") . "</h1>\n";
viric@0
    20
viric@0
    21
include("./getdb.inc");
viric@0
    22
include("./classes.inc");
viric@0
    23
viric@0
    24
// Fem la connexió
viric@0
    25
$connexio = mysql_connect($mysql_server, $mysql_user,
viric@0
    26
$mysql_password);
viric@0
    27
mysql_select_db($mysql_db, $connexio);
viric@0
    28
viric@0
    29
$butxaques = obtenir_butxaques($connexio);
viric@0
    30
viric@0
    31
if (!isset($_POST["afegir"]) && !isset($_GET["eliminar"]) &&
viric@0
    32
	!isset($_POST["modificar"]))
viric@0
    33
{
viric@0
    34
	if (!isset($_GET["id"]))
viric@0
    35
	{
viric@0
    36
		$formulari = new ingres();
viric@0
    37
		echo "<h2>" . _("Nou ingrés/despesa") . "</h2>\n";
viric@0
    38
	}
viric@0
    39
	else
viric@0
    40
	{
viric@0
    41
		echo "<h2>" . _("Modificar ingrés/despesa") . "</h2>\n";
viric@0
    42
		$formulari = new ingres($connexio, $_GET["id"]);
viric@0
    43
	}
viric@0
    44
?>
viric@0
    45
viric@0
    46
<p><?php echo _("Dades de l'ingrés/despesa");?></p>
viric@0
    47
viric@0
    48
<FORM method=post action="update-ingres">
viric@0
    49
<table>
viric@0
    50
<tr>
viric@0
    51
<th><?php echo _("Data");?>
viric@0
    52
<td>
viric@0
    53
<input type="text" name="dia" size=2 maxlength=2 value="<?php
viric@0
    54
	    echo $formulari->dia;
viric@0
    55
         ?>">
viric@0
    56
      <input type="text" name="mes" size=2 maxlength=2 value="<?php
viric@0
    57
	    echo $formulari->mes;
viric@0
    58
         ?>">
viric@0
    59
      <input type="text" name="any" size=4 maxlength=4 value="<?php
viric@0
    60
	    echo $formulari->any;
viric@0
    61
         ?>">
viric@0
    62
<tr>
viric@0
    63
<th><?php echo _("Hora");?>
viric@0
    64
<td>
viric@0
    65
<input type="text" name="hora" size=2 maxlength=2 value="<?php
viric@0
    66
	    echo $formulari->hora;
viric@0
    67
        ?>">
viric@0
    68
      <input type="text" name="minut" size=2 maxlength=2
viric@0
    69
      value="<?php
viric@0
    70
	    echo $formulari->minut;
viric@0
    71
         ?>">
viric@0
    72
viric@0
    73
<?php
viric@0
    74
	if (isset($_GET["id"])) // Modificació
viric@0
    75
	{
viric@0
    76
		//*** Truquilllo
viric@0
    77
		echo "<input type=hidden name=data_vella value=\"".
viric@0
    78
			$formulari->data(). "\">";
viric@0
    79
		echo "<tr>\n";
viric@0
    80
		echo "<th>". _("Data de la última modificació"). "\n";
viric@0
    81
		echo "<td>" . date("d/m/Y H:i", $formulari->modificat) . "\n";
viric@0
    82
	}
viric@0
    83
?>
viric@0
    84
viric@0
    85
<tr>
viric@0
    86
	<th><?php echo _("Butxaca");?>
viric@0
    87
	<td><?php select_butxaques("butxaca", $formulari->butxaca);?>
viric@0
    88
viric@0
    89
<tr>
viric@0
    90
	<th><?php echo _("Ingrés o despesa");?>
viric@0
    91
	<td><input type=radio name="tipus" value="ingres"<?php
viric@0
    92
		if ($formulari->tipus == "ingres")
viric@0
    93
			echo "checked"; ?>><?php
viric@0
    94
		echo _("Ingrés"); ?>
viric@0
    95
<tr>
viric@0
    96
	<td>
viric@0
    97
	<td><input type=radio name="tipus" value="despesa"<?php
viric@0
    98
		if ($formulari->tipus != "ingres")
viric@0
    99
			echo "checked"; ?>><?php
viric@0
   100
		echo _("Despesa"); ?>
viric@0
   101
<tr>
viric@0
   102
	<th><?php echo _("Diners") ?>
viric@0
   103
	<td><input type="text" name="diners" size=10 maxlength=20 value="<?php
viric@0
   104
		echo $formulari->diners; ?>">
viric@0
   105
<tr>
viric@0
   106
	<th><?php echo _("Raó") ?>
viric@0
   107
	<td><input type="text" name="rao" size=30 maxlength=250 value="<?php
viric@0
   108
		echo $formulari->rao; ?>">
viric@0
   109
<tr>
viric@0
   110
	<th><?php echo _("Comentari") ?>
viric@0
   111
	<td><textarea type="text" name="comentari" rows=3 cols=40><?php
viric@0
   112
		echo $formulari->comentari;
viric@0
   113
	?></textarea>
viric@0
   114
</table>
viric@0
   115
<center>
viric@0
   116
<?php
viric@0
   117
	if (isset($_GET["id"])) // Modificació
viric@0
   118
	{
viric@0
   119
		echo "<input type=submit value=\"";
viric@0
   120
		echo _("Modificar");
viric@0
   121
		echo "\" name=modificar>";
viric@0
   122
	}
viric@0
   123
	else
viric@0
   124
	{
viric@0
   125
		echo "<input type=submit value=\"";
viric@0
   126
		echo _("Afegir");
viric@0
   127
		echo "\" name=afegir>";
viric@0
   128
	}
viric@0
   129
?>
viric@0
   130
<input type=reset value="<?php echo _("Ressetejar formulari");?>">
viric@0
   131
</center>
viric@0
   132
viric@0
   133
<?php
viric@0
   134
}
viric@0
   135
elseif (isset($_POST["afegir"]))
viric@0
   136
{
viric@0
   137
	$formulari = new ingres();
viric@0
   138
	$formulari->dia = $_POST[dia];
viric@0
   139
	$formulari->mes = $_POST[mes];
viric@0
   140
	$formulari->any = $_POST[any];
viric@0
   141
	$formulari->hora = $_POST[hora];
viric@0
   142
	$formulari->minut = $_POST[minut];
viric@0
   143
	$formulari->rao = $_POST[rao];
viric@0
   144
	$formulari->comentari = $_POST[comentari];
viric@0
   145
	$formulari->tipus = $_POST[tipus];
viric@0
   146
	$formulari->diners = $_POST[diners];
viric@0
   147
	$formulari->butxaca = $_POST[butxaca];
viric@0
   148
viric@0
   149
	if ($formulari->diners == 0)
viric@0
   150
	{
viric@0
   151
		echo "<p>". _("<strong>Error:</strong> La quantitat de diners ha de ser diferent de zero.") . "</p>";
viric@0
   152
	}
viric@0
   153
	else
viric@0
   154
	if($formulari->DBAfegir($connexio) == 0)
viric@0
   155
		echo "<p>". _("Inserció efectuada correctament") . "</p>";
viric@0
   156
	else
viric@0
   157
		echo "<p>". _("<strong>Error insertant.</strong>") . "</p>";
viric@0
   158
}
viric@0
   159
elseif (isset($_POST["modificar"]))
viric@0
   160
{
viric@0
   161
viric@0
   162
	$formulari = new ingres($connexio, $_POST["data_vella"]);
viric@0
   163
	$formulari->dia = $_POST[dia];
viric@0
   164
	$formulari->mes = $_POST[mes];
viric@0
   165
	$formulari->any = $_POST[any];
viric@0
   166
	$formulari->hora = $_POST[hora];
viric@0
   167
	$formulari->minut = $_POST[minut];
viric@0
   168
	$formulari->rao = $_POST[rao];
viric@0
   169
	$formulari->comentari = $_POST[comentari];
viric@0
   170
	$formulari->diners = $_POST[diners];
viric@0
   171
	$formulari->tipus = $_POST[tipus];
viric@0
   172
	$formulari->butxaca = $_POST[butxaca];
viric@0
   173
viric@0
   174
	if ($formulari->diners == 0)
viric@0
   175
	{
viric@0
   176
		echo "<p>". _("<strong>Error:</strong> La quantitat de diners ha de ser diferent de zero.") . "</p>";
viric@0
   177
	}
viric@0
   178
	else
viric@0
   179
	if($formulari->DBModificar($connexio,$_POST["data_vella"]) == 0)
viric@0
   180
		echo "<p>". _("Modificació efectuada correctament") . "</p>";
viric@0
   181
	else
viric@0
   182
		echo "<p>". _("<strong>Error modificant.</strong>") . "</p>";
viric@0
   183
viric@0
   184
viric@0
   185
}
viric@0
   186
elseif (isset($_GET["eliminar"])) // if eliminar, borrem
viric@0
   187
{
viric@0
   188
	$formulari = new ingres($connexio, $_GET["id"]);
viric@0
   189
	if ($formulari->DBBorrar($connexio) == 0)
viric@0
   190
		echo "<p>". _("Entrada eliminada correctament") . "</p>";
viric@0
   191
	else
viric@0
   192
		echo "<p>". _("<strong>Error eliminant.</strong>") . "</p>";
viric@0
   193
}
viric@0
   194
mysql_close($connexio);
viric@0
   195
?>
viric@0
   196
viric@0
   197
<p><A HREF="index"><?php echo _("Tornar al menú principal");?></A></p>
viric@0
   198
<?php
viric@0
   199
	if (isset($_GET["id"]) && !isset($_GET["eliminar"])) // Modificació
viric@0
   200
	{
viric@0
   201
		echo "<p align=right><a href=\"update-ingres?eliminar=1&id=".
viric@0
   202
			$formulari->data(). "\">";
viric@0
   203
		echo _("[ELIMINAR]");
viric@0
   204
		echo "</A></p>";
viric@0
   205
	}
viric@0
   206
?>
viric@0
   207
viric@0
   208
</body>
viric@0
   209
</html>