Skip to content

Commit d03ffe8

Browse files
authored
check student variables set (#446)
update packages, dropbox, modal, new contract, new remote feature
1 parent 0eaef32 commit d03ffe8

43 files changed

Lines changed: 2239 additions & 4437 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

boost/boost.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
$proper_name = 'Internship Inventory';
7-
$version = '1.1.0';
7+
$version = '1.1.1';
88
$register = false;
99
$unregister = false;
1010
$import_sql = true;

boost/install.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,6 @@ CREATE TABLE intern_internship (
659659
middle_name_meta VARCHAR,
660660
last_name_meta VARCHAR,
661661
preferred_name_meta VARCHAR,
662-
loc_address VARCHAR NULL,
663-
loc_city VARCHAR NULL,
664662
loc_state VARCHAR NULL,
665663
loc_zip VARCHAR NULL,
666664
loc_province VARCHAR(255) NULL,
@@ -690,6 +688,8 @@ CREATE TABLE intern_internship (
690688
host_id INT REFERENCES intern_host(id),
691689
host_sub_id INT REFERENCES intern_special_host(id),
692690
loc_phone VARCHAR,
691+
remote SMALLINT,
692+
remote_state VARCHAR,
693693
PRIMARY KEY(id)
694694
);
695695

boost/update.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ function intern_update(&$content, $currentVersion)
146146
internRunDbMigration('update_01.00.00.sql');
147147
PHPWS_Core::initModClass('users', 'Permission.php');
148148
Users_Permission::registerPermissions('intern', $content);
149+
case version_compare($currentVersion, '1.1.1', '<') :
150+
internRunDbMigration('update_01.01.01.sql');
149151
}
150152

151153
return TRUE;

boost/updates/update_01.01.01.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE intern_internship ADD COLUMN remote SMALLINT;
2+
ALTER TABLE intern_internship ADD COLUMN remote_state VARCHAR;

class/Command/AddInternship.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function execute() {
5858

5959
// If there are missing fields, redirect to the add internship interface
6060
if(!empty($missingFieldList)) {
61-
\NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "Please complete the highlighted fields.");
61+
\NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "Banner ID must be in Student box before creating internship.");
6262
$this->redirectToForm();
6363
return;
6464
}
@@ -140,7 +140,7 @@ private function checkForMissingInput() {
140140
$missingFieldList = array();
141141

142142
// Check student ID
143-
if (!isset($_POST['studentId']) || (isset($_POST['studentId']) && $_POST['studentId'] == '')) {
143+
if (!isset($_POST['studentId']) || (isset($_POST['studentId']) && $_POST['studentId'] == '') || !preg_match('/^([0-9]){9}$/', $_POST['studentId'])) {
144144
$missingFieldList[] = 'studentId';
145145
}
146146

class/Command/SaveInternship.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ public function execute() {
148148
$i->stipend = isset($_REQUEST['stipend']) && $i->paid;
149149
$i->pay_rate = self::trimField($_REQUEST['pay_rate']);
150150
$i->loc_phone = self::trimField($_REQUEST['host_phone']);
151+
if (isset($_POST['remote'])){
152+
$i->remote = 1;
153+
$i->remote_state = $_POST['remote_state'];
154+
} else{
155+
$i->remote = 0;
156+
$i->remote_state = NULL;
157+
}
151158

152159
if (\Current_User::allow('intern', 'change_term')) {
153160
$i->term = $_REQUEST['term'];

class/DataProvider/Student/WebServiceDataProvider.php

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class WebServiceDataProvider extends StudentDataProvider {
4545
/**
4646
* @param string $currentUserName - Username of the user currently logged in. Will be sent to web service
4747
*/
48-
public function __construct($currentUserName)
49-
{
48+
public function __construct($currentUserName){
5049
$this->currentUserName = $currentUserName;
5150

5251
// Get the WSDL URI from module's settings
@@ -58,8 +57,7 @@ public function __construct($currentUserName)
5857
* Returns a Student object with hard-coded data
5958
* @return \Intern\Student
6059
*/
61-
public function getStudent($studentId)
62-
{
60+
public function getStudent($studentId){
6361
if($studentId === null || $studentId == ''){
6462
throw new \InvalidArgumentException('Missing student ID.');
6563
}
@@ -93,20 +91,22 @@ public function getStudent($studentId)
9391
// Log the request
9492
$this->logRequest('getStudent', 'success', $params);
9593

96-
// Create the Student object and plugin the values
97-
$student = new Student();
98-
$this->plugStudentValues($student, $result);
99-
94+
// Create the Student object and plugin the values, Full check for missing data
95+
try {
96+
$student = new Student();
97+
$this->plugStudentValues($student, $result);
98+
}
99+
catch(\Exception $e) {
100+
throw new \Intern\Exception\StudentNotFoundException("Missing student data: $studentId");
101+
}
100102
return $student;
101103
}
102104

103-
protected function sendRequest(Array $params)
104-
{
105+
protected function sendRequest(Array $params){
105106
return $this->client->GetInternInfo($params);
106107
}
107108

108-
public function getCreditHours(string $studentId, string $term)
109-
{
109+
public function getCreditHours(string $studentId, string $term){
110110
if($studentId === null || $studentId == ''){
111111
throw new \InvalidArgumentException('Missing student ID.');
112112
}
@@ -139,8 +139,7 @@ public function getCreditHours(string $studentId, string $term)
139139
}
140140
}
141141

142-
public function getFacultyMember($facultyId)
143-
{
142+
public function getFacultyMember($facultyId){
144143
if($facultyId === null || $facultyId == ''){
145144
throw new \InvalidArgumentException('Missing student ID.');
146145
}
@@ -181,33 +180,35 @@ public function getFacultyMember($facultyId)
181180
* @param Student $student
182181
* @param stdClass $data
183182
*/
184-
protected function plugStudentValues(&$student, \stdClass $data)
185-
{
183+
protected function plugStudentValues(&$student, \stdClass $data){
186184
/**********************
187185
* Basic Demographics *
188186
**********************/
189187
$student->setStudentId($data->bannerID);
190188
$student->setUsername($data->userName);
191-
192189
$student->setFirstName($data->firstName);
193-
$student->setMiddleName($data->middleName);
190+
if(isset($data->middleName)){
191+
$student->setMiddleName($data->middleName);
192+
}
194193
$student->setLastName($data->lastName);
195-
$student->setPreferredName($data->preferredName);
194+
if(isset($data->preferredName)){
195+
$student->setPreferredName($data->preferredName);
196+
}
196197

197-
if($data->confidential === 'N') {
198+
if(isset($data->confidential) && $data->confidential === 'N') {
198199
$student->setConfidentialFlag(false);
199200
} else {
200201
$student->setConfidentialFlag(true);
201202
}
202203

203204
// Person type flags
204-
if($data->isStudent == 1){
205+
if(isset($data->isStudent) && $data->isStudent == 1){
205206
$student->setStudentFlag(true);
206207
} else {
207208
$student->setStudentFlag(false);
208209
}
209210

210-
if($data->isStaff == 1){
211+
if(isset($data->isStaff) && $data->isStaff == 1){
211212
$student->setStaffFlag(true);
212213
} else {
213214
$student->setStaffFlag(false);
@@ -218,10 +219,10 @@ protected function plugStudentValues(&$student, \stdClass $data)
218219
*****************/
219220

220221
// Campus
221-
if($data->campusDescription == WebServiceDataProvider::MAIN_CAMPUS) {
222+
if(isset($data->campusDescription) && $data->campusDescription == WebServiceDataProvider::MAIN_CAMPUS) {
222223
// If campus is 'Main Campus', then we know it's a main campus student
223224
$student->setCampus(Student::MAIN_CAMPUS);
224-
} else if ($data->campusDescription != '') {
225+
} else if (isset($data->campusDescription) && $data->campusDescription != '') {
225226
// If the campus is set, but is not 'Main Campus', then we know it's some other campus name (e.g. "Catawba EdD EdLead")
226227
// We're not going to check for every possible campus name; as long as there's *something* there, we'll assume it's distance ed
227228
$student->setCampus(Student::DISTANCE_ED);
@@ -233,9 +234,9 @@ protected function plugStudentValues(&$student, \stdClass $data)
233234
}
234235

235236
// Check if level exist, if not add it
236-
if(LevelFactory::checkLevelExist($data->studentLevel) && $student->getStudentFlag()){
237+
if(isset($data->studentLevel) && LevelFactory::checkLevelExist($data->studentLevel) && $student->getStudentFlag()){
237238
$student->setLevel($data->studentLevel);
238-
} else if($student->getStudentFlag()) {
239+
} else if(isset($data->studentLevel) && $student->getStudentFlag()) {
239240
$newLevel = LevelFactory::saveNewCode($data->studentLevel);
240241
$student->setLevel($newLevel);
241242
}
@@ -255,12 +256,14 @@ protected function plugStudentValues(&$student, \stdClass $data)
255256
// Grad date, if available
256257
if(isset($data->gradDate) && $data->gradDate != '') {
257258
$student->setGradDateFromString($data->gradDate);
258-
} else if(isset($data->gradYear) && $data->gradYear != '') {
259+
} /*else if(isset($data->gradYear) && $data->gradYear != '') {
259260
$student->setGradDateFromString($data->gradYear);
260-
}
261+
}*/
261262

262263
// Contact info
263-
$student->setPhone($data->phoneNumber);
264+
if(isset($data->phoneNumber)){
265+
$student->setPhone($data->phoneNumber);
266+
}
264267
}
265268

266269
/**
@@ -289,8 +292,7 @@ protected function plugFacultyValues(\stdClass $data) {
289292
/**
290293
* Logs this request to PHPWS' curlapi.log file
291294
*/
292-
private function logRequest($functionName, $result, Array $params)
293-
{
295+
private function logRequest($functionName, $result, Array $params) {
294296
$args = implode(', ', $params);
295297
$msg = "$functionName($args) result: $result";
296298
\PHPWS_Core::log($msg, 'curlapi.log', 'CURLAPI');

class/EditInternshipFormView.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,14 @@ public function buildInternshipForm() {
331331
$this->tpl['LOCATION'] = 'International';
332332
$this->form->addHidden('location', 'international');
333333
}
334+
// Remote
335+
$this->form->addCheck('remote');
336+
$this->form->setLabel('remote', 'This internship is remote.');
337+
338+
$this->form->addSelect('remote_state', State::$UNITED_STATES);
339+
$this->form->setLabel('remote_state', 'Remote State');
340+
$this->form->addCssClass('remote_state', 'form-control');
341+
334342
// Phone
335343
$this->form->addText('host_phone');
336344
$this->form->addCssClass('host_phone', 'form-control');
@@ -611,6 +619,11 @@ private function plugInternInfo() {
611619
$this->formVals['credits'] = $this->intern->credits;
612620
$this->formVals['avg_hours_week'] = $this->intern->avg_hours_week;
613621

622+
if ($this->intern->isRemote()) {
623+
$this->form->setMatch('remote', '1');
624+
$this->formVals['remote_state'] = $this->intern->remote_state;
625+
}
626+
614627
if ($this->intern->paid) {
615628
$this->form->setMatch('payment', 'paid');
616629
$this->form->setMatch('stipend', $this->intern->stipend);

class/Internship.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class Internship {
8787
public $loc_state;
8888
public $loc_country;
8989
public $loc_phone;
90+
public $remote;
91+
public $remote_state;
9092

9193
// Term Info
9294
public $term;
@@ -317,6 +319,8 @@ public function getCSV()
317319
// Internship location data
318320
$csv['Domestic'] = $this->isDomestic() ? 'Yes' : 'No';
319321
$csv['International'] = $this->isInternational() ? 'Yes' : 'No';
322+
$csv['Remote'] = $this->isRemote() ? 'Yes' : 'No';
323+
$csv['Remote State'] = $this->remote_state;
320324
$csv['Host Phone'] = $this->loc_phone;
321325

322326
// Gets host information
@@ -666,6 +670,14 @@ public function setOiedCertified($certified) {
666670
}
667671
}
668672

673+
public function isRemote() {
674+
if($this->remote == 1){
675+
return true;
676+
}else{
677+
return false;
678+
}
679+
}
680+
669681
public function isMultipart() {
670682
if($this->multi_part == 1){
671683
return true;
@@ -925,6 +937,10 @@ public function getPhoneNumber(){
925937
return $this->phone;
926938
}
927939

940+
public function getRemoteState(){
941+
return $this->remote_state;
942+
}
943+
928944
/**
929945
* Returns this internship's term
930946
*

class/InternshipContractPdfView.php

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private function generatePdf()
7777
$f = $this->internship->getFaculty();
7878
//$subject = $this->internship->getSubject();
7979

80-
$this->pdf->setSourceFile(PHPWS_SOURCE_DIR . 'mod/intern/pdf/Contract_Updated_202010.pdf');
80+
$this->pdf->setSourceFile(PHPWS_SOURCE_DIR . 'mod/intern/pdf/Acknowledgment_Updated_202110.pdf');
8181
$tplidx = $this->pdf->importPage(1);
8282
$this->pdf->addPage();
8383
$this->pdf->useTemplate($tplidx);
@@ -170,8 +170,6 @@ private function generatePdf()
170170
$this->pdf->cell(81, 5, $addrFac2);
171171
}
172172

173-
174-
175173
$this->pdf->setXY(29, 141);
176174
$this->pdf->cell(77, 5, $f->getPhone());
177175

@@ -209,6 +207,9 @@ private function generatePdf()
209207
$this->pdf->cell(77, 5, $addr2);
210208
}
211209

210+
$this->pdf->setXY(137, 174);
211+
$this->pdf->cell(77,0, $this->internship->getRemoteState());
212+
212213
/**
213214
* Supervisor info.
214215
*/
@@ -234,31 +235,24 @@ private function generatePdf()
234235
$this->pdf->setXY(113, 149);
235236
$this->pdf->cell(78, 5, $super_address);
236237
}else{
237-
// Too long, need to use two lines
238-
$host_info_len = strlen($superName) + strlen($supervisorTitle);
239-
$newX = 113 + ($host_info_len * 2);
240-
$endX = (203 - $newX) / 1.5;
241-
242-
//$superLine1 = substr($super_address, 0, $endX); // get first 55 chars
243-
//$superLine2 = substr($super_address, $endX); // get the rest, hope it fits
244-
245-
$addrSup = wordwrap($host_address, $endX);
238+
// Too long, need to use two lines, breaks string at whole word around 55 chars
239+
$addrSup = wordwrap($super_address, 55);
246240
$superLine1 = substr($addrSup, 0, strpos($addrSup, "\n"));
247241
$superLine2 = substr($addrSup, strpos($addrSup, "\n"));
248242

249-
$this->pdf->setXY($newX, 144);
250-
$this->pdf->cell(78, 5, $superLine1);
251243
$this->pdf->setXY(113, 149);
244+
$this->pdf->cell(78, 5, $superLine1);
245+
$this->pdf->setXY(113, 155);
252246
$this->pdf->cell(78, 5, $superLine2);
253247
}
254248

255-
$this->pdf->setXY(125, 159);
249+
$this->pdf->setXY(125, 166);
256250
$this->pdf->cell(72, 5, $s->getSupervisorEmail());
257251

258-
$this->pdf->setXY(125, 154);
252+
$this->pdf->setXY(125, 160);
259253
$this->pdf->cell(33, 5, $s->getSupervisorPhoneNumber());
260254

261-
$this->pdf->setXY(166, 154);
255+
$this->pdf->setXY(166, 160);
262256
$this->pdf->cell(40, 5, $s->getSupervisorFaxNumber());
263257

264258

@@ -273,13 +267,13 @@ private function generatePdf()
273267
if(sizeof($this->emergencyContacts) > 0){
274268
$firstContact = $this->emergencyContacts[0];
275269

276-
$this->pdf->setXY(59, 271);
270+
$this->pdf->setXY(59, 273);
277271
$this->pdf->cell(52, 0, $firstContact->getName());
278272

279-
$this->pdf->setXY(134, 271);
273+
$this->pdf->setXY(134, 273);
280274
$this->pdf->cell(52, 0, $firstContact->getRelation());
281275

282-
$this->pdf->setXY(172, 271);
276+
$this->pdf->setXY(172, 273);
283277
$this->pdf->cell(52, 0, $firstContact->getPhone());
284278
}
285279
}

0 commit comments

Comments
 (0)