<commit_before><?php // $Id$

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');
define('ORDER_VOID',    'void');

/**
 * authorize_print_orders
 *
 */
function authorize_print_orders($courseid, $userid)
{
    global $CFG, $USER, $SITE;
    global $strs, $authstrs;
    require_once($CFG->libdir.'/tablelib.php');

    $perpage = 10;
    $status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
    $searchtype = optional_param('searchtype', 'id', PARAM_ALPHA);
    $idortransid = optional_param('idortransid', '0', PARAM_INT);

    if (! has_capability('enrol/authorize:managepayments', get_context_instance(CONTEXT_COURSE, $courseid))) {
        $userid = $USER->id;
    }

    $baseurl = $CFG->wwwroot."/enrol/authorize/index.php?user=$userid";
    $statusmenu = array(AN_STATUS_NONE => $strs->all,
                        AN_STATUS_AUTH | AN_STATUS_UNDERREVIEW | AN_STATUS_APPROVEDREVIEW => $authstrs->allpendingorders,
                        AN_STATUS_AUTH => $authstrs->authorizedpendingcapture,
                        AN_STATUS_AUTHCAPTURE => $authstrs->authcaptured,
                        AN_STATUS_CREDIT => $authstrs->refunded,
                        AN_STATUS_VOID => $authstrs->cancelled,
                        AN_STATUS_EXPIRE => $authstrs->expired,
                        AN_STATUS_UNDERREVIEW => $authstrs->underreview,
                        AN_STATUS_APPROVEDREVIEW => $authstrs->approvedreview,
                        AN_STATUS_REVIEWFAILED => $authstrs->reviewfailed,
                        AN_STATUS_TEST => $authstrs->tested
    );

    $sql = "SELECT c.id, c.fullname FROM {$CFG->prefix}course c INNER JOIN {$CFG->prefix}enrol_authorize e ON c.id = e.courseid ";
    if ($CFG->enrol == 'authorize') { // default enrolment plugin
        $sql .= "WHERE (c.enrol IS NULL) OR (c.enrol='') OR (c.enrol = 'authorize') ";
    }
    else {
        $sql .= "WHERE (c.enrol = 'authorize') ";
    }
    $sql .= "ORDER BY c.sortorder, c.fullname";
    if ($popupcrs = get_records_sql_menu($sql)) {
        $popupcrs[$SITE->id] = $SITE->fullname;
        echo "<table border='0' width='100%' cellspacing=0 cellpadding=3 class='generaltable generalbox'>";
        echo "<tr>";
        echo "<td width='5%'>$strs->status: </td><td width='10%'>";popup_form($baseurl.'&amp;course='.$courseid.'&amp;status=',$statusmenu,'statusmenu',$status,'','','',false);echo"</td>\n";
        echo "<td width='5%'>$strs->course: </td><td width='10%'>";popup_form($baseurl.'&amp;status='.$status.'&amp;course=',$popupcrs,'coursesmenu',$courseid,'','','',false);echo"</td>\n";
        if (has_capability('enrol/authorize:uploadcsv', get_context_instance(CONTEXT_USER, $USER->id))) {
            echo "<form method='get' action='uploadcsv.php'>";
            echo "<td rowspan=2 align='center' valign='middle' width='50%'><input type='submit' value='".get_string('uploadcsv', 'enrol_authorize')."'></td>";
            echo "</form>";
        }
        else {
            echo "<td rowspan=2 width='100%'>&nbsp;</td>";
        }
        echo "</tr>\n";

        echo "<tr><td>$strs->search: </td>"; $searchmenu = array('id' => $authstrs->orderid, 'transid' => $authstrs->transid);
        echo "<form method='POST' action='index.php' autocomplete='off'>";
        echo "<td colspan=3>"; choose_from_menu($searchmenu, 'searchtype', $searchtype, '');
        echo " = <input type='text' size='14' name='idortransid' value='' /> ";
        echo "<input type='submit' value='$strs->search' /></td>";<commit_msg>Show site name at top when selecting courses.<commit_after><?php // $Id$

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');
define('ORDER_VOID',    'void');

/**
 * authorize_print_orders
 *
 */
function authorize_print_orders($courseid, $userid)
{
    global $CFG, $USER, $SITE;
    global $strs, $authstrs;
    require_once($CFG->libdir.'/tablelib.php');

    $perpage = 10;
    $status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
    $searchtype = optional_param('searchtype', 'id', PARAM_ALPHA);
    $idortransid = optional_param('idortransid', '0', PARAM_INT);

    if (! has_capability('enrol/authorize:managepayments', get_context_instance(CONTEXT_COURSE, $courseid))) {
        $userid = $USER->id;
    }

    $baseurl = $CFG->wwwroot."/enrol/authorize/index.php?user=$userid";
    $statusmenu = array(AN_STATUS_NONE => $strs->all,
                        AN_STATUS_AUTH | AN_STATUS_UNDERREVIEW | AN_STATUS_APPROVEDREVIEW => $authstrs->allpendingorders,
                        AN_STATUS_AUTH => $authstrs->authorizedpendingcapture,
                        AN_STATUS_AUTHCAPTURE => $authstrs->authcaptured,
                        AN_STATUS_CREDIT => $authstrs->refunded,
                        AN_STATUS_VOID => $authstrs->cancelled,
                        AN_STATUS_EXPIRE => $authstrs->expired,
                        AN_STATUS_UNDERREVIEW => $authstrs->underreview,
                        AN_STATUS_APPROVEDREVIEW => $authstrs->approvedreview,
                        AN_STATUS_REVIEWFAILED => $authstrs->reviewfailed,
                        AN_STATUS_TEST => $authstrs->tested
    );

    $sql = "SELECT c.id, c.fullname FROM {$CFG->prefix}course c INNER JOIN {$CFG->prefix}enrol_authorize e ON c.id = e.courseid ";
    if ($CFG->enrol == 'authorize') { // default enrolment plugin
        $sql .= "WHERE (c.enrol IS NULL) OR (c.enrol='') OR (c.enrol = 'authorize') ";
    }
    else {
        $sql .= "WHERE (c.enrol = 'authorize') ";
    }
    $sql .= "ORDER BY c.sortorder, c.fullname";
    if ($popupcrs = get_records_sql_menu($sql)) {
        $popupcrs = array($SITE->id => $SITE->fullname) + $popupcrs;
        echo "<table border='0' width='100%' cellspacing=0 cellpadding=3 class='generaltable generalbox'>";
        echo "<tr>";
        echo "<td width='5%'>$strs->status: </td><td width='10%'>";popup_form($baseurl.'&amp;course='.$courseid.'&amp;status=',$statusmenu,'statusmenu',$status,'','','',false);echo"</td>\n";
        echo "<td width='5%'>$strs->course: </td><td width='10%'>";popup_form($baseurl.'&amp;status='.$status.'&amp;course=',$popupcrs,'coursesmenu',$courseid,'','','',false);echo"</td>\n";
        if (has_capability('enrol/authorize:uploadcsv', get_context_instance(CONTEXT_USER, $USER->id))) {
            echo "<form method='get' action='uploadcsv.php'>";
            echo "<td rowspan=2 align='center' valign='middle' width='50%'><input type='submit' value='".get_string('uploadcsv', 'enrol_authorize')."'></td>";
            echo "</form>";
        }
        else {
            echo "<td rowspan=2 width='100%'>&nbsp;</td>";
        }
        echo "</tr>\n";

        echo "<tr><td>$strs->search: </td>"; $searchmenu = array('id' => $authstrs->orderid, 'transid' => $authstrs->transid);
        echo "<form method='POST' action='index.php' autocomplete='off'>";
        echo "<td colspan=3>"; choose_from_menu($searchmenu, 'searchtype', $searchtype, '');
        echo " = <input type='text' size='14' name='idortransid' value='' /> ";
        echo "<input type='submit' value='$strs->search' /></td>";
{'fraction_non_alphanumeric': 0.18565906970545115, 'fraction_numerical': 0.006664001066240171, 'mean_word_length': 3.2563811684628474, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 134, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2201293', 'n_tokens_mistral': 2535, 'n_tokens_neox': 2450, 'n_words': 410}