Bank Payment View, Bank Deposit View: fixed 'left to allocate' amount, added value...
[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                         global $path_to_root;
55                         $this->language = $user["language"];
56                         $_SESSION['language']->set_language($this->language);
57
58                         $this->qty_dec = $user["qty_dec"];
59                         $this->price_dec = $user["prices_dec"];
60                         $this->exrate_dec = $user["rates_dec"];
61                         $this->percent_dec = $user["percent_dec"];
62
63                         $this->show_gl_info = $user["show_gl"];
64                         $this->show_codes = $user["show_codes"];
65                         $this->date_format = $user["date_format"];
66                         $this->date_sep = $user["date_sep"];
67                         $this->tho_sep = $user["tho_sep"];
68                         $this->dec_sep = $user["dec_sep"];
69                         $this->theme = $user["theme"];
70                         $this->pagesize = $user["page_size"];
71                         $this->show_hints = $user["show_hints"];
72                         $this->print_profile = $user["print_profile"];
73                         $this->rep_popup = $user["rep_popup"];
74                         $this->query_size = $user["query_size"];
75                         $this->graphic_links = $user["graphic_links"];
76                         if (isset($user["sticky_doc_date"]))
77                         {
78                                 $this->sticky_date = $user["sticky_doc_date"];
79                                 $this->startup_tab = $user['startup_tab'];
80                         }
81                         else
82                         {
83                                 $this->sticky_date = 0;
84                                 $this->startup_tab = "orders";
85                         }
86                         if (!file_exists("$path_to_root/themes/$this->theme"))
87                                 $this->theme = "default";
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                 elseif ($this->date_format == 2)
170                         return "Y".$sep."m".$sep."d";
171                 elseif ($this->date_format == 3)
172                         return "M".$sep."j".$sep."Y";
173                 elseif ($this->date_format == 4)
174                         return "j".$sep."M".$sep."Y";
175                 else
176                         return "Y".$sep."M".$sep."j";
177         }
178
179         function tho_sep() 
180         {
181                 return $this->tho_sep;
182         }
183
184         function dec_sep() 
185         {
186                 return $this->dec_sep;
187         }
188
189         function get_theme() 
190         {
191                 return $this->theme;
192         }
193
194         function get_pagesize() 
195         {
196                 return $this->pagesize;
197         }
198
199         function show_hints() 
200         {
201                 return $this->show_hints;
202         }
203
204         function print_profile() 
205         {
206                 return $this->print_profile;
207         }
208
209         function rep_popup() 
210         {
211                 return $this->rep_popup;
212         }
213
214         function query_size() 
215         {
216                 return $this->query_size;
217         }
218
219         function graphic_links() 
220         {
221                 return $this->graphic_links;
222         }
223         
224         function sticky_date()
225         {
226                 return $this->sticky_date;
227         }
228         
229         function start_up_tab()
230         {
231                 return $this->startup_tab;
232         }
233
234         function set_dec($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes) 
235         {
236                 $this->price_dec = $price_dec;
237                 $this->qty_dec = $qty_dec;
238                 $this->exrate_dec = $exrate_dec;
239                 $this->percent_dec = $percent_dec;
240                 $this->show_gl_info = $showgl;
241                 $this->show_codes = $showcodes;
242         }
243
244         function set_format($date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize) 
245         {
246                 $this->date_format = $date_format;
247                 $this->date_sep = $date_sep;
248                 $this->tho_sep = $tho_sep;
249                 $this->dec_sep = $dec_sep;
250                 $this->theme = $theme;
251                 $this->pagesize = $pagesize;
252         }
253
254 }
255
256 ?>