public function execute() { PHPWS_Core::initModClass('hms', 'HousingApplication.php'); PHPWS_Core::initModClass('hms', 'HMS_Util.php'); // Select all cancelled apps for the given term $db = new PHPWS_DB('hms_new_application'); $db->addWhere('cancelled', 1); $db->addWhere('term', $this->term); $results = $db->select(); // Initialize storage for processed rows $this->rows = array(); // Get friendly cancellation reasons from HousingApplication $reasons = HousingApplication::getCancellationReasons(); // Process and store each result foreach ($results as $app) { $row = array(); $row['bannerId'] = $app['banner_id']; $row['username'] = $app['username']; $row['gender'] = HMS_Util::formatGender($app['gender']); $row['application_term'] = $app['application_term']; $row['student_type'] = $app['student_type']; $row['cancelled_reason'] = $reasons[$app['cancelled_reason']]; $row['cancelled_on'] = HMS_Util::get_long_date($app['cancelled_on']); $row['cancelled_by'] = $app['cancelled_by']; $this->rows[] = $row; } }
public function execute() { PHPWS_Core::initModClass('hms', 'HousingApplication.php'); $this->reasons = HousingApplication::getCancellationReasons(); // All students $db = new PHPWS_DB('hms_new_application'); $db->addColumn('cancelled_reason'); $db->addColumn('id', null, 'ount', true); $db->addWhere('term', $this->getTerm()); $db->addWhere('cancelled', 1); $db->addGroupBy('cancelled_reason'); $this->reasonCounts = $db->select('assoc'); // Freshmen $db = new PHPWS_DB('hms_new_application'); $db->addColumn('cancelled_reason'); $db->addColumn('id', null, 'count', true); $db->addWhere('term', $this->getTerm()); $db->addWhere('cancelled', 1); $db->addWhere('student_type', TYPE_FRESHMEN); $db->addGroupBy('cancelled_reason'); $this->freshmenReasonCounts = $db->select('assoc'); // Continuing $db = new PHPWS_DB('hms_new_application'); $db->addColumn('cancelled_reason'); $db->addColumn('id', null, 'count', true); $db->addWhere('term', $this->getTerm()); $db->addWhere('cancelled', 1); $db->addWhere('student_type', TYPE_CONTINUING); $db->addGroupBy('cancelled_reason'); $this->continuingReasonCounts = $db->select('assoc'); }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'cancel_housing_application')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to cancel housing applications.'); } // Check for a housing application id $applicationId = $context->get('applicationId'); if (!isset($applicationId) || is_null($applicationId)) { throw new InvalidArgumentException('Missing housing application id.'); } // Check for a cancellation reason $cancelReason = $context->get('cancel_reason'); if (!isset($cancelReason) || is_null($cancelReason)) { throw new InvalidArgumentException('Missing cancellation reason.'); } // Load the housing application PHPWS_Core::initModClass('hms', 'HousingApplicationFactory.php'); $application = HousingApplicationFactory::getApplicationById($applicationId); // Load the student $student = $application->getStudent(); $username = $student->getUsername(); $term = $application->getTerm(); // Load the cancellation reasons $reasons = HousingApplication::getCancellationReasons(); // Check for an assignment and remove it // Decide which term to use - If this application is in a past fall term, then use the current term if ($term < Term::getCurrentTerm() && Term::getTermSem($term) == TERM_FALL) { $assignmentTerm = Term::getCurrentTerm(); } else { $assignmentTerm = $term; } PHPWS_Core::initModClass('hms', 'HMS_Assignment.php'); $assignment = HMS_Assignment::getAssignmentByBannerId($student->getBannerId(), $assignmentTerm); if (isset($assignment)) { // TODO: Don't hard code cancellation refund percentage HMS_Assignment::unassignStudent($student, $assignmentTerm, 'Application cancellation: ' . $reasons[$cancelReason], UNASSIGN_CANCEL, 100); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php'); $rlcAssignment = HMS_RLC_Assignment::getAssignmentByUsername($username, $term); if (!is_null($rlcAssignment)) { $rlcAssignment->delete(); } PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php'); $rlcApplication = HMS_RLC_Application::getApplicationByUsername($username, $term); if (!is_null($rlcApplication)) { $rlcApplication->denied = 1; $rlcApplication->save(); HMS_Activity_Log::log_activity($username, ACTIVITY_DENIED_RLC_APPLICATION, \Current_User::getUsername(), Term::toString($term) . ' Denied RLC Application due to Contract Cancellation'); } // Cancel the application $application->cancel($cancelReason); $application->save(); echo 'success'; exit; }
public function show() { $tpl = array(); if (empty($this->housingApps)) { $tpl['APPLICATIONS_EMPTY'] = 'No applications found.'; return PHPWS_Template::process($tpl, 'hms', 'admin/profileHousingAppList.tpl'); } // Include javascript for cancel application jquery dialog $jsParams = array('LINK_SELECT' => '.cancelAppLink'); javascript('profileCancelApplication', $jsParams, 'mod/hms/'); $app_rows = ""; // Get the list of cancellation reasons $reasons = HousingApplication::getCancellationReasons(); // Show a row for each application foreach ($this->housingApps as $app) { $term = Term::toString($app->getTerm()); $mealPlan = HMS_Util::formatMealOption($app->getMealPlan()); $phone = HMS_Util::formatCellPhone($app->getCellPhone()); $type = $app->getPrintableAppType(); // Clean/dirty and early/late preferences are only fields on the FallApplication if ($app instanceof FallApplication && isset($app->room_condition)) { $clean = $app->room_condition == 1 ? 'Neat' : 'Cluttered'; } else { $clean = ''; } if ($app instanceof FallApplication && isset($app->preferred_bedtime)) { $bedtime = $app->preferred_bedtime == 1 ? 'Early' : 'Late'; } else { $bedtime = ''; } $viewCmd = CommandFactory::getCommand('ShowApplicationView'); $viewCmd->setAppId($app->getId()); $view = $viewCmd->getURI(); $row = array('term' => $term, 'type' => $type, 'meal_plan' => $mealPlan, 'cell_phone' => $phone, 'clean' => $clean, 'bedtime' => $bedtime, 'view' => $view); if ($app->isCancelled()) { $reInstateCmd = CommandFactory::getCommand('ReinstateApplication'); $reInstateCmd->setAppID($app->getId()); $row['reinstate'] = $reInstateCmd->getURI(); $cancelledReason = "({$reasons[$app->getCancelledReason()]})"; $row['cancelledReason'] = $cancelledReason; $row['row_style'] = 'warning'; } else { // Show Cancel Command, if user has permission to cancel apps if (Current_User::allow('hms', 'cancel_housing_application')) { $cancelCmd = CommandFactory::getCommand('ShowCancelHousingApplication'); $cancelCmd->setHousingApp($app); $cancel = $cancelCmd->getURI(); $row['cancel'] = $cancel; } } $app_rows[] = $row; } $tpl['APPLICATIONS'] = $app_rows; return PHPWS_Template::process($tpl, 'hms', 'admin/profileHousingAppList.tpl'); }
public function show() { $tpl = array(); $tpl['NAME'] = $this->student->getName(); $tpl['TERM'] = Term::toString($this->application->getTerm()); if (isset($this->assignment)) { $tpl['ASSIGNMENT'] = $this->assignment->where_am_i(); } else { $tpl['NO_ASSIGNMENT'] = ""; // dummy tag } $form = new PHPWS_Form('cancel_app_form'); $submitCmd = CommandFactory::getCommand('CancelHousingApplication'); $submitCmd->initForm($form); $reasons = array_merge(array(-1 => 'Select...'), HousingApplication::getCancellationReasons()); $form->addDropBox('cancel_reason', $reasons); $form->setLabel('cancel_reason', 'Reason'); $form->addHidden('applicationId', $this->application->getId()); $form->addHidden('term', $this->application->getTerm()); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'admin/housingApplicationCancelView.tpl'); }