diff --git a/application/models/rows/ApprovalActionCollegeRouter.php b/application/models/rows/ApprovalActionCollegeRouter.php new file mode 100644 index 0000000000000000000000000000000000000000..8f7214931bcb71416fabd1ff1322463842ff3ced --- /dev/null +++ b/application/models/rows/ApprovalActionCollegeRouter.php @@ -0,0 +1,46 @@ +<?php + +require_once 'ApprovalActionRow/Interface.php'; + +/** + * @foreignKey approvalActionId + * @tableClass ApprovalActionsCollegeRouter + * + */ +class ApprovalActionCollegeRouter extends ApprovalAction + implements Application_ApprovalActionRow_Interface +{ + + public function getResultStatusStrings() + { + return $this->getTable()->getResultStatusStrings(); + } + + public function consider(Request $request, ApprovalChain $parentChain) + { + $parentChain->advance($request, $request->getCourseGeneration()->getHomeCollege()->name); + } + + public function updateFromForm($formData) + { + // no special data is used. + } + + /** + * Let the action know that a user has made a decsion so that the approval + * process may continue. + * + * @param Request $request + * @param User $user + * @param string $decision + */ + public function userMadeDecision(Request $request, User $user, $decision) + { + // since this is an automatic action, nothing needs to happen here. + } + + public function getUserDecision(Request $request, User $user) + { + return null; + } +} \ No newline at end of file diff --git a/application/models/rows/ApprovalActionDepartmentRouter.php b/application/models/rows/ApprovalActionDepartmentRouter.php new file mode 100644 index 0000000000000000000000000000000000000000..73dc59ffb9cc1b0b432671a1891af20c041c70ae --- /dev/null +++ b/application/models/rows/ApprovalActionDepartmentRouter.php @@ -0,0 +1,46 @@ +<?php + +require_once 'ApprovalActionRow/Interface.php'; + +/** + * @foreignKey approvalActionId + * @tableClass ApprovalActionsDepartmentRouter + * + */ +class ApprovalActionDepartmentRouter extends ApprovalAction + implements Application_ApprovalActionRow_Interface +{ + + public function getResultStatusStrings() + { + return $this->getTable()->getResultStatusStrings(); + } + + public function consider(Request $request, ApprovalChain $parentChain) + { + $parentChain->advance($request, $request->getCourseGeneration()->getHomeDepartment()->name); + } + + public function updateFromForm($formData) + { + // no special data is used. + } + + /** + * Let the action know that a user has made a decsion so that the approval + * process may continue. + * + * @param Request $request + * @param User $user + * @param string $decision + */ + public function userMadeDecision(Request $request, User $user, $decision) + { + // since this is an automatic action, nothing needs to happen here. + } + + public function getUserDecision(Request $request, User $user) + { + return null; + } +} \ No newline at end of file diff --git a/application/models/rows/ApprovalActionSubjectRouter.php b/application/models/rows/ApprovalActionSubjectRouter.php new file mode 100644 index 0000000000000000000000000000000000000000..c4fe47d6c1d9495dfa1e2b76eb3eef76322bd6da --- /dev/null +++ b/application/models/rows/ApprovalActionSubjectRouter.php @@ -0,0 +1,46 @@ +<?php + +require_once 'ApprovalActionRow/Interface.php'; + +/** + * @foreignKey approvalActionId + * @tableClass ApprovalActionsSubjectRouter + * + */ +class ApprovalActionSubjectRouter extends ApprovalAction + implements Application_ApprovalActionRow_Interface +{ + + public function getResultStatusStrings() + { + return $this->getTable()->getResultStatusStrings(); + } + + public function consider(Request $request, ApprovalChain $parentChain) + { + $parentChain->advance($request, $request->getCourseGeneration()->subject); + } + + public function updateFromForm($formData) + { + // no special data is used. + } + + /** + * Let the action know that a user has made a decsion so that the approval + * process may continue. + * + * @param Request $request + * @param User $user + * @param string $decision + */ + public function userMadeDecision(Request $request, User $user, $decision) + { + // since this is an automatic action, nothing needs to happen here. + } + + public function getUserDecision(Request $request, User $user) + { + return null; + } +} \ No newline at end of file diff --git a/application/models/rows/ApprovalChain.php b/application/models/rows/ApprovalChain.php index 40e1e8a8a44a8a555ae4473c968c6f783d0708e8..17927d0468598436c881667a5787274530ba7413 100644 --- a/application/models/rows/ApprovalChain.php +++ b/application/models/rows/ApprovalChain.php @@ -107,7 +107,11 @@ class ApprovalChain extends Nmc_Db_Table_Row $where = array(); $where[] = $db->quoteInto('chain=?', $this->getPrimaryKey()); $where[] = $db->quoteInto('currentAction=?', $request->stackPointer->action->getPrimaryKey()); - $where[] = $db->quoteInto('currentState=?', $request->state); + if ($request->state != '') { + $where[] = $db->quoteInto('currentState=?', $request->state); + } else { + $where[] = 'currentState IS NULL'; + } $where = implode(' AND ', $where); $nextLink = ApprovalLinks::getInstance()->fetchRow($where); diff --git a/application/models/rows/CourseGeneration.php b/application/models/rows/CourseGeneration.php index c4c36704d17b307fcd5d6495f3ddb6ae6ea489d7..3ccaa99628121bd042a278867b1a96ba79b87f76 100644 --- a/application/models/rows/CourseGeneration.php +++ b/application/models/rows/CourseGeneration.php @@ -176,13 +176,20 @@ class CourseGeneration extends Asset public function getHomeCollege() { - $subject = Subjects::getInstance()->fetchSubject($this->subject); - $department = $subject->department; + $department = $this->getHomeDepartment(); $college = $department->college; return $college; } + public function getHomeDepartment() + { + $subject = Subjects::getInstance()->fetchSubject($this->subject); + $department = $subject->department; + + return $department; + } + /** * Returns a reference to the home crosslist * diff --git a/application/models/tables/ApprovalActionsCollegeRouter.php b/application/models/tables/ApprovalActionsCollegeRouter.php new file mode 100644 index 0000000000000000000000000000000000000000..c48bd64b0b2712159b06c3415787ec2b34b9af83 --- /dev/null +++ b/application/models/tables/ApprovalActionsCollegeRouter.php @@ -0,0 +1,63 @@ +<?php + +require_once 'ApprovalActionTable/Interface.php'; + +class ApprovalActionsCollegeRouter extends Nmc_Db_Table + implements Application_ApprovalActionTable_Interface +{ + protected $_primary = 'approvalActionId'; + protected $_rowClass = 'ApprovalActionCollegeRouter'; + + /** + * The one true instance + * + * @var ApprovalActionsCollegeRouter + */ + static protected $_instance; + + /** + * Return the one true instance + * + * @return ApprovalActionsCollegeRouter + */ + static public function getInstance($config = array()) + { + if (!self::$_instance) { + self::$_instance = new ApprovalActionsCollegeRouter($config); + } + return self::$_instance; + } + + public function getActionName() + { + return 'College Router'; + } + + public function getResultStatusStrings() + { + $colleges = Colleges::getInstance()->fetchAll(); + $collegesArray = array(); + foreach ($colleges as $college) { + $collegesArray[$college->name] = $college->name; + } + return $collegesArray; + } + + public function getEditTemplate() + { + return 'approval_actions/ApprovalActionCollegeRouter.xhtml'; + } + + public function fetchNew($formData = null) + { + if (!$formData) { + return parent::fetchNew(); + } + + $new = parent::fetchNew(); + $new->className = 'ApprovalActionCollegeRouter'; + + return $new; + } + +} diff --git a/application/models/tables/ApprovalActionsDepartmentRouter.php b/application/models/tables/ApprovalActionsDepartmentRouter.php new file mode 100644 index 0000000000000000000000000000000000000000..af729022dd4833862c8de3431b1ed42789a79106 --- /dev/null +++ b/application/models/tables/ApprovalActionsDepartmentRouter.php @@ -0,0 +1,63 @@ +<?php + +require_once 'ApprovalActionTable/Interface.php'; + +class ApprovalActionsDepartmentRouter extends Nmc_Db_Table + implements Application_ApprovalActionTable_Interface +{ + protected $_primary = 'approvalActionId'; + protected $_rowClass = 'ApprovalActionDepartmentRouter'; + + /** + * The one true instance + * + * @var ApprovalActionsDepartmentRouter + */ + static protected $_instance; + + /** + * Return the one true instance + * + * @return ApprovalActionsDepartmentRouter + */ + static public function getInstance($config = array()) + { + if (!self::$_instance) { + self::$_instance = new ApprovalActionsDepartmentRouter($config); + } + return self::$_instance; + } + + public function getActionName() + { + return 'Department Router'; + } + + public function getResultStatusStrings() + { + $departments = Departments::getInstance()->fetchAll(); + $departmentsArray = array(); + foreach ($departments as $department) { + $departmentsArray[$department->name] = $department->name; + } + return $departmentsArray; + } + + public function getEditTemplate() + { + return 'approval_actions/ApprovalActionDepartmentRouter.xhtml'; + } + + public function fetchNew($formData = null) + { + if (!$formData) { + return parent::fetchNew(); + } + + $new = parent::fetchNew(); + $new->className = 'ApprovalActionDepartmentRouter'; + + return $new; + } + +} diff --git a/application/models/tables/ApprovalActionsSubjectRouter.php b/application/models/tables/ApprovalActionsSubjectRouter.php new file mode 100644 index 0000000000000000000000000000000000000000..277fcd47a4476dd07fb8ca1a401939d2c7b75ccd --- /dev/null +++ b/application/models/tables/ApprovalActionsSubjectRouter.php @@ -0,0 +1,63 @@ +<?php + +require_once 'ApprovalActionTable/Interface.php'; + +class ApprovalActionsSubjectRouter extends Nmc_Db_Table + implements Application_ApprovalActionTable_Interface +{ + protected $_primary = 'approvalActionId'; + protected $_rowClass = 'ApprovalActionSubjectRouter'; + + /** + * The one true instance + * + * @var ApprovalActionsSubjectRouter + */ + static protected $_instance; + + /** + * Return the one true instance + * + * @return ApprovalActionsSubjectRouter + */ + static public function getInstance($config = array()) + { + if (!self::$_instance) { + self::$_instance = new ApprovalActionsSubjectRouter($config); + } + return self::$_instance; + } + + public function getActionName() + { + return 'Subject Router'; + } + + public function getResultStatusStrings() + { + $subjects = Subjects::getInstance()->fetchAll(); + $subjectsArray = array(); + foreach ($subjects as $subject) { + $subjectsArray[$subject->name] = $subject->name; + } + return $subjectsArray; + } + + public function getEditTemplate() + { + return 'approval_actions/ApprovalActionSubjectRouter.xhtml'; + } + + public function fetchNew($formData = null) + { + if (!$formData) { + return parent::fetchNew(); + } + + $new = parent::fetchNew(); + $new->className = 'ApprovalActionSubjectRouter'; + + return $new; + } + +} diff --git a/application/views/approval_actions/ApprovalActionCollegeRouter.xhtml b/application/views/approval_actions/ApprovalActionCollegeRouter.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..1276d21e4e0297713f46bfa4a0dda54b61d6e16f --- /dev/null +++ b/application/views/approval_actions/ApprovalActionCollegeRouter.xhtml @@ -0,0 +1 @@ +<em>This space intentionally left blank</em> \ No newline at end of file diff --git a/application/views/approval_actions/ApprovalActionDepartmentRouter.xhtml b/application/views/approval_actions/ApprovalActionDepartmentRouter.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..1276d21e4e0297713f46bfa4a0dda54b61d6e16f --- /dev/null +++ b/application/views/approval_actions/ApprovalActionDepartmentRouter.xhtml @@ -0,0 +1 @@ +<em>This space intentionally left blank</em> \ No newline at end of file diff --git a/application/views/approval_actions/ApprovalActionSubjectRouter.xhtml b/application/views/approval_actions/ApprovalActionSubjectRouter.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..1276d21e4e0297713f46bfa4a0dda54b61d6e16f --- /dev/null +++ b/application/views/approval_actions/ApprovalActionSubjectRouter.xhtml @@ -0,0 +1 @@ +<em>This space intentionally left blank</em> \ No newline at end of file