863dc1fab05f8a74a8583aef68e9e4a8ddba3bf6
[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         var $save_report_selection; // save report selections days 0...
40         var $use_date_picker; // use date picker for all date fields
41         var $def_print_destination; // default print destination. 0 = PDF/Printer, 1 = Excel
42         var $def_print_orientation; // default print orientation. 0 = Portrait. 1 = Landscape
43
44         function __construct($user=null)
45         {
46                 if ($user == null) { 
47                         // set default values, used before login
48                         global $dflt_lang, $SysPrefs;
49
50                         $this->date_sep = $SysPrefs->dflt_date_sep;
51                         $this->date_format = $SysPrefs->dflt_date_fmt;
52                         $this->tho_sep = 0;
53                         $this->dec_sep = 0;
54                         $this->price_dec = 2;
55                         $this->language = $dflt_lang;
56                         $this->theme = 'default';
57                         $this->transaction_days = -30;
58                         $this->save_report_selections = 0;
59                         $this->use_date_picker = 1;
60                         $this->def_print_destination = 0;
61                         $this->def_print_orientation = 0;
62
63                 } else {
64                         global $path_to_root;
65                         $this->language = $user["language"];
66                         $_SESSION['language']->set_language($this->language);
67
68                         $this->qty_dec = $user["qty_dec"];
69                         $this->price_dec = $user["prices_dec"];
70                         $this->exrate_dec = $user["rates_dec"];
71                         $this->percent_dec = $user["percent_dec"];
72
73                         $this->show_gl_info = $user["show_gl"];
74                         $this->show_codes = $user["show_codes"];
75                         $this->date_format = $user["date_format"];
76                         $this->date_sep = $user["date_sep"];
77                         $this->tho_sep = $user["tho_sep"];
78                         $this->dec_sep = $user["dec_sep"];
79                         $this->theme = $user["theme"];
80                         $this->pagesize = $user["page_size"];
81                         $this->show_hints = $user["show_hints"];
82                         $this->print_profile = $user["print_profile"];
83                         $this->rep_popup = $user["rep_popup"];
84                         $this->query_size = $user["query_size"];
85                         $this->graphic_links = $user["graphic_links"];
86                         if (isset($user["sticky_doc_date"]))
87                         {
88                                 $this->sticky_date = $user["sticky_doc_date"];
89                                 $this->startup_tab = $user['startup_tab'];
90                         }
91                         else
92                         {
93                                 $this->sticky_date = 0;
94                                 $this->startup_tab = "orders";
95                         }
96                         $this->transaction_days = @$user['transaction_days'];
97                         $this->save_report_selections = @$user['save_report_selections'];
98                         $this->use_date_picker = @$user['use_date_picker'];
99                         $this->def_print_destination = @$user['def_print_destination'];
100                         $this->def_print_orientation = @$user['def_print_orientation'];
101
102                         if (!file_exists("$path_to_root/themes/$this->theme"))
103                                 $this->theme = "default";
104                 }
105         }
106         
107         function get_all()
108         {
109                         return array(
110                         'language' => $this->language,
111                         'qty_dec' => $this->qty_dec,
112                         'prices_dec' => $this->price_dec,
113                         'rates_dec' => $this->exrate_dec,
114                         'percent_dec' => $this->percent_dec,
115                         'show_gl' => $this->show_gl_info,
116                         'show_codes' => $this->show_codes,
117                         'date_format' =>$this->date_format,
118                         'date_sep' => $this->date_sep,
119                         'tho_sep' => $this->tho_sep,
120                         'dec_sep' => $this->dec_sep,
121                         'theme' => $this->theme,
122                         'page_size' => $this->pagesize,
123                         'show_hints' => $this->show_hints,
124                         'print_profile' => $this->print_profile,
125                         'rep_popup' => $this->rep_popup,
126                         'query_size' => $this->query_size,
127                         'graphic_links' => $this->graphic_links,
128                         'sticky_doc_date' => $this->sticky_date,
129                         'startup_tab' => $this->startup_tab,
130                         'save_report_selections' => $this->save_report_selections,
131                         'use_date_picker' => $this->use_date_picker,
132                         'def_print_destination' => $this->def_print_destination,
133                         'def_print_orientation' => $this->def_print_orientation);
134         }
135         
136         function language() 
137         {
138                 return $this->language;
139         }
140
141         function qty_dec() 
142         {
143                 return $this->qty_dec;
144         }
145
146         function price_dec() 
147         {
148                 return $this->price_dec;
149         }
150
151         function exrate_dec() 
152         {
153                 return $this->exrate_dec;
154         }
155
156         function percent_dec() 
157         {
158                 return $this->percent_dec;
159         }
160
161         function show_gl_info() 
162         {
163                 return $this->show_gl_info;
164         }
165
166         function show_codes() 
167         {
168                 return $this->show_codes;
169         }
170
171         function date_format() 
172         {
173                 return $this->date_format;
174         }
175
176         function date_sep() 
177         {
178                 return $this->date_sep;
179         }
180
181         function date_display() 
182         {
183                 global $SysPrefs;
184                 $sep = $SysPrefs->dateseps[$this->date_sep];
185                 if ($this->date_format == 0)
186                         return "m".$sep."d".$sep."Y";
187                 elseif ($this->date_format == 1)
188                         return "d".$sep."m".$sep."Y";
189                 elseif ($this->date_format == 2)
190                         return "Y".$sep."m".$sep."d";
191                 elseif ($this->date_format == 3)
192                         return "M".$sep."j".$sep."Y";
193                 elseif ($this->date_format == 4)
194                         return "j".$sep."M".$sep."Y";
195                 else
196                         return "Y".$sep."M".$sep."j";
197         }
198
199         function tho_sep() 
200         {
201                 return $this->tho_sep;
202         }
203
204         function dec_sep() 
205         {
206                 return $this->dec_sep;
207         }
208
209         function get_theme() 
210         {
211                 return $this->theme;
212         }
213
214         function get_pagesize() 
215         {
216                 return $this->pagesize;
217         }
218
219         function show_hints() 
220         {
221                 return $this->show_hints;
222         }
223
224         function print_profile() 
225         {
226                 return $this->print_profile;
227         }
228
229         function rep_popup() 
230         {
231                 return $this->rep_popup;
232         }
233
234         function query_size() 
235         {
236                 return $this->query_size;
237         }
238
239         function graphic_links() 
240         {
241                 return $this->graphic_links;
242         }
243         
244         function sticky_date()
245         {
246                 return $this->sticky_date;
247         }
248         
249         function start_up_tab()
250         {
251                 return $this->startup_tab;
252         }
253
254     function transaction_days() 
255     {
256         return $this->transaction_days;
257     }
258
259     function save_report_selections() 
260     {
261         return $this->save_report_selections;
262     }
263
264     function use_date_picker() 
265     {
266         return $this->use_date_picker;
267     }
268
269     function def_print_destination() 
270     {
271         return $this->def_print_destination;
272     }
273
274     function def_print_orientation() 
275     {
276         return $this->def_print_orientation;
277     }
278
279         function set_dec($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes) 
280         {
281                 $this->price_dec = $price_dec;
282                 $this->qty_dec = $qty_dec;
283                 $this->exrate_dec = $exrate_dec;
284                 $this->percent_dec = $percent_dec;
285                 $this->show_gl_info = $showgl;
286                 $this->show_codes = $showcodes;
287         }
288
289         function set_format($date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize) 
290         {
291                 $this->date_format = $date_format;
292                 $this->date_sep = $date_sep;
293                 $this->tho_sep = $tho_sep;
294                 $this->dec_sep = $dec_sep;
295                 $this->theme = $theme;
296                 $this->pagesize = $pagesize;
297         }
298
299 }
300