From d67b1f9a0cd27f9321f7d0497a24d2353c1783ca Mon Sep 17 00:00:00 2001
From: Eric Cambel
Date: Mon, 14 Mar 2016 09:48:06 -0400
Subject: [PATCH 01/32] Made student component
---
class/InternshipView.php | 25 +++--
.../editInternshipView/InternshipView.jsx | 106 ++++++++++++++++++
templates/editInternshipView.tpl | 13 +++
3 files changed, 135 insertions(+), 9 deletions(-)
create mode 100644 javascript/editInternshipView/InternshipView.jsx
create mode 100644 templates/editInternshipView.tpl
diff --git a/class/InternshipView.php b/class/InternshipView.php
index f2e30411..9a95aae8 100644
--- a/class/InternshipView.php
+++ b/class/InternshipView.php
@@ -31,6 +31,7 @@ public function __construct(Internship $internship, Student $student = null, Wor
public function display()
{
+ /*
$tpl = array();
$tpl['TITLE'] = 'Edit Internship';
@@ -39,37 +40,43 @@ 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);
+ // }
- $form->mergeTemplate($tpl);
+ //$form->mergeTemplate($tpl);
- $this->showWarnings();
- $this->showStudentWarnings();
+ //$this->showWarnings();
+ //$this->showStudentWarnings();
- return \PHPWS_Template::process($form->getTemplate(), 'intern', 'internshipView.tpl');
+ //return \PHPWS_Template::process($form->getTemplate(), 'intern', 'internshipView.tpl');
+ $content = array();
+ //javascriptMod('intern', 'editInternshipView');
+ return \PHPWS_Template::process($content, 'intern', 'editInternshipView.tpl');
}
private function showWarnings()
diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx
new file mode 100644
index 00000000..5bee1a61
--- /dev/null
+++ b/javascript/editInternshipView/InternshipView.jsx
@@ -0,0 +1,106 @@
+
+var EditInternshipInterface = React.createClass({
+ render: function() {
+ return (
+
+
+
+ );
+ }
+});
+
+var StudentInformation = React.createClass({
+ render: function() {
+ return (
+
+ );
+ }
+});
+
+
+React.render(
+ , document.getElementById('editInternshipInterface')
+);
\ No newline at end of file
diff --git a/templates/editInternshipView.tpl b/templates/editInternshipView.tpl
new file mode 100644
index 00000000..e0c49b50
--- /dev/null
+++ b/templates/editInternshipView.tpl
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From c897909f8ad159edffadf8099a2e80d32c82f776 Mon Sep 17 00:00:00 2001
From: Eric Cambel
Date: Tue, 22 Mar 2016 16:09:41 -0400
Subject: [PATCH 02/32] Finalized the student component.
---
class/Command/EditInternshipRest.php | 158 +++++++++++++++++
class/Command/ShowInternship.php | 53 +++---
class/Command/StateRest.php | 2 +-
class/Internship.php | 2 +-
class/InternshipInventory.php | 4 +
class/InternshipView.php | 8 +-
.../editInternshipView/InternshipView.jsx | 165 ++++++++++++++++--
.../emergencyContact/EmgContactList.jsx | 2 +-
templates/editInternshipView.tpl | 6 +-
9 files changed, 348 insertions(+), 52 deletions(-)
create mode 100644 class/Command/EditInternshipRest.php
diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php
new file mode 100644
index 00000000..56b37530
--- /dev/null
+++ b/class/Command/EditInternshipRest.php
@@ -0,0 +1,158 @@
+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()
+ {
+
+ }
+
+ 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 = StudentProviderFactory::getProvider()->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);
+
+ // Load the WorkflowState
+ $wfState = $intern->getWorkflowState();
+
+ // Load the agency
+ $agency = AgencyFactory::getAgencyById($intern->getAgencyId());
+
+ // 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
+ }
+
+ $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs);
+ 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();
+
+ 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;
+ }
+}
+
diff --git a/class/Command/ShowInternship.php b/class/Command/ShowInternship.php
index 762b4f49..5c67e2bb 100644
--- a/class/Command/ShowInternship.php
+++ b/class/Command/ShowInternship.php
@@ -8,6 +8,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
@@ -17,43 +31,22 @@ public function execute()
\PHPWS_Core::reroute('index.php');
}
- // Load the Internship
- try{
- $intern = InternshipFactory::getInternshipById($_REQUEST['internship_id']);
- }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;
- }
+ $tpl = array();
+ //javascriptMod('intern', 'editInternshipView');
- // Load a fresh copy of the student data from the web service
- try {
- $student = StudentProviderFactory::getProvider()->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.");
- }
+ javascript('jquery');
+ $tpl['INTERN_ID'] = $_REQUEST['internship_id'];
- // Load the WorkflowState
- $wfState = $intern->getWorkflowState();
+ return \PHPWS_Template::process($tpl, 'intern', 'editInternshipView.tpl');
- // Load the agency
- $agency = AgencyFactory::getAgencyById($intern->getAgencyId());
-
- // Load the documents
- $docs = $intern->getDocuments();
- if($docs === null) {
- $docs = array(); // if no docs, setup an empty array
- }
+/*
+
$view = new InternshipView($intern, $student, $wfState, $agency, $docs);
return $view->display();
+ */
}
}
diff --git a/class/Command/StateRest.php b/class/Command/StateRest.php
index adc0fca9..3f5c2bdc 100644
--- a/class/Command/StateRest.php
+++ b/class/Command/StateRest.php
@@ -32,7 +32,7 @@ public function get()
$sth = $pdo->prepare($sql);
$sth->execute();
- $result = $sth->fetchAll(PDO::FETCH_ASSOC);
+ $result = $sth->fetchAll(\PDO::FETCH_ASSOC);
return $result;
}
diff --git a/class/Internship.php b/class/Internship.php
index 17de27c9..6a9b6291 100644
--- a/class/Internship.php
+++ b/class/Internship.php
@@ -795,7 +795,7 @@ public function setState(WorkflowState $state){
public function getWorkflowState()
{
$stateName = $this->getStateName();
-
+
if(is_null($stateName)){
return null;
}
diff --git a/class/InternshipInventory.php b/class/InternshipInventory.php
index f6cd99c4..948778b8 100644
--- a/class/InternshipInventory.php
+++ b/class/InternshipInventory.php
@@ -207,6 +207,10 @@ public function handleRequest()
$ctrl = new Command\EmergencyContactRest();
$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 9a95aae8..230ee16a 100644
--- a/class/InternshipView.php
+++ b/class/InternshipView.php
@@ -74,9 +74,13 @@ public function display()
//$this->showStudentWarnings();
//return \PHPWS_Template::process($form->getTemplate(), 'intern', 'internshipView.tpl');
- $content = array();
+ $tpl = array();
//javascriptMod('intern', 'editInternshipView');
- return \PHPWS_Template::process($content, 'intern', 'editInternshipView.tpl');
+
+ javascript('jquery');
+ $tpl['INTERN_ID'] = $this->intern->getId();
+
+ return \PHPWS_Template::process($tpl, 'intern', 'editInternshipView.tpl');
}
private function showWarnings()
diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx
index 5bee1a61..c0af52bd 100644
--- a/javascript/editInternshipView/InternshipView.jsx
+++ b/javascript/editInternshipView/InternshipView.jsx
@@ -1,9 +1,59 @@
var EditInternshipInterface = React.createClass({
+ getInitialState: function() {
+ return {
+ internData: null,
+ stateData: null
+ };
+ },
+ componentWillMount: function(){
+ this.getInternData();
+ this.getStates();
+ },
+ getInternData: function(){
+ // Grabs the internship data
+ $.ajax({
+ url: 'index.php?module=intern&action=editInternshipRest&internshipId='+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)
+ });
+ },
render: function() {
+ if(this.state.internData != null){
+ var interface =
+ }else{
+ var interface =
+ Loading Internship...
+
;
+ }
return (
-
+ {interface}
);
}
@@ -11,6 +61,22 @@ var EditInternshipInterface = React.createClass({
var StudentInformation = React.createClass({
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 (
+
+ );
+ }.bind(this));
+ }
+
return (
-
Next status
+ Next Status
@@ -305,7 +349,7 @@ var InternStatus = React.createClass({
-
+
@@ -314,30 +358,185 @@ var InternStatus = React.createClass({
}
});
-var FacultyInfo = React.createClass({
+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.setState({facultyID: null, 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});
+ },
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;
+
+ //FIX DEPT NAME
+ // WORK HERE TUESDAY - GETTING CHANGE BUTTON WORKING
+ if(facultyData != null){
+ facultyDetail = facultyData.map(function (faculty) {
+ if(facultyID == faculty.id)
+ return (
);
+ }.bind(this));
+ } //this.props.facultyID == null
return (