noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
do.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
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21define('ALLOWED',1);
22/**\file
23 * \brief Main file
24 */
25require_once '../include/constant.php';
26require_once NOALYSS_INCLUDE.'/constant.security.php';
27require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
28
29MaintenanceMode("block.html");
30
31require_once NOALYSS_INCLUDE.'/class/database.class.php';
32require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
33require_once NOALYSS_INCLUDE.'/lib/user_common.php';
34require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
35require_once NOALYSS_INCLUDE.'/lib/html_input.class.php';
36require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
37require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php';
39
40mb_internal_encoding("UTF-8");
41// if gDossier is not set redirect to form to choose a folder
42if ( ! isset($_REQUEST['gDossier']))
43{
44 redirect_header('user_login.php');
45 exit();
46}
47if ( ! isset ($_SESSION[SESSION_KEY.'g_user']))
48 {
49 echo "<h2>"._('Vous êtes déconnecté')."</h2>";
50 $backurl=$_SERVER['REQUEST_URI'];
51 $url="index.php?".http_build_query(array('reconnect'=>1,'backurl'=>urlencode($backurl)));
52 redirect($url);
53 exit();
54
55 }
56$cn = Dossier::connect();
57
59$g_user = new Noalyss_user($cn);
60$http=new HttpInput();
61
62IDate::set_firstDate($g_user->get_first_week_day());
63ITva_Popup::set_vat_code($g_user->get_vat_code_preference());
64
65/*
66 * check that the database is not empty
67 */
68if ( ! $cn->exist_table('version')) {
69 echo '<h2 class="notice">'._('Désolé').'</h2>';
70 echo _('Ce dossier est vide');
71 echo '<p>';
72 echo '<a class="button" href="do.php">'._("Retour à l'accueil").'</a>';
73 echo '</p>';
74 return;
75}
76
77/**
78 * if access_mode is MOBILE than force it to mobile.php
79 */
80if ($g_user->get_access_mode()=='MOBILE') { require NOALYSS_HOME."/mobile.php"; return;}
81
82$style_user=$http->post("style_user","string",$_SESSION[SESSION_KEY.'g_theme']);
83
85
86// check that the current user is saved into PostgreSQL setting in order to use it in PLPGSQL
87\Noalyss\Dbg::echo_var(1,sprintf("current user is [%s]",$cn->get_value("select current_setting('noalyss.user_login')")));
88
89if ( DEBUGNOALYSS > 1 ) {
90 /**
91 * Debug Design
92 */
96} //<--- if DEBUG
98
99$g_user->Check();
100if ( ! $g_user->is_double_identified()) {
101 echo "<h2>"._('Vous êtes déconnecté')."</h2>";
102 $backurl=$_SERVER['REQUEST_URI'];
103 $url="index.php?".http_build_query(array('reconnect'=>1,'backurl'=>urlencode($backurl)));
104 redirect($url);
105 exit();
106}
107$g_user->check_dossier(Dossier::id());
109/* Check Browser version if < IE6 then unsupported */
110$browser = $_SERVER['HTTP_USER_AGENT'];
111if (strpos($browser, 'MSIE 6') != false ||
112 strpos($browser, 'MSIE 5') != false)
113{
114
115
116 echo <<<EOF
117 <!--[if lt IE 7]>
118 <div style='border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;'>
119 <div style='position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;'><a href='#' onclick='javascript:this.parentNode.parentNode.style.display="none"; return false;'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg' style='border: none;' alt='Close this notice'/></a></div>
120 <div style='width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;'>
121 <div style='width: 75px; float: left;'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg' alt='Warning!'/></div>
122 <div style='width: 275px; float: left; font-family: Arial, sans-serif;'>
123 <div style='font-size: 14px; font-weight: bold; margin-top: 12px;'>Vous utilisez un navigateur dépassé depuis près de 8 ans!</div>
124 <div style='font-size: 12px; margin-top: 6px; line-height: 12px;'>Pour une meilleure expérience web, prenez le temps de mettre votre navigateur à jour.</div>
125 </div>
126 <div style='width: 75px; float: left;'><a href='http://fr.www.mozilla.com/fr/' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg' style='border: none;' alt='Get Firefox 3.5'/></a></div>
127 <div style='width: 73px; float: left;'><a href='http://www.apple.com/fr/safari/download/' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg' style='border: none;' alt='Get Safari 4'/></a></div>
128 <div style='float: left;'><a href='http://www.google.com/chrome?hl=fr' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg' style='border: none;' alt='Get Google Chrome'/></a></div>
129 </div>
130 </div>
131 <![endif]-->
132EOF;
133 exit();
134}
135if ($cn->exist_table('version') == false)
136{
137 echo '<h2 class="error" style="font-size:12px">' . _("Base de donnée invalide") . '</h2>';
138 $base = dirname($_SERVER['REQUEST_URI']);
139 echo HtmlInput::button_anchor('Retour', $base . '/user_login.php');
140 exit();
141}
142if (DBVERSION < dossier::get_version($cn))
143{
144 $a = _("cliquez ici pour mettre à jour ");
145 $base =NOALYSS_URL."/admin-noalyss.php?action=upgrade&sb=application";
146
147 echo '<h2 class="error" style="font-size:12px">' .
148 _("Attention: la version de base de donnée est supérieure à la version du programme, vous devriez mettre à jour") ,
149 '<a class="text-warning line" hreF="' . $base . '">' . $a . '</a></h2>',
150 '</h2>';
151}
152if (DBVERSION > dossier::get_version($cn))
153{
154 echo '<h2 class="error" style="font-size:12px">' . _("Votre base de données n'est pas à jour") . ' ';
155 $a = _("cliquez ici pour appliquer le patch");
156 $base =NOALYSS_URL.'/admin-noalyss.php?action=upgrade&sb=database';
157 echo '<a class="text-warning line" href="' . $base . '">' . $a . '</a></h2>';
158}
159
160/*
161 * Set a correct periode for the user
162 */
163$periode = $g_user->get_periode();
164$oPeriode = new Periode($cn, $periode);
165
166if ($oPeriode->load() == -1)
167{
168 $periode = $cn->get_value('select p_id from parm_periode order by p_start asc limit 1');
169 $g_user->set_periode($periode);
170}
171
173
174?>
175<script>
176/**
177 * All the onload must be here otherwise the other will overwritten
178 * @returns {undefined}
179 */
180window.onload=function ()
181{
182 create_anchor_up();
183 init_scroll();
184
185 sorttable.init
186}
187
188</script>
189<?php
190
191/*
192 * if an action is requested
193 */
194if (isset($_REQUEST['ac']))
195{
196 // When debugging save all the input in a file
197 if ( LOGINPUT)
198 {
199 $file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
200 $tmp_ac=explode('/',trim(strtoupper($_REQUEST['ac'])));
201 $last=count($tmp_ac);
202 if ($last > 0) $last--;
203 fwrite ($file_loginput,"<?php \n");
204 fwrite ($file_loginput,'//@description:'.$tmp_ac[$last]."\n");
205 fwrite($file_loginput, '$_GET='.var_export($_GET,true));
206 fwrite($file_loginput,";\n");
207 fwrite($file_loginput, '$_POST='.var_export($_POST,true));
208 fwrite($file_loginput,";\n");
209 fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
210 fwrite($file_loginput,"\n");
211 fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
212 fwrite($file_loginput,"\n");
213 fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
214 fwrite($file_loginput,"\n");
215 fclose($file_loginput);
216 }
217
218 // Priority to POST , otherwise "duplicate operation" doesn't work
219 $ac_post = trim(strtoupper($http->post("ac","string","")));
220 $ac_get = trim(strtoupper($http->get("ac","string","")));
221
222 $AC=($ac_post == "")?$ac_get:$ac_post;
223 $user_profile=$g_user->get_profile();
224
225
226 $amenu_id=$cn->get_array('select
227 pm_id_v3,pm_id_v2,pm_id_v1
228 from v_menu_profile where code= upper($1) and p_id=$2',
229 array($AC,$user_profile));
230
231 try {
232 if (count($amenu_id) == 0 ) {
233 // if only an Access Direct is asked without the full path
234
235 $aAccess=[];
236 // Find the possible path pm_id_v3 / pm_id_v2 / pm_id_v1
237 $direct_ac=$cn->get_array("select me_file,me_parameter,me_javascript from profile_menu
238 join menu_ref using (me_code)
239 where
240 p_id=$2
241 and me_code=$1", [strtoupper($AC),$user_profile]);
242
243 // if the me_code is available for user, find all the possible path
244 if (!empty($direct_ac)) {
245 $aAccess=$cn->get_array("select code, me_code from v_menu_description where me_code=$1 and p_id=$2",
246 [strtoupper($AC),$user_profile]);
247 }
248
249 if (empty($aAccess)) {
250 throw new Exception(_('Erreur menu'),10);
251 }
252
253 // retrieve the element path
254 $amenu_id=$cn->get_array('select
255 pm_id_v3,pm_id_v2,pm_id_v1
256 from v_menu_profile
257 where code= upper($1) and p_id=$2',
258 array($aAccess[0]['code'],$user_profile));
259
260 }
261 if ( count($amenu_id)> 1) {
262 $tmp=$amenu_id[0];
263 $amenu_id=[];
264 $amenu_id[0]=$tmp;
265 }
266 $amenu_id=complete_default_menu($amenu_id,$user_profile);
267
268 $AC=rebuild_access_code($amenu_id);
269
270 put_global(array(array("key"=>"ac","value"=>$AC)));
271 $module_id=$cn->get_value('select distinct
272 case when pm_id_v3 = 0 then (case when pm_id_v2 = 0 then pm_id_v1 else pm_id_v2 end) else pm_id_v3 end
273 from
274 v_menu_profile
275 where p_id =$1
276 and upper(code)=upper($2)',
277 array($user_profile,$AC));
278 $g_user->audit();
279 // Show module and highligt selected one
280 show_module($module_id);
281
282 global $level;
283 $level = 0;
284 show_menu( $amenu_id[0]['pm_id_v3']);
285
286 show_menu( $amenu_id[0]['pm_id_v2']);
287
288 show_menu($amenu_id[0]['pm_id_v1']);
289
290
291 } catch (Exception $e) {
292 if ( $e->getCode() == 10 ) {
293 alert(_('Accès menu impossible'));
294 echo '<a class="button" href="do.php?'.Dossier::get().'">';
295 echo _('Retour');
296 echo '</a>';
297 return;
298 }
299 else {
300 alert($e->getMessage());
301 record_log($e);
302 throw $e;
303 }
304 }
305}
306else
307{
308 $default = find_default_module();
309 $user_profile=$g_user->get_profile();
310
311 try
312 {
313 if ( $user_profile == "" )
314 throw new Exception (_('Aucun profil utilisateur'));
315
316 $menu_id=$cn->get_value('select
317 case when pm_id_v3 = 0 then
318 (case when pm_id_v2 = 0 then pm_id_v1 else pm_id_v2 end)
319 else pm_id_v3 end
320 from v_menu_profile where code= upper($1) and p_id=$2',
321 array($default,$user_profile));
322 $_GET['ac']=$default;
323 $_POST['ac']=$default;
324 $_REQUEST['ac']=$default;
326 $all[0] = $default;
328 }
329 catch (Exception $exc)
330 {
331 echo $exc->getMessage();
332 record_log("No user profile ");
333 record_log($exc);
334 throw $exc;
335 }
336
337}
338
339
complete_default_menu($pa_menu)
Check if there is a default menu for this user and add it.
MaintenanceMode($p_file)
When you want to prevent users to connect, create a file in noalyss/ (NOALYSS_BASE) with the message ...
put_global($array)
Put in superglobal (get,post,request) the value contained in the parameter field (me_parameter)
html_page_start($p_theme="", $p_script="", $p_script2="")
Default page header for each page.
rebuild_access_code($pan_code)
rebuild the access code
find_default_module()
show_module($selected)
Show the modules.
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
show_menu($module)
show the module
alert($p_msg, $buffer=false)
alert in javascript
global $g_parameter
global $g_user
if no group available , then stop
$base
$opd_description style
$_REQUEST['ac']
if(! empty( $error)) for($i=0;$i< count($error);$i++)( $last !=$error[$i]) $last
_("actif, passif,charge,...")
$_GET['qcode']
static button_anchor($p_label, $p_value, $p_name="", $p_javascript="", $p_class="smallbutton")
create a button with a ref
manage the http input (get , post, request) and extract from an array
static set_firstDate($firstDate)
static set_vat_code(int $vat_code)
show the Numeric ID or the code
static echo_var($n_level, $msg, $print=true)
Display the value of a var if DEBUGNOALYSS is greater than $n_level, the debugging info has a certain...
Definition dbg.php:45
static display_global()
for development , show GLOBAL and SESSION
Definition dbg.php:148
static display_request()
for development , show request (POST, GET)
Definition dbg.php:119
static display_size()
display a bar depending of the size of the screen , it helps for CSS to see the media-size
Definition dbg.php:104
Class to manage the company parameter (address, name...)
const DBVERSION
Definition constant.php:31
$menu_id
Definition do.php:316
$_POST['ac']
Definition do.php:323
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:82
$user_profile
Definition do.php:309
$oPeriode
Definition do.php:164
if($oPeriode->load()==-1) $module_selected
Definition do.php:172
$browser
Definition do.php:110
for($e=0; $e< count($afiche); $e++) exit
load_all_script()
load all the javascript only one time
redirect_header($p_string)
redirect with header,
redirect( $p_string, $p_time=0)
redirect with javascript