Merged changes up to 2.3.16 into unstable
[fa-stable.git] / includes / prefs / userprefs.inc
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 class user_prefs 
13 {
14
15         var $language;
16
17         var $qty_dec;
18         var $price_dec;
19         var     $exrate_dec;
20         var     $percent_dec;
21
22         var     $show_gl_info;
23         var     $show_codes;
24
25         var $date_format;
26         var $date_sep;
27         var $tho_sep;
28         var $dec_sep;
29         var $theme;
30         var $print_profile;
31         var $rep_popup;
32         var $pagesize; // for printing
33         var $show_hints;
34         var $query_size; // table pager page length
35         var $graphic_links; // use graphic links
36         var $sticky_date;       // save date on subsequent document entry
37         var $startup_tab;  // default start-up menu tab
38         var $transaction_days; // transaction days in inquiries.
39
40         function user_prefs($user=null)
41         {
42                 if ($user == null) { 
43                         // set default values, used before login
44                         global $dflt_lang, $dflt_date_sep, $dflt_date_fmt;
45                         
46                         $this->date_sep = $dflt_date_sep;
47                         $this->date_format = $dflt_date_fmt;
48                         $this->tho_sep = 0;
49                         $this->dec_sep = 0;
50                         $this->price_dec = 2;
51                         $this->language = $dflt_lang;
52                         $this->theme = 'default';
53                         $this->transaction_days = -30;
54
55                 } else {
56                         global $path_to_root;
57                         $this->language = $user["language"];
58                         $_SESSION['language']->set_language($this->language);
59
60                         $this->qty_dec = $user["qty_dec"];
61                         $this->price_dec = $user["prices_dec"];
62                         $this->exrate_dec = $user["rates_dec"];
63                         $this->percent_dec = $user["percent_dec"];
64
65                         $this->show_gl_info = $user["show_gl"];
66                         $this->show_codes = $user["show_codes"];
67                         $this->date_format = $user["date_format"];
68                         $this->date_sep = $user["date_sep"];
69                         $this->tho_sep = $user["tho_sep"];
70                         $this->dec_sep = $user["dec_sep"];
71                         $this->theme = $user["theme"];
72                         $this->pagesize = $user["page_size"];
73                         $this->show_hints = $user["show_hints"];
74                         $this->print_profile = $user["print_profile"];
75                         $this->rep_popup = $user["rep_popup"];
76                         $this->query_size = $user["query_size"];
77                         $this->graphic_links = $user["graphic_links"];
78                         if (isset($user["sticky_doc_date"]))
79                         {
80                                 $this->sticky_date = $user["sticky_doc_date"];
81                                 $this->startup_tab = $user['startup_tab'];
82                         }
83                         else
84                         {
85                                 $this->sticky_date = 0;
86                                 $this->startup_tab = "orders";
87                         }
88                         $this->transaction_days = $user['transaction_days'];
89                         if (!file_exists("$path_to_root/themes/$this->theme"))
90                                 $this->theme = "default";
91                 }
92         }
93         
94         function get_all()
95         {
96                         return array(
97                         'language' => $this->language,
98                         'qty_dec' => $this->qty_dec,
99                         'prices_dec' => $this->price_dec,
100                         'rates_dec' => $this->exrate_dec,
101                         'percent_dec' => $this->percent_dec,
102                         'show_gl' => $this->show_gl_info,
103                         'show_codes' => $this->show_codes,
104                         'date_format' =>$this->date_format,
105                         'date_sep' => $this->date_sep,
106                         'tho_sep' => $this->tho_sep,
107                         'dec_sep' => $this->dec_sep,
108                         'theme' => $this->theme,
109                         'page_size' => $this->pagesize,
110                         'show_hints' => $this->show_hints,
111                         'print_profile' => $this->print_profile,
112                         'rep_popup' => $this->rep_popup,
113                         'query_size' => $this->query_size,
114                         'graphic_links' => $this->graphic_links,
115                         'sticky_doc_date' => $this->sticky_date,
116                         'startup_tab' => $this->startup_tab);
117         }
118         
119         function language() 
120         {
121                 return $this->language;
122         }
123
124         function qty_dec() 
125         {
126                 return $this->qty_dec;
127         }
128
129         function price_dec() 
130         {
131                 return $this->price_dec;
132         }
133
134         function exrate_dec() 
135         {
136                 return $this->exrate_dec;
137         }
138
139         function percent_dec() 
140         {
141                 return $this->percent_dec;
142         }
143
144         function show_gl_info() 
145         {
146                 return $this->show_gl_info;
147         }
148
149         function show_codes() 
150         {
151                 return $this->show_codes;
152         }
153
154         function date_format() 
155         {
156                 return $this->date_format;
157         }
158
159         function date_sep() 
160         {
161                 return $this->date_sep;
162         }
163
164         function date_display() 
165         {
166                 global $dateseps;
167                 $sep = $dateseps[$this->date_sep];
168                 if ($this->date_format == 0)
169                         return "m".$sep."d".$sep."Y";
170                 elseif ($this->date_format == 1)
171                         return "d".$sep."m".$sep."Y";
172                 elseif ($this->date_format == 2)
173                         return "Y".$sep."m".$sep."d";
174                 elseif ($this->date_format == 3)
175                         return "M".$sep."j".$sep."Y";
176                 elseif ($this->date_format == 4)
177                         return "j".$sep."M".$sep."Y";
178                 else
179                         return "Y".$sep."M".$sep."j";
180         }
181
182         function tho_sep() 
183         {
184                 return $this->tho_sep;
185         }
186
187         function dec_sep() 
188         {
189                 return $this->dec_sep;
190         }
191
192         function get_theme() 
193         {
194                 return $this->theme;
195         }
196
197         function get_pagesize() 
198         {
199                 return $this->pagesize;
200         }
201
202         function show_hints() 
203         {
204                 return $this->show_hints;
205         }
206
207         function print_profile() 
208         {
209                 return $this->print_profile;
210         }
211
212         function rep_popup() 
213         {
214                 return $this->rep_popup;
215         }
216
217         function query_size() 
218         {
219                 return $this->query_size;
220         }
221
222         function graphic_links() 
223         {
224                 return $this->graphic_links;
225         }
226         
227         function sticky_date()
228         {
229                 return $this->sticky_date;
230         }
231         
232         function start_up_tab()
233         {
234                 return $this->startup_tab;
235         }
236
237     function transaction_days() 
238     {
239         return $this->transaction_days;
240     }
241
242         function set_dec($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes) 
243         {
244                 $this->price_dec = $price_dec;
245                 $this->qty_dec = $qty_dec;
246                 $this->exrate_dec = $exrate_dec;
247                 $this->percent_dec = $percent_dec;
248                 $this->show_gl_info = $showgl;
249                 $this->show_codes = $showcodes;
250         }
251
252         function set_format($date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize) 
253         {
254                 $this->date_format = $date_format;
255                 $this->date_sep = $date_sep;
256                 $this->tho_sep = $tho_sep;
257                 $this->dec_sep = $dec_sep;
258                 $this->theme = $theme;
259                 $this->pagesize = $pagesize;
260         }
261
262 }
263
264 ?>