-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontract_activity.php
More file actions
231 lines (229 loc) · 8.15 KB
/
contract_activity.php
File metadata and controls
231 lines (229 loc) · 8.15 KB
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
<?php
require_once 'bootstrap.php';
require_once 'include/layout.php';
require_once 'include/components/stat_card.php';
include_once 'include/graph.php';
$graphConfigs = require 'include/graph_configs.php';
use Siagraph\Utils\ApiClient;
use Siagraph\Utils\Locale;
$months = 12; // default visible range; slider covers all data
$aggEndpoint = '/api/v1/monthly/aggregates';
$latestData = ApiClient::fetchJson($aggEndpoint);
$dataError = !is_array($latestData);
$latest = $dataError ? [] : end($latestData);
$asOf = !$dataError && isset($latest['date']) ? $latest['date'] : null;
$asOfText = $asOf ? ('Monthly total as of ' . \Siagraph\Utils\Locale::date($asOf)) : 'Monthly total';
?>
<?php render_header("SiaGraph - Contract Activity"); ?>
<section id="main-content" class="sg-container">
<h1 class="sg-container__heading text-center mb-2"><i class="bi bi-clock-history me-2"></i>Contract Activity</h1>
<!-- range dropdown removed -->
<?php if ($dataError): ?>
<p class="text-center text-muted">Contract data unavailable.</p>
<?php endif; ?>
<div class="sg-container__row mb-4">
<div class="sg-container__row-content sg-container__row-content--center">
<div class="sg-container__column sg-container__column--one-fifth">
<?php
render_stat_card([
'icon' => 'bi bi-file-earmark-text',
'label' => 'Contracts Formed',
'value' => isset($latest['contracts_formed']) ? Locale::integer($latest['contracts_formed']) : 'N/A',
'compact' => true,
'context' => $asOfText,
]);
?>
</div>
<div class="sg-container__column sg-container__column--one-fifth">
<?php
render_stat_card([
'icon' => 'bi bi-arrow-repeat',
'label' => 'Renewed',
'value' => isset($latest['renewed_contracts']) ? Locale::integer($latest['renewed_contracts']) : 'N/A',
'compact' => true,
'context' => $asOfText,
]);
?>
</div>
<div class="sg-container__column sg-container__column--one-fifth">
<?php
render_stat_card([
'icon' => 'bi bi-x-circle',
'label' => 'Failed',
'value' => isset($latest['failed_contracts']) ? Locale::integer($latest['failed_contracts']) : 'N/A',
'compact' => true,
'context' => $asOfText,
]);
?>
</div>
<div class="sg-container__column sg-container__column--one-fifth">
<?php
render_stat_card([
'icon' => 'bi bi-check-circle',
'label' => 'Successful',
'value' => isset($latest['successful_contracts']) ? Locale::integer($latest['successful_contracts']) : 'N/A',
'compact' => true,
'context' => $asOfText,
]);
?>
</div>
<div class="sg-container__column sg-container__column--one-fifth">
<?php
render_stat_card([
'icon' => 'bi bi-people-fill',
'label' => 'Unique Renters',
'value' => isset($latest['unique_contract_renters']) ? Locale::integer($latest['unique_contract_renters']) : 'N/A',
'compact' => true,
'context' => $asOfText,
]);
?>
</div>
</div>
</div>
<div class="sg-container__row">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Contracts Formed</h2>
<div class="card__content">
<?php
renderGraph(
'aggregates-contracts-formed',
[
$graphConfigs['contracts_formed']
],
'date',
$aggEndpoint,
null,
'bar',
'month',
true,
'true',
$months,
'false',
null
);
?>
</div>
</section>
</div>
</div>
</div>
<div class="sg-container__row">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Renewed Contracts</h2>
<div class="card__content">
<?php
renderGraph(
'aggregates-renewed-contracts',
[
$graphConfigs['renewed_contracts']
],
'date',
$aggEndpoint,
null,
'bar',
'month',
true,
'true',
$months,
'false',
null
);
?>
</div>
</section>
</div>
</div>
</div>
<div class="sg-container__row mt-4">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Failed Contracts</h2>
<div class="card__content">
<?php
renderGraph(
'aggregates-failed-contracts',
[
$graphConfigs['failed_contracts']
],
'date',
$aggEndpoint,
null,
'bar',
'month',
true,
'true',
$months,
'false',
null
);
?>
</div>
</section>
</div>
</div>
</div>
<div class="sg-container__row mt-4">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Successful Contracts</h2>
<div class="card__content">
<?php
renderGraph(
'aggregates-successful-contracts',
[
$graphConfigs['successful_contracts']
],
'date',
$aggEndpoint,
null,
'bar',
'month',
true,
'true',
$months,
'false',
null
);
?>
</div>
</section>
</div>
</div>
</div>
<div class="sg-container__row mt-4">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Unique Renter Identities</h2>
<div class="card__content">
<?php
renderGraph(
'aggregates-unique-renters',
[
$graphConfigs['unique_contract_renters']
],
'date',
$aggEndpoint,
null,
'bar',
'month',
true,
'true',
$months,
'false',
null
);
?>
</div>
</section>
</div>
</div>
</div>
</section>
<?php render_footer(); ?>