Merged last changes from stable.
[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
90                         if (!file_exists("$path_to_root/themes/$this->theme"))
91                                 $this->theme = "default";
92                 }
93         }
94         
95         function get_all()
96         {
97                         return array(
98                         'language' => $this->language,
99                         'qty_dec' => $this->qty_dec,
100                         'prices_dec' => $this->price_dec,
101                         'rates_dec' => $this->exrate_dec,
102                         'percent_dec' => $this->percent_dec,
103                         'show_gl' => $this->show_gl_info,
104                         'show_codes' => $this->show_codes,
105                         'date_format' =>$this->date_format,
106                         'date_sep' => $this->date_sep,
107                         'tho_sep' => $this->tho_sep,
108                         'dec_sep' => $this->dec_sep,
109                         'theme' => $this->theme,
110                         'page_size' => $this->pagesize,
111                         'show_hints' => $this->show_hints,
112                         'print_profile' => $this->print_profile,
113                         'rep_popup' => $this->rep_popup,
114                         'query_size' => $this->query_size,
115                         'graphic_links' => $this->graphic_links,
116                         'sticky_doc_date' => $this->sticky_date,
117                         'startup_tab' => $this->startup_tab);
118         }
119         
120         function language() 
121         {
122                 return $this->language;
123         }
124
125         function qty_dec() 
126         {
127                 return $this->qty_dec;
128         }
129
130         function price_dec() 
131         {
132                 return $this->price_dec;
133         }
134
135         function exrate_dec() 
136         {
137                 return $this->exrate_dec;
138         }
139
140         function percent_dec() 
141         {
142                 return $this->percent_dec;
143         }
144
145         function show_gl_info() 
146         {
147                 return $this->show_gl_info;
148         }
149
150         function show_codes() 
151         {
152                 return $this->show_codes;
153         }
154
155         function date_format() 
156         {
157                 return $this->date_format;
158         }
159
160         function date_sep() 
161         {
162                 return $this->date_sep;
163         }
164
165         function date_display() 
166         {
167                 global $dateseps;
168                 $sep = $dateseps[$this->date_sep];
169                 if ($this->date_format == 0)
170                         return "m".$sep."d".$sep."Y";
171                 elseif ($this->date_format == 1)
172                         return "d".$sep."m".$sep."Y";
173                 elseif ($this->date_format == 2)
174                         return "Y".$sep."m".$sep."d";
175                 elseif ($this->date_format == 3)
176                         return "M".$sep."j".$sep."Y";
177                 elseif ($this->date_format == 4)
178                         return "j".$sep."M".$sep."Y";
179                 else
180                         return "Y".$sep."M".$sep."j";
181         }
182
183         function tho_sep() 
184         {
185                 return $this->tho_sep;
186         }
187
188         function dec_sep() 
189         {
190                 return $this->dec_sep;
191         }
192
193         function get_theme() 
194         {
195                 return $this->theme;
196         }
197
198         function get_pagesize() 
199         {
200                 return $this->pagesize;
201         }
202
203         function show_hints() 
204         {
205                 return $this->show_hints;
206         }
207
208         function print_profile() 
209         {
210                 return $this->print_profile;
211         }
212
213         function rep_popup() 
214         {
215                 return $this->rep_popup;
216         }
217
218         function query_size() 
219         {
220                 return $this->query_size;
221         }
222
223         function graphic_links() 
224         {
225                 return $this->graphic_links;
226         }
227         
228         function sticky_date()
229         {
230                 return $this->sticky_date;
231         }
232         
233         function start_up_tab()
234         {
235                 return $this->startup_tab;
236         }
237
238     function transaction_days() 
239     {
240         return $this->transaction_days;
241     }
242
243         function set_dec($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes) 
244         {
245                 $this->price_dec = $price_dec;
246                 $this->qty_dec = $qty_dec;
247                 $this->exrate_dec = $exrate_dec;
248                 $this->percent_dec = $percent_dec;
249                 $this->show_gl_info = $showgl;
250                 $this->show_codes = $showcodes;
251         }
252
253         function set_format($date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize) 
254         {
255                 $this->date_format = $date_format;
256                 $this->date_sep = $date_sep;
257                 $this->tho_sep = $tho_sep;
258                 $this->dec_sep = $dec_sep;
259                 $this->theme = $theme;
260                 $this->pagesize = $pagesize;
261         }
262
263 }
264
265 ?>