noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
ajax_preference.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19// Copyright Author Dany De Bontridder danydb@aevalys.eu
20/**\file
21 * \brief this file is always included and then executed
22 * it permits to change the user preferences
23 */
24if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
25
26
27global $g_user;
28
32$action=$http->post("action","string","display_form");
33
34if (isset($_REQUEST['gDossier']) && $http->request("gDossier","number",0) != 0 )
35{
36 $g_user->load_global_pref();
37 $msg = "";
38 $cn =Dossier::connect();
39 $g_user->db = $cn;
40 $inside_dossier = true;
41 $local_pref=$g_user->get_preference();
42}
43//////////////////////////////////////////////////////////////////////////
44// Theme
45//////////////////////////////////////////////////////////////////////////
46
47 $repo = new Database();
48// charge tous les styles
49 $res = $repo->exec_sql("select the_name from theme
50 order by the_name");
51 $style = new ISelect('style_user');
52 $style->value = $repo->make_array("select the_name,the_name
53 from theme
54 order by the_name");
55 $style->selected =$_SESSION[SESSION_KEY.'g_theme'];
56
57//----------------------------------------------------------------------------------------------
58// Display the form
59//----------------------------------------------------------------------------------------------
60if ( $action == 'display_form' )
61{
62 echo HtmlInput::title_box(_('Préférence'), 'preference_div');
63 echo '<DIV class="content">';
64 echo '<p class="notice">';
65 echo _("Après validation, recharger pour appliquer les changements");
66 echo '</p>';
67 //----------------------------------------------------------------------
68 //
69?>
70
71<div class="content" >
72
73 <FORM METHOD="POST" onsubmit="updatePreference();return false;" id="preference_frm">
74 <fieldset style="margin: 1%"><legend><?php echo _('Options Générales')?></legend>
75 <table>
76 <tr>
77 <td>
78 <?php echo _('Email')?>
79 </td>
80 <td>
81 <input type="text" name="p_email" value="<?php echo $g_user->email?>" class="input_text">
82 </td>
83 </tr>
84 <tr><td>
85 Mot de passe :
86 </td>
87 <td><input type="password" value="" class="input_text" name="pass_1" id="pass_1" nohistory onkeyup=check_password_strength('pass_1','info_passid',1)>
88 <input type="password" value="" class="input_text" name="pass_2" nohistory>
89 <span id="info_passid"></span>
90 </td>
91 </tr>
92
93 <tr>
94 <td>
95 <?php echo _('Thème');?>
96 </td>
97 <td>
98 <?php echo $style->input();?>
99 </td>
100 </tr>
101
102 <?php
103 if ($inside_dossier)
104 {
105 $l_user_per = $g_user->get_periode();
106 if ($l_user_per == "")
107 $l_user_per = $cn->get_value("select min(p_id) from parm_periode where p_closed='f'");
108
109 // if periode is closed then warns the users
110 $period = new Periode($cn, $l_user_per);
111
112 $period->p_id = $l_user_per;
113 $period->jrn_def_id = 0;
114 $selected_exercice=$period->get_exercice();
115 $js=sprintf('onchange="updatePeriodePreference(%d);"',Dossier::id());
117
118 if ($period->is_closed($l_user_per) == 1)
119 {
120 $msg = _('Attention cette période est fermée, vous ne pourrez rien modifier dans le module comptable');
121 $msg = '<h2 class="notice">' . $msg . '</h2>';
122 }
123
124 $iperiod = new IPeriod("period");
125 $iperiod->id="setting_period";
126 $iperiod->user = $g_user;
127 $iperiod->cn = $cn;
128 $iperiod->filter_year = true;
129 $iperiod->exercice=$selected_exercice;
130 $iperiod->value = $l_user_per;
131 $iperiod->type = ALL;
132 $l_form_per = $iperiod->input();
133 ?>
134 <tr>
135 <td>
136 <?=_("Exercice")?>
137 </td>
138 <td>
139 <?=$exercice->select("exercice_setting",$selected_exercice,$js)->input();?>
140 </td>
141 </tr>
142
143 <tr>
144
145 <td><?php echo _('Période');?></td>
146 <td>
147 <?php printf(' %s ', $l_form_per);?>
148 </td>
149 <td> <?php echo $msg;?></td>
150 <tr>
151 <td><?php echo _('Taille des pages');?></td>
152 <td>
153 <SELECT NAME="p_size">
154 <option value="15">15
155 <option value="25">25
156 <option value="50">50
157 <option value="100">100
158 <option value="150">150
159 <option value="200">200
160 <option value="-1"><?php echo _('Illimité');?>
161 <?php
162 $label = ($_SESSION[SESSION_KEY.'g_pagesize'] == -1) ? _('Illimité') : $_SESSION[SESSION_KEY.'g_pagesize'];
163 echo '<option value="' . $_SESSION[SESSION_KEY.'g_pagesize'] . '" selected>' . $label;
164 ?>
165 </SELECT>
166
167 </td>
168 </tr>
169 <?php
170 }
171 ?>
172 <tr>
173 <td>
174 <?=_("Premier jour semaine")?>
175 </td>
176 <td>
177 <?php
178 $aFirstDay=array(
179 ["label"=>_("Lundi"),"value"=>1],
180 ["label"=>_("Mardi"),"value"=>2],
181 ["label"=>_("Mercredi"),"value"=>3],
182 ["label"=>_("Jeudi"),"value"=>4],
183 ["label"=>_("Vendredi"),"value"=>5],
184 ["label"=>_("Samedi"),"value"=>6],
185 ["label"=>_("Dimanche"),"value"=>0],
186 );
187 $selFirstDay=new ISelect("selFirstDay");
188 $selFirstDay->value=$aFirstDay;
189 $selFirstDay->selected=$g_user->get_first_week_day();
190 echo $selFirstDay->input();
191 ?>
192
193 </td>
194 </tr>
195 <tr>
196 <td>
197 <?=_('Utilisation id TVA ou code')?>
198 </td>
199 <td>
200 <?php
201 $selVATCode=new ISelect('selVATCode');
202 $selVATCode->value=array(
203 ['label'=>'numérique','value'=>0],
204 ['label'=>'Code','value'=>1]
205 );
206 $selVATCode->selected=$g_user->get_vat_code_preference();
207 echo $selVATCode->input();
208 ?>
209 </td>
210 </tr>
211 </table>
212 </fieldset>
213 <fieldset>
214 <legend><?=_("Format Export CSV")?></legend>
215 <p>
216 <?php
217 if ( $_SESSION[SESSION_KEY.'csv_fieldsep']==1 && $_SESSION[SESSION_KEY.'csv_decimal']==1)
218 {
219 echo_warning(_("N'utilisez pas le même séparateur pour les champs et les décimales"));
220 }
221 ?>
222 </p>
223 <table>
224 <tr>
225 <td>
226 <?=_("Séparateur de champs")?>
227 </td>
228 <td>
229 <?php
230 $csv_fieldsep=new ISelect('csv_fieldsep');
231 $csv_fieldsep->value=[
232 ["label"=>_("Point-virgule"),"value"=>0],
233 ["label"=>_("virgule"),"value"=>1]
234 ];
235 $csv_fieldsep->selected=$_SESSION[SESSION_KEY.'csv_fieldsep'];
236 echo $csv_fieldsep->input();
237 ?>
238 </td>
239 </tr>
240 <tr>
241 <td>
242 <?=_("Séparateur Décimale")?>
243 </td>
244 <td>
245 <?php
246 $csv_decimal=new ISelect('csv_decimal');
247 $csv_decimal->value=[
248 ["label"=>_("point"),"value"=>0],
249 ["label"=>_("virgule"),"value"=>1]
250 ];
251 $csv_decimal->selected=$_SESSION[SESSION_KEY.'csv_decimal'];
252 echo $csv_decimal->input();
253 ?>
254 </td>
255 </tr>
256 <tr>
257 <td>
258 <?=_("Encodage")?>
259 </td>
260 <td>
261 <?php
262 $csv_encoding=new ISelect('csv_encoding');
263 $csv_encoding->value=[
264 ["label"=>_("utf8"),"value"=>'utf8'],
265 ["label"=>_("latin1"),"value"=>'latin1']
266 ];
267 $csv_encoding->selected=$_SESSION[SESSION_KEY.'csv_encoding'];
268 echo $csv_encoding->input();
269 ?>
270 </td>
271 </tr>
272 </table>
273
274 </fieldset>
275 <?php
276
277 echo '<fieldset style="margin: 1%">';
278 echo '<legend>' . _('Langue') . '</legend>';
279 echo _('Selectionnez votre langue');
280 $aLang = array(array(_('Français'), 'fr_FR.utf8'),
281 array(_('Anglais'), 'en_US.utf8'),
282 array(_('Néerlandais'), 'nl_NL.utf8'),
283 );
284 echo '<select name="lang" id="l">';
285 for ($i = 0; $i < count($aLang); $i++)
286 {
287 $sel = "";
288 if ($aLang[$i][1] == $_SESSION[SESSION_KEY.'g_lang'])
289 $sel = " selected ";
290 printf('<option value="%s" %s>%s</option>', $aLang[$i][1], $sel, $aLang[$i][0]);
291 }
292 echo '</select>';
293 echo '</fieldset>';
294
295 if ($inside_dossier){
296 echo Dossier::hidden();
297 }
298 echo '<p style="text-align:center">';
299 echo HtmlInput::button_close('preference_div');
300 echo HtmlInput::submit("set_preference", _("Valider"));
301 echo '</p>';
302 echo '</form>';
303
304 echo "</DIV>";
305 ?>
306<?php
307}
308//---------------------------------------------------------------------------------------------------------------------
309// Save the form
310//---------------------------------------------------------------------------------------------------------------------
311if ($action == 'save')
312{
313 //// Save value
314 $style_user=$http->post("style_user","string","Classique");
315 $lang=$http->post("lang","string","fr_FR.utf8");
316 $p_size=$http->post("p_size","number",50);
317 $pass_1=$http->post("pass_1","string","");
318 $pass_2=$http->post("pass_2","string","");
319 $p_email=$http->post("p_email","string","");
320 $csv_fieldsep=$http->post("csv_fieldsep","number");
321 $csv_decimal=$http->post("csv_decimal","number");
322 $csv_encoding=$http->post("csv_encoding");
323 $firstday=$http->post("selFirstDay","number");
324 $vatCode=$http->post("selVATCode","number");
325 $password="OK";
326 $msg ="";
327 if (noalyss_strlentrim($pass_1) != 0 && noalyss_strlentrim($pass_2) != 0)
328 {
329 if ( $g_user->save_password($_POST['pass_1'],$pass_2) )
330 {
331 $g_user->password_to_session() ;
332
333 } else {
334 /**
335 * password not changed
336 */
337 $password="NOK";
338 $msg="";
339 if ( $_POST['pass_1'] !== $pass_2) {
340 $msg = _("Mot de passe ne correspondent pas");
341 $msg .="<br/>";
342 }
343 $a_pass_error=check_password_strength($_POST['pass_1']);
344 if ( count($a_pass_error['msg']) != 0 ) {
345 foreach($a_pass_error['msg'] as $pass_error) {
346 $msg.=$pass_error."<br/>";
347 }
348 }
349
350 }
351 }
352 if ( $inside_dossier)
353 {
354 $period=$http->post("period","number");
355 $g_user->set_periode($period);
356 }
357 $g_user->save_global_preference('THEME', $style_user);
358 $g_user->save_global_preference('LANG', $lang);
359 $g_user->save_global_preference('PAGESIZE', $p_size);
360 $g_user->save_global_preference('csv_fieldsep', $csv_fieldsep);
361 $g_user->save_global_preference('csv_decimal', $csv_decimal);
362 $g_user->save_global_preference('csv_encoding', $csv_encoding);
363 $g_user->save_global_preference('first_week_day', $firstday);
364 $g_user->save_global_preference('vat_code', $vatCode);
365 $g_user->save_email($p_email);
366
367 $_SESSION[SESSION_KEY.'g_theme']=$style_user;
368 $_SESSION[SESSION_KEY.'g_pagesize']=$p_size;
369 $_SESSION[SESSION_KEY.'g_lang']=$lang;
370 $_SESSION[SESSION_KEY.'csv_fieldsep']=$csv_fieldsep;
371 $_SESSION[SESSION_KEY.'csv_decimal']=$csv_decimal;
372 $_SESSION[SESSION_KEY.'csv_encoding']=$csv_encoding;
373
374 // find the right CSS theme
375 $style= $repo->get_value("select the_filestyle from theme
376 where the_name=$1" ,[$style_user]);
377 if ($style == "")
378 {
379 $style = "style-classic7.css";
380 }
381 json_response(["style"=>$style,'psw'=>$password,'msg'=>$msg]);
382
383}
span($p_string, $p_extra='')
Definition ac_common.php:43
noalyss_strlentrim($p_string)
echo_warning($p_string)
warns
check_password_strength($password)
returns an double array with the error found and code , if the count is 0 then the password is very s...
tr($p_string, $p_extra='')
Definition ac_common.php:88
p($p_string)
Definition ac_common.php:39
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
global $g_user
if no group available , then stop
catch(Exception $e) $exercice
$opd_description style
$inside_dossier
if(isset($_REQUEST['gDossier']) && $http->request("gDossier","number", 0) !=0) $repo
$_REQUEST['ac']
$from_poste name
_("actif, passif,charge,...")
$input_from type
contains the class for connecting to Noalyss
about the accountancy period (usually 1 year starting in January until december) = exercice
manage the http input (get , post, request) and extract from an array
Generate the form for the periode Data Members.
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Data & function about connected users.
$all table
const ALL
Definition constant.php:204
$_POST['ac']
Definition do.php:312
if(! $cn->exist_table( 'version')) if($g_user->get_access_mode()=='MOBILE') $style_user
if access_mode is MOBILE than force it to mobile.php
Definition do.php:85
json_response($p_answer)
Send header and json object.