public function doNotification(Internship $i, $note = null)
 {
     // Should always be a grad-level internship if we've made it to this transition, but double check
     if ($i->isGraduate()) {
         $agency = $i->getAgency();
         Email::sendRegistrarEmail($i, $agency);
     }
 }
 public function isApplicable(Internship $i)
 {
     if ($i->isGraduate()) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
 public function execute()
 {
     // Check permissions
     if (!\Current_User::allow('intern', 'create_internship')) {
         \NQ::simple('intern', NotifyUI::ERROR, 'You do not have permission to create new internships.');
         \NQ::close();
         \PHPWS_Core::home();
     }
     // Get a list of any missing input the user didn't fill in
     $missingFieldList = $this->checkForMissingInput();
     // If there are missing fields, redirect to the add internship interface
     if (!empty($missingFieldList)) {
         $this->redirectToForm();
     }
     // Check that the student Id looks valid
     $studentId = $_POST['studentId'];
     // Get the term
     // TODO Double check that this is reasonable
     $term = $_POST['term'];
     // Create the student object
     $student = StudentProviderFactory::getProvider()->getStudent($studentId, $term);
     // Get the department ojbect
     $departmentId = preg_replace("/^_/", '', $_POST['department']);
     // Remove leading underscore in department id
     $department = DepartmentFactory::getDepartmentById($departmentId);
     if (!$department instanceof Department) {
         throw new \Exception('Could not load department.');
     }
     // Create and save the agency object
     $agency = new Agency($_POST['agency']);
     DatabaseStorage::save($agency);
     // Get the location
     $location = $_POST['location'];
     if ($location == 'international') {
         $state = null;
         $country = $_POST['country'];
     } else {
         $state = $_POST['state'];
         $country = null;
     }
     // Create a new internship object
     $intern = new Internship($student, $term, $location, $state, $country, $department, $agency);
     // Save it!!
     $intern->save();
     $t = \Intern\WorkflowTransitionFactory::getTransitionByName('Intern\\WorkflowTransition\\CreationTransition');
     $workflow = new \Intern\WorkflowController($intern, $t);
     $workflow->doTransition(null);
     $workflow->doNotification(null);
     // Show a success notice and redirect to the edit page
     \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, "Created internship for {$intern->getFullName()}");
     \NQ::close();
     return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $intern->getId());
 }
Ejemplo n.º 4
0
 public function doNotification(Internship $i, $note = null)
 {
     $agency = $i->getAgency();
     // If this is an undergrad internship, then send the Registrar an email
     // Graduate level internships have another workflow state to go through before we alert the Registrar
     if ($i->isUndergraduate()) {
         Email::sendRegistrarEmail($i, $agency);
     }
     // If this is a graduate email, send the notification email to the grad school office
     if ($i->isGraduate()) {
         Email::sendGradSchoolNotification($i, $agency);
     }
 }
 public function checkRequiredFields(Internship $i)
 {
     if (!$i->isSecondaryPart()) {
         // Check the course subject
         $courseSubj = $i->getSubject();
         if (!isset($courseSubj) || $courseSubj == '' || $courseSubj->id == 0) {
             throw new MissingDataException("Please select a course subject.");
         }
         // Check the course number
         $courseNum = $i->getCourseNumber();
         if (!isset($courseNum) || $courseNum == '') {
             throw new MissingDataException("Please enter a course number.");
         }
         // Check the course section number
         $sectionNum = $i->getCourseSection();
         if (!isset($sectionNum) || $sectionNum == '') {
             throw new MissingDataException("Please enter a course section number.");
         }
         // Check the course credit hours field
         $creditHours = $i->getCreditHours();
         if (!isset($creditHours) || $creditHours === '') {
             throw new MissingDataException("Please enter the number of course credit hours.");
         }
         /*
         if(!\Current_User::isDeity() && $creditHours <= 0){
             throw new MissingDataException("The number of course credit hours should be greater than zero.");
         }
         */
     }
 }
 /**
  * Builds the body of the internship form.
  */
 public function buildInternshipForm()
 {
     javascript('jquery');
     javascript('jquery_ui');
     javascriptMod('intern', 'formGoodies');
     // Form Submission setup
     $this->form->setAction('index.php?module=intern&action=SaveInternship');
     $this->form->addSubmit('submit', 'Save');
     /*********************
      * Workflow / Status *
      */
     // Workflow Transitions View, adds fields to the form by reference
     $transView = new WorkflowTransitionView($this->intern, $this->form);
     $transView->show();
     /*****************
      * OIED Approval *
      */
     $this->form->addCheck('oied_certified');
     $this->form->setLabel('oied_certified', 'Certified by Office of International Education and Development');
     // If the user is not allowed to do OIED certification, disable the checkbox
     if (!\Current_User::allow('intern', 'oied_certify') || $this->intern->isDomestic()) {
         $this->form->setExtra('oied_certified', 'disabled="disabled" disabled');
     }
     // Hidden field that shadows the real field, to ensure a value is always submitted,
     // because disabled fields are not submitted
     $this->form->addHidden('oied_certified_hidden');
     /******************
      * Student fields *
      */
     $this->form->addText('student_first_name');
     $this->form->setLabel('student_first_name', 'First Name');
     $this->form->addCssClass('student_first_name', 'form-control');
     $this->form->addText('student_middle_name');
     $this->form->setLabel('student_middle_name', 'Middle Name/Initial');
     $this->form->addCssClass('student_middle_name', 'form-control');
     $this->form->addText('student_last_name');
     $this->form->setLabel('student_last_name', 'Last Name');
     $this->form->addCssClass('student_last_name', 'form-control');
     $this->form->addText('student_phone');
     $this->form->setLabel('student_phone', 'Phone');
     $this->form->addCssClass('student_phone', 'form-control');
     $this->form->addText('student_email');
     $this->form->setLabel('student_email', 'ASU Email');
     $this->form->addCssClass('student_email', 'form-control');
     /* Student Address */
     $this->form->addText('student_address');
     $this->form->setLabel('student_address', 'Address');
     $this->form->addCssClass('student_address', 'form-control');
     $this->form->addText('student_city');
     $this->form->setLabel('student_city', 'City');
     $this->form->addCssClass('student_city', 'form-control');
     $this->form->addDropBox('student_state', State::$UNITED_STATES);
     $this->form->setLabel('student_state', 'State');
     $this->form->addCssClass('student_state', 'form-control');
     $this->form->addText('student_zip');
     $this->form->setLabel('student_zip', 'Zip Code');
     $this->form->addCssClass('student_zip', 'form-control');
     /************************
      * Department Drop Down *
      */
     if (\Current_User::isDeity()) {
         if (!is_null($this->intern)) {
             $depts = Department::getDepartmentsAssoc($this->intern->department_id);
         } else {
             $depts = Department::getDepartmentsAssoc();
         }
     } else {
         if (!is_null($this->intern)) {
             $depts = Department::getDepartmentsAssocForUsername(\Current_User::getUsername(), $this->intern->department_id);
         } else {
             $depts = Department::getDepartmentsAssocForUsername(\Current_User::getUsername());
         }
     }
     $this->form->addSelect('department', $depts);
     $this->form->setLabel('department', 'Department');
     $this->form->addCssClass('department', 'form-control');
     // If the user only has one department, select it for them
     // sizeof($depts) == 2 because of the 'Select Deparmtnet' option
     if (sizeof($depts) == 2) {
         $keys = array_keys($depts);
         $this->form->setMatch('department', $keys[1]);
     }
     /********************
      * Faculty Member Dropdown
      *
      * The options for this drop down are provided through AJAX on page-load and
      * when the user changes the department dropdown above.
      */
     $this->form->addSelect('faculty', array(-1 => 'Select Faculty Advisor'));
     $this->form->setExtra('faculty', 'disabled');
     $this->form->setLabel('faculty', 'Faculty Advisor / Instructor of Record');
     $this->form->addCssClass('faculty', 'form-control');
     // Hidden field for selected faculty member
     $this->form->addHidden('faculty_id');
     /***************
      * Agency info *
      */
     $this->form->addText('agency_name');
     $this->form->addCssClass('agency_name', 'form-control');
     $this->form->addCheck('copy_address_agency');
     $this->form->setLabel('copy_address_agency', "Agency's address is same as Internship's");
     $this->form->addText('agency_address');
     $this->form->setLabel('agency_address', 'Address');
     $this->form->addCssClass('agency_address', 'form-control');
     $this->form->addText('agency_city');
     $this->form->setLabel('agency_city', 'City');
     $this->form->addCssClass('agency_city', 'form-control');
     $this->form->addText('agency_zip');
     $this->form->addCssClass('agency_zip', 'form-control');
     $countries = CountryFactory::getCountries();
     $countries = array('-1' => 'Select Country') + $countries;
     if ($this->intern->domestic) {
         $this->form->addSelect('agency_state', State::$UNITED_STATES);
         $this->form->setLabel('agency_state', 'State');
         $this->form->addCssClass('agency_state', 'form-control');
         $this->form->setLabel('agency_zip', 'Zip Code');
     } else {
         $this->form->addText('agency_province');
         $this->form->setLabel('agency_province', 'Province/Territory');
         $this->form->addCssClass('agency_province', 'form-control');
         $this->form->addSelect('agency_country', $countries);
         $this->form->setLabel('agency_country', 'Country');
         $this->form->addCssClass('agency_country', 'form-control');
         $this->form->setLabel('agency_zip', 'Postal Code');
     }
     $this->form->addText('agency_phone');
     $this->form->setLabel('agency_phone', 'Phone');
     $this->form->addCssClass('agency_phone', 'form-control');
     /***
      * Agency supervisor info
      */
     $this->form->addText('agency_sup_first_name');
     $this->form->setLabel('agency_sup_first_name', 'First Name');
     $this->form->addCssClass('agency_sup_first_name', 'form-control');
     $this->form->addText('agency_sup_last_name');
     $this->form->setLabel('agency_sup_last_name', 'Last Name');
     $this->form->addCssClass('agency_sup_last_name', 'form-control');
     $this->form->addText('agency_sup_title');
     $this->form->setLabel('agency_sup_title', 'Title');
     $this->form->addCssClass('agency_sup_title', 'form-control');
     $this->form->addText('agency_sup_phone');
     $this->form->setLabel('agency_sup_phone', 'Phone');
     $this->form->addCssClass('agency_sup_phone', 'form-control');
     $this->form->addText('agency_sup_email');
     $this->form->setLabel('agency_sup_email', 'Email');
     $this->form->addCssClass('agency_sup_email', 'form-control');
     $this->form->addCheck('copy_address');
     $this->form->setLabel('copy_address', "Supervisor's information is same as agency's");
     $this->form->addText('agency_sup_address');
     $this->form->setLabel('agency_sup_address', 'Address');
     $this->form->addCssClass('agency_sup_address', 'form-control');
     $this->form->addText('agency_sup_city');
     $this->form->setLabel('agency_sup_city', 'City');
     $this->form->addCssClass('agency_sup_city', 'form-control');
     $this->form->addText('agency_sup_zip');
     $this->form->addCssClass('agency_sup_zip', 'form-control');
     if ($this->intern->domestic) {
         $this->form->addSelect('agency_sup_state', State::$UNITED_STATES);
         $this->form->setLabel('agency_sup_state', 'State');
         $this->form->addCssClass('agency_sup_state', 'form-control');
         $this->form->setLabel('agency_sup_zip', 'Zip Code');
     } else {
         $this->form->addText('agency_sup_province');
         $this->form->setLabel('agency_sup_province', 'Province');
         $this->form->addCssClass('agency_sup_province', 'form-control');
         $this->form->addSelect('agency_sup_country', $countries);
         $this->form->setLabel('agency_sup_country', 'Country');
         $this->form->addCssClass('agency_sup_country', 'form-control');
         $this->form->setLabel('agency_sup_zip', 'Postal Code');
     }
     $this->form->addText('agency_sup_fax');
     $this->form->setLabel('agency_sup_fax', 'Fax');
     $this->form->addCssClass('agency_sup_fax', 'form-control');
     /**********************
      * Internship details *
      */
     /***********************
      * Internship location *
      */
     if ($this->intern->isDomestic() && !$this->intern->isInternational()) {
         $this->tpl['LOCATION'] = 'Domestic';
         $this->form->addHidden('location', 'domestic');
     } else {
         if (!$this->intern->isDomestic() && $this->intern->isInternational()) {
             $this->tpl['LOCATION'] = 'International';
             $this->form->addHidden('location', 'international');
         }
     }
     // Domestic fields
     $this->form->addText('loc_address');
     $this->form->setLabel('loc_address', 'Address');
     $this->form->addCssClass('loc_address', 'form-control');
     // City
     $this->form->addText('loc_city');
     $this->form->setLabel('loc_city', 'City');
     $this->form->addCssClass('loc_city', 'form-control');
     // Zip or postal code
     $this->form->addText('loc_zip');
     $this->form->addCssClass('loc_zip', 'form-control');
     // State or Country & Province
     if ($this->intern->isDomestic()) {
         $states = State::getAllowedStates();
         $locationState = $this->intern->getLocationState();
         if ($locationState === null) {
             throw new \InvalidArgumentException('Domestic internship with null value for state.');
         }
         $this->tpl['LOC_STATE'] = $states[$locationState];
         $this->form->setLabel('loc_zip', 'Zip');
     } else {
         $countries = CountryFactory::getCountries();
         $locationCountry = $this->intern->getLocationCountry();
         if ($locationCountry === null) {
             throw new \InvalidArgumentException('International internship with null value for country.');
         }
         $this->tpl['LOC_COUNTRY'] = $countries[$locationCountry];
         // Itn'l location fields
         $this->form->addText('loc_province');
         $this->form->setLabel('loc_province', 'Province/Territory');
         $this->form->addCssClass('loc_province', 'form-control');
         $this->form->setLabel('loc_zip', 'Postal Code');
     }
     /*************
      * Term Info *
      */
     //$terms = Term::getFutureTermsAssoc();
     //$terms[-1] = 'Select Term';
     //$this->form->addSelect('term', $terms);
     //$this->form->setLabel('term', 'Select Term');
     //$this->form->addCssClass('term', 'form-control');
     $this->tpl['TERM'] = Term::rawToRead($this->intern->term);
     $this->form->addText('start_date');
     $this->form->setLabel('start_date', 'Start Date');
     $this->form->addCssClass('start_date', 'form-control');
     $this->form->addText('end_date');
     $this->form->setLabel('end_date', 'End Date');
     $this->form->addCssClass('end_date', 'form-control');
     $this->form->addText('credits');
     $this->form->setLabel('credits', 'Credit Hours');
     $this->form->addCssClass('credits', 'form-control');
     $this->form->addText('avg_hours_week');
     $this->form->setLabel('avg_hours_week', 'Average Hours per Week');
     $this->form->addCssClass('avg_hours_week', 'form-control');
     $this->form->addCheck('multipart');
     $this->form->setLabel('multipart', 'This internship is part of a multi-part experience.');
     $this->form->addCheck('secondary_part');
     $this->form->setLabel('secondary_part', 'This is a secondary part (enrollment complete through primary part).');
     /***************
      * Course Info *
      */
     $subjects = array("-1" => "Select subject...") + Subject::getSubjects();
     $this->form->addSelect('course_subj', $subjects);
     $this->form->setLabel('course_subj', 'Subject');
     $this->form->addCssClass('course_subj', 'form-control');
     $this->form->addText('course_no');
     $this->form->setLabel('course_no', 'Number');
     $this->form->addCssClass('course_no', 'form-control');
     $this->form->addText('course_sect');
     $this->form->setLabel('course_sect', 'Section');
     $this->form->addCssClass('course_sect', 'form-control');
     $this->form->addText('course_title');
     $this->form->setLabel('course_title', 'Title');
     $this->form->setMaxSize('course_title', 28);
     // Limit to 28 chars, per Banner
     $this->form->addCssClass('course_title', 'form-control');
     // Corequisite
     if (!is_null($this->intern)) {
         $dept = $this->intern->getDepartment();
         if ($dept->hasCorequisite()) {
             $this->form->addText('corequisite_course_num');
             $this->form->addCssClass('corequisite_course_num', 'form-control');
             $this->form->addText('corequisite_course_sect');
             $this->form->addCssClass('corequisite_course_sect', 'form-control');
         }
     }
     /************
      * Pay Info *
      */
     $pay = array('unpaid' => 'Unpaid', 'paid' => 'Paid');
     $this->form->addRadioAssoc('payment', $pay);
     $this->form->setMatch('payment', 'unpaid');
     // Default to unpaid
     $this->form->addCheck('stipend');
     $this->form->setLabel('stipend', 'Stipend');
     $this->form->addText('pay_rate');
     $this->form->setLabel('pay_rate', 'Pay Rate');
     $this->form->addCssClass('pay_rate', 'form-control');
     /*******************
      * Internship Type *
      */
     $this->form->addRadioAssoc('experience_type', Internship::getTypesAssoc());
     $this->form->setMatch('experience_type', 'internship');
     /*********
      * Notes *
      */
     $this->form->addTextArea('notes');
     $this->form->setLabel('notes', 'Notes');
     $this->form->addCssClass('notes', 'form-control');
 }
 public function doNotification(Internship $i, $note = null)
 {
     $agency = $i->getAgency();
     Email::sendRegistrationIssueEmail($i, $agency, $note);
 }