'.$p_string."

"; } function span($p_string, $p_extra='') { return '' . $p_string . ''; } function hi($p_string) { return '' . h($p_string) . ''; } function hb($p_string) { return '' . h($p_string) . ''; } function th($p_string, $p_extra='',$raw='') { return '' . h($p_string).$raw . ''; } function h2info($p_string) { return '

' . h($p_string) . '

'; } function h2($p_string, $p_class="",$raw="") { return '

' . $raw.h($p_string) . '

'; } function h1($p_string, $p_class="") { return '

' . h($p_string) . '

'; } /** * \brief surround the string with td * \param $p_string string to surround by TD * \param $p_extra extra info (class, style, javascript...) * \return string surrounded by td */ function td($p_string='', $p_extra='') { return '' . $p_string . ''; } function tr($p_string, $p_extra='') { return '' . $p_string . ''; } /** * @brief escape correctly php string to javascript */ function j($p_string) { $a = preg_replace("/\r?\n/", "\\n", addslashes($p_string)); $a = str_replace("'", '\'', $a); return $a; } /** * format the number for the CSV export * @param $p_number number */ function nb($p_number) { $r=trim($p_number); $r = sprintf('%.4f', $p_number); $r = str_replace('.', ',', $r); return $r; } /** * return D if the number is smaller than 0 , C if bigger and an empty string if * equal to 0. Used for displaying saldo D / C (debit / credit ) * @param float $p_number */ function findSide($p_number) { $return =''; if ( $p_number > 0 ) { $return ='D'; }else { $return =($p_number== 0)?"":"C"; } return $return; } /** * format the number with a sep. for the thousand * @param $p_number number * @param $p_dec number of decimal to display */ function nbm($p_number,$p_dec = 2) { if (trim($p_number) == '') return ''; if ($p_number == 0) return "0,00"; $a = doubleval($p_number); $r = number_format($a, $p_dec, ",", "."); if (trim($r) == '') { var_dump($r); var_dump($p_number); var_dump($a); exit(); } return $r; } /** * \brief log error into the /tmp/noalyss_error.log it doesn't work on windows * * \param p_log message * \param p_line line number * \param p_message is the message * * \return nothing * */ function echo_error($p_log, $p_line="", $p_message="") { echo "ERREUR :" . $p_log . " " . $p_line . " " . $p_message; $fdebug = fopen($_ENV['TMP'] . DIRECTORY_SEPARATOR . "noalyss_error.log", "a+"); if ($fdebug != null) { fwrite($fdebug, date("Ymd H:i:s") . $p_log . " " . $p_line . " " . $p_message . "\n"); fclose($fdebug); } } /** * \brief Compare 2 dates * \param p_date * \param p_date_oth * * \return * - == 0 les dates sont identiques * - > 0 date1 > date2 * - < 0 date1 < date2 */ function cmpDate($p_date, $p_date_oth) { date_default_timezone_set('Europe/Brussels'); $l_date = isDate($p_date); $l2_date = isDate($p_date_oth); if ($l_date == null || $l2_date == null) { throw new Exception("erreur date [$p_date] [$p_date_oth]"); } $l_adate = explode(".", $l_date); $l2_adate = explode(".", $l2_date); $l_mkdate = mktime(0, 0, 0, $l_adate[1], $l_adate[0], $l_adate[2]); $l2_mkdate = mktime(0, 0, 0, $l2_adate[1], $l2_adate[0], $l2_adate[2]); // si $p_date > $p_date_oth return > 0 return $l_mkdate - $l2_mkdate; } /***! * @brief check if the argument is a number * * @param $p_int number to test * * @return * - 1 it's a number * - 0 it is not */ function isNumber($p_int) { if (strlen(trim($p_int)) == 0) return 0; if (is_numeric($p_int) === true) return 1; else return 0; } /*** * \brief Verifie qu'une date est bien formaté * en d.m.y et est valable * \param $p_date * * \return * - null si la date est invalide ou malformaté * - $p_date si tout est bon * */ function isDate($p_date) { if (strlen(trim($p_date)) == 0) return null; if (preg_match("/^[0-9]{1,2}\.[0-9]{1,2}\.20[0-9]{2}$/", $p_date) == 0) { return null; } else { $l_date = explode(".", $p_date); if (sizeof($l_date) != 3) return null; if ($l_date[2] > COMPTA_MAX_YEAR || $l_date[2] < COMPTA_MIN_YEAR) { return null; } if (checkdate($l_date[1], $l_date[0], $l_date[2]) == false) { return null; } } return $p_date; } /** * \brief Default page header for each page * * \param p_theme default theme * \param $p_script * \param $p_script2 another js script * Must be called only once * \return none */ function html_page_start($p_theme="", $p_script="", $p_script2="") { // check not called twiced static $already_call=0; if ( $already_call==1)return; $already_call=1; $cn = new Database(); if ($p_theme != "") { $Res = $cn->exec_sql("select the_filestyle from theme where the_name=$1" ,[$p_theme]); if (Database::num_row($Res) == 0) { $style = "style-classic7.css"; } else { $s = Database::fetch_array($Res, 0); $style = $s['the_filestyle']; } } else { $style = "style-classic7.css"; } // end if $title="NOALYSS"; if ( isset ($_REQUEST['ac'])) { $ac=strip_tags($_REQUEST['ac']); if (strpos($ac,'/') <> 0) { $m= explode('/',$ac); $title=$m[count($m)-1]." ".$title; } else $title=$ac." ".$title; } $is_msie=is_msie(); if ($is_msie == 0 ) { echo ''; printf("\n"); } else { echo ''; printf("\n"); } echo ""; if ($p_script2!="") { $p_script2=''; } $style=trim($style); echo ""; echo ''; echo ""; if ($is_msie==1) { echo ' '; } echo " $title " . $p_script2 . " "; // preload font echo ''; echo ''; echo ''; echo ' '; if (isset($_SESSION[SESSION_KEY.'g_lang']) && $_SESSION[SESSION_KEY.'g_lang']=='fr_FR.utf8' ) { echo ''; } if (isset($_SESSION[SESSION_KEY.'g_lang']) && $_SESSION[SESSION_KEY.'g_lang']=='nl_NL.utf8' ) { echo ''; } echo ' '; // language if (isset($_SESSION[SESSION_KEY.'g_lang'])) { set_language(); } echo load_all_script(); echo ' '; echo ""; echo '
'; echo '
'. HtmlInput::title_box(_("Erreur"), 'error_div','hide'). '
'. '
'. '

'. HtmlInput::button_action('Valider','$(\'error_div\').style.visibility=\'hidden\';$(\'error_content_div\').innerHTML=\'\';'). '

'. '
'; } /** * \brief Minimal page header for each page, used for small popup window * * \param p_theme default theme * \param $p_script * \param $p_script2 another js script * * \return none */ function html_min_page_start($p_theme="", $p_script="", $p_script2="") { $cn = new Database(); if ($p_theme != "") { $Res = $cn->exec_sql("select the_filestyle from theme where the_name='" . $p_theme . "'"); if (Database::num_row($Res) == 0) $style = "style-classic.css"; else { $s = Database::fetch_array($Res, 0); $style = $s['the_filestyle']; } } else { $style = "style-classic.css"; } // end if echo ''; echo ""; if ($p_script2!="") { $p_script2=''; } echo " NOALYSS " . $p_script2 . " "; echo ""; include_once NOALYSS_INCLUDE.'/lib/message_javascript.php'; echo ' '; echo ""; /* If we are on the user_login page */ if (basename($_SERVER['PHP_SELF']) == 'user_login.php') { return; } } /** * \brief end tag * */ function html_page_stop() { echo ""; echo ""; } /** * \brief Echo no access and stop * * \return nothing */ function NoAccess($js=1) { if ($js == 1) { echo ""; } else { echo '
'; echo '

' . _(' Cette action ne vous est pas autorisée Contactez votre responsable') . '

'; echo '
'; } exit - 1; } /** * replaced by sql_string * @deprecated */ function FormatString($p_string) { return sql_string($p_string); } /** * \brief Fix the problem with the quote char for the database * * \param $p_string * \return a string which won't let strange char for the database */ function sql_string($p_string) { $p_string = trim($p_string); if (strlen($p_string) == 0) return null; $p_string = str_replace("'", "''", $p_string); $p_string = str_replace('\\', '\\\\', $p_string); return $p_string; } /** * \brief store the string which print * the content of p_array in a table * used to display the menu * \param $p_array array like ( 0=>HREF reference, 1=>visible item (name),2=>Help(opt), * 3=>selected (opt) 4=>javascript (normally a onclick event) (opt) * \param $p_dir direction of the menu (H Horizontal V vertical) * \param $class CSS for li tag * \param $class_ref CSS for the A tag * \param $default selected item * \param $p_extra extra code for the table tag (CSS or javascript) */ /* \return : string */ function ShowItem($p_array, $p_dir='V', $class="nav-item", $class_ref="nav-link", $default="", $p_extra="nav nav-pills nav-fill") { $ret = ''; // for comptability with old application mtitle for anchor is replace by nav-link // direction Vertical if ($p_dir == 'V') { $ret .= "