noalyss Version-9
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('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// check that the current user is saved into PostgreSQL setting in order to use it in PLPGSQL
66\Noalyss\Dbg::echo_var(1,sprintf("current user is [%s]",$cn->get_value("select current_setting('noalyss.user_login')")));
67
68/*
69 * check that the database is not empty
70 */
71if ( ! $cn->exist_table('version')) {
72 echo '<h2 class="notice">'._('Désolé').'</h2>';
73 echo _('Ce dossier est vide');
74 echo '<p>';
75 echo '<a class="button" href="do.php">'._("Retour à l'accueil").'</a>';
76 echo '</p>';
77 return;
78}
79
80/**
81 * if access_mode is MOBILE than force it to mobile.php
82 */
83if ($g_user->get_access_mode()=='MOBILE') { require NOALYSS_HOME."/mobile.php"; return;}
84
85$style_user=$http->post("style_user","string",$_SESSION[SESSION_KEY.'g_theme']);
86
88if ( DEBUGNOALYSS > 1 ) {
89 /**
90 * Debug Design
91 */
95} //<--- if DEBUG
97
98$g_user->Check();
99$g_user->check_dossier(Dossier::id());
101/* Check Browser version if < IE6 then unsupported */
102$browser = $_SERVER['HTTP_USER_AGENT'];
103if (strpos($browser, 'MSIE 6') != false ||
104 strpos($browser, 'MSIE 5') != false)
105{
106
107
108 echo <<<EOF
109 <!--[if lt IE 7]>
110 <div style='border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;'>
111 <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>
112 <div style='width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;'>
113 <div style='width: 75px; float: left;'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg' alt='Warning!'/></div>
114 <div style='width: 275px; float: left; font-family: Arial, sans-serif;'>
115 <div style='font-size: 14px; font-weight: bold; margin-top: 12px;'>Vous utilisez un navigateur dépassé depuis près de 8 ans!</div>
116 <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>
117 </div>
118 <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>
119 <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>
120 <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>
121 </div>
122 </div>
123 <![endif]-->
124EOF;
125 exit();
126}
127if ($cn->exist_table('version') == false)
128{
129 echo '<h2 class="error" style="font-size:12px">' . _("Base de donnée invalide") . '</h2>';
130 $base = dirname($_SERVER['REQUEST_URI']);
131 echo HtmlInput::button_anchor('Retour', $base . '/user_login.php');
132 exit();
133}
134if (DBVERSION < dossier::get_version($cn))
135{
136 $a = _("cliquez ici pour mettre à jour ");
137 $base =NOALYSS_URL."/admin-noalyss.php?action=upgrade&sb=application";
138
139 echo '<h2 class="error" style="font-size:12px">' .
140 _("Attention: la version de base de donnée est supérieure à la version du programme, vous devriez mettre à jour") ,
141 '<a class="text-warning line" hreF="' . $base . '">' . $a . '</a></h2>',
142 '</h2>';
143}
144if (DBVERSION > dossier::get_version($cn))
145{
146 echo '<h2 class="error" style="font-size:12px">' . _("Votre base de données n'est pas à jour") . ' ';
147 $a = _("cliquez ici pour appliquer le patch");
148 $base =NOALYSS_URL.'/admin-noalyss.php?action=upgrade&sb=database';
149 echo '<a class="text-warning line" href="' . $base . '">' . $a . '</a></h2>';
150}
151
152/*
153 * Set a correct periode for the user
154 */
155$periode = $g_user->get_periode();
156$oPeriode = new Periode($cn, $periode);
157
158if ($oPeriode->load() == -1)
159{
160 $periode = $cn->get_value('select p_id from parm_periode order by p_start asc limit 1');
161 $g_user->set_periode($periode);
162}
163
165
166?>
167<script>
168/**
169 * All the onload must be here otherwise the other will overwritten
170 * @returns {undefined}
171 */
172window.onload=function ()
173{
174 create_anchor_up();
175 init_scroll();
176 sorttable.init
177}
178</script>
179<?php
180
181/*
182 * if an action is requested
183 */
184if (isset($_REQUEST['ac']))
185{
186 // When debugging save all the input in a file
187 if ( LOGINPUT)
188 {
189 $file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
190 $tmp_ac=explode('/',trim(strtoupper($_REQUEST['ac'])));
191 $last=count($tmp_ac);
192 if ($last > 0) $last--;
193 fwrite ($file_loginput,"<?php \n");
194 fwrite ($file_loginput,'//@description:'.$tmp_ac[$last]."\n");
195 fwrite($file_loginput, '$_GET='.var_export($_GET,true));
196 fwrite($file_loginput,";\n");
197 fwrite($file_loginput, '$_POST='.var_export($_POST,true));
198 fwrite($file_loginput,";\n");
199 fwrite($file_loginput, '$_POST[\'gDossier\']=$gDossierLogInput;');
200 fwrite($file_loginput,"\n");
201 fwrite($file_loginput, '$_GET[\'gDossier\']=$gDossierLogInput;');
202 fwrite($file_loginput,"\n");
203 fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);');
204 fwrite($file_loginput,"\n");
205 fclose($file_loginput);
206 }
207
208 // Priority to POST , otherwise "duplicate operation" doesn't work
209 $ac_post = trim(strtoupper($http->post("ac","string","")));
210 $ac_get = trim(strtoupper($http->get("ac","string","")));
211
212 $AC=($ac_post == "")?$ac_get:$ac_post;
213 $user_profile=$g_user->get_profile();
214
215
216 $amenu_id=$cn->get_array('select
217 pm_id_v3,pm_id_v2,pm_id_v1
218 from v_menu_profile where code= upper($1) and p_id=$2',
219 array($AC,$user_profile));
220
221 try {
222 if (count($amenu_id) == 0 ) {
223 // if only an Access Direct is asked without the full path
224
225 $aAccess=[];
226 // Find the possible path pm_id_v3 / pm_id_v2 / pm_id_v1
227 $direct_ac=$cn->get_array("select me_file,me_parameter,me_javascript from profile_menu
228 join menu_ref using (me_code)
229 where
230 p_id=$2
231 and me_code=$1", [strtoupper($AC),$user_profile]);
232
233 // if the me_code is available for user, find all the possible path
234 if (!empty($direct_ac)) {
235 $aAccess=$cn->get_array("select code, me_code from v_menu_description where me_code=$1 and p_id=$2",
236 [strtoupper($AC),$user_profile]);
237 }
238
239 if (empty($aAccess)) {
240 throw new Exception(_('Erreur menu'),10);
241 }
242
243 // retrieve the element path
244 $amenu_id=$cn->get_array('select
245 pm_id_v3,pm_id_v2,pm_id_v1
246 from v_menu_profile
247 where code= upper($1) and p_id=$2',
248 array($aAccess[0]['code'],$user_profile));
249
250 }
251 if ( count($amenu_id)> 1) {
252 $tmp=$amenu_id[0];
253 $amenu_id=[];
254 $amenu_id[0]=$tmp;
255 }
256 $amenu_id=complete_default_menu($amenu_id,$user_profile);
257
258 $AC=rebuild_access_code($amenu_id);
259
260 put_global(array(array("key"=>"ac","value"=>$AC)));
261 $module_id=$cn->get_value('select distinct
262 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
263 from
264 v_menu_profile
265 where p_id =$1
266 and upper(code)=upper($2)',
267 array($user_profile,$AC));
268 $g_user->audit();
269 // Show module and highligt selected one
270 show_module($module_id);
271
272
273 show_menu( $amenu_id[0]['pm_id_v3']);
274
275 show_menu( $amenu_id[0]['pm_id_v2']);
276
277 show_menu($amenu_id[0]['pm_id_v1']);
278
279
280 } catch (Exception $e) {
281 if ( $e->getCode() == 10 ) {
282 alert(_('Accès menu impossible'));
283 echo '<a class="button" href="do.php?'.Dossier::get().'">';
284 echo _('Retour');
285 echo '</a>';
286 return;
287 }
288 else {
289 alert($e->getMessage());
290 record_log($e->getTraceAsString());
291 throw $e;
292 }
293 }
294}
295else
296{
297 $default = find_default_module();
298 $user_profile=$g_user->get_profile();
299
300 try
301 {
302 if ( $user_profile == "" )
303 throw new Exception (_('Aucun profil utilisateur'));
304
305 $menu_id=$cn->get_value('select
306 case when pm_id_v3 = 0 then
307 (case when pm_id_v2 = 0 then pm_id_v1 else pm_id_v2 end)
308 else pm_id_v3 end
309 from v_menu_profile where code= upper($1) and p_id=$2',
310 array($default,$user_profile));
311 $_GET['ac']=$default;
312 $_POST['ac']=$default;
313 $_REQUEST['ac']=$default;
315 $all[0] = $default;
317 }
318 catch (Exception $exc)
319 {
320 echo $exc->getMessage();
321 record_log("No user profile ");
322 record_log($exc->getMessage());
323 record_log($exc->getTraceAsString());
324 throw $exc;
325 }
326
327}
328
329
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)
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:305
$_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
$user_profile
Definition do.php:298
$oPeriode
Definition do.php:156
if($oPeriode->load()==-1) $module_selected
Definition do.php:164
$browser
Definition do.php:102
for($e=0; $e< count($afiche); $e++) exit
load_all_script()
load all the javascript only one time
redirect($p_string, $p_time=0)