mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
No need anymore some database fields.
This commit is contained in:
parent
18ab5c16d2
commit
9e1c2ba45c
6 changed files with 47 additions and 26 deletions
|
@ -304,8 +304,6 @@ function authorizenet_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE
|
||||||
case AN_ACTION_PRIOR_AUTH_CAPTURE:
|
case AN_ACTION_PRIOR_AUTH_CAPTURE:
|
||||||
{
|
{
|
||||||
$order->transid = strval($response[6]); // TransactionID
|
$order->transid = strval($response[6]); // TransactionID
|
||||||
$order->avscode = strval($response[5]); // Address Verification System code
|
|
||||||
$order->authcode = strval($response[4]); // Authorization or Approval code
|
|
||||||
if ($action == AN_ACTION_AUTH_ONLY) {
|
if ($action == AN_ACTION_AUTH_ONLY) {
|
||||||
$order->status = AN_STATUS_AUTH;
|
$order->status = AN_STATUS_AUTH;
|
||||||
// dont't update settletime
|
// dont't update settletime
|
||||||
|
|
|
@ -77,6 +77,13 @@ function authorize_upgrade($oldversion=0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oldversion < 2005122800) { // no need anymore some fields.
|
||||||
|
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP ccexp", false);
|
||||||
|
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP cvv", false);
|
||||||
|
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP avscode", false);
|
||||||
|
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,13 @@ function authorize_upgrade($oldversion=0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oldversion < 2005122800) { // no need anymore some fields.
|
||||||
|
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP ccexp", false);
|
||||||
|
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP cvv", false);
|
||||||
|
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP avscode", false);
|
||||||
|
execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,12 +185,9 @@ class enrolment_plugin extends enrolment_base
|
||||||
$timenow = time();
|
$timenow = time();
|
||||||
$order = new stdClass();
|
$order = new stdClass();
|
||||||
$order->cclastfour = substr($form->cc, -4);
|
$order->cclastfour = substr($form->cc, -4);
|
||||||
$order->ccexp = $exp_date;
|
|
||||||
$order->cvv = $form->cvv;
|
|
||||||
$order->ccname = $form->ccfirstname . " " . $form->cclastname;
|
$order->ccname = $form->ccfirstname . " " . $form->cclastname;
|
||||||
$order->courseid = $course->id;
|
$order->courseid = $course->id;
|
||||||
$order->userid = $USER->id;
|
$order->userid = $USER->id;
|
||||||
$order->avscode = 'P';
|
|
||||||
$order->status = AN_STATUS_NONE; // it will be changed...
|
$order->status = AN_STATUS_NONE; // it will be changed...
|
||||||
$order->settletime = 0; // cron changes this.
|
$order->settletime = 0; // cron changes this.
|
||||||
$order->timecreated = $timenow;
|
$order->timecreated = $timenow;
|
||||||
|
@ -619,8 +616,13 @@ class enrolment_plugin extends enrolment_base
|
||||||
|
|
||||||
// AUTO-CAPTURE: Transaction must be captured within 30 days. Otherwise it will expired.
|
// AUTO-CAPTURE: Transaction must be captured within 30 days. Otherwise it will expired.
|
||||||
$timediffcnf = $timenowsettle - (intval($CFG->an_review_day) * 3600 * 24);
|
$timediffcnf = $timenowsettle - (intval($CFG->an_review_day) * 3600 * 24);
|
||||||
$select = "status = '" .AN_STATUS_AUTH. "' AND timecreated < '$timediffcnf' AND timecreated > '$timediff30'";
|
$sql = "SELECT E.*, C.fullname, C.enrolperiod " .
|
||||||
if (!$orders = get_records('enrol_authorize', $select)) {
|
"FROM {$CFG->prefix}enrol_authorize E " .
|
||||||
|
"INNER JOIN {$CFG->prefix}course C ON C.id = E.courseid " .
|
||||||
|
"WHERE (status = '" .AN_STATUS_AUTH. "') " .
|
||||||
|
" AND (E.timecreated < '$timediffcnf') AND (E.timecreated > '$timediff30')";
|
||||||
|
|
||||||
|
if (!$orders = get_records_sql($sql)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,11 +649,9 @@ class enrolment_plugin extends enrolment_base
|
||||||
"ID=$order->id in enrol_authorize table.", $order);
|
"ID=$order->id in enrol_authorize table.", $order);
|
||||||
}
|
}
|
||||||
$timestart = $timeend = 0;
|
$timestart = $timeend = 0;
|
||||||
if ($course = get_record_sql("SELECT enrolperiod FROM {$CFG->prefix}course WHERE id='$order->courseid'")) {
|
if ($order->enrolperiod) {
|
||||||
if ($course->enrolperiod) {
|
$timestart = $timenow;
|
||||||
$timestart = $timenow;
|
$timeend = $order->settletime + $order->enrolperiod;
|
||||||
$timeend = $timestart + $course->enrolperiod;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'authorize')) {
|
if (enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'authorize')) {
|
||||||
$this->log .= "User($order->userid) has been enrolled to course($order->courseid).\n";
|
$this->log .= "User($order->userid) has been enrolled to course($order->courseid).\n";
|
||||||
|
|
|
@ -28,7 +28,7 @@ $strs = get_strings(array('user', 'status', 'action', 'delete', 'time',
|
||||||
$authstrs = get_strings(array('paymentmanagement', 'orderid', 'void', 'capture', 'refund',
|
$authstrs = get_strings(array('paymentmanagement', 'orderid', 'void', 'capture', 'refund',
|
||||||
'authorizedpendingcapture','capturedpendingsettle', 'capturedsettled',
|
'authorizedpendingcapture','capturedpendingsettle', 'capturedsettled',
|
||||||
'settled', 'refunded', 'cancelled', 'expired', 'tested',
|
'settled', 'refunded', 'cancelled', 'expired', 'tested',
|
||||||
'transid', 'settlementdate', 'notsettled', 'returns', 'noreturns', 'amount',
|
'transid', 'settlementdate', 'notsettled', 'amount',
|
||||||
'howmuch', 'captureyes', 'unenrolstudent'), 'enrol_authorize');
|
'howmuch', 'captureyes', 'unenrolstudent'), 'enrol_authorize');
|
||||||
|
|
||||||
print_header("$site->shortname: $authstr->paymentmanagement", "$site->fullname", "<a href=\"index.php\">$authstr->paymentmanagement</a>", "");
|
print_header("$site->shortname: $authstr->paymentmanagement", "$site->fullname", "<a href=\"index.php\">$authstr->paymentmanagement</a>", "");
|
||||||
|
@ -97,7 +97,7 @@ function authorize_orders()
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
$actionstatus = get_order_status_desc($record);
|
$actionstatus = get_order_status_desc($record);
|
||||||
$actions = ' ';
|
$actions = ' ';
|
||||||
foreach ($actionstatus->actions as $value) {
|
foreach ($actionstatus->actions as $value) {
|
||||||
$actions .= " <a href='index.php?$value=yes&order=$record->id'>{$authstrs->$value}</a> ";
|
$actions .= " <a href='index.php?$value=yes&order=$record->id'>{$authstrs->$value}</a> ";
|
||||||
}
|
}
|
||||||
$table->add_data(array(
|
$table->add_data(array(
|
||||||
|
@ -130,7 +130,7 @@ function authorize_order_details($orderno) {
|
||||||
$table->size = array('30%', '70%');
|
$table->size = array('30%', '70%');
|
||||||
$table->align = array('right', 'left');
|
$table->align = array('right', 'left');
|
||||||
|
|
||||||
$sql = "SELECT E.*, C.shortname " .
|
$sql = "SELECT E.*, C.shortname, C.enrolperiod " .
|
||||||
"FROM {$CFG->prefix}enrol_authorize E " .
|
"FROM {$CFG->prefix}enrol_authorize E " .
|
||||||
"INNER JOIN {$CFG->prefix}course C ON C.id = E.courseid " .
|
"INNER JOIN {$CFG->prefix}course C ON C.id = E.courseid " .
|
||||||
"WHERE E.id = '$orderno'";
|
"WHERE E.id = '$orderno'";
|
||||||
|
@ -176,15 +176,24 @@ function authorize_order_details($orderno) {
|
||||||
else {
|
else {
|
||||||
if (empty($CFG->an_test)) {
|
if (empty($CFG->an_test)) {
|
||||||
$timestart = $timeend = 0;
|
$timestart = $timeend = 0;
|
||||||
if ($course = get_record_sql("SELECT enrolperiod FROM {$CFG->prefix}course WHERE id='$order->courseid'")) {
|
if ($order->enrolperiod) {
|
||||||
if ($course->enrolperiod) {
|
$timestart = time(); // early start
|
||||||
$timestart = $order->settletime;
|
$timeend = $order->settletime + $order->enrolperiod; // lately end
|
||||||
$timeend = $timestart + $course->enrolperiod;
|
}
|
||||||
}
|
if (enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'authorize')) {
|
||||||
|
$user = get_record('user', 'id', $order->userid);
|
||||||
|
$teacher = get_teacher($order->courseid);
|
||||||
|
$a->coursename = $order->shortname;
|
||||||
|
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
|
||||||
|
email_to_user($user, $teacher,
|
||||||
|
get_string("enrolmentnew", '', $order->shortname),
|
||||||
|
get_string('welcometocoursetext', '', $a));
|
||||||
|
redirect("index.php?order=$order->id");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$table->data[] = array("<b><font color=red>$strs->error:</font></b>",
|
||||||
|
"Error while trying to enrol ".fullname($user)." in '$order->shortname'");
|
||||||
}
|
}
|
||||||
enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'authorize');
|
|
||||||
// To do: inform user. You will access to course on date $order->settletime
|
|
||||||
redirect("index.php?order=$order->id");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$table->data[] = array(get_string('testmode', 'enrol_authorize'), get_string('capturetestwarn', 'enrol_authorize'));
|
$table->data[] = array(get_string('testmode', 'enrol_authorize'), get_string('capturetestwarn', 'enrol_authorize'));
|
||||||
|
@ -348,7 +357,7 @@ function authorize_order_details($orderno) {
|
||||||
$table->data[] = array("<b>$strs->action</b>", $actions);
|
$table->data[] = array("<b>$strs->action</b>", $actions);
|
||||||
print_table($table);
|
print_table($table);
|
||||||
if ($settled) { // show refunds.
|
if ($settled) { // show refunds.
|
||||||
echo "<h4>$authstrs->returns</h4>\n";
|
echo "<h4>" . get_string('returns', 'enrol_authorize') . "</h4>\n";
|
||||||
$table2->size = array('15%', '15%', '20%', '35%', '15%');
|
$table2->size = array('15%', '15%', '20%', '35%', '15%');
|
||||||
$table2->align = array('right', 'right', 'right', 'left', 'right');
|
$table2->align = array('right', 'right', 'right', 'left', 'right');
|
||||||
$table2->head = array($authstrs->transid, $authstrs->amount, $strs->status, $authstrs->settlementdate, $strs->action);
|
$table2->head = array($authstrs->transid, $authstrs->amount, $strs->status, $authstrs->settlementdate, $strs->action);
|
||||||
|
@ -369,7 +378,7 @@ function authorize_order_details($orderno) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$table2->data[] = array($authstrs->noreturns);
|
$table2->data[] = array(get_string('noreturns', 'enrol_authorize'));
|
||||||
}
|
}
|
||||||
print_table($table2);
|
print_table($table2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?PHP // $Id$
|
<?PHP // $Id$
|
||||||
|
|
||||||
$module->version = 2005122200;
|
$module->version = 2005122800;
|
||||||
$module->requires = 2005072200;
|
$module->requires = 2005072200;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue