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 | |
---|
18 | include_once("class.so_main.inc.php"); |
---|
19 | |
---|
20 | class so_state extends so_main |
---|
21 | { |
---|
22 | |
---|
23 | function so_state ( $id = false ) |
---|
24 | { |
---|
25 | $this->init(); |
---|
26 | |
---|
27 | $this->main_fields = array( |
---|
28 | 'id_state' => array( |
---|
29 | 'name' => 'id_state', |
---|
30 | 'type' => 'primary', |
---|
31 | 'state' => 'empty', |
---|
32 | 'value' => &$this->id |
---|
33 | ), |
---|
34 | 'id_country' => array( |
---|
35 | 'name' => 'id_country', |
---|
36 | 'type' => 'foreign', |
---|
37 | 'association' => array( |
---|
38 | 'table' => 'phpgw_common_country_list', |
---|
39 | 'field' => 'id_country' |
---|
40 | ), |
---|
41 | 'state' => 'empty', |
---|
42 | 'value' => false |
---|
43 | ), |
---|
44 | 'state_name' => array( |
---|
45 | 'name' => 'state_name', |
---|
46 | 'type' => false, |
---|
47 | 'state' => 'empty', |
---|
48 | 'value' => false |
---|
49 | ), |
---|
50 | 'state_symbol' => array( |
---|
51 | 'name' => 'state_symbol', |
---|
52 | 'type' => false, |
---|
53 | 'state' => 'empty', |
---|
54 | 'value' => false |
---|
55 | ) |
---|
56 | ); |
---|
57 | |
---|
58 | |
---|
59 | $this->db_tables = array( |
---|
60 | 'phpgw_cc_state' => array( |
---|
61 | 'type' => 'main', |
---|
62 | 'keys' => array( |
---|
63 | 'primary' => array(&$this->main_fields['id_state']), |
---|
64 | 'foreign' => array(&$this->main_fields['id_country']) |
---|
65 | ), |
---|
66 | 'fields' => & $this->main_fields |
---|
67 | ) |
---|
68 | ); |
---|
69 | |
---|
70 | if($id) |
---|
71 | { |
---|
72 | if (!$this->checkout($id)) |
---|
73 | { |
---|
74 | $this->reset_values(); |
---|
75 | $this->state = 'new'; |
---|
76 | } |
---|
77 | } |
---|
78 | else |
---|
79 | { |
---|
80 | $this->state = 'new'; |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | |
---|
85 | /*********************************************************************\ |
---|
86 | * Methods to Get Information * |
---|
87 | \*********************************************************************/ |
---|
88 | |
---|
89 | /*! |
---|
90 | |
---|
91 | @function get_id_country |
---|
92 | @abstract Returns the ID of the Country where this |
---|
93 | State is located |
---|
94 | @author Raphael Derosso Pereira |
---|
95 | |
---|
96 | */ |
---|
97 | function get_id_country ( ) |
---|
98 | { |
---|
99 | return $this->main_fields['id_country']['value']; |
---|
100 | } |
---|
101 | |
---|
102 | /*! |
---|
103 | |
---|
104 | @function get_state_name |
---|
105 | @abstract Returns the Name of the State |
---|
106 | @author Raphael Derosso Pereira |
---|
107 | |
---|
108 | */ |
---|
109 | function get_state_name ( ) |
---|
110 | { |
---|
111 | return $this->main_fields['state_name']['value']; |
---|
112 | } |
---|
113 | |
---|
114 | /*! |
---|
115 | |
---|
116 | @function get_state_symbol |
---|
117 | @abstract Returns the State Symbol |
---|
118 | @author Raphael Derosso Pereira |
---|
119 | |
---|
120 | */ |
---|
121 | function get_state_symbol ( ) |
---|
122 | { |
---|
123 | return $this->main_fields['state_symbol']['value']; |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | /*********************************************************************\ |
---|
128 | * Methods to Alter Information * |
---|
129 | \*********************************************************************/ |
---|
130 | |
---|
131 | /*! |
---|
132 | |
---|
133 | @function set_id_country |
---|
134 | @abstract Sets the State's Country ID |
---|
135 | @author Raphael Derosso Pereira |
---|
136 | |
---|
137 | @param string $id_country The Country ID |
---|
138 | */ |
---|
139 | function set_id_country ( $id_country ) |
---|
140 | { |
---|
141 | $this->main_fields['id_country']['value'] = $id_country; |
---|
142 | $this->manage_fields($this->main_fields['id_country'], 'changed'); |
---|
143 | } |
---|
144 | |
---|
145 | /*! |
---|
146 | |
---|
147 | @function set_state_name |
---|
148 | @abstract Sets the State's Name |
---|
149 | @author Raphael Derosso Pereira |
---|
150 | |
---|
151 | @param string $name The State Name |
---|
152 | */ |
---|
153 | function set_state_name ( $name ) |
---|
154 | { |
---|
155 | $this->main_fields['state_name']['value'] = $name; |
---|
156 | $this->manage_fields($this->main_fields['state_name'], 'changed'); |
---|
157 | } |
---|
158 | |
---|
159 | /*! |
---|
160 | |
---|
161 | @function set_state_symbol |
---|
162 | @abstract Sets the State's Symbol |
---|
163 | @author Raphael Derosso Pereira |
---|
164 | |
---|
165 | @param string $symbol The State Symbol |
---|
166 | */ |
---|
167 | function set_state_symbol ( $symbol ) |
---|
168 | { |
---|
169 | $this->main_fields['state_symbol']['value'] = $symbol; |
---|
170 | $this->manage_fields($this->main_fields['state_symbol'], 'changed'); |
---|
171 | } |
---|
172 | } |
---|
173 | ?> |
---|