28require_once NOALYSS_INCLUDE.
'/lib/function_javascript.php';
37 return ( $p_string ===
null)?
"":htmlspecialchars($p_string,
ENT_QUOTES|ENT_HTML5,
'UTF-8',
true);
41 return '<p>'.$p_string.
"</p>";
43function span($p_string, $p_extra=
'')
45 return '<span ' . $p_extra .
'>' . $p_string .
'</span>';
50 return '<i>' .
h($p_string) .
'</i>';
55 return '<b>' .
h($p_string) .
'</b>';
58function th($p_string, $p_extra=
'',$raw=
'')
60 return '<th ' . $p_extra .
'>' .
h($p_string).$raw .
'</th>';
65 return '<h2 class="info">' .
h($p_string) .
'</h2>';
68function h2($p_string, $p_class=
"",$raw=
"")
70 return '<h2 ' . $p_class .
'>' . $raw.h($p_string) .
'</h2>';
72function h1($p_string, $p_class=
"")
74 return '<h1 ' . $p_class .
'>' .
h($p_string) .
'</h1>';
83function td($p_string=
'', $p_extra=
'')
85 return '<td ' . $p_extra .
'>' . $p_string .
'</td>';
88function tr($p_string, $p_extra=
'')
90 return '<tr ' . $p_extra .
'>' . $p_string .
'</tr>';
98 $a = preg_replace(
"/\r?\n/",
"\\n", addslashes($p_string));
107function nb($p_number)
110 $r = sprintf(
'%.4f', $p_number);
124 if ( $p_number > 0 ) {
127 $return =($p_number== 0)?
"":
"C";
137function nbm($p_number,$p_dec = 2)
145 $a = doubleval($p_number);
146 $r = number_format(
$a, $p_dec,
",",
".");
171 $msg=
"ERREUR :" . $p_log .
" " . $p_line .
" " . $p_message;
173 syslog(LOG_ERR,
$msg);
190 date_default_timezone_set(
'Europe/Brussels');
193 $l2_date =
isDate($p_date_oth);
194 if ($l_date ==
null || $l2_date ==
null)
196 throw new Exception(
"erreur date [$p_date] [$p_date_oth]");
198 $l_adate = explode(
".", $l_date);
199 $l2_adate = explode(
".", $l2_date);
200 $l_mkdate = mktime(0, 0, 0, $l_adate[1], $l_adate[0], $l_adate[2]);
201 $l2_mkdate = mktime(0, 0, 0, $l2_adate[1], $l2_adate[0], $l2_adate[2]);
203 return $l_mkdate - $l2_mkdate;
219 if (is_numeric($p_int) ===
true)
240 if (preg_match(
"/^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}$/",
$p_date) == 0)
247 $l_date = explode(
".",
$p_date);
249 if (
sizeof($l_date) != 3)
257 if (checkdate($l_date[1], $l_date[0], $l_date[2]) ==
false)
278 static $already_call=0;
279 if ( $already_call==1)
return;
285 $Res =
$cn->exec_sql(
"select the_filestyle from theme
286 where the_name=$1" ,[$p_theme]);
289 $style =
"style-classic7.css";
299 $style =
"style-classic7.css";
305 if (strpos(
$ac,
'/') <> 0)
307 $m= explode(
'/',
$ac);
317 echo
'<!doctype html>';
322 echo
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN" >';
329 $p_script2=
'<script src="'.$p_script2.
'" type="text/javascript"></script>';
333 echo
'<meta charset="utf-8">';
334 echo
"<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
337 echo
' <meta http-equiv="x-ua-compatible" content="IE=edge"/>';
342 <link rel=
"icon" type=
"image/ico" href=
"favicon.ico" />
343 <meta
name=
"viewport" content=
"width=device-width, initial-scale=1.0">
344 <LINK
id=
"bootstrap" REL=
"stylesheet" type=
"text/css" href=
"css/bootstrap.min.css" media=
"screen"/>
345 <LINK
id=
"fontello" REL=
"stylesheet" type=
"text/css" href=
"css/font/fontello/css/fontello.css" media=
"screen"/>
346 <LINK
id=
"pagestyle" REL=
"stylesheet" type=
"text/css" href=
"css/$style?version=$version_noalyss" media=
"screen"/>
347 <link rel=
"stylesheet" type=
"text/css" href=
"css/style-print.css?version=$version_noalyss" media=
"print"/>
351 echo
'<link rel="preload" href="css/font/OpenSansRegular.woff" as="font" crossorigin="anonymous" />';
352 echo
'<link rel="preload" href="css/font/SansationLight/SansationLight.woff" as="font" crossorigin="anonymous" />';
353 echo
'<link rel="preload" href="css/font/fontello/fontello.woff" as="font" crossorigin="anonymous" />';
355 echo
'<script language="javascript" src="js/calendar.js"></script>
356 <script type="text/javascript" src="js/lang/calendar-en.js"></script>';
358 if (isset($_SESSION[SESSION_KEY.
'g_lang']) && $_SESSION[SESSION_KEY.
'g_lang']==
'fr_FR.utf8' )
360 echo
'<script type="text/javascript" src="js/lang/calendar-fr.js"></script>';
362 if (isset($_SESSION[SESSION_KEY.
'g_lang']) && $_SESSION[SESSION_KEY.
'g_lang']==
'nl_NL.utf8' )
364 echo
'<script type="text/javascript" src="js/lang/calendar-nl.js"></script>';
367 <script language="javascript" src="js/calendar-setup.js"></script>
368 <LINK REL="stylesheet" type="text/css" href="css/calendar-blue.css" media="screen">
371 if (isset($_SESSION[SESSION_KEY.
'g_lang']))
385 echo
"<BODY $p_script>";
386 echo
'<div id="info_div"></div>';
387 echo
'<div id="error_div">'.
388 HtmlInput::title_box(
_(
"Erreur"),
'error_div',
'hide').
389 '<div id="error_content_div">'.
391 '<p style="text-align:center">'.
392 HtmlInput::button_action(
'Valider',
'$(\'error_div\').style.visibility=\'hidden\';$(\'error_content_div\').innerHTML=\'\';').
414 $Res =
$cn->exec_sql(
"select the_filestyle from theme
415 where the_name='" . $p_theme .
"'");
417 $style =
"style-classic7.css";
426 $style =
"style-classic7.css";
428 echo
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN">';
434 $p_script2=
'<script src="'.$p_script2.
'" type="text/javascript"></script>';
438 <TITLE>NOALYSS</TITLE>
439 <META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF8\">
440 <LINK REL=\"stylesheet\" type=\"text/css\" href=\"css/$style\" media=\"screen\">
441 <link rel=\"stylesheet\" type=\"text/css\" href=\"css/style-print.css\" media=\"print\">" .
443 <script src=\"js/prototype.js\" type=\"text/javascript\"></script>
444 <script src=\"js/noalyss_script.js\" type=\"text/javascript\"></script>
445 <script src=\"js/acc_ledger.js\" type=\"text/javascript\"></script>
446 <script src=\"js/smoke.js\" type=\"text/javascript\"></script>
447 <script src=\"export.php?loadjs=message\" type=\"text/javascript\" charset=\"utf-8\"></script>";
449 echo
"<LINK id=\"pagestyle\" REL=\"stylesheet\" type=\"text/css\" href=\"css/font/fontello/css/fontello.css\" media=\"screen\"/>";
457 echo
"<BODY $p_script>";
459 if (basename($_SERVER[
'PHP_SELF']) ==
'user_login.php')
487 echo
"alert ('" .
_(
'Cette action ne vous est pas autorisée Contactez votre responsable') .
"');";
492 echo
'<div class="redcontent">';
493 echo
'<h2 class="error">' .
_(
' Cette action ne vous est pas autorisée Contactez votre responsable') .
'</h2>';
515 $p_string = trim($p_string??
"");
516 if (strlen($p_string) == 0)
537function ShowItem(
$p_array, $p_dir=
'V',
$class=
"nav-item", $class_ref=
"nav-link", $default=
"", $p_extra=
"nav nav-pills nav-fill")
546 $ret .=
"<ul class=\"$p_extra noprint \" flex-row>";
548 $ret .=
"<ul class=\"$p_extra noprint \" >";
554 $javascript = (isset(
$href[4])) ?
$href[4] :
"";
568 $ret.=
'<li class="nav-item"><A class="'.$class_ref.
' active'.
'" HREF="'.$href[0].
'" title="'.
$title.
'" '.$javascript.
'>'.
$href[1].
'</A></li>';
572 $ret.=
'<li class="nav-item"><A class="'.$class_ref.
'" HREF="'.
$href[0].
'" title="'.
$title.
'" '.$javascript.
'>'.
$href[1].
'</A></li>';
593 echo
'<span class="warning">' . $p_string .
'</span>';
609 if (
$pos !=
'p_start' &&
$pos !=
'p_end')
611 echo_error(
'lib/ac_common.php' .
"-" . __LINE__ .
' UNDEFINED PERIODE');
612 throw new Exception(
_(
"paramètre invalide"));
616 throw new Exception(
"Paramètre invalide");
619 $ret = $p_cn->get_value(
"select to_char($pos,'Mon YYYY') as t from parm_periode where p_id=$1",
637 $R = $p_cn->get_value(
"select p_id from parm_periode where
638 to_char(p_start,'DD.MM.YYYY') = $1", array(
'01.'.
$p_date));
654 $p_html = urldecode($p_html);
684function sql_filter_per($p_cn, $p_from, $p_to, $p_form=
'p_id', $p_field=
'jr_tech_per')
687 if ($p_form !=
'p_id' && $p_form !=
'date')
689 echo_error(__FILE__, __LINE__,
'Mauvais parametres ');
695 if ($p_form ==
'p_id')
697 if ( isNUmber($p_from)==0 || isNUmber($p_to)==0){
698 throw new Exception(
"SFP1".
_(
"Nombre invalide").
"\$p_from=$p_from \$p_to=$p_to");
702 $a_start =
$pPeriode->get_date_limit($p_from);
703 $a_end =
$pPeriode->get_date_limit($p_to);
704 if ($a_start==
null||$a_end==
null)
706 throw new Exception(__FILE__.__LINE__.sprintf(
_(
'Attention periode
707 non trouvee periode p_from= %s p_to_periode = %s'), $p_from, $p_to));
711 $p_from = $a_start[
'p_start'];
712 $p_to = $a_end[
'p_end'];
715 throw new Exception(
"SFP2".
_(
"Date invalide").
"\$p_from=$p_from \$p_to=$p_to");
720 $periode=
" $p_field = (select p_id from parm_periode ".
722 " p_start = to_date('$p_from','DD.MM.YYYY')) ";
726 $periode=
"$p_field in (select p_id from parm_periode ".
727 " where p_start >= to_date('$p_from','DD.MM.YYYY') and p_end <= to_date('$p_to','DD.MM.YYYY')) ";
756function set_language()
758 // desactivate local check
759 if (defined("LOCALE")&&LOCALE==0)
763 if (!isset($_SESSION[SESSION_KEY.'g_lang
']))
769 * If translation is not supported by current
771 if (!function_exists("bindtextdomain"))
777 // set differently the language depending of the operating system
780 $dir = setlocale(LC_MESSAGES, $_SESSION[SESSION_KEY.'g_lang
']);
783 $g_lang = 'fr_FR.utf8
';
784 $dir = setlocale(LC_MESSAGES, $g_lang);
785 // echo '<
span class=
"notice">
' . $_SESSION[SESSION_KEY.'g_lang
'] . ' domaine non supporté</h2>
';
787 bindtextdomain('messages
', NOALYSS_HOME.'/lang
');
788 textdomain('messages
');
789 bind_textdomain_codeset('messages
', 'UTF8
');
794 putenv('LANG=
' . $_SESSION[SESSION_KEY.'g_lang
']);
795 $dir = setlocale(LC_ALL, $_SESSION[SESSION_KEY.'g_lang
']);
796 bindtextdomain('messages
', '.\\lang
');
797 textdomain('messages
');
798 bind_textdomain_codeset('messages
', 'UTF8
');
810 $inc_path = get_include_path();
812 if (strpos($inc_path, ";") != 0)
814 $os = 0; /* $os is 0 for windoz */
818 $os = 1; /* $os is 1 for unix */
828function shrink_date($p_date)
830 $date = noalyss_str_replace('.
', '', $p_date);
831 $str_date = substr($date, 0, 4) . substr($date, 6, 2);
839function smaller_date($p_date)
841 if (empty ($p_date)) return "";
842 $str_date = substr($p_date, 0, 6) . substr($p_date, 8, 2);
854function format_date($p_date, $p_from_format = 'YYYY-MM-DD
',$p_to_format='DD.MM.YYYY
')
856 if (empty($p_date)) {return $p_date;}
857 if ($p_from_format == 'YYYY-MM-DD
')
859 $date = explode('-
', $p_date);
860 if (count($date) != 3)
863 if ($p_from_format == 'DD.MM.YYYY
')
865 $temp_date = explode('.
', $p_date);
866 if (count($temp_date) != 3)
868 $date[0] = $temp_date[2]; // 0 is year
869 $date[1] = $temp_date[1]; // 1 for month
870 $date[2] = $temp_date[0]; // 2 for day
873 switch ($p_to_format)
876 $str_date = $date[2] . '.
' . $date[1] . '.
' . $date[0];
879 $str_date = $date[2] . '-
' . $date[1] . '-
' . $date[0];
882 $str_date = $date[0] . '-
' . $date[1] . '-
' . $date[2];
885 $str_date = $date[0] . $date[1] . $date[2];
888 $str_date = $date[0] . '/
' . $date[1] . '/
' . $date[2];
891 $str_date = $date[2] . '.
' . $date[1] . '.
' . substr($date[0],2,2);
894 $str_date = $date[2] . '-
' . $date[1] . '-
' . substr($date[0],2,2);
897 throw new Exception(_("Format Invalide"),1);
909function ajax_disconnected($p_div)
912 echo HtmlInput::title_box(_("Déconnecté"), $p_div);
913 echo h2(_('Données non disponibles
'), 'class=
"error" ');
914 echo h2(_('Veuillez vous reconnecter soit dans une autre fenêtre soit
'
915 . ' en cliquant sur le bouton
'), 'class=
"error"');
917 $reload=new IButton("reload");
918 $reload->value=_("Se connecter");
919 $reload->class="button";
920 $reload->javascript='window.location.reload()
';
921 // Link to log in another tab
922 echo '<
p style=
"text-align:center">
';
923 echo $reload->input();
924 echo HtmlInput::button_close($p_div,'button
');
934function show_module($selected)
937 $cn = Dossier::connect();
938 $amodule = $cn->get_array("select
939 me_code,me_menu,me_url,me_javascript,p_order,me_type,me_description
943 and p_type_display='M
'
944 order by p_order", array($g_user->get_profile()));
948 $selected_module=$cn->get_value('select me_code
from profile_menu where
'
949 . ' pm_id = $1
', array($selected));
950 require_once NOALYSS_TEMPLATE.'/module.php
';
951 $file = $cn->get_array("select me_file,me_parameter,me_javascript,me_type,me_description from v_all_menu
952 where pm_id=$1 and p_id=$2", array($selected,$g_user->get_profile()));
953 if ( count($file ) == 0 )
957 echo '<div
class=
"content">
';
958 echo_warning(_("Module inexistant")."[ $selected ] ");
962 if ($file[0]['me_file
'] != '')
964 if ($file[0]['me_parameter
'] != "")
966 // if there are paramter put them in superglobal
967 $array=compute_variable($file[0]['me_parameter
']);
971 // if file is not a plugin, include the file, otherwise
972 // include the plugin launcher
973 if ($file[0]['me_type
'] != 'PL
')
975 require_once $file[0]['me_file
'];
979 // nothing : direct call to plugin
982 if ( $file[0]['me_javascript
'] != '')
984 create_script($file[0]['me_javascript
']);
993function find_default_module()
996 $cn = Dossier::connect();
998 $default_module = $cn->get_array("select me_code
999 from profile_menu join profile_user using (p_id)
1001 p_type_display='M
' and
1002 user_name=$1 and pm_default=1", array($g_user->login));
1005 * Try to find the smallest order for module
1007 if (empty($default_module))
1009 $default_module = $cn->get_array("select me_code
1010 from profile_menu join profile_user using (p_id)
1012 p_type_display='M
' and
1013 user_name=$1 order by p_order limit 1", array($g_user->login));
1015 // if no default try to find the default menu
1016 if ( empty ($default_module))
1018 $default_module = $cn->get_array("select me_code
1019 from profile_menu join profile_user using (p_id)
1021 p_type_display='E
' and
1022 user_name=$1 and pm_default=1 ", array($g_user->login));
1024 * Try to find a default menu by order
1026 if (empty ($default_module))
1028 $default_module = $cn->get_array("select me_code
1029 from profile_menu join profile_user using (p_id)
1031 user_name=$1 and p_order=(select min(p_order) from profile_menu join profile_user using (p_id)
1032 where user_name=$2) limit 1", array($g_user->login, $g_user->login));
1036 * if nothing found, there is no profile for this user => exit
1038 if (empty ($default_module))
1041 * If administrateur, then we insert a default profile (1)
1044 if ( $g_user->admin == 1 )
1046 $cn->exec_sql('insert into profile_user(user_name,
p_id) values ($1,1)
',array($g_user->login));
1047 return find_default_module();
1049 echo_warning(_("Utilisateur n'a pas de profil, votre administrateur doit en configurer un dans C0SEC
"));
1053 return $default_module[0]['me_code'];
1056 if (count($default_module) > 1)
1058 // return the first module found
1059 return $default_module[0]['me_code'];
1061 elseif (count($default_module) == 1)
1063 return $default_module[0]['me_code'];
1073function show_menu($module)
1075 if ($module == 0)return;
1078 $http=new HttpInput();
1079 $access_code=$http->request("ac
");
1080 $cn = Dossier::connect();
1084 $amenu = $cn->get_array("
1094 me_description_etendue
1096 join menu_ref
using (me_code)
1097 where pm_id_dep=$1 and
p_id=$2
1098 order by p_order
", array($module, $g_user->get_profile()));
1100 // There are submenuS, so show them
1101 if (!empty($amenu) && count($amenu) > 1)
1103 $a_style_menu=array('topmenu','menu2','menu3');
1104 if ( $level > count($a_style_menu))
1105 $style_menu='menu3';
1107 $style_menu=$a_style_menu[$level];
1109 require NOALYSS_TEMPLATE.'/menu.php';
1112 } elseif (count($amenu) == 1)
1114 // there is only one submenu so we include the code or javascript
1115 // or we show the submenu
1116 if ( trim($amenu[0]['me_url']??"") != "" ||
1117 trim ($amenu[0]['me_file']??"") != "" ||
1118 trim ($amenu[0]['me_javascript']??"") != "" )
1120 echo '<div class="topmenu
">';
1121 echo h2info(_($amenu[0]['me_menu']));
1123 $module = $amenu[0]['pm_id'];
1124 display_menu($module);
1128 $url=$access_code.'/'.$amenu[0]['me_code'];
1129 echo '<a href="do.php?gDossier=
'.Dossier::id().'&ac=
'.$url.'">';
1130 echo _($amenu[0]['me_menu']);
1137 // !!! this point should never be reached
1138 // There is no submenu or only one
1139 if (empty($amenu) || count($amenu) == 1)
1141 display_menu($module);
1152function display_menu($p_menuid)
1154 if ($p_menuid == 0) return;
1156 $cn=Dossier::connect();
1158 $file = $cn->get_array("
1159 select me_file,me_parameter,me_javascript,me_type
1161 join profile_menu
using (me_code)
1162 join profile_user
using (
p_id)
1166 (me_file is not
null or trim(me_file) <>
'' or
1167 me_javascript is not
null or trim (me_javascript) <>
'')
", array($p_menuid,$g_user->login));
1169 if (count($file)==0)
1174 if ($file[0]['me_file'] != "")
1176 if ($file[0]['me_parameter'] !== "")
1178 // if there are paramter put them in superglobal
1179 $array=compute_variable($file[0]['me_parameter']);
1182 \Noalyss\Dbg::echo_var(1,$file[0]['me_file']." ".$file[0]['me_parameter']);
1184 * Log the file we input to put in the folder test-noalyss for replaying it
1187 $file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
1188 fwrite($file_loginput, "include
'".$file[0]['me_file
']."';
");
1189 fwrite($file_loginput,"\
n");
1190 fclose($file_loginput);
1192 // if file is not a plugin, include the file, otherwise
1193 // include the plugin launcher
1194 if ( $file[0]['me_type'] != 'PL') {
1195 if (file_exists ($file[0]['me_file']) )
1197 require_once $file[0]['me_file'];
1198 } elseif ( file_exists(NOALYSS_INCLUDE.'/'.$file[0]['me_file'])) {
1199 require_once NOALYSS_INCLUDE.'/'.$file[0]['me_file'];
1201 echo echo_warning(_("Fichier non trouvé
"));
1204 require 'extension_get.inc.php';
1208 } elseif ( $file[0]['me_javascript'] != '')
1210 $js= noalyss_str_replace('<DOSSIER>', dossier::id(), $file[0]['me_javascript']);
1211 echo create_script($js);
1219function header_csv($p_filename)
1222 header('Pragma: public');
1223 header('Content-type: application/csv');
1224 header("Content-Disposition: attachment;filename=\
"{$p_filename}\"",
1226 header(
'Cache-Control: no-store, no-cache, must-revalidate');
1227 header(
'Expires: Sun, 1 Jan 2000 12:00:00 GMT');
1228 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
'GMT');
1255 if ($p_string ==
'')
return $array;
1257 $var=explode(
"&",$p_string);
1261 $var2=explode(
'=',
$var[
$i]);
1270 header(
'Content-type: text/xml; charset=UTF-8');
1272<?xml version=
"1.0" encoding=
"UTF-8"?>
1286 if ( isset(
$r[$key])) {
1322 throw new Exception(
'Ledger type not found');
1332 if ( strpos ($_SERVER[
'HTTP_USER_AGENT'],
'MSIE 8.0') != 0 ||
1333 strpos ($_SERVER[
'HTTP_USER_AGENT'],
'MSIE 9.0') != 0 )
1346 $date= date (
'Y-m-d');
1348 $handle_log=fopen(NOALYSS_BASE.
"/log/noalyss-{$date}.log",
"a+");
1350 if ($handle_log ==
false )
1353 if ( gettype ($p_message) ==
"object" && method_exists($p_message,
"getTraceAsString") == 1) {
1356 error_log(
"noalyss exception File [".$exc->getFile().
":".$exc->getLine().
"]",0);
1357 error_log(
"noalyss exception Message [".$exc->getMessage().
"]",0);
1358 error_log(
"noalyss exception Code [".$exc->getCode().
"]",0);
1359 error_log(
"noalyss exception Trace ".$exc->getTraceAsString(),0);
1360 error_log(
"------ ",0);
1361 $exc=$exc->getPrevious();
1362 if ($exc !=
null )fwrite ($handle_log,
"*********************** Previous *********************** \n");
1363 }
while ($exc !=
null);
1365 error_log(
"noalyss".var_export($p_message,
true),0);
1368 error_log(
"noalyss GET [".json_encode(
$_GET,0,10).
"]");
1369 error_log(
"_POST [".json_encode(
$_POST,0,10).
"]",0);
1371 if ( gettype ($p_message) ==
"object" && method_exists($p_message,
"getTraceAsString") == 1) {
1373 error_log(
"noalyss exception ".$p_message->getMessage(),0);
1374 error_log(
"noalyss exception".$p_message->getTraceAsString(),0);
1376 error_log(
"noalyss".var_export($p_message,
true),0);
1380 $now=date (
'Y-m-d H:i:s');
1381 fwrite ($handle_log,str_repeat(
"=", 80).
"\n");
1382 fwrite ($handle_log,
"ERROR: {$now}\n");
1383 fwrite($handle_log,
"noalyss GET [".var_export(
$_GET,
true).
"]");
1384 fwrite ($handle_log,
"\n");
1385 fwrite($handle_log,
"_POST [".var_export(
$_POST,
true).
"]");
1386 fwrite ($handle_log,
"\n");
1387 if ( gettype ($p_message) ==
"object" && method_exists($p_message,
"getTraceAsString") == 1) {
1390 fwrite($handle_log,
"noalyss exception File [".$exc->getFile().
":".$exc->getLine().
"]");
1391 fwrite ($handle_log,
"\n");
1392 fwrite($handle_log,
"noalyss exception Message [".$exc->getMessage().
"]");
1393 fwrite ($handle_log,
"\n");
1394 fwrite($handle_log,
"noalyss exception Code [".$exc->getCode().
"]");
1395 fwrite ($handle_log,
"\n");
1396 fwrite($handle_log,
"noalyss exception Trace \n".$exc->getTraceAsString());
1397 fwrite ($handle_log,
"\n");
1398 $exc=$exc->getPrevious();
1399 if ($exc !=
null )fwrite ($handle_log,
"*********************** Previous *********************** \n");
1400 }
while ($exc !=
null);
1402 fwrite($handle_log,
"noalyss".var_export($p_message,
true));
1403 fwrite ($handle_log,
"\n");
1407 fwrite ($handle_log,str_repeat(
"=", 80).
"\n");
1408 fclose($handle_log);
1413if(!function_exists(
'tracedebug')) {
1416 $tmp_file = sys_get_temp_dir().DIRECTORY_SEPARATOR.$file;
1417 $file_loginput=fopen( $tmp_file,
'a+');
1418 if ( $file_loginput ==
false) {
return;}
1424 if ( gettype (
$var) ==
'object' && get_class(
$var)==
'DOMDocument')
1426 $var->formatOutput=
true;
1433 file_put_contents($tmp_file,
$output, FILE_APPEND);
1444 $p_string2=mb_convert_encoding($p_string,
'ISO-8859-1',
'UTF-8');
1445 $p_string2=iconv(
'UTF-8',
'ISO-8859-1//IGNORE',$p_string);
1448 $nb_result=strlen($p_string2);
1449 for (
$i = 0 ;
$i < $nb_result ;
$i++ ){
1450 if (ord($p_string[
$i]) < 127 ) {
1453 $result.=
'\u'.ord($p_string[
$i]).chr(92).chr(39).
'3f';
1470 $p_formula=preg_replace(
"![0-9]+\.*[0-9]*/0\.{0,1}0*(\+|-|\*|/|;){1}!",
"0$1",$test);
1471 $p_formula=trim($p_formula,
';');
1483 $chaine=
"abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-=";
1485 $chaine=
"abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789";
1486 $microtime=microtime(
true)*microtime(
true)*100;
1488 srand((
int)$microtime);
1489 for (
$i=0;
$i<$p_length;
$i++)
1491 $string .= $chaine[rand()%strlen($chaine)];
1506 $r = HtmlInput::hidden(
"ctlcode",
$code);
1507 $r.=
'<span style="margin-left:1.2em;margin-right:1.2em;font-size:112%;font-weight:bold;border:navy solid 1px ; padding:0.5rem">'.
$code.
'</span>';
1518 $cn=Dossier::connect();
1519 $sql =
' select pm_id from profile_menu where pm_default =1 and pm_id_dep = $1';
1520 $aresult=
$cn->get_array(
$sql, [$pn_menu]);
1521 if (empty($aresult)) {
1524 return $aresult[0][
'pm_id'];
1545 if ($pa_menu[0][
'pm_id_v2'] == 0) {
1548 $a_result[0][
'pm_id_v2']=$pa_menu[0][
'pm_id_v1'];
1549 $a_result[0][
'pm_id_v1']=
$tmp;
1552 if ($pa_menu[0][
'pm_id_v3'] == 0) {
1555 $a_result[0][
'pm_id_v3']=$a_result[0][
'pm_id_v2'];
1556 $a_result[0][
'pm_id_v2']=$a_result[0][
'pm_id_v1'];
1557 $a_result[0][
'pm_id_v1']=
$tmp;
1569 if ( empty ($pan_code)) {
return;}
1571 $cn=Dossier::connect();
1572 $an_code=[
'pm_id_v3',
'pm_id_v2',
'pm_id_v1'];
1577 $s_result.=
$sep.$cn->get_value(
"select me_code from profile_menu where pm_id=$1",[ $pan_code[0][
$ix] ]);
1578 $sep=($s_result !=
"" )?
"/":
"";
1589 $ret=preg_replace(
"!http[s]{0,1}://[[:graph:]*]*!",
'<a href="\\0" target="_blank">\0</a>',
$text);
1602 else return strlen($p_string);
1605 if ($p_string===
null)
return "";
1606 else return trim($p_string);
1610 return strlen(trim($p_string));
1613 if (
$string===
null)
return "";
1614 else return str_replace($search,$replace??
"",
$string);
1618 $p_first=(empty($p_first))?0:$p_first;
1619 $p_second=(empty($p_second))?0:$p_second;
1620 return bcsub($p_first,$p_second,$p_decimal);
1624 $p_first=(empty($p_first))?0:$p_first;
1625 $p_second=(empty($p_second))?0:$p_second;
1626 return bcadd($p_first,$p_second,$p_decimal);
1630 if ($p_string===
null)
return "";
1631 return strip_tags($p_string);
1635 $p_first=(empty($p_first))?0:$p_first;
1636 $p_second=(empty($p_second))?0:$p_second;
1637 return bcmul($p_first??0,$p_second??0);
1641 $p_first=(empty($p_first))?0:$p_first;
1642 $p_second=(empty($p_second))?0:$p_second;
1643 return round($p_first??0,$p_second??0);
1653 if (
$string===
null)
return '';
1654 return explode($separator,
$string);
1662 if (!empty($p_tel)) {
1663 $r=sprintf(
'<a href="tel:%s">%s</a>',
h($p_tel),
h($p_tel));
1675 if (empty($p_email ))
return "";
1676 $nComma=preg_match(
"/,/",$p_email);
1678 $aEmail=explode(
",",$p_email);
1680 $aEmail[0]=$p_email;
1683 foreach ($aEmail as $email) {
1684 if ( filter_var(trim($email),FILTER_VALIDATE_EMAIL) ) {
1685 $r.=sprintf(
'<a href="mailto:%s">%s</a> ',
h($email),
h($email));
1687 $r.=sprintf(
"%s",
h($email));
1702 if (!empty($p_tel)) {
1703 $r=sprintf(
'<a href="fax:%s">%s</a>',
h($p_tel),
h($p_tel));
1710 if (empty(
$p_url) )
return "";
1711 if (filter_var(trim(
$p_url,FILTER_VALIDATE_URL)) ) {
1712 return sprintf(
'<a href="%s" target="_blank">%s</a>',
$p_url,
$p_url);
1724 if ( file_exists(NOALYSS_BASE.
"/".$p_file )) {
1725 include NOALYSS_BASE.
"/".$p_file;
1761 $error_code=array();
1763 $len=strlen($password??
"");
1765 $errors[] =
_(
"mot de passe de 8 lettres minimum");
1769 if (!preg_match(
"#[0-9]+#", $password)) {
1770 $errors[] =
_(
"mot de passe doit inclure au moins un chiffre");
1774 if (!preg_match(
"#[a-z]+#", $password)) {
1775 $errors[] =
_(
"mot de passe doit inclure au moins une minuscule");
1778 if (!preg_match(
"#[A-Z]+#", $password)) {
1779 $errors[] =
_(
"mot de passe doit inclure au moins une majuscule");
1784 $cnt_diff=count(count_chars($password,1));
1785 $ratio_diff=$len/$cnt_diff;
1787 if ($ratio_diff > 2) {
1788 $errors[] =
_(
"Trop souvent le(s) même(s) symbole(s)");
1791 $special_char=preg_replace(
'/[[:alnum:]]/',
'',$password);
1792 if ( strlen($special_char??
"")==0)
1794 $errors[] =
_(
"mot de passe doit inclure au moins un caractére spécial '+-/*[...'");
1800 return array(
'msg'=>$errors,
'code'=>$error_code);
1810 $car=($car < 8 )?8:$car;
1811 $max_loop=20;$loop=0;
1816 $chaine=
"abcdefghijklmnpqrstuvwxy";
1818 for (
$i=0;
$i<$car;
$i++)
1820 $string .= $chaine[rand()%strlen($chaine)];
1822 $chaine=
"ABCDEFGHIJKLMNPQRSTUVWXY";
1824 $string[rand()%$car]=$chaine[rand()%strlen($chaine)];;
1826 $chaine=
"0123456789";
1828 $string[rand()%$car]=$chaine[rand()%strlen($chaine)];;
1830 $special_set=
"+-/*;,.=:&()[]";
1831 $special_car=$special_set[rand()%strlen($special_set)];
1832 $string[rand()%$car]=$special_car;
1846 $pos_prefix=strrpos($filename,
".");
1849 $filename_suff=
".pdf";
1850 $filename.=$filename_suff;
1851 $pos_prefix=strrpos($filename,
".");
1854 $filename_suff=substr($filename, $pos_prefix, strlen($filename));
1856 $filename=str_replace(array(
'/',
'*',
'<',
'>',
';',
',',
'\\',
'.',
':',
'(',
')',
' ',
'[',
']'),
"-", $filename);
1858 $filename_no=substr($filename, 0, $pos_prefix);
1860 $new_filename=strtolower($filename_no).
"-".date(
"Ymd-Hi").$filename_suff;
1861 return $new_filename;
noalyss_bcsub($p_first, $p_second, $p_decimal=4)
noalyss_round($p_first, $p_second)
noalyss_bcadd($p_first, $p_second, $p_decimal=4)
ajax_xml_error($p_code, $p_string)
transform_sql_filter_per($p_sql)
transform the SQL for ANALYTIC table operation_analytique
h2($p_string, $p_class="", $raw="")
sanitize_filename($filename)
removed invalid character when computing a filename, the suffix is kept
FormatString($p_string)
replaced by sql_string
complete_default_menu($pa_menu)
Check if there is a default menu for this user and add it.
compute_variable($p_string)
the string has the format a=b&c=d, it is parsed and an array[][key,value] is returned
noalyss_strlen($p_string)
phoneTo($p_tel)
compose a HTML string with phone
th($p_string, $p_extra='', $raw='')
MaintenanceMode($p_file)
When you want to prevent users to connect, create a file in noalyss/ (NOALYSS_BASE) with the message ...
sql_filter_per($p_cn, $p_from, $p_to, $p_form='p_id', $p_field='jr_tech_per')
Create the condition to filter on the j_tech_per thanks a from and to date.
confirm_with_string($p_ctl_name, $p_car)
generate a string of p_car character and a input text with name p_ctl_name work like a kind of captch...
noalyss_explode($separator, $string)
to avoid deprecated in PHP8.1 : explode cannot use a null
mailTo($p_email)
compose a HTML string with email
findSide($p_number)
return D if the number is smaller than 0 , C if bigger and an empty string if equal to 0.
getPeriodeFromMonth($p_cn, $p_date)
Return the period corresponding to the date.
put_global($array)
Put in superglobal (get,post,request) the value contained in the parameter field (me_parameter)
noalyss_strip_tags($p_string)
span($p_string, $p_extra='')
get_array_column($p_array, $key)
getPeriodeName($p_cn, $p_id, $pos='p_start')
Show the periode which found thanks its id.
find_default_menu($pn_menu)
Find the menu marked as default in the given profile.
noalyss_strlentrim($p_string)
html_page_start($p_theme="", $p_script="", $p_script2="")
Default page header for each page.
echo_warning($p_string)
warns
Decode($p_html)
Decode the html for the widegt richtext and remove newline.
ShowItem($p_array, $p_dir='V', $class="nav-item", $class_ref="nav-link", $default="", $p_extra="nav nav-pills nav-fill")
store the string which print the content of p_array in a table used to display the menu
h1($p_string, $p_class="")
rebuild_access_code($pan_code)
rebuild the access code
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...
html_min_page_start($p_theme="", $p_script="", $p_script2="")
Minimal page header for each page, used for small popup window.
noalyss_str_replace($search, $replace, $string)
NoAccess($js=1)
Echo no access and stop.
echo_error($p_log, $p_line="", $p_message="")
log error into the /tmp/noalyss_error.log it doesn't work on windows
tr($p_string, $p_extra='')
remove_divide_zero($p_formula)
When it is needed to eval a formula , this function prevent the divide by zero.
generate_random_password($car)
generate a strong random password
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...
noalyss_bcmul($p_first, $p_second)
sql_string($p_string)
Fix the problem with the quote char for the database.
nb($p_number)
format the number for the CSV export
td($p_string='', $p_extra='')
surround the string with td
FaxTo($p_tel)
compose a HTML string with fax
nbm($p_number, $p_dec=2)
format the number with a sep.
generate_random_string($p_length, $special=1)
Create randomly a string.
cmpDate($p_date, $p_date_oth)
Compare 2 dates.
if(!function_exists( 'tracedebug')) convert_to_rtf($p_string)
encode the string for RTF, return a string
j($p_string)
escape correctly php string to javascript
alert($p_msg, $buffer=false)
alert in javascript
is_msie()
Check if we use IE 8 or 9.
factory_Ledger(Database &$p_cn, $ledger_id)
This function create a ledger object and return the right one.
if(headers_sent() &&DEBUGNOALYSS > 0) $html
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
if(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...
if(isNumber($jr_id)==0) $ledger_id
if(isset( $_REQUEST[ 'show'])) if(isset($_REQUEST['del'])) $ac
_("actif, passif,charge,...")
else $card content[$j]['j_montant']
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger
Handle the ledger of purchase,.
Handle the ledger of sold,.
Class for jrn, class acc_ledger for manipulating the ledger AND some acc.
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
contains the class for connecting to Noalyss
static warnbulle($p_comment)
Display a warning in a bubble, text is in message_javascript.
Contains some parameters to change appearance of noalyss, the colors are saved into the table parm_ap...
if($request_jrn !="" && $g_user->check_jrn($request_jrn) !='W' $p_msg)
if(sizeof($array)==0) $pPeriode
for($e=0; $e< count($afiche); $e++) exit
load_all_script()
load all the javascript only one time
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character,...