public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'admin_approve_room_change')) {
         PHPWS_Core::initModClasS('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve room changes.');
     }
     PHPWS_Core::initModClass('hms', 'RoomChangeRequestFactory.php');
     PHPWS_Core::initModClass('hms', 'RoomChangeApprovalView.php');
     $term = Term::getSelectedTerm();
     // Get all requests in the FutureRDApproved state (i.e. waiting on housing assignments office)
     $needsApprovalChanges = RoomChangeRequestFactory::getAllRoomChangesNeedsAdminApproval($term);
     // Get all requests that are Approved (in-progress)
     $allApproved = RoomChangeRequestFactory::getAllRoomChangesByState($term, array('Approved'));
     // Get all requests that are pending/in-progress, but not waiting on Housing
     $allPending = RoomChangeRequestFactory::getAllRoomChangesByState($term, array('Pending', 'Hold'));
     // Get all complete requests
     $allComplete = RoomChangeRequestFactory::getAllRoomChangesByState($term, array('Complete'));
     // Get all requests that are inactive (cancelled, denied, complete)
     $allInactive = RoomChangeRequestFactory::getAllRoomChangesByState($term, array('Cancelled', 'Denied'));
     $view = new RoomChangeApprovalView($needsApprovalChanges, $allApproved, $allPending, $allComplete, $allInactive, array('All Halls'), $term);
     $context->setContent($view->show());
 }
예제 #2
0
 /**
  * Sends a notification to the Current RD involved in a room change request
  * letting them know they need to log in and approve
  *
  * Template Tags:
  * {STUDENT_NAME}
  * {BANNER_ID}
  * {CURRENT_ASSIGNMENT}
  * {CELL_PHONE}
  *
  * @param $rd string The username of the RD
  * @param $participant RoomChangeParticipant The Participant object involved
  */
 public static function sendRoomChangeCurrRDNotice(RoomChangeRequest $request)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClasS('hms', 'HMS_Bed.php');
     $subject = 'Room Change Approval Required';
     $template = 'email/roomChangeCurrRDNotice.tpl';
     $tags = array('PARTICIPANTS' => array());
     $rds = array();
     $term = Term::getCurrentTerm();
     foreach ($request->getParticipants() as $p) {
         // Add participant's RD(s) to recipients
         $rds = array_merge($rds, $p->getCurrentRdList());
         $bid = $p->getBannerId();
         $student = StudentFactory::getStudentByBannerID($bid, $term);
         $assign = HMS_Assignment::getAssignmentByBannerID($bid, $term);
         $participantTags = array('BANNER_ID' => $student->getBannerId(), 'NAME' => $student->getName(), 'CURRENT' => $assign->where_am_i());
         // If they have a future assignment, show it
         $futureBedId = $p->getToBed();
         if ($futureBedId) {
             $bed = new HMS_Bed($futureBedId);
             $participantTags['DESTINATION'] = $bed->where_am_i();
         }
         $tags['PARTICIPANTS'][] = $participantTags;
     }
     // In case an RD ends up in here several times, no need for dup emails
     $recips = array_unique($rds);
     $message = self::makeSwiftmailMessage(null, $subject, $tags, $template);
     foreach ($recips as $recip) {
         $message->setTo($recip . TO_DOMAIN);
         self::sendSwiftmailMessage($message);
     }
 }