Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 9 additions & 98 deletions class/AssignStudentView.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function show()

javascript('jquery');
javascript('modules/hms/assign_student');
javascriptMod('hms', 'student_assign');

$tpl = array();
$tpl['TERM'] = Term::getPrintableSelectedTerm();
Expand Down Expand Up @@ -78,112 +79,22 @@ public function show()

$hallList = HMS_Residence_Hall::getHallsWithVacanciesArray(Term::getSelectedTerm());

$form->addDropBox('residence_hall', $hallList);

if ($pre_populate) {
$form->setMatch('residence_hall', $hall->id);
} else {
$form->setMatch('residence_hall', 0);
}
$form->setLabel('residence_hall', 'Residence hall: ');
$form->addCssClass('residence_hall', 'form-control');

if ($pre_populate) {
$form->addDropBox('floor', $hall->get_floors_array());
$form->setMatch('floor', $floor->id);
} else {
$form->addDropBox('floor', array(0 => ''));
$prepop = array();
if($pre_populate)
{
$prepop = array('hall_id'=> $hall->id, 'floor_id' => $floor->id, 'room_id' => $room->id, 'bed_id' => $this->bed->id);
}
$form->setLabel('floor', 'Floor: ');
$form->addCssClass('floor', 'form-control');

if ($pre_populate) {
$form->addDropBox('room', $floor->get_rooms_array());
$form->setMatch('room', $room->id);
} else {
$form->addDropBox('room', array(0 => ''));
}
$form->setLabel('room', 'Room: ');
$form->addCssClass('room', 'form-control');

if ($pre_populate) {
$form->addDropBox('bed', $room->get_beds_array());
$form->setMatch('bed', $this->bed->id);
$show_bed_drop = true;
} else {
$form->addDropBox('bed', array(0 => ''));
$show_bed_drop = false;
}
$form->setLabel('bed', 'Bed: ');
$form->addCssClass('bed', 'form-control');

if ($show_bed_drop) {
$tpl['BED_STYLE'] = '';
$tpl['LINK_STYLE'] = 'display: none';
} else {
$tpl['BED_STYLE'] = 'display: none';
$tpl['LINK_STYLE'] = '';
}

$form->addDropBox('meal_plan', array(
BANNER_MEAL_LOW => 'Low',
BANNER_MEAL_STD => 'Standard',
BANNER_MEAL_HIGH => 'High',
BANNER_MEAL_SUPER => 'Super',
BANNER_MEAL_NONE => 'None',
// 4 Week Meal Plan Removed according to ticket #709
// BANNER_MEAL_4WEEK => 'Summer (4 weeks)',
BANNER_MEAL_5WEEK => 'Summer (5 weeks)'));
$form->setLabel('meal_plan', 'Meal plan: ');
$form->addCssClass('meal_plan', 'form-control');

// If the username was passed in, and that student has a meal plan
// pre-select the student's chosen meal plan
if (isset($this->application)) {
$form->setMatch('meal_plan', $this->application->getMealPlan());
$meal_plan = array('meal_plan' => $this->application->getMealPlan());
} else {
// Otherwise, select 'standard' meal plan
$form->setMatch('meal_plan', BANNER_MEAL_STD);
$meal_plan = array('meal_plan' => BANNER_MEAL_STD);
}

// "Assignment Type", see defines.php for declarations
$form->addDropBox('assignment_type', array(
-1 => 'Choose assignment type...',
ASSIGN_ADMIN => 'Administrative',
ASSIGN_APPEALS => 'Appeals',
ASSIGN_LOTTERY => 'Lottery',
ASSIGN_FR => 'Freshmen',
ASSIGN_TRANSFER => 'Transfer',
ASSIGN_APH => 'APH',
ASSIGN_RLC_FRESHMEN => 'RLC Freshmen',
ASSIGN_RLC_TRANSFER => 'RLC Transfer',
ASSIGN_RLC_CONTINUING => 'RLC Continuing',
ASSIGN_HONORS_FRESHMEN => 'Honors Freshmen',
ASSIGN_HONORS_CONTINUING => 'Honors Continuing',
ASSIGN_LLC_FRESHMEN => 'LLC Freshmen',
ASSIGN_LLC_CONTINUING => 'LLC Continuing',
ASSIGN_INTL => 'International',
ASSIGN_RA => 'RA',
ASSIGN_RA_ROOMMATE => 'RA Roommate',
ASSIGN_MEDICAL_FRESHMEN => 'Medical Freshmen',
ASSIGN_MEDICAL_CONTINUING => 'Medical Continuing',
//ASSIGN_MEDICAL => 'Medical',
ASSIGN_SPECIAL_FRESHMEN => 'Special Needs Freshmen',
ASSIGN_SEPCIAL_CONTINUING => 'Special Needs Continuing',
//ASSIGN_SPECIAL => 'Special Needs',
ASSIGN_RHA => 'RHA/NRHH',
ASSIGN_SCHOLARS => 'Diversity & Plemmons Scholars'
));

$form->setMatch('assignment_type', -1);
$form->setLabel('assignment_type', 'Assignment Type: ');
$form->addCssClass('assignment_type', 'form-control');

if ($pre_populate) {
$form->addHidden('use_bed', 'true');
} else {
$form->addHidden('use_bed', 'false');
}
$tpl['PREPOPULATE'] = json_encode($prepop);
$tpl['MEAL_PLAN'] = json_encode($meal_plan);

$form->addTextarea('note');
$form->setLabel('note', 'Note: ');
Expand Down
18 changes: 0 additions & 18 deletions class/ResidenceHallMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,6 @@ public function __construct()
$residenceHallCmd->setOnSelectCmd(CommandFactory::getCommand('EditResidenceHallView'));
$this->addCommand('Edit a residence hall', $residenceHallCmd);
}
if(Current_User::allow('hms', 'floor_view')){
$floorCmd = CommandFactory::getCommand('SelectFloor');
$floorCmd->setTitle('Edit a Floor');
$floorCmd->setOnSelectCmd(CommandFactory::getCommand('EditFloorView'));
$this->addCommand('Edit a floor', $floorCmd);
}
if(Current_User::allow('hms', 'room_view')){
$roomCmd = CommandFactory::getCommand('SelectRoom');
$roomCmd->setTitle('Edit a Room');
$roomCmd->setOnSelectCmd(CommandFactory::getCommand('EditRoomView'));
$this->addCommand('Edit a room', $roomCmd);
}
if(Current_User::allow('hms', 'bed_view')){
$bedCmd = CommandFactory::getCommand('SelectBed');
$bedCmd->setTitle('Edit a Bed');
$bedCmd->setOnSelectCmd(CommandFactory::getCommand('EditBedView'));
$this->addCommand('Edit a bed', $bedCmd);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions class/SelectHallView.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function show()
{
$tpl = array();

javascript('jquery');
javascriptMod('hms', 'hall_editor');

$tpl['TITLE'] = $this->title;
$tpl['TERM'] = Term::getPrintableSelectedTerm();

Expand Down
22 changes: 10 additions & 12 deletions class/command/AjaxGetBedsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AjaxGetBedsCommand extends Command {
private $roomId;

public function getRequestVars(){
return array('action'=>'AjaxGetFloors');
return array('action'=>'AjaxGetBeds');
}

public function execute(CommandContext $context)
Expand All @@ -19,20 +19,18 @@ public function execute(CommandContext $context)

$room = new HMS_Room($context->get('roomId'));

$beds = $room->get_beds();
$bedsResult = $room->get_beds();

$json_beds = array();
$json_beds[0] = 'Select...';
$beds = array();
$i = 0;

foreach ($beds as $bed){
if($bed->room_change_reserved != 0){
//Cannot assign to reserved rooms
continue;
}
$json_beds[$bed->id] = $bed->bed_letter;
foreach ($bedsResult as $bed)
{
$beds[$i]['bed_letter'] = strtoupper($bed->getBedroomLabel()) . $bed->getLetter();
$beds[$i]['bed_id'] = $bed->getId();
$i++;
}

$context->setContent(json_encode($json_beds));
$context->setContent(json_encode($beds));
}
}

33 changes: 14 additions & 19 deletions class/command/AjaxGetFloorsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,21 @@ public function execute(CommandContext $context)

$hall = new HMS_Residence_Hall($context->get('hallId'));

$floors = $hall->get_floors();

#test($floors, 1);

$json_floors = array();
$json_floors[0] = 'Select...';

foreach ($floors as $floor){
unset($text);

$text = $floor->floor_number;

if($hall->gender_type == COED && $floor->gender_type != COED){
$text .= (' (' . HMS_Util::formatGender($floor->gender_type) . ')');
}

$json_floors[$floor->id] = $text;
$floorsResult = $hall->getFloors();

$floors = array();
$i = 0;

foreach ($floorsResult as $floor)
{
if(!empty($floor->get_rooms()))
{
$floors[$i]['floor_number'] = $floor->getFloorNumber();
$floors[$i]['floor_id'] = $floor->getId();
$i++;
}
}

$context->setContent(json_encode($json_floors));
$context->setContent(json_encode($floors));
}
}

34 changes: 34 additions & 0 deletions class/command/AjaxGetHallsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

PHPWS_Core::initModClass('hms', 'Command.php');

class AjaxGetHallsCommand extends Command {

private $floorId;

public function getRequestVars(){
return array('action'=>'AjaxGetHalls');
}

public function execute(CommandContext $context)
{
PHPWS_Core::initModClass('hms', 'HMS_Floor.php');

$term = Term::getSelectedTerm();

$hallsResults = ResidenceHallFactory::getHallsForTerm($term);

$halls = array();

$i = 0;

foreach ($hallsResults as $hall)
{
$halls[$i]['hall_name'] = $hall->getHallName();
$halls[$i]['hall_id'] = $hall->getId();
$i++;
}

$context->setContent(json_encode($halls));
}
}
68 changes: 60 additions & 8 deletions class/command/AjaxGetRoomsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AjaxGetRoomsCommand extends Command {
private $floorId;

public function getRequestVars(){
return array('action'=>'AjaxGetFloors');
return array('action'=>'AjaxGetRooms');
}

public function execute(CommandContext $context)
Expand All @@ -19,16 +19,68 @@ public function execute(CommandContext $context)

$floor = new HMS_Floor($context->get('floorId'));

$rooms = $floor->get_rooms();
$roomsResult = $floor->get_rooms();

$json_rooms = array();
$json_rooms[0] = 'Select...';
$rooms = array();
$i = 0;

foreach ($rooms as $room){
$json_rooms[$room->id] = $room->room_number;
foreach ($roomsResult as $room)
{
$text = $room->getRoomNumber();

if($floor->gender_type == COED){
$text .= (' (' . HMS_Util::formatGender($room->gender_type) . ')');
}

if($room->ra == 1){
$text .= (' (RA)');
}

if($room->reserved == 1)
{
$text .= (' (Reserved)');
}

if($room->offline == 1)
{
$text .= (' (Offline)');
}

if($room->private == 1)
{
$text .= (' (Private)');
}

if($room->overflow == 1)
{
$text .= (' (Overflow)');
}

if($room->parlor == 1)
{
$text .= (' (Parlor)');
}

if($room->ada == 1)
{
$text .= (' (ADA)');
}

if($room->hearing_impaired == 1)
{
$text .= (' (Hearing Impaired)');
}

if($room->bath_en_suite)
{
$text .= (' (Bath En Suite)');
}

$rooms[$i]['room_number'] = $text;
$rooms[$i]['room_id'] = $room->getId();
$i++;
}

$context->setContent(json_encode($json_rooms));
$context->setContent(json_encode($rooms));
}
}

6 changes: 5 additions & 1 deletion class/command/AssignStudentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function getRequestVars()

public function execute(CommandContext $context)
{


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 assign students.');
Expand All @@ -98,10 +100,12 @@ public function execute(CommandContext $context)
// NB: Username must be all lowercase
$username = strtolower(trim($context->get('username')));
$term = Term::getSelectedTerm();
$bed = $context->get('bed');

// Setup command to redirect to in case of error
$errorCmd = CommandFactory::getCommand('ShowAssignStudent');
$errorCmd->setUsername($username);
$errorCmd->setBedId($bed);

/***
* Input Sanity Checking
Expand Down Expand Up @@ -215,7 +219,7 @@ public function execute(CommandContext $context)
}

// Actually try to make the assignment, decide whether to use the room id or the bed id
$bed = $context->get('bed');

try {
if(isset($bed) && $bed != 0){
HMS_Assignment::assignStudent($student, $term, NULL, $bed, $context->get('meal_plan'), $context->get('note'), false, $context->get('assignment_type'));
Expand Down
Loading