示例#1
0
 public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'RlcSelfSelectionMenuBlockView.php');
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm());
     $roomAssignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $this->getTerm());
     $roommateRequests = HMS_Lottery::get_lottery_roommate_invites($student->getUsername(), $this->term);
     return new RlcSelfSelectionMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $rlcAssignment, $roomAssignment, $roommateRequests);
 }
示例#2
0
 public function getMenuBlockView(Student $student)
 {
     // Get an application if one exists
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     $application = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $this->getTerm());
     // Check for an assignment
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     $assignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm());
     PHPWS_Core::initModClass('hms', 'RlcApplicationMenuView.php');
     return new RlcApplicationMenuView($this->term, $student, $this->getStartDate(), $this->getEditDate(), $this->getEndDate(), $application, $assignment);
 }
示例#3
0
 public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'ReapplicationMenuBlockView.php');
     $assignment = HMS_Assignment::getAssignment($student->getUsername(), $this->term);
     $application = HousingApplication::getApplicationByUser($student->getUsername(), $this->term);
     if (!$application instanceof LotteryApplication) {
         $application = null;
     }
     $roommateRequests = HMS_Lottery::get_lottery_roommate_invites($student->getUsername(), $this->term);
     return new ReapplicationMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $assignment, $application, $roommateRequests);
 }
示例#4
0
 public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'ApplicationMenuBlockView.php');
     $application = HousingApplication::getApplicationByUser($student->getUsername(), $this->term);
     return new ApplicationMenuBlockView($this->term, $this->getStartDate(), $this->getEditDate(), $this->getEndDate(), $application);
 }
示例#5
0
 public function showForStudent(Student $student, $term)
 {
     // for freshmen
     if ($student->getApplicationTerm() > Term::getCurrentTerm()) {
         return false;
     }
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     $application = HousingApplication::checkForApplication($student->getUsername(), $term);
     $assignment = HMS_Assignment::checkForAssignment($student->getUsername(), $term);
     // for returning students (summer terms)
     if ($term > $student->getApplicationTerm() && $assignment !== TRUE && $application !== FALSE) {
         return true;
     }
     return false;
 }
 private function populateSharedFields($term, Student $student)
 {
     $this->app->setTerm($term);
     $this->app->setBannerId($student->getBannerId());
     $this->app->setUsername($student->getUsername());
     $this->app->setGender($student->getGender());
     $this->app->setStudentType($student->getType());
     $this->app->setApplicationTerm($student->getApplicationTerm());
     $doNotCall = $this->context->get('do_not_call');
     $areaCode = $this->context->get('area_code');
     $exchange = $this->context->get('exchange');
     $number = $this->context->get('number');
     /* Phone Number */
     /*
     if(is_null($doNotCall)){
         //test('ohh hai',1);
         // do not call checkbox was not selected, so check the number
         if(is_null($areaCode) || is_null($exchange) || is_null($number)){
             throw new InvalidArgumentException('Please provide a cell-phone number or click the checkbox stating that you do not wish to share your number with us.');
         }
     }
     */
     if (is_null($doNotCall)) {
         $this->app->setCellPhone($areaCode . $exchange . $number);
     } else {
         $this->app->setCellPhone(null);
     }
     /* Meal Plan */
     $mealOption = $this->context->get('meal_option');
     if (!isset($mealOption)) {
         //throw new InvalidArgumentException('Missing meal option from context.');
     }
     $this->app->setMealPlan($mealOption);
     /* Emergency Contact */
     $this->app->setEmergencyContactName($this->context->get('emergency_contact_name'));
     $this->app->setEmergencyContactRelationship($this->context->get('emergency_contact_relationship'));
     $this->app->setEmergencyContactPhone($this->context->get('emergency_contact_phone'));
     $this->app->setEmergencyContactEmail($this->context->get('emergency_contact_email'));
     /* Missing Persons */
     $this->app->setMissingPersonName($this->context->get('missing_person_name'));
     $this->app->setMissingPersonRelationship($this->context->get('missing_person_relationship'));
     $this->app->setMissingPersonPhone($this->context->get('missing_person_phone'));
     $this->app->setMissingPersonEmail($this->context->get('missing_person_email'));
     /* Medical Conditions */
     $this->app->setEmergencyMedicalCondition($this->context->get('emergency_medical_condition'));
     /* Special Needs */
     $specialNeeds = $this->context->get('special_needs');
     isset($specialNeeds['physical_disability']) ? $this->app->setPhysicalDisability(true) : null;
     isset($specialNeeds['psych_disability']) ? $this->app->setPsychDisability(true) : null;
     isset($specialNeeds['gender_need']) ? $this->app->setGenderNeed(true) : null;
     isset($specialNeeds['medical_need']) ? $this->app->setMedicalNeed(true) : null;
     if ($student->isInternational()) {
         $this->app->setInternational(true);
     } else {
         $this->app->setInternational(false);
     }
 }
示例#7
0
 public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'RlcReapplicationMenuBlockView.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     $application = HousingApplication::getApplicationByUser($student->getUsername(), $this->term);
     if (!$application instanceof LotteryApplication) {
         $application = null;
     }
     $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $this->term);
     if (!$rlcApp instanceof HMS_RLC_Application) {
         $rlcApp = null;
     }
     // Check for an assignment
     $assignment = HMS_RLC_Assignment::getAssignmentByUsername($student->getUsername(), $this->getTerm());
     return new RlcReapplicationMenuBlockView($this->term, $this->getStartDate(), $this->getEndDate(), $application, $rlcApp, $assignment);
 }
 public static function getApplication(Student $student, $term)
 {
     $db = PdoFactory::getPdoInstance();
     $query = "SELECT * FROM hms_learning_community_applications where username = :username and term = :term";
     $stmt = $db->prepare($query);
     $stmt->execute(array('username' => $student->getUsername(), 'term' => $term));
     $stmt->setFetchMode(PDO::FETCH_CLASS, 'RlcApplicationRestored');
     return $stmt->fetch();
 }
 public static function getMembership(Student $student, $term)
 {
     $db = PdoFactory::getPdoInstance();
     $query = "select hms_learning_community_assignment.* from hms_learning_community_assignment JOIN hms_learning_community_applications ON hms_learning_community_assignment.application_id = hms_learning_community_applications.id where term = :term and username = :username;";
     $stmt = $db->prepare($query);
     $stmt->execute(array('username' => $student->getUsername(), 'term' => $term));
     $stmt->setFetchMode(PDO::FETCH_CLASS, 'RlcMembershipRestored');
     return $stmt->fetch();
 }
示例#10
0
 public function getMenuBlockView(Student $student)
 {
     PHPWS_Core::initModClass('hms', 'RoomChangeMenuBlockView.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'RoomChangeRequestFactory.php');
     $assignment = HMS_Assignment::getAssignment($student->getUsername(), $this->term);
     $request = RoomChangeRequestFactory::getPendingByStudent($student, $this->term);
     return new RoomChangeMenuBlockView($student, $this->term, $this->getStartDate(), $this->getEndDate(), $assignment, $request);
 }
示例#11
0
 public function __construct($id = null, $type = null, Student $student = null, $term = null, HMS_Residence_Hall $hall = null, HMS_Bed $bed = null, $mealPlan = null, $mealCode = null, $percentRefund = null)
 {
     if (!is_null($id) && $id != 0) {
         $this->load();
         return;
     }
     if (is_null($type)) {
         return;
     }
     $this->type = $type;
     $this->asu_username = strtolower($student->getUsername());
     $this->term = $term;
     $this->building_code = $hall->getBannerBuildingCode();
     $this->bed_code = $bed->getBannerId();
     $this->meal_plan = $mealPlan;
     $this->meal_code = $mealCode;
     $this->percent_refund = $percentRefund;
 }
 private function refreshCache(Student $student, $term)
 {
     // Store the core data
     $db = new PHPWS_DB('hms_student_cache');
     $db->addWhere('username', $student->getUsername());
     $db->addWhere('banner_id', $student->getBannerId());
     $db->addWhere('term', $term);
     $result = $db->delete();
     // Silently log any errors
     PHPWS_Error::logIfError($result);
     $db->reset();
     $student = CachedStudent::toCachedStudent($student);
     $student->save($term);
     // Silently log any errors
     PHPWS_Error::logIfError($result);
     // Store the addresses
     self::setAddresses($student);
     // Store the phone numbers
     self::setPhoneNumbers($student);
 }
示例#13
0
 /**
  * Queues a Remove Assignment
  *
  * NOTE: If the queue contains a Create Assignment for the same
  * user to the same room, this will NOT queue a room assignment,
  * but rather will delete the original assignment, UNLESS the
  * $force_queue flag is set.  The $force_queue flag being true will
  * queue a removal no matter what.
  *
  * MORE NOTE: If this requires immediate processing because banner
  * commits are enabled, the it will be sent straight to Banner,
  * and so the force_queue flag will be ignored.
  */
 public static function queueRemoveAssignment(Student $student, $term, HMS_Residence_Hall $hall, HMS_Bed $bed, $refund)
 {
     $entry = new BannerQueueItem(0, BANNER_QUEUE_REMOVAL, $student, $term, $hall, $bed, null, null, $refund);
     if (BannerQueue::processImmediately($term)) {
         return $entry->process();
     }
     // Otherwise, look for an corresponding assignment
     $db = new PHPWS_DB('hms_banner_queue');
     $db->addWhere('type', BANNER_QUEUE_ASSIGNMENT);
     $db->addWhere('asu_username', $student->getUsername());
     $db->addWhere('building_code', $hall->getBannerBuildingCode());
     $db->addWhere('bed_code', $bed->getBannerId());
     $db->addWhere('term', $term);
     $result = $db->count();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     if ($result == 0) {
         return $entry->save();
     } else {
         return $db->delete();
     }
 }
示例#14
0
 private function sendInvite(Student $student)
 {
     $this->output[] = "Inviting {$student->getUsername()} ({$student->getBannerId()})";
     // Update the winning student's invite
     try {
         $entry = HousingApplicationFactory::getAppByStudent($student, $this->term, 'lottery');
         $entry->invited_on = $this->now;
         $entry->save();
     } catch (Exception $e) {
         $this->output[] = 'Error while trying to select a winning student. Exception: ' . $e->getMessage();
         return;
     }
     // Update the total count
     $this->numInvitesSent['TOTAL']++;
     // Send the notification email
     HMS_Email::send_lottery_invite($student->getUsername(), $student->getName(), $this->academicYear);
     // Log that the invite was sent
     HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_LOTTERY_INVITED, UserStatus::getUsername(), "Expires on " . date('m/d/Y h:i:s a', $this->expireTime));
 }
示例#15
0
 public static function sendCheckoutConfirmation(Student $student, InfoCard $infoCard)
 {
     $tags = array();
     $tags['NAME'] = $student->getName();
     $tags['ASSIGNMENT'] = $infoCard->getRoom()->where_am_i();
     $content = PHPWS_Template::process($tags, 'hms', 'email/checkoutConfirmation.tpl');
     $htmlContent = Markdown::defaultTransform($content);
     $message = Swift_Message::newInstance();
     $message->setSubject('Check-out Confirmation');
     $message->setFrom(array(FROM_ADDRESS => SYSTEM_NAME));
     $message->setTo(array($student->getUsername() . TO_DOMAIN => $student->getName()));
     $message->setBody($content);
     $message->addPart($htmlContent, 'text/html');
     // Attach info card
     //$attachment = Swift_Attachment::newInstance($infoCardView->getPdf()->output('my-pdf-file.pdf', 'S'), 'ResidentInfoCard.pdf', 'application/pdf');
     //$message->attach($attachment);
     if (EMAIL_TEST_FLAG) {
         self::logSwiftmailMessageLong($message);
         return;
     }
     $transport = Swift_SmtpTransport::newInstance('localhost');
     $mailer = Swift_Mailer::newInstance($transport);
     $mailer->send($message);
 }
示例#16
0
 /**
  * Removes/unassignes a student
  *
  * Valid values for $reason are defined in defines.php.
  *
  * @param Student $student Student to un-assign.
  * @param String $term The term of the assignment to remove.
  * @param String $notes Additional notes for the ActivityLog.
  * @param String $reason Reason string, defined in defines.php
  * @param Integer $refund Percentage of original charges student should be refunded
  * @throws PermissionException
  * @throws InvalidArgumentException
  * @throws AssignmentException
  * @throws DatabaseException
  */
 public static function unassignStudent(Student $student, $term, $notes = "", $reason, $refund)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assignment_maintenance')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to unassign students.');
     }
     PHPWS_Core::initModClass('hms', 'BannerQueue.php');
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     PHPWS_Core::initModClass('hms', 'AssignmentHistory.php');
     PHPWS_Core::initModClass('hms', 'exception/AssignmentException.php');
     $username = $student->getUsername();
     // Make sure a username was entered
     if (!isset($username) || $username == '') {
         throw new InvalidArgumentException('Bad username.');
     }
     $username = strtolower($username);
     // Check refund field, required field
     if (!isset($refund) || $refund == '') {
         throw new InvalidArgumentException('Please enter a refund percentage.');
     }
     // Refund must be numeric
     if (!is_numeric($refund) || $refund < 0 || $refund > 100) {
         throw new InvalidArgumentException('The refund percentage must be between 0 and 100 percent.');
     }
     // Must be whole number
     if (is_float($refund)) {
         throw new InvalidArgumentException('Only whole number refund percentages are supported, no decimal place is allowed.');
     }
     // Make sure the requested username is actually assigned
     if (!HMS_Assignment::checkForAssignment($username, $term)) {
         throw new AssignmentException('Student is not assigned.');
     }
     $assignment = HMS_Assignment::getAssignment($username, $term);
     if ($assignment == FALSE || $assignment == NULL) {
         throw new AssignmentException('Could not load assignment object.');
     }
     $bed = $assignment->get_parent();
     $room = $bed->get_parent();
     $floor = $room->get_parent();
     $building = $floor->get_parent();
     // Attempt to unassign the student in Banner though SOAP
     $banner_result = BannerQueue::queueRemoveAssignment($student, $term, $building, $bed, $refund);
     // Show an error and return if there was an error
     if ($banner_result !== TRUE) {
         throw new AssignmentException('Error while adding the assignment removal to the Banner queue.');
     }
     // Record this before we delete from the db
     $banner_bed_id = $bed->getBannerId();
     $banner_building_code = $building->getBannerBuildingCode();
     // Attempt to delete the assignment in HMS
     $result = $assignment->delete();
     if (!$result) {
         throw new DatabaseException($result->toString());
     }
     // Log in the activity log
     HMS_Activity_Log::log_activity($username, ACTIVITY_REMOVED, UserStatus::getUsername(), $term . ' ' . $banner_building_code . ' ' . $banner_bed_id . ' ' . $notes . 'Refund: ' . $refund);
     // Insert into history table
     AssignmentHistory::makeUnassignmentHistory($assignment, $reason);
     // Generate assignment notices for old roommates
     $assignees = $room->get_assignees();
     // get an array of student objects for those assigned to this room
     if (sizeof($assignees) > 1) {
         foreach ($assignees as $roommate) {
             // Skip this student
             if ($roommate->getUsername() == $username) {
                 continue;
             }
             $roommate_assign = HMS_Assignment::getAssignment($roommate->getUsername(), Term::getSelectedTerm());
             $roommate_assign->letter_printed = 0;
             $roommate_assign->email_sent = 0;
             $roommate_assign->save();
         }
     }
     // Show a success message
     return true;
 }
示例#17
0
 /**
  * Handles removing RLC applications.
  * @param Student $student
  */
 private function handleRlcApplication(Student $student)
 {
     // Mark any RLC applications as denied
     $rlcApp = HMS_RLC_Application::getApplicationByUsername($student->getUsername(), $this->term);
     if (!is_null($rlcApp)) {
         // TODO catch/handle exceptions
         $rlcApp->delete();
         $this->actions[$student->getUsername()][] = 'Marked RLC application as denied.';
         HMS_Activity_Log::log_activity($student->getUsername(), ACTIVITY_WITHDRAWN_RLC_APP_DENIED, UserStatus::getUsername(), 'Withdrawn search');
     }
 }