0
{
$errs[] = "Please enter correct amount";
$amount = "";
}
if ($order_total)
{
if (!(is_numeric($order_total) && $order_total > 0))
$errs[] = "Please enter correct order total amount";
else
$add_sql = "transaction_amount='$order_total',";
}
switch ($status)
{
case "confirmed": $status="confirmed"; break;
case "pending": $status="pending"; break;
case "declined": $status="declined"; break;
default: $status="unknown"; break;
}
}
if (count($errs) == 0)
{
$sql = "UPDATE exchangerix_transactions SET ".$add_sql." amount='$amount', status='$status', reason='$reason', updated=NOW() WHERE transaction_id='$transaction_id' LIMIT 1";
$result = smart_mysql_query($sql);
if ($notification == 1)
{
$tsql = "SELECT * FROM exchangerix_transactions WHERE transaction_id='$transaction_id' LIMIT 1";
$tresult = smart_mysql_query($tsql);
$ttotal = mysqli_num_rows($tresult);
if ($ttotal > 0)
{
$trow = mysqli_fetch_array($tresult);
}
// send email ///////////////////////////////////////////////////////////////
// if (urow['newsletter'] == 1) //
$etemplate = GetEmailTemplate('manual_credit');
$esubject = $etemplate['email_subject'];
$emessage = $etemplate['email_message'];
$emessage = str_replace("{transaction_id}", $reference_id, $emessage);
$emessage = str_replace("{first_name}", GetUsername($trow['user_id'], $type = 3), $emessage);
$emessage = str_replace("{payment_type}", $trow['payment_type'], $emessage);
$emessage = str_replace("{amount}", DisplayMoney($amount), $emessage);
$emessage = str_replace("{status}", $status, $emessage);
$emessage = str_replace("{reason}", $reason, $emessage);//dev
$to_email = $urow['fname'].' '.$urow['lname'].' <'.$urow['email'].'>';
SendEmail($to_email, $esubject, $emessage, $noreply_mail = 1);
//////////////////////////////////////////////////////////////////////////////
}
if (isset($_GET['type']) && $_GET['type'] == "cashback") $go_to = "cashback.php?msg=updated"; else $go_to = "payments.php?msg=updated";
header("Location: ".$go_to);
exit();
}
else
{
$errormsg = "";
foreach ($errs as $errorname)
$errormsg .= $errorname."
";
}
}
if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int)$_GET['id']; } elseif (isset($_POST['tid']) && is_numeric($_POST['tid'])) { $id = (int)$_POST['tid']; }
if (isset($id) && is_integer($id))
{
$query = "SELECT t.*, DATE_FORMAT(t.created, '".DATE_FORMAT." %h:%i %p') AS payment_date, u.username, u.fname, u.lname FROM exchangerix_transactions t, exchangerix_users u WHERE t.user_id=u.user_id AND t.transaction_id='$id' LIMIT 1";
$result = smart_mysql_query($query);
$total = mysqli_num_rows($result);
}
$title = "Edit Payment";
require_once ("inc/header.inc.php");
?>