public function getRowTags() { $delete_cmd = CommandFactory::getCommand('DeleteMoveinTime'); $delete_cmd->setId($this->id); $tags = array(); $tags['BEGIN_TIMESTAMP'] = HMS_Util::get_long_date_time($this->begin_timestamp); $tags['END_TIMESTAMP'] = HMS_Util::get_long_date_time($this->end_timestamp); $tags['ACTION'] = $delete_cmd->getLink('Delete'); return $tags; }
/** * Returns the full CSV output as one long string. * * @return String CSV output */ public function getOutput() { // Get the columns from the report $columns = $this->report->getCsvColumnsArray(); // Add a copule of meta-data fields $columns[] = HMS_Util::get_long_date_time($this->report->getCompletedTimestamp()); $columns[] = $this->report->getCreatedBy(); $columns[] = Term::toString($this->report->getTerm()); $output = self::sputcsv($columns); $rows = $this->report->getCsvRowsArray(); if (isset($rows) && !empty($rows)) { foreach ($rows as $cols) { $output .= self::sputcsv($cols); } } return $output; }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Util.php'); $tpl = array(); $now = time(); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); $tpl['STATUS'] = ""; if ($this->startDate > $now) { // Too early! $tpl['ICON'] = FEATURE_NOTYET_ICON; $tpl['BEGIN_DEADLINE'] = HMS_Util::get_long_date_time($this->startDate); } else { if ($this->endDate < $now) { // Too late $tpl['ICON'] = FEATURE_LOCKED_ICON; // fade out header $tpl['STATUS'] = "locked"; $tpl['END_DEADLINE'] = HMS_Util::get_long_date_time($this->endDate); } else { if (!isset($this->application)) { $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['STATUS'] = "locked"; $tpl['DID_NOT_APPLY'] = ""; } else { if (isset($this->application) && isset($this->application->waiting_list_date)) { $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['SIGNED_UP'] = ""; } else { if (isset($this->application)) { $tpl['ICON'] = FEATURE_OPEN_ICON; $cmd = CommandFactory::getCommand('ShowWaitingListSignup'); $cmd->setTerm($this->term); $tpl['APPLY_LINK'] = $cmd->getLink("apply to the On-campus Housing Waiting List"); } else { } } } } } Layout::addPageTitle("Re-Application Waiting List"); return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/reApplicationWaitingListMenuBlock.tpl'); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $roomId = $context->get('roomId'); $roommates = $context->get('roommates'); $mealPlan = $context->get('mealPlan'); $term = PHPWS_Settings::get('hms', 'lottery_term'); $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); $errorCmd = CommandFactory::getCommand('LotteryShowConfirm'); $errorCmd->setRoomId($roomId); $errorCmd->setRoommates($roommates); $errorCmd->setMealPlan($mealPlan); $successCmd = CommandFactory::getCommand('LotteryShowConfirmed'); $successCmd->setRoomId($roomId); PHPWS_Core::initCoreClass('Captcha.php'); $captcha = Captcha::verify(TRUE); // returns the words entered if correct, FALSE otherwise //$captcha = TRUE; if ($captcha === FALSE) { NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, the words you eneted were incorrect. Please try again.'); $errorCmd->redirect(); } PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Room.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php'); $room = new HMS_Room($roomId); // Check for an RLC assignment in the self-select status $rlcAssignment = RlcMembershipFactory::getMembership($student, $term); // Check roommates for validity foreach ($roommates as $bed_id => $username) { // Double check the student is valid try { $roommate = StudentFactory::getStudentByUsername($username, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not a valid student. Please choose a different roommate."); $errorCmd->redirect(); } // Make sure the bed is still empty $bed = new HMS_Bed($bed_id); if ($bed->has_vacancy() != TRUE) { NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.'); $errorCmd->redirect(); } // Make sure none of the needed beds are reserved if ($bed->is_lottery_reserved()) { NQ::simple('hms', hms\NotificationView::ERROR, 'One or more of the beds in the room you selected is no longer available. Please try again.'); $errorCmd->redirect(); } // Double check the genders are all the same as the person logged in if ($student->getGender() != $roommate->getGender()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender."); $errorCmd->redirect(); } // Double check the genders are the same as the room (as long as the room isn't AUTO) if ($room->gender_type != AUTO && $roommate->getGender() != $room->gender_type) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is a different gender. Please choose a roommate of the same gender."); $errorCmd->redirect(); } // If this student is an RLC-self-selection, then each roommate must be in the same RLC and in the selfselect-invite state too if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { // This student is an RLC-self-select, so check the roommate's RLC status $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term); // Make sure the roommate is a member of the same RLC and is eligible for self-selection if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$roommate} must be a member of the same learning community as you, and must also be eligible for self-selction."); $errorCmd->redirect(); } // Otherwise (if not RLC members), make sure each roommate is eligible } else { if (HMS_Lottery::determineEligibility($username) !== TRUE) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} is not eligible for assignment."); $errorCmd->redirect(); } } // If this student is a self-select RLC member, then this student must also be a self-select RLC member of the same RLC if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { $roommateRlcAssign = RlcMembershipFactory::getMembership($roommate, $term); if ($roommateRlcAssign == null || $roommateRlcAssign->getStateName() != 'selfselect-invite' || $rlcAssignment->getRlc()->getId() != $roommateRlcAssign->getRlc()->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, "{$username} must be a member of the same learning community as you, and must also be eligible for self-selction."); $errorCmd->redirect(); } } } // If the room's gender is 'AUTO' and no one is assigned to it yet, switch it to the student's gender if ($room->gender_type == AUTO && $room->get_number_of_assignees() == 0) { $room->gender_type = $student->getGender(); $room->save(); } // Assign the student to the requested bed $bed_id = array_search(UserStatus::getUsername(), $roommates); // Find the bed id of the student who's logged in try { $result = HMS_Assignment::assignStudent($student, PHPWS_Settings::get('hms', 'lottery_term'), NULL, $bed_id, $mealPlan, 'Confirmed lottery invite', TRUE, ASSIGN_LOTTERY); } catch (Exception $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error creating your room assignment. Please try again or contact University Housing.'); $errorCmd->redirect(); } // Log the assignment HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ROOM_CHOSEN, UserStatus::getUsername(), 'Captcha: ' . $captcha); // Update the student's meal plan in the housing application, just for future reference $app = HousingApplication::getApplicationByUser($student->getUsername(), $term); $app->setMealPlan($mealPlan); $app->save(); // If this student was an RLC self-select, update the RLC memberhsip state if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') { $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment)); } foreach ($roommates as $bed_id => $username) { // Skip the current user if ($username == $student->getUsername()) { continue; } # Reserve the bed for the roommate $expires_on = time() + INVITE_TTL_HRS * 3600; $bed = new HMS_Bed($bed_id); if (!$bed->lottery_reserve($username, $student->getUsername(), $expires_on)) { NQ::smiple('hms', hms\NotificationView::WARNING, "You were assigned, but there was a problem reserving space for your roommates. Please contact University Housing."); $successCmd->redirect(); } HMS_Activity_Log::log_activity($username, ACTIVITY_LOTTERY_REQUESTED_AS_ROOMMATE, $student->getUsername(), 'Expires: ' . HMS_Util::get_long_date_time($expires_on)); # Invite the selected roommates $roomie = StudentFactory::getStudentByUsername($username, $term); $term = PHPWS_Settings::get('hms', 'lottery_term'); $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term)); HMS_Email::send_lottery_roommate_invite($roomie, $student, $expires_on, $room->where_am_i(), $year); } HMS_Email::send_lottery_assignment_confirmation($student, $room->where_am_i(), $term); $successCmd->redirect(); }
public static function send_lottery_roommate_reminder($to, $name, $expires_on, $requestor_name, $hall_room, $year) { $tpl = array(); $tpl['NAME'] = $name; $tpl['EXPIRES_ON'] = HMS_Util::get_long_date_time($expires_on); $tpl['YEAR'] = $year; $tpl['REQUESTOR'] = $requestor_name; $tpl['HALL_ROOM'] = $hall_room; $hours = round(($expires_on - time()) / 3600); HMS_Email::send_template_message($to . TO_DOMAIN, "Roommate Invitation Reminder: Only {$hours} hours left!", 'email/lottery_roommate_invite_reminder.tpl', $tpl); }
/** * Returns the DBPager tags used for showing scheduled execution records * on the ReportDetailView. * * @return Array DBPager tags for this report */ public function schedulePagerRowTags() { $tags = array(); $tags['SCHEDULE_DATE'] = HMS_Util::get_long_date_time($this->getScheduledExecTime()); $actions = array(); $cancelCmd = CommandFactory::getCommand('CancelReport'); $cancelCmd->setReportId($this->getId()); $actions[] = $cancelCmd->getLink('cancel'); $tags['ACTIONS'] = implode(' ', $actions); return $tags; }
public function get_roommate_pager_tags() { $tags = array(); $term = Term::getSelectedTerm(); $requestor = StudentFactory::getStudentByUsername($this->requestor, $term); $requestee = StudentFactory::getStudentByUsername($this->requestee, $term); $deleteCmd = CommandFactory::getCommand('DeleteRoommateGroup'); $deleteCmd->setId($this->id); $tags['REQUESTOR'] = $requestor->getProfileLink(); $tags['REQUESTEE'] = $requestee->getProfileLink(); $tags['REQUESTED_ON'] = HMS_Util::get_long_date_time($this->requested_on); $tags['CONFIRMED_ON'] = HMS_Util::get_long_date_time($this->confirmed_on); $tags['ACTION'] = $deleteCmd->getLink('Delete'); return $tags; }
/** * Uses the report stored in this view to provide template variables. * This method provides some common template variables, but should be * extended by subclasses. */ protected function render() { $this->tpl['NAME'] = $this->report->getFriendlyName(); $this->tpl['EXEC_DATE'] = HMS_Util::get_long_date_time($this->report->getCompletedTimestamp()); $this->tpl['EXEC_USER'] = $this->report->getCreatedBy(); }