public function execute(CommandContext $context) { $term = new Term(Term::getSelectedTerm()); $term->setDocusignTemplate($context->get('template')); $term->setDocusignUnder18Template($context->get('under18_template')); $term->save(); $cmd = CommandFactory::getCommand('ShowEditTerm'); $cmd->redirect(); }
public function show() { if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'edit_terms')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to edit terms.'); } $printable = Term::getPrintableSelectedTerm(); $tpl = array(); $tpl['TITLE'] = dgettext('hms', 'Term settings for ') . $printable; $newTermCmd = CommandFactory::getCommand('ShowCreateTerm'); $tpl['NEW_TERM_URI'] = $newTermCmd->getURI(); // Is this the Current Term? if (Term::isCurrentTermSelected()) { $tpl['CURRENT_TERM_TEXT'] = dgettext('hms', 'This term is the <strong>active term</strong>. To make another term active, please select it from the list at the top-left.'); } else { $tpl['CURRENT_TERM_TEXT'] = dgettext('hms', 'This term is <strong>not</strong> the active term.'); if (Current_User::allow('hms', 'activate_term')) { $cmd = CommandFactory::getCommand('SetCurrentTerm'); $cmd->setTerm(Term::getSelectedTerm()); $tpl['SET_TERM_URI'] = $cmd->getURI(); $tpl['SET_TERM_TEXT'] = "Make <strong>{$printable}</strong> the Current Term"; } } // What's with the Banner Queue? $term = new Term(Term::getSelectedTerm()); if ($term->getBannerQueue()) { $tpl['QUEUE_ENABLED'] = ''; $count = $term->getQueueCount(); $tpl['BANNER_QUEUE_COUNT'] = $count; if ($count > 0) { $cmd = CommandFactory::getCommand('ProcessBannerQueue'); $cmd->setTerm(Term::getSelectedTerm()); $tpl['BANNER_QUEUE_PROCESS_URI'] = $cmd->getURI(); } else { $cmd = CommandFactory::getCommand('DisableBannerQueue'); $cmd->setTerm(Term::getSelectedTerm()); $tpl['BANNER_QUEUE_LINK'] = $cmd->getLink('Disable'); } } else { $tpl['QUEUE_DISABLED'] = ''; $cmd = CommandFactory::getCommand('EnableBannerQueue'); $cmd->setTerm(Term::getSelectedTerm()); $tpl['BANNER_QUEUE_LINK'] = $cmd->getLink('Enable'); } // Terms and Conditions PHPWS_Core::initModClass('hms', 'TermsConditionsAdminView.php'); $tcav = new TermsConditionsAdminView($this->term); $tpl['TERMS_CONDITIONS_CONTENT'] = $tcav->show(); // Features and Deadlines PHPWS_Core::initModClass('hms', 'ApplicationFeatureListView.php'); $aflv = new ApplicationFeatureListView(Term::getSelectedTerm()); $tpl['FEATURES_DEADLINES_CONTENT'] = $aflv->show(); Layout::addPageTitle("Term Settings"); return PHPWS_Template::process($tpl, 'hms', 'admin/TermEditView.tpl'); }
protected function import_terms($array) { foreach ($array as $term_data) { $term = new Term($term_data->name, $term_data->taxonomy); if ($term->id) { foreach ($term_data as $key => $value) { $term->set($key, $value); } } } }
public function show() { PHPWS_Core::initCoreClass('Form.php'); javascript('jquery'); javascript('modules/hms/assign_student'); $unassignCmd = CommandFactory::getCommand('UnassignStudent'); $form = new PHPWS_Form(); $unassignCmd->initForm($form); $form->addText('username'); if (!is_null($this->student)) { $form->setValue('username', $this->student->getUsername()); } $form->addCssClass('username', 'form-control'); $form->setExtra('username', 'autofocus'); // Addition of "Unassignment Type" $form->addDropBox('unassignment_type', array('-1' => 'Choose a reason...', UNASSIGN_ADMIN => 'Administrative', UNASSIGN_REASSIGN => 'Re-assign', UNASSIGN_CANCEL => 'Contract Cancellation', UNASSIGN_PRE_SPRING => 'Pre-spring room change', UNASSIGN_RELEASE => 'Contract Release')); //$form->setMatch('unassignment_type', UNASSIGN_ADMIN); $form->setLabel('unassignment_type', 'Unassignment Type: '); $form->addCssClass('unassignment_type', 'form-control'); $form->addText('refund'); $form->setLabel('refund', 'Refund Percentage'); $form->setSize('refund', 4); $form->setMaxSize('refund', 3); $form->addCssClass('refund', 'form-control'); $form->addTextarea('note'); $form->setLabel('note', 'Note: '); $form->addCssClass('note', 'form-control'); $tpl = $form->getTemplate(); $tpl['TERM'] = Term::getPrintableSelectedTerm(); Layout::addPageTitle("Unassign Student"); return PHPWS_Template::process($tpl, 'hms', 'admin/unassignStudent.tpl'); }
public function execute(CommandContext $context) { $resultCmd = CommandFactory::getCommand('ShowSendRlcInvites'); $respondByDate = $context->get('respond_by_date'); $respondByTime = $context->get('time'); if (!isset($respondByDate) || $respondByDate == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a \'respond by\' date.'); $resultCmd->redirect(); } $dateParts = explode('/', $respondByDate); $respondByTimestamp = mktime($respondByTime, null, null, $dateParts[0], $dateParts[1], $dateParts[2]); $term = Term::getSelectedTerm(); $studentType = $context->get('type'); if (!isset($studentType)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a student type.'); $resultCmd->redirect(); } PHPWS_Core::initModClass('hms', 'RlcAssignmentFactory.php'); PHPWS_Core::initModClass('hms', 'RlcAssignmentInvitedState.php'); $assignments = RlcAssignmentFactory::getAssignmentsByTermStateType($term, 'new', $studentType); if (sizeof($assignments) == 0) { NQ::simple('hms', hms\NotificationView::WARNING, 'No invites needed to be sent.'); $resultCmd->redirect(); } foreach ($assignments as $assign) { $assign->changeState(new RlcAssignmentInvitedState($assign, $respondByTimestamp)); } NQ::simple('hms', hms\NotificationView::SUCCESS, 'Learning community invites sent.'); $resultCmd->redirect(); }
protected function render() { parent::render(); $this->tpl['TERM'] = Term::toString($this->report->getTerm()); // Males foreach ($this->report->getMaleTotals() as $total) { $this->tpl['male_totals'][] = array('COUNT' => $total); } $this->tpl['MALE_SUB'] = $this->report->getMaleSubTotal(); // Females foreach ($this->report->getFemaleTotals() as $total) { $this->tpl['female_totals'][] = array('COUNT' => $total); } $this->tpl['FEMALE_SUB'] = $this->report->getFemaleSubTotal(); // Type totals foreach ($this->report->getTypeTotals() as $total) { $this->tpl['type_totals'][] = array('COUNT' => $total); } $this->tpl['SUB_TOTAL'] = $this->report->getSubTotal(); // Cancelled totals $cancelledTotals = $this->report->getCancelledTotals(); $this->tpl['FEMALE_CANCELLED'] = $cancelledTotals[FEMALE]; $this->tpl['MALE_CANCELLED'] = $cancelledTotals[MALE]; $this->tpl['CANCELLED_SUB'] = $this->report->getCancelledSubTotal(); $this->tpl['FEMALE_TOTAL'] = $this->report->getFemaleGrandTotal(); $this->tpl['MALE_TOTAL'] = $this->report->getMaleGrandTotal(); $this->tpl['ALL_TOTAL'] = $this->report->getTotal(); return PHPWS_Template::process($this->tpl, 'hms', 'admin/reports/ApplicantDemographics.tpl'); }
public function actionList() { $title = 'Sản phẩm'; $criteria = new CDbCriteria(array('condition' => 'status<>0', 'order' => 'count_buy DESC')); if ($_GET['catid']) { $criteria->addCondition('`cat_id` =' . $_GET['catid']); $term = Term::model()->findByPk($_GET['catid']); $title = $term->name; } $dataProvider = new CActiveDataProvider('Product', array('pagination' => array('pageSize' => Yii::app()->params['itemsPerPage']), 'criteria' => $criteria)); $thuongHieu = Term::model()->findAll('vid=7'); $thItems = array(); if ($thuongHieu) { foreach ($thuongHieu as $thItem) { $thItems[] = array('title' => $thItem['name'], 'value' => $thItem['id'], 'checked' => false); } } $cat = Term::model()->findAll('vid=6'); $catItems = array(); if ($cat) { foreach ($cat as $thItem) { $catItems[] = array('title' => $thItem['name'], 'value' => $thItem['id'], 'checked' => false); } } $this->render('list', array('items' => $dataProvider, 'title' => $title, 'thItems' => $thItems, 'catItems' => $catItems)); }
public function show() { $username = UserStatus::getUsername(); $currentTerm = Term::getCurrentTerm(); $student = StudentFactory::getStudentByUsername($username, $currentTerm); $applicationTerm = $student->getApplicationTerm(); $tpl = array(); $tpl['TITLE'] = 'Contact Form'; $form = new PHPWS_Form(); $form->addText('name'); $form->setLabel('name', 'Name'); $form->addText('email'); $form->setLabel('email', 'Email Address'); $form->addText('phone'); $form->setLabel('phone', 'Phone number'); $form->addDropBox('stype', array('F' => 'New Freshmen', 'T' => 'Transfer', 'C' => 'Returning')); $form->setLabel('stype', 'Classification'); $form->addTextArea('comments'); $form->setLabel('comments', 'Question, Comments, or Description of the Problem'); $form->addSubmit('Submit'); $form->mergeTemplate($tpl); $cmd = CommandFactory::getCommand('SubmitContactForm'); $cmd->setUsername($username); $cmd->setApplicationTerm($applicationTerm); $cmd->setStudentType($student->getType()); $cmd->initForm($form); $tpl = $form->getTemplate(); //var_dump($tpl);exit; return PHPWS_Template::process($tpl, 'hms', 'student/contact_page.tpl'); }
public function show() { $tpl = array(); $tpl['REVIEW_MSG'] = ''; // set this to show the review message $tpl['STUDENT_NAME'] = $this->student->getFullName(); $tpl['TERM'] = Term::toString($this->term); /* Emergency Contact */ $tpl['EMERGENCY_CONTACT_NAME'] = $this->app->getEmergencyContactName(); $tpl['EMERGENCY_CONTACT_RELATIONSHIP'] = $this->app->getEmergencyContactRelationship(); $tpl['EMERGENCY_CONTACT_PHONE'] = $this->app->getEmergencyContactPhone(); $tpl['EMERGENCY_CONTACT_EMAIL'] = $this->app->getEmergencyContactEmail(); $tpl['EMERGENCY_MEDICAL_CONDITION'] = $this->app->getEmergencyMedicalCondition(); /* Missing Person */ $tpl['MISSING_PERSON_NAME'] = $this->app->getMissingPersonName(); $tpl['MISSING_PERSON_RELATIONSHIP'] = $this->app->getMissingPersonRelationship(); $tpl['MISSING_PERSON_PHONE'] = $this->app->getMissingPersonPhone(); $tpl['MISSING_PERSON_EMAIL'] = $this->app->getMissingPersonEmail(); $form = new PHPWS_Form('hidden_form'); $submitCmd = CommandFactory::getCommand('EmergencyContactConfirm'); $submitCmd->setVars($_REQUEST); $submitCmd->initForm($form); $form->addSubmit('submit', 'Confirm & Continue'); $redoCmd = CommandFactory::getCommand('ShowEmergencyContactForm'); $redoCmd->setTerm($this->term); $redoCmd->setVars($_REQUEST); $tpl['REDO_BUTTON'] = $redoCmd->getLink('modify your information'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'student/emergency_contact_form.tpl'); }
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 show() { $tpl = array(); if ($this->halls == NULL) { NQ::simple('hms', hms\NotificationView::ERROR, 'There are no halls available for the selected term.'); $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu'); $cmd->redirect(); } $tpl['TITLE'] = $this->title; $tpl['TERM'] = Term::getPrintableSelectedTerm(); javascript('jquery'); javascript('modules/hms/select_floor'); # Setup the form $form = new PHPWS_Form(); $this->onSelectCmd->initForm($form); $form->setMethod('get'); $form->addDropBox('residence_hall', $this->halls); $form->setLabel('residence_hall', 'Residence hall'); $form->setMatch('residence_hall', 0); $form->setClass('residence_hall', 'form-control'); $form->addDropBox('floor', array(0 => '')); $form->setLabel('floor', 'Floor'); $form->setClass('floor', 'form-control'); $form->addSubmit('submit_button', 'Select'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); Layout::addPageTitle("Select Floor"); return PHPWS_Template::process($tpl, 'hms', 'admin/select_floor.tpl'); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::getPrintableSelectedTerm(); $tpl['NAME'] = $this->student->getFullName(); $tpl['LOCATION'] = $this->assignment->where_am_i(); $submitCmd = CommandFactory::getCommand('AssignStudent'); $submitCmd->setUsername($this->student->getUsername()); $submitCmd->setRoom($this->room); $submitCmd->setBed($this->bed); $submitCmd->setMealPlan($this->mealPlan); $submitCmd->setMoveConfirmed("true"); $submitCmd->setAssignmentType($this->assignmentType); $submitCmd->setNotes($this->notes); $form = new PHPWS_Form(); $submitCmd->initForm($form); $form->addSubmit('submit', 'Confirm Move'); $form->setClass('submit', 'btn btn-danger'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); if (!empty($_SERVER['HTTP_REFERER'])) { $tpl['BACK'] = $_SERVER['HTTP_REFERER']; } else { $tpl['BACK'] = 'index.php?module=hms&action=ShowAssignStudent'; } Layout::addPageTitle("Assignment Move Confirmation"); return PHPWS_Template::process($tpl, 'hms', 'admin/assign_student_move_confirm.tpl'); }
/** * Executes this pulse. Does the withdrawn search and emails the results. */ public function execute() { // Reschedule the next run of this process $sp = $this->makeClone(); $sp->execute_at = strtotime("tomorrow"); $sp->save(); // Load some classes PHPWS_Core::initModClass('hms', 'HMS.php'); PHPWS_Core::initModClass('hms', 'WithdrawnSearch.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'UserStatus.php'); UserStatus::wearMask('HMS System'); // The search is run over all future terms $terms = Term::getFutureTerms(); $text = ""; foreach ($terms as $term) { $search = new WithdrawnSearch($term); $search->doSearch(); $text .= "\n\n=========== " . Term::toString($term) . " ===========\n\n"; $text .= $search->getTextView(); } $text = $search->getTextView(); HMS_Email::sendWithdrawnSearchOutput($text); UserStatus::removeMask(); HMS::quit(); }
public function show() { PHPWS_Core::initModClass('hms', 'HMS_Lottery.php'); $tpl = array(); $form = new PHPWS_Form(); $submitCmd = CommandFactory::getCommand('LotterySettingsSubmit'); $submitCmd->initForm($form); $form->addDropBox('lottery_term', Term::getTermsAssoc()); $form->setMatch('lottery_term', PHPWS_Settings::get('hms', 'lottery_term')); $form->setLabel('lottery_term', 'Lottery Term'); $form->setClass('lottery_term', 'form-control'); $form->addText('hard_cap'); $form->setLabel('hard_cap', 'Max # Returning Students (hard cap):'); $form->setValue('hard_cap', PHPWS_Settings::get('hms', 'lottery_hard_cap')); $form->setClass('hard_cap', 'form-control'); /* $form->addText('soph_goal'); $form->setLabel('soph_goal', 'Sophomores:'); $form->setValue('soph_goal', PHPWS_Settings::get('hms', 'lottery_soph_goal')); */ $form->addText('jr_goal'); $form->setLabel('jr_goal', 'Juniors:'); $form->setValue('jr_goal', PHPWS_Settings::get('hms', 'lottery_jr_goal')); $form->setClass('jr_goal', 'form-control'); $form->addText('sr_goal'); $form->setLabel('sr_goal', 'Senior:'); $form->setValue('sr_goal', PHPWS_Settings::get('hms', 'lottery_sr_goal')); $form->setClass('sr_goal', 'form-control'); $form->addSubmit('submit', 'Save'); $form->mergeTemplate($tpl); Layout::addPageTitle("Lottery Settings"); return PHPWS_Template::process($form->getTemplate(), 'hms', 'admin/lottery_settings.tpl'); }
/** * function __get * Overrides QueryRecord __get to implement custom object properties * @param string Name of property to return * @return mixed The requested field value **/ public function __get($name) { $term = Term::get(Tags::vocabulary()->id, $this->id); switch ($name) { case 'tag': case 'tag_text': $out = $term->term_display; break; case 'tag_text_searchable': // if it's got spaces, then quote it. if (strpos($term->term_display, ' ') !== FALSE) { $out = '\'' . str_replace("'", "\\'", $term->term_display) . '\''; } else { $out = $term->term_display; } break; case 'slug': case 'tag_slug': $out = $term->term; break; case 'count': $out = $this->get_count(); break; default: break; } return $out; }
public function execute(CommandContext $context) { PHPWS_Core::initModClass('hms', 'RoomDamageFactory.php'); PHPWS_Core::initModClass('hms', 'StudentFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Email.php'); PHPWS_Core::initModClass('hms', 'CheckinFactory.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); $term = Term::getSelectedTerm(); // Get the total damages assessed for each student $damages = RoomDamageFactory::getAssessedDamagesStudentTotals($term); foreach ($damages as $dmg) { $student = StudentFactory::getStudentByBannerId($dmg['banner_id'], $term); // Get the student's last checkout // (NB: the damages may be for multiple check-outs, // but we'll just take the last one) $checkout = CheckinFactory::getLastCheckoutForStudent($student); $bed = new HMS_Bed($checkout->getBedId()); $room = $bed->get_parent(); $floor = $room->get_parent(); $hall = $floor->get_parent(); $coordinators = $hall->getCoordinators(); if ($coordinators != null) { $coordinatorName = $coordinators[0]->getDisplayName(); $coordinatorEmail = $coordinators[0]->getEmail(); } else { $coordinatorName = '(No coordinator set for this hall.)'; $coordinatorEmail = '(No coordinator set for this hall.)'; } HMS_Email::sendDamageNotification($student, $term, $dmg['sum'], $coordinatorName, $coordinatorEmail); } // Show a success message and redirect back to the main admin menu NQ::simple('hms', hms\NotificationView::SUCCESS, 'Room damage noties sent.'); $cmd = CommandFactory::getCommand('ShowAdminMaintenanceMenu'); $cmd->redirect(); }
public function show() { if (\UserStatus::isGuest()) { return ''; } $terms = \Term::getTermsAssoc(); $current = \Term::getCurrentTerm(); if (isset($terms[$current])) { $terms[$current] .= ' (Current)'; } $form = new \PHPWS_Form('term_selector'); $cmd = \CommandFactory::getCommand('SelectTerm'); $cmd->initForm($form); $form->addDropBox('term', $terms); $tags = $form->getTemplate(); $currentTerm = \Term::getSelectedTerm(); $tags['TERM_OPTIONS'] = array(); foreach ($tags['TERM_VALUE'] as $key => $value) { $selected = ''; if ($key == $currentTerm) { $selected = 'selected="selected"'; } $tags['TERM_OPTIONS'][] = array('id' => $key, 'term' => $value, 'selected' => $selected); } javascript('jquery'); javascriptMod('hms', 'jqueryCookie'); javascript('modules/hms/SelectTerm'); return \PHPWS_Template::process($tags, 'hms', 'admin/SelectTerm.tpl'); }
/** * Generates the activity log table */ public function getPagerTags() { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $tpl = array(); try { $student = StudentFactory::getStudentByUsername($this->get_user_id(), Term::getSelectedTerm()); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::WARNING, "Could not find data for student: {$this->get_user_id()}"); $student = null; } if (is_null($student)) { $tpl['ACTEE'] = 'UNKNOWN'; } else { $tpl['ACTEE'] = $student->getProfileLink(); } if (strcmp($this->get_user_id(), $this->get_actor()) == 0) { $tpl['ACTOR'] = NULL; } else { $tpl['ACTOR'] = $this->get_actor(); } $time = $this->get_timestamp(); $tpl['DATE'] = date('j M Y', $time); $tpl['TIME'] = date('g:i a', $time); $tpl['ACTIVITY'] = $this->get_text_activity(); $notes = $this->get_notes(); if (!is_null($notes)) { $tpl['NOTES'] = $notes; } return $tpl; }
public function __construct($username) { PHPWS_Core::initModClass('hms', 'StudentFactory.php'); $student = StudentFactory::getStudentByUsername($username, Term::getCurrentTerm()); $this->student = $student; $this->term = $student->getApplicationTerm(); }
protected function render() { $this->tpl = $this->report->getSortedRows(); parent::render(); $this->tpl['TERM'] = Term::toString($this->report->getTerm()); return PHPWS_Template::process($this->tpl, 'hms', 'admin/reports/SpecialNeedsRequest.tpl'); }
protected function render() { parent::render(); $this->tpl['TERM'] = Term::toString($this->report->getTerm()); $rows = array(); $totalAssignments = 0; foreach ($this->report->getTypeCounts() as $result) { $row = array(); // Translate the reason string into a human readable label, if it exists // Otherwsie, use the raw reason code $name = constant($result['reason']); if (isset($name)) { $row['REASON'] = $name; } else { $row['REASON'] = $result['reason']; } $row['COUNT'] = $result['count']; $rows[] = $row; // Add the count for this reason to the running total $totalAssignments += $result['count']; } $this->tpl['TABLE_ROWS'] = $rows; $this->tpl['TOTAL_ASSIGNMENTS'] = $totalAssignments; return PHPWS_Template::process($this->tpl, 'hms', 'admin/reports/AssignmentsByType.tpl'); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::getPrintableSelectedTerm(); $form = new PHPWS_Form('roommate_group'); $submitCmd = CommandFactory::getCommand('CreateRoommateGroup'); $submitCmd->initForm($form); if (isset($this->roommate1)) { $form->addText('roommate1', $this->roommate1); } else { $form->addText('roommate1'); } $form->addCssClass('roommate1', 'form-control'); $form->setExtra('roommate1', 'autofocus'); if (isset($this->roommate1)) { $form->addText('roommate2', $this->roommate2); } else { $form->addText('roommate2'); } $form->addCssClass('roommate2', 'form-control'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); Layout::addPageTitle("Create Roommate Group"); return PHPWS_Template::process($tpl, 'hms', 'admin/createRoommateGroup.tpl'); }
public function execute(CommandContext $context) { // Check permissions if (!Current_User::allow('hms', 'checkin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to checkin students.'); } $term = Term::getSelectedTerm(); $bannerId = $context->get('bannerId'); $hallId = $context->get('hallId'); $errorCmd = CommandFactory::getCommand('ShowCheckinStart'); if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing Banner ID.'); $errorCmd->redirect(); } if (!isset($hallId)) { NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.'); $errorCmd->redirect(); } // Check the Banner ID if (preg_match("/[\\d]{9}/", $bannerId) == false) { NQ::simple('hms', hms\NotificationView::ERROR, 'Imporperly formatted Banner ID.'); $errorCmd->redirect(); } // Try to lookup the student in Banner try { $student = StudentFactory::getStudentByBannerId($bannerId, $term); } catch (StudentNotFoundException $e) { NQ::simple('hms', hms\NotificationView::ERROR, 'Could not locate a student with that Banner ID.'); $errorCmd->redirect(); } // Make sure the student is assigned in the current term $assignment = HMS_Assignment::getAssignmentByBannerId($bannerId, $term); if (!isset($assignment) || is_null($assignment)) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' is not assigned for ' . Term::toString($term) . '. Please contact the University Housing Assignments Office at 828-262-6111.'); $errorCmd->redirect(); } // Make sure the student's assignment matches the hall the user selected $bed = $assignment->get_parent(); $room = $bed->get_parent(); $floor = $room->get_parent(); $hall = $floor->get_parent(); if ($hallId != $hall->getId()) { NQ::simple('hms', hms\NotificationView::ERROR, 'Wrong hall! ' . $student->getName() . ' is assigned to ' . $assignment->where_am_i()); $errorCmd->redirect(); } // Load any existing check-in $checkin = CheckinFactory::getLastCheckinByBannerId($bannerId, $term); // If there is a checkin for the same bed, and the difference between the current time and the checkin time is // greater than 48 hours, then show an error. if (!is_null($checkin)) { $checkoutDate = $checkin->getCheckoutDate(); if ($checkin->getBedId() == $bed->getId() && !isset($checkoutDate) && time() - $checkin->getCheckinDate() > Checkin::CHECKIN_TIMEOUT) { NQ::simple('hms', hms\NotificationView::ERROR, $student->getName() . ' has already checked in to ' . $assignment->where_am_i()); $errorCmd->redirect(); } } $view = new CheckinFormView($student, $assignment, $hall, $floor, $room, $checkin); $context->setContent($view->show()); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::toString($this->term); $form = new PHPWS_Form('rlc_reapp'); $submitCmd = CommandFactory::getCommand('SubmitRLCReapplicationPage2'); $submitCmd->setTerm($this->term); $submitCmd->initForm($form); foreach ($this->rlcs as $i => $rlc) { $question = $this->rlcs[$i]->getReturningQuestion(); if (!isset($question)) { throw new Exception("Missing returning question for {$this->rlcs[$i]->get_community_name()}"); } if (isset($this->reApp) && isset($this->reApp->{"rlc_question_{$i}"})) { $form->addTextArea("rlc_question_{$i}", $this->reApp->{"rlc_question_{$i}"}); } else { $form->addTextArea("rlc_question_{$i}"); } $form->setLabel("rlc_question_{$i}", $this->rlcs[$i]->getReturningQuestion()); $form->addCssClass("rlc_question_{$i}", 'form-control'); } $form->addSubmit('submit', 'Submit Application'); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'student/RlcReapplicationPage2.tpl'); }
/** * Loads the form's fields with the internship's information. * TODO: Use getter methods instead of just accessing Internship member variables directly. */ public function plugInternship() { $this->plugStudent(); $this->plugDept(); $this->plugFaculty(); $this->plugAgency(); $this->plugInternInfo(); $this->plugCourseInfo(); // We're editing an internship... // If this internship's term is in the past, then replace the term list with just that term if (!in_array($this->intern->term, array_keys(Term::getFutureTermsAssoc()))) { // Remove the term dropdown and repalce it $this->form->dropElement('term'); $this->form->addSelect('term', array($this->intern->term => Term::rawToRead($this->intern->term))); $this->form->setLabel('term', 'Select Term'); $this->form->addCssClass('term', 'form-control'); } $this->form->setMatch('term', $this->intern->term); $this->form->setMatch('experience_type', $this->intern->getExperienceType()); // Plug $this->form->plugIn($this->formVals); /** * * * Emergency Contacts */ //javascript('jquery'); PHPWS_Core::initModClass('intern', 'EmergencyContactFactory.php'); $contacts = EmergencyContactFactory::getContactsForInternship($this->intern); $emgContactJson = json_encode($contacts); Layout::add(javascriptMod('intern', 'emergencyContact', array('existing_contacts_json' => $emgContactJson))); }
/** * Report lists rooms in each residence hall that are still available, along with * the available beds in the room. Also, show the number of beds allocated to the * lotter for each residence hall. * */ public static function reappAvailability() { $term = Term::getSelectedTerm(); // Available rooms in each residence hall. $db = new PHPWS_DB('hms_bed'); $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id'); $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id'); $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id'); //$db->addWhere('hms_bed.ra_bed', 0); $db->addWhere('hms_room.private', 0); $db->addWhere('hms_room.overflow', 0); $db->addWhere('hms_room.reserved', 0); $db->addWhere('hms_room.offline', 0); $db->addWhere('hms_bed.term', $term); $db->addColumn('hms_room.room_number'); $db->addColumn('hms_bed.bed_letter', null, null, True); $db->addColumn('hms_residence_hall.hall_name'); $db->addGroupBy('hms_residence_hall.hall_name'); $db->addGroupBy('hms_room.room_number'); $db->addOrder('hms_residence_hall.hall_name'); $availRooms = $db->select(); // Allocated beds for lottery. $db = new PHPWS_DB('hms_bed'); $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id'); $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id'); $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id'); $db->addJoin('RIGHT', 'hms_bed', 'hms_lottery_reservation', 'id', 'bed_id'); $db->addWhere('hms_lottery_reservation.term', $term); $db->addColumn('hms_residence_hall.hall_name'); $db->addColumn('hms_bed.id', null, null, True); $db->addGroupBy('hms_residence_hall.hall_name'); $db->setIndexBy('hall_name'); $lotteryBeds = $db->select(); $tpl = new PHPWS_Template('hms'); $tpl->setFile('admin/reports/reapp_availability.tpl'); // // "The parent row must be parsed after the child rows." // Preload currHall with first residence hall name $currHall = $availRooms[0]['hall_name']; foreach ($availRooms as $row) { // Change halls, create new block. if ($currHall != $row['hall_name'] || $currHall == null) { $tpl->setCurrentBlock('halls'); // Get allocated beds for the residence hall. $lottCount = isset($lotteryBeds[$currHall]['count']) ? $lotteryBeds[$currHall]['count'] : 0; $tpl->setData(array('HALL_NAME' => $currHall, 'LOTTERY_BEDS' => $lottCount)); $tpl->parseCurrentBlock(); $currHall = $row['hall_name']; } // Add room to residence hall template block. $tpl->setCurrentBlock('rooms'); $tpl->setData(array('ROOM_NUM' => $row['room_number'], 'BED_COUNT' => $row['count'])); $tpl->parseCurrentBlock(); } // Get last residence hall. Can't parse parent before child with template class. $tpl->setCurrentBlock('halls'); $tpl->setData(array('HALL_NAME' => $currHall)); $tpl->parseCurrentBlock(); return $tpl->get(); }
public function execute(CommandContext $context) { $term = $context->get('term'); if (!isset($term) || is_null($term) || empty($term)) { throw new InvalidArgumentException('Missing term.'); } $cmd = CommandFactory::getCommand('ShowStudentMenu'); $feature = ApplicationFeature::getInstanceByNameAndTerm('RlcApplication', $term); // Make sure the RLC application feature is enabled if (is_null($feature) || !$feature->isEnabled()) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, RLC applications are not avaialable for this term."); $cmd->redirect(); } // Check feature's deadlines if ($feature->getStartDate() > time()) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, it is too soon to fill out an RLC application."); $cmd->redirect(); } else { if ($feature->getEndDate() < time()) { NQ::simple('hms', hms\NotificationView::ERROR, "Sorry, the RLC application deadline has already passed. Please contact University Housing if you are interested in applying for a RLC."); $cmd->redirect(); } } // Get the Student object $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), Term::getCurrentTerm()); $view = new RlcApplicationPage1View($context, $student); $context->setContent($view->show()); }
public function show() { $tpl = array(); $tpl['TERM'] = Term::toString($this->room->getTerm()); $tpl['TITLE'] = 'Add New Bed'; $tpl['HALL_NAME'] = $this->hall->getLink(); $tpl['FLOOR_NUMBER'] = $this->floor->getLink(); $tpl['ROOM_NUMBER'] = $this->room->getLink(); $tpl['ASSIGNED_TO'] = '<unassigned>'; $submitCmd = CommandFactory::getCommand('AddBed'); $submitCmd->setRoomId($this->room->id); $tpl['HALL_ABBR'] = $this->hall->getBannerBuildingCode(); $form = new PHPWS_Form(); $submitCmd->initForm($form); if (isset($this->bedLetter)) { $form->addText('bed_letter', $this->bedLetter); } else { $form->addText('bed_letter', chr($this->room->get_number_of_beds() + 97)); } $form->addCssClass('bed_letter', 'form-control'); if (isset($this->bedroomLabel)) { $form->addText('bedroom_label', $this->bedroomLabel); } else { $form->addText('bedroom_label', 'a'); } $form->addCssClass('bedroom_label', 'form-control'); if (isset($this->phoneNumber)) { $form->addText('phone_number', $this->phoneNumber); } else { // Try to guess at the phone number $beds = $this->room->get_beds(); if (sizeof($beds) > 0) { $form->addText('phone_number', $beds[0]->phone_number); } else { $form->addText('phone_number'); } } $form->setMaxSize('phone_number', 4); $form->setSize('phone_number', 5); $form->addCssClass('phone_number', 'form-control'); if (isset($this->bannerId)) { $form->addText('banner_id', $this->bannerId); } else { // try to guess a the banner ID // Strip any text out of the room number, just get the numbers $match = null; preg_match("/[0-9]*/", $this->room->room_number, $match); $roomNumber = $match[0]; $form->addText('banner_id', '0' . $roomNumber . ($this->room->get_number_of_beds() + 1)); } $form->addCssClass('banner_id', 'form-control'); $form->addCheckBox('ra', 1); $form->addCheckBox('ra_roommate', 1); $form->addCheckBox('international_reserved', 1); $form->mergeTemplate($tpl); $tpl = $form->getTemplate(); Layout::addPageTitle("Add Bed"); // Reusing the edit bed template here return PHPWS_Template::process($tpl, 'hms', 'admin/addBed.tpl'); }
public function execute(CommandContext $context) { $term = Term::getSelectedTerm(); $messageAll = Current_User::allow('hms', 'email_all'); $db = new PHPWS_DB('hms_residence_hall'); $db->addWhere('term', $term); $results = $db->getObjects('HMS_Residence_Hall'); if (PHPWS_Error::logIfError($results) || is_null($results)) { $errorMsg = array(); if (is_null($results)) { $errorMsg['error'] = 'You do not have permission to message any halls, sorry.'; } else { $errorMsg['error'] = 'There was a problem reading the database, please try reloading the page. If the problem persists contact ESS.'; } echo json_encode($errorMsg); exit; } $permission = new HMS_Permission(); $data = array(); foreach ($results as $hall) { $somethingEnabled = false; $floors = $hall->get_floors(); unset($obj); $obj = new stdClass(); $obj->name = $hall->getHallName(); $obj->id = $hall->getId(); $obj->floors = array(); //$blah = 'Verify: ' . ($permission->verify(UserStatus::getUsername(), $hall, 'email') ? 'true' : 'false'); if ($permission->verify(UserStatus::getUsername(), $hall, 'email') || $messageAll) { $obj->enabled = true; $somethingEnabled = true; foreach ($floors as $floor) { unset($floor_obj); $floor_obj = new stdClass(); $floor_obj->name = "Floor: " . $floor->getFloorNumber(); $floor_obj->id = $floor->getId(); $floor_obj->enabled = true; $obj->floors[] = $floor_obj; } } else { $obj->enabled = false; foreach ($floors as $floor) { unset($floor_obj); $floor_obj = new stdClass(); $floor_obj->name = "Floor: " . $floor->getFloorNumber(); $floor_obj->id = $floor->getId(); $floor_obj->enabled = $permission->verify(Current_User::getUsername(), $floor, 'email'); $obj->floors[] = $floor_obj; if ($floor_obj->enabled) { $somethingEnabled = true; } } } if ($somethingEnabled) { $data[] = $obj; } } echo json_encode($data); exit; }
public function show() { $form = new PHPWS_Form('room_change_request'); /* Cell phone */ $form->addText('cell_num'); $form->setLabel('cell_num', 'Cell phone Number'); $form->addCssClass('cell_num', 'form-control'); $form->addCheck('cell_opt_out'); /* Preferences */ $halls = array(0 => 'Choose from below...'); $halls = $halls + HMS_Residence_Hall::get_halls_array(Term::getSelectedTerm()); $form->addRadioAssoc('type', array('switch' => 'I want to change to an open bed.', 'swap' => 'I want to swap beds with someone I know.')); /* Swap */ $form->addText('swap_with'); $form->setLabel('swap_with', 'ASU Email Address'); $form->addCssClass('swap_with', 'form-control'); /* Switch */ $form->addDropBox('first_choice', $halls); $form->setLabel('first_choice', 'First Choice'); $form->addCssClass('first_choice', 'form-control'); $form->addDropBox('second_choice', $halls); $form->setLabel('second_choice', 'Second Choice'); $form->addCssClass('second_choice', 'form-control'); /* Reason */ $form->addTextArea('reason'); $form->setLabel('reason', 'Reason'); $form->addCssClass('reason', 'form-control'); $form->setRows('reason', 5); /* POST location */ $cmd = CommandFactory::getCommand('SubmitRoomChangeRequest'); $cmd->initForm($form); $tpl = $form->getTemplate(); return PHPWS_Template::process($tpl, 'hms', 'student/roomChangeRequestForm.tpl'); }