diff --git a/boost/update.php b/boost/update.php index 7f529241..b08b3956 100644 --- a/boost/update.php +++ b/boost/update.php @@ -44,7 +44,7 @@ function intern_update(&$content, $currentVersion) case version_compare($currentVersion, '0.0.16', '<') : internRunDbMigration('update_0_0_16.sql'); case version_compare($currentVersion, '0.0.17', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.18', '<') : internRunDbMigration('update_0_0_18.sql'); @@ -61,7 +61,7 @@ function intern_update(&$content, $currentVersion) case version_compare($currentVersion, '0.0.24', '<') : internRunDbMigration('update_0_0_24.sql'); case version_compare($currentVersion, '0.0.25', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.26', '<') : internRunDbMigration('update_0_0_26.sql'); @@ -77,15 +77,15 @@ function intern_update(&$content, $currentVersion) internRunDbMigration('update_0_0_31.sql'); case version_compare($currentVersion, '0.0.32', '<') : internRunDbMigration('update_0_0_32.sql'); - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.33', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.35', '<') : internRunDbMigration('update_0_0_35.sql'); case version_compare($currentVersion, '0.0.36', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.37', '<') : internRunDbMigration('update_0_0_37.sql'); @@ -112,7 +112,7 @@ function intern_update(&$content, $currentVersion) case version_compare($currentVersion, '0.1.10', '<') : internRunDbMigration('update_00.01.10.sql'); case version_compare($currentVersion, '0.1.15', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.1.21', '<') : internRunDbMigration('update_00.01.21.sql'); diff --git a/class/ChangeHistoryView.php b/class/ChangeHistoryView.php index e9f4c5d4..23bb6ef1 100644 --- a/class/ChangeHistoryView.php +++ b/class/ChangeHistoryView.php @@ -15,34 +15,39 @@ public function show() { $tpl = array(); - $tpl['CHANGELOG_REPEAT'] = array(); - $changes = ChangeHistoryFactory::getChangesForInternship($this->internship); if(is_null($changes)){ return ""; } + // Needed for key value in react -> ChangeFields class + // untill something better can be thought of. + $id = 0; + foreach($changes as $change){ $changeFields = array(); + $changeFields['id'] = $id++; - $changeFields['RELATIVE_DATE'] = $change->getRelativeDate(); - $changeFields['EXACT_DATE'] = $change->getFormattedDate(); - $changeFields['USERNAME'] = $change->getUsername(); + $changeFields['relative_date'] = $change->getRelativeDate(); + $changeFields['exact_date'] = $change->getFormattedDate(); + $changeFields['username'] = $change->getUsername(); if($change->getFromStateFriendlyname() != $change->getToStateFriendlyName()){ - $changeFields['FROM_STATE'] = $change->getFromStateFriendlyName(); - $changeFields['TO_STATE'] = $change->getToStateFriendlyName(); + $changeFields['from_state'] = $change->getFromStateFriendlyName(); + $changeFields['to_state'] = $change->getToStateFriendlyName(); } $note = $change->getNote(); if(!is_null($note)){ - $changeFields['NOTE'] = $note; + $changeFields['note'] = $note; + } else { + $changeFields['note'] = ''; } - $tpl['changelog_repeat'][] = $changeFields; + $tpl[] = $changeFields; } - return \PHPWS_Template::process($tpl, 'intern', 'changeHistory.tpl'); + return $tpl; } } diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php new file mode 100644 index 00000000..0df40d06 --- /dev/null +++ b/class/Command/EditInternshipRest.php @@ -0,0 +1,561 @@ +post(); + exit; + case 'DELETE': + $this->delete(); + exit; + case 'GET': + $data = $this->get(); + echo (json_encode($data)); + exit; + default: + header('HTTP/1.1 405 Method Not Allowed'); + exit; + } + } + + public function post() + { + $req = \Server::getCurrentRequest(); + $postarray = json_decode($req->getRawData(), true); + + + // id, internId, agencyId, loc_start, loc_end, loc_address, loc_city, loc_zip, loc_province, loc_country +// echo("
");
+// var_dump($postarray);
+// echo("
"); +// exit; + $studentPost = $postarray["internship"]["student"]; + $faculty = $postarray['internship']['faculty']; + $status = $postarray['internship']['status']; + $term = $postarray['internship']['term']; + $type = $postarray['internship']['type']; + + \PHPWS_DB::begin(); + + /******************************** + * Load the existing internship * + */ + try { + $i = \Intern\InternshipFactory::getInternshipById($studentPost['id']); + } catch (\Exception $e) { + // Rollback and re-throw the exception so that admins gets an email + \PHPWS_DB::rollback(); + throw $e; + } + +/* + // Check that the form token matched before we save anything + if($i->form_token == $_REQUEST['form_token']) { + // Generate a new form token + $i->form_token = uniqid(); + } else { + // Form token doesn't match, so show a nice error message + $this->rerouteWithError('index.php?module=intern&action=ShowInternship', 'Some else has modified this internship while you were working. In order to not overwrite their changes, your changes were not saved.'); + } +*/ + + + // Load the student object + try { + $student = ExternalDataProviderFactory::getProvider()->getStudent($i->getBannerId(), $i->getTerm()); + } catch (StudentNotFoundException $e){ + $student = null; + + $this->rerouteWithError('index.php?module=intern&action=ShowInternship', "We couldn't find a matching student in Banner. Your changes were saved, but this student probably needs to contact the Registrar's Office to re-enroll."); + \NQ::close(); + } + + // Student Information Field + $i->first_name = $_REQUEST['student_first_name']; + $i->middle_name = $_REQUEST['student_middle_name']; + $i->last_name = $_REQUEST['student_last_name']; + + $i->setFirstNameMetaphone($_REQUEST['student_first_name']); + $i->setMiddleNameMetaphone($_REQUEST['student_middle_name']); + $i->setLastNameMetaphone($_REQUEST['student_last_name']); + + $i->phone = $_REQUEST['student_phone']; + $i->email = $_REQUEST['student_email']; + + $i->student_address = $_REQUEST['student_address']; + $i->student_city = $_REQUEST['student_city']; + if($_REQUEST['student_state'] != '-1'){ + $i->student_state = $_REQUEST['student_state']; + }else{ + $i->student_state = ""; + } + $i->student_zip = $_REQUEST['student_zip']; + + // Student major handling, if more than one major + // Make sure we have a student object, since it could be null if the Banner lookup failed + if(isset($student) && $student != null) { + $majors = $student->getMajors(); + } else { + $majors = array(); + } + + if(sizeof($majors) > 1) { + + if(!isset($_POST['major_code'])){ + // Student has multiple majors, but user didn't choose one, so just take the first one + $i->major_code = $majors[0]->getCode(); + $i->major_description = $majors[0]->getDescription(); + }else{ + // User choose a major, so loop over the set of majors until we find the matching major code + $code = $_POST['major_code']; + foreach($majors as $m){ + if($m->getCode() == $code){ + $major = $m; + break; + } + } + + $i->major_code = $major->getCode(); + $i->major_description = $major->getDescription(); + } + } else if(sizeof($majors) == 1){ + // Student has exactly one major + $i->major_code = $majors[0]->getCode(); + $i->major_description = $majors[0]->getDescription(); + + } + + + /************************ + * Faculty Advisor Field * + *************************/ + $i->faculty_id = $faculty['faculty_id'] > 0 ? $faculty['faculty_id'] : null; + $i->department_id = $studentPost['department']; + + // Term & Course Information Field + // TERM START AND END DATE + $i->start_date = !empty($term['termStart']) ? strtotime($term['termStart']) : 0; + $i->end_date = !empty($term['termEnd']) ? strtotime($term['termEnd']) : 0; + + // Course info + $i->course_no = !isset($_POST['course_no']) ? null : strip_tags($_POST['course_no']); + $i->course_sect = !isset($_POST['course_sect']) ? null : strip_tags($_POST['course_sect']); + $i->course_title = !isset($_POST['course_title']) ? null : strip_tags($_POST['course_title']); + +//Ensure this is the correct creditHours field.. + $i->credits = (int) $term['creditHours']; + + // Compensation Field + $avg_hours_week = (int) $_REQUEST['avg_hours_week']; + $i->avg_hours_week = $avg_hours_week ? $avg_hours_week : null; + $i->paid = $_REQUEST['payment'] == 'paid'; + $i->stipend = isset($_REQUEST['stipend']) && $i->paid; + $i->pay_rate = $_REQUEST['pay_rate']; + + if (\Current_User::isDeity()) { + $i->term = $_REQUEST['term']; + } + + // Internship experience type + if(isset($_REQUEST['experience_type'])){ + $i->setExperienceType($_REQUEST['experience_type']); + } + + if($i->isInternational()){ + // Set province + $i->loc_province = $_POST['loc_province']; + } + + // Address, city, zip are always set (no matter domestic or international) + $i->loc_address = strip_tags($_POST['loc_address']); + $i->loc_city = strip_tags($_POST['loc_city']); + $i->loc_zip = strip_tags($_POST['loc_zip']); + + if(isset($_POST['course_subj']) && $_POST['course_subj'] != '-1'){ + $i->course_subj = strip_tags($_POST['course_subj']); + }else{ + $i->course_subj = null; + } + + + // Corequisite Course Info +/* UNSURE ABOUT THIS BLOCK + if (isset($_POST['corequisite_course_num'])) { + $i->corequisite_number = $_POST['corequisite_course_num']; + } + + if (isset($_POST['corequisite_course_sect'])) { + $i->corequisite_section = $_POST['corequisite_course_sect']; + } +*/ + + + + /************ + * OIED Certification + */ + // Check if this has changed from non-certified->certified so we can log it later + if($i->oied_certified == 0 && $_POST['oied_certified_hidden'] == 'true'){ + // note the change for later + $oiedCertified = true; + }else{ + $oiedCertified = false; + } + + if($_POST['oied_certified_hidden'] == 'true'){ + $i->oied_certified = 1; + }else if($_POST['oied_certified_hidden'] == 'false'){ + $i->oied_certified = 0; + }else{ + $i->oied_certified = 0; + } + + /************ + * Background and Drug checks + */ + // Check if this has changed from no to yes for sending email + if($i->background_check == 0 && $_REQUEST['background_code'] == '1'){ + // note the change for later + $backgroundCheck = true; + }else{ + $backgroundCheck = false; + } + + if($_REQUEST['background_code'] == '1'){ + $i->background_check = 1; + }else if($_REQUEST['background_code'] == '0'){ + $i->background_check = 0; + } + + if($i->drug_check == 0 && $_REQUEST['drug_code'] == '1'){ + // note the change for later + $drugCheck = true; + }else{ + $drugCheck = false; + } + + if($_REQUEST['drug_code'] == '1'){ + $i->drug_check = 1; + }else if($_REQUEST['drug_code'] == '0'){ + $i->drug_check = 0; + } + + // If we don't have a state and this is a new internship, + // the set an initial state + if($i->id == 0 && is_null($i->state)){ + $state = WorkflowStateFactory::getState('CreationState'); + $i->setState($state); // Set this initial value + } + + try { + $i->save(); + } catch (\Exception $e) { + // Rollback and re-throw the exception so that admins gets an email + \PHPWS_DB::rollback(); + throw $e; + } + + // Update agency + try { + $agency = AgencyFactory::getAgencyById($_REQUEST['agency_id']); + } catch (\Exception $e) { + // Rollback and re-throw the exception so that admins gets an email + \PHPWS_DB::rollback(); + throw $e; + } + + // Agency Info + $agency->name = $_REQUEST['agency_name']; + $agency->address = $_REQUEST['agency_address']; + $agency->city = $_REQUEST['agency_city']; + $agency->zip = $_REQUEST['agency_zip']; + $agency->phone = $_REQUEST['agency_phone']; + + if($i->isDomestic()){ + $agency->state = $_REQUEST['agency_state'] == '-1' ? null : $_REQUEST['agency_state']; + } else { + $agency->province = $_REQUEST['agency_province']; + $agency->country = $_REQUEST['agency_country']== '-1' ? null : $_REQUEST['agency_country']; + } + + // Agency Supervisor Info + $agency->supervisor_first_name = $_REQUEST['agency_sup_first_name']; + $agency->supervisor_last_name = $_REQUEST['agency_sup_last_name']; + $agency->supervisor_title = $_REQUEST['agency_sup_title']; + $agency->supervisor_phone = $_REQUEST['agency_sup_phone']; + $agency->supervisor_email = $_REQUEST['agency_sup_email']; + $agency->supervisor_fax = $_REQUEST['agency_sup_fax']; + $agency->supervisor_address = $_REQUEST['agency_sup_address']; + $agency->supervisor_city = $_REQUEST['agency_sup_city']; + $agency->supervisor_zip = $_REQUEST['agency_sup_zip']; + if($i->isDomestic()){ + $agency->supervisor_state = $_REQUEST['agency_sup_state']; + } else { + $agency->supervisor_province = $_REQUEST['agency_sup_province']; + $agency->supervisor_country = $_REQUEST['agency_sup_country'] == '-1' ? null : $_REQUEST['agency_sup_country']; + } + $agency->address_same_flag = isset($_REQUEST['copy_address']) ? 't' : 'f'; + + try { + DatabaseStorage::save($agency); + } catch (\Exception $e) { + // Rollback and re-throw the exception so that admins gets an email + \PHPWS_DB::rollback(); + throw $e; + } + + /*************************** + * State/Workflow Handling * + ***************************/ + $t = \Intern\WorkflowTransitionFactory::getTransitionByName($_POST['workflow_action']); + $workflow = new \Intern\WorkflowController($i, $t); + try { + $workflow->doTransition(isset($_POST['notes'])?$_POST['notes']:null); + } catch (\Intern\Exception\MissingDataException $e) { + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, $e->getMessage()); + \NQ::close(); + return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $i->id); + } + + // Create a ChangeHisotry for the OIED certification. + if($oiedCertified){ + $currState = WorkflowStateFactory::getState($i->getStateName()); + $ch = new ChangeHistory($i, \Current_User::getUserObj(), time(), $currState, $currState, 'Certified by OIED'); + $ch->save(); + + // Notify the faculty member that OIED has certified the internship + if ($i->getFaculty() != null) { + \Intern\Email::sendOIEDCertifiedNotice($i, $agency); + } + } + + // If the background check or drug check status changed to true (computed earlier), then send a notification + if($backgroundCheck || $drugCheck) { + \Intern\Email::sendBackgroundCheckEmail($i, $agency, $backgroundCheck, $drugCheck); + } + + \PHPWS_DB::commit(); + + $workflow->doNotification(isset($_POST['notes'])?$_POST['notes']:null); + + //var_dump($_POST['generateContract']);exit; + + // If the user clicked the 'Generate Contract' button, then redirect to the PDF view + if(isset($_POST['generateContract']) && $_POST['generateContract'] == 'true'){ + //return \PHPWS_Core::reroute('index.php?module=intern&action=pdf&internship_id=' . $i->id); + echo json_encode($i); + exit; + } else { + // Otherwise, redirect to the internship edit view + + // Show message if user edited internship + \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, 'Saved internship for ' . $i->getFullName()); + \NQ::close(); + + return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $i->id); + } + + + echo("
");
+        var_dump($postarray);
+        echo("
"); + exit; + } + + public function delete() + { + + } + + public function get() + { + // Load the Internship + try{ + $intern = InternshipFactory::getInternshipById($_REQUEST['internshipId']); + }catch(\Intern\Exception\InternshipNotFoundException $e){ + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); + return; + } + + if($intern === false) { + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); + //TODO redirect to the search interface + return; + } + + // Load a fresh copy of the student data from the web service + try { + + $student = StudentFactory::getStudent($intern->getBannerId(), $intern->getTerm()); + + + } catch(\Intern\Exception\StudentNotFoundException $e) { + $studentId = $intern->getBannerId(); + $student = null; + \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a student with an ID of {$studentId} in Banner. This probably means this person is not an active student."); + } + + // Format intern data + $intern = $this->formatIntern($intern); + + $state = $intern->getWorkflowState(); + // Load the WorkflowState + $transitions = $state->getTransitions($intern); + + $workflow = array('status'=>$state->getFriendlyName()); + + // Generate the array of radio buttons to add (one for each possible transition) + $radioButtons = array(); + + foreach($transitions as $t){ + $radioButtons[$t->getName()] = $t->getActionName(); + } + + $workflow['workflowAction'] = $radioButtons; + $workflow['allow'] = true; + + if(!\Current_User::allow('intern', 'oied_certify') || $intern->isDomestic()){ + $workflow['allow'] = false; + } + + $wfState = $workflow; + + $agencies = InternshipAgencyFactory::getHostInfoById($intern->getId()); + + // foreach($agencies as $a){ + // // Load the agency + // var_dump(AgencyFactory::getAgencyById($a['agency_id'])); + // //$agencies[] += AgencyFactory::getAgencyById($a['agency_id']); + // } + // //var_dump($agencies); + // exit; + + // Grab Student Data + $studentData = $this->getStudentData($student, $intern); + + // Load the documents + $docs = $intern->getDocuments(); + // if($docs === null) { + // $docs = array(); // if no docs, setup an empty array + // } else { + $doc = $this->setupDocumentList($docs, $intern->getId()); + //} + + $notes = $this->setupChangeHistory($intern); + + $expType = Internship::getTypesAssoc(); + $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); + + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agencies, "docs" => $doc, "notes" => $notes, "experience_type" => $expType, "subjects" => $subjects); + return $content; + } + + public function formatIntern($intern) + { + $birthday = $intern->getBirthDateFormatted(); + if(is_null($birthday)) { + $intern->birth_date = null; + } else { + $intern->birth_date = $birthday; + } + + $intern->campus = $intern->getCampusFormatted(); + $intern->level = $intern->getLevelFormatted(); + $intern->level = $intern->getLevelFormatted(); + + return $intern; + } + + public function getStudentData($student, $intern) + { + $data = array(); + + // Student object can be null, so be sure we actually have a student first + // TODO: newer PHP versions provide syntax to clean up this logic + if(isset($student)){ + // Credit Hours + $creditHours = $student->getCreditHours(); + if(isset($creditHours)) + { + $data['enrolled_credit_hours'] = $creditHours; + }else{ + $data['enrolled_credit_hours'] = null; + // $this->tpl['ENROLLED_CREDIT_HORUS'] = 'Not Available'; + } + + + // Grad date + $gradDate = $student->getGradDate(); + if(isset($gradDate)) + { + $data['grad_date'] = date('n/j/Y', $gradDate); + }else{ + $data['grad_date'] = null; + //$this->tpl['GRAD_DATE'] = 'Not Available'; + } + + // Major selector + $majors = $student->getMajors(); + $majorsCount = sizeof($majors); + if($majorsCount == 1) { + // Only one major, so display it + $data['major'] = $intern->getMajorDescription(); + } else if($majorsCount > 1) { + // Add a repeat for each major + foreach($majors as $m) { + if($intern->getMajorCode() == $m->getCode()){ + $data['majors_repeat'][] = array('code' => $m->getCode(), 'desc' => $m->getDescription(), 'active' => 'active', 'checked' => 'checked'); + } else { + $data['majors_repeat'][] = array('code' => $m->getCode(), 'desc' => $m->getDescription(), 'active' => '', 'checked' => ''); + } + } + } + } else { + $data['enrolled_credit_hours'] = null; + $data['grad_date'] = null; + $data['major'] = null; + //$this->tpl['ENROLLED_CREDIT_HORUS'] = 'Not Available'; + //$this->tpl['GRAD_DATE'] = 'Not Available'; + } + return $data; + } + + private function setupDocumentList($docs, $id) + { + $data = array(); + + // Document list + if (!is_null($docs)) { + foreach ($docs as $doc) { + $data['docs'][] = array('DOWNLOAD' => $doc->getDownloadLink('blah'), + 'DELETE' => $doc->getDeleteLink()); + } + } + + // Document upload button + $folder = new \Intern\InternFolder(\Intern\InternDocument::getFolderId()); + $data = $folder->documentUpload($id); + + return $data; + } + + private function setupChangeHistory($intern) + { + $historyView = new \Intern\ChangeHistoryView($intern); + return $historyView->show(); + } +} diff --git a/class/Command/FacultyDeptRest.php b/class/Command/FacultyDeptRest.php index 1a27fc57..ea1df5c0 100644 --- a/class/Command/FacultyDeptRest.php +++ b/class/Command/FacultyDeptRest.php @@ -32,7 +32,9 @@ public function execute() private function get() { - $departments = DepartmentFactory::getDepartmentsAssocForUsername(\Current_User::getUsername()); + \PHPWS_Core::initModClass('intern', 'Department.php'); + $departments = \Intern\Department::getDepartmentsAssocForUsername(\Current_User::getUsername()); + $props = array(); diff --git a/class/Command/ShowInternship.php b/class/Command/ShowInternship.php index f60b530c..db596ed7 100644 --- a/class/Command/ShowInternship.php +++ b/class/Command/ShowInternship.php @@ -9,6 +9,20 @@ class ShowInternship { + public function test() + { + + switch($_SERVER['REQUEST_METHOD']) { + case 'GET': + $data = $this->get(); + echo (json_encode($data)); + exit; + default: + header('HTTP/1.1 405 Method Not Allowed'); + exit; + } + } + public function execute() { // Make sure an 'internship_id' key is set on the request @@ -25,13 +39,11 @@ public function execute() \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); return; } - if($intern === false) { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); //TODO redirect to the search interface return; } - // Load a fresh copy of the student data from the web service try { $student = ExternalDataProviderFactory::getProvider()->getStudent($intern->getBannerId(), $intern->getTerm()); @@ -41,17 +53,17 @@ public function execute() \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a student with an ID of {$studentId} in Banner. This probably means this person is not an active student."); } - // Load the WorkflowState - $wfState = $intern->getWorkflowState(); + $tpl = array(); + + $tpl['vendor_bundle'] = \Intern\AssetResolver::resolveJsPath('assets.json', 'vendor'); + $tpl['entry_bundle'] = \Intern\AssetResolver::resolveJsPath('assets.json', 'internshipView'); + $tpl['INTERN_ID'] = $_REQUEST['internship_id']; - // Load the agency - $agency = AgencyFactory::getAgencyById($intern->getAgencyId()); + return \PHPWS_Template::process($tpl, 'intern', 'editInternshipView.tpl'); + + +/* - // Load the documents - $docs = $intern->getDocuments(); - if($docs === null) { - $docs = array(); // if no docs, setup an empty array - } // Load the term info for this internship $termProvider = TermProviderFactory::getProvider(); @@ -60,5 +72,6 @@ public function execute() $view = new InternshipView($intern, $student, $wfState, $agency, $docs, $termInfo); return $view->display(); + */ } } diff --git a/class/Department.php b/class/Department.php index 6e4c3d2a..ce6231e9 100644 --- a/class/Department.php +++ b/class/Department.php @@ -30,9 +30,157 @@ public function getCSV() return array('Department' => $this->name); } + public function getId(){ return $this->id; } + + /** + * @Override Editable::getEditAction + */ + public static function getEditAction() + { + return 'edit_dept'; + } + + /** + * @Override Editable::getEditPermission + */ + public static function getEditPermission() + { + return 'edit_dept'; + } + + /** + * @Override Editable::getDeletePermission + */ + public static function getDeletePermission() + { + return 'delete_dept'; + } + + /** + * @Override Editable::del + * + * Do not show the 'Force Delete?' link if this delete fails. + */ + public function del() + { + if(!\Current_User::allow('intern', $this->getDeletePermission())){ + return \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'You do not have permission to delete departments.'); + } + + if($this->id == 0){ + // Item wasn't loaded correctly + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "Error occurred while loading information from database."); + return; + } + + $name = $this->getName(); + + try{ + // Try to delete item + if(!$this->delete()){ + // Something bad happend. This should have been caught in the check above... + \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, "Error occurred removing $name from database."); + return; + } + // Item deleted successfully. + \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, "Deleted $name"); + }catch(Exception $e){ + if($e->getCode() == DB_ERROR_CONSTRAINT){ + return \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "One or more internship has $this->name as their department. Sorry, cannot delete."); + }else{ + return \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, $e->getMessage()); + } + } + } + + /** + * Return an associative array {id => dept. name} for all the + * departments in database. + * @param $except - Always show the department with this ID. Used for internships + * with a hidden department. We still want to see it in the select box. + */ + public static function getDepartmentsAssoc($except=null) + { + $db = self::getDb(); + $db->addOrder('name'); + $db->addColumn('id'); + $db->addColumn('name'); + $db->addWhere('hidden', 0, '=', 'OR'); + if(!is_null($except)) { + $db->addWhere('id', $except, '=', 'OR'); + } + + $db->setIndexBy('id'); + + return $db->select('col'); + } + + /** + * Return an associative array {id => dept. name} for all the departments + * that the user with $username is allowed to see. + * @param $includeHiddenDept - Include the department with this ID, even if it's hidden. Used for internships + * with a hidden department. We still want to see it in the select box. + */ + public static function getDepartmentsAssocForUsername($username, $includeHiddenDept = null) + { + $db = self::getDb(); + $db->addOrder('name'); + $db->addColumn('id'); + $db->addColumn('name'); + $db->addWhere('hidden', 0, '=', 'OR', 'grp'); + + if(!is_null($includeHiddenDept)){ + $db->addWhere('id', $includeHiddenDept, '=', 'OR', 'grp'); + } + + // If the user doesn't have the 'all_departments' permission, + // then add a join to limit to specific departments + if(!\Current_User::allow('intern', 'all_departments') && !\Current_User::isDeity()){ + $db->addJoin('LEFT', 'intern_department', 'intern_admin', 'id', 'department_id'); + $db->addWhere('intern_admin.username', $username); + } + + $db->setIndexBy('id'); + + $depts = array(); + $depts += $db->select('col'); + + return $depts; + } + + /** + * Add a department to database with the passed name. + */ + public static function add($name) + { + $name = trim($name); + if($name == ''){ + return \NQ::simple('intern', \Intern\NotifyUI::WARNING, 'No name given for new major. No major was added.'); + } + + $db = self::getDb(); + $db->addWhere('name', $name); + if($db->select('count') > 0){ + \NQ::simple('intern', \Intern\NotifyUI::WARNING, "Department $name already exists."); + return; + } + + // Create the new Department Obj. + $dept = new Department(); + + $dept->name = $name; + $dept->hidden = 0; // Be sure to set a default value for this, otherwise it gets set to null and screws things up + $dept->corequisite = 0; // Be sure to set a default value for this, otherwise it gets set to null and screws things up + + $dept->save(); + + // Successfully saved department to DB. Alert user and remind them the department they just saved. + \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, "Department $name added."); + + } public function getName(){ return $this->name; diff --git a/class/InternFolder.php b/class/InternFolder.php index 4588c32e..1fbee825 100644 --- a/class/InternFolder.php +++ b/class/InternFolder.php @@ -3,7 +3,7 @@ namespace Intern; use PHPWS_Link; -use PHPWS_Core; +use \PHPWS_Core; /** * Intern_Folder @@ -34,7 +34,10 @@ public function documentUpload($internshipId) $label = dgettext('filecabinet', 'Add document'); - javascript('open_window'); - return ''; + + return array('label'=> $label, 'address'=> $link->getAddress()); + + // javascript('open_window'); + // return ''; } } diff --git a/class/Internship.php b/class/Internship.php index ca0954ec..da29fd4b 100644 --- a/class/Internship.php +++ b/class/Internship.php @@ -531,6 +531,8 @@ public function getLastName() public function getStartDate($formatted=false) { if (!$this->start_date) { + var_dump("made it"); + exit; return null; } if ($formatted) { @@ -836,7 +838,7 @@ public function setState(WorkflowState $state){ public function getWorkflowState() { $stateName = $this->getStateName(); - + if(is_null($stateName)){ return null; } diff --git a/class/InternshipAgencyFactory.php b/class/InternshipAgencyFactory.php new file mode 100644 index 00000000..326e212d --- /dev/null +++ b/class/InternshipAgencyFactory.php @@ -0,0 +1,30 @@ +getPDO(); + + $stmt = $pdo->prepare("SELECT * FROM intern_internshipAgency + JOIN intern_agency ON intern_internshipAgency.agency_id = intern_agency.id + WHERE intern_internshipAgency.internship_id = :id"); + $stmt->execute(array('id' => $id)); + $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); +//var_dump($id); + return $result; + } +} + diff --git a/class/InternshipInventory.php b/class/InternshipInventory.php index a5db1879..c7711fab 100644 --- a/class/InternshipInventory.php +++ b/class/InternshipInventory.php @@ -246,6 +246,10 @@ public function handleRequest() $ctrl = new Command\SendPendingEnrollmentReminders(); $ctrl->execute(); break; + case 'editInternshipRest': + $ctrl = new Command\EditInternshipRest(); + $ctrl->execute(); + break; default: $menu = new UI\InternMenu(); $this->content = $menu->display(); diff --git a/class/InternshipView.php b/class/InternshipView.php index b68f265d..78cac50e 100644 --- a/class/InternshipView.php +++ b/class/InternshipView.php @@ -33,6 +33,7 @@ public function __construct(Internship $internship, Student $student = null, Wor public function display() { + /* $tpl = array(); // Setup the form @@ -40,40 +41,55 @@ public function display() // Get the Form object $form = $internshipForm->getForm(); + */ /* * If 'missing' is set then we have been redirected * back to the form because the user didn't type in something and * somehow got past the javascript. */ +/* if (isset($_REQUEST['missing'])) { $missing = explode(' ', $_REQUEST['missing']); - +*/ /* * Set classes on field we are missing. */ +/* foreach ($missing as $m) { //$form->addCssClass($m, 'has-error'); $form->addExtraTag($m, 'data-has-error="true"'); } - +*/ /* Plug old values back into form fields. */ - $form->plugIn($_GET); + // $form->plugIn($_GET); /* Re-add hidden fields with object ID's */ - $form->addHidden('id', $this->intern->id); - } + // $form->addHidden('id', $this->intern->id); + // } + $tpl['vendor_bundle'] = AssetResolver::resolveJsPath('assets.json', 'vendor'); $tpl['entry_bundle'] = AssetResolver::resolveJsPath('assets.json', 'emergencyContact'); $form->mergeTemplate($tpl); - $this->showWarnings(); - $this->showStudentWarnings(); - return \PHPWS_Template::process($form->getTemplate(), 'intern', 'internshipView.tpl'); + //$this->showWarnings(); + //$this->showStudentWarnings(); + + +// ********************************************************* +// COME BACK TO THIS - Jan 11, 2017 +// return \PHPWS_Template::process($form->getTemplate(), 'intern', 'internshipView.tpl'); + + javascript('jquery'); + + $content = array(); + //javascriptMod('intern', 'editInternshipView'); + return \PHPWS_Template::process($content, 'intern', 'editInternshipView.tpl'); + } private function showWarnings() diff --git a/class/State.php b/class/State.php index 0260fbe3..ce7f6075 100644 --- a/class/State.php +++ b/class/State.php @@ -43,7 +43,7 @@ public static function getAllowedStates() if (empty($states)) { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to add allowed states.'); \NQ::close(); - PHPWS_Core::goBack(); + \PHPWS_Core::goBack(); } return $states; @@ -66,7 +66,7 @@ public static function getStates() if (empty($result)) { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to add allowed states.'); \NQ::close(); - PHPWS_Core::goBack(); + \PHPWS_Core::goBack(); } $resultState = array(); diff --git a/class/SubselectDatabase.php b/class/SubselectDatabase.php index 46562683..9dd89bb7 100644 --- a/class/SubselectDatabase.php +++ b/class/SubselectDatabase.php @@ -2136,7 +2136,7 @@ public function requireClasses() if (!is_array($files)) { continue; } - PHPWS_Core::initModClass($files[0], $files[1]); + \PHPWS_Core::initModClass($files[0], $files[1]); } $this->load_class = null; } @@ -2173,7 +2173,7 @@ public function loadObject($object, $require_where = true) return false; } - return PHPWS_Core::plugObject($object, $variables); + return \PHPWS_Core::plugObject($object, $variables); } // END FUNC loadObject @@ -2235,11 +2235,11 @@ public function getObjects($class_name) if (isset($itemResult[0]) && is_array($itemResult[0])) { foreach ($itemResult as $key => $sub) { $genClass = new $class_name; - PHPWS_Core::plugObject($genClass, $sub, $args); + \PHPWS_Core::plugObject($genClass, $sub, $args); $items[$indexby][] = $genClass; } } else { - PHPWS_Core::plugObject($genClass, $itemResult, $args); + \PHPWS_Core::plugObject($genClass, $itemResult, $args); $items[$indexby] = $genClass; } } diff --git a/class/SubselectPager.php b/class/SubselectPager.php index dc649f54..486fb752 100644 --- a/class/SubselectPager.php +++ b/class/SubselectPager.php @@ -1266,7 +1266,7 @@ function createReport() $result = call_user_func($this->report_row, $foo); } else { if (is_object($foo)) { - $result = PHPWS_Core::stripObjValues($foo); + $result = \PHPWS_Core::stripObjValues($foo); } else { $result = & $foo; } @@ -1309,7 +1309,7 @@ public function plugPageTags(&$template) public function saveLastView() { - $_SESSION['DBPager_Last_View'][$this->table] = PHPWS_Core::getCurrentUrl(); + $_SESSION['DBPager_Last_View'][$this->table] = \PHPWS_Core::getCurrentUrl(); } public static function getLastView($table) diff --git a/class/WorkflowTransitionFactory.php b/class/WorkflowTransitionFactory.php index 994bb688..59d3b9d7 100644 --- a/class/WorkflowTransitionFactory.php +++ b/class/WorkflowTransitionFactory.php @@ -65,7 +65,7 @@ public static function getAllTransitions() // Look for directories that don't start with '.' if(!is_dir($dir . '/' . $f) && substr($f, 0, 1) != '.'){ // Include each one - PHPWS_Core::initModClass('intern', self::$dir . '/' . $f); + \PHPWS_Core::initModClass('intern', self::$dir . '/' . $f); $className = preg_replace('/\.php/', '', $f); $className = '\Intern\WorkflowTransition\\' . $className; diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx new file mode 100644 index 00000000..8cadf637 --- /dev/null +++ b/javascript/editInternshipView/InternshipView.jsx @@ -0,0 +1,1470 @@ +//Needed to turn off spacing rule for the file +/* eslint react/jsx-equals-spacing: 0 */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import $ from 'jquery'; +import {Button, Modal} from 'react-bootstrap'; +import classNames from 'classnames'; +import EmergencyContactList from '../emergencyContact/EmgContactList.jsx'; + +// this.props.internshipId is an internshipId taken from the phpfile. +// Used to save the internship. + +var EditInternshipInterface = React.createClass({ + getInitialState: function() { + return { + internData: null, + departmentData: null, + facultyData: null, + stateData: null, + submitted: false + }; + }, + componentWillMount: function(){ + this.getInternData(); + this.getStates(); + this.getDepartmentData(); + }, + saveInternship: function(e){ + e.preventDefault(); + var form = e.target; + var thisComponent = this; + + this.setState({submitted: true}, function(){ + // After disabling submit buttons, use callback to validate the data + if(!true){ + // If the data doesn't validate, wait a second before re-enabling the submit button + // This makes sure the user sees the "Creating..." spinner, instead of it re-rendering + // so fast that they don't think it did anything + setTimeout(function(){ + thisComponent.setState({submitted: false}); + // thisComponent.refs.mainInterface.buildInternshipData(form); + }, 1000); + + return; + } + + setTimeout(function(){ + thisComponent.setState({submitted: false}); + var data = thisComponent.refs.mainInterface.buildInternshipData(form); + console.log(data); + $.ajax({ + url: 'index.php?module=intern&action=editInternshipRest&internshipId=' + this.props.internshipId, + type: 'POST', + processData: false, + dataType: 'json', + data: JSON.stringify(data), + success: function() { + console.log("success!"); + }, + error: function(xhr, status, err) { + alert("Failed to save intern data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, 1000); + }); + }, + getInternData: function(){ + // Grabs the internship data + $.ajax({ + url: 'index.php?module=intern&action=editInternshipRest&internshipId=' + this.props.internshipId, + type: 'GET', + dataType: 'json', + success: function(data) { + console.log(data); + this.setState({internData: data}); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load intern data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + getStates: function(){ + // Grabs the State data + $.ajax({ + url: 'index.php?module=intern&action=stateRest', + type: 'GET', + dataType: 'json', + success: function(data) { + this.setState({stateData: data}); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load state data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + //getFacultyListForDept&department + getFacultyData: function(deptNum){ + // Grabs the State data + $.ajax({ + url: 'index.php?module=intern&action=getFacultyListForDept&department='+deptNum, + type: 'GET', + dataType: 'json', + success: function(data) { + if(data !== '') + { + data.unshift({first_name: "None", last_name: "", id: "-1"}); + this.setState({facultyData: data}); + } else { + this.setState({facultyData: null}); + } + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load faculty data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + getDepartmentData: function(){ + // Grabs the State data + $.ajax({ + url: 'index.php?module=intern&action=facultyDeptRest', + type: 'GET', + dataType: 'json', + success: function(data) { + this.setState({departmentData: data}); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load department data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + render: function() { + if(this.state.internData != null){ + return + }else{ + return(

+ Loading Internship... +

+ ); + } + } +}); + +var MainInterface = React.createClass({ + buildInternshipData: function(form) { + var student = this.refs.student.grabStudentData(); + var status = this.refs.status.grabStatusData(form); + var faculty = this.refs.faculty.grabFacultyData(); + var term = this.refs.term.grabCourseAndTerm(); + var type = this.refs.type.grabTypeData(form); + var host = this.refs.host.buildHostData(form); + + var internship = {student: student, + status: status, + faculty: faculty, + term: term, + type: type}; + + + var internData = {internship: internship, + host: host}; + return internData; + //Host Information + //var status = this.refs.student.grabStudentData(); + }, + render: function() { + var internData = this.props.internData; + var stateData = this.props.stateData; + var facultyData = this.props.facultyData; + var departmentData = this.props.departmentData; + + console.log(internData.agency); + + //var deleteURL = "index.php?module=intern&action=DeleteInternship&internship_id=" + internshipId; + return( +
+

+ Edit Internship +

+ +
+ +
+
+ +
+ +
+ Delete +
+ +
+ +
+
+ + +
+
+ + +
+ +
+ + + + + + + +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ {internData.agency.map(function (agency) { + return ( + + ); + })} + +
+
+ +
+
+ +
+ +
+ + +
+
+ + + +
+ ); + } +}); + +var SaveInternshipButton = React.createClass({ + render: function() { + var button = null; + if(this.props.submitted) { + button = ; + } else { + button = ; + } + return ( + button + ); + } +}); + +var StudentInformation = React.createClass({ + grabStudentData: function() { + + var student = { id: this.props.intern.banner, + fname: this.refs.fname.value, + lname: this.refs.lname.value, + mname: this.refs.mname.value, + email: this.refs.email.value, + address: this.refs.address.value, + city: this.refs.city.value, + state: this.refs.state.value, + zip: this.refs.zip.value, + phone: this.refs.phone.value, + department: this.props.intern.department_id} + + return student; + }, + render: function() { + var intern = this.props.intern; + var student = this.props.student; + var stateData = ''; + + if(this.props.states != null){ + stateData = this.props.states.map(function (state) { + return ( + + ); + }); + } + + return ( +
+ Student +
+ +

{intern.banner}

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ @appstate.edu +
+
+
+ +
+ +

{intern.birth_date}

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +

{intern.gpa}

+
+ +
+ +

{intern.campus}

+
+ +
+ +

{intern.level}

+
+ +
+ + +
+
+ + {student.majors_repeat.map(function (major) { + return ( + + ); + })} + +
+
+
+ +
+ +

+ {student.grad_date == null ? Not Available + : student.grad_date + } +

+
+ +
+ +

+ {student.enrolled_credit_hours == null ? Not Available + : student.enrolled_credit_hours + } +

+
+
+ ); + } +}); + +var StateDropDown = React.createClass({ + render: function() { + if (this.props.active === 1 && this.props.stuState === this.props.sAbbr){ + return + }else { + return + } + } +}); + +var MajorSelector = React.createClass({ + render: function() { + var setActive = (this.props.active === 'active') ? true : false; + + var activeButton = classNames({ + 'btn' : true, + 'btn-default' : true, + 'active' : setActive + }); + + var majorSelect = null; + if (this.props.checked === 'checked'){ + majorSelect = + }else{ + majorSelect = + } + return ( + majorSelect + ); + } +}); + + +var EmgContactList = React.createClass({ + render: function() { + return ( +
+ Emergency Contacts +
+
+ +
+
+
+ ); + } +}); + +var InternStatus = React.createClass({ + grabStatusData: function(form) { + var status = { status: form.elements.workflowOption.value, + oied: form.elements.oiedCert.checked} + + return status; + }, + render: function() { + var status = this.props.workflow.status; + var workflowAction = this.props.workflow.workflowAction; + var oiedAllow = this.props.workflow.allow; + +/**************** + NOT DONE!!! * + ****************/ + + return ( +
+ Status +

+ Current Status: {status} +

+
+
+

Next Status

+
+
+ + {Object.keys(workflowAction).map(function(key) { + if(key === "Intern\\WorkflowTransition\\LeaveTransition"){ + return(
+ +
) + } else { + return(
+ +
) + } + })} + +
+
+
+
+
+ { oiedAllow ? + : + } + +
+
+
+
+ ); + } +}); + +var FacultyInterface = React.createClass({ + getInitialState: function(){ + return {showDetails: false, facultyID: null}; + }, + //Query for list of departments for first drop down + //Query based on chosen department for second drop down + //Use second dropdown information for details page. + componentWillMount: function() { + this.getFacultyData(); + }, + getFacultyData: function() { + if (this.props.deptNumber !== '' && this.props.facultyID != null) + { + this.setState({facultyID: this.props.facultyID, showDetails: true}, this.props.getFacultyData(this.props.deptNumber)); + } else { + this.setState({facultyID: null, showDetails: false}); + } + }, + setFacultyID: function(num) { + this.setState({facultyID: num, showDetails: true}); + }, + hideDetailInfo: function() { + this.setState({facultyID: null,showDetails: false}); + }, + grabFacultyData: function() { + var faculty = {faculty_id: this.state.facultyID}; + return faculty; + }, + render: function() { + + if (this.props.departmentData == null){ + + return (
) + } + var facultyDetail = null; + var facultyData = this.props.facultyData; + var facultyID = (this.state.facultyID != null) ? this.state.facultyID :this.props.facultyID; + var dept = this.props.departmentData; + var deptNum = this.props.deptNumber; +console.log(deptNum); + //FIX DEPT NAME + if(facultyData != null){ + //console.log("Made it") + facultyDetail = facultyData.map(function (faculty) { + if(facultyID === faculty.id) + return (); + }.bind(this)); + } //this.props.facultyID == null + return ( +
+ Faculty Advisor + {(this.state.showDetails) ? facultyDetail + : } +
+ ); + } + +}); + +var FacultyDropDown = React.createClass({ + componentWillMount: function() { + this.props.getFacultyData(this.props.deptNumber); + }, + handleDeptDrop: function(e) { + var deptNum = e.target.value; + + this.props.getFacultyData(deptNum); + }, + handleFaculty: function(e) { + var faculty = e.target.value; + this.props.setFacultyID(faculty); + + }, + render: function() { + var departments = this.props.departmentData; + var facultyData = this.props.facultyData; + var deptNumber = this.props.deptNumber; + var ddFaculty = null; + + if (this.props.facultyData == null){ + ddFaculty = + } else { + ddFaculty = + } + return( +
+
+ +
+ +
+
+
+ +
+ {ddFaculty} +
+
+
+ ); + } +}); + +var FacultyDetail = React.createClass({ + handleClick: function() { + this.props.hideDetailInfo(); + }, + render: function() { + var name = this.props.fname + " " + this.props.lname + " - " + this.props.deptname; + + + // Format Faculty Email + var emailInfo = "mailto:" + this.props.username + "@appstate.edu"; + var email = {this.props.username + "@appstate.edu"} + + // Format Faculty Phone + var phone = ''; + if(this.props.phone !== ''){ + var phoneInfo = "tel:+1" + this.props.phone; + phone = {this.props.phone} ; + } else { + phone = Has not been set; + } + + // Format Faculty Fax + var fax = ''; + if(this.props.fax !== ''){ + var faxInfo = "fax:+1" + this.props.fax; + fax = {this.props.fax} ; + } else { + fax = Has not been set; + } + + // Format Faculty Address + var address = ''; + if(this.props.address1 !== '' && this.props.address1 !== null){ + address += this.props.address1; + + if (this.props.address2 !== '') { + address += "
" + this.props.address2; + } + } else { + address = Address has not been set; + } + if(this.props.city !== '' && this.props.city !== null && this.props.state !== '' && this.props.state !== null){ + address += "
" + this.props.city + ", " + this.props.state; + } + if(this.props.zip !== '' && this.props.zip !== null) { + address += " " + this.props.zip; + } + + + return ( +
+ +
+
+ +
+
{name}
+
+ +
+
+ +
+
+

+   + {email} +

+
+
+ +
+
+

+   + {phone} +

+
+
+ +
+
+

+   + {fax} +

+
+
+
+ +
+   +
{address}
+
+
+
+ ); + } +}); + +var CourseAndTerm = React.createClass({ + grabCourseAndTerm: function(form) { + var courseTerm = {termStart: this.refs.startDate.value, + termEnd: this.refs.endDate.value, + courseSubj: this.refs.courseSubj.value, + courseNum: this.refs.courseNum.value, + section: this.refs.courseSect.value, + creditHours: this.refs.courseCH.value, + title: this.refs.courseTitle.value}; + return courseTerm; + }, + render: function() { + var intern = this.props.intern; + var subjects = this.props.subjects; + return( +
+
+ Term & Course Information + +
+ +

{intern.term}

+
+ + +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ +
+
+ +
+ +
+
+ +
+ +
+ Decimal values will be rounded. +
+
+ +
+ +
+ (Limit 28 characters; Banner) +
+
+
+
+ ); + } +}); + + +var TypeInterface = React.createClass({ + getInitialState: function() { + return {showModal: false}; + }, + closeModal: function() { + this.setState({ showModal: false }); + }, + openModal: function() { + this.setState({ showModal: true }); + }, + grabTypeData: function(form) { + var type = { type: form.elements.typeOption.value} + + return type; + }, + render: function() { + var expType = this.props.experience_type; + return( +
+
+ Type +
+
+ {Object.keys(expType).map(function(key) { + if(key === "internship"){ + return(
+ +
) + } else { + return(
+ +
) + } + })} +
+ +
+
+
+ ); + } +}); + +var TypeModalForm = React.createClass({ + render: function() { + return ( + + +

Internship Type Definitions

+
+ +
+
+
+

Student Teaching

+

A course requiring students to instruct or teach at an entity external to the institution, generally as part of the culminating curriculum of a teacher education or certificate program.

+ +

Practicum

+

A course requiring students to participate in an approved project or proposal that practically applies previously studied theory of the field or discipline under the supervision of an expert or qualified representative of the field or discipline.

+ +

Clinical

+

A course requiring medical- or healthcare-focused experiential work where students test, observe, experiment, or practice a field or discipline in a hands-on or simulated environment.

+ +

Internship

+

A course requiring students to participate in a partnership, professional employment, work experience or cooperative education with any entity external to the institution, generally under the supervision of an employee of the external entity.

+
+
+
+
+ + + +
+ ); + } +}); + +var NoteBox = React.createClass({ + grabNoteData: function() { + + }, + render: function() { + return( + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + ); + } +}); + +var ChangeLog = React.createClass({ + render: function() { + return( +
+
+

Change History

+ {this.props.noteData.map(function (notes) { + return ( + + ); + })} +
+
+ ); + } +}); + +var ChangeFields = React.createClass({ + render: function() { + return( +
+
+

+ {this.props.exactDate}Changed {this.props.relativeData} ago by {this.props.username} +

+ {this.props.fromState !== undefined ? +
    +
  • Status changed from {this.props.fromState} to {this.props.toState} +
  • +
+ : null} +
{this.props.note}
+
+
+ ); + } +}); + +// var DropzoneDemo = React.createClass({ +// onDrop: function (files) { +// console.log('Received files: ', files); +// }, +// +// render: function () { +// return ( +//
+// +//
Try dropping some files here, or click to select files to upload.
+//
+//
+// ); +// } +// }); + + + + +// <--------------------------------------------Host Information Section----------------------------------------------> + +var HostInterface = React.createClass({ + buildHostData: function(form) { + var location = this.refs.location.grabLocationData(); + var compensation = this.refs.compensation.grabCompensationData(form); + var contract = this.refs.contract.grabContractData(); + var hostDetails = this.refs.hDetails.grabHostData(); + var superDetails = this.refs.sDetails.grabSupervisorData(); + + var hostData = {location: location, + compensation: compensation, + contract: contract, + hostDetails: hostDetails, + superDetails: superDetails}; + + return hostData; + }, + render: function() { + var hostData = this.props.hostData; + var intern = this.props.intern; + var docs = this.props.docs; + return( +
+
+

Host Information: {hostData.name}

+
+
+
+
+ + + +
+
+ + +
+
+
+
+ ); + } +}); + +var Location = React.createClass({ + grabLocationData: function() { + var locationData = { + loc_address: this.refs.locAddress.value, + loc_city: this.refs.locCity.value, + loc_zip: this.refs.locZip.value, + loc_start: this.refs.locStart.value, + loc_end: this.refs.locEnd.value + }; + + return locationData; + }, + render: function() { + var hostData = this.props.hostData; + var domestic = this.props.domestic; + var locState = ""; + var zip = ""; + if(domestic){ + locState = "State"; + zip = "Zip"; + } else { + locState = "Country"; + zip = "Postal Code"; + } + return( +
+
+ Location + +
+ +

{hostData.international}

+
+ +
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +

{hostData.loc_state}

+
+ + {!domestic ?
+ +

{hostData.loc_province}

+
+ : null} + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ ); + } +}); + + + +var Compensation = React.createClass({ + getInitialState: function() { + return { + paid: false, + stipend: false + }; + }, + componentWillMount: function() { + var intern = this.props.intern; + if(intern.paid === true){ + this.setState({paid: true}); + } + + if(intern.stipend === true){ + this.setState({stipend: true}); + } + }, + grabCompensationData: function(form) { + + var compensationData = { + paid: this.state.paid, + stipend: this.state.stipend, + pay_rate: this.refs.payRate.value, + avg_hours_week: this.refs.hoursPerWeek.value + }; + + return compensationData; + }, + changePaid: function(e) { + this.setState({paid: e.currentTarget.value}); + }, + changeStipend: function(e) { + this.setState({stipend: e.currentTarget.checked}); + }, + render: function() { + //var hostData = this.props.hostData; + var intern = this.props.intern; + //var allow = intern.stipend; + var rButtons; + var rName = this.props.hostData.id; + + if(this.state.paid === false){ + rButtons =
+ + +
+ } else { + rButtons =
+ + +
+ } + + return( +
+
+ Compensation +
+
+ + {rButtons} + +
+ { this.state.stipend ? + : + } +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+ ); + } +}); + +var Contracts = React.createClass({ + grabContractData: function() { + + }, + render: function() { + var change = undefined; + return( +
+
+ {this.props.title} +
+
+ {change !== undefined ? +
    +
  • DOWNLOAD  DELETE
  • +
+ : null + } +
+
+ +
+ + +
+
+
+ ); + } +}); + +var HostDetails = React.createClass({ + grabHostData: function() { + var hostData = { + name: this.refs.name.value, + phone: this.refs.phone.value, + address: this.refs.address.value, + city: this.refs.city.value, + state: this.refs.state.value, + zip: this.refs.zip.value + } + + return hostData; + }, + render: function() { + var hostData = this.props.hostData; + var stateData = ''; + + if(this.props.states != null){ + stateData = this.props.states.map(function (state) { + return ( + + ); + }); + } + return( +
+
+ Host Details +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ ); + } +}); + +var SupervisorInfo = React.createClass({ + grabSupervisorData: function() { + var superData = { + fname: this.refs.fname.value, + lname: this.refs.lname.value, + title: this.refs.title.value, + email: this.refs.email.value, + fax: this.refs.fax.value, + phone: this.refs.phone.value, + address: this.refs.address.value, + city: this.refs.city.value, + state: this.refs.state.value, + zip: this.refs.zip.value + } + + return superData; + }, + render: function() { + var hostData = this.props.hostData; + var stateData = ''; + + if(this.props.states != null){ + stateData = this.props.states.map(function (state) { + return ( + + ); + }); + } + return( +
+
+ Supervisor Information +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ ); + } +}); + +ReactDOM.render( + , + document.getElementById('content') +); diff --git a/javascript/emergencyContact/EmgContactList.jsx b/javascript/emergencyContact/EmgContactList.jsx index 6ee2059b..fdddac47 100644 --- a/javascript/emergencyContact/EmgContactList.jsx +++ b/javascript/emergencyContact/EmgContactList.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import ReactDOM from 'react-dom'; import $ from 'jquery'; import {Button, Modal} from 'react-bootstrap'; @@ -233,8 +232,4 @@ var EmergencyContactList = React.createClass({ } }); - -ReactDOM.render( - , - document.getElementById('emergency-contact-list') -); +export default EmergencyContactList; diff --git a/templates/editInternshipView.tpl b/templates/editInternshipView.tpl new file mode 100644 index 00000000..9fc48cf4 --- /dev/null +++ b/templates/editInternshipView.tpl @@ -0,0 +1,8 @@ +
+ + + + + diff --git a/webpack.config.dev.js b/webpack.config.dev.js index 9fe2010e..8140226b 100644 --- a/webpack.config.dev.js +++ b/webpack.config.dev.js @@ -14,13 +14,14 @@ module.exports = { editAdmin: JS_DIR + '/editAdmin/editAdmin.jsx', editDepartment: JS_DIR + '/editDepartment/deptEditor.jsx', stateList: JS_DIR + '/stateList/StateList.jsx', - emergencyContact: JS_DIR + '/emergencyContact/EmgContactList.jsx', + //emergencyContact: JS_DIR + '/emergencyContact/EmgContactList.jsx', facultyEdit: JS_DIR + '/facultyEdit/FacultyEdit.jsx', editMajor: JS_DIR + '/editMajor/editMajor.jsx', editGrad: JS_DIR + '/editGrad/editGrad.jsx', affiliationDepartments: JS_DIR + '/affiliationAgreement/AffiliationDepartments.jsx', affiliationLocation: JS_DIR + '/affiliationAgreement/AffiliationLocation.jsx', affiliationTerminate: JS_DIR + '/affiliationAgreement/AffiliationTerminate.jsx', + internshipView: JS_DIR + '/editInternshipView/InternshipView.jsx', vendor: ['jquery', 'react', 'react-dom', 'react-bootstrap'] }, output: { diff --git a/webpack.config.prod.js b/webpack.config.prod.js index 6bb7b5ad..09cf4b4c 100644 --- a/webpack.config.prod.js +++ b/webpack.config.prod.js @@ -17,13 +17,14 @@ module.exports = { editAdmin: JS_DIR + '/editAdmin/editAdmin.jsx', editDepartment: JS_DIR + '/editDepartment/deptEditor.jsx', stateList: JS_DIR + '/stateList/StateList.jsx', - emergencyContact: JS_DIR + '/emergencyContact/EmgContactList.jsx', + //emergencyContact: JS_DIR + '/emergencyContact/EmgContactList.jsx', facultyEdit: JS_DIR + '/facultyEdit/FacultyEdit.jsx', editMajor: JS_DIR + '/editMajor/editMajor.jsx', editGrad: JS_DIR + '/editGrad/editGrad.jsx', affiliationDepartments: JS_DIR + '/affiliationAgreement/AffiliationDepartments.jsx', affiliationLocation: JS_DIR + '/affiliationAgreement/AffiliationLocation.jsx', affiliationTerminate: JS_DIR + '/affiliationAgreement/AffiliationTerminate.jsx', + internshipView: JS_DIR + '/editInternshipView/InternshipView.jsx', vendor: ['jquery', 'react', 'react-dom', 'react-bootstrap'] }, output: {