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
5 changes: 5 additions & 0 deletions class/FakeSoapTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,9 @@ public function getBannerIdByBuildingRoom($building, $room, $term)
return null;
}

public function addRoomDamageToStudentAccount($bannerId, $term, $amount, $damageDescription)
{
return true;
}

}
15 changes: 15 additions & 0 deletions class/RlcApplicationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,19 @@ public static function getApplication(Student $student, $term)

return $stmt->fetch();
}

public static function getApplicationById($id, $term)
{
$db = PdoFactory::getPdoInstance();

$query = "SELECT * FROM hms_learning_community_applications where id = :id and term = :term";

$stmt = $db->prepare($query);
$stmt->execute(array('id' => $id,
'term' => $term));

$stmt->setFetchMode(PDO::FETCH_CLASS, 'RlcApplicationRestored');

return $stmt->fetch();
}
}
111 changes: 0 additions & 111 deletions class/RlcAssignmentView.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,119 +35,8 @@ public function show()
{
$tags = array();
$tags['TERM'] = Term::toString(Term::getSelectedTerm());
$tags['FILTERS'] = $this->getFilters();
$tags['ASSIGNMENTS_PAGER'] = $this->rlcApplicationPager();

$exportForm = new PHPWS_Form('export_form');
$exportCmd = CommandFactory::getCommand('ExportRlcApps');
$exportCmd->initForm($exportForm);

$exportForm->addDropBox('rlc_list', HMS_Learning_Community::getRlcList());
$exportForm->setClass('rlc_list', 'form-control');
$exportForm->addSubmit('submit', 'Export');
$exportForm->setClass('submit', 'btn btn-primary');

$exportForm->mergeTemplate($tags);
$tags = $exportForm->getTemplate();

return PHPWS_Template::process($tags, 'hms', 'admin/make_new_rlc_assignments.tpl');
}

/**
* Generates a template for the rlc sort dropdown box
*
* @return string HTML for community selector drop down
*/
public function getFilters()
{
javascript('jquery');
javascript('modules/hms/page_refresh');

// Get the list of communities
$communities = RlcFactory::getRlcList($this->term);

$communityList = array('0' => 'All');

foreach ($communities as $key => $val) {
$communityList[$key] = $val;
}

// Initialize form and submit command
$submitCmd = CommandFactory::getCommand('ShowAssignRlcApplicants');
$form = new PHPWS_Form('dropdown_selector');
$submitCmd->initForm($form);
$form->setMethod('get');


// Community drop down
$form->addSelect('rlc', $communityList);
if (isset($this->rlc) && !is_null($this->rlc)) {
$form->setMatch('rlc', $this->rlc->getId());
}
$form->setClass('rlc', 'form-control');
$form->setExtra('rlc', 'onChange="refresh_page(\'dropdown_selector\')"');


// Student Type drop down
$form->addSelect('student_type', array(0 => 'All', TYPE_CONTINUING => 'Continuing', TYPE_FRESHMEN => 'Freshmen'));
if (isset($this->studentType)) {
$form->setMatch('student_type', $this->studentType);
}
$form->setClass('student_type', 'form-control');
$form->setExtra('student_type', 'onChange="refresh_page(\'dropdown_selector\')"');

return PHPWS_Template::process($form->getTemplate(), 'hms', 'admin/rlcApplicationListFilters.tpl');
}

/**
* RLC Application pager for the RLC admin panel
*
* @return string HTML for application pager
*/
public function rlcApplicationPager()
{
PHPWS_Core::initCoreClass('DBPager.php');

$submitCmd = CommandFactory::getCommand('AssignRlcApplicants');
$form = new PHPWS_Form;
$submitCmd->initForm($form);
$form->addSubmit('submit', 'Submit Changes');
$form->setClass('submit', 'btn btn-primary');
$tags = $form->getTemplate();

$pager = new DBPager('hms_learning_community_applications', 'HMS_RLC_Application');
$pager->db->addColumn('hms_learning_community_applications.*');

$pager->db->addJoin('LEFT OUTER', 'hms_learning_community_applications', 'hms_learning_community_assignment', 'id', 'application_id');
$pager->db->addWhere('hms_learning_community_assignment.application_id', 'NULL', '=');
$pager->db->addWhere('term', $this->term);
$pager->db->addWhere('denied', 0); // Only show non-denied applications in this pager
// If community filter is set, use it
if (isset($this->rlc)) {
$pager->db->addWhere('hms_learning_community_applications.rlc_first_choice_id', $this->rlc->getId(), '=');
}

// If student type filter is set, use it
if (isset($this->studentType)) {
if ($this->studentType == TYPE_FRESHMEN) {
$pager->db->addWhere('hms_learning_community_applications.application_type', 'freshmen');
} else if ($this->studentType == TYPE_CONTINUING) {
// TODO fix this so 'returning' is consistent with 'continuing'.. really just use student types
$pager->db->addWhere('hms_learning_community_applications.application_type', 'returning');
}
}

$pager->setModule('hms');
$pager->setLink('index.php?module=hms&action=SubmitRlcAssignments');
$pager->setTemplate('admin/rlc_assignments_pager.tpl');
$pager->setEmptyMessage("No pending RLC applications.");
$pager->addPageTags($tags);
$pager->addRowTags('getAdminPagerTags');
$pager->setReportRow('applicantsReport');

Layout::addPageTitle("RLC Assignments");

return $pager->get();
}

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

class AjaxDenyRlcApplicationCommand extends Command {

private $applicationId;

public function setApplicationId($id){
$this->applicationId = $id;
}

public function getRequestVars(){
return array('action'=>'AjaxDenyRlcApplication', 'applicationId'=>$this->applicationId);
}

public function execute(CommandContext $context)
{
if(!Current_User::allow('hms', 'approve_rlc_applications')){
echo json_encode(array('success' => false,
'message' => 'You do not have permission to approve/deny RLC applications.'
));
exit;
}

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

$app = HMS_RLC_Application::getApplicationById($context->get('applicationId'));
$app->denied = 1;
$app->save();

PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
HMS_Activity_Log::log_activity($app->username, 28, Current_User::getUsername(), 'Application Denied');

echo json_encode(array('success' => true,
'message' => 'Successfully denied application'
));
exit;
}
}
35 changes: 35 additions & 0 deletions class/command/AjaxGetCommunitiesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

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

class AjaxGetCommunitiesCommand extends Command {

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

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

$term = Term::getSelectedTerm();

$communities = RlcFactory::getRlcList($term);

$keys = array_keys($communities);

$communityNodes = array();


foreach($keys as $cId)
{
$communityName = $communities[$cId];
$node = array('cId' => $cId,
'cName' => $communityName);
$communityNodes[] = $node;
}

echo json_encode($communityNodes);
exit;
}
}
130 changes: 130 additions & 0 deletions class/command/AjaxGetRLCApplicantsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php

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

/**
* Handles retrieving the Rlc Applicants for a given set of filters.
* @package hms
* @author Chris Detsch
*
*/

class AjaxGetRLCApplicantsCommand extends Command {

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

public function execute(CommandContext $context)
{
$studentTypeFilter = $context->get('studentTypeFilter');
$communityFilter = $context->get('communityFilter');
$firstChoice = filter_var($context->get('firstChoice'), FILTER_VALIDATE_BOOLEAN);
$secondChoice = filter_var($context->get('secondChoice'), FILTER_VALIDATE_BOOLEAN);
$thirdChoice = filter_var($context->get('thirdChoice'), FILTER_VALIDATE_BOOLEAN);
$term = Term::getSelectedTerm();

$db = PdoFactory::getPdoInstance();

$query = "SELECT hms_learning_community_applications.id,
hms_learning_community_applications.username,
hms_learning_community_applications.date_submitted,
hms_learning_community_applications.rlc_first_choice_id,
hms_learning_community_applications.rlc_second_choice_id,
hms_learning_community_applications.rlc_third_choice_id
FROM hms_learning_community_applications
LEFT OUTER JOIN hms_learning_community_assignment
ON hms_learning_community_applications.id = hms_learning_community_assignment.application_id
WHERE hms_learning_community_assignment.application_id IS NULL
AND hms_learning_community_applications.term = :term
AND hms_learning_community_applications.denied = 0";

$params = array('term' => $term);

if($communityFilter != 0)
{
$query .= " AND (";

if($firstChoice) // Default to first choice
{
$query .= "hms_learning_community_applications.rlc_first_choice_id = :rlc";
if($secondChoice || $thirdChoice)
{
$query .= " OR ";
}
}
if($secondChoice)
{

$query .= "hms_learning_community_applications.rlc_second_choice_id = :rlc";
if($thirdChoice)
{
$query .= " OR ";
}
}
if($thirdChoice)
{
$query .= "hms_learning_community_applications.rlc_third_choice_id = :rlc";
}

if(!($firstChoice || $secondChoice || $thirdChoice))
{
$query .= "hms_learning_community_applications.rlc_first_choice_id = :rlc
OR hms_learning_community_applications.rlc_second_choice_id = :rlc
OR hms_learning_community_applications.rlc_third_choice_id = :rlc";
}

$query .= ")";

$params['rlc'] = $communityFilter;
}

if($studentTypeFilter != '0')
{
if ($studentTypeFilter == TYPE_FRESHMEN) {
$params['sType'] = "freshmen";
} else if ($studentTypeFilter == TYPE_CONTINUING) {
$params['sType'] = "returning";
}

$query .= " AND hms_learning_community_applications.application_type = :sType";
}


$stmt = $db->prepare($query);
$stmt->execute($params);

$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

$output = array();
$communities = RlcFactory::getRlcList($term);

foreach ($results as $applicant)
{
$node = array();
$student = StudentFactory::getStudentByUsername($applicant['username'], $term);
$node['app_id'] = $applicant['id'];
$node['first_name'] = $student->getFirstName();
$node['last_name'] = $student->getLastName();
$node['name'] = $student->getName();
$node['bannerId'] = $student->getBannerId();
$node['first_choice'] = $communities[$applicant['rlc_first_choice_id']];
if(isset($applicant['rlc_second_choice_id']))
{
$node['second_choice'] = $communities[$applicant['rlc_second_choice_id']];
if(isset($applicant['rlc_third_choice_id']))
{
$node['third_choice'] = $communities[$applicant['rlc_third_choice_id']];
}
}
$node['gender'] = $student->getGender() ? 'Male':'Female';
$node['app_date'] = date('d-M-y', $applicant['date_submitted']);
$node['unix_date'] = $applicant['date_submitted'];
$output[] = $node;
}

echo json_encode($output);
exit;
}
}
Loading