1 | <?php |
---|
2 | /***************************************************************************\ |
---|
3 | * eGroupWare - Contacts Center * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * * |
---|
6 | * Storage Object Classes * |
---|
7 | * Written by: * |
---|
8 | * - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> * |
---|
9 | * sponsored by Thyamad - http://www.thyamad.com * |
---|
10 | * ------------------------------------------------------------------------- * |
---|
11 | * This program is free software; you can redistribute it and/or modify it * |
---|
12 | * under the terms of the GNU General Public License as published by the * |
---|
13 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
14 | * option) any later version. * |
---|
15 | \***************************************************************************/ |
---|
16 | |
---|
17 | include_once("class.so_main.inc.php"); |
---|
18 | |
---|
19 | class so_company extends so_main { |
---|
20 | |
---|
21 | function so_company ( $id_company = false) |
---|
22 | { |
---|
23 | $this->init(); |
---|
24 | |
---|
25 | $this->main_fields = array( |
---|
26 | 'id_company' => array( |
---|
27 | 'name' => 'id_company', |
---|
28 | 'type' => 'primary', |
---|
29 | 'state' => 'empty', |
---|
30 | 'value' => &$this->id |
---|
31 | ), |
---|
32 | 'id_company_owner' => array( |
---|
33 | 'name' => 'id_company_owner', |
---|
34 | 'type' => false, |
---|
35 | 'state' => 'empty', |
---|
36 | 'value' => false |
---|
37 | ), |
---|
38 | 'company_name' => array( |
---|
39 | 'name' => 'company_name', |
---|
40 | 'type' => false, |
---|
41 | 'state' => 'empty', |
---|
42 | 'value' => false |
---|
43 | ), |
---|
44 | 'company_notes' => array( |
---|
45 | 'name' => 'company_notes', |
---|
46 | 'type' => false, |
---|
47 | 'state' => 'empty', |
---|
48 | 'value' => false |
---|
49 | ), |
---|
50 | ); |
---|
51 | |
---|
52 | $this->contacts = array( |
---|
53 | 'id_contact' => array( |
---|
54 | 'name' => 'id_contact', |
---|
55 | 'type' => array('foreign', 'primary'), |
---|
56 | 'association' => array( |
---|
57 | 'table' => 'phpgw_cc_contact', |
---|
58 | 'field' => 'id_contact' |
---|
59 | ), |
---|
60 | 'states' => array(), |
---|
61 | 'values' => array() |
---|
62 | ), |
---|
63 | 'id_company' => array( |
---|
64 | 'name' => 'id_company', |
---|
65 | 'type' => array('foreign', 'primary'), |
---|
66 | 'association' => array( |
---|
67 | 'table' => 'phpgw_cc_company', |
---|
68 | 'field' => 'id_company' |
---|
69 | ), |
---|
70 | 'states' => array(), |
---|
71 | 'values' => array() |
---|
72 | ), |
---|
73 | 'title' => array( |
---|
74 | 'name' => 'title', |
---|
75 | 'type' => false, |
---|
76 | 'states' => array(), |
---|
77 | 'values' => array() |
---|
78 | ), |
---|
79 | 'department' => array( |
---|
80 | 'name' => 'department', |
---|
81 | 'type' => false, |
---|
82 | 'states' => array(), |
---|
83 | 'values' => array() |
---|
84 | ), |
---|
85 | 'default_contact' => array( |
---|
86 | 'name' => 'default_contact', |
---|
87 | 'type' => false, |
---|
88 | 'states' => array(), |
---|
89 | 'values' => array() |
---|
90 | ), |
---|
91 | 'default_company' => array( |
---|
92 | 'name' => 'default_company', |
---|
93 | 'type' => false, |
---|
94 | 'states' => array(), |
---|
95 | 'values' => array() |
---|
96 | ) |
---|
97 | ); |
---|
98 | |
---|
99 | $this->relations = array( |
---|
100 | 'id_company' => array( |
---|
101 | 'name' => 'id_company', |
---|
102 | 'type' => array('foreign', 'primary'), |
---|
103 | 'association' => array( |
---|
104 | 'table' => 'phpgw_cc_company', |
---|
105 | 'field' => 'id_contact' |
---|
106 | ), |
---|
107 | 'states' => array(), |
---|
108 | 'values' => array() |
---|
109 | ), |
---|
110 | 'id_related' => array( |
---|
111 | 'name' => 'id_related', |
---|
112 | 'type' => array('foreign', 'primary'), |
---|
113 | 'association' => array( |
---|
114 | 'table' => 'phpgw_cc_company', |
---|
115 | 'field' => 'id_contact' |
---|
116 | ), |
---|
117 | 'states' => array(), |
---|
118 | 'values' => array() |
---|
119 | ), |
---|
120 | 'id_typeof_company_relation' => array( |
---|
121 | 'name' => 'id_typeof_company_relation', |
---|
122 | 'type' => array('foreign', 'primary'), |
---|
123 | 'association' => array( |
---|
124 | 'table' => 'phpgw_cc_typeof_co_rels', |
---|
125 | 'field' => 'id_typeof_company_relation' |
---|
126 | ), |
---|
127 | 'states' => array(), |
---|
128 | 'values' => false |
---|
129 | ) |
---|
130 | ); |
---|
131 | |
---|
132 | $this->addresses = array( |
---|
133 | 'id_company' => array( |
---|
134 | 'name' => 'id_company', |
---|
135 | 'type' => array('foreign', 'primary'), |
---|
136 | 'association' => array( |
---|
137 | 'table' => 'phpgw_cc_company', |
---|
138 | 'field' => 'id_contact' |
---|
139 | ), |
---|
140 | 'states' => array(), |
---|
141 | 'values' => array() |
---|
142 | ), |
---|
143 | 'id_address' => array( |
---|
144 | 'name' => 'id_address', |
---|
145 | 'type' => array('foreign', 'primary'), |
---|
146 | 'association' => array( |
---|
147 | 'table' => 'phpgw_cc_addresses', |
---|
148 | 'field' => 'id_address' |
---|
149 | ), |
---|
150 | 'states' => array(), |
---|
151 | 'values' => array() |
---|
152 | ), |
---|
153 | 'id_typeof_company_address' => array( |
---|
154 | 'name' => 'id_typeof_company_address', |
---|
155 | 'type' => 'foreign', |
---|
156 | 'association' => array( |
---|
157 | 'table' => 'phpgw_cc_typeof_co_addrs', |
---|
158 | 'field' => 'id_typeof_company_address' |
---|
159 | ), |
---|
160 | 'states' => array(), |
---|
161 | 'values' => array() |
---|
162 | ) |
---|
163 | ); |
---|
164 | |
---|
165 | $this->connections = array( |
---|
166 | 'id_company' => array( |
---|
167 | 'name' => 'id_company', |
---|
168 | 'type' => array('foreign', 'primary'), |
---|
169 | 'association' => array( |
---|
170 | 'table' => 'phpgw_cc_company', |
---|
171 | 'field' => 'id_contact' |
---|
172 | ), |
---|
173 | 'states' => array(), |
---|
174 | 'values' => array() |
---|
175 | ), |
---|
176 | 'id_connection' => array( |
---|
177 | 'name' => 'id_connection', |
---|
178 | 'type' => array('foreign', 'primary'), |
---|
179 | 'association' => array( |
---|
180 | 'table' => 'phpgw_cc_connections', |
---|
181 | 'field' => 'id_connection' |
---|
182 | ), |
---|
183 | 'states' => array(), |
---|
184 | 'values' => array() |
---|
185 | ), |
---|
186 | 'id_typeof_company_connection' => array( |
---|
187 | 'name' => 'id_typeof_company_connection', |
---|
188 | 'type' => array('foreign', 'primary'), |
---|
189 | 'association' => array( |
---|
190 | 'table' => 'phpgw_cc_typeof_co_conns', |
---|
191 | 'field' => 'id_typeof_company_connection' |
---|
192 | ), |
---|
193 | 'states' => array(), |
---|
194 | 'values' => array() |
---|
195 | ) |
---|
196 | ); |
---|
197 | |
---|
198 | $this->legals = array( |
---|
199 | 'id_company_legal' => array( |
---|
200 | 'name' => 'id_company_legal', |
---|
201 | 'type' => array('foreign', 'primary'), |
---|
202 | 'association' => array( |
---|
203 | 'table' => 'phpgw_cc_company', |
---|
204 | 'field' => 'id_company' |
---|
205 | ), |
---|
206 | 'states' => array(), |
---|
207 | 'values' => array() |
---|
208 | ), |
---|
209 | 'id_typeof_company_legal' => array( |
---|
210 | 'name' => 'id_typeof_company_legal', |
---|
211 | 'type' => 'foreign', |
---|
212 | 'association' => array( |
---|
213 | 'table' => 'phpgw_cc_company_legal', |
---|
214 | 'field' => 'id_typeof_company_legal' |
---|
215 | ), |
---|
216 | 'states' => array(), |
---|
217 | 'values' => array() |
---|
218 | ), |
---|
219 | 'id_company' => array( |
---|
220 | 'name' => 'id_company', |
---|
221 | 'type' => 'foreign', |
---|
222 | 'association' => array( |
---|
223 | 'table' => 'phpgw_cc_company', |
---|
224 | 'field' => 'id_company' |
---|
225 | ), |
---|
226 | 'states' => array(), |
---|
227 | 'values' => array() |
---|
228 | ), |
---|
229 | 'legal_info_name' => array( |
---|
230 | 'name' => 'legal_info_name', |
---|
231 | 'type' => false, |
---|
232 | 'states' => array(), |
---|
233 | 'values' => array() |
---|
234 | ), |
---|
235 | 'legal_info_value' => array( |
---|
236 | 'name' => 'legal_info_value', |
---|
237 | 'type' => false, |
---|
238 | 'states' => array(), |
---|
239 | 'values' => array() |
---|
240 | ) |
---|
241 | ); |
---|
242 | |
---|
243 | |
---|
244 | $this->db_tables = array( |
---|
245 | 'phpgw_cc_company' => array( |
---|
246 | 'type' => 'main', |
---|
247 | 'keys' => array( |
---|
248 | 'primary' => array(&$this->main_fields['id_company']), |
---|
249 | 'foreign' => false |
---|
250 | ), |
---|
251 | 'fields' => & $this->main_fields |
---|
252 | ), |
---|
253 | 'phpgw_cc_contact_company' => array( |
---|
254 | 'type' => 'multi', |
---|
255 | 'keys' => array( |
---|
256 | 'primary' => array( |
---|
257 | &$this->contacts['id_contact'], |
---|
258 | &$this->contacts['id_company'] |
---|
259 | ), |
---|
260 | 'foreign' => array( |
---|
261 | &$this->contacts['id_contact'], |
---|
262 | &$this->contacts['id_company'] |
---|
263 | ) |
---|
264 | ), |
---|
265 | 'fields' => & $this->contacts |
---|
266 | ), |
---|
267 | 'phpgw_cc_company_rels' => array( |
---|
268 | 'type' => 'multi', |
---|
269 | 'keys' => array( |
---|
270 | 'primary' => array( |
---|
271 | &$this->relations['id_company'], |
---|
272 | &$this->relations['id_related'] |
---|
273 | ), |
---|
274 | 'foreign' => array( |
---|
275 | &$this->relations['id_company'], |
---|
276 | &$this->relations['id_related'] |
---|
277 | ) |
---|
278 | ), |
---|
279 | 'fields' => & $this->relations |
---|
280 | ), |
---|
281 | 'phpgw_cc_company_addrs' => array( |
---|
282 | 'type' => 'multi', |
---|
283 | 'keys' => array( |
---|
284 | 'primary' => array( |
---|
285 | &$this->addresses['id_company'], |
---|
286 | &$this->addresses['id_address'] |
---|
287 | ), |
---|
288 | 'foreign' => array( |
---|
289 | &$this->addresses['id_company'], |
---|
290 | &$this->addresses['id_address'], |
---|
291 | &$this->addresses['id_typeof_company_address'] |
---|
292 | ) |
---|
293 | ), |
---|
294 | 'fields' => & $this->addresses |
---|
295 | ), |
---|
296 | 'phpgw_cc_company_conns' => array( |
---|
297 | 'type' => 'multi', |
---|
298 | 'keys' => array( |
---|
299 | 'primary' => array( |
---|
300 | &$this->connections['id_company'], |
---|
301 | &$this->connections['id_connection'] |
---|
302 | ), |
---|
303 | 'foreign' => array( |
---|
304 | &$this->connections['id_company'], |
---|
305 | &$this->connections['id_connection'], |
---|
306 | &$this->connections['id_typeof_company_connection'] |
---|
307 | ) |
---|
308 | ), |
---|
309 | 'fields' => & $this->connections |
---|
310 | ) |
---|
311 | ); |
---|
312 | |
---|
313 | if ($id_company) |
---|
314 | { |
---|
315 | $this->id = $id_company; |
---|
316 | if (!$this->checkout($id_company)) |
---|
317 | { |
---|
318 | $this->reset_values(); |
---|
319 | $this->state = 'new'; |
---|
320 | } |
---|
321 | } |
---|
322 | else |
---|
323 | { |
---|
324 | $this->state = 'new'; |
---|
325 | } |
---|
326 | } |
---|
327 | |
---|
328 | /*********************************************************************\ |
---|
329 | * Methods to Get Company Info * |
---|
330 | \*********************************************************************/ |
---|
331 | |
---|
332 | /*! |
---|
333 | |
---|
334 | @function get_company_name |
---|
335 | @abstract Returns the Company Name |
---|
336 | @author Raphael Derosso Pereira |
---|
337 | |
---|
338 | */ |
---|
339 | function get_company_name() |
---|
340 | { |
---|
341 | return $this->main_fields['company_name']['value']; |
---|
342 | } |
---|
343 | |
---|
344 | /*! |
---|
345 | |
---|
346 | @function get_company_notes |
---|
347 | @abstract Returns the Company Notes |
---|
348 | @author Raphael Derosso Pereira |
---|
349 | |
---|
350 | */ |
---|
351 | function get_company_notes() |
---|
352 | { |
---|
353 | return $this->main_fields['company_notes']['value']; |
---|
354 | } |
---|
355 | |
---|
356 | /*! |
---|
357 | |
---|
358 | @function get_legals |
---|
359 | @abstract Returns the Company's Legals IDs |
---|
360 | @author Raphael Derosso Pereira |
---|
361 | |
---|
362 | @return array Format: |
---|
363 | $return = array( |
---|
364 | '<id_legal1>' => array( |
---|
365 | 'id_type' => '<id_type>', |
---|
366 | 'legal_info_name' => '<legal_info_name>', |
---|
367 | 'legal_info_value' => '<legal_info_value>' |
---|
368 | ), |
---|
369 | '<id_legal2>' => array( |
---|
370 | 'id_type' => '<id_type>', |
---|
371 | 'legal_info_name' => '<legal_info_name>', |
---|
372 | 'legal_info_value' => '<legal_info_value>' |
---|
373 | ), |
---|
374 | ... |
---|
375 | ); |
---|
376 | */ |
---|
377 | function get_legals ( ) |
---|
378 | { |
---|
379 | $return = array(); |
---|
380 | |
---|
381 | while(list(,$id_legal) = each($this->legals['id_legal']['values']) and |
---|
382 | list(,$id_type) = each($this->legals['id_typeof_company_legal']['values']) and |
---|
383 | list(,$legal_info_name) = each($this->legals['legal_info_name']['values']) and |
---|
384 | list(,$legal_info_value) = each($this->legals['legal_info_value']['values'])) |
---|
385 | { |
---|
386 | $return[$id_legal] = array( |
---|
387 | 'id_type' => $id_type, |
---|
388 | 'legal_info_name' => $legal_info_name, |
---|
389 | 'legal_info_value' => $legal_info_value |
---|
390 | ); |
---|
391 | } |
---|
392 | |
---|
393 | return $return; |
---|
394 | } |
---|
395 | |
---|
396 | /*! |
---|
397 | |
---|
398 | @function get_relations |
---|
399 | @abstract Returns the Company's Relations |
---|
400 | @author Raphael Derosso Pereira |
---|
401 | |
---|
402 | @return array Format: |
---|
403 | $return = array( |
---|
404 | '<id_related1>' => '<id_relation1_type>', |
---|
405 | '<id_related2>' => '<id_relation2_type>', |
---|
406 | ...); |
---|
407 | */ |
---|
408 | function get_relations ( ) |
---|
409 | { |
---|
410 | $return = array(); |
---|
411 | |
---|
412 | while(list(,$id_related) = each($this->relations['id_related']['values']) and |
---|
413 | list(,$id_relation_type) = each($this->relations['id_typeof_company_relation']['values'])) |
---|
414 | { |
---|
415 | $return[$id_related] = $id_relation_type; |
---|
416 | } |
---|
417 | |
---|
418 | return $return; |
---|
419 | } |
---|
420 | |
---|
421 | /*! |
---|
422 | |
---|
423 | @function get_addresses |
---|
424 | @abstract Returns the Company's Addresses |
---|
425 | @author Raphael Derosso Pereira |
---|
426 | |
---|
427 | @return array Format: |
---|
428 | $return = array( |
---|
429 | '<id_address1>' => '<id_address1_type>', |
---|
430 | '<id_address2>' => '<id_address2_type>', |
---|
431 | ...); |
---|
432 | */ |
---|
433 | function get_addresses ( ) |
---|
434 | { |
---|
435 | $return = array(); |
---|
436 | |
---|
437 | while(list(,$id_address) = each($this->addresses['id_address']['values']) and |
---|
438 | list(,$id_address_type) = each($this->addresses['id_typeof_company_address']['values'])) |
---|
439 | { |
---|
440 | $return[$id_address] = $id_address_type; |
---|
441 | } |
---|
442 | |
---|
443 | return $return; |
---|
444 | } |
---|
445 | |
---|
446 | /*! |
---|
447 | |
---|
448 | @function get_connections |
---|
449 | @abstract Returns the Company's Connections |
---|
450 | @author Raphael Derosso Pereira |
---|
451 | |
---|
452 | @return array Format: |
---|
453 | $return = array( |
---|
454 | '<id_connection1>' => '<id_connection1_type>', |
---|
455 | '<id_connection2>' => '<id_connection2_type>', |
---|
456 | ...); |
---|
457 | */ |
---|
458 | function get_connections ( ) |
---|
459 | { |
---|
460 | $return = array(); |
---|
461 | |
---|
462 | while(list(,$id_connection) = each($this->connections['id_connection']['values']) and |
---|
463 | list(,$id_connection_type) = each($this->connections['id_typeof_company_connection']['values'])) |
---|
464 | { |
---|
465 | $return[$id_connection] = $id_connection_type; |
---|
466 | } |
---|
467 | |
---|
468 | return $return; |
---|
469 | } |
---|
470 | |
---|
471 | /*! |
---|
472 | |
---|
473 | @function get_contacts |
---|
474 | @abstract Returns the Company's Contacts IDs and |
---|
475 | bussiness info |
---|
476 | @author Raphael Derosso Pereira |
---|
477 | |
---|
478 | @return array Format: |
---|
479 | $return = array( |
---|
480 | '<id_contact1>' => array( |
---|
481 | 'title' => '<title>', |
---|
482 | 'department' => '<department>' |
---|
483 | ), |
---|
484 | '<id_contact2>' => array( |
---|
485 | 'title' => '<title>', |
---|
486 | 'department' => '<department>' |
---|
487 | ), |
---|
488 | ... |
---|
489 | ); |
---|
490 | */ |
---|
491 | function get_contacts ( ) |
---|
492 | { |
---|
493 | $return = array(); |
---|
494 | |
---|
495 | while(list(,$id_contact) = each($this->contacts['id_contact']['values']) and |
---|
496 | list(,$title) = each($this->contacts['title']['values']) and |
---|
497 | list(,$department) = each($this->contacts['department']['values'])) |
---|
498 | { |
---|
499 | $return[$id_contact] = array( |
---|
500 | 'title' => $title, |
---|
501 | 'department' => $department); |
---|
502 | } |
---|
503 | |
---|
504 | return $return; |
---|
505 | } |
---|
506 | |
---|
507 | |
---|
508 | /*********************************************************************\ |
---|
509 | * Methods to Alter Data * |
---|
510 | \*********************************************************************/ |
---|
511 | |
---|
512 | /*! |
---|
513 | |
---|
514 | @function set_company_name |
---|
515 | @abstract Sets the Company's Name |
---|
516 | @author Raphael Derosso Pereira |
---|
517 | @param string $name The new Contact's Name |
---|
518 | |
---|
519 | */ |
---|
520 | function set_company_name ( $name ) |
---|
521 | { |
---|
522 | $this->main_fields['company_name']['value'] = $name; |
---|
523 | $this->manage_fields($this->main_fields['company_name'], 'changed'); |
---|
524 | } |
---|
525 | |
---|
526 | /*! |
---|
527 | |
---|
528 | @function set_company_notes |
---|
529 | @abstract Sets the Company's Notes |
---|
530 | @author Raphael Derosso Pereira |
---|
531 | @param string $name The new Company's Name |
---|
532 | |
---|
533 | */ |
---|
534 | function set_company_notes ( $notes ) |
---|
535 | { |
---|
536 | $this->main_fields['company_notes']['value'] = $notes; |
---|
537 | $this->manage_fields($this->main_fields['company_notes'], 'changed'); |
---|
538 | } |
---|
539 | |
---|
540 | /*! |
---|
541 | |
---|
542 | @function set_legal |
---|
543 | @abstract Sets on of this Company's Legal |
---|
544 | @author Raphael Derosso Pereira |
---|
545 | @param integer $id_legal The Company's Legal ID |
---|
546 | @param integer $id_type The new Company's Legal type ID |
---|
547 | @param string $legal_info The new Company's Legal information name |
---|
548 | @param string $legal_info_value The new Company's Legal information |
---|
549 | value |
---|
550 | |
---|
551 | */ |
---|
552 | function set_legal ( $id_legal, $id_type, $legal_info_name, $legal_info_value ) |
---|
553 | { |
---|
554 | if (($pos = array_search($id_legal, $this->legals['id_legal']['values']))) |
---|
555 | { |
---|
556 | $this->legals['id_typeof_company_legal']['values'][$pos] = $id_type; |
---|
557 | $this->legals['legal_info_name']['values'][$pos] = $legal_info_name; |
---|
558 | $this->legals['legal_info_value']['values'][$pos] = $legal_info_value; |
---|
559 | |
---|
560 | $this->manage_fields($this->legals['id_typeof_company_legal'], 'changed', $pos); |
---|
561 | $this->manage_fields($this->legals['legal_info'], 'changed', $pos); |
---|
562 | $this->manage_fields($this->legals['legal_value'], 'changed', $pos); |
---|
563 | |
---|
564 | return; |
---|
565 | } |
---|
566 | |
---|
567 | array_push($this->legals['id_company']['values'], &$this->id); |
---|
568 | array_push($this->legals['id_legal']['values'], $id_legal); |
---|
569 | array_push($this->legals['id_typeof_company_legal']['values'], $id_legal); |
---|
570 | array_push($this->legals['legal_info_name']['values'], $legal_info_name); |
---|
571 | array_push($this->legals['legal_info_value']['values'], $legal_info_value); |
---|
572 | |
---|
573 | $this->manage_fields($this->legals['id_company']['values'], 'changed', 'new'); |
---|
574 | $this->manage_fields($this->legals['id_legal']['values'], 'changed', 'new'); |
---|
575 | $this->manage_fields($this->legals['id_typeof_company_legal'], 'changed', 'new'); |
---|
576 | $this->manage_fields($this->legals['legal_info'], 'changed', 'new'); |
---|
577 | $this->manage_fields($this->legals['legal_value'], 'changed', 'new'); |
---|
578 | } |
---|
579 | |
---|
580 | /*! |
---|
581 | |
---|
582 | @function set_relation |
---|
583 | @abstract Sets the company's Relation |
---|
584 | @author Raphael Derosso Pereira |
---|
585 | @param integer $id_related The new company's Relation type ID |
---|
586 | @param integer $id_type The new company's Relation ID |
---|
587 | |
---|
588 | */ |
---|
589 | function set_relation ( $id_related, $id_type ) |
---|
590 | { |
---|
591 | if (($pos = array_search($id_related, $this->relations['id_related']['values']))) |
---|
592 | { |
---|
593 | $this->relations['id_typeof_company_relation']['values'][$pos] = $id_type; |
---|
594 | $this->manage_fields($this->relations['id_typeof_company_relation'], 'changed', $pos); |
---|
595 | |
---|
596 | return; |
---|
597 | } |
---|
598 | |
---|
599 | array_push($this->relations['id_company']['values'], &$this->id); |
---|
600 | array_push($this->relations['id_related']['values'], $id_related); |
---|
601 | array_push($this->relations['id_typeof_company_relation']['values'], $id_type); |
---|
602 | |
---|
603 | $this->manage_fields($this->relations['id_company']['values'], 'changed', 'new'); |
---|
604 | $this->manage_fields($this->relations['id_typeof_company_relation'], 'changed', 'new'); |
---|
605 | $this->manage_fields($this->relations['id_related'], 'changed', 'new'); |
---|
606 | } |
---|
607 | |
---|
608 | /*! |
---|
609 | |
---|
610 | @function set_address |
---|
611 | @abstract Sets the company's Address |
---|
612 | @author Raphael Derosso Pereira |
---|
613 | @param integer $id_address The new company's Address ID |
---|
614 | @param integer $id_type The new company's Address type ID |
---|
615 | |
---|
616 | */ |
---|
617 | function set_address ( $id_address, $id_type ) |
---|
618 | { |
---|
619 | if (($pos = array_search($id_address, $this->addresses['id_address']['values']))) |
---|
620 | { |
---|
621 | $this->addresses['id_typeof_company_address']['values'][$pos] = $id_type; |
---|
622 | $this->manage_fields($this->addresses['id_typeof_company_address'], 'changed', $pos); |
---|
623 | |
---|
624 | return; |
---|
625 | } |
---|
626 | |
---|
627 | array_push($this->addresses['id_company']['values'], &$this->id); |
---|
628 | array_push($this->addresses['id_address']['values'], $id_address); |
---|
629 | array_push($this->addresses['id_typeof_company_address']['values'], $id_type); |
---|
630 | |
---|
631 | $this->manage_fields($this->addresses['id_company']['values'], 'changed', 'new'); |
---|
632 | $this->manage_fields($this->addresses['id_typeof_company_address'], 'changed', 'new'); |
---|
633 | $this->manage_fields($this->addresses['id_address'], 'changed', 'new'); |
---|
634 | } |
---|
635 | |
---|
636 | /*! |
---|
637 | |
---|
638 | @function set_connection |
---|
639 | @abstract Sets the company's Connection |
---|
640 | @author Raphael Derosso Pereira |
---|
641 | @param integer $id_connection The new company's Connection ID |
---|
642 | @param integer $id_type The new company's Connection type ID |
---|
643 | |
---|
644 | */ |
---|
645 | function set_connection ( $id_connection, $id_type ) |
---|
646 | { |
---|
647 | if (($pos = array_search($id_connection, $this->connections['id_connection']['values']))) |
---|
648 | { |
---|
649 | $this->connections['id_typeof_company_connection']['values'][$pos] = $id_type; |
---|
650 | $this->manage_fields($this->connections['id_typeof_company_connection'], 'changed', $pos); |
---|
651 | |
---|
652 | return; |
---|
653 | } |
---|
654 | |
---|
655 | array_push($this->connections['id_company']['values'], &$this->id); |
---|
656 | array_push($this->connections['id_connection']['values'], $id_connection); |
---|
657 | array_push($this->connections['id_typeof_company_connection']['values'], $id_type); |
---|
658 | |
---|
659 | $this->manage_fields($this->connections['id_company']['values'], 'changed', 'new'); |
---|
660 | $this->manage_fields($this->connections['id_typeof_company_connection'], 'changed', 'new'); |
---|
661 | $this->manage_fields($this->connections['id_connection'], 'changed', 'new'); |
---|
662 | } |
---|
663 | |
---|
664 | /*! |
---|
665 | |
---|
666 | @function set_contact |
---|
667 | @abstract Sets the Company's Contacts information |
---|
668 | @author Raphael Derosso Pereira |
---|
669 | @param integer $id_contact The new Company's Contac ID |
---|
670 | @param string $title The new Contact's Title on this Company |
---|
671 | @param string $department The new Contact's Department on this |
---|
672 | Company |
---|
673 | |
---|
674 | */ |
---|
675 | function set_contact ( $id_contact, $title, $department ) |
---|
676 | { |
---|
677 | if (($pos = array_search($id_contact, $this->contacts['id_contact']['values']))) |
---|
678 | { |
---|
679 | $this->contacts['title']['values'][$pos] = $title; |
---|
680 | $this->contacts['department']['values'][$pos] = $department; |
---|
681 | |
---|
682 | $this->manage_fields($this->contacts['title'], 'changed', $pos); |
---|
683 | $this->manage_fields($this->contacts['department'], 'changed', $pos); |
---|
684 | |
---|
685 | return; |
---|
686 | } |
---|
687 | |
---|
688 | array_push($this->contacts['id_company']['values'], &$this->id); |
---|
689 | array_push($this->contacts['id_contact']['values'], $id_contact); |
---|
690 | array_push($this->contacts['title']['values'], $title); |
---|
691 | array_push($this->contacts['department']['values'], $department); |
---|
692 | |
---|
693 | $this->manage_fields($this->contacts['id_company']['values'], 'changed', 'new'); |
---|
694 | $this->manage_fields($this->contacts['title'], 'changed', 'new'); |
---|
695 | $this->manage_fields($this->contacts['department'], 'changed', 'new'); |
---|
696 | } |
---|
697 | |
---|
698 | |
---|
699 | |
---|
700 | /*********************************************************************\ |
---|
701 | * Methods to Remove Data * |
---|
702 | \*********************************************************************/ |
---|
703 | |
---|
704 | |
---|
705 | /*! |
---|
706 | |
---|
707 | @function remove_relation |
---|
708 | @abstract Remove one Company's Relation |
---|
709 | @author Raphael Derosso Pereira |
---|
710 | @param integer $id_relation The ID of the relation to be removed |
---|
711 | |
---|
712 | */ |
---|
713 | function remove_relation ( $id_related ) |
---|
714 | { |
---|
715 | if (($pos = array_search($id_related, $this->relations['id_related']['values']))) |
---|
716 | { |
---|
717 | $this->manage_fields($this->relations['id_related'], 'deleted', $pos); |
---|
718 | $this->manage_fields($this->relations['id_typeof_company_relation'], 'deleted', $pos); |
---|
719 | |
---|
720 | return true; |
---|
721 | } |
---|
722 | |
---|
723 | return false; |
---|
724 | } |
---|
725 | |
---|
726 | /*! |
---|
727 | |
---|
728 | @function remove_address |
---|
729 | @abstract Remove one Company's Address |
---|
730 | @author Raphael Derosso Pereira |
---|
731 | @param integer $id_address The ID of the address to be removed |
---|
732 | |
---|
733 | */ |
---|
734 | function remove_address ( $id_address ) |
---|
735 | { |
---|
736 | if (($pos = array_search($id_address, $this->addresses['id_address']['values']))) |
---|
737 | { |
---|
738 | $this->manage_fields($this->addresses['id_address'], 'deleted', $pos); |
---|
739 | $this->manage_fields($this->addresses['id_typeof_company_address'], 'deleted', $pos); |
---|
740 | |
---|
741 | return true; |
---|
742 | } |
---|
743 | |
---|
744 | return false; |
---|
745 | } |
---|
746 | |
---|
747 | /*! |
---|
748 | |
---|
749 | @function remove_connection |
---|
750 | @abstract Remove one Company's Connection |
---|
751 | @author Raphael Derosso Pereira |
---|
752 | @param integer $id_connection The ID of the connection to be removed |
---|
753 | |
---|
754 | */ |
---|
755 | function remove_connection ( $id_connection ) |
---|
756 | { |
---|
757 | if (($pos = array_search($id_connection, $this->connections['id_connection']['values']))) |
---|
758 | { |
---|
759 | $this->manage_fields($this->connections['id_connection'], 'deleted', $pos); |
---|
760 | $this->manage_fields($this->connections['id_typeof_company_connection'], 'deleted', $pos); |
---|
761 | |
---|
762 | return true; |
---|
763 | } |
---|
764 | |
---|
765 | return false; |
---|
766 | } |
---|
767 | |
---|
768 | /*! |
---|
769 | |
---|
770 | @function remove_contact |
---|
771 | @abstract Remove one Company's Contact |
---|
772 | @author Raphael Derosso Pereira |
---|
773 | @param integer $id_contact The ID of the contact to be removed |
---|
774 | |
---|
775 | */ |
---|
776 | function remove_contact ( $id_contact ) |
---|
777 | { |
---|
778 | if (($pos = array_search($id_contact, $this->contacts['id_contact']['values']))) |
---|
779 | { |
---|
780 | $this->manage_fields($this->contacts['id_contact'], 'deleted', $pos); |
---|
781 | $this->manage_fields($this->contacts['title'], 'deleted', $pos); |
---|
782 | $this->manage_fields($this->contacts['department'], 'deleted', $pos); |
---|
783 | |
---|
784 | return true; |
---|
785 | } |
---|
786 | |
---|
787 | return false; |
---|
788 | } |
---|
789 | |
---|
790 | |
---|
791 | /*! |
---|
792 | |
---|
793 | @function remove_legal |
---|
794 | @abstract Remove one Company's Legal |
---|
795 | @author Raphael Derosso Pereira |
---|
796 | @param integer $id_company The ID of the legal information to be removed |
---|
797 | |
---|
798 | */ |
---|
799 | function remove_legal ( $id_type ) |
---|
800 | { |
---|
801 | if (($pos = array_search($id_type, $this->contacts['id_contact']['values']))) |
---|
802 | { |
---|
803 | $this->manage_fields($this->legals['id_company']['values'], 'deleted', $pos); |
---|
804 | $this->manage_fields($this->legals['id_legal']['values'], 'deleted', $pos); |
---|
805 | $this->manage_fields($this->legals['id_typeof_company_legal'], 'deleted', $pos); |
---|
806 | $this->manage_fields($this->legals['legal_info'], 'deleted', $pos); |
---|
807 | $this->manage_fields($this->legals['legal_value'], 'deleted', $pos); |
---|
808 | |
---|
809 | return true; |
---|
810 | } |
---|
811 | |
---|
812 | return false; |
---|
813 | } |
---|
814 | |
---|
815 | } |
---|
816 | ?> |
---|