forked from phpcoinn/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtxs.php
More file actions
171 lines (151 loc) · 7.21 KB
/
txs.php
File metadata and controls
171 lines (151 loc) · 7.21 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
<?php
require_once dirname(__DIR__)."/apps.inc.php";
define("PAGE", true);
define("APP_NAME", "Explorer");
require_once ROOT. '/web/apps/explorer/include/functions.php';
function getConditions($search) {
$condition = "";
$params = [];
if(isset($search['type']) && is_array($search['type']) && count($search['type'])>0) {
$list = implode(",", $search['type']);
$condition .= " and type in ($list)";
}
if(isset($search['date']['from']) && !empty($search['date']['from'])) {
$condition.= " and date >= :dateFrom ";
$params[":dateFrom"]=strtotime($search['date']['from']);
}
if(isset($search['date']['to']) && !empty($search['date']['to'])) {
$condition.= " and date <= :dateTo ";
$params[":dateTo"]=strtotime($search['date']['to']);
}
if(isset($search['src']) && !empty($search['src'])) {
$condition.= " and src like :src ";
$params[':src']=$search['src'];
}
if(isset($search['dst']) && !empty($search['dst'])) {
$condition.= " and dst like :dst ";
$params[':dst']=$search['dst'];
}
return [$condition, $params];
}
function TransactiongetCount() {
global $db;
list($condition, $params) = getConditions($_GET['search']);
$sql="select count(*) as cnt from transactions where type >= 0 $condition";
$row = $db->row($sql, $params);
return $row['cnt'];
}
function TransactiongetAll($dm) {
global $db;
list($condition, $params) = getConditions($dm['search']);
$limit = $dm['limit'];
$start = $dm['start'];
$sorting = $dm['sorting'];
$sql="select * from transactions where 1 $condition $sorting limit $start, $limit";
return $db->run($sql, $params);
}
$link = '/apps/explorer/txs.php?';
$dm = get_data_model(TransactiongetCount(), $link, "order by height desc");
$txs = TransactiongetAll($dm);
define("HEAD_CSS", ["/apps/common/css/flatpickr.min.css","/apps/common/css/choices.min.css"]);
require_once __DIR__. '/../common/include/top.php';
?>
<ol class="breadcrumb m-0 ps-0 h4">
<li class="breadcrumb-item"><a href="/apps/explorer">Explorer</a></li>
<li class="breadcrumb-item">Transactions</li>
</ol>
<form class="row mb-3" method="get" action="">
<div class="col-lg-2">
<input type="text" class="form-control flatpickr-input p-1 datepicker" placeholder="Date from" name="search[date][from]"
value="<?php echo $dm['search']['date']['from'] ?? '' ?>">
</div>
<div class="col-lg-2">
<input type="text" class="form-control flatpickr-input p-1 datepicker" placeholder="Date to" name="search[date][to]"
value="<?php echo $dm['search']['date']['to'] ?? '' ?>">
</div>
<div class="col-lg-2">
<input type="text" class="form-control p-1" placeholder="Source" value="<?php echo $dm['search']['src'] ?? '' ?>" name="search[src]">
</div>
<div class="col-lg-2">
<input type="text" class="form-control p-1" placeholder="Destination" value="<?php echo $dm['search']['dst'] ?? '' ?>" name="search[dst]">
</div>
<div class="col-lg-2">
<select class="form-control"
id="choices-type" name="search[type][]"
multiple>
<option value="">Type</option>
<option value="<?php echo TX_TYPE_REWARD ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_REWARD,$dm['search']['type'])) { ?> selected<?php } ?>>Reward</option>
<option value="<?php echo TX_TYPE_SEND ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_SEND,$dm['search']['type'])) { ?> selected<?php } ?>>Transfer</option>
<option value="<?php echo TX_TYPE_BURN ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_BURN,$dm['search']['type'])) { ?> selected<?php } ?>>Burn</option>
<option value="<?php echo TX_TYPE_MN_CREATE ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_MN_CREATE,$dm['search']['type'])) { ?> selected<?php } ?>>Create masternode</option>
<option value="<?php echo TX_TYPE_MN_REMOVE ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_MN_REMOVE,$dm['search']['type'])) { ?> selected<?php } ?>>Remove masternode</option>
<option value="<?php echo TX_TYPE_FEE ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_FEE,$dm['search']['type'])) { ?> selected<?php } ?>>Fee</option>
<option value="<?php echo TX_TYPE_SC_CREATE ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_SC_CREATE,$dm['search']['type'])) { ?> selected<?php } ?>>Create Smart Contract</option>
<option value="<?php echo TX_TYPE_SC_EXEC ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_SC_EXEC,$dm['search']['type'])) { ?> selected<?php } ?>>Execute Smart Contract</option>
<option value="<?php echo TX_TYPE_SC_SEND ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_SC_SEND,$dm['search']['type'])) { ?> selected<?php } ?>>Send Smart Contract</option>
<option value="<?php echo TX_TYPE_SYSTEM ?>" <?php if(isset($dm['search']['type']) && in_array(TX_TYPE_SYSTEM,$dm['search']['type'])) { ?> selected<?php } ?>>System</option>
</select>
</div>
<div class="col-lg-2 text-end">
<button type="submit" class="btn btn-primary btn-sm">Search</button>
<a href="<?php echo $link ?>" class="btn btn-outline-primary btn-sm">Clear</a>
</div>
</form>
<div class="table-responsive">
<table class="table table-sm table-striped dataTable">
<thead class="table-light">
<tr>
<?php echo sort_column($link, $dm, 'id', 'ID', 'text-start') ?>
<?php echo sort_column($link, $dm, 'date', 'Date', 'text-start') ?>
<?php echo sort_column($link, $dm, 'height', 'Height', 'text-start') ?>
<?php echo sort_column($link, $dm, 'block', 'Block', 'text-start') ?>
<th>Source</th>
<?php echo sort_column($link, $dm, 'dst', 'Destination', 'text-start') ?>
<?php echo sort_column($link, $dm, 'type', 'Type', 'text-start') ?>
<?php echo sort_column($link, $dm, 'val', 'Value') ?>
<?php echo sort_column($link, $dm, 'fee', 'Fee') ?>
</tr>
</thead>
<tbody>
<?php foreach($txs as $tx) { ?>
<tr>
<td><?php echo explorer_tx_link($tx['id'], true) ?></td>
<td><?php echo display_date($tx['date']) ?></td>
<td><?php echo $tx['height'] ?></td>
<td><?php echo explorer_block_link($tx['block'], true) ?></td>
<td><?php echo explorer_address_link($tx['src'], true) ?></td>
<td><?php echo explorer_address_link($tx['dst'], true) ?></td>
<td><?php echo Transaction::typeLabel($tx['type']) ?></td>
<td class="text-end"><?php echo $tx['val'] ?></td>
<td class="text-end"><?php echo !empty(floatval($tx['fee'])) ? $tx['fee'] : '' ?></td>
<?php } ?>
</tbody>
</table>
</div>
<?php echo $dm['paginator'] ?>
<script src="/apps/common/js/choices.min.js"></script>
<script src="/apps/common/js/flatpickr.min.js"></script>
<script type="text/javascript">
flatpickr('.datepicker', {
enableTime: true
});
new Choices(
'#choices-type',
{
removeItemButton: true,
shouldSort: false
}
);
</script>
<style>
.choices__inner {
min-height: 31px;
padding: 0 0.25rem;
}
.choices__list--multiple .choices__item {
padding: 2px 5px;
}
</style>
<?php
require_once __DIR__ . '/../common/include/bottom.php';
?>