function stats_report_advisor_use

7.x stats.module stats_report_advisor_use($bool_only_return_total_number = FALSE)
6.x stats.module stats_report_advisor_use($bool_only_return_total_number = FALSE)
4.x stats.module stats_report_advisor_use()
5.x stats.module stats_report_advisor_use()

This report shows which advisors are using FlightPath most often.

Return value

unknown

File

modules/stats/stats.module, line 717
This module displays statistics and reports for FlightPath

Code

function stats_report_advisor_use() {
  $rtn = "";

  $start_date = trim(addslashes($_REQUEST ["start_date"]));
  $end_date = trim(addslashes($_REQUEST ["end_date"]));

  $rtn .= stats_draw_date_range_form("stats/advisor-use", $start_date, $end_date);

  if ($start_date == "" || $end_date == "") {
    return $rtn;
  }

  $start_date .= " 00:00:00"; // make it start at midnight of the startDate.
  $end_date .= " 23:59:59"; // make it go through to midnight of the endDate.

  $start_ts = strtotime($start_date);
  $end_ts = strtotime($end_date);

  // Now, what we're doing here is we want the names of the advisors,
  // and how many advisings they actually completed for each,
  // as well as which college or department they belong to.  They need
  // to be sorted by college/department.
  $f_array = array();
  $s_array = array();

  $result = db_query("SELECT * FROM watchdog a, faculty b, users c
            WHERE 
              a.timestamp > '?' AND a.timestamp < '?'
            AND
              (a.type = 'save_adv_active' OR a.type = 'save_adv_active_whatif')
            AND a.cwid = b.cwid
            AND a.cwid = c.cwid
            AND c.is_faculty = 1
            ORDER BY b.department ", $start_ts, $end_ts);

  while ($cur = db_fetch_array($result)) {
    $faculty_id = trim($cur ["cwid"]);

    $f_array [$faculty_id] = $f_array [$faculty_id] * 1; // make it a number.
    $f_array [$faculty_id];

    ++$s_array [$faculty_id]["dept_name"] = ucwords(strtolower(trim($cur ["department"])));
    $s_array [$faculty_id]["college_name"] = ucwords(strtolower(trim($cur ["college"])));
    $s_array [$faculty_id]["name"] = ucwords(strtolower(trim($cur ["f_name"]) . " " . trim($cur ["l_name"])));



  }



  // Sort based on who has advised the most...
  //arsort($f_array);

  $start_date = trim(addslashes($_REQUEST ["start_date"]));
  $end_date = trim(addslashes($_REQUEST ["end_date"]));

  // Now, output the results...
  $rtn .= "
      <table border='1' width='650'>
        <tr>
          <th>" . t("Name") . "</th>
          <th>" . t("Dept") . "</th>
          <th>#</th>
      </tr>";
  foreach ($f_array as $faculty_id => $value) 
   {
    $name = $s_array [$faculty_id]["name"];
    $college_name = $s_array [$faculty_id]["college_name"];
    $dept_name = $s_array [$faculty_id]["dept_name"];

    $rtn .= "<tr>
       <td valign='top'>$name</td>
       <td valign='top'>$dept_name</td>
       <td valign='top' align='center'>$value</td>
      </tr>
      
      ";
  }
  $rtn .= "</table>";



  return $rtn;
}