-
Notifications
You must be signed in to change notification settings - Fork 1
/
createEntry.php
executable file
·296 lines (263 loc) · 9.04 KB
/
createEntry.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?php
/*
* UWS - Universal Wealth System
* createEntry.php
* GPL license
* author: Fabio Barone
* date: 30. Nov. 2009
*
* When a user has performed a service, be it for the community or for a
* specific user, a click on the correspondent action in the menu
* ("Create new service delivery") will lead to this file.
*
* The user enters the details of the service delivery, like the type of
* service (which needs to be created in createService.php first if not existing),
* the description, the amount of time in minutes, and the factor. Updating
* will calculate the service units according to the factor. The save button
* is active only after updating. Saving is done in saveEntry.php
*
* If the user does not select a receiver for the service, the service is regarded
* as a community service and the user only gets credited his account. If a receiver
* gets selected, the amount gets credited on the user's account and debited on the
* receiver's account.
*/
session_start();
include "config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
terrafirma1.0 by nodethirtythree design
http://www.nodethirtythree.com
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Universal Wealth System UWS - <?php echo translate("uws:create_entry") ?></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="default.css" />
<script type="text/javascript">
function saveStory() {
//clicking on save will submit the form to saveEntry.php
document.story.action = "saveEntry.php";
document.story.submit();
}
</script>
</head>
<body>
<div id="outer">
<div id="upbg"></div>
<div id="inner">
<?php include "header.php" ?>
<h3><?php echo translate("uws:create_entry") ?></h3>
<div class="date">
<?php
echo date('d F Y') ?></div>
</div>
<div class="content">
<?php
//echo "isset: " .isset($_SESSION['uname']);
$username = $_SESSION['uname'];
$user_1 = "";
$submit = "disabled";
//enable the submit button only if the form has been updated
if (isset($_POST['update']))
{
$user_1 = $_POST['user_1'];
$submit = "";
}
else {
//the form has not been updated, thus no receiver selected yet
$user_1 = $username;
}
$factor_1 = $_POST['factor_1'];
$user_2 = $_POST['user_2'];
$contribution = $_POST['contribution'];
$work_1 = $_POST['work_1'];
$desc = $_POST['desc'];
$weighted_perf = $factor_1 * $work_1;
$selected_receiver = null;
$selected_service = null;
//the form has been updated and a receiver has been selected in
//the dropdown list
if (isset($_POST['user_2']))
{
$selected_receiver = $_POST['user_2'];
}
//the form has been updated and a service has been selected in the
//the dropdown list
if (isset($_POST['contribution']))
{
$selected_service = $_POST['contribution'];
}
//get all services in the system and add them to an array
$sql = "SELECT service FROM servicelist";
$query = mysql_query($sql);
$services_list = array();
while ($result = mysql_fetch_array($query)) {
array_push($services_list, current($result));
}
//get all members in the system and add them to an array
$sql = "SELECT name FROM members";
$query = mysql_query($sql);
$user_list = array();
while ($result = mysql_fetch_array($query)) {
array_push($user_list, current($result));
}
//add an empty entry to the members dropdown list,
//as there a service delivery might not need a member
//(community service)
array_unshift($user_list, "");
?>
<form name="story" id="story" action="<?php echo $_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
<table class="formtable" width="470" cellspacing="0" cellpadding="0">
<tr>
<td width="50" class="text"><?php echo translate("uws:user") ?></td>
<td width="5"> </td>
<td><span class="text"><input name="user_1" type="text" id="user_1" value="<?php echo $user_1?>" size="30" />
</span></td>
</tr>
<tr>
<td width="50"> </td>
<td width="5"> </td>
<td></td>
</tr>
<tr>
<td width="50" class="text"><?php echo translate("uws:receiver") ?></td>
<td width="5"> </td>
<td><span class="text">
<select name="user_2" size="1">
<?php
//fill in the members dropdown list from an array filled further up
foreach ($user_list as $user) {
echo "<option";
//the form has been updated and a receiver had previously been selected.
if (! strcmp($user,$selected_receiver)) {
echo " selected>";
}
else {
echo ">";
}
echo $user ."</option";
}
?>
</select>
<!-- <input name="user_2" type="text" id="user_2" value="<?php echo $user_2?>" size="30" /> -->
</span></td>
</tr>
<tr>
<td width="50"> </td>
<td width="5"> </td>
<td></td>
</tr>
<tr>
<td width="50" class="text"><?php echo translate("uws:service") ?></td>
<td width="5"> </td>
<td><span class="text">
<!-- <input name="contribution" type="text" id="contribution" value="<?php echo $contribution?>" size="30" /> -->
<select name="contribution" size="1">
<?php
//fill in the services dropdown list from an array further up
foreach ($services_list as $service) {
echo "<option";
//the form had been updated and a service had previously been selected
if (! strcmp($service,$selected_service)) {
echo " selected>";
}
else {
echo ">";
}
echo $service ."</option";
}
?>
</select>
</span></td>
</tr>
<tr>
<td width="50"> </td>
<td width="5"> </td>
<td></td>
</tr>
<tr>
<td width="50" class="text"><?php echo translate("uws:desc") ?></td>
<td width="5"> </td>
<td><span class="text"><input name="desc" type="text" id="desc" value="<?php echo $desc ?>" size="30" />
</span></td>
</tr>
</table>
<p> </p>
<table class="formtable" width="470" cellspacing="0" cellpadding="0">
<tr>
<td width="65" class="text"><?php echo translate("uws:factor") ?></td>
<td width="5"> </td>
<td><span class="text">
<input name="factor_1" type="text" id="factor_1" size="8" maxlength="8" value="<?php echo number_format($factor_1, 6, '.', '\'') ?>" />
</span></td>
</tr>
<tr>
<td width="50" class="text"><?php echo translate("uws:lifetime") ?></td>
<td width="5"> </td>
<td><span class="text">
<input name="work_1" type="text" id="work_1" size="8" maxlength="8" value="<?php echo $work_1 ?>" />
</span></td>
</tr>
<tr>
<td width="50" class="text"><?php echo translate("uws:service_units") ?></td>
<td width="5"> </td>
<td><span class="text"><?php echo ($weighted_perf) ?></span></td>
</tr>
<tr>
<td width="50" height="5"></td>
<td height="5"></td>
<td></td>
<td height="5"></td>
</tr>
<tr bgcolor=" #666666">
<td width="50" height="1"></td>
<td height="5"></td>
<td></td>
<td height="1"></td>
</tr>
<tr>
<td width="50" height="5"></td>
<td height="5"></td>
<td></td>
<td height="5"></td>
</tr>
<tr>
<td colspan="4"><div align="left" class="text">
<input type="submit" name="update" id="update" value="<?php echo translate("uws:calc_srv_units") ?>" />
<br />
<br />
<input type="button" name="button2" id="button2" value="<?php echo translate("uws:save_record") ?>" onclick="javascript:saveStory()" <?php echo $submit ?> />
<br />
<br />
</div></td>
<td width="80"> </td>
</tr>
</table>
<input type="hidden" name="weighted_perf" id="weighted_perf" value="<?php echo $weighted_perf ?>" />
</form>
</div>
<div class="footer">
<ul>
<li class="printerfriendly"><a href="#">Printer Friendly</a></li>
<li class="readmore"><a href="#">Read more</a></li>
</ul>
</div>
</div>
</div>
<div id="secondarycontent">
<!-- Displaying lists links -->
<?php include "lists.php" ?>
<!-- Displaying action links -->
<?php include "actions.php" ?>
<!-- secondary content end -->
</div>
<div id="footer">
© UWS. </a>.
</div>
</div>
</div>
</body>
</html>