-
Notifications
You must be signed in to change notification settings - Fork 1
/
bidDetail.php
executable file
·376 lines (320 loc) · 11.9 KB
/
bidDetail.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<?php
/*
* UWS - Universal Wealth System
* bidDetail.php
* GPL license
* author: Fabio Barone
* date: 30. Nov. 2009
*
* The original UWS design foresees auctions in order to manage
* offer and demand of goods and assets in the system. This file was
* meant to display details on single bids. As auctions are disabled
* resp. not designed in the system, the file is currently superflous,
* but kept here for future development.
*/
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:bid") ?> </title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="default.css" />
<script type="text/javascript">
function validate_form() {
var price = document.forms['bid'].elements["price"].value;
var balance = document.forms['bid'].elements["balance"].value;
var max_bid = document.forms['bid'].elements["my_share_physical"].value;
var bid = document.forms['bid'].elements["my_bid_amount"].value;
if (bid == 0 || price ==0 || isNaN(bid) || isNaN(price))
{
var invalid= "<?php echo translate('uws:invalid_value')?>";
alert(invalid);
return false;
}
if (price > balance){
var invalid= "<?php echo translate('uws:price_above_balance')?>";
alert();
return false;
}
if (bid >= max_bid)
{
var bid_too_high= "<?php echo translate('uws:bid_too_high')?>";
alert(bid_too_high);
return false;
}
else {
return true;
}
}
function update_fields() {
calc_fair_price();
calc_factor();
}
function calc_factor2() {
if (last_factor == 0)
{
var old_factor = document.forms['bid'].elements["old_factor"].value;
last_factor = old_factor;
}
var same_factor_price_per_unit = document.forms['bid'].elements["same_factor_price_per_unit"].value;
var new_price = document.forms['bid'].elements["price"].value;
var reference = document.forms['bid'].elements["my_share_physical"].value;
// var new_factor = (new_price / (reference / 100)) / 100;
var new_factor = (last_factor * reference) / new_price;
document.forms['bid'].elements["my_factor"].value = new_factor;
}
function calc_factor() {
var same_factor_price_per_unit = document.forms['bid'].elements["same_factor_price_per_unit"].value;
var new_price = document.forms['bid'].elements["price"].value;
var bid_amount = document.forms['bid'].elements["my_bid_amount"].value;
var new_price_per_unit = bid_amount / new_price;
var new_factor = same_factor_price_per_unit / new_price_per_unit;
document.forms['bid'].elements["my_factor"].value = new_factor;
}
function calc_fair_price() {
var bid = document.forms['bid'].elements["my_bid_amount"].value;
var total_cost = document.forms['bid'].elements["total_cost"].value;
var total_units = document.forms['bid'].elements["physical"].value;
var unit_price = total_cost / total_units;
var bid_price = bid * unit_price;
document.forms['bid'].elements["price"].value = bid_price;
}
</script>
</head>
<body>
<div id="outer">
<div id="upbg"></div>
<div id="inner">
<?php
include "header.php";
$username = $_SESSION['uname'];
$bidID = $_GET['bidID'];
$inventory = 0;
$balance = 0;
$myshare = 0;
$my_share_price = 0;
//if unitID not set, first offer to choose unit
$sql = "SELECT * from bid where bid_id='" . $bidID . "'";
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query))
{
$inventory = $result['tstamp'];
$user = $result['member_id'];
$unit = $result['asset_id'];
$amount = $result['amount'];
$price = $result['price'];
$factor = $result['factor'];
}
?>
<?php
// $sql = "SELECT balance from members where contributor='" . $username . "'";
// $query = mysql_query($sql);
// while ($result = mysql_fetch_array($query))
// {
// $balance = $result['balance'];
// }
//
// $sql = "SELECT total_services from uwstotals";
// $query = mysql_query($sql);
// $total_services = mysql_fetch_row($query);
//
// $sql = "SELECT total_inventory from uwstotals";
// $query = mysql_query($sql);
// $total_inventory = mysql_fetch_row($query);
//
// $total_cost = $inventory * $total_services[0] / $total_inventory[0];
// $ratio = $total_cost / $balance;
// $my_share_physical = $physical / $ratio;
// $my_share_inventory = $inventory / $ratio;
//
// if ($my_share_physical > $physical)
// {
// $my_share_physical = $physical;
// $my_share_inventory = $inventory;
// }
//
// $price = ($total_cost / $inventory) * $my_share_inventory;
// $same_factor_price_per_unit = $physical / $total_cost;
?>
<h3><?php echo translate("uws:bid_asset") . ": " . $unit ?></h3>
<div class="date">
<?php
echo date('d F Y') ?></div>
</div>
<div class="content">
<form name="bid" id="story" action="placeBid.php" method="post" enctype="multipart/form-data">
<table class="formtable" width="470" cellspacing="0" cellpadding="0">
<tr>
<td width="150" class="text"><?php echo translate("uws:inventory")?>:</td>
<td width="10"> </td>
<td><span class="text">
<input name="inventory" type="text" id="inventory" value="<?php echo $inventory?>" size="40" readonly/>
</span>
</td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" class="text"><?php echo translate("uws:physical")?>:</td>
<td width="5"> </td>
<td><span class="text"><input name="physical" type="text" id="physical" value="<?php echo $physical ?>" size="40" readonly/>
</span></td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" class="text"><?php echo translate("uws:factor") ?></td>
<td width="10"> </td>
<td><span class="text"><input name="factor" type="text" id="factor" value="<?php echo $factor ?>" size="40" readonly/>
</span></td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" class="text"><?php echo translate("uws:total_cost") ?></td>
<td width="10"> </td>
<td><span class="text"><input name="total_cost" type="text" id="total_cost" value="<?php echo $total_cost ?>" size="40" readonly/>
</span></td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" class="text"><?php echo translate("uws:my_share_physical") ?></td>
<td width="10"> </td>
<td><span class="text"><input name="my_share_physical" type="text" id="my_share_physical" value="<?php echo $my_share_physical ?>" size="40" readonly/>
</span></td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" class="text"><?php echo translate("uws:my_share_inventory") ?></td>
<td width="10"> </td>
<td><span class="text"><input name="my_share_inventory" type="text" id="my_share_inventory" value="<?php echo $my_share_inventory ?>" size="40" readonly/>
</span></td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr bgcolor=" #666666">
<td width="150" height="1"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" class="text"><?php echo translate("uws:balance") ?>:</td>
<td width="10"> </td>
<td><span class="text"><input name="balance" type="text" id="balance" value="<?php echo $balance?>" size="40" readonly/>
</span></td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" class="text"><?php echo translate("uws:my_bid_amount") ?></td>
<td width="10"> </td>
<td>
<span class="text">
<input name="my_bid_amount" type="text" id="my_bid_amount" value="<?php echo $my_share_physical ?>" onchange=update_fields() />
</span>
</td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" class="text"><?php echo translate("uws:price") ?></td>
<td width="10"> </td>
<td><span class="text"><input name="price" type="text" id="price" value="<?php echo $price ?>" size="40" onchange=calc_factor() />
</span></td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td width="150" class="text"><?php echo translate("uws:my_factor") ?></td>
<td width="10"> </td>
<td><span class="text"><input name="my_factor" type="text" id="my_factor" value="<?php echo $factor ?>" size="40" readonly/>
</span></td>
</tr>
<tr>
<td width="150" height="5"></td>
<td height="5"></td>
<td></td>
</tr>
<tr>
<td colspan="3"><div align="left" class="text">
<input type="submit" name="place_bid" id="place_bid" value="<?php echo translate("uws:submit_bid") ?>" onclick="return validate_form()" />
<br />
<br />
<!--
<input type="button" name="button2" id="button2" value="<?php echo translate("uws:save_record") ?>" onclick="javascript:saveStory()" />
-->
<br />
<br />
</div></td>
</tr>
</table>
<input type="hidden" name="asset_id" id="asset_id" value="<?php echo $asset_id ?>" />
<input type="hidden" name="unit" id="unit" value="<?php echo $unit ?>" />
<input type="hidden" name="old_factor" id="unit" value="<?php echo $factor ?>" />
<input type="hidden" name="same_factor_price_per_unit" id="same_factor_price_per_unit" value="<?php echo $same_factor_price_per_unit ?>" />
</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>