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
|
|
|
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; |
35
|
|
|
|
36
|
|
|
xoops_loadLanguage('main', $xoopsModule->getVar('dirname')); |
|
|
|
|
37
|
|
|
// require_once dirname(__DIR__) . '/class/Utility.php'; |
38
|
|
|
require_once __DIR__ . '/admin_header.php'; |
39
|
|
|
xoops_cp_header(); |
|
|
|
|
40
|
|
|
|
41
|
|
|
$tr_config = $utility::getConfigInfo(); |
42
|
|
|
//determine the currency |
43
|
|
|
$PP_CURR_CODE = explode('|', $tr_config['pp_curr_code']); // [USD,GBP,JPY,CAD,EUR,AUD] |
44
|
|
|
$PP_CURR_CODE = $PP_CURR_CODE[0]; |
45
|
|
|
$currencySign = $utility::defineCurrency($PP_CURR_CODE); |
46
|
|
|
|
47
|
|
|
/*************************************************************************** |
48
|
|
|
* |
49
|
|
|
***************************************************************************/ |
50
|
|
|
function treasury() |
51
|
|
|
{ |
52
|
|
|
global $tr_config, $xoopsDB, $xoopsModule, $modversion, $currencySign, $pathIcon16; |
53
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
|
|
|
54
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
|
|
|
|
55
|
|
|
$adminObject->displayNavigation('donations.php?op=Treasury'); |
56
|
|
|
|
57
|
|
|
// Register paging |
58
|
|
|
$maxRows_Recordset1 = 10; |
59
|
|
|
$pageNum_Recordset1 = \Xmf\Request::getInt('pageNum_Recordset1', 0, 'POST'); |
|
|
|
|
60
|
|
|
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; |
61
|
|
|
|
62
|
|
|
// $query_Recordset1 = "SELECT id, date, DATE_FORMAT(date, '%d-%b-%Y') as fdate, DATE_FORMAT(date, '%d') as day, DATE_FORMAT(date, '%m') as mon, DATE_FORMAT(date, '%Y') as year, num, name, descr, amount FROM ".$xoopsDB->prefix("donations_financial")." order by date DESC"; |
63
|
|
|
$query_Recordset1 = "SELECT id, date, DATE_FORMAT(date, '%d-%b-%Y') AS fdate, num, name, descr, amount FROM " . $xoopsDB->prefix('donations_financial') . ' ORDER BY date DESC'; |
64
|
|
|
$query_limit_Recordset1 = "$query_Recordset1 LIMIT $startRow_Recordset1, $maxRows_Recordset1"; |
65
|
|
|
$Recordset1 = $xoopsDB->query($query_limit_Recordset1); |
66
|
|
|
$row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
67
|
|
|
|
68
|
|
|
if (\Xmf\Request::hasVar('totalRows_Recordset1', 'POST')) { |
69
|
|
|
$totalRows_Recordset1 = $_POST['totalRows_Recordset1']; |
70
|
|
|
} else { |
71
|
|
|
$all_Recordset1 = $xoopsDB->query($query_Recordset1); |
72
|
|
|
$totalRows_Recordset1 = $xoopsDB->getRowsNum($all_Recordset1); |
73
|
|
|
} |
74
|
|
|
$totalPages_Recordset1 = ceil($totalRows_Recordset1 / $maxRows_Recordset1) - 1; |
75
|
|
|
$queryString_Recordset1 = '&totalRows_Recordset1=' . $totalRows_Recordset1 . '#AdminTop'; |
|
|
|
|
76
|
|
|
|
77
|
|
|
// Collect IPN reconcile data |
78
|
|
|
// First, get the date of the last time we reconciled |
79
|
|
|
$query_Recordset2 = 'SELECT `date` AS recdate FROM ' . $xoopsDB->prefix('donations_financial') . " WHERE name = 'PayPal IPN' ORDER BY date DESC LIMIT 1"; |
80
|
|
|
$Recordset2 = $xoopsDB->query($query_Recordset2); |
81
|
|
|
$row_Recordset2 = $xoopsDB->fetchArray($Recordset2); |
82
|
|
|
$recdate = $row_Recordset2['recdate']; |
83
|
|
|
|
84
|
|
|
// Get the date of the last donation |
85
|
|
|
$query_Recordset2 = 'SELECT `payment_date` AS curdate FROM ' . $xoopsDB->prefix('donations_transactions') . " WHERE payment_status = 'Completed' AND (txn_type = 'send_money' OR txn_type = 'web_accept' ) ORDER BY payment_date DESC LIMIT 1"; |
86
|
|
|
$Recordset2 = $xoopsDB->query($query_Recordset2); |
87
|
|
|
$row_Recordset2 = $xoopsDB->fetchArray($Recordset2); |
88
|
|
|
$curdate = $row_Recordset2['curdate']; |
89
|
|
|
|
90
|
|
|
// Collect the IPN transactions between recdate and curdate |
91
|
|
|
$query_Recordset2 = 'SELECT custom, SUM(mc_gross) AS gross, SUM(mc_gross - mc_fee) AS net FROM ' . $xoopsDB->prefix('donations_transactions') . " WHERE (payment_date > '{$recdate}' AND payment_date <= '{$curdate}') GROUP BY txn_id"; |
92
|
|
|
$Recordset2 = $xoopsDB->query($query_Recordset2); |
93
|
|
|
|
94
|
|
|
// Iterate over the records skipping the ones that total out to zero(refunds) |
95
|
|
|
$ipn_tot = 0; |
96
|
|
|
$num_ipn = 0; |
97
|
|
|
while (false !== ($row_Recordset2 = $xoopsDB->fetchArray($Recordset2))) { |
98
|
|
|
if ($row_Recordset2['gross'] > 0) { |
99
|
|
|
$ipn_tot += $row_Recordset2['net']; |
100
|
|
|
++$num_ipn; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
// Get the register balance & total number of records |
105
|
|
|
$query_Recordset4 = 'SELECT SUM(amount) AS total, COUNT(*) AS numRec FROM ' . $xoopsDB->prefix('donations_financial') . ' '; |
106
|
|
|
$Recordset4 = $xoopsDB->query($query_Recordset4); |
107
|
|
|
list($total, $numRec) = $xoopsDB->fetchRow($Recordset4); |
108
|
|
|
/* |
109
|
|
|
$row_Recordset4 = $xoopsDB->fetchArray($Recordset4); |
110
|
|
|
$total = $row_Recordset4['total']; |
111
|
|
|
|
112
|
|
|
// Query to remove the Edit/Delete buttons if no results will be listed. |
113
|
|
|
$queryRec = "SELECT COUNT(*) FROM ".$xoopsDB->prefix("donations_financial").""; |
114
|
|
|
list($numRec) = $xoopsDB->fetchRow($queryRec); |
115
|
|
|
*/ |
116
|
|
|
// Output the page |
117
|
|
|
echo "<table style=\"border-width: 1px; width: 100%; text-align: center;\">\n" . "<tr><td>\n"; |
118
|
|
|
echo "<table style=\"border-width: 0px; padding: 0px; margin: 0px; text-align: center;\">\n"; |
119
|
|
|
echo ' <tr><td style="width: 100%; text-align: center; font-weight: bold;">'; |
120
|
|
|
echo '<span class="option"><h3>' . _AD_XDONATION_TREASURY_F_REGISTER . "</h3></span></td></tr>\n"; |
121
|
|
|
echo ' <tr><td style="width: 100%;">' . _AD_XDONATION_NEW_IPN_COUNT . " {$num_ipn} - " . _AD_XDONATION_TOTALING . " {$currencySign}{$ipn_tot}"; |
122
|
|
|
echo "</td></tr>\n"; |
123
|
|
|
echo "<tr><td style=\"width: 100%; text-align: center;\">\n"; |
124
|
|
|
echo " <form action=\"donations.php?op=IpnRec#AdminTop\" method=\"post\">\n"; |
125
|
|
|
echo " <input type=\"hidden\" name=\"op\" value=\"IpnRec\">\n" . ' <input type="submit" value="' . _AD_XDONATION_SYNCHRONISE_IPN . "\" onClick=\"return confirm('" . _AD_XDONATION_CONFIRM_TOTAL_UP . "')\">\n" . " </form>\n"; |
126
|
|
|
echo "</td></tr></table>\n"; |
127
|
|
|
|
128
|
|
|
if ($pageNum_Recordset1 > 0) { |
129
|
|
|
echo "<table style=\"border-width: 0px; text-align: center;\">\n" . " <tr>\n"; |
130
|
|
|
echo " <td><form action=\"donations.php#AdminTop\" method=\"post\">\n" |
131
|
|
|
. "<input type=\"hidden\" name=\"op\" value=\"Treasury\">\n" |
132
|
|
|
. "<input type=\"hidden\" name=\"pageNum_Recordset1\" value=\"0\">\n" |
133
|
|
|
. "<input type=\"hidden\" name=\"totalRows_Recordset1\" value=\"{$totalRows_Recordset1}\">\n" |
134
|
|
|
. '<input type="submit" name="navig" value="|<" title="' |
135
|
|
|
. _AD_XDONATION_CURRENT |
136
|
|
|
. "\"></form></td>\n"; |
137
|
|
|
echo "<td><form action=\"donations.php#AdminTop\" method=\"post\">\n" |
138
|
|
|
. "<input type=\"hidden\" name=\"op\" value=\"Treasury\">\n" |
139
|
|
|
. '<input type="hidden" name="pageNum_Recordset1" value="' |
140
|
|
|
. max(0, $pageNum_Recordset1 - 1) |
141
|
|
|
. "\">\n" |
142
|
|
|
. "<input type=\"hidden\" name=\"totalRows_Recordset1\" value=\"{$totalRows_Recordset1}\">\n" |
143
|
|
|
. '<input type="submit" name="navig" value="<" title="' |
144
|
|
|
. _AD_XDONATION_NEXT_NEWEST |
145
|
|
|
. "\"></form></td>\n"; |
146
|
|
|
if ($pageNum_Recordset1 < $totalPages_Recordset1) { |
147
|
|
|
echo "<td><form action=\"donations.php#AdminTop\" method=\"post\">\n" |
148
|
|
|
. "<input type=\"hidden\" name=\"op\" value=\"Treasury\">\n" |
149
|
|
|
. '<input type="hidden" name="pageNum_Recordset1" value="' |
150
|
|
|
. min($totalPages_Recordset1, $pageNum_Recordset1 + 1) |
151
|
|
|
. "\">\n" |
152
|
|
|
. "<input type=\"hidden\" name=\"totalRows_Recordset1\" value=\"{$totalRows_Recordset1}\">\n" |
153
|
|
|
. '<input type="submit" name="navig" value=">" title="' |
154
|
|
|
. _AD_XDONATION_NEXT_OLDEST |
155
|
|
|
. "\"></form></td>\n"; |
156
|
|
|
echo "<td><form action=\"donations.php#AdminTop\" method=\"post\">\n" |
157
|
|
|
. "<input type=\"hidden\" name=\"op\" value=\"Treasury\">\n" |
158
|
|
|
. "<input type=\"hidden\" name=\"pageNum_Recordset1\" value=\"{$totalPages_Recordset1}\">\n" |
159
|
|
|
. "<input type=\"hidden\" name=\"totalRows_Recordset1\" value=\"{$totalRows_Recordset1}\">\n" |
160
|
|
|
. '<input type="submit" name="navig" value=">|" title="' |
161
|
|
|
. _AD_XDONATION_OLDEST |
162
|
|
|
. "\"></form></td>\n"; |
163
|
|
|
} |
164
|
|
|
echo "</tr></table>\n"; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
echo "<table class='outer' width='100%' border='0' cellpadding='0' cellspacing='0'>" |
168
|
|
|
. "<th align='center'>" |
169
|
|
|
. _AD_XDONATION_DATE |
170
|
|
|
. "</th><th align='center'>" |
171
|
|
|
. _AD_XDONATION_NUM |
172
|
|
|
. "</th><th align='center'>" |
173
|
|
|
. _AD_XDONATION_NAME |
174
|
|
|
. "</th><th align='center'>" |
175
|
|
|
. _AD_XDONATION_DESCRIPTION |
176
|
|
|
. "</th><th align='center'>" |
177
|
|
|
. _AD_XDONATION_AMOUNT |
178
|
|
|
. "</th><th align='center'>" |
179
|
|
|
. _AD_XDONATION_ACTION |
180
|
|
|
. "</th></tr>\n"; |
181
|
|
|
// $class = 'even'; |
182
|
|
|
|
183
|
|
|
$row = 0; |
184
|
|
|
do { |
185
|
|
|
++$row; |
186
|
|
|
echo "<tr>\n"; |
187
|
|
|
echo "</td>\n" |
188
|
|
|
. "<td style=\"text-align: center;\">$row_Recordset1[fdate]</td>\n" |
189
|
|
|
. "<td style=\"text-align: center; width: 8px;\">$row_Recordset1[num]</td>\n" |
190
|
|
|
. "<td style=\"text-align: center;\">$row_Recordset1[name]</td>\n" |
191
|
|
|
. "<td style=\"text-align: center;\">$row_Recordset1[descr]</td>\n" |
192
|
|
|
. '<td style="text-align: right;"><span '; |
193
|
|
|
$amt = sprintf('%10.2f', $row_Recordset1['amount']); |
194
|
|
|
if ($amt < 0) { |
195
|
|
|
echo 'style="color: #FF0000;"'; |
196
|
|
|
} |
197
|
|
|
echo ">{$currencySign}{$amt}</span></td>\n"; |
198
|
|
|
|
199
|
|
|
if (0 != $numRec) { |
200
|
|
|
echo '<td style="text-align: center;">'; |
201
|
|
|
$jscriptCmd = '<a href="javascript: void 0" onclick="' . "document.recedit.id.value = '$row_Recordset1[id]'; " . "document.recedit.StartDate.value = '$row_Recordset1[fdate]'; "; |
202
|
|
|
$jscriptCmd .= "document.recedit.Num.value = '$row_Recordset1[num]'; " |
203
|
|
|
. "document.recedit.Name.value = '$row_Recordset1[name]'; " |
204
|
|
|
. "document.recedit.Descr.value = '$row_Recordset1[descr]'; " |
205
|
|
|
. "document.recedit.Amount.value = '$row_Recordset1[amount]'; " |
206
|
|
|
. "document.recedit.Submit.value = 'Modify'; " |
207
|
|
|
. "document.recedit.op.value = 'FinRegEdit'; " |
208
|
|
|
. 'return false;">' |
209
|
|
|
. '<img style="border-width: 0px; width: 16px; height: 16px;" src=' |
210
|
|
|
. $pathIcon16 |
211
|
|
|
. '/edit.png' |
212
|
|
|
. " alt='" |
213
|
|
|
. _EDIT |
|
|
|
|
214
|
|
|
. "' title='" |
215
|
|
|
. _EDIT |
216
|
|
|
. "'></a> " |
217
|
|
|
. "<a href=\"donations.php?op=FinRegDel&id=$row_Recordset1[id]\">" |
218
|
|
|
. '<img style="border-width: 0px; width: 16px; height: 16px;" src=' |
219
|
|
|
. $pathIcon16 |
220
|
|
|
. '/delete.png' |
221
|
|
|
. " alt='" |
222
|
|
|
. _DELETE |
|
|
|
|
223
|
|
|
. "' title='" |
224
|
|
|
. _DELETE |
225
|
|
|
. "'\" onClick=\"return confirm('" |
226
|
|
|
. _AD_XDONATION_CONFIRM_DELETE |
227
|
|
|
. '\n\n' |
228
|
|
|
. _AD_XDONATION_CONFIRM_ACTION |
229
|
|
|
. "')\"" |
230
|
|
|
. '></a>' |
231
|
|
|
. "</td>\n"; |
232
|
|
|
echo $jscriptCmd; |
233
|
|
|
} |
234
|
|
|
} while (false !== ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))); |
235
|
|
|
|
236
|
|
|
echo "</table>\n" . "<table style=\"width: 100%; text-align: center;\"><br>\n"; |
237
|
|
|
echo '<tr><td style="text-align: right; font-weight: bold;" colspan="5"><h4>' . _AD_XDONATION_NETBAL . ": {$currencySign}"; |
238
|
|
|
echo sprintf('%0.2f', $total) . " </h4></td></tr>\n"; |
239
|
|
|
echo "</table><br>\n"; |
240
|
|
|
|
241
|
|
|
echo "<table style=\"text-align: center;\">\n" |
242
|
|
|
. '<tr><td style="text-align: center; font-weight: bold;">' |
243
|
|
|
. _AD_XDONATION_DATE |
244
|
|
|
. "</td>\n" |
245
|
|
|
. '<td style="text-align: center; font-weight: bold;">' |
246
|
|
|
. _AD_XDONATION_NUM |
247
|
|
|
. "</td>\n" |
248
|
|
|
. '<td style="text-align: center; font-weight: bold;">' |
249
|
|
|
. _AD_XDONATION_NAME |
250
|
|
|
. "</td>\n" |
251
|
|
|
. '<td style="text-align: center; font-weight: bold;">' |
252
|
|
|
. _AD_XDONATION_DESCRIPTION |
253
|
|
|
. "</td>\n" |
254
|
|
|
. '<td style="text-align: right; font-weight: bold;">' |
255
|
|
|
. _AD_XDONATION_AMOUNT |
256
|
|
|
. "</td></tr>\n" |
257
|
|
|
. "<tr>\n" |
258
|
|
|
. "<td style=\"text-align: center;\">\n" |
259
|
|
|
. "<form action=\"donations.php\" method=\"post\" name=\"recedit\">\n" |
260
|
|
|
. "<input name=\"id\" type=\"hidden\">\n"; |
261
|
|
|
$newDate = new \XoopsFormTextDateSelect('Date', 'StartDate', $size = 15, null); |
|
|
|
|
262
|
|
|
$showDate = $newDate->render(); |
263
|
|
|
echo $showDate . "</td>\n"; |
264
|
|
|
echo "<td style=\"text-align: center; width: 8px;\"><input name=\"Num\" type=\"text\" size=\"8\"></td>\n" |
265
|
|
|
. "<td style=\"text-align: center;\"><input name=\"Name\" type=\"text\"></td>\n" |
266
|
|
|
. "<td style=\"text-align: center;\"><input name=\"Descr\" type=\"text\"></td>\n" |
267
|
|
|
. "<td style=\"text-align: right;\"><input name=\"Amount\" type=\"text\" size=\"8\"></td>\n"; |
268
|
|
|
echo "</tr>\n"; |
269
|
|
|
echo "<tr><td style=\"text-align: right;\" colspan=\"5\">\n" |
270
|
|
|
. '<input name="" type="reset" value="' |
271
|
|
|
. _RESET |
|
|
|
|
272
|
|
|
. '" onclick="' |
273
|
|
|
. "document.recedit.Submit.value = '" |
274
|
|
|
. _ADD |
|
|
|
|
275
|
|
|
. "'; " |
276
|
|
|
. "document.recedit.op.value = 'FinRegAdd'; " |
277
|
|
|
. "return true;\"> \n" |
278
|
|
|
. '<input type="hidden" name="op" value="FinRegAdd"><input name="Submit" type="submit" value="' |
279
|
|
|
. _AD_XDONATION_ADD |
280
|
|
|
. "\">\n" |
281
|
|
|
. "</form>\n"; |
282
|
|
|
echo "</td></tr>\n"; |
283
|
|
|
echo "</table>\n"; |
284
|
|
|
echo "</td></tr></table>\n"; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
function addFinancialReg() |
288
|
|
|
{ |
289
|
|
|
global $tr_config, $modversion, $xoopsDB; |
290
|
|
|
|
291
|
|
|
$time = date('h:i:s'); |
292
|
|
|
// $nTime = $_POST['StartYear'].'-'.$_POST['StartMonth'].'-'.$_POST['StartDay'].' '.$time; |
293
|
|
|
// $nTime = strtotime($nTime); |
294
|
|
|
$nTime = strtotime("{$_POST['StartDate']} {$time}"); |
295
|
|
|
if (-1 == $nTime) { |
296
|
|
|
echo _AD_XDONATION_ERR_BAD_DATE_FORMAT . "<br>\n"; |
297
|
|
|
} else { |
298
|
|
|
if ('' === $_POST['Name']) { |
299
|
|
|
echo _AD_XDONATION_ERR_BAD_NAME_FORMAT . "<br>\n"; |
300
|
|
|
} else { |
301
|
|
|
if (!is_numeric($_POST['Amount'])) { |
302
|
|
|
echo _AD_XDONATION_INVALID_AMOUNT . '<br>'; |
303
|
|
|
} else { |
304
|
|
|
echo _AD_XDONATION_FIELD_PASSED . '<br>'; |
305
|
|
|
echo strftime('%Y-%m-%d', $nTime) . " $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br><br>"; |
306
|
|
|
|
307
|
|
|
$insertRecordset = 'INSERT INTO `' |
308
|
|
|
. $xoopsDB->prefix('donations_financial') |
309
|
|
|
. '` VALUES ' |
310
|
|
|
. "(NULL, '" |
311
|
|
|
. strftime('%Y-%m-%d %H:%M:%S', $nTime) |
312
|
|
|
. "','" |
313
|
|
|
. addslashes($_POST['Num']) |
314
|
|
|
. "','" |
315
|
|
|
. addslashes($_POST['Name']) |
316
|
|
|
. "','" |
317
|
|
|
. addslashes($_POST['Descr']) |
318
|
|
|
. "','" |
319
|
|
|
. addslashes($_POST['Amount']) |
320
|
|
|
. "')"; |
321
|
|
|
|
322
|
|
|
$rvalue = $xoopsDB->query($insertRecordset); |
|
|
|
|
323
|
|
|
echo $insertRecordset; |
324
|
|
|
echo strftime('%Y-%m-%d', $nTime) . " $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br><br>$insertRecordset"; |
325
|
|
|
header('Location: donations.php?op=Treasury#AdminTop'); |
326
|
|
|
} |
327
|
|
|
} |
328
|
|
|
} |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
function deleteFinancialReg() |
332
|
|
|
{ |
333
|
|
|
global $tr_config, $modversion, $xoopsDB; |
334
|
|
|
|
335
|
|
|
echo _AD_XDONATION_FIELD_PASSED . "<br>\n"; |
336
|
|
|
|
337
|
|
|
if (is_numeric($_GET['id']) && ($_GET['id'] > 0)) { |
338
|
|
|
$del_Recordset = 'DELETE FROM `' . $xoopsDB->prefix('donations_financial') . '`' . " WHERE `id`='" . \Xmf\Request::getInt('id', 0, 'GET') . "' LIMIT 1"; |
339
|
|
|
$rvalue = $xoopsDB->queryF($del_Recordset); |
|
|
|
|
340
|
|
|
header('Location: donations.php?op=Treasury#AdminTop'); |
341
|
|
|
} else { |
342
|
|
|
echo '<br>' . _AD_XDONATION_ERR_INVALID_RECORD_ID . "<br>\n"; |
343
|
|
|
} |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
function editFinancialReg() |
347
|
|
|
{ |
348
|
|
|
global $tr_config, $modversion, $xoopsDB; |
349
|
|
|
|
350
|
|
|
$time = date('h:i:s'); |
351
|
|
|
// $nTime = $_POST['StartYear'].'-'.$_POST['StartMonth'].'-'.$_POST['StartDay'].' '.$time; |
352
|
|
|
$nTime = $_POST['StartDate'] . ' ' . $time; |
353
|
|
|
$nTime = strtotime($nTime); |
354
|
|
|
|
355
|
|
|
if (-1 == $nTime) { |
356
|
|
|
echo _AD_XDONATION_ERR_BAD_DATE_FORMAT . "<br>\n"; |
357
|
|
|
} else { |
358
|
|
|
if ('' === $_POST['Name']) { |
359
|
|
|
echo _AD_XDONATION_ERR_BAD_NAME_FORMAT . "<br>\n"; |
360
|
|
|
} else { |
361
|
|
|
if (!is_numeric($_POST['Amount'])) { |
362
|
|
|
echo _AD_XDONATION_INVALID_AMOUNT2 . '<br>\n'; |
363
|
|
|
} else { |
364
|
|
|
echo _AD_XDONATION_FIELD_PASSED . "<br>\n"; |
365
|
|
|
|
366
|
|
|
echo strftime('%Y-%m-%d', $nTime) . " $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br><br>\n"; |
367
|
|
|
|
368
|
|
|
$insertRecordset = 'UPDATE `' . $xoopsDB->prefix('donations_financial') . "` SET date='" . strftime('%Y-%m-%d %H:%M:%S', $nTime) . "', num='$_POST[Num]', Name='$_POST[Name]', " . "descr='$_POST[Descr]', amount='$_POST[Amount]' WHERE id='$_POST[id]' LIMIT 1"; |
369
|
|
|
|
370
|
|
|
echo $insertRecordset; |
371
|
|
|
$rvalue = $xoopsDB->query($insertRecordset); |
|
|
|
|
372
|
|
|
|
373
|
|
|
echo (string)$_POST['id'] . strftime('%Y-%m-%d', $nTime) . " $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br><br>$insertRecordset"; |
374
|
|
|
|
375
|
|
|
header('Location: donations.php?op=Treasury#AdminTop'); |
376
|
|
|
} |
377
|
|
|
} |
378
|
|
|
} |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
/********************************************************************* |
382
|
|
|
* |
383
|
|
|
*********************************************************************/ |
384
|
|
|
function setConfig() |
385
|
|
|
{ |
386
|
|
|
global $tr_config, $xoopsModule, $modversion, $xoopsDB; |
387
|
|
|
|
388
|
|
|
|
389
|
|
|
/** @var Xdonations\Utility $utility */ |
390
|
|
|
$utility = new Xdonations\Utility(); |
391
|
|
|
|
392
|
|
|
//------------------------------------------------------------------------ |
393
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
394
|
|
|
$adminObject->displayNavigation('donations.php?op=Config'); ?> |
395
|
|
|
<script Language="JavaScript"> |
396
|
|
|
function isEmailAddr(email) { |
397
|
|
|
var result = false; |
398
|
|
|
var theStr = String(email); |
399
|
|
|
var index = theStr.indexOf("@"); |
400
|
|
|
if (index > 0) { |
401
|
|
|
var pindex = theStr.indexOf(".", index); |
402
|
|
|
if ((pindex > index + 1) && (theStr.length > pindex + 1)) |
403
|
|
|
result = true; |
404
|
|
|
} |
405
|
|
|
return result; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
function validRequired(formField, fieldLabel, message) { |
409
|
|
|
var result = true; |
410
|
|
|
|
411
|
|
|
if (formField.value === "") { |
412
|
|
|
alert(message.replace("%1\$s", field)); |
413
|
|
|
|
414
|
|
|
formField.focus(); |
415
|
|
|
result = false; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
return result; |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
function allDigits(str) { |
422
|
|
|
return inValidCharSet(str, "0123456789"); |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
function inValidCharSet(str, charset) { |
426
|
|
|
var result = true; |
427
|
|
|
|
428
|
|
|
// Note: doesn't use regular expressions to avoid early Mac browser bugs |
429
|
|
|
for (var i = 0; i < str.length; i++) |
430
|
|
|
if (charset.indexOf(str.substr(i, 1)) < 0) { |
431
|
|
|
result = false; |
432
|
|
|
break; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
return result; |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
function validInt(formField, fieldLabel, required, message) { |
439
|
|
|
var result = true; |
440
|
|
|
|
441
|
|
|
if (required && !validRequired(formField, fieldLabel, message)) |
442
|
|
|
result = false; |
443
|
|
|
|
444
|
|
|
if (result) { |
445
|
|
|
// var num = parseInt(formField.value,10); |
446
|
|
|
if (!allDigits(formField.value)) { |
447
|
|
|
if (required) { |
448
|
|
|
//alert('Please enter a number for the "' + fieldLabel +'" field.'); |
449
|
|
|
alert(message.replace("%1\$s", fieldLabel)); |
450
|
|
|
formField.focus(); |
451
|
|
|
result = false; |
452
|
|
|
} |
453
|
|
|
elseif(formField.value == "") |
454
|
|
|
{ |
455
|
|
|
return true; |
456
|
|
|
} |
457
|
|
|
else |
458
|
|
|
{ |
459
|
|
|
//alert('Please enter a number or a blank for the "' + fieldLabel +'" field.'); |
460
|
|
|
alert(message.replace("%1\$s", fieldLabel)); |
461
|
|
|
formField.focus(); |
462
|
|
|
result = false; |
463
|
|
|
} |
464
|
|
|
} |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
return result; |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
|
471
|
|
|
function validateURL(formField, value, secure) { |
472
|
|
|
|
473
|
|
|
var match = /https/i.test(value); |
474
|
|
|
|
475
|
|
|
if (value !== "" && !/^http/i.test(value)) { |
476
|
|
|
alert('The URL must start with http://'); |
477
|
|
|
formField.focus(); |
478
|
|
|
|
479
|
|
|
return false; |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
if (secure && value !== "" && !/^https/i.test(value)) { |
483
|
|
|
// alert('This should reside on a HTTPS server. Users will be warned about viewing secure and non-secure data on the same page'); |
484
|
|
|
return confirm('This URL does not begin with https://\nThis image should reside on an HTTPS server.\nIf you use this URL, users will receive a warning\nabout viewing secure and non-secure data on the same page.\n\n Are you sure you want to continue?'); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
return true; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
|
491
|
|
|
function checkCancelledURL() { |
492
|
|
|
if (document.tr_configs.var_pp_image_url.value === "") |
493
|
|
|
alert('There is no URL for a Cancelled payment. If you do not enter\na URL for cancelled payments PayPal will also use\nthis URL for cancelled payments.'); |
494
|
|
|
|
495
|
|
|
return true; |
496
|
|
|
} |
497
|
|
|
</script> |
498
|
|
|
<?php |
499
|
|
|
//------------------------------------------------------------------------------- |
500
|
|
|
echo "<form name=\"tr_configs\" action=\"donations.php\" method=\"post\">\n" . "<input type=\"hidden\" name=\"op\" value=\"updateConfig\">\n"; |
501
|
|
|
echo "<table style=\"border-width: 1px; width: 90%; text-align: center;\"><tr>\n"; |
502
|
|
|
echo "<td style=\"text-align: center; font-weight: bold;\" class=\"title\">\n"; |
503
|
|
|
echo '<h3>' . _AD_XDONATION_CONFIG_MODULE . "</h3>\n"; |
504
|
|
|
echo "<table style=\"border-width: 1px; text-align: center;\">\n"; |
505
|
|
|
|
506
|
|
|
$utility::showTextBox('don_button_top', '<span style="font-weight: bold;">' . _AD_XDONATION_IMG_BUTTON_TOP . '</span>', '', '70', 'onChange="return validateURL(this,this.value);"'); |
|
|
|
|
507
|
|
|
$utility::showImgXYBox('don_top_img_width', 'don_top_img_height', '<span style="font-weight: bold;">' . _AD_XDONATION_IMAGE_SIZE . '</span>', '4', "onChange='return validInt(this,\"" . _AD_XDONATION_IMAGE_SIZE . '",0,"' . _AD_XDONATION_ALERTE_INPUT_NUMBER . "\");'"); |
508
|
|
|
$utility::showTextBox('don_button_submit', '<span style="font-weight: bold;">' . _AD_XDONATION_IMG_BUTTON_URL . '</span>', '', '70', 'onChange="return validateURL(this,this.value);"'); |
509
|
|
|
$utility::showImgXYBox('don_sub_img_width', 'don_sub_img_height', '<span style="font-weight: bold;">' . _AD_XDONATION_IMAGE_SIZE . '</span>', '4', "onChange='return validInt(this,\"" . _AD_XDONATION_IMAGE_SIZE . '",0,"' . _AD_XDONATION_ALERTE_INPUT_NUMBER . "\");'"); |
510
|
|
|
//"onChange='return validInt(this,"._AD_XDONATION_IMAGE_SIZE.")'" |
511
|
|
|
$utility::showTextBox('don_name_prompt', '<span style="font-weight: bold;">' . _AD_XDONATION_USERNAME_REQUEST . '</span>', '', '70', ''); |
512
|
|
|
$utility::showTextBox('don_name_yes', '<span style="font-weight: bold;">' . _AD_XDONATION_USERNAME_REQUEST_YES . '</span>', '', '50', ''); |
513
|
|
|
$utility::showTextBox('don_name_no', '<span style="font-weight: bold;">' . _AD_XDONATION_USERNAME_REQUEST_NO . '</span>', '', '50', ''); |
514
|
|
|
|
515
|
|
|
$desc = 'This is where you can appeal to your' . 'users and your community for donations.' . 'Suggestion: Explain why you need donations,' . 'what you do with the money and how you' . 'manage it. Make them comfortable that' . 'they are not throwing their money away.'; |
516
|
|
|
|
517
|
|
|
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'don_text'"; |
518
|
|
|
$Recordset = $xoopsDB->query($sql); |
519
|
|
|
$row = $xoopsDB->fetchArray($Recordset); |
520
|
|
|
$donText = $row['text']; |
521
|
|
|
echo "<tr>\n" |
522
|
|
|
. " <td title=\"{$desc}\" style=\"text-align: right; font-weight: bold;\">" |
523
|
|
|
. _AD_XDONATION_INTRODUCE_TEXT |
524
|
|
|
. "</td>\n" |
525
|
|
|
. " <td title=\"{$desc}\" style=\"text-align: left;\">" |
526
|
|
|
. "<textarea name=\"var_xdonation_text-rawtext-txt\" cols=\"100\" rows=\"20\">{$donText}</textarea></td>\n"; |
527
|
|
|
echo "</tr>\n"; |
528
|
|
|
|
529
|
|
|
// $utility::showTextBox('don_amt_checked', '<span style=\'font-weight: bold;\'>'._AD_XDONATION_AMOUNT_DEFAULT.'</span>', '', '4', "onChange=\"return validInt(this,'"._AD_XDONATION_AMOUNT_DEFAULT."',1,'"._AD_XDONATION_ALERTE_INPUT_NUMBER."');\""); |
530
|
|
|
|
531
|
|
|
echo "</table>\n"; |
532
|
|
|
echo "<br>\n"; |
533
|
|
|
|
534
|
|
|
$query_Recordset1 = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'don_amount' ORDER BY subtype"; |
535
|
|
|
$Recordset1 = $xoopsDB->query($query_Recordset1); |
536
|
|
|
$row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
537
|
|
|
$totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
|
|
|
|
538
|
|
|
$desc = htmlentities($row_Recordset1['text'], ENT_QUOTES | ENT_HTML5); |
539
|
|
|
|
540
|
|
|
echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
541
|
|
|
echo ' <tr><td style="text-align: center; width: 100%; font-weight: bold;" colspan="8">' . _AD_XDONATION_SUGGESTED_AMOUNT . "<br></td></tr>\n"; |
542
|
|
|
$row1 = " <tr><td title=\"{$desc}\" style=\"text-align: center;\"></td>\n"; |
543
|
|
|
$row2 = " <tr><td title=\"{$desc}\" style=\"text-align: center; font-weight: bold;\">" . _AD_XDONATION_AMOUNT . "</td>\n"; |
544
|
|
|
do { |
545
|
|
|
$row1 .= " <td title=\"{$desc}\" style=\"text-align: center;\">{$row_Recordset1['subtype']}</td>\n"; |
546
|
|
|
$row2 .= " <td title=\"{$desc}\" style=\"text-align: center;\"><input size=\"4\" name=\"var_xdonation_amount-{$row_Recordset1['subtype']}\" type=\"text\" value=\"{$row_Recordset1['value']}\" onChange=\"return validInt(this,'" |
547
|
|
|
. _AD_XDONATION_SUGGESTED_AMOUNT |
548
|
|
|
. " #{$row_Recordset1['subtype']}',1,'" |
549
|
|
|
. _AD_XDONATION_ALERTE_INPUT_NUMBER |
550
|
|
|
. "');\"></td>\n"; |
551
|
|
|
} while (false !== ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))); |
552
|
|
|
|
553
|
|
|
$row1 .= "</tr>\n"; |
554
|
|
|
$row2 .= "</tr>\n"; |
555
|
|
|
echo "{$row1} {$row2}\n"; |
556
|
|
|
|
557
|
|
|
// display default option |
558
|
|
|
$query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'don_amt_checked' LIMIT 1"; |
559
|
|
|
$cfgResult = $xoopsDB->query($query_cfg); |
560
|
|
|
$amt = $xoopsDB->fetchArray($cfgResult); |
561
|
|
|
$amt_checked = (int)$amt['value']; |
562
|
|
|
echo '<tr><td>' . _AD_XDONATION_DEFAULT . "</td>\n"; |
563
|
|
|
for ($i = 1; $i < 8; ++$i) { |
564
|
|
|
$checked = ($i == $amt_checked) ? ' checked' : ''; |
565
|
|
|
echo "<td><input type=\"radio\" name=\"var_xdonation_amt_checked\"{$checked} value=\"{$i}\"></td>\n"; |
566
|
|
|
} |
567
|
|
|
echo "</tr>\n"; |
568
|
|
|
echo "</table>\n"; |
569
|
|
|
|
570
|
|
|
echo "</td></tr>\n"; |
571
|
|
|
echo '<tr><td style="text-align: center; width: 100%;"><br><input type="submit" value="' . _AD_XDONATION_SUBMIT . '"></td></tr>'; |
572
|
|
|
echo "</table><br><br>\n"; |
573
|
|
|
$adminObject->displayNavigation('donations.php?op=Config'); |
574
|
|
|
echo "<table style=\"border-width: 1px; width: 90%; text-align: center;\"><tr>\n"; |
575
|
|
|
echo '<td class="title" style="font-weight: bold; text-align: center;"><h3>' . _AD_XDONATION_CONFIG_PAYPAL_HEADER . "</h3><br>\n"; |
576
|
|
|
echo "<table style=\"border-width: 1px; text-align: center;\">\n"; |
577
|
|
|
|
578
|
|
|
$rsql = 'SELECT rank_id, rank_title FROM ' . $xoopsDB->prefix('ranks') . ' '; |
579
|
|
|
$rresult = $xoopsDB->query($rsql); |
580
|
|
|
$r_array = []; |
581
|
|
|
while (false !== ($r_row = $xoopsDB->fetchRow($rresult))) { |
582
|
|
|
$r_array[] = $r_row; |
583
|
|
|
} |
584
|
|
|
$utility::showDropBox('paypal_url', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_IPN_URL . '</span>'); |
585
|
|
|
$utility::showTextBox('receiver_email', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_IPN_EMAIL_RECEIVER . '</span>', '', '40', ''); |
586
|
|
|
$utility::showTextBox('ty_url', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_IPN_URL_SUCCESS . '</span>', '', '80', 'onChange="checkCancelledURL(); return validateURL(this,this.value);"'); |
587
|
|
|
$utility::showTextBox('pp_cancel_url', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_IPN_URL_CANCELED . '</span>', '', '80', 'onChange="return validateURL(this,this.value);"'); |
588
|
|
|
$utility::showTextBox('pp_itemname', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_PP_ITEM_NAME . '</span>', '', '20', ''); |
589
|
|
|
$utility::showTextBox('pp_item_num', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_PP_ITEM_NUMBER . '</span>', '', '20', ''); |
590
|
|
|
$utility::showTextBox('pp_image_url', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_PP_IMG . '</span>', '', '60', ''); |
591
|
|
|
$utility::showYNBox('pp_get_addr', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_PP_ASK_CP_ADRESS . '</span>'); |
592
|
|
|
$utility::showDropBox('pp_curr_code', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_PP_MONEY . '</span>'); |
593
|
|
|
$gsql = 'SELECT groupid, name FROM ' . $xoopsDB->prefix('groups') . ' WHERE groupid>3'; |
594
|
|
|
$gresult = $xoopsDB->query($gsql); |
595
|
|
|
$g_array = []; |
596
|
|
|
while (false !== ($g_row = $xoopsDB->fetchRow($gresult))) { |
597
|
|
|
$g_array[] = $g_row; |
598
|
|
|
} |
599
|
|
|
$utility::showArrayDropBox('assign_group', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_PP_GROUP . '</span>', $g_array); |
600
|
|
|
$rsql = 'SELECT rank_id, rank_title FROM ' . $xoopsDB->prefix('ranks') . ' '; |
601
|
|
|
$rresult = $xoopsDB->query($rsql); |
602
|
|
|
$r_array = []; |
603
|
|
|
while (false !== ($r_row = $xoopsDB->fetchRow($rresult))) { |
604
|
|
|
$r_array[] = $r_row; |
605
|
|
|
} |
606
|
|
|
$utility::showArrayDropBox('assign_rank', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_PP_RANK . '</span>', $r_array); |
607
|
|
|
$utility::showYNBox('don_forceadd', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_ADD_ANYWAY . '</span>'); |
608
|
|
|
|
609
|
|
|
echo "</table><br>\n"; |
610
|
|
|
|
611
|
|
|
echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
612
|
|
|
echo ' <tr><td style="text-align: center; width: 100%; font-weight: bold;" colspan="2">' . _AD_XDONATION_IPN_LOGGING . "<br></td></tr>\n"; |
613
|
|
|
echo " <tr>\n" . ' <td style="text-align: right; font-weight: bold;">' . _AD_XDONATION_IPN_LOGGING_LEVEL . "</td>\n" . " <td style=\"text-align: left;\">\n" . " <select size=\"1\" name=\"var_ipn_dbg_lvl\">\n"; |
614
|
|
|
echo ' <option '; |
615
|
|
|
if (0 == $tr_config['ipn_dbg_lvl']) { |
616
|
|
|
echo 'selected '; |
617
|
|
|
} |
618
|
|
|
echo 'value="0">' . _AD_XDONATION_LOG_OFF . "</option>\n"; |
619
|
|
|
echo ' <option '; |
620
|
|
|
if (1 == $tr_config['ipn_dbg_lvl']) { |
621
|
|
|
echo 'selected '; |
622
|
|
|
} |
623
|
|
|
echo 'value="1">' . _AD_XDONATION_LOG_ONLY_ERRORS . "</option>\n"; |
624
|
|
|
echo ' <option '; |
625
|
|
|
if (2 == $tr_config['ipn_dbg_lvl']) { |
626
|
|
|
echo 'selected '; |
627
|
|
|
} |
628
|
|
|
echo 'value="2">' . _AD_XDONATION_LOG_EVERYTHING . "</option>\n"; |
629
|
|
|
echo " </select>\n" . " </td>\n" . " </tr>\n"; |
630
|
|
|
|
631
|
|
|
$utility::showTextBox('ipn_log_entries', '<nobr><span style=\'font-weight: bold;\'>' . _AD_XDONATION_LOG_ENTRY . '</span></nobr>', '', '4', ''); |
632
|
|
|
|
633
|
|
|
$desc = 'This box shows the link to the IPN recorder. |
634
|
|
|
This link must be pasted EXACTLY as it is |
635
|
|
|
into your PayPal IPN profile. You can click |
636
|
|
|
on the "test" link to the right to verify |
637
|
|
|
that the IPN recorder is functioning correctly.'; |
638
|
|
|
$desc = htmlentities($desc, ENT_QUOTES | ENT_HTML5); |
639
|
|
|
echo "<tr>\n" |
640
|
|
|
. " <td title =\"$desc\" style=\"text-align: right; font-weight: bold;\">" |
641
|
|
|
. _AD_XDONATION_IPN_LINK |
642
|
|
|
. "</td>\n" |
643
|
|
|
. " <td title =\"$desc\" style=\"text-align: center;\"> " |
644
|
|
|
. XOOPS_URL |
|
|
|
|
645
|
|
|
. '/modules/' |
646
|
|
|
. $xoopsModule->getVar('dirname') |
647
|
|
|
. "/ipnppd.php \n" |
648
|
|
|
. ' <br><a href="' |
649
|
|
|
. XOOPS_URL |
650
|
|
|
. '/modules/' |
651
|
|
|
. $xoopsModule->getVar('dirname') |
652
|
|
|
. '/ipnppd.php?dbg=1" target="_blank"><span style="font-weight: bold; font-style: italic;"><img src="../assets/images/admin/info.png" style="height: 16px; width: 16px;" alt=""> ' |
653
|
|
|
. _AD_XDONATION_TEST_IPN |
654
|
|
|
. "</span></a>\n" |
655
|
|
|
. " </td>\n" |
656
|
|
|
. "</tr>\n"; |
657
|
|
|
echo "</table><br>\n"; |
658
|
|
|
echo "</td></tr>\n"; |
659
|
|
|
echo '<tr><td style="text-align: center; width: 100%;"><input type="submit" value="' . _AD_XDONATION_SUBMIT . "\">\n"; |
660
|
|
|
echo '</td></tr></table><br><br>'; |
661
|
|
|
|
662
|
|
|
//Goal Preferences |
663
|
|
|
//=============================== |
664
|
|
|
$adminObject->displayNavigation('donations.php?op=Config'); |
665
|
|
|
echo "<table style=\"border-width: 1px; width: 90%; text-align: center;\">\n" . " <tr>\n"; |
666
|
|
|
echo " <td style=\"text-align: center; font-weight: bold;\" class=\"title\">\n" . ' <h3>' . _AD_XDONATION_GOAL_PREFERENCES . "</h3>\n"; |
667
|
|
|
echo " <table style=\"border-width: 1px; text-align: center;\">\n" . " <tr><td style=\"text-align: center;\">\n"; |
668
|
|
|
echo " <table style=\"border-width: 1px; text-align: center;\">\n"; |
669
|
|
|
$utility::showDropBox('use_goal', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_GOAL_TYPE . '.</span>'); |
670
|
|
|
echo " </table>\n"; |
671
|
|
|
|
672
|
|
|
$query_Recordset1 = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'week_goal' AND subtype<>'Default'"; |
673
|
|
|
$Recordset1 = $xoopsDB->query($query_Recordset1); |
674
|
|
|
$row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
675
|
|
|
$totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
676
|
|
|
$desc = htmlentities($row_Recordset1['text'], ENT_QUOTES | ENT_HTML5); |
677
|
|
|
|
678
|
|
|
echo " <table style=\"border-width: 1px; width: 100px; text-align: center;\">\n" . ' <tr><td style="text-align: center; width: 100%; font-weight: bold;" colspan="5">' . _AD_XDONATION_GOAL_HEBDO . "<br></td></tr>\n"; |
679
|
|
|
$row1 = " <tr>\n" . ' <td style="text-align: center; font-weight: bold;">' . _AD_XDONATION_WEEK . "</td>\n"; |
680
|
|
|
$row2 = " <tr>\n" . ' <td style="text-align: center; font-weight: bold;">' . _AD_XDONATION_GOAL . "</td>\n"; |
681
|
|
|
//------------------------------------------------------------- |
682
|
|
|
$shortMonth = explode('|', _AD_XDONATION_SHORT_MONTH); |
683
|
|
|
$ordinaux = explode('|', _AD_XDONATION_NUMBER_ORDINAUX); |
684
|
|
|
//------------------------------------------------------------- |
685
|
|
|
$h = 0; |
686
|
|
|
do { |
687
|
|
|
$ord = $ordinaux[$h++]; |
688
|
|
|
$row1 .= " <td title=\"{$desc}\" style=\"text-align: center;\">{$ord}</td>\n"; |
689
|
|
|
$row2 .= " <td title=\"{$desc}\" style=\"text-align: center;\"><input size=\"4\" name=\"var_week_goal-$row_Recordset1[subtype]\" type=\"text\" value=\"$row_Recordset1[value]\" onChange=\"return validInt(this,'$row_Recordset1[subtype] " |
690
|
|
|
. _AD_XDONATION_GOAL_DONATION |
691
|
|
|
. "',1,'" |
692
|
|
|
. _AD_XDONATION_ALERTE_INPUT_NUMBER |
693
|
|
|
. "');\"></td>\n"; |
694
|
|
|
} while (false !== ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))); |
695
|
|
|
$row1 .= " </tr>\n"; |
696
|
|
|
$row2 .= " </tr>\n"; |
697
|
|
|
echo "{$row1} {$row2}"; |
698
|
|
|
|
699
|
|
|
echo "</table>\n"; |
700
|
|
|
|
701
|
|
|
$query_Recordset1 = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'month_goal' AND subtype<>'Default'"; |
702
|
|
|
$Recordset1 = $xoopsDB->query($query_Recordset1); |
703
|
|
|
$row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
704
|
|
|
$totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
705
|
|
|
$desc = htmlentities($row_Recordset1['text'], ENT_QUOTES | ENT_HTML5); |
706
|
|
|
|
707
|
|
|
$h = 0; |
708
|
|
|
echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
709
|
|
|
echo ' <tr><td style="text-align: center; width: 100%; font-weight: bold;" colspan="13">' . _AD_XDONATION_GOAL_MENSUEL . "</td></tr><br>\n"; |
710
|
|
|
$row1 = " <tr>\n" . ' <td style="text-align: center; font-weight: bold;">' . _AD_XDONATION_MONTH . "</td>\n"; |
711
|
|
|
$row2 = " <tr>\n" . ' <td style="text-align: center; font-weight: bold;">' . _AD_XDONATION_GOAL . "</td>\n"; |
712
|
|
|
do { |
713
|
|
|
$month = $shortMonth[$h++]; |
714
|
|
|
$row1 .= " <td title=\"{$desc}\" style=\"text-align: center;\">{$month}</td>\n"; |
715
|
|
|
$row2 .= " <td title=\"{$desc}\" style=\"text-align: center;\"><input size=\"4\" name=\"var_month_goal-$row_Recordset1[subtype]\" type=\"text\" value=\"$row_Recordset1[value]\" onChange=\"return validInt(this,'$row_Recordset1[subtype] " |
716
|
|
|
. _AD_XDONATION_GOAL_DONATION |
717
|
|
|
. "',1,'" |
718
|
|
|
. _AD_XDONATION_ALERTE_INPUT_NUMBER |
719
|
|
|
. "');\"></td>\n"; |
720
|
|
|
} while (false !== ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))); |
721
|
|
|
$row1 .= " </tr>\n"; |
722
|
|
|
$row2 .= " </tr>\n"; |
723
|
|
|
echo "{$row1}{$row2}"; |
724
|
|
|
|
725
|
|
|
echo "</table>\n"; |
726
|
|
|
echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
727
|
|
|
$utility::showTextBox('swing_day', '<span style=\'font-weight: bold;\'>' . _AD_XDONATION_SWING_DAY . '</span>', '175', '4', "onChange='return validInt(this,\"" . _AD_XDONATION_SWING_DAY . '",1,"' . _AD_XDONATION_ALERTE_INPUT_NUMBER . "\");'"); |
728
|
|
|
echo "</table>\n"; |
729
|
|
|
|
730
|
|
|
$query_Recordset1 = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'quarter_goal' AND subtype<>'Default'"; |
731
|
|
|
$Recordset1 = $xoopsDB->query($query_Recordset1); |
732
|
|
|
$row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
733
|
|
|
$totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
734
|
|
|
$desc = htmlentities($row_Recordset1['text'], ENT_QUOTES | ENT_HTML5); |
735
|
|
|
|
736
|
|
|
echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
737
|
|
|
echo ' <tr><td style="text-align: center; width: 100%; font-weight: bold;" colspan="5">' . _AD_XDONATION_QUARTER . "<br></td></tr>\n"; |
738
|
|
|
$row1 = ' <tr><td style="text-align: center; font-weight: bold;">' . _AD_XDONATION_QUARTER . "</td>\n"; |
739
|
|
|
$row2 = ' <tr><td style="text-align: center; font-weight: bold;">' . _AD_XDONATION_GOAL . "</td>\n"; |
740
|
|
|
$h = 0; |
741
|
|
|
do { |
742
|
|
|
$ord = $ordinaux[$h++]; |
743
|
|
|
$row1 .= " <td title='{$desc}' class='center;'>{$ord}</td>\n"; |
744
|
|
|
$row2 .= " <td title='{$desc}' class='center;'><input size=\"4\" name=\"var_quarter_goal-$row_Recordset1[subtype]\" type=\"text\" value=\"$row_Recordset1[value]\" onChange=\"return validInt(this,'$row_Recordset1[subtype] " |
745
|
|
|
. _AD_XDONATION_GOAL_DONATION |
746
|
|
|
. "',1,'" |
747
|
|
|
. _AD_XDONATION_ALERTE_INPUT_NUMBER |
748
|
|
|
. "');\"></td>\n"; |
749
|
|
|
} while (false !== ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))); |
750
|
|
|
$row1 .= " </tr>\n"; |
751
|
|
|
$row2 .= " </tr>\n"; |
752
|
|
|
echo "{$row1} {$row2}"; |
753
|
|
|
|
754
|
|
|
echo "</table><br>\n"; |
755
|
|
|
echo "</td></tr>\n"; |
756
|
|
|
echo '<tr><td style="text-align: center; width: 100%;"><input type="submit" value="' . _AD_XDONATION_SUBMIT . "\"></td></tr>\n"; |
757
|
|
|
echo "</table><br>\n"; |
758
|
|
|
echo "</td></tr></table>\n"; |
759
|
|
|
echo "</form>\n"; |
760
|
|
|
} |
761
|
|
|
|
762
|
|
|
/** |
763
|
|
|
* |
764
|
|
|
* Update Configuration Settings in the database |
765
|
|
|
*/ |
766
|
|
|
function updateConfig() |
767
|
|
|
{ |
768
|
|
|
global $tr_config, $modversion, $xoopsDB; |
769
|
|
|
|
770
|
|
|
echo '<br>' . _AD_XDONATION_ERR_SQL_FAILURE . "<br><br>\n"; |
771
|
|
|
|
772
|
|
|
$error = 1; |
773
|
|
|
$ilog = "<br>\n"; |
|
|
|
|
774
|
|
|
|
775
|
|
|
foreach ($_POST as $option => $value) { |
776
|
|
|
/// Look for form variables |
777
|
|
|
|
778
|
|
|
if (false !== strpos($option, 'var_')) { |
779
|
|
|
$varnm = str_replace('var_', '', $option); |
780
|
|
|
// Check for subtype field |
781
|
|
|
|
782
|
|
|
if (preg_match('/-(.*)/', $varnm, $subtype)) { |
783
|
|
|
echo "<br>subtype = $subtype[1] <br>\n"; |
784
|
|
|
$temp = $varnm; |
785
|
|
|
$varnm = preg_replace('/-.*/', '', $temp); |
786
|
|
|
// Is this is a text field? |
787
|
|
|
if (preg_match('/([^-]*)-txt/', $subtype[1], $subtype2)) { |
788
|
|
|
$textarea = addslashes($value); |
789
|
|
|
echo "$varnm $subtype2[1] text=> " . nl2br(htmlspecialchars($textarea, ENT_QUOTES | ENT_HTML5)) . "<br>\n"; |
790
|
|
|
$error &= $utility::updateDb($varnm, $subtype2[1], '0', $textarea); |
|
|
|
|
791
|
|
|
} else { |
792
|
|
|
echo "$varnm $subtype[1] => $value<br>\n"; |
793
|
|
|
$error &= $utility::updateDbShort($varnm, $subtype[1], $value); |
794
|
|
|
} |
795
|
|
|
} else { |
796
|
|
|
echo "$varnm => $value<br>\n"; |
797
|
|
|
$error &= $utility::updateDbShort($varnm, '', $value); |
798
|
|
|
} |
799
|
|
|
} |
800
|
|
|
} |
801
|
|
|
|
802
|
|
|
// If there were no errors |
803
|
|
|
if (0 == $error) { |
804
|
|
|
header('Location: donations.php?op=Config#AdminTop'); |
805
|
|
|
} |
806
|
|
|
} |
807
|
|
|
|
808
|
|
|
/** |
809
|
|
|
* |
810
|
|
|
* Reconcile the IPN Log |
811
|
|
|
*/ |
812
|
|
|
function reconcileIpn() |
813
|
|
|
{ |
814
|
|
|
global $tr_config, $modversion, $xoopsDB, $currencySign; |
815
|
|
|
$recdate = ''; |
816
|
|
|
$query_Recordset1 = 'SELECT `date` AS recdate FROM ' . $xoopsDB->prefix('donations_financial') . " WHERE name='PayPal IPN' ORDER BY date DESC LIMIT 1"; |
817
|
|
|
$Recordset1 = $xoopsDB->query($query_Recordset1); |
818
|
|
|
if ($Recordset1) { |
819
|
|
|
$row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
820
|
|
|
if ($row_Recordset1) { |
821
|
|
|
$recdate = "payment_date > '" . $row_Recordset1['recdate'] . "' AND"; |
822
|
|
|
} |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
$query_Recordset1 = 'SELECT `payment_date` AS curdate FROM ' . $xoopsDB->prefix('donations_transactions') . " WHERE payment_status='Completed' AND (txn_type='send_money' OR txn_type='web_accept')" . ' ORDER BY payment_date DESC LIMIT 1'; |
826
|
|
|
$Recordset1 = $xoopsDB->query($query_Recordset1); |
827
|
|
|
$row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
828
|
|
|
$curdate = $row_Recordset1['curdate']; |
829
|
|
|
$query_Recordset1 = 'SELECT SUM(mc_gross - mc_fee) AS ipn_total, COUNT(*) AS numrecs' . ' FROM ' . $xoopsDB->prefix('donations_transactions') . " WHERE ({$recdate} payment_date <= '{$curdate}')" . " AND payment_status = 'Completed' AND (txn_type='send_money' OR txn_type='web_accept')"; |
830
|
|
|
$Recordset1 = $xoopsDB->query($query_Recordset1); |
831
|
|
|
$row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
832
|
|
|
|
833
|
|
|
echo "<span style='text-align: center; font-weight: bold;' class='title'>" . _AD_XDONATION_UPDATE_REGISTER_IPN . '</span><br><br>'; |
834
|
|
|
if (0 == $row_Recordset1['numrecs']) { |
835
|
|
|
echo _AD_XDONATION_NO_NEW_IPNS; |
836
|
|
|
} else { |
837
|
|
|
$insert_set = 'INSERT INTO `' . $xoopsDB->prefix('donations_financial') . "` (`date`,`num`,`name`,`descr`,`amount`) VALUES ('{$curdate}','','PayPal IPN','Auto-Reconcile','{$row_Recordset1['ipn_total']}')"; |
838
|
|
|
|
839
|
|
|
if ($xoopsDB->query($insert_set)) { |
840
|
|
|
echo sprintf(_AD_XDONATION_RECORDS_INSERTED, $row_Recordset1['numrecs'], $currencySign, $row_Recordset1['ipn_total']); |
841
|
|
|
} else { |
842
|
|
|
echo sprintf(_AD_XDONATION_ERR_DB_INSERTION, $row_Recordset1['numrecs']); |
843
|
|
|
} |
844
|
|
|
} |
845
|
|
|
|
846
|
|
|
echo '<br><br><form action="donations.php?op=Treasury#AdminTop" method="post">'; |
847
|
|
|
echo '<input type="hidden" name="op" value="Treasury">' . '<input type="submit" value="' . _AD_XDONATION_RETURN . '">' . '</form>'; |
848
|
|
|
} |
849
|
|
|
|
850
|
|
|
/** |
851
|
|
|
* |
852
|
|
|
* Display the IPN Log |
853
|
|
|
* |
854
|
|
|
*/ |
855
|
|
|
function showLog() |
856
|
|
|
{ |
857
|
|
|
global $tr_config, $modversion, $xoopsDB, $currencySign; |
858
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
|
|
|
859
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
860
|
|
|
$adminObject->displayNavigation('donations.php?op=ShowLog'); |
861
|
|
|
|
862
|
|
|
$query_Recordset1 = 'SELECT id, log_date, payment_date, logentry FROM ' . $xoopsDB->prefix('donations_translog') . ' ORDER BY log_date DESC'; |
863
|
|
|
$transRecords = $xoopsDB->query($query_Recordset1); |
864
|
|
|
$numRows = $xoopsDB->getRowsNum($transRecords); |
865
|
|
|
$logForm = new \XoopsThemeForm(_AD_XDONATION_SHOW_LOG, 'logform', $_SERVER['PHP_SELF'], 'post', true); |
|
|
|
|
866
|
|
|
|
867
|
|
|
if ($numRows) { |
868
|
|
|
while (false !== (list($rId, $rLdate, $rPdate, $rLentry) = $xoopsDB->fetchRow($transRecords))) { |
869
|
|
|
$thisTray = 'logTray_' . $rId; |
870
|
|
|
${$thisTray} = new \XoopsFormElementTray($rId, '<br>'); |
|
|
|
|
871
|
|
|
${$thisTray}->addElement(new \XoopsFormLabel(_AD_XDONATION_LOG_DATE, $rLdate)); |
|
|
|
|
872
|
|
|
${$thisTray}->addElement(new \XoopsFormLabel(_AD_XDONATION_PMNT_DATE, $rPdate)); |
873
|
|
|
$rLentrySplit = ''; |
874
|
|
|
$rLentry = htmlspecialchars($rLentry, ENT_QUOTES | ENT_HTML5); |
875
|
|
|
$dispWidth = 110; |
876
|
|
|
do { |
877
|
|
|
// echo '[' . strlen($rLentry) . ']<br>'; |
878
|
|
|
$pos = strrpos($rLentry, ' ', $dispWidth - strlen($rLentry)); |
879
|
|
|
if (!$pos) { |
880
|
|
|
$pos = strrpos($rLentry, ',', $dispWidth - strlen($rLentry)); |
881
|
|
|
if (!$pos) { |
882
|
|
|
$rLentrySplit .= '<br>' . substr($rLentry, 0, $dispWidth); |
883
|
|
|
$rLentry = substr($rLentry, $dispWidth); |
884
|
|
|
} else { |
885
|
|
|
$rLentrySplit .= '<br>' . substr($rLentry, 0, $pos + 1); |
886
|
|
|
$rLentry = substr($rLentry, $pos); |
887
|
|
|
} |
888
|
|
|
} else { |
889
|
|
|
$rLentrySplit .= '<br>' . substr($rLentry, 0, $pos + 1); |
890
|
|
|
$rLentry = substr($rLentry, $pos); |
891
|
|
|
} |
892
|
|
|
} while (strlen($rLentry) > $dispWidth); |
893
|
|
|
${$thisTray}->addElement(new \XoopsFormLabel(_AD_XDONATION_LOG_ENTRY_TXT, $rLentrySplit . $rLentry)); |
894
|
|
|
|
895
|
|
|
// ${$thisTray}->addElement(new \XoopsFormLabel( _AD_XDONATION_LOGENTRY, $rLentry)); |
896
|
|
|
$logForm->addElement(${$thisTray}); |
897
|
|
|
} |
898
|
|
|
$buttonTray = new \XoopsFormElementTray(''); |
899
|
|
|
$cButton = new \XoopsFormButton('', 'op', _AD_XDONATION_CLEAR_LOG, 'submit'); |
|
|
|
|
900
|
|
|
$cButton->setExtra("onclick=\"this.form.elements.op.value='ClearLog'\"", true); |
901
|
|
|
$buttonTray->addElement($cButton); |
902
|
|
|
$logForm->addElement($buttonTray); |
903
|
|
|
} else { |
904
|
|
|
//FIXME: replace this with 'full width' cell |
905
|
|
|
$logForm->addElement(new \XoopsFormLabel('', _AD_XDONATION_LOG_EMPTY)); |
906
|
|
|
} |
907
|
|
|
$logForm->display(); |
908
|
|
|
} |
909
|
|
|
|
910
|
|
|
/** |
911
|
|
|
* |
912
|
|
|
* Clear the IPN log |
913
|
|
|
* @param int $ok =0 ask to verify, !=0 clear the log |
914
|
|
|
*/ |
915
|
|
|
function clearLog($ok = 0) |
916
|
|
|
{ |
917
|
|
|
global $xoopsDB; |
918
|
|
|
if ($ok > 0) { |
919
|
|
|
$sql = 'DELETE FROM ' . $xoopsDB->prefix('donations_translog'); |
920
|
|
|
$success = $xoopsDB->query($sql); |
921
|
|
|
$retMsg = $success ? _AD_XDONATION_LOG_CLEARED : _AD_XDONATION_LOG_NOT_CLEARED; |
922
|
|
|
echo '<form name="ipnlog" action="donations.php" method="get">'; |
923
|
|
|
echo "<table style=\"text-align: center; border-width: 0px; margin: 4px;\"><tr><td>{$retMsg}</td></tr>"; |
924
|
|
|
echo '<tr><td><input type="submit" value="' . _AD_XDONATION_CONTINUE . '"></td></tr></table>'; |
925
|
|
|
echo '</form>'; |
926
|
|
|
// redirect_header('./index.php', 2, $retMsg); |
927
|
|
|
// |
928
|
|
|
} else { |
929
|
|
|
xoops_confirm(['op' => 'ClearLog', 'ok' => 1], 'index.php', _AD_XDONATION_CLEAR_THIS_LOG, _DELETE); |
|
|
|
|
930
|
|
|
} |
931
|
|
|
} |
932
|
|
|
|
933
|
|
|
/** |
934
|
|
|
* |
935
|
|
|
* Process incoming operand |
936
|
|
|
* |
937
|
|
|
*/ |
938
|
|
|
|
939
|
|
|
$op = isset($_GET['op']) ? $_GET['op'] : 'Treasury'; |
940
|
|
|
$op = isset($_POST['op']) ? $_POST['op'] : $op; |
941
|
|
|
|
942
|
|
|
switch ($op) { |
943
|
|
|
case 'FinRegAdd': |
944
|
|
|
addFinancialReg(); |
945
|
|
|
break; |
946
|
|
|
|
947
|
|
|
case 'FinRegEdit': |
948
|
|
|
editFinancialReg(); |
949
|
|
|
break; |
950
|
|
|
|
951
|
|
|
case 'FinRegDel': |
952
|
|
|
deleteFinancialReg(); |
953
|
|
|
break; |
954
|
|
|
|
955
|
|
|
case 'Config': |
956
|
|
|
setConfig(); |
957
|
|
|
break; |
958
|
|
|
|
959
|
|
|
case 'updateConfig': |
960
|
|
|
updateConfig(); |
961
|
|
|
break; |
962
|
|
|
|
963
|
|
|
case 'IpnRec': |
964
|
|
|
reconcileIpn(); |
965
|
|
|
break; |
966
|
|
|
case 'ShowLog': |
967
|
|
|
showLog(); |
968
|
|
|
break; |
969
|
|
|
|
970
|
|
|
case 'ClearLog': |
971
|
|
|
$ok = \Xmf\Request::getInt('ok', 0, 'GET'); |
972
|
|
|
$ok = \Xmf\Request::getInt('ok', $ok, 'POST'); |
973
|
|
|
clearLog($ok); |
974
|
|
|
break; |
975
|
|
|
|
976
|
|
|
default: |
977
|
|
|
case 'Treasury': |
978
|
|
|
treasury(); |
979
|
|
|
break; |
980
|
|
|
} |
981
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
982
|
|
|
|