3 include_once($path_to_root . "/includes/prefs/userprefs.inc");
5 //--------------------------------------------------------------------------
20 function current_user()
22 $this->loginname = $username = $this->name = $this->company = "";
23 $this->logged = false;
33 function set_company($company)
35 $this->company = $company;
38 function login($company, $loginname, $password)
40 $this->set_company($company);
42 $Auth_Result = get_user_for_login($loginname, $password);
44 if (db_num_rows($Auth_Result) > 0)
46 $myrow = db_fetch($Auth_Result);
48 $this->access = $myrow["full_access"];
49 $this->name = $myrow["real_name"];
50 $this->loginname = $loginname;
51 $this->username = $this->loginname;
52 $this->prefs = new user_prefs($myrow);
54 update_user_visitdate($loginname);
59 $this->logged = false;
65 function check_user_access()
67 global $security_groups;
68 return is_array($security_groups[$this->access]);
71 function can_access_page($page_level)
73 global $security_groups;
74 return isset($page_level) && in_array($page_level, $security_groups[$this->access]);
77 function get_db_connection()
79 global $db_connections;
81 $connection = $db_connections[$this->company];
83 //print_r($connection);
85 $db = mysql_connect($connection["host"] ,
86 $connection["dbuser"], $connection["dbpassword"]);
87 mysql_select_db($connection["dbname"],$db);
89 if (!defined('TB_PREF'))
90 define('TB_PREF', $connection["tbpref"]);
95 function update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes,
96 $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize) {
97 update_user_display_prefs($this->username, $price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl,
98 $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize);
101 $user = get_user($this->username);
102 $this->prefs = new user_prefs($user);
106 //--------------------------------------------------------------------------
108 function number_format2($number, $decimals=0)
110 global $thoseps, $decseps;
111 $tsep = $thoseps[$_SESSION["wa_current_user"]->prefs->tho_sep()];
112 $dsep = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()];
113 return number_format($number, $decimals, $dsep, $tsep);
116 function price_format($number) {
117 return number_format2($number,
118 $_SESSION["wa_current_user"]->prefs->price_dec());
121 function qty_format($number) {
122 return number_format2($number,
123 $_SESSION["wa_current_user"]->prefs->qty_dec());
126 function exrate_format($number) {
127 return number_format2($number,
128 $_SESSION["wa_current_user"]->prefs->exrate_dec());
131 function percent_format($number) {
132 return number_format2($number,
133 $_SESSION["wa_current_user"]->prefs->percent_dec());
136 function user_numeric($input) {
137 global $decseps, $thoseps;
140 $sep = $thoseps[user_tho_sep()];
141 if($sep!='') $num = str_replace( $sep, '', $num);
142 str_replace($sep, '', $num);
143 $sep = $decseps[user_dec_sep()];
144 if($sep!='.') $num = str_replace( $sep, '.', $num);
146 if (!is_numeric($num))
149 if ($num == (int)$num)
155 function user_company()
157 return $_SESSION["wa_current_user"]->company;
160 function user_language()
162 return $_SESSION["wa_current_user"]->prefs->language();
165 function user_qty_dec()
167 return $_SESSION["wa_current_user"]->prefs->qty_dec();
170 function user_price_dec()
172 return $_SESSION["wa_current_user"]->prefs->price_dec();
175 function user_exrate_dec()
177 return $_SESSION["wa_current_user"]->prefs->exrate_dec();
180 function user_percent_dec()
182 return $_SESSION["wa_current_user"]->prefs->percent_dec();
185 function user_show_gl_info()
187 return $_SESSION["wa_current_user"]->prefs->show_gl_info();
190 function user_show_codes()
192 return $_SESSION["wa_current_user"]->prefs->show_codes();
195 function user_date_format()
197 return $_SESSION["wa_current_user"]->prefs->date_format();
200 function user_date_display()
202 return $_SESSION["wa_current_user"]->prefs->date_display();
205 function user_date_sep()
207 return $_SESSION["wa_current_user"]->prefs->date_sep();
210 function user_tho_sep()
212 return $_SESSION["wa_current_user"]->prefs->tho_sep();
215 function user_dec_sep()
217 return $_SESSION["wa_current_user"]->prefs->dec_sep();
220 function user_theme()
222 return $_SESSION["wa_current_user"]->prefs->get_theme();
225 function user_pagesize()
227 return $_SESSION["wa_current_user"]->prefs->get_pagesize();
230 function set_user_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes,
231 $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize)
234 $_SESSION["wa_current_user"]->update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes,
235 $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize);
238 //--------------------------------------------------------------------------