2 // What every kind of personell have
3 class BasePersonell extends BaseFrameworkSystem implements Personellizer {
9 private $gender = ""; // M=Male, F=Female, empty=uninitialized
11 // Year/month/day of birth
12 private $yearBirth = 0;
13 private $monthBirth = 0;
14 private $dayBirth = 0;
16 // Surname/family name
17 private $surname = "";
21 private $employed = false;
24 private $married = false;
27 private $salary = 0.00;
30 private function __construct ($class) {
31 // Call parent constructor
32 parent::constructor($class);
35 if ((defined('DEBUG_PERSONELL')) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output("[PersonellBase:] Konstruktor erreicht.<br />\n");
37 // Beschreibung setzen
38 $this->setPartDescr("Personal");
41 // Calls the constructor
42 public function constructor ($class) {
43 $this->__construct($class);
46 // Remove min/max ages
47 public final function removeMinMaxAge () {
48 if (defined('DEBUG_PERSONELL')) $this->getDebugInstance()->output(sprintf("[%s:%d] Minimum-/Maximum-Alter entfernt.<br />\n",
52 unset($this->MIN_AGE);
53 unset($this->MAX_AGE);
56 // Generates a birthday based on MAX_AGE/MIN_AGE and the current date
57 public final function createBirthday () {
58 // Is the birthday already set?
59 if ($this->isDateValid($this->yearBirth, $this->monthBirth, $this->dayBirth)) return false;
62 $currYear = date("Y", time());
64 // Generate random year/month/day
65 $year = mt_rand(($currYear - $this->MIN_AGE), ($currYear - $this->MAX_AGE));
68 while (!$this->isDateValid($year, $month, $day)) {
69 $month = mt_rand(1, 12);
78 $day = mt_rand(1, 31);
85 $day = mt_rand(1, 30);
91 $day = mt_rand(1, 29);
94 $day = mt_rand(1, 28);
100 // Set the new birthday
101 $this->setBirthday($year, $month, $day);
104 // Is the current day valid?
105 public final function isDateValid ($year, $month, $day) {
107 $stamp = mktime(0, 0, 0, $month, $day, $year);
109 // Get year/month/day back
110 $y = date("Y", $stamp);
111 $m = date("m", $stamp);
112 $d = date("d", $stamp);
115 return (($y == $year) && ($m == $month) && ($d == $day));
119 public final function isEmployed () {
120 return $this->employed;
124 public final function isMarried () {
125 return $this->married;
129 public final function isMale () {
130 return ($this->gender == "M");
134 public final function isFemale () {
135 return ($this->gender == "F");
138 // Setter for surname
139 public final function setSurname ($surname) {
140 $this->surname = (string) $surname;
143 // Getter for surname
144 public function getSurname () {
145 return $this->surname;
148 // Setter for family name
149 public final function setFamily ($family) {
150 $this->family = (string) $family;
153 // Getter for family name
154 public final function getFamily () {
155 return $this->family;
159 public final function setGender ($gender) {
160 // Set random gender here
161 if (($gender == "M") || ($gender == "F") || ((empty($gender)) && ($this->getSurname() == ""))) {
162 $this->gender = $gender;
164 throw new WrongGenderSpecifiedException($gender, self::EXCEPTION_GENDER_IS_WRONG);
169 public final function getGender () {
170 return $this->gender;
173 // Setter for employment status
174 public final function setEmployed ($employed) {
175 $this->employed = (boolean) $employed;
178 // Setter for marriage status
179 public final function setMarried ($married) {
180 $this->married = (boolean) $married;
184 public final function getSalary () {
185 return $this->salary;
189 public final function increaseSalary ($add) {
190 $this->salary += (float) abs($add);
194 public final function decreaseSalary ($sub) {
195 $this->salary -= (float) abs($sub);
198 // Setter for birthday
199 public final function setBirthday ($year, $month, $day) {
200 $this->yearBirth = (int) abs($year);
201 $this->monthBirth = (int) abs($month);
202 $this->dayBirth = (int) abs($day);
206 public function removeGender () {
207 unset($this->gender);
211 public function removeNames () {
212 unset($this->surname);
213 unset($this->family);
216 // Remove complete birthday
217 public function removeBirthday () {
218 unset($this->yearBirth);
219 unset($this->monthBirth);
220 unset($this->dayBirth);
224 public function removeSalary () {
225 unset($this->salary);
228 // Remove employment status
229 public function removeEmployed () {
230 unset($this->employed);
233 // Remove marrital status
234 public function removeMarried () {
235 unset($this->married);