This repository has been archived by the owner on Oct 22, 2020. It is now read-only.
/
Person.php
261 lines (224 loc) · 8.94 KB
/
Person.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
/**
* DataObject For Person Entity of OpenEvSys.
*
* This file is part of OpenEvsys.
*
* Copyright (C) 2009 Human Rights Information and Documentation Systems,
* HURIDOCS), http://www.huridocs.org/, info@huridocs.org
*
* OpenEvsys is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenEvsys is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Nilushan Silva <nilushan@respere.com>
*
* @package OpenEvsys
* @subpackage DataModel
*
*/
//require_once ( APPROOT . 'data/DataObject.php' );
class Person extends DomainEntity{
/*
public $person_record_number;
public $counting_unit;
public $person_name;
public $other_names;
public $confidentiality;
public $date_of_birth;
public $place_of_birth;
public $locality_of_birth;
public $date_deceased;
public $sex;
public $sexual_orientation;
public $identification_documents;
public $civil_status;
public $dependants;
public $formal_education;
public $other_training;
public $health;
public $medical_records;
public $group_description;
public $number_of_persons_in_group;
public $religion;
public $remarks;
public $reliability_as_source;
public $reliability_as_intervening_party;
public $deceased;
public $date_of_birth_type;
public $date_deceased_type;
public $occupation;
public $local_term_for_occupation;
public $physical_description;
public $citizenship;
public $ethnic_background;
public $other_background;
public $general_characteristics;
public $language ;
public $local_language;
public $national_origin;
//Management Data
public $date_received;
public $date_of_entry;
public $entered_by ;
public $project_title;
public $comments ;
public $record_grouping;
public $date_updated ;
public $updated_by ;
public $monitoring_status;
*/
public $Management;
public $picture;
public $person_addresses = array();
protected $managementFields = array( 'date_received', 'date_of_entry',
'entered_by' , 'project_title', 'comments', 'record_grouping',
'date_updated' , 'updated_by' , 'monitoring_status');
/*
protected $mt = array('occupation' , 'local_term_for_occupation' ,
'physical_description','citizenship','ethnic_background' , 'other_background' , 'general_characteristics',
'language' , 'local_language','national_origin'
);
*/
protected $supporting_doc = true;
protected $isAddress = true;
protected $picture_doc = true;
protected $supporting_geometry = true;
private $pkey = array('person_record_number');
public function __construct($table = false, $pkeyarr=false, $db=false, $options=array()){
parent::__construct('person', $pkey ,$db , $options);
$table = 'person';
}
public function LoadPicture(){
if($this->picture_doc == true){
$pictureDoc = new SupportingDocEntity(SupportingDocEntity::generateTableName('picture') );
$picture_data = $pictureDoc->getDocsforEntity($this->person_record_number);
$this->picture = $picture_data[0]->doc_id;
}
}
public function LoadAddresses(){
if($this->isAddress == true){
$address = new Address();
$addressEntityObjects = $address->getAddressforEntity($this->person_record_number);
foreach($addressEntityObjects as $add){
$this->person_addresses[] = $add->address_record_number;
}
}
}
private function DeleteAddresses(){
$address = new Address();
$addressEntityObjects = $address->getAddressforEntity($this->person_record_number);
foreach($addressEntityObjects as $add){
$add->Delete('person' , $this->person_record_number);
}
}
public function SaveAddresses($addresses){
if($this->isAddress == true){
$this->DeleteAddresses();
if( is_array($addresses)){
foreach($addresses as $key=>$add){
$address = new Address();
$address->person = $this->person_record_number;
$address->address_record_number = shn_create_uuid('address');;
$address->address_type = $addresses[$key]['address_type'];
$address->address = $addresses[$key]['address'];
$address->country = $addresses[$key]['country'];
$address->phone = $addresses[$key]['phone'];
$address->cellular = $addresses[$key]['cellular'];
$address->fax = $addresses[$key]['fax'];
$address->email = $addresses[$key]['email'];
$address->web = $addresses[$key]['web'];
$address->start_date = $addresses[$key]['start_date'];
$address->end_date = $addresses[$key]['end_date'];
$address->Save();
}
}
}
}
public function SavePicture(){
if($this->picture_doc == true && is_uploaded_file($_FILES['picture']['tmp_name'])){
$type = null;
$uri = shn_files_store('picture',null,$type);
if($uri == null){
$uri = '';
}
$document_form = document_form('new');
$supporting_docs = new SupportingDocs();
$supporting_docs_meta = new SupportingDocsMeta();
$pictureDoc = new SupportingDocEntity(SupportingDocEntity::generateTableName('picture') );
$pictureDoc->record_number = $this->person_record_number;
if($_POST['picture_id'] != null){
$picture_id = $_POST['picture_id'];
if($uri != ''){
$supporting_docs->doc_id = $picture_id;
$supporting_docs->uri = $uri;
$supporting_docs->_saved = true;
form_objects($document_form, $supporting_docs);
//$supporting_docs->Delete();
$supporting_docs->Save();
form_objects($document_form, $supporting_docs_meta);
$supporting_docs_meta->title = "Picture";
$supporting_docs_meta->doc_id = $picture_id;
$supporting_docs_meta->format = $type;
$supporting_docs_meta->_saved = true;
$supporting_docs_meta->Save();
$pictureDoc->doc_id = $picture_id;
$pictureDoc->_saved = true;
$pictureDoc->linked_by = $_SESSION['username'];
$pictureDoc->Save();
}
}
else{
$picture_id = shn_create_uuid('picture');
$supporting_docs->doc_id = $picture_id;
$supporting_docs->uri = $uri;
form_objects($document_form, $supporting_docs);
$supporting_docs->Save();
form_objects($document_form, $supporting_docs_meta);
$supporting_docs_meta->title = "Picture";
$supporting_docs_meta->doc_id = $picture_id;
$supporting_docs_meta->format = $type;
$supporting_docs_meta->Save();
$pictureDoc->doc_id = $picture_id;
$pictureDoc->linked_by = $_SESSION['username'];
$pictureDoc->Save();
}
}
}
public function SaveAll(){
global $global;
$saveType = $this->getSaveType();
//var_dump('saving event type' , $saveType);
if($saveType == 'create'){
acl_add_person($this->person_record_number);
//if event is marked as confidential limit it to this user and admin.
if($this->confidentiality == 'y')
acl_set_person_permissions($this->person_record_number);
}
if($saveType == 'update'){
//if event is marked as confidential limit it to this user and admin.
if($this->confidentiality == 'y')
acl_set_person_permissions($this->person_record_number);
if($this->confidentiality == 'n'){
acl_unset_person_permissions($this->person_record_number);
}
}
parent::SaveAll();
}
public function DeleteFromRecordNumber($recordNumber){
$return = parent::DeleteFromRecordNumber($recordNumber);
if($return){
//remove gacl objects for this perticuler event
acl_delete_person($recordNumber);
}
}
}