forked from AppStateESS/InternshipInventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTermInfo.php
138 lines (110 loc) · 3.03 KB
/
TermInfo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
namespace Intern;
/**
* Class to contain and manage term information (e.g. class dates and census date)
* from Banner. This info is acquired through the web service interface by using the
* BannerTermProvider class.
*
* @see \Intern\BannerTermProvider
* @author jbooker
* @package Intern
*/
class TermInfo {
// Defines for Internship Inventory Term Banner Data
// Basic demographics
private $termCode;
private $termDesc;
private $termStartDate; // Format: '8/22/2017'
private $termEndDate;
private $censusDate; // Date the term is no longer available for new internships
private $partTerm;
public function __construct()
{
$this->partTerm = array();
}
public function getTermPartByCode($code)
{
foreach($this->partTerm as $part){
if($part->part_term_code == $code){
return $part;
}
}
return null;
}
public function getLongestTermPart()
{
/*
$semester = Term::getSemester($this->termCode);
if($semester == Term::SPRING || $semester == Term::FALL){
$part = $this->getTermPartByCode('4');
} else if($semester == Term::SUMMER1){
$part = $this->getTermPartByCode('SD');
} else if($semester == Term::SUMMER2){
$part = $this->getTermPartByCode('SE');
}
*/
$parts = $this->getTermParts();
$longestPart = null;
$longestPartLength = 0;
foreach($parts as $part){
$beginTimestamp = strtotime($part->part_start_date);
$endTimestamp = strtotime($part->part_end_date);
$length = $beginTimestamp - $endTimestamp;
if($length > $longestPartLength){
// We've found a longer part, so save it
$longestPart = $part;
$longestPartLength = $length;
}
}
return $longestPart;
}
/*****
* Accessor / Mutator Methods *
*/
public function getTermCode()
{
return $this->termCode;
}
public function setTermCode($termCode)
{
$this->termCode = $termCode;
}
public function getTermDesc()
{
return $this->termDesc;
}
public function setTermDesc($termDesc)
{
$this->termDesc = $termDesc;
}
public function getTermStartDate()
{
return $this->termStartDate;
}
public function setTermStartDate($termStartDate)
{
$this->termStartDate = $termStartDate;
}
public function getTermEndDate()
{
return $this->termEndDate;
}
public function setTermEndDate($termEndDate)
{
$this->termEndDate = $termEndDate;
}
public function getCensusDate()
{
return $this->censusDate;
}
public function setCensusDate($censusDate)
{
$this->censusDate = $censusDate;
}
public function getTermParts(){
return $this->partTerm;
}
public function addTermPart($part){
$this->partTerm[] = $part;
}
}