require("../config.php");
require("$basepath/includes/subs.php");
/*************************************
index.php
Merchant Main Screen
*************************************/
require("$basepath/merch/auth_merch.php");
do_header('M',"Merchant Members Area");
$query = "SELECT * FROM merch WHERE merch_id='$merch_id'";
$result = db_query($query,__LINE__ ,__FILE__);
$number = MYSQL_NUMROWS($result);
if($number == 0) {
do_error("No Such Merchant [$merch_id]");
}
$row = mysql_fetch_assoc($result);
extract($row);
$created = date('m/d/y h:ia', strtotime($created));
$last_login = date('m/d/y h:ia', strtotime($last_login));
print "Merchant $merch_id - Status = $merch_status[$status]
";
print "$login_cnt Logins, Last Login $last_login from $from_ip
";
print "Merchant Since $created
";
$period = get_period_start(date('Y-m-d'));
list($y,$m,$d) = explode("-", $period);
$period2 = date('Y-m-d', mktime(0,0,0,$m,$d+6,$y));
?>
| Quick Stats for the Week Of echo $period; ?> |
Raw Clicks | Raw Submits | Approvals | Denials | Cancels | Refunds | Earnings |
$query = "SELECT SUM(IF(type='C',1,0)) as A,SUM(IF(type='S',1,0)) as B,SUM(IF(type='A',1,0)) as C,SUM(IF(type='D',1,0)) as D,SUM(IF(type='X',1,0)) as E,SUM(IF(type='R',1,0)) as F FROM stats WHERE merch_id='$merch_id' and (DATE_FORMAT(timestamp, '%Y-%m-%d') BETWEEN '$period' AND '$period2')";
// print "$query
";
$result = db_query($query,__LINE__ ,__FILE__);
list($clicks,$submits,$approves,$denials,$cancels,$refunds) = mysql_fetch_row($result);
// calc earnings
$query = "SELECT amount, trans_type, ref_trans_id FROM trans WHERE (trans_type='S' || trans_type='R' || trans_type='D') and (DATE_FORMAT(trans_date, '%Y-%m-%d') BETWEEN '$period' AND '$period2') and merch_id='$merch_id'";
$result = db_query($query,__LINE__ ,__FILE__);
$number = MYSQL_NUMROWS($result);
$totpay = 0;
$proc_rate = $proc_rate/100;
$i = 0;
while ($i < $number) {
list($amount, $trans_type, $ref_trans_id) = mysql_fetch_row($result);
$amount = abs($amount);
$pay = $amount - ($amount * $proc_rate);
if($trans_type == 'D') {
$query = "SELECT trans_type FROM trans WHERE trans_id='$ref_trans_id'";
$result2 = db_query($query,__LINE__ ,__FILE__);
$ttyp2 = mysql_result($result2,0);
if(($ttyp2 <> 'S') && ($ttyp2 <> 'R')) {
$i++;
continue;
} else {
$amount = -$amount;
$pay = -$pay;
}
}
$totpay += $pay;
$i++;
}
$totpay = sprintf("%1.2f", $totpay);
print "| $clicks | $submits | $approves | $denials | $cancels | $refunds | $totpay |
";
print "
";
do_footer('M');
?>