public function execute() { if (!isset($this->term) || is_null($this->term)) { throw new InvalidArgumentException('Missing term.'); } $halls = ResidenceHallFactory::getHallsForTerm($this->term); foreach ($halls as $hall) { $floors = $hall->get_floors(); $floor_array = array(); foreach ($floors as $floor) { if (is_null($floor->f_movein_time_id)) { $f_time = 'None'; } else { $f_movein = new HMS_Movein_Time($floor->f_movein_time_id); $f_time = $f_movein->get_formatted_begin_end(); } if (is_null($floor->t_movein_time_id)) { $t_time = 'None'; } else { $t_movein = new HMS_Movein_Time($floor->t_movein_time_id); $t_time = $t_movein->get_formatted_begin_end(); } if (is_null($floor->rt_movein_time_id)) { $rt_time = 'None'; } else { $rt_movein = new HMS_Movein_Time($floor->rt_movein_time_id); $rt_time = $rt_movein->get_formatted_begin_end(); } $floor_array[] = array('FLOOR_NUM' => $floor->floor_number, 'F_TIME' => $f_time, 'T_TIME' => $t_time, 'RT_TIME' => $rt_time); } $this->rows[] = array('HALL_NAME' => $hall->hall_name, 'floor_rows' => $floor_array); } }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Util.php'); $tpl = array(); $tpl['TITLE'] = 'Edit Move-in Times'; $form = new PHPWS_Form(); $form->addDropBox('begin_day', HMS_Util::get_days()); $form->addCssClass('begin_day', 'form-control'); $form->addDropBox('begin_month', HMS_Util::get_months()); $form->addCssClass('begin_month', 'form-control'); $form->addDropBox('begin_year', HMS_Util::get_years_2yr()); $form->addCssClass('begin_year', 'form-control'); $form->addDropBox('begin_hour', HMS_Util::get_hours()); $form->addCssClass('begin_hour', 'form-control'); $form->addDropBox('end_day', HMS_Util::get_days()); $form->addCssClass('end_day', 'form-control'); $form->addDropBox('end_month', HMS_Util::get_months()); $form->addCssClass('end_month', 'form-control'); $form->addDropBox('end_year', HMS_Util::get_years_2yr()); $form->addCssClass('end_year', 'form-control'); $form->addDropBox('end_hour', HMS_Util::get_hours()); $form->addCssClass('end_hour', 'form-control'); $form->addSubmit('submit', 'Create'); $cmd = CommandFactory::getCommand('CreateMoveinTime'); $cmd->initForm($form); $tpl['MOVEIN_TIME_PAGER'] = HMS_Movein_Time::get_movein_times_pager(); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); Layout::addPageTitle("Move-in Times"); return PHPWS_Template::process($tpl, 'hms', 'admin/edit_movein_time.tpl'); }
public function show_verify_assignment() { PHPWS_Core::initModClass('hms', 'HMS_Term.php'); PHPWS_Core::initModClass('hms', 'HMS_SOAP.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Movein_Time.php'); $tpl = array(); $assignment = HMS_Assignment::get_assignment($_SESSION['asu_username'], $_SESSION['application_term']); if ($assignment === NULL || $assignment == FALSE) { $tpl['NO_ASSIGNMENT'] = "You do not currently have a housing assignment."; } else { $tpl['ASSIGNMENT'] = $assignment->where_am_i() . '<br />'; # Determine the student's type and figure out their movein time $type = HMS_SOAP::get_student_type($_SESSION['asu_username'], $_SESSION['application_term']); if ($type == TYPE_CONTINUING) { $movein_time_id = $assignment->get_rt_movein_time_id(); } elseif ($type == TYPE_TRANFER) { $movein_time_id = $assignment->get_t_movein_time_id(); } else { $movein_time_id = $assignment->get_f_movein_time_id(); } if ($movein_time_id == NULL) { $tpl['MOVE_IN_TIME'] = 'To be determined<br />'; } else { $movein_times = HMS_Movein_Time::get_movein_times_array($_SESSION['application_term']); $tpl['MOVE_IN_TIME'] = $movein_times[$movein_time_id]; } } //get the assignees to the room that the bed that the assignment is in $assignees = !is_null($assignment) ? $assignment->get_parent()->get_parent()->get_assignees() : NULL; $roommates = array(); if (!is_null($assignees)) { foreach ($assignees as $roommate) { if ($roommate->asu_username != $_SESSION['asu_username']) { $roommates[] = $roommate->asu_username; } } } if (empty($roommates)) { $tpl['roommate'][]['ROOMMATE'] = 'You do not have a roommate.'; } else { foreach ($roommates as $roommate) { $tpl['roommate'][]['ROOMMATE'] = '' . HMS_SOAP::get_name($roommate) . ' (<a href="mailto:' . $roommate . '@appstate.edu">' . $roommate . '@appstate.edu</a>)'; } } $rlc_assignment = HMS_RLC_Assignment::check_for_assignment($_SESSION['asu_username'], $_SESSION['application_term']); if ($rlc_assignment == NULL || $rlc_assignment === FALSE) { $tpl['RLC'] = "You have not been accepted to an RLC."; } else { $rlc_list = HMS_Learning_Community::getRlcList(); $tpl['RLC'] = 'You have been assigned to the ' . $rlc_list[$rlc_assignment['rlc_id']]; } $tpl['MENU_LINK'] = PHPWS_Text::secureLink('Back to Main Menu', 'hms', array('type' => 'student', 'op' => 'show_main_menu')); return PHPWS_Template::process($tpl, 'hms', 'student/verify_assignment.tpl'); }
public function execute(CommandContext $context) { $cmd = CommandFactory::getCommand('ShowMoveinTimesView'); $id = $context->get('id'); if (is_null($id) || !is_numeric($id)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid id selected for deletion.'); $cmd->redirect(); } $movein_time = new HMS_Movein_Time(); $movein_time->id = $id; $result = $movein_time->delete(); if (!$result || PHPWS_Error::logIfError($result)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Database error while attempting to delete movein time.'); } else { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Movein time deleted successfully.'); } $cmd->redirect(); }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Movein_Time.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $tpl = array(); $assignment = HMS_Assignment::getAssignment($this->student->getUsername(), $this->term); if ($assignment === NULL || $assignment == FALSE) { $tpl['NO_ASSIGNMENT'] = "You do not currently have a housing assignment."; } else { $tpl['ASSIGNMENT'] = $assignment->where_am_i() . '<br />'; # Determine the student's type and figure out their movein time $type = $this->student->getType(); if ($type == TYPE_CONTINUING) { $movein_time_id = $assignment->get_rt_movein_time_id(); } elseif ($type == TYPE_TRANSFER) { $movein_time_id = $assignment->get_t_movein_time_id(); } else { $movein_time_id = $assignment->get_f_movein_time_id(); } if ($movein_time_id == NULL) { $tpl['MOVE_IN_TIME'] = 'To be determined<br />'; } else { $movein_times = HMS_Movein_Time::get_movein_times_array($this->term); $tpl['MOVE_IN_TIME'] = $movein_times[$movein_time_id]; } } //get the assignees to the room that the bed that the assignment is in $assignees = !is_null($assignment) ? $assignment->get_parent()->get_parent()->get_assignees() : NULL; if (!is_null($assignees)) { foreach ($assignees as $roommate) { if ($roommate->getUsername() != $this->student->getUsername()) { $assignment = HMS_Assignment::getAssignment($roommate->getUsername(), $this->term); $assignment->loadBed(); $label = $assignment->_bed->bedroom_label; $tpl['roommate'][]['ROOMMATE'] = $roommate->getFullName() . ' - ' . $label . ' (' . $roommate->getEmailLink() . ')'; } } } else { $tpl['roommate'] = 'You do not have a roommate'; } $rlc_assignment = HMS_RLC_Assignment::checkForAssignment($this->student->getUsername(), $this->term); if ($rlc_assignment == NULL || $rlc_assignment === FALSE) { $tpl['RLC'] = "You have not been accepted to an RLC."; } else { $rlc_list = HMS_Learning_Community::getRlcList(); $tpl['RLC'] = 'You have been assigned to the ' . $rlc_list[$rlc_assignment['rlc_id']]; } $tpl['MENU_LINK'] = PHPWS_Text::secureLink('Back to Main Menu', 'hms', array('type' => 'student', 'op' => 'show_main_menu')); Layout::addPageTitle("Verify Assignment"); return PHPWS_Template::process($tpl, 'hms', 'student/verify_assignment.tpl'); }
public function execute(CommandContext $context) { $cmd = CommandFactory::getCommand('ShowMoveinTimesView'); $begin = mktime($context->get('begin_hour'), 0, 0, $context->get('begin_month'), $context->get('begin_day'), $context->get('begin_year')); $end = mktime($context->get('end_hour'), 0, 0, $context->get('end_month'), $context->get('end_day'), $context->get('end_year')); if (is_null($begin) || is_null($end) || !is_numeric($begin) || !is_numeric($end) || $end < $begin) { NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid range specified for new movein time.'); $cmd->redirect(); } $movein_time = new HMS_Movein_Time(); $movein_time->begin_timestamp = $begin; $movein_time->end_timestamp = $end; $movein_time->term = Term::getSelectedTerm(); $result = $movein_time->save(); if (!$result || PHPWS_Error::logIfError($result)) { NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error saving the move-in time.'); } else { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Move-in time saved successfully.'); } $cmd->redirect(); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'assignment_notify')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to send assignment notifications.'); } PHPWS_Core::initModClass('hms', 'Term.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); PHPWS_Core::initModClass('hms', 'HMS_Movein_Time.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); // Check if any move-in times are set for the selected term $moveinTimes = HMS_Movein_Time::get_movein_times_array(Term::getSelectedTerm()); // If the array of move-in times ONLY has the zero-th element ['None'] then it's no good // Or, of course, if the array is null or emtpy it is no good if (count($moveinTimes) <= 1 || is_null($moveinTimes) || empty($moveinTimes)) { NQ::simple('hms', hms\NotificationView::ERROR, 'There are no move-in times set for ' . Term::getPrintableSelectedTerm()); $context->goBack(); } // Keep track of floors missing move-in times $missingMovein = array(); $term = Term::getSelectedTerm(); $db = new PHPWS_DB('hms_assignment'); $db->addWhere('email_sent', 0); $db->addWhere('term', $term); $result = $db->getObjects("HMS_Assignment"); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } foreach ($result as $assignment) { //get the students real name from their asu_username $student = StudentFactory::getStudentByUsername($assignment->getUsername(), $term); //get the location of their assignment PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); $bed = new HMS_Bed($assignment->getBedId()); $room = $bed->get_parent(); $location = $bed->where_am_i() . ' - Bedroom ' . $bed->bedroom_label; // Lookup the floor and hall to make sure the // assignment notifications flag is true for this hall $floor = $room->get_parent(); $hall = $floor->get_parent(); if ($hall->assignment_notifications == 0) { continue; } // Get the student type for determining move-in time $type = $student->getType(); // Check for an accepted and confirmed RLC assignment $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $term); // If there is an assignment, make sure the student "confirmed" the rlc invite if (!is_null($rlcAssignment)) { if ($rlcAssignment->getStateName() != 'confirmed' && $rlcAssignment->getStateName() != 'selfselect-assigned') { $rlcAssignment = null; } } // Make sure this is re-initialized $moveinTimeId = null; $rlcSetMoveinTime = false; // Determine the move-in time if (!is_null($rlcAssignment)) { // If there is a 'confirmed' RLC assignment, use the RLC's move-in times $rlc = $rlcAssignment->getRlc(); if ($type == TYPE_CONTINUING) { $moveinTimeId = $rlc->getContinuingMoveinTime(); } else { if ($type == TYPE_TRANSFER) { $moveinTimeId = $rlc->getTransferMoveinTime(); } else { if ($type == TYPE_FRESHMEN) { $moveinTimeId = $rlc->getFreshmenMoveinTime(); } } } } // If there's a non-null move-in time ID at this point, then we know the RLC must have set it if (!is_null($moveinTimeId)) { $rlcSetMoveinTime = true; } // If the RLC didn't set a movein time, set it according to the floor // TODO: Find continuing students by checking the student's application term // against the term we're wending assignment notices for if (is_null($moveinTimeId)) { if ($type == TYPE_CONTINUING) { $moveinTimeId = $assignment->get_rt_movein_time_id(); } else { if ($type == TYPE_TRANSFER) { $moveinTimeId = $assignment->get_t_movein_time_id(); } else { $moveinTimeId = $assignment->get_f_movein_time_id(); } } } // Check for missing move-in times if ($moveinTimeId == NULL) { //test($assignment, 1); // Will only happen if there's no move-in time set for the floor,student type // Lets only keep a set of the floors if (!in_array($floor, $missingMovein)) { $missingMovein[] = $floor; } // Missing move-in time, so skip to the next assignment continue; } // TODO: Grab all the move-in times and index them in an array by ID so we don't have to query the DB every single time $movein_time_obj = new HMS_Movein_Time($moveinTimeId); $movein_time = $movein_time_obj->get_formatted_begin_end(); // Add a bit of text if the move-in time was for an RLC if ($rlcSetMoveinTime) { $movein_time .= ' (for the ' . $rlc->get_community_name() . ' Residential Learning Community)'; } //get the list of roommates $roommates = array(); $beds = $room->get_beds(); foreach ($beds as $bed) { $roommate = $bed->get_assignee(); if ($roommate == false || is_null($roommate) || $roommate->getUsername() == $student->getUsername()) { continue; } $roommates[] = $roommate->getFullName() . ' (' . $roommate->getUsername() . '@appstate.edu) - Bedroom ' . $bed->bedroom_label; } // Send the email HMS_Email::sendAssignmentNotice($student->getUsername(), $student->getName(), $term, $location, $roommates, $movein_time); // Mark the student as having received an email $db->reset(); $db->addWhere('asu_username', $assignment->getUsername()); $db->addWhere('term', $term); $db->addValue('email_sent', 1); $rslt = $db->update(); if (PHPWS_Error::logIfError($rslt)) { throw new DatabaseException($result->toString()); } } // Check for floors with missing move-in times. if (empty($missingMovein) || is_null($missingMovein)) { // Ther are none, so show a success message NQ::simple('hms', hms\NotificationView::SUCCESS, "Assignment notifications sent."); } else { // Show a warning for each floor that was missing a move-in time foreach ($missingMovein as $floor) { $hall = $floor->get_parent(); $text = $floor->getLink($hall->getHallName() . " floor ") . " move-in times not set."; NQ::simple('hms', hms\NotificationView::WARNING, $text); } } $context->goBack(); }
/** * * @see View::show() */ public function show() { $tpl = array(); if (!is_null($this->community)) { $tpl['COMMUNITY'] = $this->community->get_community_name(); } $form = new PHPWS_Form('add_learning_community'); $submitCommand = CommandFactory::getCommand('SaveRlc'); $submitCommand->initForm($form); $form->addText('community_name', !is_null($this->community) ? $this->community->get_community_name() : ''); $form->setClass('community_name', 'form-control'); $form->setExtra('community_name', 'autofocus'); $form->addText('abbreviation', !is_null($this->community) ? $this->community->get_abbreviation() : ''); $form->setClass('abbreviation', 'form-control'); $form->addText('capacity', !is_null($this->community) ? $this->community->get_capacity() : ''); $form->setSize('capacity', 5); $form->setClass('capacity', 'form-control'); /*** Move-in Times ***/ $moveinTimes = HMS_Movein_Time::get_movein_times_array(Term::getSelectedTerm()); $form->addDropBox('f_movein_time', $moveinTimes); $form->setLabel('f_movein_time', 'Freshmen Move-in Time'); $form->setClass('f_movein_time', 'form-control'); $form->addDropBox('t_movein_time', $moveinTimes); $form->setLabel('t_movein_time', 'Transfer Move-in Time'); $form->setClass('t_movein_time', 'form-control'); $form->addDropBox('c_movein_time', $moveinTimes); $form->setLabel('c_movein_time', 'Continuing Move-in Time'); $form->setClass('c_movein_time', 'form-control'); if (!is_null($this->community)) { $form->setMatch('f_movein_time', $this->community->getFreshmenMoveinTime()); $form->setMatch('t_movein_time', $this->community->getTransferMoveinTime()); $form->setMatch('c_movein_time', $this->community->getContinuingMoveinTime()); } $form->addText('student_types', !is_null($this->community) ? $this->community->getAllowedStudentTypes() : ''); $form->setClass('student_types', 'form-control'); $form->addText('reapplication_student_types', !is_null($this->community) ? $this->community->getAllowedReApplicationStudentTypes() : ''); $form->setClass('reapplication_student_types', 'form-control'); $form->addCheckAssoc('members_reapply', array('reapply' => 'Current Members Can Always Re-apply')); $form->setStyle('members_reapply', 'transform: scale(1.5);-webkit-transform: scale(1.5);'); // Set match on the members_reapply checkbox if (!is_null($this->community) && $this->community->getMembersReapply() == 1) { $form->setMatch('members_reapply', 'reapply'); } $form->addTextArea('freshmen_question'); $form->setLabel('freshmen_question', 'Freshmen Question:'); $form->setClass('freshmen_question', 'form-control'); $form->addTextArea('returning_question'); $form->setLabel('returning_question', 'Returning Question:'); $form->setClass('returning_question', 'form-control'); $form->addTextArea('terms_conditions'); $form->setLabel('terms_conditions', 'Terms & Conditions:'); $form->setClass('terms_conditions', 'form-control'); if (!is_null($this->community)) { $form->setValue('freshmen_question', $this->community->getFreshmenQuestion()); $form->setValue('returning_question', $this->community->getReturningQuestion()); $form->setValue('terms_conditions', $this->community->getTermsConditions()); } $form->addHidden('hide', 0); if (!is_null($this->community) && !is_null($this->community->get_id())) { $form->addHidden('id', $this->community->get_id()); } $form->addSubmit('submit', 'Save'); $form->setClass('submit', 'btn btn-primary'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); $this->setTitle("Add/Edit RLC"); return PHPWS_Template::process($tpl, 'hms', 'admin/editLearningCommunity.tpl'); }
public function show() { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'floor_view')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You are not allowed to edit or view floors.'); } javascript('jquery_ui'); $floor_num = $this->floor->getFloorNumber(); // Setup the title and color of the title bar $tpl = array(); $tpl['FLOOR_NUMBER'] = HMS_Util::ordinal($floor_num); $tpl['TERM'] = Term::getPrintableSelectedTerm(); $submitCmd = CommandFactory::getCommand('EditFloor'); $submitCmd->setFloorId($this->floor->getId()); $form = new PHPWS_Form(); $submitCmd->initForm($form); $tpl['HALL_NAME'] = $this->hall->getLink(); $tpl['NUMBER_OF_ROOMS'] = $this->floor->get_number_of_rooms(); $tpl['NUMBER_OF_BEDS'] = $this->floor->get_number_of_beds(); $tpl['NOMINAL_BEDS'] = $this->floor->countNominalBeds(); $tpl['NUMBER_OF_ASSIGNEES'] = $this->floor->get_number_of_assignees(); if (!$this->floor->isOnline()) { $tpl['OFFLINE_ATTRIB'] = 'Offline'; } $form->addDropBox('gender_type', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, COED => COED_DESC)); $form->setMatch('gender_type', $this->floor->gender_type); $form->addCssClass('gender_type', 'form-control'); $form->addCheck('is_online', 1); $form->setMatch('is_online', $this->floor->is_online); $movein_times = HMS_Movein_Time::get_movein_times_array(); $form->addDropBox('f_movein_time', $movein_times); $form->addCssClass('f_movein_time', 'form-control'); if (!isset($this->floor->f_movein_time_id)) { $form->setMatch('f_movein_time', 0); } else { $form->setMatch('f_movein_time', $this->floor->f_movein_time_id); } $form->addDropBox('t_movein_time', $movein_times); $form->addCssClass('t_movein_time', 'form-control'); if (!isset($this->floor->t_movein_time_id)) { $form->setMatch('t_movein_time', 0); } else { $form->setMatch('t_movein_time', $this->floor->t_movein_time_id); } $form->addDropBox('rt_movein_time', $movein_times); $form->addCssClass('rt_movein_time', 'form-control'); if (!isset($this->floor->rt_movein_time_id)) { $form->setMatch('rt_movein_time', 0); } else { $form->setMatch('rt_movein_time', $this->floor->rt_movein_time_id); } // Get a list of the RLCs indexed by id PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php'); $learning_communities = RlcFactory::getRlcList($this->floor->getTerm()); $learning_communities[0] = 'None'; $form->addDropBox('floor_rlc_id', $learning_communities); $form->addCssClass('floor_rlc_id', 'form-control'); if (isset($this->floor->rlc_id)) { $tpl['RLC_NAME'] = $learning_communities[$this->floor->rlc_id]; $form->setMatch('floor_rlc_id', $this->floor->rlc_id); } else { $form->setMatch('floor_rlc_id', 0); } PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); if (isset($this->floor->floor_plan_image_id)) { $manager = Cabinet::fileManager('floor_plan_image_id', $this->floor->floor_plan_image_id); } else { $manager = Cabinet::fileManager('floor_plan_image_id'); } $manager->maxImageWidth(300); $manager->maxImageHeight(300); $manager->imageOnly(false, false); $form->addTplTag('FILE_MANAGER', $manager->get()); $form->addHidden('type', 'floor'); $form->addHidden('op', 'edit_floor'); $tpl['STATIC_ROOM_PAGER'] = HMS_Room::room_pager_by_floor($this->floor->id); $tpl['DYNAMIC_ROOM_PAGER'] = HMS_Room::room_pager_by_floor($this->floor->id, true); // if the user has permission to view the form but not edit it then // disable it if (Current_User::allow('hms', 'floor_view') && !Current_User::allow('hms', 'floor_attributes') && !Current_User::allow('hms', 'floor_structure')) { $form_vars = get_object_vars($form); $elements = $form_vars['_elements']; foreach ($elements as $element => $value) { $form->setDisabled($element); } } $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); if (Current_User::allow('hms', 'edit_role_members')) { javascript('modules/hms/role_editor'); $tpl['ROLE_EDITOR'] = PHPWS_Template::process(array('CLASS_NAME' => "'HMS_Floor'", 'ID' => $this->floor->id), 'hms', 'admin/role_editor.tpl'); } Layout::addPageTitle("Edit Floor"); return PHPWS_Template::process($tpl, 'hms', 'admin/edit_floor.tpl'); }