Changeset - 76ece8b74a2e
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2011-03-29 21:56:11
ohnobinki@ohnopublishing.net
Fix double-display of earlier times, problem caused by 933c98416373.
1 file changed with 10 insertions and 3 deletions:
0 comments (0 inline, 0 general)
inc/class.schedule.php
Show inline comments
 
@@ -242,49 +242,56 @@ class Schedule
 
		  $cs[$position]++;
 
		}
 
	      } else {
 
	      $valid = true;
 
	      $position = 0;
 
	    }
 
	  }
 
            
 
	$counter++;
 
      } while($counter < $this->possiblePermutations);
 
  }
 
    
 
  /**
 
   * \brief
 
   *   Prints out the possible permutations in tables.
 
   *
 
   * \param $schedule_store
 
   *   The schedule_store handle with which this schedule was loaded,
 
   *   used to query the parent schedule.
 
   */
 
  //--------------------------------------------------
 
  function writeoutTables(array $schedule_store = NULL)
 
  {
 
    $filled = false;
 
    $time = array(700,730,800,830,900,930,1000,1030,1100,1130,1200,1230,1300,1330,1400,1430,1500,1530,1600,1630,1700,1730,1800,1830,1900,1930,2000,2030,2100,2130, 2200);
 
    $time = array(700 => 700, 730 => 730, 800 => 800, 830 => 830,
 
		  900 => 900, 930 => 930,1000 =>1000,1030 =>1030,
 
		  1100 => 1100, 1130 => 1130, 1200 => 1200, 1230 => 1230,
 
		  1300 => 1300, 1330 => 1330, 1400 => 1400, 1430 => 1430,
 
		  1500 => 1500, 1530 => 1530, 1600 => 1600, 1630 => 1630,
 
		  1700 => 1700, 1730 => 1730, 1800 => 1800, 1830 => 1830,
 
		  1900 => 1900, 1930 => 1930, 2000 => 2000, 2030 => 2030,
 
		  2100 => 2100, 2130 => 2130, 2200 => 2200);
 

	
 
    define('SP_PERMUTATIONS_PER_PAGE', 64); /** @TODO: Define this in config.inc */
 

	
 
    $npages = ceil($this->nPermutations / SP_PERMUTATIONS_PER_PAGE);
 
    $page = 0;
 
    if (isset($_REQUEST['page']))
 
      $page = $_REQUEST['page'];
 
    /*
 
     * only display the ``this page doesn't exist'' 404 if there is at
 
     * least one permutation. Otherwise, we give an irrelevant 404 for
 
     * users with no permutations.
 
     */
 
    if ($this->nPermutations && $page >= $npages)
 
      Page::show_404('Unable to find page ' . $page . ', there are only ' . $this->nPermutations . ' non-conflicting permutations, for a total of ' . $npages . ' pages.');
 
    /* zero-based */
 
    $first_permutation = $page * SP_PERMUTATIONS_PER_PAGE;
 
    $last_permutation = min($this->nPermutations, $first_permutation + SP_PERMUTATIONS_PER_PAGE);
 

	
 
    $footcloser = '';
 

	
 
    if(isset($_REQUEST['print']) && $_REQUEST['print'] != ''){
 
      $headcode = array('jQuery', 'jQueryUI', 'uiTabsKeyboard', 'outputStyle', 'outputPrintStyle', 'displayTables');
 
    }
 
    else {
 
@@ -373,56 +380,56 @@ class Schedule
 
	$max_day_plusone = 5;
 
	$have_saturday = FALSE;
 

	
 
	$max_time = (int)max($time);
 
	$min_time = (int)min($time);
 
	$sort_time = FALSE;
 
	foreach ($this->courses as $course)
 
	  {
 
	    for ($si = 0; $si < $course->getnsections(); $si ++)
 
	      foreach ($course->getSection($si)->getMeetings() as $meeting)
 
		{
 
		  /* Saturdayness */
 
		  if ($meeting->getDay(5))
 
		    {
 
		      $max_day_plusone = 6;
 
		      $have_saturday = TRUE;
 
		    }
 

	
 
		  /* very late / very early classes */
 
		  while ($meeting->getEndTime() > $max_time)
 
		    {
 
		      $max_time = sprintf("%04d", $max_time + 30);
 
		      while (substr($max_time, -2) >= 60)
 
			$max_time = sprintf("%02d%02d", substr($max_time, 0, 2) + 1, substr($max_time, -2) - 60);
 
		      $time[] = $max_time;
 
		      $time[(int)$max_time] = $max_time;
 
		    }
 
		  while ($meeting->getStartTime() < $min_time)
 
		    {
 
		      if (substr($min_time, -2) < 30)
 
			$min_time = sprintf("%02d%02d", substr($min_time, 0, 2) - 1, substr($min_time, -2) + 60);
 
		      $min_time = sprintf("%04d", $min_time - 30);
 
		      $time[] = $min_time;
 
		      $time[(int)$min_time] = (int)$min_time;
 
		      $sort_time = TRUE;
 
		    }
 
		}
 
	  }
 
	/* ensure that early times are actually first ;-) */
 
	if ($sort_time)
 
	  sort($time);
 

	
 
        echo '    <div id="regDialog" title="Registration Codes">' . PHP_EOL
 
	  . '      <div id="regDialog-content"></div>' . PHP_EOL
 
	  . '      <p id="regDialog-disclaimer" class="graytext"><em>Note: The registration information above corresponds to the sections displayed on the currently selected tab.</em></p>'
 
	  . '    </div>';
 
	echo '<div id="tabs">' . "\n" .
 
               '<div id="show-box" class="show-buttons">
 
                  <form action="#"><p class="nospace">
 
                    <label><strong>Display:</strong></label>
 
                    <input id="show-course-title" name="show-course-title" type="checkbox" /><label for="show-course-title">Course Title</label>
 
                    <input id="show-prof" name="show-prof" type="checkbox" checked="checked" /><label for="show-prof">Professor</label>
 
                    <input id="show-location" name="show-location" type="checkbox" /><label for="show-location">Room</label>
 
                    <input id="show-synonym" name="show-synonym" type="checkbox" /><label for="show-synonym">Synonym</label>
 
                    <span id="regCodes"><label><a href="#"><strong>Register for Classes</strong></a></label></span></p>
 
                  </form>';
 

	
 
          echo '</div> <!-- id="show-box" -->'
0 comments (0 inline, 0 general)