Skip to content
Browse files

Order by order count. Courses that have many orders are emailed first.

  • Loading branch information...
1 parent abe51bb commit 2716e73e9e7e3c07cab2d3600ba8e848eac85560 ethem committed
Showing with 3 additions and 3 deletions.
  1. +3 −3 enrol/authorize/enrol.php
View
6 enrol/authorize/enrol.php
@@ -666,16 +666,16 @@ function cron()
$adminuser = get_admin();
email_to_user($adminuser, $adminuser, $subject, $message);
if (!empty($CFG->an_teachermanagepay) and !empty($CFG->an_emailexpiredteacher)) {
- $sql = "SELECT DISTINCT E.courseid, COUNT(E.courseid) AS count " .
+ $sql = "SELECT E.courseid, COUNT(E.courseid) AS cnt " .
"FROM {$CFG->prefix}enrol_authorize E " .
- "WHERE $select GROUP BY E.courseid";
+ "WHERE $select GROUP BY E.courseid ORDER BY cnt DESC";
$message = ''; $subject = '';
$lastcourse = 0; $lastcount = 0;
$courseidandcounts = get_records_sql($sql);
foreach($courseidandcounts as $courseidandcount) {
if ($lastcourse != $courseidandcount->courseid) {
$lastcourse = $courseidandcount->courseid;
- $lastcount = $courseidandcount->count;
+ $lastcount = $courseidandcount->cnt;
$a = new stdClass;
$a->pending = $lastcount;
$a->days = $CFG->an_emailexpired;

0 comments on commit 2716e73

Please sign in to comment.
Something went wrong with that request. Please try again.