function advise_display_history

6.x advise.history.inc advise_display_history()
4.x advise.history.inc advise_display_history()
5.x advise.history.inc advise_display_history()

Displays the history tab on screen.

File

modules/advise/advise.history.inc, line 11

Code

function advise_display_history() {
  global $current_student_id;

  $student_id = $current_student_id;
  $db = get_global_database_handler();

  $extra_style = $ast = "";
  $rtn = "";

  fp_add_css(fp_get_module_path("advise") . "/css/advise.css");
  fp_add_js(fp_get_module_path("advise") . "/js/advise.js");

  $rtn .= "<table class='fp-semester-table'>";


  // If coming here from a save, display info here.
  if (@$_REQUEST ["adv_id_array_serialized"] != "") {
    $click_links = "";
    $advising_session_id_array = unserialize($_REQUEST ["adv_id_array_serialized"]);

    foreach ($advising_session_id_array as $term_id => $value) {
      $term_id = (string) $term_id; // Make sure term_id is a standard string
      $aid = $advising_session_id_array [$term_id];
      if ($aid != "") 
       {
        $term_name = get_term_description($term_id);

        $turl = fp_url("advise/popup-display-summary", "advising_session_id=$aid");

        $click_links .= "<li>
                <a href='javascript: popupPrintWindow(\"" . $turl . "\");'>
                <img src='" . fp_theme_location() . "/images/popup.gif' border='0'>
                $term_name</a>";

      }
    }


    $rtn .= "
        <tr>
          <td colspan='2' width='100%'>
          
        <div class='hypo' 
        align='left' style='border: 1px solid black;
              margin: 10px 0px 10px 0px; padding: 10px; 
              font-size: 12pt; font-weight: bold;'>
        " . t("You have successfully advised") . " " . $db->get_student_name($student_id) . " ($student_id).
        <br><span style='color: blue;'>" . t("Click 
         to view a pop-up printable summary for:") . " 
         <ul style='margin-top: 5px; margin-bottom: 5px;'>
        $click_links
        </ul></span></div>
        
        </td>
        </tr>
    ";

  }






  $rtn .= "<tr><td width='50%' valign='top'  style='padding-right: 10px;'>
          ";

  ///////////////////////////////////////////////////
  //////////////////////////////////////////////////
  /////////  Advising History
  ///////////////////////////////////////////////////
  $rtn .= fp_render_curved_line(t("Advising History"));
  $render_left = array(); // creating a new render array.
  $render_left ["#id"] = "advise_history_left_column";
  $render_left ["#student_id"] = $student_id;

  //$rtn .= "<table border='0' cellspacing='0'>";
  $old_session_d_t = 0;
  $a_count = 0;
  $c = 0;
  $is_empty = true;
  $first_style = "color: maroon; font-weight:bold;";
  $advising_session_id_array = array();

  $on_mouse_over = "
            onmouseover='$(this).addClass(\"selection_highlight\");'
            onmouseout='$(this).removeClass(\"selection_highlight\");'
    ";

  $html = "";


  $res = db_query("SELECT * FROM advising_sessions
              WHERE student_id = '?'
              AND is_draft = '0'
              AND is_empty = '0'
              ORDER BY `posted` DESC, `term_id` DESC ", $student_id);
  while ($cur = db_fetch_array($res)) {
    extract($cur, 3, "db");

    $dt = date("n/j/y g:ia", $db_posted);
    $html = "";

    // Is this datetime within 5 seconds of the previous datetime?
    // If so, they were likely saved together, and are part
    // of the same advising session.  Otherwise, this is a NEW
    // advising session.  The if statement below is testing is this
    // a new advising session.
    $test_d_t = $db_posted;
    if ($old_session_d_t < ($test_d_t - 5) || $old_session_d_t > ($test_d_t + 5)) 
     {
      $p = "20px;";
      if ($a_count == 0) 
       {
        $p = "10px;";
      }

      $old_session_d_t = $test_d_t;
      $advised_by = "<div style='padding-top: $p'>
              <b>" . t("Advised by") . " " . fp_get_faculty_name($db_faculty_id, false) . "</b>
            </div>";
      /*
      $rtn .= "<tr><td colspan='2' class='tenpt'>
              $advised_by
            </td>
          </tr>";
      */

      $html .= "<div class='tenpt'>$advised_by</div>";




      $a_count++;

    }
    $is_empty = false;

    if ($a_count > 1) {
      $first_style = "";
    }

    $turl = fp_url("advise/popup-display-summary", "advising_session_id=$db_advising_session_id");

    $advising_session_id_array [] = $db_advising_session_id;

    $on_click = "popupPrintWindow(\"" . $turl . "\");";

    $term = get_term_description($db_term_id);

    /*
    $rtn .= "<tr $on_mouse_over style='cursor: pointer; $first_style'
          onClick='$on_click'>
          <td valign='top' class='tenpt'
            style='padding-left:20px;'
            width='165'>
            $term
          </td>
          <td valign='top' class='tenpt'>
            $dt
          </td>
        </tr>";
    */


    $html .= "<div $on_mouse_over style='cursor: pointer; $first_style' onClick='$on_click'>
                <div class='tenpt' style='display: inline-block; padding-left:20px; width:165px;'>$term</div>
                <div class='tenpt' style='display: inline-block;'>$dt</div>
              </div>";

    // If this is more than X number, let's hide the rest in a collapsible fieldset.
    if ($c < 5) {
      $render_left ["advising_history_$c"] = array(
        "value" => $html,
        "weight" => $c,
      );
    }
    else {
      // Let's place in a collapsible fieldset!
      if (!isset($render_left ["advising_history_fs"])) {
        $render_left ["advising_history_fs"] = array(
          "type" => "cfieldset",
          "label" => t("View complete advising history"),
          "start_closed" => TRUE,
          "elements" => array(),
          "weight" => $c,
        );
      }
      $render_left ["advising_history_fs"]["elements"][] = array("advising_history_$c" => array(
        "value" => $html,
      ));


    }


    $c++;
  }
  //$rtn .= "</table>";

  if ($is_empty == true) {
    //$rtn .= "<div class='tenpt'>No advising history available.</div>";

    $render_left ["markup_no_adv_history"] = array(
      "value" => t("No advising history available."),
    );
  }
  else {

    $print_all_url = fp_url("advise/popup-display-summary", "advising_session_id=" . join(",", $advising_session_id_array));

    $render_left ["markup_print_all"] = array(
      "value" => "<a href='javascript: popupPrintWindow(\"" . $print_all_url . "\");'  
          class='nounderline tenpt'><img src='" . fp_theme_location() . "/images/popup.gif' border='0'>view/print all</a>
          ",
      "weight" => -1,
    );
  }

  // Okay, we can render the left-hand side now.
  $rtn .= fp_render_content($render_left);




  //----------------------------------------------------------------------------------------
  //------------------------------ COMMENT HISTORY -----------------------------------------
  //----------------------------------------------------------------------------------------
  $rtn .= "</td><td width='50%' valign='top'>";
  $rtn .= fp_render_curved_line(t("Comment History"));
  //$rtn .= "<table border='0' cellspacing='0'>";

  // Prepare a render array for the right-hand side.
  $render_right = array();
  $render_right ["#id"] = "advise_history_right_column";
  $render_right ["#student_id"] = $student_id;

  $html = "";

  $old_term_id = "";
  $first_style = "first";
  $is_empty = true;
  $has_admin_category = false;
  $access_line = "";

  //if (!user_has_permission("view_faculty_comments")) { 
  //  $access_line = "and `access_type`='public' ";    
  //}

  $access_types = (user_has_permission("view_faculty_comments")) ? array("faculty", "public") : array("public");


  $turl = fp_url("comments/popup-display-all-comments");

  /*
  $rtn .= "<tr><td colspan='3' class='tenpt'>
        <!--STARTCOM--><div style='padding-top: 10px;'>
          <b>" . t("Advising Comments") . "</b>
          &nbsp; 
        <a href='javascript: popupPrintWindow(\"" . $turl . "\");'  
          class='nounderline'><img src='" . fp_theme_location() . "/images/popup.gif' border='0'>view/print all</a>
        </div><!--ENDCOM-->
        </td></tr>";

   */

  $html .= "<div colspan='3' class='tenpt'>
        <!--STARTCOM--><div style='padding-top: 10px;'>
          <b>" . t("Advising Comments") . "</b>
          &nbsp; 
        <a href='javascript: popupPrintWindow(\"" . $turl . "\");'  
          class='nounderline'><img src='" . fp_theme_location() . "/images/popup.gif' border='0'>view/print all</a>
        </div><!--ENDCOM-->
        </div>";


  // Use the function comments_get_comments instead of a direct query.

  $res = comments_get_comments($student_id, FALSE, $access_types);

  /*  
  
  $res = db_query("SELECT * FROM advising_comments
            WHERE student_id = '?' 
            AND delete_flag = '0'
            $access_line
            $cat_line
            order by `posted` desc ", $student_id);
            */
  //while ($cur = db_fetch_array($res))
  foreach ($res as $cur) 
   {
    extract($cur, 3, "db");
    $dt = format_date($db_posted);

    if ($first_style == "first") 
     {
      $first_style = "color: maroon; font-weight:bold;
          ";
    }


    $turl = fp_url("comments/popup-display-comment", "id=$db_id");

    $on_click = "popupPrintWindow(\"" . $turl . "\");";
    /*
    $rtn .= "<tr $on_mouse_over style='cursor:pointer; $first_style $extra_style'
          onClick='$on_click'>
          <td valign='top' width='165' class='tenpt'
            style='padding-left: 20px;'>
            " . fp_get_faculty_name($db_faculty_id, false) . "
          </td>
          <td valign='top' class='tenpt'>
          $dt$ast
          </td>
        </tr>";

     * 
     */
    $html .= "<div $on_mouse_over style='cursor:pointer; $first_style $extra_style'
          onClick='$on_click'>
          <div class='tenpt' style='padding-left: 20px; width:165px; display:inline-block;'>
            " . fp_get_faculty_name($db_faculty_id, false) . "
          </div>
          <div class='tenpt' style='display: inline-block;'>
              $dt$ast
          </div>
        </div>";

    $is_empty = false;
    $first_style = "";
  }

  if ($is_empty == true) {
    /*
    $rtn .= "<tr><td colspan='4' class='tenpt'>
            <div style='padding-left: 20px;'>
              " . t("No comment history available.") . "</div></td></tr>";
    */

    $render_right ["markup_no_comment_history"] = array(
      "value" => t("No comment history available."),
    );

  }

  $render_right ["comment_history"] = array(
    "value" => $html,
    "weight" => 0,
  );

  //$rtn .= "</table>";

  // Render our render array now...
  $rtn .= fp_render_content($render_right);




  $rtn .= "</td></tr>";




  $rtn .= "</table>";

  return $rtn;
}