c33220cf84fa76ed473063d5b847a45815a193b7
[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         
39         function user_prefs($user=null)
40         {
41                 if ($user == null) { 
42                         // set default values, used before login
43                         global $dflt_lang;
44                         
45                         $this->date_sep = 0;
46                         $this->tho_sep = 0;
47                         $this->dec_sep = 0;
48                         $this->language = $dflt_lang;
49                         $this->theme = 'default';
50                         
51                 } else {
52                         $this->language = $user["language"];
53                         $_SESSION['language']->set_language($this->language);
54
55                         $this->qty_dec = $user["qty_dec"];
56                         $this->price_dec = $user["prices_dec"];
57                         $this->exrate_dec = $user["rates_dec"];
58                         $this->percent_dec = $user["percent_dec"];
59
60                         $this->show_gl_info = $user["show_gl"];
61                         $this->show_codes = $user["show_codes"];
62                         $this->date_format = $user["date_format"];
63                         $this->date_sep = $user["date_sep"];
64                         $this->tho_sep = $user["tho_sep"];
65                         $this->dec_sep = $user["dec_sep"];
66                         $this->theme = $user["theme"];
67                         $this->pagesize = $user["page_size"];
68                         $this->show_hints = $user["show_hints"];
69                         $this->print_profile = $user["print_profile"];
70                         $this->rep_popup = $user["rep_popup"];
71                         $this->query_size = $user["query_size"];
72                         $this->graphic_links = $user["graphic_links"];
73                         if (isset($user["sticky_doc_date"]))
74                         {
75                                 $this->sticky_date = $user["sticky_doc_date"];
76                                 $this->startup_tab = $user['startup_tab'];
77                         }
78                         else
79                         {
80                                 $this->sticky_date = 0;
81                                 $this->startup_tab = "orders";
82                         }
83                 }
84         }
85
86         function language() 
87         {
88                 return $this->language;
89         }
90
91         function qty_dec() 
92         {
93                 return $this->qty_dec;
94         }
95
96         function price_dec() 
97         {
98                 return $this->price_dec;
99         }
100
101         function exrate_dec() 
102         {
103                 return $this->exrate_dec;
104         }
105
106         function percent_dec() 
107         {
108                 return $this->percent_dec;
109         }
110
111         function show_gl_info() 
112         {
113                 return $this->show_gl_info;
114         }
115
116         function show_codes() 
117         {
118                 return $this->show_codes;
119         }
120
121         function date_format() 
122         {
123                 return $this->date_format;
124         }
125
126         function date_sep() 
127         {
128                 return $this->date_sep;
129         }
130
131         function date_display() 
132         {
133                 global $dateseps;
134                 $sep = $dateseps[$this->date_sep];
135                 if ($this->date_format == 0)
136                         return "m".$sep."d".$sep."Y";
137                 elseif ($this->date_format == 1)
138                         return "d".$sep."m".$sep."Y";
139                 else
140                         return "Y".$sep."m".$sep."d";
141         }
142
143         function tho_sep() 
144         {
145                 return $this->tho_sep;
146         }
147
148         function dec_sep() 
149         {
150                 return $this->dec_sep;
151         }
152
153         function get_theme() 
154         {
155                 return $this->theme;
156         }
157
158         function get_pagesize() 
159         {
160                 return $this->pagesize;
161         }
162
163         function show_hints() 
164         {
165                 return $this->show_hints;
166         }
167
168         function print_profile() 
169         {
170                 return $this->print_profile;
171         }
172
173         function rep_popup() 
174         {
175                 return $this->rep_popup;
176         }
177
178         function query_size() 
179         {
180                 return $this->query_size;
181         }
182
183         function graphic_links() 
184         {
185                 return $this->graphic_links;
186         }
187         
188         function sticky_date()
189         {
190                 return $this->sticky_date;
191         }
192         
193         function start_up_tab()
194         {
195                 return $this->startup_tab;
196         }
197
198         function set_dec($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes) 
199         {
200                 $this->price_dec = $price_dec;
201                 $this->qty_dec = $qty_dec;
202                 $this->exrate_dec = $exrate_dec;
203                 $this->percent_dec = $percent_dec;
204                 $this->show_gl_info = $showgl;
205                 $this->show_codes = $showcodes;
206         }
207
208         function set_format($date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize) 
209         {
210                 $this->date_format = $date_format;
211                 $this->date_sep = $date_sep;
212                 $this->tho_sep = $tho_sep;
213                 $this->dec_sep = $dec_sep;
214                 $this->theme = $theme;
215                 $this->pagesize = $pagesize;
216         }
217
218 }
219
220 ?>