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