forked from AppStateESS/InternshipInventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAffiliationAgreement.php
145 lines (122 loc) · 3.23 KB
/
AffiliationAgreement.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
139
140
141
142
143
144
145
<?php
namespace Intern;
/**
* Represents an Affiliation Agreement
*
* @author Chris Detsch
* @package Intern
*/
class AffiliationAgreement
{
public $id;
public $name;
public $begin_date;
public $end_date;
public $auto_renew;
public $notes;
public $terminated;
/**
* Getters
*/
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function getBeginDate()
{
return $this->begin_date;
}
public function getEndDate()
{
return $this->end_date;
}
public function getAutoRenew()
{
return $this->auto_renew;
}
public function getNotes()
{
return $this->notes;
}
public function getTerminated()
{
return $this->terminated;
}
public function getDepartments()
{
\PHPWS_Core::initModClass('intern', 'AffiliationAgreement.php');
$db = new \PHPWS_DB('intern_affiliation_agreement');
$db->addWhere('agreement_id', $this->id);
//TODO Further code once the other sections of this project are further along
}
public function getLocations()
{
\PHPWS_Core::initModClass('intern', 'AffiliationAgreement.php');
$db = new \PHPWS_DB('intern_affiliation_location');
$db->addWhere('agreement_id', $this->id);
//TODO Further code once the other sections of this project are further along
}
/**
* Setters
*/
public function setId($id)
{
$this->id = $id;
}
public function setName($name)
{
$this->name = $name;
}
public function setBeginDate($beginDate)
{
$this->begin_date = $beginDate;
}
public function setEndDate($endDate)
{
$this->end_date = $endDate;
}
public function setAutoRenew($autoRenew)
{
$this->auto_renew = $autoRenew;
}
public function setNotes($notes)
{
$this->notes = $notes;
}
public function setTerminated($terminated)
{
$this->terminated = $terminated;
}
/**
* Get Document objects associated with this internship.
*/
public function getDocuments()
{
$db = new \PHPWS_DB('intern_agreement_documents');
$db->addWhere('agreement_id', $this->id);
return $db->getObjects('\Intern\AffiliationContract');
}
public function getRowTags()
{
$tpl = array();
$tpl['NAME'] = \PHPWS_Text::moduleLink($this->getName(), 'intern',
array('action' => 'showAffiliateEditView', 'affiliation_agreement_id' => $this->getId()));
$tpl['EXPIRES'] = \PHPWS_Text::moduleLink(date('m/d/Y', $this->getEndDate()), 'intern',
array('action' => 'showAffiliateEditView', 'affiliation_agreement_id' => $this->getId()));
$expirationTime = ((int)$this->getEndDate() - time());
if($this->getAutoRenew()){
$tpl['STATUS'] = "active";
}else if($expirationTime < 0){
$tpl['STATUS'] = "danger";
} else if($expirationTime < 7884000) {
$tpl['STATUS'] = "warning";
} else {
$tpl['STATUS'] = "active";
}
return $tpl;
}
}