source: branches/1.2/contactcenter/inc/class.so_address.inc.php @ 2

Revision 2, 9.7 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /***************************************************************************\
3  * eGroupWare - Contacts Center                                              *
4  * http://www.egroupware.org                                                 *
5  * Storage Object Classes                                                    *
6  * Written by:                                                               *
7  *  - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net>         *
8  *  sponsored by Thyamad - http://www.thyamad.com                            *
9  * ------------------------------------------------------------------------- *
10  *  This program is free software; you can redistribute it and/or modify it  *
11  *  under the terms of the GNU General Public License as published by the    *
12  *  Free Software Foundation; either version 2 of the License, or (at your   *
13  *  option) any later version.                                               *
14  \***************************************************************************/
15
16
17        include_once("class.so_main.inc.php");
18
19        class so_address extends so_main {
20
21                function so_address ( $id = false )
22                {
23                        $this->init();
24                       
25                        $this->main_fields = array(
26                                'id_address' => array(
27                                        'name'  => 'id_address',
28                                        'type'  => 'primary',
29                                        'state' => 'empty',
30                                        'value' => &$this->id
31                                ),
32                                'id_city' => array(
33                                        'name'  => 'id_city',
34                                        'type'  => 'foreign',
35                                        'association' => array(
36                                                'table' => 'phpgw_cc_city',
37                                                'field' => 'id_city'
38                                        ),
39                                        'state' => 'empty',
40                                        'value' => false
41                                ),
42                                'id_state' => array(
43                                        'name'  => 'id_state',
44                                        'type'  => 'foreign',
45                                        'association' => array(
46                                                'table' => 'phpgw_cc_state',
47                                                'field' => 'id_state'
48                                        ),
49                                        'state' => 'empty',
50                                        'value' => false
51                                ),
52                                'id_country' => array(
53                                        'name'  => 'id_country',
54                                        'type'  => false,
55                                        'state' => 'empty',
56                                        'value' => false
57                                ),
58                                'address1' => array(
59                                        'name'  => 'address1',
60                                        'type'  => false,
61                                        'state' => 'empty',
62                                        'value' => false
63                                ),
64                                'address2' => array(
65                                        'name'  => 'address2',
66                                        'type'  => false,
67                                        'state' => 'empty',
68                                        'value' => false
69                                ),
70                                'complement' => array(
71                                        'name'  => 'complement',
72                                        'type'  => false,
73                                        'state' => 'empty',
74                                        'value' => false
75                                ),
76                                'address_other' => array(
77                                        'name'  => 'address_other',
78                                        'type'  => false,
79                                        'state' => 'empty',
80                                        'value' => false
81                                ),
82                                'postal_code' => array(
83                                        'name'  => 'postal_code',
84                                        'type'  => false,
85                                        'state' => 'empty',
86                                        'value' => false
87                                ),
88                                'po_box' => array(
89                                        'name'  => 'po_box',
90                                        'type'  => false,
91                                        'state' => 'empty',
92                                        'value' => false
93                                ),
94                                'address_is_default' => array(
95                                        'name'  => 'address_is_default',
96                                        'type'  => false,
97                                        'state' => 'empty',
98                                        'value' => false
99                                )
100                        );
101                       
102
103                        $this->db_tables = array(
104                                'phpgw_cc_addresses' => array(
105                                        'type'   => 'main',
106                                        'keys'   => array(
107                                                'primary' => array(&$this->main_fields['id_address']),
108                                                'foreign' => array(&$this->main_fields['id_city'],
109                                                                   &$this->main_fields['id_state'])
110                                        ),
111                                        'fields' => & $this->main_fields
112                                )
113                        );
114                       
115                        if($id)
116                        {
117                                if (!$this->checkout($id))
118                                {
119                                        $this->reset_values();
120                                        $this->state = 'new';
121                                }
122                        }
123                        else
124                        {
125                                $this->state = 'new';
126                        }
127                }
128       
129
130                /*********************************************************************\
131                 *                   Methods to Get Information                      *
132                \*********************************************************************/
133               
134                /*!
135               
136                        @function get_id_city
137                        @abstract Returns the ID of the City where this
138                                address is located
139                        @author Raphael Derosso Pereira
140               
141                */
142                function get_id_city (  )
143                {
144                        return $this->main_fields['id_city']['value'];
145                }
146       
147                /*!
148               
149                        @function get_id_state
150                        @abstract Returns the ID of the State where this
151                                address is located
152                        @author Raphael Derosso Pereira
153               
154                */
155                function get_id_state (  )
156                {
157                        return $this->main_fields['id_state']['value'];
158                }
159       
160                /*!
161               
162                        @function get_id_country
163                        @abstract Returns the ID of the Country where this
164                                address is located
165                        @author Raphael Derosso Pereira
166               
167                */
168                function get_id_country (  )
169                {
170                        return $this->main_fields['id_country']['value'];
171                }
172       
173                /*!
174               
175                        @function get_address1
176                        @abstract Returns the Address1
177                        @author Raphael Derosso Pereira
178               
179                */
180                function get_address1 (  )
181                {
182                        return $this->main_fields['address1']['value'];
183                }
184       
185                /*!
186               
187                        @function get_address2
188                        @abstract Returns the Address2
189                        @author Raphael Derosso Pereira
190               
191                */
192                function get_address2 (  )
193                {
194                        return $this->main_fields['address2']['value'];
195                }
196       
197                /*!
198               
199                        @function get_complement
200                        @abstract Returns the Address' Complement
201                        @author Raphael Derosso Pereira
202               
203                */
204                function get_complement (  )
205                {
206                        return $this->main_fields['complement']['value'];
207                }
208       
209                /*!
210               
211                        @function get_address_other
212                        @abstract Returns the Other Address Info, like
213                                quarter, neighborhood, county, etc...
214                        @author Raphael Derosso Pereira
215               
216                */
217                function get_address_other (  )
218                {
219                        return $this->main_fields['address_other']['value'];
220                }
221       
222                /*!
223               
224                        @function get_postal_code
225                        @abstract Returns the Postal Code of the Address
226                        @author Raphael Derosso Pereira
227               
228                */
229                function get_postal_code (  )
230                {
231                        return $this->main_fields['postal_code']['value'];
232                }
233       
234                /*!
235               
236                        @function get_bo_box
237                        @abstract Returns the PO BOX number
238                        @author Raphael Derosso Pereira
239               
240                */
241                function get_po_box (  )
242                {
243                        return $this->main_fields['po_box']['value'];
244                }
245       
246                /*!
247               
248                        @function is_default
249                        @abstract Returns true or false depending on the value
250                                of address_is_default
251                        @author Raphael Derosso Pereira
252               
253                */
254                function is_default (  )
255                {
256                        switch(strtoupper($this->main_fields['address_is_default']['value']))
257                        {
258                                case 'T':
259                                case 'TRUE':
260                                case '1':
261                                        return true;
262                                       
263                                default:
264                                        return false;
265                        }
266                }
267       
268
269                /*********************************************************************\
270                 *                   Methods to Alter Information                    *
271                \*********************************************************************/
272               
273                /*!
274               
275                        @function set_id_city
276                        @abstract Sets the Address City ID
277                        @author Raphael Derosso Pereira
278               
279                        @param integer $id_city The City ID
280                */
281                function set_id_city ( $id_city )
282                {
283                        $this->main_fields['id_city']['value'] = $id_city;
284                        $this->manage_fields($this->main_fields['id_city'], 'changed');
285                }
286       
287                /*!
288               
289                        @function set_id_state
290                        @abstract Sets the Address State ID
291                        @author Raphael Derosso Pereira
292               
293                        @param integer $id_state The State ID
294                */
295                function set_id_state ( $id_state )
296                {
297                        $this->main_fields['id_state']['value'] = $id_state;
298                        $this->manage_fields($this->main_fields['id_state'], 'changed');
299                }
300       
301                /*!
302               
303                        @function set_id_country
304                        @abstract Sets the Address Country ID
305                        @author Raphael Derosso Pereira
306               
307                        @param integer $id_country The Country ID
308                */
309                function set_id_country ( $id_country )
310                {
311                        $this->main_fields['id_country']['value'] = $id_country;
312                        $this->manage_fields($this->main_fields['id_country'], 'changed');
313                }
314       
315                /*!
316               
317                        @function set_address1
318                        @abstract Sets the Address 1
319                        @author Raphael Derosso Pereira
320               
321                        @param string $address1 The Address
322               
323                */
324                function set_address1 ( $address1 )
325                {
326                        $this->main_fields['address1']['value'] = $address1;
327                        $this->manage_fields($this->main_fields['address1'], 'changed');
328                }
329       
330                /*!
331               
332                        @function set_address2
333                        @abstract Sets the Address 2
334                        @author Raphael Derosso Pereira
335               
336                        @param string $address2 The Address
337               
338                */
339                function set_address2 ( $address2 )
340                {
341                        $this->main_fields['address2']['value'] = $address2;
342                        $this->manage_fields($this->main_fields['address2'], 'changed');
343                }
344       
345                /*!
346               
347                        @function set_postal_code
348                        @abstract Sets the Postal Code
349                        @author Raphael Derosso Pereira
350               
351                        @param string $postal_code The Postal Code
352               
353                */
354                function set_postal_code ( $postal_code )
355                {
356                        $this->main_fields['postal_code']['value'] = $postal_code;
357                        $this->manage_fields($this->main_fields['postal_code'], 'changed');
358                }
359       
360                /*!
361               
362                        @function set_po_box
363                        @abstract Sets the PO BOX
364                        @author Raphael Derosso Pereira
365               
366                        @param string $po_box The PO BOX
367               
368                */
369                function set_po_box ( $po_box )
370                {
371                        $this->main_fields['po_box']['value'] = $po_box;
372                        $this->manage_fields($this->main_fields['po_box'], 'changed');
373                }
374       
375                /*!
376               
377                        @function set_complement
378                        @abstract Sets the Complement
379                        @author Raphael Derosso Pereira
380               
381                        @param string $complement The Complement
382               
383                */
384                function set_complement ( $complement )
385                {
386                        $this->main_fields['complement']['value'] = $complement;
387                        $this->manage_fields($this->main_fields['complement'], 'changed');
388                }
389       
390                /*!
391               
392                        @function set_address_other
393                        @abstract Sets any other address information on
394                                the option of the user, like quarter, county, etc
395                        @author Raphael Derosso Pereira
396               
397                        @param string $address_other The Address
398               
399                */
400                function set_address_other ( $address_other )
401                {
402                        $this->main_fields['address_other']['value'] = $address_other;
403                        $this->manage_fields($this->main_fields['address_other'], 'changed');
404                }
405       
406                /*!
407               
408                        @function set_address_is_default
409                        @abstract Sets the default state of this Address
410                        @author Raphael Derosso Pereira
411               
412                        @param boolean $default The default state
413               
414                */
415                function set_address_is_default ( $default )
416                {
417                        if ($default)
418                        {
419                                $this->main_fields['address_is_default']['value'] = 1;
420                        }
421                        else
422                        {
423                                $this->main_fields['address_is_default']['value'] = 0;
424                        }
425                        $this->manage_fields($this->main_fields['address_is_default'], 'changed');
426                }
427        }
428?>
Note: See TracBrowser for help on using the repository browser.