1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @package Blockchain payment |
4
|
|
|
* @category modules |
5
|
|
|
* @author Nazar Mokrynskyi <[email protected]> |
6
|
|
|
* @copyright Copyright (c) 2015-2016, Nazar Mokrynskyi |
7
|
|
|
* @license MIT License, see license.txt |
8
|
|
|
*/ |
9
|
|
|
namespace cs\modules\Blockchain_payment; |
10
|
|
|
use |
11
|
|
|
h, |
12
|
|
|
cs\Language\Prefix, |
13
|
|
|
cs\Page, |
14
|
|
|
cs\User; |
15
|
|
|
|
16
|
|
|
function make_url ($arguments) { |
17
|
|
|
$base_url = 'admin/Blockchain_payment/transactions?'; |
18
|
|
|
return $base_url.http_build_query(array_merge((array)$_GET, $arguments)); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
function make_header ($title, $field) { |
22
|
|
|
$order_by = @$_GET['order_by'] ?: 'created'; |
23
|
|
|
$icon = $order_by == $field ? h::icon(@$_GET['asc'] ? 'caret-up' : 'caret-down') : ''; |
24
|
|
|
$asc = $order_by == $field ? !@$_GET['asc'] : false; |
25
|
|
|
return h::a( |
26
|
|
|
"$title $icon", |
27
|
|
|
[ |
28
|
|
|
'href' => make_url( |
29
|
|
|
[ |
30
|
|
|
'order_by' => $field, |
31
|
|
|
'asc' => $asc, |
32
|
|
|
'page' => 1 |
33
|
|
|
] |
34
|
|
|
) |
35
|
|
|
] |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$L = new Prefix('blockchain_payment_'); |
40
|
|
|
$Transactions = Transactions::instance(); |
41
|
|
|
$page = @$_GET['page'] ?: 1; |
42
|
|
|
$count = @$_GET['count'] ?: 100; |
43
|
|
|
$transactions = $Transactions->get( |
44
|
|
|
$Transactions->search( |
45
|
|
|
(array)$_GET, |
46
|
|
|
$page, |
47
|
|
|
$count, |
48
|
|
|
@$_GET['order_by'] ?: 'created', |
49
|
|
|
@$_GET['asc'] |
50
|
|
|
) |
51
|
|
|
); |
52
|
|
|
$transactions_total = $Transactions->search( |
53
|
|
|
[ |
54
|
|
|
'total_count' => 1 |
55
|
|
|
] + (array)$_GET, |
56
|
|
|
$page, |
57
|
|
|
$count, |
58
|
|
|
@$_GET['order_by'] ?: 'created', |
59
|
|
|
@$_GET['asc'] |
60
|
|
|
); |
61
|
|
|
Page::instance() |
62
|
|
|
->title($L->transactions) |
63
|
|
|
->content( |
64
|
|
|
h::{'h2.cs-text-center'}($L->transactions). |
65
|
|
|
h::{'table.cs-table[list]'}( |
66
|
|
|
h::{'tr th'}( |
67
|
|
|
make_header('id', 'id'), |
68
|
|
|
make_header($L->amount, 'amount'), |
69
|
|
|
make_header($L->currency, 'currency'), |
70
|
|
|
make_header($L->amount_btc, 'amount_btc'), |
71
|
|
|
make_header($L->user, 'user'), |
72
|
|
|
make_header($L->created, 'created'), |
73
|
|
|
make_header($L->paid, 'paid'), |
74
|
|
|
make_header($L->confirmed, 'confirmed') |
75
|
|
|
). |
76
|
|
|
h::tr( |
77
|
|
|
array_map( |
78
|
|
|
function ($transaction) use ($L) { |
79
|
|
|
$created = $transaction['created'] |
80
|
|
|
? $L->to_locale( |
81
|
|
|
date($L->{TIME - $transaction['created'] < 24 * 3600 ? '_time' : '_datetime_long'}, $transaction['created']) |
82
|
|
|
) |
83
|
|
|
: '-'; |
84
|
|
|
$paid = $transaction['paid'] |
85
|
|
|
? $L->to_locale( |
86
|
|
|
date($L->{TIME - $transaction['paid'] < 24 * 3600 ? '_time' : '_datetime_long'}, $transaction['paid']) |
87
|
|
|
) |
88
|
|
|
: '-'; |
89
|
|
|
$confirmed = $transaction['confirmed'] |
90
|
|
|
? $L->to_locale( |
91
|
|
|
date($L->{TIME - $transaction['confirmed'] < 24 * 3600 ? '_time' : '_datetime_long'}, $transaction['confirmed']) |
92
|
|
|
) |
93
|
|
|
: '-'; |
94
|
|
|
$username = User::instance()->username($transaction['user']); |
95
|
|
|
$class = |
96
|
|
|
$transaction['confirmed'] ? 'cs-block-success.cs-text-success' : |
97
|
|
|
($transaction['paid'] ? 'cs-block-warning.cs-text-warning' : 'cs-block-error.cs-text-error'); |
98
|
|
|
$tag = "td.$class"; |
99
|
|
|
return [ |
100
|
|
|
[ |
101
|
|
|
h::$tag( |
102
|
|
|
$transaction['id'], |
103
|
|
|
$transaction['amount'], |
104
|
|
|
$transaction['currency'], |
105
|
|
|
$transaction['amount_btc'], |
106
|
|
|
h::a( |
107
|
|
|
$username, |
108
|
|
|
[ |
109
|
|
|
'href' => "admin/Blockchain_payment/transactions/?user=$transaction[user]" |
110
|
|
|
] |
111
|
|
|
), |
112
|
|
|
$created, |
113
|
|
|
$paid, |
114
|
|
|
$confirmed |
115
|
|
|
), |
116
|
|
|
[ |
117
|
|
|
'style' => 'border-bottom: none;' |
118
|
|
|
] |
119
|
|
|
], |
120
|
|
|
h::$tag( |
121
|
|
|
"$L->module: ". |
122
|
|
|
h::a( |
123
|
|
|
$transaction['module'], |
124
|
|
|
[ |
125
|
|
|
'href' => "admin/Blockchain_payment/transactions/?module=$transaction[module]" |
126
|
|
|
] |
127
|
|
|
). |
128
|
|
|
" $L->purpose: $transaction[purpose]". |
129
|
|
|
h::br(). |
130
|
|
|
"$L->destination_address: ". |
131
|
|
|
h::{'a[target=_blank]'}( |
132
|
|
|
$transaction['destination_address'], |
133
|
|
|
[ |
134
|
|
|
'href' => "https://blockchain.info/address/$transaction[destination_address]" |
135
|
|
|
] |
136
|
|
|
). |
137
|
|
|
" $L->intermediate_address: ". |
138
|
|
|
h::{'a[target=_blank]'}( |
139
|
|
|
$transaction['input_address'], |
140
|
|
|
[ |
141
|
|
|
'href' => "https://blockchain.info/address/$transaction[input_address]" |
142
|
|
|
] |
143
|
|
|
). |
144
|
|
|
h::br(). |
145
|
|
|
" $L->transaction_hash: ". |
146
|
|
|
h::{'a[target=_blank]'}( |
147
|
|
|
$transaction['transaction_hash'], |
148
|
|
|
[ |
149
|
|
|
'href' => "https://blockchain.info/tx/$transaction[transaction_hash]" |
150
|
|
|
] |
151
|
|
|
). |
152
|
|
|
" $L->intermediate_transaction_hash: ". |
153
|
|
|
h::{'a[target=_blank]'}( |
154
|
|
|
$transaction['input_transaction_hash'], |
155
|
|
|
[ |
156
|
|
|
'href' => "https://blockchain.info/tx/$transaction[input_transaction_hash]" |
157
|
|
|
] |
158
|
|
|
). |
159
|
|
|
h::br(). |
160
|
|
|
nl2br($transaction['description']), |
161
|
|
|
[ |
162
|
|
|
'colspan' => 8 |
163
|
|
|
] |
164
|
|
|
) |
165
|
|
|
]; |
166
|
|
|
}, |
167
|
|
|
$transactions |
168
|
|
|
) ?: false |
169
|
|
|
) |
170
|
|
|
). |
171
|
|
|
pages( |
172
|
|
|
$page, |
173
|
|
|
ceil($transactions_total / $count), |
174
|
|
|
function ($page) { |
175
|
|
|
return make_url( |
176
|
|
|
[ |
177
|
|
|
'page' => $page |
178
|
|
|
] |
179
|
|
|
); |
180
|
|
|
}, |
181
|
|
|
true |
182
|
|
|
) |
183
|
|
|
); |
184
|
|
|
|