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