|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* PayPal Donation extension for the phpBB Forum Software package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2015-2020 Skouat |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace skouat\ppde\controller\admin; |
|
12
|
|
|
|
|
13
|
|
|
use phpbb\template\template; |
|
14
|
|
|
use phpbb\user; |
|
15
|
|
|
use phpbb\user_loader; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @property template template Template object |
|
19
|
|
|
* @property user user User object. |
|
20
|
|
|
*/ |
|
21
|
|
|
class donors_controller extends admin_main |
|
22
|
|
|
{ |
|
23
|
|
|
protected $ppde_actions_currency; |
|
24
|
|
|
protected $ppde_entity_transactions; |
|
25
|
|
|
protected $ppde_operator_transactions; |
|
26
|
|
|
protected $user_loader; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Constructor |
|
30
|
|
|
* |
|
31
|
|
|
* @param \skouat\ppde\actions\currency $ppde_actions_currency Currency actions object |
|
32
|
|
|
* @param \skouat\ppde\entity\transactions $ppde_entity_transactions Transactions entity object |
|
33
|
|
|
* @param \skouat\ppde\operators\transactions $ppde_operator_transactions Transactions operators object |
|
34
|
|
|
* @param template $template Template object |
|
35
|
|
|
* @param user $user User object. |
|
36
|
|
|
* @param \phpbb\user_loader $user_loader User loader object |
|
37
|
|
|
* @access public |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct( |
|
40
|
|
|
\skouat\ppde\actions\currency $ppde_actions_currency, |
|
41
|
|
|
\skouat\ppde\entity\transactions $ppde_entity_transactions, |
|
42
|
|
|
\skouat\ppde\operators\transactions $ppde_operator_transactions, |
|
43
|
|
|
template $template, |
|
44
|
|
|
user $user, |
|
45
|
|
|
user_loader $user_loader |
|
46
|
|
|
) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->ppde_actions_currency = $ppde_actions_currency; |
|
49
|
|
|
$this->ppde_entity_transactions = $ppde_entity_transactions; |
|
50
|
|
|
$this->ppde_operator_transactions = $ppde_operator_transactions; |
|
51
|
|
|
$this->template = $template; |
|
52
|
|
|
$this->user = $user; |
|
53
|
|
|
$this->user_loader = $user_loader; |
|
54
|
|
|
parent::__construct( |
|
55
|
|
|
'donors', |
|
56
|
|
|
'PPDE_DD', |
|
57
|
|
|
'donor' |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Display the transactions list |
|
63
|
|
|
* |
|
64
|
|
|
* @return void |
|
65
|
|
|
* @access public |
|
66
|
|
|
*/ |
|
67
|
|
|
public function display() |
|
68
|
|
|
{ |
|
69
|
|
|
// Adds fields to the table schema needed by entity->import() |
|
70
|
|
|
$donorlist_table_schema = [ |
|
71
|
|
|
'item_amount' => ['name' => 'amount', 'type' => 'float'], |
|
72
|
|
|
'item_max_txn_id' => ['name' => 'max_txn_id', 'type' => 'integer'], |
|
73
|
|
|
'item_user_id' => ['name' => 'user_id', 'type' => 'integer'], |
|
74
|
|
|
'item_mc_currency' => ['name' => 'mc_currency', 'type' => 'string'], |
|
75
|
|
|
]; |
|
76
|
|
|
|
|
77
|
|
|
$sql_donorlist_ary = $this->ppde_operator_transactions->sql_donors_list('', false); |
|
78
|
|
|
$data_ary = $this->ppde_entity_transactions->get_data($this->ppde_operator_transactions->build_sql_donorlist_data($sql_donorlist_ary), $donorlist_table_schema, 0, 0, true); |
|
79
|
|
|
|
|
80
|
|
|
// Adds fields to the table schema needed by entity->import() |
|
81
|
|
|
$last_donation_table_schema = [ |
|
82
|
|
|
'item_payment_date' => ['name' => 'payment_date', 'type' => 'integer'], |
|
83
|
|
|
'item_mc_gross' => ['name' => 'mc_gross', 'type' => 'float'], |
|
84
|
|
|
'item_mc_currency' => ['name' => 'mc_currency', 'type' => 'string'], |
|
85
|
|
|
]; |
|
86
|
|
|
|
|
87
|
|
|
foreach ($data_ary as $data) |
|
88
|
|
|
{ |
|
89
|
|
|
$get_last_transaction_sql_ary = $this->ppde_operator_transactions->sql_last_donation_ary($data['max_txn_id']); |
|
90
|
|
|
$last_donation_data = $this->ppde_entity_transactions->get_data($this->ppde_operator_transactions->build_sql_donorlist_data($get_last_transaction_sql_ary), $last_donation_table_schema, 0, 0, true); |
|
91
|
|
|
$currency_mc_data = $this->ppde_actions_currency->get_currency_data($last_donation_data[0]['mc_currency']); |
|
92
|
|
|
$this->template->assign_block_vars('donors', [ |
|
93
|
|
|
'PPDE_DONOR_USERNAME' => $this->user_loader->get_username($data['user_id'], 'full', false, false, true), |
|
|
|
|
|
|
94
|
|
|
'PPDE_LAST_DONATED_AMOUNT' => $this->ppde_actions_currency->format_currency((float) $last_donation_data[0]['mc_gross'], $currency_mc_data[0]['currency_iso_code'], $currency_mc_data[0]['currency_symbol'], (bool) $currency_mc_data[0]['currency_on_left']), |
|
95
|
|
|
'PPDE_LAST_PAYMENT_DATE' => $this->user->format_date($last_donation_data[0]['payment_date']), |
|
96
|
|
|
]); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|