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()); }
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 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(); }
public function __construct(HMS_Floor $floor) { $this->floor = $floor; $this->hall = $floor->get_parent(); }