]> git.mjollnir.org Git - moodle.git/commitdiff
viewweek.php:
authorjungwirr <jungwirr>
Thu, 18 Sep 2003 21:23:41 +0000 (21:23 +0000)
committerjungwirr <jungwirr>
Thu, 18 Sep 2003 21:23:41 +0000 (21:23 +0000)
Added a report to view attendance rolls by week instead of all or one -

Updated view.php and viewall.php to reflect these options as well.

mod/attendance/lib.php
mod/attendance/view.php
mod/attendance/viewall.php
mod/attendance/viewweek.php [new file with mode: 0644]

index 5b1983de042b660c349de538c4d61cdc9f8efc6d..7379cff927d0d2ce9c7fdb2952e72dc22f7ea8c5 100755 (executable)
@@ -391,6 +391,105 @@ function attendance_get_records($table, $field1="", $value1="", $field2="", $val
     return get_records_sql("SELECT $fields FROM $CFG->prefix$table $select $sort $limit");
 }
 
+/**
+* Return all attendance records that are in the same section as the instance specified
+* 
+* This function uses course_modules, modules, and attendance tables together to determine
+* first what section the specified attendance instance in the course is in, then all the
+* attendance records that are in the same section, regardless of the format of the course
+*
+* @param       int     $instance       id of the attendance instance in course_modules
+* @param       int     $courseid       the id of the course for which we're getting records
+* @return      (object)recordset       associative array of records containing the attendance records we wanted 
+*/
+function get_attendance_for_section($instance, $courseid) {
+    global $CFG;
+    // first, get the section for the instance specified
+    $sql = "SELECT cm.section
+                           FROM {$CFG->prefix}course_modules cm,
+                                {$CFG->prefix}modules md, 
+                                {$CFG->prefix}attendance a 
+                           WHERE cm.course = '$courseid' AND 
+                                 cm.deleted = '0' AND
+                                 cm.instance = a.id AND 
+                                 md.name = 'attendance' AND 
+                                 md.id = cm.module AND
+                                 a.id = '$instance'";
+    $sectarray = get_record_sql($sql);
+//    echo "<pre>$sql \n</pre>";
+    $section = $sectarray->section;
+/*                                 
+select cm.section from 
+mdl_course_modules cm, mdl_modules md, mdl_attendance m
+where cm.course = '7' AND cm.deleted = '0' AND cm.instance = m.id
+AND md.name = 'attendance' AND md.id = cm.module AND m.id =  '119';
+*/
+    // then get all the attendance instances in that section
+    $sql = "SELECT a.*
+                           FROM {$CFG->prefix}course_modules cm, 
+                                {$CFG->prefix}modules md, 
+                                {$CFG->prefix}attendance a 
+                           WHERE cm.course = '$courseid' AND 
+                                 cm.deleted = '0' AND
+                                 cm.section = '$section' AND 
+                                 md.name = 'attendance' AND 
+                                 md.id = cm.module AND
+                                 a.id = cm.instance order by a.day ASC";
+//    echo "<pre>$sql \n</pre>";
+    return get_records_sql($sql);
+/*
+select m.* from mdl_course_modules cm, mdl_modules md, mdl_attendance m
+where cm.course = '7' AND cm.deleted = '0' AND cm.section = '85' 
+AND md.name = 'attendance' AND md.id = cm.module AND m.id = cm.instance;
+*/
+}
+
+/**
+* Return all attendance records that are in the same 7 day span as the instance specified
+* 
+* This function uses the course and attendance tables together to find all the attendance 
+* records that are for days within the same week span as the instance specified.  The week is
+* determined based NOT on calendar week, but instead on the week span as it occurs in a 
+* weekly formatted course - I find this by starting with the startdate of the course and 
+* then skipping ahead by weeks til I find the range that fits the instance, then I use that
+* range as min and max to query the attendance table for all the other records.  Note that this
+* function will work with non-weekly formatted courses, though the results won't easily 
+* correlate with the course view.  But it will work regardless.
+*
+* @param       int     $id     the id of the attendance record we're using as a basis for the query
+* @param       int     $courseid       the id of the course for which we're getting records
+* @return      (object)recordset       associative array of records containing the attendance records we wanted 
+*/
+function get_attendance_for_week($id, $courseid) {
+    global $CFG;
+  if (! $attendance = get_record("attendance", "id", $id)) {
+    error("Course module is incorrect");
+  }
+  if (! $course = get_record("course", "id", $courseid)) {
+    error("Course module is incorrect");
+  }
+  // the offset is for weeks that don't start on Monday
+  $day = $attendance->day;
+  // determine the week range for the select, based on the day
+  for ($maxday=$course->startdate;$day>$maxday;$maxday=$maxday+604800)
+   {;}$minday = $maxday-608400;
+  $sql = "SELECT * FROM {$CFG->prefix}attendance 
+          WHERE course = '$courseid' AND day<$maxday AND day>=$minday order by day ASC;";
+//  echo "<pre>$sql \n</pre>";
+  return get_records_sql($sql);
+}
+
+/**
+* Returns user records for all users who have DATA in a given attendance instance
+* 
+* This function is present only for the backup routines.  It won't return meaningful data
+* for an attendance roll because it only returns records for users who have been counted as 
+* tardy or absent in the rolls for a single attendance instance, since these are the only 
+* records I store in the database - for brevity's sake of course.
+*
+* @param       int     $attendanceid   the id of the attendance record we're looging for student data from
+* @return      (object)recordset       associative array of records containing the student records we wanted 
+*/
 function attendance_get_participants($attendanceid) {
 //Returns the users with data in one attendance
 //(users with records in attendance_roll, students)
index 67f8d3df2e4782f7faaee0ae7b588fe787a51606..8a94c7d24480e4779f0d6cbec816988f26ed04ba 100644 (file)
    // get the list of attendance records for all hours of the given day and 
    // put it in the array for use in the attendance table
        $strviewall = get_string("viewall", "attendance");
+       $strviewweek = get_string("viewweek", "attendance");
        echo "<table align=\"right\" width=\"50%\"".
          "border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
   echo "<tr><td align=\"right\"><a href=\"viewall.php?id=".$course->id."\">";
-  echo "$strviewall</a></td></tr></table><br \>";
+  echo "$strviewall</a></td></tr>";
+  echo "<tr><td align=\"right\"><a href=\"viewweek.php?scope=week&id=".$attendance->id."\">";
+  echo "$strviewweek</a></td></tr></table><br /> <br />";
+
   // this is the wrapper table
   echo "<table align=\"center\" width=\"80\" class=\"generalbox\"".
          "border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
index 48624b8923ea19888a4ae7f6692d04bf36291bdb..7f045524fe0dc747c2c596ae2ed6e38254235b4c 100644 (file)
@@ -56,27 +56,6 @@ if ($attendances) {
      print_footer($course); exit;
    }
 
-// print other links at top of page
-       $strviewone = get_string("viewone", "attendance");
-       $strviewtable = get_string("viewtable", "attendance");
-       $strviewmulti = get_string("viewmulti", "attendance");
-    if ($onepage) {  // one page for all tables
-      echo "<p align=\"right\"><a href=\"viewall.php?id=".$course->id."\">";
-      echo "$strviewmulti</a><br />";
-      echo "<a href=\"viewall.php?id=".$course->id."&onetable=1\">";
-      echo "$strviewtable</a></p>";
-    } else if ($onetable) { // one table for all
-      echo "<p align=\"right\"><a href=\"viewall.php?id=".$course->id."\">";
-      echo "$strviewmulti</a><br />";
-      echo "<a href=\"viewall.php?id=".$course->id."&onepage=1\">";
-      echo "$strviewone</a></p>";
-    } else { // multiple pages
-      echo "<p align=\"right\"><a href=\"viewall.php?id=".$course->id."&onepage=1\">";
-      echo "$strviewone</a><br />";
-      echo "<a href=\"viewall.php?id=".$course->id."&onetable=1\">";
-      echo "$strviewtable</a></p>";
-    }
-
 
 /// create an array of all the attendance objects for the entire course
    $numatt=0;
@@ -169,6 +148,35 @@ while (($multipage || $onepage) && (!$endonepage)) {
 //
 //
 
+// print other links at top of page
+       $strviewone = get_string("viewone", "attendance");
+       $strviewtable = get_string("viewtable", "attendance");
+       $strviewmulti = get_string("viewmulti", "attendance");
+       $strviewweek = get_string("viewweek", "attendance");    
+    if ($onepage) {  // one page for all tables
+      echo "<p align=\"right\"><a href=\"viewall.php?id=".$course->id."\">";
+      echo "$strviewmulti</a><br />";
+      echo "<a href=\"viewall.php?id=".$course->id."&onetable=1\">";
+      echo "$strviewtable</a><br />";
+      echo "<a href=\"viewweek.php?scope=week&id=".$atts[$minatt]->attendance->id."\">";
+      echo "$strviewweek</a></p>";
+    } else if ($onetable) { // one table for all
+      echo "<p align=\"right\"><a href=\"viewall.php?id=".$course->id."\">";
+      echo "$strviewmulti</a><br />";
+      echo "<a href=\"viewall.php?id=".$course->id."&onepage=1\">";
+      echo "$strviewone</a><br />";
+      echo "<a href=\"viewweek.php?scope=week&id=".$atts[$minatt]->attendance->id."\">";
+      echo "$strviewweek</a></p>";
+    } else { // multiple pages
+      echo "<p align=\"right\"><a href=\"viewall.php?id=".$course->id."&onepage=1\">";
+      echo "$strviewone</a><br />";
+      echo "<a href=\"viewall.php?id=".$course->id."&onetable=1\">";
+      echo "$strviewtable</a><br />";
+      echo "<a href=\"viewweek.php?scope=week&id=".$atts[$minatt]->attendance->id."\">";
+      echo "$strviewweek</a></p>";
+
+    }
+
   if (!$onepage) {
 
   attendance_print_pagenav(); 
diff --git a/mod/attendance/viewweek.php b/mod/attendance/viewweek.php
new file mode 100644 (file)
index 0000000..556ff26
--- /dev/null
@@ -0,0 +1,334 @@
+<?  // $Id$
+/// This page prints all instances of attendance in a given week
+
+    require_once("../../config.php");
+    require_once("lib.php" );
+/// @include_once("$CFG->dirroot/mod/attendance/lib.php"); 
+/// error_reporting(E_ALL);
+
+    optional_variable($id);    // Course Module ID, or
+    optional_variable($a);     // attendance ID
+
+/// populate the appropriate objects
+    if ($id) {
+        if (! $attendance = get_record("attendance", "id", $id)) {
+            error("Course module is incorrect");
+        }
+        if (! $course = get_record("course", "id", $attendance->course)) {
+            error("Course is misconfigured");
+        }
+        if (! $cm = get_coursemodule_from_instance("attendance", $attendance->id, $course->id)) {
+            error("Course Module ID was incorrect");
+        }
+        if ($scope == "section") {
+          if (! $attendances = get_attendance_for_section($attendance->id, $course->id)) {
+            error("Course module is incorrect");
+          }
+        } else {
+          if (! $attendances = get_attendance_for_week($attendance->id, $course->id)) {
+            error("Course module is incorrect");
+          }            
+        }
+    }
+//    echo "<pre>\n";
+//    foreach ($attendances as $attendance) {
+//    var_dump($attendances);
+//    }
+//    echo "\n</pre>";
+//    print_footer();
+//    exit;
+
+    require_login($course->id);
+
+    add_to_log($course->id, "attendance", "viewweek", "viewweek.php?scope=".$scope."&id=$course->id");
+
+/// Print the page header
+    if ($course->category) {
+        $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
+    }
+
+    $strattendances = get_string("modulenameplural", "attendance");
+    $strattendance  = get_string("modulename", "attendance");
+    $strweekattendance  = get_string("weekmodulename", "attendance");
+    print_header("$course->shortname: $strallattendance", "$course->fullname",
+                 "$navigation <A HREF=index.php?id=$course->id>$strattendances</A> -> $strweekattendance", 
+                  "", "", true, "&nbsp;", 
+                  navmenu($course, $cm));
+/// Print the main part of the page
+if ($attendances) {
+   if ( !(isteacher($course->id) || isstudent($course->id)) )  {
+     notice(get_string("noviews", "attendance"));
+     print_footer($course); exit;
+   }
+
+// print other links at top of page
+       $strviewsection = get_string("viewsection", "attendance");
+       $strviewweek = get_string("viewweek", "attendance");
+       $strviewall = get_string("viewall", "attendance");
+       $strviewone = get_string("viewone", "attendance");
+       $strviewtable = get_string("viewtable", "attendance");
+       $strviewmulti = get_string("viewmulti", "attendance");
+
+
+    echo "<p align=\"right\"><a href=\"viewall.php?id=".$course->id."\">";
+    echo "$strviewall</a><br />";
+    if ($onepage) {  // one page for all tables
+      echo "<a href=\"viewweek.php?scope=".$scope."&id=".$id ."\">";
+      echo "$strviewmulti</a><br />";
+      echo "<a href=\"viewweek.php?scope=".$scope."&id=".$id ."&onetable=1\">";
+      echo "$strviewtable</a><br />";
+    } else if ($onetable) { // one table for all
+      echo "<a href=\"viewweek.php?scope=".$scope."&id=".$id ."\">";
+      echo "$strviewmulti</a><br />";
+      echo "<a href=\"viewweek.php?scope=".$scope."&id=".$id ."&onepage=1\">";
+      echo "$strviewone</a><br />";
+    } else { // multiple pages
+      echo "<a href=\"viewweek.php?scope=".$scope."&id=".$id ."&onepage=1\">";
+      echo "$strviewone</a><br />";
+      echo "<a href=\"viewweek.php?scope=".$scope."&id=".$id ."&onetable=1\">";
+      echo "$strviewtable</a><br />";
+    }
+    if ($scope=="week") {  // week view for scope
+      echo "<a href=\"viewweek.php?scope=section&id=".$id."\">";
+      echo "$strviewsection</a></p>";
+    } else { // section view for scope
+      echo "<a href=\"viewweek.php?scope=week&id=".$id."\">";
+      echo "$strviewweek</a></p>";
+    }
+
+
+
+/// create an array of all the attendance objects for the entire course
+   $numatt=0;
+   $numhours=0;
+   foreach ($attendances as $attendance){
+     // store the raw attendance object
+     $atts[$numatt]->attendance=$attendance;
+     // tally the hours for possible paging of the report
+     $numhours=$numhours+$attendance->hours;
+     // get the list of attendance records for all hours of the given day and 
+     // put it in the array for use in the attendance table
+     if (isstudent($course->id)) { 
+       $rolls = get_records("attendance_roll", "dayid", $form->id, "userid", $USER->id);
+     } else { // must be a teacher
+        $rolls = get_records("attendance_roll", "dayid", $attendance->id);
+     }
+     if ($rolls) {
+            foreach ($rolls as $roll) {
+              $atts[$numatt]->sroll[$roll->userid][$roll->hour]->status=$roll->status;
+              $atts[$numatt]->sroll[$roll->userid][$roll->hour]->notes=$roll->notes;
+            }
+     }
+   $numatt++;
+   }
+
+   if (isstudent($course->id)) {
+     $onepage=true;
+     $multipage=false; 
+   } else if (!(isset($onepage))){
+     $onepage=false;
+     $multipage=true;
+   } else if ($onepage) {
+     $multipage=false;
+   } else {  // if onepage is set to false
+        $multilpage=true;
+   }
+
+// adjust the width for the report for students 
+
+   if (($onetable) || ($CFG->attendance_hours_in_full_report == 0)) {
+      $hoursinreport = 100+$numhours;
+   } else if (isstudent($course->id)) {
+      $hoursinreport = $CFG->attendance_hours_in_full_report + 15;
+   } else { 
+      $hoursinreport = $CFG->attendance_hours_in_full_report;
+   }           
+while (($multipage || $onepage) && (!$endonepage)) {
+   // this makes for a one iteration loop for multipage
+        $multipage = false;
+        
+        
+   if ($numhours>=$hoursinreport) {
+        if (!isset($pagereport)) {
+               // $pagereport is used to determine whether the report needs to be paged at all
+               $pagereport=true;
+               $endatt=0;
+               $page=1;
+        } 
+        // find the last hour to have on this page of the report
+           // go to the next (or first) page
+//             $endatt++;
+//             $startatt=$endatt;
+               $curpage=1;
+               $endatt=0;
+  for($curpage=1;true;$curpage++) { // the for loop is broken from the inside
+               $pagehours=$atts[$endatt]->attendance->hours;
+               $startatt=$endatt;
+               while(($pagehours<$hoursinreport)) {
+                       if ($endatt>=$numatt) { break 2; } // end the page number calculations and trigger the end of a multi-page report!
+                       $endatt++;
+                       $pagehours=$pagehours+$atts[$endatt]->attendance->hours;
+               }
+               // if this is the page we're on, save the info
+               if ($curpage == $page) {$endatt_target = $endatt; $startatt_target = $startatt; }
+      } // hopefully at this point, startatt and endatt are set correctly for the current page
+               if ($curpage == $page) {$endatt_target = $endatt; $startatt_target = $startatt; } else {
+                  $endatt=$endatt_target; $startatt=$startatt_target; }
+               $maxpages = $curpage;
+   } else {$pagereport=false;}
+
+  $minatt=($pagereport ? $startatt : 0);
+  $maxatt=($pagereport ? $endatt : $numatt);     
+  if ((!$pagereport) || ($page == $maxpages)) {$endonepage = true;}  // end a one page display
+
+//
+//
+//  ALL PRELIMINARY STUFF DONE - MAKE THE MEAT OF THE PAGE
+//
+//
+
+  if (!$onepage) {
+
+  attendance_print_pagenav(); 
+  } 
+
+
+
+   // build the table for attendance roll
+   // this is the wrapper table
+   echo "<table align=\"center\" width=\"80\" class=\"generalbox\"".
+         "border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>".
+         "<td bgcolor=\"#ffffff\" class=\"generalboxcontent\">";
+   // this is the main table
+   echo "<table width=\"100%\" border=\"0\" valign=\"top\" align=\"center\" ".
+         "cellpadding=\"5\" cellspacing=\"1\" class=\"generaltable\">";
+   if (isteacher($course->id)) {
+   echo "<tr><th valign=\"top\" align=\"right\" colspan=\"3\" nowrap class=\"generaltableheader\">".
+              "&nbsp;</th>\n";
+   } 
+//      $minpage=0;$maxpage=$numatt;
+    // print the date headings at the top of the table
+    // for each day of attendance
+    for($k=$minatt;$k<$maxatt;$k++)  {
+    // put notes for the date in the date heading
+      $notes = ($atts[$k]->attendance->notes != "") ? ":<br />".$atts[$k]->attendance->notes : "";
+         echo "<th valign=\"top\" align=\"left\" colspan=\"" .$atts[$k]->attendance->hours. "\" nowrap class=\"generaltableheader\">".
+              userdate($atts[$k]->attendance->day,"%m/%0d").$notes."</th>\n";
+    }
+    // if we're at the end of the report
+    if ($maxatt==$numatt || !$pagereport) {
+      echo "<th valign=\"top\" align=\"left\" nowrap class=\"generaltableheader\">&nbsp;</th>\n";
+    }
+    echo "</tr>\n";
+    // print the second level headings with name and possibly hour numbers
+  if (isteacher($course->id)) {
+       echo "<tr><th valign=\"top\" align=\"left\" nowrap class=\"generaltableheader\">Last Name</th>\n";
+         echo "<th valign=\"top\" align=\"left\" nowrap class=\"generaltableheader\">First Name</th>\n";
+         echo "<th valign=\"top\" align=\"left\" nowrap class=\"generaltableheader\">ID</th>\n";
+  }
+    // generate the headers for the attendance hours
+    for($k=$minatt;$k<$maxatt;$k++)  {
+      if ($atts[$k]->attendance->hours > 1) {
+           for($i=1;$i<=$atts[$k]->attendance->hours;$i++) {
+           echo "<th valign=\"top\" align=\"center\" nowrap class=\"generaltableheader\">".$i."</th>\n";
+           }
+         } else { echo "<th valign=\"top\" align=\"center\" nowrap class=\"generaltableheader\">&nbsp;</th>\n"; }
+    }
+    // if we're at the end of the report
+    if ($maxatt==$numatt || !$pagereport) {
+      echo "<th valign=\"top\" align=\"center\" nowrap class=\"generaltableheader\">total</th>";
+    }
+       echo "</tr>\n";
+
+   // get the list of students along with student ID field
+   // get back array of stdclass objects in sorted order, with members:
+   // id, username,firstname,lastname,maildisplay,mailformat,email,city,country,
+   //   lastaccess,lastlogin,picture (picture is null, 0, or 1), idnumber
+
+
+  if (isstudent($course->id)) { 
+       $students[0] = get_user_info_from_db("id", $USER->id);
+  } else { // must be a teacher
+    $students = attendance_get_course_students($attendance->course, "u.lastname ASC");
+  }
+  $i=0;
+  $A = get_string("absentshort","attendance");
+  $T = get_string("tardyshort","attendance");
+  $P = get_string("presentshort","attendance");  
+  foreach ($students as $student) {
+    if (isteacher($course->id)) {
+      echo "<tr><td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->lastname."</td>\n";
+      echo "<td align=\"left\" nowrap class=\"generaltablecell\"  style=\"border-top: 1px solid;\">".$student->firstname."</td>\n";
+      $studentid=(($student->idnumber != "") ? $student->idnumber : "&nbsp");
+      echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$studentid."</td>\n";
+    }
+    for($k=$minatt;$k<$maxatt;$k++)  {  // for eacj day of attendance for the student
+         for($j=1;$j<=$atts[$k]->attendance->hours;$j++) {
+      // set the attendance defaults for each student
+           if ($atts[$k]->sroll[$student->id][$j]->status == 1) {$status=$T;}
+           elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {$status=$A;}
+           else {$status=$P;}
+        echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-left: 1px dotted; border-top: 1px solid;\">".$status."</td>\n";
+         } /// for loop
+    }
+    if ($maxatt==$numatt || !$pagereport) {
+           // tally total attendances for the students
+               $abs=$tar=0;
+           for($k=0;$k<$numatt;$k++)  {  // for eacj day of attendance for the student
+                 for($j=1;$j<=$atts[$k]->attendance->hours;$j++) {
+             // set the attendance defaults for each student
+                   if ($atts[$k]->sroll[$student->id][$j]->status == 1) {;$tar++;}
+                   elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {;$abs++;}
+                 } /// for loop
+           } // outer for for each day of attendance
+      $tot=tally_overall_absences_fraction($abs,$tar);
+      echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-left: 1px dotted; border-top: 1px solid;\">".$tot."</td></tr>\n";
+    }
+  }  // foreach
+  /// doing the table manually now
+  ///  print_table($table);
+  /// ending for the table
+  echo "</table></td></tr></table>\n";
+
+if ($onepage) {$page++; echo "<br /> <br />\n"; }
+}  // while loop for multipage/one page printing
+
+  if (!$onepage) { attendance_print_pagenav(); }
+
+ } else { error("There are no attendance rolls in this course.");} // for no attendance rolls  
+/// Finish the page
+    print_footer($course);
+
+
+function attendance_print_pagenav() {
+    global $pagereport, $minatt, $maxatt, $course, $page, $numatt, $maxpages, $attendance,$scope,$id;
+         if ($pagereport) {
+       $of = get_string('of','attendance');
+       $pg = get_string('page');
+       $next = get_string('next');
+       $prev = get_string('previous', 'attendance');
+
+               echo "<center><table align=\"center\" width=\"80\" class=\"generalbox\"".
+         "border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>".
+         "<td bgcolor=\"#ffffff\" class=\"generalboxcontent\">";
+    // this is the main table
+    echo "<table width=\"100%\" border=\"0\" valign=\"top\" align=\"center\" ".
+         "cellpadding=\"5\" cellspacing=\"1\" class=\"generaltable\">";
+    echo "<tr>";
+       if ($minatt!=0) {
+    echo "<th valign=\"top\" align=\"right\" nowrap class=\"generaltableheader\">".
+              "<a href=\"viewweek.php?scope=".$scope."&id=".$id ."&pagereport=1&page=".($page-1)."\">$prev $pg</a></th>\n";
+       }
+    echo "<th valign=\"top\" align=\"right\" nowrap class=\"generaltableheader\">".
+              "$pg $page $of $maxpages</th>\n";
+       if ($maxatt!=$numatt) {
+      echo "<th valign=\"top\" align=\"right\" nowrap class=\"generaltableheader\">".
+      "<a href=\"viewweek.php?scope=".$scope."&id=".$id ."&pagereport=1&page=". ($page+1)."\">$next $pg</a></th>";
+       }
+               echo "</tr></table></td></tr></table></center>\n";
+  }
+}
+
+?>