code comments including license information added, type hints added, minor rewrites...
[shipsimu.git] / application / ship-simu / main / personell / company / class_CompanyEmployee.php
1 <?php
2 /**
3  * Campany employees may be handled and payed within this class
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright(c) 2007, 2008 Roland Haeder, this is free software
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 class CompanyEmployee extends SimulatorPersonell {
25         // Employeee list
26         private $employeeList = null;
27
28         // Constructor
29         private function __construct () {
30                 // Call parent constructor
31                 parent::constructor(__CLASS__);
32
33                 // Debug message
34                 if ((((defined('DEBUG_COMPANY_EMPLOYEE')) && (defined('DEBUG_PERSONELL'))) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) {
35                         $this->getDebugInstance()->output(sprintf("[%s:%d] Konstruktor erreicht.<br />\n",
36                                 __CLASS__,
37                                 __LINE__
38                         ));
39                 }
40
41                 // Set description
42                 $this->setPartDescr("Firmenangestellte(r)");
43
44                 // Create unique ID
45                 $this->createUniqueID();
46
47                 // Clean up a little
48                 $this->removeSystemArray();
49         }
50
51         // Generate a specified amount of personell
52         public static function createCompanyEmployee ($surname, $family, $gender, $year, $month, $day, $married, $salary) {
53                 // Get instance
54                 $personellInstance = new CompanyEmployee();
55
56                 // Debug message
57                 if (((defined('DEBUG_COMPANY_EMPLOYEE')) && (defined('DEBUG_PERSONELL'))) || (defined('DEBUG_ALL'))) {
58                         $personellInstance->getDebugInstance()->output(sprintf("[%s:%d] Der/Die Angestellte <strong>%s %s</strong> wird angelegt.<br />\n",
59                                 __CLASS__,
60                                 __LINE__,
61                                 $surname,
62                                 $family
63                         ));
64                 }
65
66                 // Ist the given birthday valid?
67                 if ($personellInstance->isDateValid($year, $month, $day)) {
68                         // Set birthday
69                         $personellInstance->setBirthday($year, $month, $day);
70                 } else {
71                         // Something is wrong ...
72                         throw new BirthdayInvalidException(array($year, $month, $day), self::EXCEPTION_BIRTH_DATE_IS_INVALID);
73                 }
74
75                 // Set as employed/marrital status
76                 $personellInstance->setEmployed(true);
77                 $personellInstance->setMarried($married);
78
79                 // Set surname/family/gender
80                 $personellInstance->setSurname($surname);
81                 $personellInstance->setFamily($family);
82                 $personellInstance->setGender($gender);
83
84                 // Set salary
85                 $personellInstance->increaseSalary($salary);
86
87                 // Tidy up a little
88                 $personellInstance->removeEmployeeList();
89                 $personellInstance->removeMinMaxAge();
90
91                 // Return prepared instance
92                 return $personellInstance;
93         }
94
95         // Remove the employee list
96         private function removeEmployeeList () {
97                 if (((defined('DEBUG_COMPANY_EMPLOYEE')) && (defined('DEBUG_PERSONELL'))) || (defined('DEBUG_ALL'))) {
98                         $this->getDebugInstance()->output(sprintf("[%s:%d] Angestellten-List entfernt.<br />\n",
99                                 __CLASS__,
100                                 __LINE__
101                         ));
102                 }
103                 unset($this->employeeList);
104         }
105
106         /**
107          * Call parent method
108          */
109         public function saveObjectToDatabase () {
110                 parent::saveObjectToDatabase();
111         }
112
113         /**
114          * Limits this object with an ObjectLimits instance
115          */
116         public function limitObject (ObjectLimits $limitInstance) {
117                 parent::limitObject($limitInstance);
118         }
119 }
120
121 // [EOF]
122 ?>