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