1 | <?php |
||
2 | /************************************************************************/ |
||
3 | /* Donations - Paypal financial management module for Xoops 2 */ |
||
4 | /* Copyright (c) 2016 XOOPS Project */ |
||
5 | /* http://dev.xoops.org/modules/xfmod/project/?group_id=1060 */ |
||
6 | /* |
||
7 | /************************************************************************/ |
||
8 | /* */ |
||
9 | /* Based on NukeTreasury for PHP-Nuke - by Dave Lawrence AKA Thrash */ |
||
10 | /* NukeTreasury - Financial management for PHP-Nuke */ |
||
11 | /* Copyright (c) 2004 by Dave Lawrence AKA Thrash */ |
||
12 | /* [email protected] */ |
||
13 | /* [email protected] */ |
||
14 | /* */ |
||
15 | /************************************************************************/ |
||
16 | /* */ |
||
17 | /* This program is free software; you can redistribute it and/or modify */ |
||
18 | /* it under the terms of the GNU General Public License as published by */ |
||
19 | /* the Free Software Foundation; either version 2 of the License. */ |
||
20 | /* */ |
||
21 | /* This program is distributed in the hope that it will be useful, but */ |
||
22 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ |
||
23 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ |
||
24 | /* General Public License for more details. */ |
||
25 | /* */ |
||
26 | /* You should have received a copy of the GNU General Public License */ |
||
27 | /* along with this program; if not, write to the Free Software */ |
||
28 | /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ |
||
29 | /* USA */ |
||
30 | /************************************************************************/ |
||
31 | |||
32 | use XoopsModules\Xdonations; |
||
33 | |||
34 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||
35 | |||
36 | $moduleDirName = basename(dirname(__DIR__)); |
||
37 | |||
38 | xoops_loadLanguage('main', $moduleDirName); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
39 | |||
40 | /** |
||
41 | * @param $options |
||
42 | * @return array |
||
43 | */ |
||
44 | function b_donations_donors_show($options) |
||
45 | { |
||
46 | global $xoopsDB; |
||
47 | $utility = new Xdonations\Utility(); |
||
48 | $tr_config = $utility::getConfigInfo(); |
||
49 | //determine the currency |
||
50 | $PP_CURR_CODE = explode('|', $tr_config['pp_curr_code']); // [USD,GBP,JPY,CAD,EUR] |
||
51 | $PP_CURR_CODE = $PP_CURR_CODE[0]; |
||
52 | $currencySign = $utility::defineCurrency($PP_CURR_CODE); |
||
53 | |||
54 | $dmshowdate = $options[1]; |
||
55 | $dmshowamt = $options[2]; |
||
56 | $block = []; |
||
57 | $swingd = $tr_config['swing_day']; |
||
58 | |||
59 | if (($swingd < 0) || ($swingd > 31)) { |
||
60 | $swingd = 6; |
||
61 | } |
||
62 | |||
63 | if (date('d') >= $swingd) { |
||
64 | $query_Recordset1 = "SELECT custom AS muser_id, option_selection1 as showname, DATE_FORMAT(payment_date, '%b %e') AS date, CONCAT('" |
||
65 | . $currencySign |
||
66 | . "',SUM(mc_gross)) AS amt FROM " |
||
67 | . $xoopsDB->prefix('donations_transactions') |
||
68 | . " WHERE (payment_date >= DATE_FORMAT(NOW(),'%Y-%m-" |
||
69 | . $swingd |
||
70 | . "')) GROUP BY txn_id ORDER BY payment_date DESC"; |
||
71 | } else { |
||
72 | $query_Recordset1 = "SELECT custom AS muser_id, option_selection1 as showname, DATE_FORMAT(payment_date, '%b-%e') AS date, CONCAT('" |
||
73 | . $currencySign |
||
74 | . "',SUM(mc_gross)) AS amt FROM " |
||
75 | . $xoopsDB->prefix('donations_transactions') |
||
76 | . " WHERE (payment_date < DATE_FORMAT(NOW(), '%Y-%m-" |
||
77 | . $swingd |
||
78 | . "')) AND payment_date > DATE_FORMAT(SUBDATE(NOW(),INTERVAL " |
||
79 | . $swingd |
||
80 | . " DAY), '%Y-%m-" |
||
81 | . $swingd |
||
82 | . "') GROUP BY txn_id ORDER BY payment_date DESC"; |
||
83 | } |
||
84 | |||
85 | $Recordset1 = $xoopsDB->query($query_Recordset1); |
||
86 | $totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
||
0 ignored issues
–
show
|
|||
87 | |||
88 | $ROWS_DONATORS = ''; |
||
89 | // Fill out the donators table tag |
||
90 | while (false !== ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))) { |
||
91 | if ($row_Recordset1['amt'] > $currencySign . '0') { |
||
92 | $ROWS_DONATORS .= '<tr>'; |
||
93 | $ROWS_DONATORS .= '<td style="font-weight: bold;"> '; |
||
94 | |||
95 | $muser_id = $row_Recordset1['muser_id']; |
||
96 | if (0 == strcmp($row_Recordset1['showname'], 'Yes') && ($userfoin = $utility::getUserInfo($muser_id))) { |
||
97 | $ROWS_DONATORS .= "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userfoin->getVar('uid') . "'>" . xdshorten($userfoin->getVar('uname')) . "</a>\n"; |
||
0 ignored issues
–
show
|
|||
98 | } else { |
||
99 | $ROWS_DONATORS .= _MB_XDONATION_ANONYMOUS_SHORT; |
||
100 | } |
||
101 | |||
102 | $ROWS_DONATORS .= "</td>\n"; |
||
103 | if ($dmshowamt) { |
||
104 | $ROWS_DONATORS .= "<td style=\"width: 2px;\"> </td>\n"; |
||
105 | $ROWS_DONATORS .= '<td style="width: 55px; font-weight: bold;"> '; |
||
106 | $ROWS_DONATORS .= $row_Recordset1['amt']; |
||
107 | $ROWS_DONATORS .= "</td>\n"; |
||
108 | } |
||
109 | if ($dmshowdate) { |
||
110 | $ROWS_DONATORS .= "<td style=\"width: 2px;\"> </td>\n"; |
||
111 | $ROWS_DONATORS .= '<td style="font-weight: bold;"> '; |
||
112 | $ROWS_DONATORS .= $row_Recordset1['date']; |
||
113 | $ROWS_DONATORS .= "</td>\n"; |
||
114 | } |
||
115 | $ROWS_DONATORS .= "</tr>\n"; |
||
116 | } |
||
117 | } |
||
118 | |||
119 | // Ok, output the page |
||
120 | |||
121 | $block['showamt'] = $dmshowamt; |
||
122 | $block['showdate'] = $dmshowdate; |
||
123 | $block['list'] = $ROWS_DONATORS; |
||
124 | $block['amount'] = _MB_XDONATION_AMOUNT; |
||
125 | $block['date'] = _MB_XDONATION_DATE; |
||
126 | $block['name'] = _MB_XDONATION_NAME; |
||
127 | |||
128 | return $block; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @param $var |
||
133 | * @param int $len |
||
134 | * @return string |
||
135 | */ |
||
136 | function xdshorten($var, $len = 10) |
||
137 | { |
||
138 | $var = trim($var); |
||
139 | if (empty($var)) { |
||
140 | return ''; |
||
141 | } |
||
142 | if (strlen($var) < $len) { |
||
143 | return $var; |
||
144 | } |
||
145 | |||
146 | if (preg_match("/(.{1,$len})\s/", $var, $match)) { |
||
147 | return $match [1] . '...'; |
||
148 | } |
||
149 | |||
150 | return substr($var, 0, $len) . '...'; |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @param $options |
||
155 | * @return string |
||
156 | */ |
||
157 | function b_donations_donors_edit($options) |
||
158 | { |
||
159 | $form = _MB_XDONATION_NUM_DONORS . ": <input type='text' name='options[0]' value='" . $options[0] . "' size='4'>"; |
||
160 | $form .= '<br>' . _MB_XDONATION_REVEAL_DATES . ": <select size='1' name='options[1]'><option value='1'"; |
||
161 | if (1 == $options[1]) { |
||
162 | $form .= ' selected'; |
||
163 | } |
||
164 | $form .= '>' . _YES . "</option><option value='0'"; |
||
0 ignored issues
–
show
|
|||
165 | if (0 == $options[1]) { |
||
166 | $form .= ' selected'; |
||
167 | } |
||
168 | $form .= '>' . _NO . '</option></select>'; |
||
0 ignored issues
–
show
|
|||
169 | $form .= '<br>' . _MB_XDONATION_REVEAL_AMOUNTS . ": <select size='1' name='options[2]'><option value='1'"; |
||
170 | if (1 == $options[2]) { |
||
171 | $form .= ' selected'; |
||
172 | } |
||
173 | $form .= '>' . _YES . "</option><option value='0'"; |
||
174 | if (0 == $options[2]) { |
||
175 | $form .= ' selected'; |
||
176 | } |
||
177 | $form .= '>' . _NO . '</option></select>'; |
||
178 | |||
179 | return $form; |
||
180 | } |
||
181 |