-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathmanage_currencies.php
82 lines (78 loc) · 2.61 KB
/
manage_currencies.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
<?php
require(AppSettings::srcPath()."/includes/connect.php");
require(AppSettings::srcPath()."/includes/get_session.php");
$nav_tab_selected = "manage_currencies";
$pagetitle = AppSettings::getParam('site_name')." - Manage Currencies";
AppSettings::addJsDependency("jquery.datatables.js");
include(AppSettings::srcPath()."/includes/html_start.php");
?>
<div class="container-fluid">
<?php
if (!$thisuser) {
$redirect_url = $app->get_redirect_url($_SERVER['REQUEST_URI']);
$redirect_key = $redirect_url['redirect_key'];
include(AppSettings::srcPath()."/includes/html_register.php");
}
else if (!$app->user_is_admin($thisuser)) {
?>
You must be logged in as admin to manage currencies.
<?php
}
else {
$reference_currency = $app->get_reference_currency();
$display_currency = $app->fetch_currency_by_id(1);
$all_currencies = $app->fetch_currencies([])->fetchAll();
?>
<div class="panel panel-default" style="margin-top: 15px;">
<div class="panel-heading">
<div class="panel-title">
Manage Currencies
</div>
</div>
<div class="panel-body">
<p><?php echo count($all_currencies); ?> currencies are installed.</p>
<table style="width: 100%;" class="table table-bordered">
<thead style="background-color: #f6f6f6;">
<tr>
<th>Name</th>
<th>Symbol</th>
<th>Exchange Rate</th>
<th>Exchange Rate Time</th>
</tr>
</thead>
<tbody>
<?php
foreach ($all_currencies as $currency) {
$price_info = $app->exchange_rate_between_currencies($display_currency['currency_id'], $currency['currency_id'], time(), $reference_currency['currency_id']);
?>
<tr>
<td><?php echo $currency['name']; ?></td>
<td><?php echo $currency['abbreviation']; ?></td>
<td>
<?php
if (!empty($price_info['time'])){
echo $display_currency['abbreviation']."/".$currency['abbreviation']." ".$app->round_to(1/$price_info['exchange_rate'], false, EXCHANGE_RATE_SIGFIGS, true)." (".$app->round_to($price_info['exchange_rate'], false, EXCHANGE_RATE_SIGFIGS, true).")";
}
?>
</td>
<td>
<?php
if (!empty($price_info['time']) && $currency['currency_id'] != $display_currency['currency_id']) {
echo $app->format_seconds(time()-$price_info['time'])." ago";
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<?php
}
?>
</div>
<?php
include(AppSettings::srcPath().'/includes/html_stop.php');