-
Notifications
You must be signed in to change notification settings - Fork 6
/
paylog.php
101 lines (98 loc) · 5.04 KB
/
paylog.php
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
<?php
// mail ready
// addnews ready
// translator ready
require_once("common.php");
require_once("lib/http.php");
translator::tlschema("paylog");
check_su_access(SU_EDIT_PAYLOG);
/*
+-----------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------------+------+-----+---------+----------------+
| payid | int(11) | | PRI | NULL | auto_increment |
| info | text | | | | |
| response | text | | | | |
| txnid | varchar(32) | | MUL | | |
| amount | float(9,2) | | | 0.00 | |
| name | varchar(50) | | | | |
| acctid | int(11) unsigned | | | 0 | |
| processed | tinyint(4) unsigned | | | 0 | |
| filed | tinyint(4) unsigned | | | 0 | |
| txfee | float(9,2) | | | 0.00 | |
+-----------+---------------------+------+-----+---------+----------------+
*/
page_header("Payment Log");
require_once("lib/superusernav.php");
superusernav();
$op = http::httpget('op');
if ($op==""){
$sql = "SELECT info,txnid FROM ".db_prefix("paylog")." WHERE processdate='0000-00-00'";
$result = db_query($sql);
while ($row = db_fetch_assoc($result)){
$info = unserialize($row['info']);
$sql = "UPDATE ".db_prefix('paylog')." SET processdate='".date("Y-m-d H:i:s",strtotime($info['payment_date']))."' WHERE txnid='".addslashes($row['txnid'])."'";
db_query($sql);
}
$sql = "SELECT substring(processdate,1,7) AS month, sum(amount)-sum(txfee) AS profit FROM ".db_prefix('paylog')." GROUP BY month DESC";
$result = db_query($sql);
output::addnav("Months");
while ($row = db_fetch_assoc($result)){
output::addnav(array("%s %s %s", date("M Y",strtotime($row['month']."-01")), settings::getsetting("paypalcurrency", "USD"), $row['profit']),"paylog.php?month={$row['month']}");
}
$month = http::httpget('month');
if ($month=="") $month = date("Y-m");
$startdate = $month."-01 00:00:00";
$enddate = date("Y-m-d H:i:s",strtotime("+1 month",strtotime($startdate)));
$sql = "SELECT " . db_prefix("paylog") . ".*," . db_prefix("accounts") . ".name," . db_prefix("accounts") . ".donation," . db_prefix("accounts") . ".donationspent FROM " . db_prefix("paylog") . " LEFT JOIN " . db_prefix("accounts") . " ON " . db_prefix("paylog") . ".acctid = " . db_prefix("accounts") . ".acctid WHERE processdate>='$startdate' AND processdate < '$enddate' ORDER BY payid DESC";
$result = db_query($sql);
rawoutput("<table border='0' cellpadding='2' cellspacing='1' bgcolor='#999999'>");
$type = translator::translate_inline("Type");
$gross = translator::translate_inline("Gross");
$fee = translator::translate_inline("Fee");
$net = translator::translate_inline("Net");
$processed = translator::translate_inline("Processed");
$id = translator::translate_inline("Transaction ID");
$who = translator::translate_inline("Who");
rawoutput("<tr class='trhead'><td>Date</td><td>$id</td><td>$type</td><td>$gross</td><td>$fee</td><td>$net</td><td>$processed</td><td>$who</td></tr>");
$number=db_num_rows($result);
for ($i=0;$i<$number;$i++){
$row = db_fetch_assoc($result);
$info = unserialize($row['info']);
rawoutput("<tr class='".($i%2?"trlight":"trdark")."'><td nowrap>");
output_notl(date("m/d H:i",strtotime($info['payment_date'])));
rawoutput("</td><td>");
output_notl("%s",$row['txnid']);
rawoutput("</td><td>");
output_notl("%s", $info['txn_type']);
rawoutput("</td><td nowrap>");
output_notl("%.2f %s", $info['mc_gross'], $info['mc_currency']);
rawoutput("</td><td>");
output_notl("%s", $info['mc_fee']);
rawoutput("</td><td>");
output_notl("%.2f", (float)$info['mc_gross'] - (float)$info['mc_fee']);
rawoutput("</td><td>");
output_notl("%s", translator::translate_inline($row['processed']?"`@Yes`0":"`\$No`0"));
rawoutput("</td><td nowrap>");
if ($row['name']>"") {
rawoutput("<a href='user.php?op=edit&userid={$row['acctid']}'>");
output_notl("`&%s`0 (%d/%d)", $row['name'], $row['donationspent'],
$row['donation']);
rawoutput("</a>");
output::addnav("","user.php?op=edit&userid={$row['acctid']}");
}else{
$amt = round((float)$info['mc_gross'] * 100,0);
$memo = "";
if (isset($info['memo'])) {
$memo = $info['memo'];
}
$link = "donators.php?op=add1&name=".rawurlencode($memo)."&amt=$amt&txnid={$row['txnid']}";
rawoutput("-=( <a href='$link' title=\"".htmlentities($info['item_number'], ENT_COMPAT, settings::getsetting("charset", "ISO-8859-1"))."\" alt=\"".htmlentities($info['item_number'], ENT_COMPAT, settings::getsetting("charset", "ISO-8859-1"))."\">[".htmlentities($memo, ENT_COMPAT, settings::getsetting("charset", "ISO-8859-1"))."]</a> )=-");
output::addnav("",$link);
}
rawoutput("</td></tr>");
}
rawoutput("</table>");
output::addnav("Refresh","paylog.php");
}
page_footer();