1: <?php
2:
3: /*
4: projectPersonHandler.class.php
5: Copyright 2007 Mika Ristolainen/Bmm Solutions
6: */
7:
8: class projectPersonHandler {
9:
10: protected $person_id;
11: protected $role;
12: protected $desc;
13: protected $hrm_id;
14:
15: public function __construct ( $person_id,$role,$desc,$hrm_id){
16: $this->person_id = $person_id;
17: $this->role = $role;
18: $this->desc = $desc;
19: $this->hrm_id = $hrm_id;
20: $this->hrmhandler = new hrmHandler();
21:
22: }
23:
24: public function setDataSource(&$db){
25: $this->dbhandler = new projectPersonDbHandler($db);
26: $this->hrmhandler->setDataSource($db);
27: }
28:
29: public function destructDbInstances(){
30: unset($this->dbhandler);
31: $this->hrmhandler->destructDbInstances();
32: }
33:
34: public function initialize (){
35: $this->person_id = null;
36: $this->role = null;
37: $this->desc = null;
38: $this->hrm_id = null;
39: $this->hrmhandler->initialize();
40: }
41:
42: public function initializeById($id){
43: $this->person_id = $id;
44: $this->role = $this->dbhandler->getPersonRole($id);
45: $this->desc = $this->dbhandler->getPersonDescription($id);
46: $this->hrm_id = $this->dbhandler->getPersonUserId($id);
47:
48: $this->hrmhandler->initializeById($this->hrm_id);
49: }
50:
51: public function initializePersonData($id){
52: $this->hrmhandler->initializeById($id);
53: }
54:
55:
56: public function syncStorageInsert($trans = true){
57:
58: #if (is_numeric($this->contracthandler->getContractId()) == false) $this->contracthandler->setContractId(0);
59: try {
60: if ($trans == true) $this->dbhandler->db->transactionStart();
61:
62: $this->person_id = $this->dbhandler->insertPersonData(
63: $this->getPersonRole(),
64: $this->getPersonDescription(),
65: $this->getPersonUserId());
66:
67: }catch (Exception $e){
68: $this->dbhandler->db->transactionRollback();
69: throw new Exception($e->getMessage());
70: }
71: if ($trans == true) $this->dbhandler->db->transactionEnd();
72: }
73:
74:
75: public function getPersonUserId(){
76: return $this->hrm_id;
77: }
78:
79: public function getPersonId(){
80: return $this->person_id;
81: }
82:
83: public function getPersonName(){
84: return $this->hrmhandler->personhandler->main_dataobj->getOrganisation();
85: }
86:
87: public function getPersonEmail(){
88: return $this->hrmhandler->personhandler->main_dataobj->getEmail();
89: }
90:
91: public function getPersonRole(){
92: return $this->role;
93: }
94:
95: public function getPersonDescription(){
96: return $this->desc;
97: }
98: }
99: ?>
100: