From af55255d821b3b13167ce8adacc5b0be3a8214b9 Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Thu, 18 Oct 2007 17:02:18 +0000
Subject: [PATCH] Dynamically generate effective term list for next few years.

---
 application/controllers/RequestController.php | 26 +++++++++++++++++++
 application/views/request/submit.xhtml        |  8 +-----
 application/views/request/view.xhtml          |  8 +-----
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/application/controllers/RequestController.php b/application/controllers/RequestController.php
index 67d3d055..5d1cb987 100755
--- a/application/controllers/RequestController.php
+++ b/application/controllers/RequestController.php
@@ -738,6 +738,7 @@ class RequestController extends Nmc_Controller_Action
         $out->addSidebarModule('bulletinPreview');
         $out->course = $course;
         $out->request = $request;
+        $out->terms = $this->_getFutureTerms();
         $out->page = 'request/edit_wrapper';
         $out->tagline = 'Edit Request';
         $out->requestPage = 'submit';
@@ -796,6 +797,7 @@ class RequestController extends Nmc_Controller_Action
             $currentGeneration = $currentGeneration->getParentGeneration();
         }
 
+
         $out = new Application_View();
         //$out->addSidebarModule('requestProgress');
         $out->addSidebarModule('bulletinPreview');
@@ -803,6 +805,7 @@ class RequestController extends Nmc_Controller_Action
         $out->request = $request;
         $out->currentGeneration = $currentGeneration;
         $out->proposedGeneration = $proposedGeneration;
+        $out->terms = $this->_getFutureTerms();
         $out->page = 'request/view';
         $out->tagline = 'Preview Request';
         $out->addCssFile('/ooss/request/submit');
@@ -891,5 +894,28 @@ class RequestController extends Nmc_Controller_Action
         $view->refresh = '/home';
         echo $view->render('unlModernWrapper.xhtml');
     }
+
+    protected function _getFutureTerms()
+    {
+        $now = new Zend_Date();
+        $month = $now->get(Zend_Date::MONTH);
+        $thisYear = $now->get(Zend_Date::YEAR);
+        $nextYear = $thisYear + 1;
+
+        $terms = array();
+        if ($month < 3) {
+            $terms[$thisYear . '3'] = 'Summer ' . $thisYear;
+        }
+        if ($month < 8) {
+            $terms[$nextYear . '1'] = 'Fall ' . $thisYear;
+        }
+        for ($year = $nextYear; $year < $thisYear + 5; $year++) {
+            $terms[$year . '2'] = 'Spring ' . $year;
+            $terms[$year . '3'] = 'Summer ' . $year;
+            $terms[($year + 1) . '1'] = 'Fall ' . ($year + 1);
+        }
+
+        return $terms;
+    }
 }
 
diff --git a/application/views/request/submit.xhtml b/application/views/request/submit.xhtml
index ca601c84..f9a3c262 100644
--- a/application/views/request/submit.xhtml
+++ b/application/views/request/submit.xhtml
@@ -11,13 +11,7 @@
             'effectiveSemester',
             $this->course->effectiveSemester,
             array('id' => 'effectiveSemester'),
-            array(
-                '20082' => 'Spring 2008',
-                '20083' => 'Summer 2008',
-                '20091' => 'Fall 2008',
-                '20092' => 'Spring 2009',
-                '20093' => 'Summer 2009'
-            )
+            $this->terms
         );
         ?>
     </label>
diff --git a/application/views/request/view.xhtml b/application/views/request/view.xhtml
index fdebfa26..9a45cc20 100644
--- a/application/views/request/view.xhtml
+++ b/application/views/request/view.xhtml
@@ -97,13 +97,7 @@
                     'effectiveSemester',
                     $this->course->effectiveSemester,
                     array('id' => 'effectiveSemester'),
-                    array(
-                        '20082' => 'Spring 2008',
-                        '20083' => 'Summer 2008',
-                        '20091' => 'Fall 2008',
-                        '20092' => 'Spring 2009',
-                        '20093' => 'Summer 2009'
-                    )
+                    $this->terms
                 );
                 ?>
             </label>
-- 
GitLab