diff --git a/boost/updates/update_01.00.00.sql b/boost/updates/update_01.00.00.sql index a5108725..bff583b0 100644 --- a/boost/updates/update_01.00.00.sql +++ b/boost/updates/update_01.00.00.sql @@ -1,8 +1,3 @@ - --reason for admin stop that only they see - --reason for stop that user sees - --Warning, Stop - --name to check sup on flag - --see about having this as Admin Setting CREATE TABLE intern_special_host( id INT NOT NULL, admin_message VARCHAR NOT NULL, @@ -14,20 +9,16 @@ CREATE TABLE intern_special_host( PRIMARY KEY(id) ); ---overall host name ---flag to show if a new host or one that is awaiting approval 0=not approved 1=approve 2=awaiting CREATE TABLE intern_host ( id INT NOT NULL, host_name VARCHAR NOT NULL, - host_condition INT REFERENCES intern_special_host(id), + host_condition INT DEFAULT NULL REFERENCES intern_special_host(id), host_condition_date VARCHAR, host_approve_flag INT NOT NULL DEFAULT 2, host_notes VARCHAR, PRIMARY KEY(id) ); ---sub name of host that will contain the address information ---flag to show if a new host or one that is awaiting approval 0=not approved 1=approve 2=awaiting CREATE TABLE intern_sub_host ( id INT NOT NULL, main_host_id INT REFERENCES intern_host(id), @@ -39,17 +30,16 @@ CREATE TABLE intern_sub_host ( province VARCHAR, country VARCHAR, other_name VARCHAR, - sub_condition INT REFERENCES intern_special_host(id), + sub_condition INT DEFAULT NULL REFERENCES intern_special_host(id), sub_condition_date VARCHAR, sub_approve_flag INT NOT NULL DEFAULT 2, sub_notes VARCHAR, PRIMARY KEY(id) ); ---be able to handle old and new sups CREATE TABLE intern_supervisor( id INT NOT NULL, - host_id INT REFERENCES intern_host(id), + host_id INT DEFAULT NULL REFERENCES intern_host(id), supervisor_first_name VARCHAR NULL, supervisor_last_name VARCHAR NULL, supervisor_title VARCHAR NULL, @@ -66,7 +56,6 @@ CREATE TABLE intern_supervisor( PRIMARY KEY(id) ); ---agency_id keep for old records for now ALTER TABLE intern_internship ADD COLUMN supervisor_id INT; ALTER TABLE intern_internship ADD COLUMN host_id INT; ALTER TABLE intern_internship ADD COLUMN host_sub_id INT; diff --git a/class/Command/HostRest.php b/class/Command/HostRest.php index 6cd4ecb9..8317e16f 100644 --- a/class/Command/HostRest.php +++ b/class/Command/HostRest.php @@ -58,7 +58,7 @@ public function get() { $sql = "SELECT id, host_name, host_condition, host_approve_flag FROM intern_host WHERE host_approve_flag = 2 ORDER BY host_name ASC"; } else if(isset($_REQUEST['Condition'])){ $sql = "SELECT intern_host.id, host_name, host_condition, host_approve_flag, host_condition_date, host_notes, admin_message, intern_special_host.id AS con_id - FROM intern_host JOIN intern_special_host ON intern_host.host_condition = intern_special_host.id WHERE host_condition IS NOT NULL ORDER BY host_name ASC"; + FROM intern_host LEFT JOIN intern_special_host ON intern_host.host_condition = intern_special_host.id ORDER BY host_name ASC"; } else if(isset($_REQUEST['Waiting'])){ if($_REQUEST['Waiting']){ $sql = "SELECT id, host_name, host_condition, host_approve_flag FROM intern_host WHERE host_approve_flag != 0 ORDER BY host_name ASC"; diff --git a/class/Command/SubRest.php b/class/Command/SubRest.php index 58d04d88..827a7cd5 100644 --- a/class/Command/SubRest.php +++ b/class/Command/SubRest.php @@ -56,12 +56,12 @@ public function get() { if($_REQUEST['domestic']=='true'){ $Main = $_REQUEST['main']; $State = $_REQUEST['location']; - $sql = "SELECT id, main_host_id, sub_name, sub_condition FROM intern_sub_host WHERE main_host_id = :main AND state = :state ORDER BY sub_name ASC"; + $sql = "SELECT id, main_host_id, sub_name, sub_condition FROM intern_sub_host WHERE main_host_id = :main AND state = :state AND sub_approve_flag != 0 ORDER BY sub_name ASC"; $arr = array('main' => $Main, 'state'=>$State); } else if($_REQUEST['domestic']=='false'){ $Main = $_REQUEST['main']; $Country = $_REQUEST['location']; - $sql = "SELECT id, main_host_id, sub_name, sub_condition FROM intern_sub_host WHERE main_host_id = :main AND country = :country ORDER BY sub_name ASC"; + $sql = "SELECT id, main_host_id, sub_name, sub_condition FROM intern_sub_host WHERE main_host_id = :main AND country = :country AND sub_approve_flag != 0 ORDER BY sub_name ASC"; $arr = array('main' => $Main, 'country'=>$Country); } } else if(isset($_REQUEST['Conditions'])){ diff --git a/class/EditInternshipFormView.php b/class/EditInternshipFormView.php index 8910ec49..cc824d6b 100644 --- a/class/EditInternshipFormView.php +++ b/class/EditInternshipFormView.php @@ -128,7 +128,7 @@ public function buildInternshipForm() { /********************* * Copy to Next Term * *********************/ - if($this->intern->getStateName() != 'DeniedState'){ + if($this->intern->getStateName() != 'DeniedState' && \Current_User::allow('intern', 'create_internship')){ // Get next three terms $term = TermFactory::getTermByTermCode($this->intern->getTerm()); @@ -164,6 +164,8 @@ public function buildInternshipForm() { if(sizeof($this->tpl['CONTINUE_TERM_LIST']) == 0) { $this->tpl['CONTINUE_TERM_NO_TERMS'] = 'No future terms available.'; } + } else if(!\Current_User::allow('intern', 'create_internship')){ + $this->tpl['CONTINUE_TERM_NO_TERMS'] = 'You do not have permission to create new internships.'; } else{ $this->tpl['CONTINUE_TERM_NO_TERMS'] = 'No future terms available.'; } diff --git a/class/SubHostFactory.php b/class/SubHostFactory.php index 131e5d7b..74ea6aad 100644 --- a/class/SubHostFactory.php +++ b/class/SubHostFactory.php @@ -158,8 +158,8 @@ public static function getSubHostCond($m_host_id, $state, $country) { if ($country == 'US') { $stmt = $db->prepare("SELECT ish.id, ish.sub_name FROM intern_sub_host AS ish LEFT JOIN intern_special_host AS isp ON ish.sub_condition=isp.id - WHERE ish.state=:state AND ish.main_host_id=:m_host_id - AND (ish.sub_condition IS null OR isp.stop_level<>'Stop')"); + WHERE ish.state=:state AND ish.main_host_id=:m_host_id AND ish.sub_approve_flag != 0 + AND (ish.sub_condition IS null OR isp.stop_level<>'Stop') ORDER BY ish.sub_name ASC"); $stmt->execute(array('state' => $state, 'm_host_id' => $m_host_id)); $stmt->setFetchMode(\PDO::FETCH_ASSOC); @@ -167,8 +167,8 @@ public static function getSubHostCond($m_host_id, $state, $country) { } else { $stmt = $db->prepare("SELECT ish.id, ish.sub_name FROM intern_sub_host AS ish LEFT JOIN intern_special_host AS isp ON ish.sub_condition=isp.id - WHERE ish.country=:country AND ish.main_host_id=:m_host_id - AND (ish.sub_condition IS null OR isp.stop_level<>'Stop')"); + WHERE ish.country=:country AND ish.main_host_id=:m_host_id AND ish.sub_approve_flag != 0 + AND (ish.sub_condition IS null OR isp.stop_level<>'Stop') ORDER BY ish.sub_name ASC"); $stmt->execute(array('country' => $country, 'm_host_id' => $m_host_id)); $stmt->setFetchMode(\PDO::FETCH_ASSOC); diff --git a/class/Supervisor.php b/class/Supervisor.php index d8339ab5..1909c7fd 100644 --- a/class/Supervisor.php +++ b/class/Supervisor.php @@ -132,29 +132,25 @@ public function getSupervisorFullName(){ * Get the domestic looking address of supervisor. */ public function getSuperAddress(){ - if($this->address_same_flag == 1){ - return $this->getAddress(); - }else{ - $add = array(); - if(!empty($this->supervisor_address)){ - $add[] = $this->supervisor_address . ','; - } - if(!empty($this->supervisor_city)){ - $add[] = $this->supervisor_city . ','; - } - if(!empty($this->supervisor_state)){ - $add[] = $this->supervisor_state; - } - if(!empty($this->supervisor_zip)){ - $add[] = $this->supervisor_zip; - } - - if(!empty($this->supervisor_country)){ - $add[] = $this->supervisor_country; - } - - return implode(' ', $add); + $add = array(); + if(!empty($this->supervisor_address)){ + $add[] = $this->supervisor_address . ','; } + if(!empty($this->supervisor_city)){ + $add[] = $this->supervisor_city . ','; + } + if(!empty($this->supervisor_state)){ + $add[] = $this->supervisor_state; + } + if(!empty($this->supervisor_zip)){ + $add[] = $this->supervisor_zip; + } + + if(!empty($this->supervisor_country)){ + $add[] = $this->supervisor_country; + } + + return implode(' ', $add); } public function getId(){ diff --git a/class/WorkflowState/CancelledState.php b/class/WorkflowState/CancelledState.php index 6aeb6d31..952aea7b 100644 --- a/class/WorkflowState/CancelledState.php +++ b/class/WorkflowState/CancelledState.php @@ -23,7 +23,7 @@ class CancelledState extends WorkflowState { const friendlyName = 'Cancelled'; - const sortIndex = 8; + const sortIndex = 9; public function getAllowedPermissionList(){ return array('cancel', 'reinstate'); diff --git a/class/WorkflowState/DeanApprovedGradState.php b/class/WorkflowState/DeanApprovedGradState.php index 579ebd80..dca8f76e 100644 --- a/class/WorkflowState/DeanApprovedGradState.php +++ b/class/WorkflowState/DeanApprovedGradState.php @@ -23,7 +23,7 @@ class DeanApprovedGradState extends WorkflowState { const friendlyName = 'Dean Approved / Pending Graduate School Aproval'; - const sortIndex = 10; + const sortIndex = 5; public function getAllowedPermissionList(){ return array('grad_school_approve', 'register', 'oied_certify', 'distance_ed_register'); diff --git a/class/WorkflowState/DeniedState.php b/class/WorkflowState/DeniedState.php index 0248895d..3c0f617b 100644 --- a/class/WorkflowState/DeniedState.php +++ b/class/WorkflowState/DeniedState.php @@ -23,7 +23,7 @@ class DeniedState extends WorkflowState { const friendlyName = 'Denied'; - const sortIndex = 9; + const sortIndex = 10; public function getAllowedPermissionList(){ return array('special_host'); diff --git a/class/WorkflowState/GradSchoolApprovedState.php b/class/WorkflowState/GradSchoolApprovedState.php index 9d6b2b45..7b473604 100644 --- a/class/WorkflowState/GradSchoolApprovedState.php +++ b/class/WorkflowState/GradSchoolApprovedState.php @@ -23,7 +23,7 @@ class GradSchoolApprovedState extends WorkflowState { const friendlyName = 'Graduate School Approved / Pending Registration'; - const sortIndex = 5; + const sortIndex = 6; public function getAllowedPermissionList(){ return array('grad_school_approve', 'register', 'oied_certify', 'distance_ed_register'); diff --git a/class/WorkflowState/RegisteredState.php b/class/WorkflowState/RegisteredState.php index d573e099..0c13b6e6 100644 --- a/class/WorkflowState/RegisteredState.php +++ b/class/WorkflowState/RegisteredState.php @@ -23,7 +23,7 @@ class RegisteredState extends WorkflowState { const friendlyName = 'Registered'; - const sortIndex = 6; + const sortIndex = 7; public function getAllowedPermissionList(){ return array('register'); diff --git a/class/WorkflowState/RegistrationIssueState.php b/class/WorkflowState/RegistrationIssueState.php index f8281d58..a7f98488 100644 --- a/class/WorkflowState/RegistrationIssueState.php +++ b/class/WorkflowState/RegistrationIssueState.php @@ -23,7 +23,7 @@ class RegistrationIssueState extends WorkflowState { const friendlyName = 'Registration Issue'; - const sortIndex = 7; + const sortIndex = 8; public function getAllowedPermissionList(){ return array('grad_school_approve', 'register', 'oied_certify', 'distance_ed_register'); diff --git a/contrib/importHost.php b/contrib/importHost.php index 553997b5..aee26a11 100755 --- a/contrib/importHost.php +++ b/contrib/importHost.php @@ -60,7 +60,7 @@ function createHost($name){ if($id_result){ $id_result = pg_fetch_row($id_result); $id = $id_result[0]; - $sql = "INSERT INTO intern_host (id, host_name) VALUES ($id, '$name')"; + $sql = "INSERT INTO intern_host (id, host_name, host_approve_flag) VALUES ($id, '$name', 1)"; $result = pg_query($sql); if($result === false){ echo "failed to insert host\n\n"; diff --git a/contrib/importSubHost.php b/contrib/importSubHost.php index 974fc063..e2738872 100755 --- a/contrib/importSubHost.php +++ b/contrib/importSubHost.php @@ -47,6 +47,7 @@ $values['zip'] = $line[5]; $values['province'] = $line[6]; $values['country'] = $line[7]; + $values['sub_approve_flag'] = 1; $intern_result = createSubHost($db, $values); diff --git a/contrib/importUpdateIntern.php b/contrib/importUpdateIntern.php new file mode 100755 index 00000000..437e98f5 --- /dev/null +++ b/contrib/importUpdateIntern.php @@ -0,0 +1,74 @@ +#!/usr/bin/php +. + * + * Copyright 2011-2018 Appalachian State University + */ + + +require_once('cliCommon.php'); +require_once('dbConnect.php'); + +ini_set('display_errors', 1); +ini_set('ERROR_REPORTING', E_WARNING); +error_reporting(E_ALL); + +$args = array('input_file'=>''); +$switches = array(); +check_args($argc, $argv, $args, $switches); + +// Open input and output files +$inputFile = fopen($args['input_file'], 'r'); + +if($inputFile === FALSE){ + die("Could not open input file.\n"); + exit; +} + +$db = connectToDb(); + +if(!$db){ + die('Could not connect to database.\n'); +} + +// Parse CSV input into fields line by line +while(($line = fgetcsv($inputFile, 0, '|')) !== FALSE) { + foreach($line as $key=>$element){ + $line[$key] = pg_escape_string($element); + } + $arrIn = $line[0]; + $new = explode(',', $arrIn); + $len = count($new); + $host = $new[$len-2]; + $subHost = $new[$len-1]; + array_pop($new); + array_pop($new); + $internships = implode("','",$new); + $internship = "'".$internships."'"; + + $sql = "UPDATE intern_internship SET host_id=$host, host_sub_id=$subHost WHERE id IN ($internship)"; + + $result = pg_query($sql); + + if($result === false){ + echo $sql . "\n\n"; + echo pg_last_error() . "\n\n"; + } +} + +pg_close($db); +fclose($inputFile); diff --git a/javascript/specialHost/ApproveHost.jsx b/javascript/specialHost/ApproveHost.jsx index 2801a487..c428d884 100644 --- a/javascript/specialHost/ApproveHost.jsx +++ b/javascript/specialHost/ApproveHost.jsx @@ -78,7 +78,7 @@ class ModalFormHost extends React.Component {
{this.props.main}
Loading Host With Conditions...
; } - var SubConData = null; - if (this.state.subConData != null && this.state.conditionData != null) { - SubConData = this.state.subConData.map(function (host) { - return ( -Loading Host With Conditions...
; - } - var ConditionData = null; if (this.state.conditionData != null) { ConditionData = this.state.conditionData.map(function (host) { @@ -767,7 +879,7 @@ class AllHostList extends React.Component { var HostData = null; if (this.state.mainData != null) { - HostData = this.state.mainData.map(function (host) { + HostData = this.state.mainDisplayData.map(function (host) { return (Name | -Condition | -Condition Added | -Notes | -
---|
Name | -Sub | -Address | -City | -State | -Condition | -Notes | -
---|
Name | +Condition | +Condition Changed | +Approval | +Notes | +
---|