Moved libraries to index.php

This commit is contained in:
ethem
2008-02-11 15:18:48 +00:00
parent 7614a54d59
commit 3abe79ff52
3 changed files with 11 additions and 18 deletions
+2 -8
View File
@@ -204,13 +204,8 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
$message = "Order must be credited within 120 days!";
return AN_RETURNZERO;
}
if (empty($extra)) {
$message = "Need extra fields to REFUND!";
return AN_RETURNZERO;
}
$total = floatval($extra->sum) + floatval($extra->amount);
if (($extra->amount == 0) || ($total > $order->amount)) {
$message = "Can be credited up to original amount.";
if (empty($extra->amount)) {
$message = "No valid amount!";
return AN_RETURNZERO;
}
$poststring .= '&x_type=CREDIT&x_trans_id=' . urlencode($order->transid);
@@ -336,7 +331,6 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
$extra->status = AN_STATUS_CREDIT;
$extra->transid = $transid;
$extra->settletime = authorize_getsettletime(time());
unset($extra->sum); // this is not used in refunds table.
if (! $extra->id = insert_record('enrol_authorize_refunds', $extra)) {
unset($extra->id);
email_to_admin("Error while trying to insert data " .
+3
View File
@@ -2,7 +2,10 @@
/// Load libraries
require_once('../../config.php');
require_once('const.php');
require_once('locallib.php');
require_once('localfuncs.php');
require_once('authorizenetlib.php');
/// Parameters
$orderid = optional_param('order', 0, PARAM_INT);
+6 -10
View File
@@ -4,9 +4,6 @@ if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.');
}
require_once('const.php');
require_once('authorizenetlib.php');
define('ORDER_CAPTURE', 'capture');
define('ORDER_DELETE', 'delete');
define('ORDER_REFUND', 'refund');
@@ -304,17 +301,14 @@ function authorize_print_order_details($orderno)
error(get_string('youcantdo', 'enrol_authorize', $a));
}
$extra = new stdClass;
$extra->sum = 0.0;
$extra->orderid = $orderno;
$refunded = 0.0;
$sql = "SELECT SUM(amount) AS refunded FROM {$CFG->prefix}enrol_authorize_refunds " .
"WHERE (orderid = '" . $orderno . "') AND (status = '" . AN_STATUS_CREDIT . "')";
if (($refund = get_record_sql($sql))) {
$extra->sum = floatval($refund->refunded);
if (($refundval = get_field_sql($sql))) {
$refunded = floatval($refundval);
}
$upto = format_float($order->amount - $extra->sum, 2);
$upto = format_float($order->amount - $refunded, 2);
if ($upto <= 0) {
error("Refunded to original amount.");
}
@@ -333,6 +327,8 @@ function authorize_print_order_details($orderno)
$strcanbecredit<br /><input type='submit' name='".ORDER_REFUND."' value='$authstrs->refund'>");
}
else {
$extra = new stdClass;
$extra->orderid = $orderno;
$extra->amount = $amount;
$message = '';
$success = authorize_action($order, $message, $extra, AN_ACTION_CREDIT);