TODO: We should find something better than BaseFrameworkSystem as a type-hint
[shipsimu.git] / ship-simu / application / ship-simu / main / personell / company / class_CompanyEmployee.php
1 <?php
2
3 // Die Schiffsbesatzung
4 class CompanyEmployee extends SimulatorPersonell {
5         // Employeee list
6         private $employeeList = null;
7
8         // Constructor
9         private function __construct () {
10                 // Call parent constructor
11                 parent::constructor(__CLASS__);
12
13                 // Debug message
14                 if ((((defined('DEBUG_COMPANY_EMPLOYEE')) && (defined('DEBUG_PERSONELL'))) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
15                         $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
16                                 __CLASS__,
17                                 __LINE__
18                         ));
19                 }
20
21                 // Beschreibung setzen
22                 $this->setPartDescr("Firmenangestellte(r)");
23
24                 // Create unique ID
25                 $this->createUniqueID();
26
27                 // Clean up a little
28                 $this->removeSystemArray();
29         }
30
31         // Generate a specified amount of personell
32         public static function createCompanyEmployee ($surname, $family, $gender, $year, $month, $day, $married, $salary) {
33                 // Get instance
34                 $personellInstance = new CompanyEmployee();
35
36                 // Debug message
37                 if (((defined('DEBUG_COMPANY_EMPLOYEE')) && (defined('DEBUG_PERSONELL'))) || (defined('DEBUG_ALL'))) {
38                         $personellInstance->getDebugInstance()->output(sprintf("[%s:%d] Der/Die Angestellte <strong>%s %s</strong> wird angelegt.<br />\n",
39                                 __CLASS__,
40                                 __LINE__,
41                                 $surname,
42                                 $family
43                         ));
44                 }
45
46                 // Ist the given birthday valid?
47                 if ($personellInstance->isDateValid($year, $month, $day)) {
48                         // Set birthday
49                         $personellInstance->setBirthday($year, $month, $day);
50                 } else {
51                         // Something is wrong ...
52                         throw new BirthdayInvalidException(array($year, $month, $day), self::EXCEPTION_BIRTH_DATE_IS_INVALID);
53                 }
54
55                 // Set as employed/marrital status
56                 $personellInstance->setEmployed(true);
57                 $personellInstance->setMarried($married);
58
59                 // Set surname/family/gender
60                 $personellInstance->setSurname($surname);
61                 $personellInstance->setFamily($family);
62                 $personellInstance->setGender($gender);
63
64                 // Set salary
65                 $personellInstance->increaseSalary($salary);
66
67                 // Tidy up a little
68                 $personellInstance->removeEmployeeList();
69                 $personellInstance->removeMinMaxAge();
70
71                 // Return prepared instance
72                 return $personellInstance;
73         }
74
75         // Remove the employee list
76         private function removeEmployeeList () {
77                 if (((defined('DEBUG_COMPANY_EMPLOYEE')) && (defined('DEBUG_PERSONELL'))) || (defined('DEBUG_ALL'))) {
78                         $this->getDebugInstance()->output(sprintf("[%s:%d] Angestellten-List entfernt.<br />\n",
79                                 __CLASS__,
80                                 __LINE__
81                         ));
82                 }
83                 unset($this->employeeList);
84         }
85
86         /**
87          * Call parent method
88          */
89         public function saveObjectToDatabase () {
90                 parent::saveObjectToDatabase();
91         }
92
93         /**
94          * Limits this object with an ObjectLimits instance
95          */
96         public function limitObject (ObjectLimits $limitInstance) {
97                 parent::limitObject($limitInstance);
98         }
99 }
100
101 // [EOF]
102 ?>