public function execute(CommandContext $context) { $reminders = $context->get('send_reminders'); $sendReminders = isset($reminders) ? true : false; $magic = $context->get('magic_flag'); $sendMagic = isset($magic) ? true : false; $srMale = $context->get('sr_male'); $srFemale = $context->get('sr_female'); $jrMale = $context->get('jr_male'); $jrFemale = $context->get('jr_female'); $sophMale = $context->get('soph_male'); $sophFemale = $context->get('soph_female'); PHPWS_Core::initModClass('hms', 'LotteryProcess.php'); $inviteCounts = array(); $inviteCounts[CLASS_SENIOR][MALE] = $srMale; $inviteCounts[CLASS_SENIOR][FEMALE] = $srFemale; $inviteCounts[CLASS_JUNIOR][MALE] = $jrMale; $inviteCounts[CLASS_JUNIOR][FEMALE] = $jrFemale; $inviteCounts[CLASS_SOPHOMORE][MALE] = $sophMale; $inviteCounts[CLASS_SOPHOMORE][FEMALE] = $sophFemale; $lottery = new LotteryProcess($sendMagic, $sendReminders, $inviteCounts); $lottery->sendInvites(); $_SESSION['LOTTERY_OUTPUT'] = $lottery->getOutput(); $viewCmd = CommandFactory::getCommand('ShowLotteryInviteResults'); $viewCmd->redirect(); }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'LotteryChooseHallView.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'LotteryProcess.php'); PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php'); $term = PHPWS_Settings::get('hms', 'lottery_term'); // Check the hard cap! if (LotteryProcess::hardCapReached($term)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, re-application is now closed.'); $errorCmd = CommandFactory::getCommand('ShowStudentMenu'); $errorCmd->redirect(); } $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term); $rlcAssignment = RlcMembershipFactory::getMembership($student, $term); if ($rlcAssignment == false) { $rlcAssignment = null; } $view = new LotteryChooseHallView($student, $term, $rlcAssignment); $context->setContent($view->show()); }
public function execute() { PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); PHPWS_Core::initModClass('hms', 'LotteryProcess.php'); $lotteryTerm = PHPWS_Settings::get('hms', 'lottery_term'); /******************************* * Gross number of application * *******************************/ $this->data['LOTTERY_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm); $this->data['SOPH_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, CLASS_SOPHOMORE); $this->data['SOPH_M_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, CLASS_SOPHOMORE, MALE); $this->data['SOPH_F_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, CLASS_SOPHOMORE, FEMALE); $this->data['JR_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, CLASS_JUNIOR); $this->data['JR_M_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, CLASS_JUNIOR, MALE); $this->data['JR_F_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, CLASS_JUNIOR, FEMALE); $this->data['SR_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, CLASS_SENIOR); $this->data['SR_M_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, CLASS_SENIOR, MALE); $this->data['SR_F_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, CLASS_SENIOR, FEMALE); $this->data['M_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, null, MALE); $this->data['F_APPS'] = LotteryProcess::countGrossApplicationsByClassGender($lotteryTerm, null, FEMALE); /******************** * Net Applications * ********************/ $this->data['NET_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, null, null); $this->data['NET_SO_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, CLASS_SOPHOMORE); $this->data['NET_SO_M_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, CLASS_SOPHOMORE, MALE); $this->data['NET_SO_F_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, CLASS_SOPHOMORE, FEMALE); $this->data['NET_JR_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, CLASS_JUNIOR); $this->data['NET_JR_M_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, CLASS_JUNIOR, MALE); $this->data['NET_JR_F_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, CLASS_JUNIOR, FEMALE); $this->data['NET_SR_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, CLASS_SENIOR); $this->data['NET_SR_M_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, CLASS_SENIOR, MALE); $this->data['NET_SR_F_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, CLASS_SENIOR, FEMALE); $this->data['NET_M_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, null, MALE); $this->data['NET_F_APPS'] = LotteryProcess::countNetAppsByClassGender($lotteryTerm, null, FEMALE); /**************** * Invites Sent * ****************/ $this->data['SO_INVITES'] = LotteryProcess::countInvitesByClassGender($lotteryTerm, CLASS_SOPHOMORE); $this->data['SO_M_INVITES'] = LotteryProcess::countInvitesByClassGender($lotteryTerm, CLASS_SOPHOMORE, MALE); $this->data['SO_F_INVITES'] = LotteryProcess::countInvitesByClassGender($lotteryTerm, CLASS_SOPHOMORE, FEMALE); $this->data['JR_INVITES'] = LotteryProcess::countInvitesByClassGender($lotteryTerm, CLASS_JUNIOR); $this->data['JR_M_INVITES'] = LotteryProcess::countInvitesByClassGender($lotteryTerm, CLASS_JUNIOR, MALE); $this->data['JR_F_INVITES'] = LotteryProcess::countInvitesByClassGender($lotteryTerm, CLASS_JUNIOR, FEMALE); $this->data['SR_INVITES'] = LotteryProcess::countInvitesByClassGender($lotteryTerm, CLASS_SENIOR); $this->data['SR_M_INVITES'] = LotteryProcess::countInvitesByClassGender($lotteryTerm, CLASS_SENIOR, MALE); $this->data['SR_F_INVITES'] = LotteryProcess::countInvitesByClassGender($lotteryTerm, CLASS_SENIOR, FEMALE); //TODO make this based on lottery assignment reason $db = new PHPWS_DB('hms_assignment'); $db->addWhere('term', $lotteryTerm); $db->addWhere('reason', 'lottery'); $numLotteryAssigned = $db->select('count'); /*********************** * Outstanding Invites * */ $this->data['ROOMMATE_INVITES'] = LotteryProcess::countOutstandingRoommateInvites($lotteryTerm); $this->data['PENDING_SOPH_INVITES'] = LotteryProcess::countOutstandingInvites($lotteryTerm, CLASS_SOPHOMORE); $this->data['PENDING_JR_INVITES'] = LotteryProcess::countOutstandingInvites($lotteryTerm, CLASS_JUNIOR); $this->data['PENDING_SR_INVITES'] = LotteryProcess::countOutstandingInvites($lotteryTerm, CLASS_SENIOR); // Assignments $this->data['LOTTERY_ASSIGNED'] = $numLotteryAssigned; // Assignments by class $this->data['SOPH_ASSIGNED'] = LotteryProcess::countLotteryAssignedByClassGender($lotteryTerm, CLASS_SOPHOMORE); $this->data['SOPH_MALE_ASSIGNED'] = LotteryProcess::countLotteryAssignedByClassGender($lotteryTerm, CLASS_SOPHOMORE, MALE); $this->data['SOPH_FEMALE_ASSIGNED'] = LotteryProcess::countLotteryAssignedByClassGender($lotteryTerm, CLASS_SOPHOMORE, FEMALE); $this->data['JR_ASSIGNED'] = LotteryProcess::countLotteryAssignedByClassGender($lotteryTerm, CLASS_JUNIOR); $this->data['JR_MALE_ASSIGNED'] = LotteryProcess::countLotteryAssignedByClassGender($lotteryTerm, CLASS_JUNIOR, MALE); $this->data['JR_FEMALE_ASSIGNED'] = LotteryProcess::countLotteryAssignedByClassGender($lotteryTerm, CLASS_JUNIOR, FEMALE); $this->data['SR_ASSIGNED'] = LotteryProcess::countLotteryAssignedByClassGender($lotteryTerm, CLASS_SENIOR); $this->data['SR_MALE_ASSIGNED'] = LotteryProcess::countLotteryAssignedByClassGender($lotteryTerm, CLASS_SENIOR, MALE); $this->data['SR_FEMALE_ASSIGNED'] = LotteryProcess::countLotteryAssignedByClassGender($lotteryTerm, CLASS_SENIOR, FEMALE); /*************************************** * Remaining unaffiliated applications * ***************************************/ $this->data['SO_M_ENTRIES_REMAIN'] = LotteryProcess::countRemainingApplicationsByClassGender($lotteryTerm, CLASS_SOPHOMORE, MALE); $this->data['SO_F_ENTRIES_REMAIN'] = LotteryProcess::countRemainingApplicationsByClassGender($lotteryTerm, CLASS_SOPHOMORE, FEMALE); $this->data['SO_ENTRIES_REMAIN'] = $this->data['SO_M_ENTRIES_REMAIN'] + $this->data['SO_F_ENTRIES_REMAIN']; $this->data['JR_M_ENTRIES_REMAIN'] = LotteryProcess::countRemainingApplicationsByClassGender($lotteryTerm, CLASS_JUNIOR, MALE); $this->data['JR_F_ENTRIES_REMAIN'] = LotteryProcess::countRemainingApplicationsByClassGender($lotteryTerm, CLASS_JUNIOR, FEMALE); $this->data['JR_ENTRIES_REMAIN'] = $this->data['JR_M_ENTRIES_REMAIN'] + $this->data['JR_F_ENTRIES_REMAIN']; $this->data['SR_M_ENTRIES_REMAIN'] = LotteryProcess::countRemainingApplicationsByClassGender($lotteryTerm, CLASS_SENIOR, MALE); $this->data['SR_F_ENTRIES_REMAIN'] = LotteryProcess::countRemainingApplicationsByClassGender($lotteryTerm, CLASS_SENIOR, FEMALE); $this->data['SR_ENTRIES_REMAIN'] = $this->data['SR_M_ENTRIES_REMAIN'] + $this->data['SR_F_ENTRIES_REMAIN']; $this->data['REMAINING_ENTRIES'] = LotteryProcess::countRemainingApplications($lotteryTerm); }
public function show() { $tpl = array(); $tpl['DATES'] = HMS_Util::getPrettyDateRange($this->startDate, $this->endDate); $tpl['STATUS'] = ""; $hardCapReached = LotteryProcess::hardCapReached($this->term); if (!is_null($this->assignment)) { // Student has already been assigned. $tpl['ICON'] = FEATURE_COMPLETED_ICON; //$tpl['ASSIGNED'] = $this->assignment->where_am_i(); $tpl['ASSIGNED'] = ''; } else { if ($hardCapReached) { // Hard cap has been reached $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['HARD_CAP'] = ""; // dummy tag } else { if (!is_null($this->application) && $this->application->isWinner()) { // Student has won, let them choose their room $tpl['ICON'] = FEATURE_OPEN_ICON; $chooseRoomCmd = CommandFactory::getCommand('LotteryShowChooseHall'); $tpl['SELECT_LINK'] = $chooseRoomCmd->getLink('Click here to select your room'); } else { if (!is_null($this->application)) { // Student has already re-applied $tpl['ICON'] = FEATURE_COMPLETED_ICON; $tpl['ALREADY_APPLIED'] = ""; // dummy tag, text is in template } else { if (time() < $this->startDate) { // Too early $tpl['ICON'] = FEATURE_NOTYET_ICON; $tpl['BEGIN_DEADLINE'] = HMS_Util::getFriendlyDate($this->startDate); } else { if (time() > $this->endDate) { // Too late $tpl['ICON'] = FEATURE_LOCKED_ICON; // fade out header $tpl['STATUS'] = "locked"; $tpl['END_DEADLINE'] = HMS_Util::getFriendlyDate($this->endDate); } else { if (HMS_Lottery::determineEligibility(UserStatus::getUsername())) { $tpl['ICON'] = FEATURE_OPEN_ICON; $reAppCommand = CommandFactory::getCommand('ShowReApplication'); $reAppCommand->setTerm($this->term); $tpl['ELIGIBLE'] = ""; //dummy tag, text is in template $tpl['LOTTERY_TERM_1'] = Term::toString($this->term); $tpl['NEXT_TERM_1'] = Term::toString(Term::getNextTerm($this->term)); $tpl['ENTRY_LINK'] = $reAppCommand->getLink('Click here to re-apply.'); } else { $tpl['ICON'] = FEATURE_LOCKED_ICON; $tpl['NOT_ELIGIBLE'] = ""; //dummy tag, text is in template $tpl['LOTTERY_TERM_2'] = Term::toString($this->term); $tpl['NEXT_TERM_2'] = Term::toString(Term::getNextTerm($this->term)); } } } } } } } if (!$hardCapReached && time() > $this->startDate) { if ($this->roommateRequests != FALSE && !is_null($this->roommateRequests) && $this->assignment != TRUE && !PEAR::isError($this->assignment)) { $tpl['roommates'] = array(); $tpl['ROOMMATE_REQUEST'] = ''; // dummy tag foreach ($this->roommateRequests as $invite) { $cmd = CommandFactory::getCommand('LotteryShowRoommateRequest'); $cmd->setRequestId($invite['id']); $roommie = StudentFactory::getStudentByUsername($invite['requestor'], $this->term); $tpl['roommates'][]['ROOMMATE_LINK'] = $cmd->getLink($roommie->getName()); //$tpl['roommates'][]['ROOMMATE_LINK'] = PHPWS_Text::secureLink(HMS_SOAP::get_name($invite['requestor']), 'hms', array('type'=>'student', 'op'=>'lottery_show_roommate_request', 'id'=>$invite['id'])); } } } return PHPWS_Template::process($tpl, 'hms', 'student/menuBlocks/reApplicationMenuBlock.tpl'); }
public static function srSoftCapReached($term) { $softCap = LotteryProcess::getSrSoftCap(); $assigned = LotteryProcess::countLotteryAssignedByClassGender($term, CLASS_SENIOR); if ($assigned >= $softCap) { return true; } return false; }