|
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 moviment");?></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 moviment(); |
|
37 echo "<h2>" . _("Nou moviment") . "</h2>\n"; |
|
38 } |
|
39 else |
|
40 { |
|
41 echo "<h2>" . _("Modificar moviment") . "</h2>\n"; |
|
42 $formulari = new moviment($connexio, $_GET["id"]); |
|
43 } |
|
44 ?> |
|
45 |
|
46 <p><?php echo _("Dades del moviment");?></p> |
|
47 |
|
48 <FORM method=post action="update-moviment"> |
|
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 <?php |
|
73 if (isset($_GET["id"])) // Modificació |
|
74 { |
|
75 //*** Truquilllo |
|
76 echo "<input type=hidden name=data_vella value=\"". |
|
77 $formulari->data(). "\">"; |
|
78 echo "<tr>\n"; |
|
79 echo "<th>". _("Data de la última modificació"). "\n"; |
|
80 echo "<td>" . date("d/m/Y H:i", $formulari->modificat) . "\n"; |
|
81 } |
|
82 ?> |
|
83 |
|
84 <tr> |
|
85 <th><?php echo _("Butxaca origen");?> |
|
86 <td><?php select_butxaques("butxaca_origen", $formulari->butxaca_origen);?> |
|
87 <tr> |
|
88 <th><?php echo _("Butxaca destí");?> |
|
89 <td><?php select_butxaques("butxaca_desti", $formulari->butxaca_desti);?> |
|
90 <tr> |
|
91 <th><?php echo _("Diners") ?> |
|
92 <td><input type="text" name="diners" size=10 maxlength=20 value="<?php |
|
93 echo $formulari->diners; ?>"> |
|
94 <tr> |
|
95 <th><?php echo _("Raó") ?> |
|
96 <td><input type="text" name="rao" size=30 maxlength=250 value="<?php |
|
97 echo $formulari->rao; ?>"> |
|
98 <tr> |
|
99 <th><?php echo _("Comentari") ?> |
|
100 <td><textarea type="text" name="comentari" rows=3 cols=40><?php |
|
101 echo $formulari->comentari; |
|
102 ?></textarea> |
|
103 </table> |
|
104 <center> |
|
105 <?php |
|
106 if (isset($_GET["id"])) // Modificació |
|
107 { |
|
108 echo "<input type=submit value=\""; |
|
109 echo _("Modificar"); |
|
110 echo "\" name=modificar>"; |
|
111 } |
|
112 else |
|
113 { |
|
114 echo "<input type=submit value=\""; |
|
115 echo _("Afegir"); |
|
116 echo "\" name=afegir>"; |
|
117 } |
|
118 ?> |
|
119 <input type=reset value="<?php echo _("Ressetejar formulari");?>"> |
|
120 </center> |
|
121 |
|
122 <?php |
|
123 } |
|
124 elseif (isset($_POST["afegir"])) // if afegir, afegim |
|
125 { |
|
126 $formulari = new moviment(); |
|
127 $formulari->dia = $_POST[dia]; |
|
128 $formulari->mes = $_POST[mes]; |
|
129 $formulari->any = $_POST[any]; |
|
130 $formulari->hora = $_POST[hora]; |
|
131 $formulari->minut = $_POST[minut]; |
|
132 $formulari->rao = $_POST[rao]; |
|
133 $formulari->comentari = $_POST[comentari]; |
|
134 $formulari->diners = $_POST[diners]; |
|
135 $formulari->butxaca_origen = $_POST[butxaca_origen]; |
|
136 $formulari->butxaca_desti = $_POST[butxaca_desti]; |
|
137 |
|
138 if ($formulari->diners == 0) |
|
139 { |
|
140 echo "<p>". _("<strong>Error:</strong> La quantitat de diners ha de ser diferent de zero.") . "</p>"; |
|
141 } |
|
142 else |
|
143 if ($formulari->butxaca_origen == $formulari->butxaca_desti) |
|
144 { |
|
145 echo "<p>". _("<strong>Error:</strong> Les butxaques orígen i destí han de ser diferents.") . "</p>"; |
|
146 } |
|
147 else |
|
148 if($formulari->DBAfegir($connexio) == 0) |
|
149 echo "<p>". _("Inserció efectuada correctament") . "</p>"; |
|
150 else |
|
151 echo "<p>". _("<strong>Error insertant.</strong>") . "</p>"; |
|
152 |
|
153 |
|
154 } |
|
155 elseif (isset($_POST["modificar"])) |
|
156 { |
|
157 |
|
158 $formulari = new moviment($connexio, $_POST["data_vella"]); |
|
159 $formulari->dia = $_POST[dia]; |
|
160 $formulari->mes = $_POST[mes]; |
|
161 $formulari->any = $_POST[any]; |
|
162 $formulari->hora = $_POST[hora]; |
|
163 $formulari->minut = $_POST[minut]; |
|
164 $formulari->rao = $_POST[rao]; |
|
165 $formulari->comentari = $_POST[comentari]; |
|
166 $formulari->diners = $_POST[diners]; |
|
167 $formulari->butxaca_origen = $_POST[butxaca_origen]; |
|
168 $formulari->butxaca_desti = $_POST[butxaca_desti]; |
|
169 |
|
170 if($formulari->DBModificar($connexio,$_POST["data_vella"]) == 0) |
|
171 echo "<p>". _("Modificació efectuada correctament") . "</p>"; |
|
172 else |
|
173 echo "<p>". _("<strong>Error modificant.</strong>") . "</p>"; |
|
174 } |
|
175 elseif (isset($_GET["eliminar"])) // if eliminar, borrem |
|
176 { |
|
177 $formulari = new moviment($connexio, $_GET["id"]); |
|
178 if ($formulari->DBBorrar($connexio) == 0) |
|
179 echo "<p>". _("Entrada eliminada correctament") . "</p>"; |
|
180 else |
|
181 echo "<p>". _("<strong>Error eliminant.</strong>") . "</p>"; |
|
182 } |
|
183 mysql_close($connexio); |
|
184 ?> |
|
185 |
|
186 <p><A HREF="index"><?php echo _("Tornar al menú principal");?></A></p> |
|
187 <?php |
|
188 if (isset($_GET["id"]) && !isset($_GET["eliminar"])) // Modificació |
|
189 { |
|
190 echo "<p align=right><a href=\"update-moviment?eliminar=1&id=". |
|
191 $formulari->data(). "\">"; |
|
192 echo _("[ELIMINAR]"); |
|
193 echo "</A></p>"; |
|
194 } |
|
195 ?> |
|
196 |
|
197 </body> |
|
198 </html> |