Пример #1
0
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'floor_view')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit floors.');
     }
     // Check for a hall ID
     $floorId = $context->get('floor');
     if (!isset($floorId)) {
         throw new InvalidArgumentException('Missing floor ID.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
     PHPWS_Core::initModClass('hms', 'FloorView.php');
     $floor = new HMS_Floor($floorId);
     if ($floor->term != Term::getSelectedTerm()) {
         $floorCmd = CommandFactory::getCommand('SelectFloor');
         $floorCmd->setTitle('Edit a Floor');
         $floorCmd->setOnSelectCmd(CommandFactory::getCommand('EditFloorView'));
         $floorCmd->redirect();
     }
     $hall = $floor->get_parent();
     $floorView = new FloorView($hall, $floor);
     $context->setContent($floorView->show());
 }
Пример #2
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'room_structure')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to add a room.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     PHPWS_Core::initModClass('hms', 'AddRoomView.php');
     $floor_id = $context->get('floor');
     $tpl = array();
     # Setup the title and color of the title bar
     $tpl['TITLE'] = 'Add Room';
     # Check to make sure we have a floor and hall.
     $floor = new HMS_Floor($floor_id);
     if (!$floor) {
         $tpl['ERROR_MSG'] = 'There was an error getting the floor object. Please contact ESS.';
         return PHPWS_Template::process($tpl, 'hms', 'admin/add_room.tpl');
     }
     $hall = $floor->get_parent();
     if (!$hall) {
         $tpl['ERROR_MSG'] = 'There was an error getting the hall object. Please contact ESS.';
         return PHPWS_Template::process($tpl, 'hms', 'admin/add_room.tpl');
     }
     # Check Permissions
     if (!Current_User::allow('hms', 'room_structure')) {
         HMS_Floor::show_edit_floor($floor_id, NULL, 'You do not have permission to add rooms.');
     }
     $view = new AddRoomView($floor);
     $context->setContent($view->show());
 }
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     $tpl = array();
     $template = new PHPWS_Template('hms');
     $template->setFile('admin/review_hall_email.tpl');
     if (is_array($this->floors)) {
         foreach ($this->floors as $floorId) {
             $floor = new HMS_Floor();
             $floor->id = $floorId;
             $floor->load();
             $floor->loadHall();
             $tpl['halls'][$floor->_hall->getHallName()][] = 'Floor ' . $floor->getFloorNumber();
         }
     } else {
         $floor = new HMS_Floor();
         $floor->id = $this->floors;
         $floor->load();
         $floor->loadHall();
         $tpl['halls'][$floor->_hall->getHallName()][] = 'Floor ' . $floor->getFloorNumber();
     }
     $tpl['FROM'] = $this->anonymous && Current_User::allow('hms', 'anonymous_notifications') ? FROM_ADDRESS : Current_User::getUsername() . '@' . DOMAIN_NAME;
     $tpl['SUBJECT'] = $this->subject;
     $tpl['BODY'] = preg_replace('/\\n/', '<br />', $this->body);
     $editCmd = CommandFactory::getCommand('ShowHallNotificationEdit');
     $tpl['EDIT_URI'] = $editCmd->getUri();
     /*
     $form->addHidden('anonymous',   isset($this->anonymous) ? $this->anonymous : '');
     $form->addHidden('subject',     $this->subject);
     $form->addHidden('body',        $this->body);
     $form->addHidden('hall',        $this->halls);
     $form->addHidden('floor',       $this->floors);
     $form->addSubmit('back',        'Edit Message');
     */
     $form2 = new PHPWS_Form('review_email');
     $sendCmd = CommandFactory::getCommand('SendNotificationEmails');
     $sendCmd->initForm($form2);
     $form2->addHidden('anonymous', isset($this->anonymous) ? $this->anonymous : '');
     $form2->addHidden('subject', $this->subject);
     $form2->addHidden('body', $this->body);
     $form2->addHidden('hall', $this->halls);
     $form2->addHidden('floor', $this->floors);
     foreach ($tpl['halls'] as $hall => $floors) {
         foreach ($floors as $floor) {
             $template->setCurrentBlock('floors');
             $template->setData(array("FLOOR" => $floor));
             $template->parseCurrentBlock();
         }
         $template->setCurrentBlock('halls');
         $template->setData(array("HALL" => $hall));
         $template->parseCurrentBlock();
     }
     $form2->mergeTemplate($tpl);
     $tpl = $form2->getTemplate();
     $template->setCurrentBlock('remainder');
     $template->setData($tpl);
     $template->parseCurrentBlock();
     return $template->get();
 }
 public function execute(CommandContext $context)
 {
     $term = Term::getCurrentTerm();
     // Get the list of role memberships this user has
     // NB: This gets memberships for all terms.. must filter later
     $hms_perm = new HMS_Permission();
     $memberships = $hms_perm->getMembership('room_change_approve', NULL, UserStatus::getUsername());
     // Use the roles to instantiate a list of floors this user has access to
     $floors = array();
     foreach ($memberships as $member) {
         if ($member['class'] == 'hms_residence_hall') {
             $hall = new HMS_Residence_Hall($member['instance']);
             // Filter out halls that aren't in the current term
             if ($hall->getTerm() != $term) {
                 continue;
             }
             $floors = array_merge($floors, $hall->getFloors());
         } else {
             if ($member['class'] == 'hms_floor') {
                 $f = new HMS_Floor($member['instance']);
                 // Filter out floors that aren't in the current term
                 if ($f->getTerm() != $term) {
                     continue;
                 }
                 $floors[] = $f;
             } else {
                 throw new Exception('Unknown object type.');
             }
         }
     }
     if (empty($floors)) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         NQ::simple('hms', hms\NotificationView::ERROR, "You do not have the 'RD' role on any residence halls or floors.");
         $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu');
         $cmd->redirect();
     }
     // Remove duplicate floors
     $uniqueFloors = array();
     foreach ($floors as $floor) {
         $uniqueFloors[$floor->getId()] = $floor;
     }
     // Use the list of floors to get a unique list of hall names
     $hallNames = array();
     foreach ($uniqueFloors as $floor) {
         $hall = $floor->get_parent();
         $hallNames[$hall->getId()] = $hall->getHallName();
     }
     // Get the set of room changes which are not complete based on the floor list
     $needsApprovalChanges = RoomChangeRequestFactory::getRoomChangesNeedsApproval($term, $uniqueFloors);
     $approvedChanges = RoomChangeRequestFactory::getRoomChangesByFloor($term, $uniqueFloors, array('Approved'));
     $allPendingChanges = RoomChangeRequestFactory::getRoomChangesByFloor($term, $uniqueFloors, array('Pending', 'Hold'));
     $completedChanges = RoomChangeRequestFactory::getRoomChangesByFloor($term, $uniqueFloors, array('Complete'));
     $inactiveChanges = RoomChangeRequestFactory::getRoomChangesByFloor($term, $uniqueFloors, array('Cancelled', 'Denied'));
     $view = new RoomChangeApprovalView($needsApprovalChanges, $approvedChanges, $allPendingChanges, $completedChanges, $inactiveChanges, $hallNames, $term);
     $context->setContent($view->show());
 }
Пример #5
0
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
     $floor = new HMS_Floor($this->floorId);
     $tpl = array();
     $tpl['HALL_FLOOR'] = $floor->where_am_i();
     if (isset($floor->floor_plan_image_id) && $floor->floor_plan_image_id != 0) {
         $file = Cabinet::getFile($floor->floor_plan_image_id);
         //if the image loaded properly
         if ($file->id == $floor->floor_plan_image_id) {
             $tpl['FLOOR_PLAN_IMAGE'] = $file->parentLinked();
         }
     }
     if ($this->rlcAssignment != null && ($this->rlcAssignment->getStateName() == 'confirmed' || $this->rlcAssignment->getStateName() == 'selfselect-invite')) {
         $rlcId = $this->rlcAssignment->getRlc()->getId();
     } else {
         $rlcId = null;
     }
     $rooms = $floor->get_rooms();
     $tpl['room_list'] = array();
     foreach ($rooms as $room) {
         $row = array();
         $num_avail_beds = $room->count_avail_lottery_beds();
         // We list the room dispite whether it's actually available to choose or not,
         // so decide whether to "gray out" this row in the room list or not
         if ($room->gender_type != $this->student->getGender() && $room->gender_type != AUTO || $num_avail_beds == 0 || $room->reserved == 1 || $room->offline == 1 || $room->private == 1 || $room->overflow == 1 || $room->parlor == 1 || $room->getReservedRlcId() != $rlcId) {
             // Show a grayed out row and no link
             $row['ROOM_NUM'] = $room->room_number;
             $row['ROW_TEXT_COLOR'] = 'text-muted';
             $row['AVAIL_BEDS'] = 0;
             // show 0 available beds since this room is unavailable to the user
         } else {
             // Show the room number as a link
             $roomCmd = CommandFactory::getCommand('LotteryChooseRoom');
             $roomCmd->setRoomId($room->id);
             $row['ROOM_NUM'] = $roomCmd->getLink($room->room_number);
             $row['ROW_TEXT_COLOR'] = 'black';
             $row['AVAIL_BEDS'] = $num_avail_beds;
         }
         if ($room->isADA()) {
             $row['ADA'] = '<i class="fa fa-wheelchair" title="ADA Compliant"></i>';
         }
         if ($room->isHearingImpaired()) {
             $row['HEARING_IMPAIRED'] = '<i class="fa fa-bell-slash" title="Equiped for Hearing Impaired"></i>';
         }
         if ($room->bathEnSuite()) {
             $row['BATH_EN_SUITE'] = '<i class="fa fa-female" title="Bathroom en Suite">|</i><i class="fa fa-male" title="Bathroom en Suite"></i>';
         }
         $row['NUM_BEDS'] = $room->get_number_of_beds();
         $tpl['room_list'][] = $row;
     }
     Layout::addPageTitle("Lottery Choose Room");
     return PHPWS_Template::process($tpl, 'hms', 'student/lottery_choose_room.tpl');
 }
Пример #6
0
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     //TODO check for a hallId
     $floor = new HMS_Floor($context->get('floorId'));
     $rooms = $floor->get_rooms();
     $json_rooms = array();
     $json_rooms[0] = 'Select...';
     foreach ($rooms as $room) {
         $json_rooms[$room->id] = $room->room_number;
     }
     $context->setContent(json_encode($json_rooms));
 }
 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     //TODO check for a floorId
     $floor = new HMS_Floor($context->get('floorId'));
     $rooms = $floor->getRoomsWithVacancies();
     $json_rooms = array();
     $json_rooms[0] = 'Select ...';
     foreach ($rooms as $room) {
         unset($text);
         $text = $room->room_number;
         if ($floor->gender_type == COED) {
             $text .= ' (' . HMS_Util::formatGender($room->gender_type) . ')';
         }
         if ($room->ra == 1) {
             $text .= ' (RA)';
         }
         $json_rooms[$room->id] = $text;
     }
     $context->setContent(json_encode($json_rooms));
 }
Пример #8
0
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'room_structure')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to add a room.');
     }
     $floor_id = $context->get('floor');
     $room = new HMS_Room();
     $room->floor_id = $floor_id;
     $room->room_number = $context->get('room_number');
     $room->gender_type = $context->get('gender_type');
     $room->default_gender = $context->get('default_gender');
     $room->ra = !is_null($context->get('ra')) ? 1 : 0;
     $room->private = !is_null($context->get('private')) ? 1 : 0;
     $room->overflow = !is_null($context->get('overflow')) ? 1 : 0;
     $room->reserved = !is_null($context->get('reserved')) ? 1 : 0;
     $room->offline = !is_null($context->get('offline')) ? 1 : 0;
     $room->parlor = !is_null($context->get('parlor')) ? 1 : 0;
     $room->ada = !is_null($context->get('ada')) ? 1 : 0;
     $room->hearing_impaired = !is_null($context->get('hearing_impaired')) ? 1 : 0;
     $room->bath_en_suite = !is_null($context->get('bath_en_suite')) ? 1 : 0;
     $rlcId = $context->get('rlc_reserved');
     $room->reserved_rlc_id = !is_null($rlcId) ? $rlcId : null;
     $room->term = Term::getSelectedTerm();
     // Get the building code
     $floor = new HMS_Floor($floor_id);
     $hall = $floor->get_parent();
     // and set the rooms building code to the same as the hall it is in
     $room->banner_building_code = $hall->banner_building_code;
     // creates a persistent_id for the new room
     $room->persistent_id = uniqid();
     $room->save();
     $cmd = CommandFactory::getCommand('EditRoomView');
     $cmd->setRoomId($room->getId());
     $cmd->redirect();
 }
Пример #9
0
 public function getCountsForFloor(HMS_Floor $floor)
 {
     return $this->floorCounts[$floor->getId()];
 }
Пример #10
0
 public function show()
 {
     if (!UserStatus::isAdmin()) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You are not allowed to view residence halls');
     }
     javascript('jquery_ui');
     $tpl = array();
     # Setup the title and color of the title bar
     $tpl['TITLE'] = $this->hall->getHallName();
     $tpl['TERM'] = Term::getPrintableSelectedTerm();
     if (!$this->hall->isOnline()) {
         $tpl['OFFLINE'] = '';
     }
     $submitCmd = CommandFactory::getCommand('EditResidenceHall');
     $submitCmd->setHallId($this->hall->getId());
     $form = new PHPWS_Form();
     $submitCmd->initForm($form);
     // This is unused, as far as I can tell, so comment it out for now.
     //$form->addHidden('beds_per_room', $this->hall->count_beds_per_room()); // add a hidden field for beds per room
     $form->addText('hall_name', $this->hall->hall_name);
     $form->addCssClass('hall_name', 'form-control');
     $tpl['NUMBER_OF_FLOORS'] = $this->hall->get_number_of_floors();
     $tpl['NUMBER_OF_ROOMS'] = $this->hall->get_number_of_rooms();
     $tpl['NUMBER_OF_BEDS'] = $this->hall->get_number_of_beds();
     $tpl['NUMBER_OF_BEDS_ONLINE'] = $this->hall->get_number_of_online_nonoverflow_beds();
     $tpl['NUMBER_OF_ASSIGNEES'] = $this->hall->get_number_of_assignees();
     $form->addDropBox('gender_type', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, COED => COED_DESC));
     $form->setMatch('gender_type', $this->hall->gender_type);
     $form->addCssClass('gender_type', 'form-control');
     $form->addCheckBox('air_conditioned', 1);
     $form->setMatch('air_conditioned', $this->hall->air_conditioned);
     $form->addCheckBox('is_online', 1);
     $form->setMatch('is_online', $this->hall->is_online);
     $form->addCheckBox('meal_plan_required', 1);
     $form->setMatch('meal_plan_required', $this->hall->meal_plan_required);
     $form->addCheckBox('assignment_notifications', 1);
     $form->setMatch('assignment_notifications', $this->hall->assignment_notifications);
     // Package Desks
     //PHPWS_Core::initModClass('hms', 'PackageDeskFactory.php');
     //$packageDesks = PackageDeskFactory::getPackageDesksAssoc();
     //$form->addDropBox('package_desk', $packageDesks);
     //$form->setMatch('package_desk', $this->hall->getPackageDeskId());
     // Images
     PHPWS_Core::initModClass('filecabinet', 'Cabinet.php');
     if (isset($this->hall->exterior_image_id)) {
         $manager = Cabinet::fileManager('exterior_image_id', $this->hall->exterior_image_id);
     } else {
         $manager = Cabinet::fileManager('exterior_image_id');
     }
     $manager->maxImageWidth(300);
     $manager->MaxImageHeight(300);
     $manager->imageOnly(false, false);
     $form->addTplTag('EXTERIOR_IMG', $manager->get());
     if (isset($this->hall->other_image_id)) {
         $manager = Cabinet::fileManager('other_image_id', $this->hall->other_image_id);
     } else {
         $manager = Cabinet::fileManager('other_image_id');
     }
     $manager->maxImageWidth(300);
     $manager->MaxImageHeight(300);
     $manager->imageOnly(false, false);
     $form->addTplTag('OTHER_IMG', $manager->get());
     if (isset($this->hall->map_image_id)) {
         $manager = Cabinet::fileManager('map_image_id', $this->hall->map_image_id);
     } else {
         $manager = Cabinet::fileManager('map_image_id');
     }
     $manager->maxImageWidth(300);
     $manager->MaxImageHeight(300);
     $manager->imageOnly(false, false);
     $form->addTplTag('MAP_IMG', $manager->get());
     if (isset($this->hall->room_plan_image_id)) {
         $manager = Cabinet::fileManager('room_plan_image_id', $this->hall->room_plan_image_id);
     } else {
         $manager = Cabinet::fileManager('room_plan_image_id');
     }
     $manager->maxImageWidth(300);
     $manager->MaxImageHeight(300);
     $manager->imageOnly(false, false);
     $form->addTplTag('ROOM_PLAN_IMG', $manager->get());
     # if the user has permission to view the form but not edit it then
     # disable it
     if (Current_User::allow('hms', 'hall_view') && !Current_User::allow('hms', 'hall_attributes') && !Current_User::allow('hms', 'hall_structure')) {
         $form_vars = (array) $form;
         $elements = $form_vars["PHPWS_Form_elements"];
         //NB: this is a weird results of casting the object to an array
         foreach ($elements as $element => $value) {
             $form->setDisabled($element);
         }
     }
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     $tpl['FLOOR_PAGER'] = HMS_Floor::get_pager_by_hall($this->hall->getId());
     javascript('modules/hms/role_editor');
     $tpl['ROLE_EDITOR'] = PHPWS_Template::process(array('CLASS_NAME' => "'HMS_Residence_Hall'", 'ID' => $this->hall->id), 'hms', 'admin/role_editor.tpl');
     Layout::addPageTitle("Edit Residence Hall");
     return PHPWS_Template::process($tpl, 'hms', 'admin/edit_residence_hall.tpl');
 }
Пример #11
0
 public function __construct(HMS_Floor $floor)
 {
     $this->floor = $floor;
     $this->hall = $floor->get_parent();
 }
Пример #12
0
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'floor_attributes')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit floors.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
     $floorId = $context->get('floorId');
     $viewCmd = CommandFactory::getCommand('EditFloorView');
     $viewCmd->setFloorId($floorId);
     // Create the floor object gien the floor id
     $floor = new HMS_Floor($floorId);
     if (!$floor) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid floor.');
         $viewCmd->redirect();
     }
     if ($context->get('tab') == 'settings') {
         // Compare the floor's gender and the gender the user selected
         // If they're not equal, call 'can_change_gender' public function
         if ($floor->gender_type != $context->get('gender_type')) {
             if (!$floor->can_change_gender($context->get('gender_type'))) {
                 NQ::simple('hms', hms\NotificationView::ERROR, 'Incompatible gender detected. No changes were made.');
                 $viewCmd->redirect();
             }
         }
         // Grab all the input from the form and save the floor
         $floor->gender_type = $context->get('gender_type');
         $context->setDefault('is_online', 0);
         $floor->is_online = $context->get('is_online');
         if ($context->get('f_movein_time') == 0) {
             $floor->f_movein_time_id = NULL;
         } else {
             $floor->f_movein_time_id = $context->get('f_movein_time');
         }
         if ($context->get('t_movein_time') == 0) {
             $floor->t_movein_time_id = NULL;
         } else {
             $floor->t_movein_time_id = $context->get('t_movein_time');
         }
         if ($context->get('rt_movein_time') == 0) {
             $floor->rt_movein_time_id = NULL;
         } else {
             $floor->rt_movein_time_id = $context->get('rt_movein_time');
         }
         if ($context->get('floor_rlc_id') == 0) {
             $floor->rlc_id = NULL;
         } else {
             $floor->rlc_id = $context->get('floor_rlc_id');
         }
     } else {
         if ($context->get('tab') == 'images') {
             $floor->floor_plan_image_id = $context->get('floor_plan_image_id');
         }
     }
     try {
         $floor->save();
     } catch (DatabaseException $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There was a problem saving the floor data. No changes were made.');
         $viewCmd->redirect();
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'The floor was updated successfully.');
     $viewCmd->redirect();
 }
Пример #13
0
 public function create_child_objects($num_floors, $rooms_per_floor, $beds_per_room)
 {
     if (!$this->id) {
         return false;
     }
     for ($i = 0; $i < $num_floors; $i++) {
         $floor = new HMS_Floor();
         $floor->residence_hall_id = $this->id;
         $floor->term = $this->term;
         $floor->gender_type = $this->gender_type;
         if ($floor->save()) {
             $floor->create_child_objects($rooms_per_floor, $beds_per_room);
         } else {
             // Decide on bed result.
         }
     }
 }