Merged changes from stable branch up to 2.3.12
[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                         $this->language = $user["language"];
57                         $_SESSION['language']->set_language($this->language);
58
59                         $this->qty_dec = $user["qty_dec"];
60                         $this->price_dec = $user["prices_dec"];
61                         $this->exrate_dec = $user["rates_dec"];
62                         $this->percent_dec = $user["percent_dec"];
63
64                         $this->show_gl_info = $user["show_gl"];
65                         $this->show_codes = $user["show_codes"];
66                         $this->date_format = $user["date_format"];
67                         $this->date_sep = $user["date_sep"];
68                         $this->tho_sep = $user["tho_sep"];
69                         $this->dec_sep = $user["dec_sep"];
70                         $this->theme = $user["theme"];
71                         $this->pagesize = $user["page_size"];
72                         $this->show_hints = $user["show_hints"];
73                         $this->print_profile = $user["print_profile"];
74                         $this->rep_popup = $user["rep_popup"];
75                         $this->query_size = $user["query_size"];
76                         $this->graphic_links = $user["graphic_links"];
77                         if (isset($user["sticky_doc_date"]))
78                         {
79                                 $this->sticky_date = $user["sticky_doc_date"];
80                                 $this->startup_tab = $user['startup_tab'];
81                         }
82                         else
83                         {
84                                 $this->sticky_date = 0;
85                                 $this->startup_tab = "orders";
86                         }
87                         $this->transaction_days = $user['transaction_days'];
88                 }
89         }
90         
91         function get_all()
92         {
93                         return array(
94                         'language' => $this->language,
95                         'qty_dec' => $this->qty_dec,
96                         'prices_dec' => $this->price_dec,
97                         'rates_dec' => $this->exrate_dec,
98                         'percent_dec' => $this->percent_dec,
99                         'show_gl' => $this->show_gl_info,
100                         'show_codes' => $this->show_codes,
101                         'date_format' =>$this->date_format,
102                         'date_sep' => $this->date_sep,
103                         'tho_sep' => $this->tho_sep,
104                         'dec_sep' => $this->dec_sep,
105                         'theme' => $this->theme,
106                         'page_size' => $this->pagesize,
107                         'show_hints' => $this->show_hints,
108                         'print_profile' => $this->print_profile,
109                         'rep_popup' => $this->rep_popup,
110                         'query_size' => $this->query_size,
111                         'graphic_links' => $this->graphic_links,
112                         'sticky_doc_date' => $this->sticky_date,
113                         'startup_tab' => $this->startup_tab);
114         }
115         
116         function language() 
117         {
118                 return $this->language;
119         }
120
121         function qty_dec() 
122         {
123                 return $this->qty_dec;
124         }
125
126         function price_dec() 
127         {
128                 return $this->price_dec;
129         }
130
131         function exrate_dec() 
132         {
133                 return $this->exrate_dec;
134         }
135
136         function percent_dec() 
137         {
138                 return $this->percent_dec;
139         }
140
141         function show_gl_info() 
142         {
143                 return $this->show_gl_info;
144         }
145
146         function show_codes() 
147         {
148                 return $this->show_codes;
149         }
150
151         function date_format() 
152         {
153                 return $this->date_format;
154         }
155
156         function date_sep() 
157         {
158                 return $this->date_sep;
159         }
160
161         function date_display() 
162         {
163                 global $dateseps;
164                 $sep = $dateseps[$this->date_sep];
165                 if ($this->date_format == 0)
166                         return "m".$sep."d".$sep."Y";
167                 elseif ($this->date_format == 1)
168                         return "d".$sep."m".$sep."Y";
169                 else
170                         return "Y".$sep."m".$sep."d";
171         }
172
173         function tho_sep() 
174         {
175                 return $this->tho_sep;
176         }
177
178         function dec_sep() 
179         {
180                 return $this->dec_sep;
181         }
182
183         function get_theme() 
184         {
185                 return $this->theme;
186         }
187
188         function get_pagesize() 
189         {
190                 return $this->pagesize;
191         }
192
193         function show_hints() 
194         {
195                 return $this->show_hints;
196         }
197
198         function print_profile() 
199         {
200                 return $this->print_profile;
201         }
202
203         function rep_popup() 
204         {
205                 return $this->rep_popup;
206         }
207
208         function query_size() 
209         {
210                 return $this->query_size;
211         }
212
213         function graphic_links() 
214         {
215                 return $this->graphic_links;
216         }
217         
218         function sticky_date()
219         {
220                 return $this->sticky_date;
221         }
222         
223         function start_up_tab()
224         {
225                 return $this->startup_tab;
226         }
227
228     function transaction_days() 
229     {
230         return $this->transaction_days;
231     }
232
233         function set_dec($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes) 
234         {
235                 $this->price_dec = $price_dec;
236                 $this->qty_dec = $qty_dec;
237                 $this->exrate_dec = $exrate_dec;
238                 $this->percent_dec = $percent_dec;
239                 $this->show_gl_info = $showgl;
240                 $this->show_codes = $showcodes;
241         }
242
243         function set_format($date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize) 
244         {
245                 $this->date_format = $date_format;
246                 $this->date_sep = $date_sep;
247                 $this->tho_sep = $tho_sep;
248                 $this->dec_sep = $dec_sep;
249                 $this->theme = $theme;
250                 $this->pagesize = $pagesize;
251         }
252
253 }
254
255 ?>