noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
ac_common.php File Reference

common utilities for a lot of procedure, classe More...

Go to the source code of this file.

Functions

 add_http_link ($text)
 Transform a http link into a clickable link.
 
 ajax_disconnected ($p_div)
 Should a dialog box when you are disconnected from an ajax call propose to reload or to connect in another tab.
 
 ajax_xml_error ($p_code, $p_string)
 
 alert ($p_msg, $buffer=false)
 alert in javascript
 
 check_iban (&$iban)
 check that an IBAN is valid
 
 check_password_strength ($password)
 returns an double array with the error found and code , if the count is 0 then the password is very strong, 5 means it is empty ,4 weak, ... the array contains the errors, [msg]=>array message [code] => array of code Codes are
 
 cmpDate ($p_date, $p_date_oth)
 Compare 2 dates.
 
 complete_default_menu ($pa_menu)
 Check if there is a default menu for this user and add it.
 
 compute_letter_value ()
 
 compute_variable ($p_string)
 the string has the format a=b&c=d, it is parsed and an array[][key,value] is returned
 
 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 captcha.The control code for checking is ctlcode.
 
 convert_array_select ($array)
 convert an array KEY=>VALUE into a double array useable by \ISelect
 
 convert_ini_unit ($p_value)
 convert a value in Mbytes, kb ... in byte
 
if(!function_exists( 'tracedebug')) convert_to_rtf ($p_string)
 encode the string for RTF, return a string
 
 Decode ($p_html)
 Decode the html for the widegt richtext and remove newline.
 
 display_menu ($p_menuid)
 Display a menu @global type $g_user.
 
 echo_error ($p_log, $p_line="", $p_message="")
 log error into the /tmp/noalyss_error.log it doesn't work on windows
 
 echo_warning ($p_string)
 warns
 
 factory_Ledger (Database &$p_cn, $ledger_id)
 This function create a ledger object and return the right one.
 
 FaxTo ($p_tel)
 compose a HTML string with fax
 
 find_default_menu ($pn_menu)
 Find the menu marked as default in the given profile.
 
 find_default_module ()
 
 find_idx ($array, $key, $value)
 retrieve the index for the key percent, returns -1 if nothing found
 
 findSide ($p_number)
 return D if the number is smaller than 0 , C if bigger and an empty string if equal to 0.
 
 format_date ($p_date, $p_from_format='YYYY-MM-DD', $p_to_format='DD.MM.YYYY')
 format the date, when taken from the database the format is MM-DD-YYYY
 
 FormatString ($p_string)
 replaced by sql_string
 
 generate_random_password ($car)
 generate a strong random password
 
 generate_random_string ($p_length, $special=1)
 Create randomly a string.
 
 get_array_column ($p_array, $key)
 
 getPeriodeFromMonth ($p_cn, $p_date)
 Return the period corresponding to the date.
 
 getPeriodeName ($p_cn, $p_id, $pos='p_start')
 Show the periode which found thanks its id.
 
 guidv4 ($data=null)
 generate an UUID
 
 h ($p_string)
 to protect again bad characters which can lead to a cross scripting attack the string to be diplayed must be protected.
 
 h1 ($p_string, $p_class="")
 
 h2 ($p_string, $p_class="", $raw="")
 
 h2info ($p_string)
 
 hb ($p_string)
 
 header_csv ($p_filename)
 Send an header CSV with a filename.
 
 hi ($p_string)
 
 html_min_page_start ($p_theme="", $p_script="", $p_script2="")
 Minimal page header for each page, used for small popup window.
 
 html_page_start ($p_theme="", $p_script="", $p_script2="")
 Default page header for each page.
 
 html_page_stop ()
 end tag
 
 is_msie ()
 Check if we use IE 8 or 9.
 
 isDate ($p_date)
 Verifie qu'une date est bien formaté en d.m.y et est valable.
 
 isNumber ($p_int)
 
 j ($p_string)
 escape correctly php string to javascript
 
 linkTo ($p_url)
 
 mailTo ($p_email)
 compose a HTML string with email
 
 MaintenanceMode ($p_file)
 When you want to prevent users to connect, create a file in noalyss/ (NOALYSS_BASE) with the message in Html.
 
 nb ($p_number)
 format the number for the CSV export
 
 nbm ($p_number, $p_dec=2)
 format the number with a sep.
 
 NoAccess ($js=1)
 Echo no access and stop.
 
 noalyss_bcadd ($p_first, $p_second, $p_decimal=4)
 
 noalyss_bcmul ($p_first, $p_second)
 
 noalyss_bcsub ($p_first, $p_second, $p_decimal=4)
 
 noalyss_explode ($separator, $string)
 to avoid deprecated in PHP8.1 : explode cannot use a null
 
 noalyss_round ($p_first, $p_second)
 
 noalyss_str_replace ($search, $replace, $string)
 
 noalyss_strip_tags ($p_string)
 
 noalyss_strlen ($p_string)
 
 noalyss_strlentrim ($p_string)
 
 noalyss_trim ($p_string)
 
 p ($p_string, $p_extra='')
 
 phoneTo ($p_tel)
 compose a HTML string with phone
 
 put_global ($array)
 Put in superglobal (get,post,request) the value contained in the parameter field (me_parameter)
 
 rebuild_access_code ($pan_code)
 rebuild the access code
 
 record_log ($p_message)
 Record an error message into the log file of the server or in the log folder of NOALYSS Record also the GET and POST data.
 
 remove_divide_zero ($p_formula)
 When it is needed to eval a formula , this function prevent the divide by zero.
 
 sanitize_filename ($filename, $with_date=true)
 removed invalid character when computing a filename, the suffix is kept
 
 set_language ()
 set the lang thanks the _SESSION['g_lang'] var.
 
 show_menu ($module)
 show the module
 
 show_menu_extension ($p_array, $default="", $p_extra="")
 Same menu for all extensions, with the right level, it calls ShowItem with the right parameters @global $level (int) global variable of the menu level.
 
 show_module ($selected)
 Show the modules.
 
 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
 
 shrink_date ($p_date)
 shrink the date, make a date shorter for the printing
 
 smaller_date ($p_date)
 shrink the date, make a date shorter for the printing
 
 span ($p_string, $p_extra='')
 
 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.
 
 sql_string ($p_string)
 Fix the problem with the quote char for the database.
 
 td ($p_string='', $p_extra='')
 surround the string with td
 
 th ($p_string, $p_extra='', $raw='')
 
 tr ($p_string, $p_extra='')
 
 transform_sql_filter_per ($p_sql)
 transform the SQL for ANALYTIC table operation_analytique
 
 what_os ()
 try to determine on what os you are running the pĥpcompte server
 

Detailed Description

common utilities for a lot of procedure, classe

Definition in file ac_common.php.

Function Documentation

◆ add_http_link()

add_http_link ( $text)

Transform a http link into a clickable link.

Definition at line 1639 of file ac_common.php.

1640{
1641
1642 $ret=preg_replace("!http[s]{0,1}://[[:graph:]*]*!",'<a href="\\0" target="_blank">\0</a>',$text);
1643
1644 return $ret;
1645
1646}

References $ret, and $text.

◆ ajax_disconnected()

ajax_disconnected ( $p_div)

Should a dialog box when you are disconnected from an ajax call propose to reload or to connect in another tab.

Definition at line 960 of file ac_common.php.

961{
962
963 echo HtmlInput::title_box(_("Déconnecté"), $p_div);
964 echo h2(_('Données non disponibles'), 'class="error" ');
965 echo h2(_('Veuillez vous reconnecter soit dans une autre fenêtre soit '
966 . ' en cliquant sur le bouton'), 'class="error"');
967 // Reload button
968 $reload=new IButton("reload");
969 $reload->value=_("Se connecter");
970 $reload->class="button";
971 $reload->javascript='window.location.reload()';
972 // Link to log in another tab
973 echo '<p style="text-align:center">';
974 echo $reload->input();
975 echo HtmlInput::button_close($p_div,'button');
976 echo '</p>';
977
978
979}
h2($p_string, $p_class="", $raw="")
Definition ac_common.php:68
_("actif, passif,charge,...")
static button_close($div_name, $class='smallbutton')
close button for the HTML popup
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n', $raw="", $refresh='')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
Html Input.

References p(), and style.

+ Here is the call graph for this function:

◆ ajax_xml_error()

ajax_xml_error ( $p_code,
$p_string )

Definition at line 1316 of file ac_common.php.

1317{
1318 $html = escape_xml($p_string);
1319 header('Content-type: text/xml; charset=UTF-8');
1320 echo <<<EOF
1321<?xml version="1.0" encoding="UTF-8"?>
1322<data>
1323<code>$p_code</code>
1324<value>$html</value>
1325</data>
1326EOF;
1327}
if(headers_sent() &&DEBUGNOALYSS > 0) $html
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character,...

References $html, escape_xml(), and value.

+ Here is the call graph for this function:

◆ alert()

alert ( $p_msg,
$buffer = false )

alert in javascript

Parameters
$p_msgis the message
$bufferif false, echo directly and execute the javascript, if $buffer is true, the alert javascript is in the return string
Returns
string with alert javascript if $buffer is true

Definition at line 791 of file ac_common.php.

792{
793 $r = '<script>';
794 $r.= 'alert_box(\'' . j($p_msg) . '\')';
795 $r.= '</script>';
796
797 if ($buffer)
798 {
799 return $r;
800 }
801 echo $r;
802}
j($p_string)
escape correctly php string to javascript
Definition ac_common.php:96
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
if($request_jrn !="" && $g_user->check_jrn($request_jrn) !='W' $p_msg)

References $p_msg, $r, and j().

Referenced by Fiche_Def\Add(), Extension\check_version(), Noalyss\Widget\Mini_Report\display(), Anc_Acc_List\display_html(), Anc_Group\display_html(), Anc_Table\display_html(), Acc_Ledger_Fin\input(), Todo_List\insert(), Extension\insert_plugin(), js_include(), Fiche\remove(), Extension\remove_plugin(), Acc_Parm_Code\save(), Document_Type\set_number(), Acc_Ledger\test_me(), ICard\test_me(), Extension\update_plugin(), Acc_Report\upload(), and Menu_Ref\verify().

+ Here is the call graph for this function:

◆ check_iban()

check_iban ( & $iban)

check that an IBAN is valid

Parameters
$ibanstring, this parameter will change:remove of space, comma,...
Returns
bool false the IBAN is invalid, true IBAN is VALID

Definition at line 1974 of file ac_common.php.

1974 : bool
1975{
1976 global $aLetter, $aLetterValue;
1977 if (trim($iban ?? "") == "")
1978 return false;
1979
1980 //------------------------------------------------
1981 // Make the letter
1982 //------------------------------------------------
1983 static $make_string,$aLetter, $aLetterValue=null;
1984
1985 if ( $make_string == null )
1986 {
1987 for ($i=65;$i!=91;$i++)
1988 {
1989 $make_string[chr($i)]=$i-55;
1990 }
1991 $aLetter=array_keys($make_string);
1992 $aLetterValue=array_values($make_string);
1993 }
1994
1995 $iban = strtoupper($iban);
1996 $iban=str_replace([" ", ",", ".", "-"], '', $iban);
1997
1998 $first = substr($iban, 0, 4);
1999 $chain = substr($iban, 4) . $first;
2000
2001 $replaced = str_replace($aLetter, $aLetterValue, $chain);
2002
2003 // computed by slice of 10: mod function is limited
2004 $start = 0;
2005 $slice = 10;
2006 $result = "";
2007 $length = strlen($replaced);
2008 while ($start < $length)
2009 {
2010 $slice_string = $result . substr($replaced, $start, $slice);
2011 $result = $slice_string % 97;
2012 $start += $slice;
2013 }
2014
2015 if ($result == 1)
2016 return true;
2017
2018 return false;
2019}

References $i, $result, and $start.

◆ check_password_strength()

check_password_strength ( $password)

returns an double array with the error found and code , if the count is 0 then the password is very strong, 5 means it is empty ,4 weak, ... the array contains the errors, [msg]=>array message [code] => array of code Codes are

  • 1 : too short
  • 2 : missing digit
  • 3 : missing lowercase letter
  • 4 : missing uppercase letter
  • 5 : too many time same letter or symbol..
  • 6 : missing special char

If the password is strong returns an empty array

Parameters
$passwordstring
if ( count($error['msg']) > 0 ) {
echo "password to weak";
foreach ($error['msg'] as $item_error) {
echo "error $item_error";
}
} else {
echo "OK password strong";
}
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...

Definition at line 1812 of file ac_common.php.

1812 {
1813 $errors=array();
1814 $error_code=array();
1815
1816 $len=strlen($password??"");
1817 if ( $len < 8) {
1818 $errors[] = _("mot de passe de 8 lettres minimum");
1819 $error_code[]=1;
1820 }
1821
1822 if (!preg_match("#[0-9]+#", $password)) {
1823 $errors[] = _("mot de passe doit inclure au moins un chiffre");
1824 $error_code[]=2;
1825 }
1826
1827 if (!preg_match("#[a-z]+#", $password)) {
1828 $errors[] = _("mot de passe doit inclure au moins une minuscule");
1829 $error_code[]=3;
1830 }
1831 if (!preg_match("#[A-Z]+#", $password)) {
1832 $errors[] = _("mot de passe doit inclure au moins une majuscule");
1833 $error_code[]=4;
1834 }
1835
1836 if ( $len > 0 ) {
1837 $cnt_diff=count(count_chars($password,1));
1838 $ratio_diff=$len/$cnt_diff;
1839
1840 if ($ratio_diff > 2) {
1841 $errors[] = _("Trop souvent le(s) même(s) symbole(s)");
1842 $error_code[]=5;
1843 }
1844 $special_char=preg_replace('/[[:alnum:]]/','',$password);
1845 if ( strlen($special_char??"")==0)
1846 {
1847 $errors[] = _("mot de passe doit inclure au moins un caractére spécial '+-/*[...'");
1848 $error_code[]=6;
1849
1850 }
1851 }
1852
1853 return array( 'msg'=>$errors, 'code'=>$error_code);
1854}

References _.

Referenced by generate_random_password().

◆ cmpDate()

cmpDate ( $p_date,
$p_date_oth )

Compare 2 dates.

Parameters
p_date
p_date_oth
Returns
  • == 0 les dates sont identiques
  • > 0 date1 > date2
  • < 0 date1 < date2

Definition at line 188 of file ac_common.php.

189{
190 date_default_timezone_set('Europe/Brussels');
191
192 $l_date = isDate($p_date);
193 $l2_date = isDate($p_date_oth);
194 if ($l_date == null || $l2_date == null)
195 {
196 throw new Exception("erreur date [$p_date] [$p_date_oth]");
197 }
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]);
202 // si $p_date > $p_date_oth return > 0
203 return $l_mkdate - $l2_mkdate;
204}
isDate($p_date)
Verifie qu'une date est bien formaté en d.m.y et est valable.

References $p_date, and isDate().

Referenced by Fiche\HtmlTable(), Acc_Ledger_Fin\verify_operation(), Acc_Ledger_Purchase\verify_operation(), and Acc_Ledger_Sale\verify_operation().

+ Here is the call graph for this function:

◆ complete_default_menu()

complete_default_menu ( $pa_menu)

Check if there is a default menu for this user and add it.

The array is filling from 1 to 3

* 
* COMPTA              0   -   0 - 173
* COMPTA/MENUACH      0   - 173 -   3
* COMPTA/MENUACH/ACH  173 -   3 -  85
* 
* 
Parameters
array$pa_menuif the array of option ; index pm_id_v1 , pm_id_v2 and pm_id_v3

Definition at line 1594 of file ac_common.php.

1595{
1596 $a_result=$pa_menu;
1597 // find the first one which is null
1598 if ($pa_menu[0]['pm_id_v2'] == 0) {
1599 $tmp=find_default_menu($pa_menu[0]['pm_id_v1']);
1600 if ( $tmp <> 0 ) {
1601 $a_result[0]['pm_id_v2']=$pa_menu[0]['pm_id_v1'];
1602 $a_result[0]['pm_id_v1']=$tmp;
1603 }
1604 }
1605 if ($pa_menu[0]['pm_id_v3'] == 0) {
1606 $tmp=find_default_menu($a_result[0]['pm_id_v1']);
1607 if ( $tmp <> 0 ) {
1608 $a_result[0]['pm_id_v3']=$a_result[0]['pm_id_v2'];
1609 $a_result[0]['pm_id_v2']=$a_result[0]['pm_id_v1'];
1610 $a_result[0]['pm_id_v1']=$tmp;
1611 }
1612 }
1613 return $a_result;
1614}
find_default_menu($pn_menu)
Find the menu marked as default in the given profile.

References $tmp, and find_default_menu().

+ Here is the call graph for this function:

◆ compute_letter_value()

compute_letter_value ( )

Definition at line 1956 of file ac_common.php.

1957 {
1958 global $aLetter,$aLetterValue;
1959
1960 static $make_string=null;
1961 if ( $make_string == null ) {
1962 for ($i=65;$i!=91;$i++) {
1963 $make_string[chr($i)]=$i-55;
1964 }
1965 $aLetter=array_keys($make_string);
1966 $aLetterValue=array_values($make_string);
1967 }
1968 }

References $i.

◆ compute_variable()

compute_variable ( $p_string)

the string has the format a=b&c=d, it is parsed and an array[][key,value] is returned

Parameters
$p_string
Returns
$array usable in put_global

Definition at line 1301 of file ac_common.php.

1302{
1303 $array=array();
1304 if ($p_string == '') return $array;
1305
1306 $var=explode("&",$p_string);
1307 if (empty ($var)) return $array;
1308 for ($i=0;$i < count($var);$i++)
1309 {
1310 $var2=explode('=',$var[$i]);
1311 $array[$i]['key']=$var2[0];
1312 $array[$i]['value']=$var2[1];
1313 }
1314 return $array;
1315}
$var
Definition ajax_card.php:64

References $array, $i, and $var.

Referenced by Noalyss\Mobile\execute_menu().

◆ confirm_with_string()

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 captcha.The control code for checking is ctlcode.

You compare the content of the variable p_ctl_name with ctlcode

Parameters
$p_ctl_namename of the HTML input text
$p_carlength of the string

Definition at line 1556 of file ac_common.php.

1557{
1558 $code=generate_random_string($p_car ,0);
1559 $r = HtmlInput::hidden("ctlcode",$code);
1560 $r.='<span style="margin-left:1.2em;margin-right:1.2em;font-size:120%;font-weight:bold;border:navy solid 1px ; padding:0.5rem">'. $code.'</span>';
1561 $ctl=new IText($p_ctl_name);
1562 $r.=$ctl->input();
1563 return $r;
1564}
generate_random_string($p_length, $special=1)
Create randomly a string.
static hidden($p_name, $p_value, $p_id="")
Html Input Text member :

References $code, $ctl, $r, and generate_random_string().

+ Here is the call graph for this function:

◆ convert_array_select()

convert_array_select ( $array)

convert an array KEY=>VALUE into a double array useable by \ISelect

Parameters
$array(array) array key=>value
Returns
double array array (array('value'=>'KEY','label'=>VALUE),...))
See also
ISelect

Definition at line 2046 of file ac_common.php.

2047{
2048 if (count($array) == 0 ) return null;
2049 $a_ret=array();$i=0;
2050 foreach ($array as $key=>$value) {
2051 $a_ret[$i]['value']=$key;
2052 $a_ret[$i]['label']=$value;
2053 $i++;
2054 }
2055 return $a_ret;
2056}

References $array, $i, and $value.

◆ convert_ini_unit()

convert_ini_unit ( $p_value)

convert a value in Mbytes, kb ... in byte

Parameters
(string)$p_value containing K , M, G
Returns
int in bytes

Definition at line 2026 of file ac_common.php.

2027{
2028 if ($p_value=="") return 0;
2029 $a_convert=["k"=>1024,"m"=>1024**2,"g"=>1024**3];
2030
2031 $p_value=trim($p_value);
2032 $last=strtolower($p_value[strlen($p_value)-1]);
2033 $p_value=substr($p_value,0,strlen($p_value)-1);
2034 if ( isset($a_convert[$last])) {
2035 $p_value=$p_value*$a_convert[$last];
2036 }
2037
2038 return $p_value;
2039}
if(! empty( $error)) for($i=0;$i< count($error);$i++)( $last !=$error[$i]) $last

References $last.

◆ convert_to_rtf()

if(!function_exists('tracedebug')) convert_to_rtf ( $p_string)

encode the string for RTF, return a string

Parameters
$p_stringstring to convert
Returns
string

Definition at line 1494 of file ac_common.php.

1495{
1496 $result="";
1497 $p_string2=mb_convert_encoding($p_string,'ISO-8859-1','UTF-8');
1498 $p_string2=iconv('UTF-8','ISO-8859-1//IGNORE',$p_string);
1499
1500
1501 $nb_result=strlen($p_string2);
1502 for ($i = 0 ; $i < $nb_result ; $i++ ){
1503 if (ord($p_string[$i]) < 127 ) {
1504 $result.=$p_string[$i];
1505 } else {
1506 $result.='\u'.ord($p_string[$i]).chr(92).chr(39).'3f';
1507 }
1508 }
1509 return $result;
1510}
for( $i=0;$i< $nb_match;$i++) if(empty($result)) $nb_result

References $i, $nb_result, and $result.

Referenced by Acc_Bilan\generate_plain().

◆ Decode()

Decode ( $p_html)

Decode the html for the widegt richtext and remove newline.

Parameters
$p_htmlstring to decode
Returns
the html code without new line

Definition at line 701 of file ac_common.php.

702{
703 $p_html = noalyss_str_replace('%0D', '', $p_html);
704 $p_html = noalyss_str_replace('%0A', '', $p_html);
705 $p_html = urldecode($p_html);
706 return $p_html;
707}
noalyss_str_replace($search, $replace, $string)

References noalyss_str_replace().

+ Here is the call graph for this function:

◆ display_menu()

display_menu ( $p_menuid)

Display a menu @global type $g_user.

Parameters
type$p_menuid
Returns
type

Definition at line 1201 of file ac_common.php.

1202{
1203 if ($p_menuid == 0) return;
1204 global $g_user;
1206
1207 $file = $cn->get_array("
1208 select me_file,me_parameter,me_javascript,me_type
1209 from menu_ref
1210 join profile_menu using (me_code)
1211 join profile_user using (p_id)
1212 where
1213 pm_id=$1 and
1214 user_name=$2 and
1215 (me_file is not null or trim(me_file) <>'' or
1216 me_javascript is not null or trim (me_javascript) <> '')", array($p_menuid,$g_user->login));
1217
1218 if (count($file)==0)
1219 {
1220 return;
1221 }
1222
1223 if ($file[0]['me_file'] != "")
1224 {
1225 if ($file[0]['me_parameter'] !== "")
1226 {
1227 // if there are paramter put them in superglobal
1228 $array=compute_variable($file[0]['me_parameter']);
1230 }
1231 \Noalyss\Dbg::echo_var(1,$file[0]['me_file']." ".$file[0]['me_parameter']);
1232 /*
1233 * Log the file we input to put in the folder test-noalyss for replaying it
1234 */
1235 if (LOGINPUT) {
1236 $file_loginput=fopen($_ENV['TMP'].'/scenario-'.$_SERVER['REQUEST_TIME'].'.php','a+');
1237 fwrite($file_loginput, "include '".$file[0]['me_file']."';");
1238 fwrite($file_loginput,"\n");
1239 fclose($file_loginput);
1240 }
1241 // if file is not a plugin, include the file, otherwise
1242 // include the plugin launcher
1243 if ( $file[0]['me_type'] != 'PL') {
1244 if (file_exists ($file[0]['me_file']) )
1245 {
1246 require_once $file[0]['me_file'];
1247 } elseif ( file_exists(NOALYSS_INCLUDE.'/'.$file[0]['me_file'])) {
1248 require_once NOALYSS_INCLUDE.'/'.$file[0]['me_file'];
1249 }else {
1250 echo echo_warning(_("Fichier non trouvé"));
1251 }
1252 } else {
1253 require 'extension_get.inc.php';
1254 }
1255
1256 exit();
1257 } elseif ( $file[0]['me_javascript'] != '')
1258 {
1259 $js= noalyss_str_replace('<DOSSIER>', dossier::id(), $file[0]['me_javascript']);
1260 echo create_script($js);
1261 }
1262
1263}
compute_variable($p_string)
the string has the format a=b&c=d, it is parsed and an array[][key,value] is returned
put_global($array)
Put in superglobal (get,post,request) the value contained in the parameter field (me_parameter)
echo_warning($p_string)
warns
global $g_user
if no group available , then stop
static connect()
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
for($e=0; $e< count($afiche); $e++) exit
create_script($p_string)
create the HTML for adding the script tags around of the script
if( $delta< 0) elseif( $delta==0)

References from, n, and p_id.

◆ echo_error()

echo_error ( $p_log,
$p_line = "",
$p_message = "" )

log error into the /tmp/noalyss_error.log it doesn't work on windows

Parameters
p_logmessage
p_lineline number
p_messageis the message
Returns
nothing

Definition at line 169 of file ac_common.php.

170{
171 $msg="ERREUR :" . $p_log . " " . $p_line . " " . $p_message;
172 echo $msg;
174
175}
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...

References $msg, and record_log().

Referenced by Database\format_name(), Fiche\get_row(), Fiche\get_row_date(), getPeriodeName(), isValid_deprecrated(), Document_Modele\Save(), sql_filter_per(), and Document_Modele\update().

+ Here is the call graph for this function:

◆ echo_warning()

echo_warning ( $p_string)

warns

Parameters
p_stringerror message gen :
  • none
Returns
:
  • none

Definition at line 642 of file ac_common.php.

643{
644 echo '<span class="warning">' . $p_string . '</span>';
645}

Referenced by Acc_Tax_Purchase_Sale\display(), Acc_Bilan\display_form(), Noalyss\Mobile\execute_menu(), Stock_Goods\input(), Template_Card_Category\input(), Extension\read_definition(), Dossier\synchro_admin(), and Dossier\upgrade().

◆ factory_Ledger()

factory_Ledger ( Database & $p_cn,
$ledger_id )

This function create a ledger object and return the right one.

It uses the factory pattern

Parameters
Database$p_cn
type$ledger_id
Returns
Acc_Ledger
Exceptions
Exception

Definition at line 1350 of file ac_common.php.

1351{
1352 $ledger=new Acc_Ledger($p_cn, $ledger_id);
1353 $type=$ledger->get_type();
1354
1355 switch ($type)
1356 {
1357 case 'VEN':
1358 $obj=new Acc_Ledger_Sale($p_cn, $ledger_id);
1359 break;
1360 case 'ACH':
1362 break;
1363 case 'FIN':
1364 $obj= new Acc_Ledger_Fin($p_cn, $ledger_id);
1365 break;
1366 case 'ODS':
1367 $obj=$ledger;
1368 break;
1369
1370 default:
1371 throw new Exception('Ledger type not found');
1372 }
1373 return $obj;
1374}
catch(Exception $e) $obj
if(isNumber($jr_id)==0) $ledger_id
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger
: input, confirm and save new operations in edger of purchase the $_POST data is an array with these ...
: input, confirm and save new operations in edger of sales the $_POST data is an array with these key...
Class for jrn, class acc_ledger for manipulating the ledger AND some acc.

References $ledger, $ledger_id, $obj, and $type.

◆ FaxTo()

FaxTo ( $p_tel)

compose a HTML string with fax

Parameters
string$p_faxfax number
Returns
false|string returns false if $p_fax is empty

Definition at line 1754 of file ac_common.php.

1754 {
1755 if (!empty($p_tel)) {
1756 $r=sprintf('<a href="fax:%s">%s</a>',h($p_tel),h($p_tel));
1757 return $r;
1758 }
1759 return false;
1760}
h( $row[ 'oa_description'])

References $r, and h.

◆ find_default_menu()

find_default_menu ( $pn_menu)

Find the menu marked as default in the given profile.

Parameters
number$pn_menu(profile_menu.id)

Definition at line 1569 of file ac_common.php.

1570{
1572 $sql = ' select pm_id from profile_menu where pm_default =1 and pm_id_dep = $1';
1573 $aresult=$cn->get_array($sql, [$pn_menu]);
1574 if (empty($aresult)) {
1575 return 0;
1576 }
1577 return $aresult[0]['pm_id'];
1578}

References $cn, and $sql.

Referenced by complete_default_menu().

◆ find_default_module()

find_default_module ( )

Definition at line 1044 of file ac_common.php.

1045{
1046 global $g_user;
1048
1049 $default_module = $cn->get_array("select me_code
1050 from profile_menu join profile_user using (p_id)
1051 where
1052 p_type_display='M' and
1053 user_name=$1 and pm_default=1", array($g_user->login));
1054
1055 /*
1056 * Try to find the smallest order for module
1057 */
1058 if (empty($default_module))
1059 {
1060 $default_module = $cn->get_array("select me_code
1061 from profile_menu join profile_user using (p_id)
1062 where
1063 p_type_display='M' and
1064 user_name=$1 order by p_order limit 1", array($g_user->login));
1065
1066 // if no default try to find the default menu
1067 if ( empty ($default_module))
1068 {
1069 $default_module = $cn->get_array("select me_code
1070 from profile_menu join profile_user using (p_id)
1071 where
1072 p_type_display='E' and
1073 user_name=$1 and pm_default=1 ", array($g_user->login));
1074 /*
1075 * Try to find a default menu by order
1076 */
1077 if (empty ($default_module))
1078 {
1079 $default_module = $cn->get_array("select me_code
1080 from profile_menu join profile_user using (p_id)
1081 where
1082 user_name=$1 and p_order=(select min(p_order) from profile_menu join profile_user using (p_id)
1083 where user_name=$2) limit 1", array($g_user->login, $g_user->login));
1084 }
1085
1086 /*
1087 * if nothing found, there is no profile for this user => exit
1088 */
1089 if (empty ($default_module))
1090 {
1091 /*
1092 * If administrateur, then we insert a default profile (1)
1093 * for him
1094 */
1095 if ( $g_user->admin == 1 )
1096 {
1097 $cn->exec_sql('insert into profile_user(user_name,p_id) values ($1,1) ',array($g_user->login));
1098 return find_default_module();
1099 }
1100 echo_warning(_("Utilisateur n'a pas de profil, votre administrateur doit en configurer un dans C0SEC"));
1101 exit();
1102 }
1103 }
1104 return $default_module[0]['me_code'];
1105 }
1106
1107 if (count($default_module) > 1)
1108 {
1109 // return the first module found
1110 return $default_module[0]['me_code'];
1111 }
1112 elseif (count($default_module) == 1)
1113 {
1114 return $default_module[0]['me_code'];
1115 }
1116}
find_default_module()

References p_id.

◆ find_idx()

find_idx ( $array,
$key,
$value )

retrieve the index for the key percent, returns -1 if nothing found

Parameters
$array(array) SubTotal
$key(string) name of the key
$value(string) value to look for
Returns
int

Definition at line 1945 of file ac_common.php.

1945 {
1946 if ( count($array) == 0 ) { return -1; }
1947 $nb_array=count($array);
1948 for($i=0;$i <$nb_array;$i++) {
1949 if ($array[$i][$key] == $value) {
1950 return $i;
1951 }
1952 }
1953 return -1;
1954}

References $array, $i, $nb_array, and $value.

Referenced by Noalyss\XMLDocument\XMLInvoice\build_data().

◆ findSide()

findSide ( $p_number)

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 )

Parameters
float$p_number

Definition at line 121 of file ac_common.php.

122{
123 $return ='';
124 if ( $p_number > 0 ) {
125 $return ='D';
126 }else {
127 $return =($p_number== 0)?"":"C";
128 }
129 return $return;
130}

Referenced by Anc_Listing\display_html().

◆ format_date()

format_date ( $p_date,
$p_from_format = 'YYYY-MM-DD',
$p_to_format = 'DD.MM.YYYY' )

format the date, when taken from the database the format is MM-DD-YYYY

Parameters
$p_dateformat
Exceptions
1if invalid format DOMEntity
Parameters

return date in the format DD.MM.YYYY

Definition at line 905 of file ac_common.php.

906{
907 if (empty($p_date)) {return $p_date;}
908 if ($p_from_format == 'YYYY-MM-DD')
909 {
910 $date = explode('-', $p_date);
911 if (count($date) != 3)
912 return $p_date;
913 }
914 if ($p_from_format == 'DD.MM.YYYY')
915 {
916 $temp_date = explode('.', $p_date);
917 if (count($temp_date) != 3)
918 return $p_date;
919 $date[0] = $temp_date[2]; // 0 is year
920 $date[1] = $temp_date[1]; // 1 for month
921 $date[2] = $temp_date[0]; // 2 for day
922 }
923
924 switch ($p_to_format)
925 {
926 case 'DD.MM.YYYY':
927 $str_date = $date[2] . '.' . $date[1] . '.' . $date[0];
928 break;
929 case 'DD-MM-YYYY':
930 $str_date = $date[2] . '-' . $date[1] . '-' . $date[0];
931 break;
932 case 'YYYY-MM-DD':
933 $str_date = $date[0] . '-' . $date[1] . '-' . $date[2];
934 break;
935 case 'YYYYMMDD':
936 $str_date = $date[0] . $date[1] . $date[2];
937 break;
938 case 'YYYY/MM/DD':
939 $str_date = $date[0] . '/' . $date[1] . '/' . $date[2];
940 break;
941 case "DD.MM.YY":
942 $str_date = $date[2] . '.' . $date[1] . '.' . substr($date[0],2,2);
943 break;
944 case "DD-MM-YY":
945 $str_date = $date[2] . '-' . $date[1] . '-' . substr($date[0],2,2);
946 break;
947 default:
948 throw new Exception(_("Format Invalide"),1);
949
950 }
951 return $str_date;
952}

Referenced by Stock\build_tmp_table(), Acc_Ledger_Sale\convert_to_array(), Anticipation\display(), Operation_Exercice\display_result(), Periode_Ledger_Table\display_row(), Periode\display_row_global(), Acc_Bilan\filter_date(), Acc_Account_Ledger\HtmlTable(), Fiche\HtmlTable(), Follow_Up\myList(), and Document\replace().

◆ FormatString()

FormatString ( $p_string)

replaced by sql_string

Deprecated

Definition at line 502 of file ac_common.php.

503{
504 return sql_string($p_string);
505}
sql_string($p_string)
Fix the problem with the quote char for the database.

References sql_string().

+ Here is the call graph for this function:

◆ generate_random_password()

generate_random_password ( $car)

generate a strong random password

Parameters
$carint length of the password, minimum 8

Definition at line 1860 of file ac_common.php.

1860 :string
1861{
1862 $string="";
1863 $car=($car < 8 )?8:$car;
1864 $max_loop=20;$loop=0;
1865 do
1866 {
1867 $loop++;
1868 $string="";
1869 $chaine="abcdefghijklmnpqrstuvwxy";
1870 // srand( (int)microtime()*1020030);
1871 for ($i=0; $i<$car; $i++)
1872 {
1873 $string .= $chaine[rand()%strlen($chaine)];
1874 }
1875 $chaine="ABCDEFGHIJKLMNPQRSTUVWXY";
1876 for ($i=0;$i<2;$i++) {
1877 $string[rand()%$car]=$chaine[rand()%strlen($chaine)];;
1878 }
1879 $chaine="0123456789";
1880 for ($i=0;$i<2;$i++) {
1881 $string[rand()%$car]=$chaine[rand()%strlen($chaine)];;
1882 }
1883 $special_set="+-/*;,.=:&()[]";
1884 $special_car=$special_set[rand()%strlen($special_set)];
1885 $string[rand()%$car]=$special_car;
1886 // echo $string."\n";
1887 }while ( count(check_password_strength($string)['msg'])> 0 && $loop<$max_loop);
1888 return $string;
1889}

References $i, $string, and check_password_strength().

+ Here is the call graph for this function:

◆ generate_random_string()

generate_random_string ( $p_length,
$special = 1 )

Create randomly a string.

Parameters
int$p_lengthlength of the generate string

Definition at line 1532 of file ac_common.php.

1533{
1534 $string="";
1535 if ($special == 1)
1536 $chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-=";
1537 if ($special == 0)
1538 $chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789";
1539 $microtime=microtime(true)*microtime(true)*100;
1540 srand(0);
1541 srand((int)$microtime);
1542 for ($i=0; $i<$p_length; $i++)
1543 {
1544 $string .= $chaine[rand()%strlen($chaine)];
1545 }
1546 return $string;
1547}

References $i, and $string.

Referenced by confirm_with_string(), and display_file_config().

◆ get_array_column()

get_array_column ( $p_array,
$key )

Definition at line 1329 of file ac_common.php.

1330{
1331 $array=array();
1332 for ($i=0;$i<count($p_array);$i++)
1333 {
1334 $r=$p_array[$i];
1335 if ( isset($r[$key])) {
1336 $array[]=$r[$key];
1337 }
1338 }
1339 return $array;
1340}

References $array, $i, $p_array, and $r.

◆ getPeriodeFromMonth()

getPeriodeFromMonth ( $p_cn,
$p_date )

Return the period corresponding to the date.

Parameters
p_cndatabase connection
p_datethe month + year 'MM.YYYY'
Returns
: parm_periode.p_id

Definition at line 686 of file ac_common.php.

687{
688 $R = $p_cn->get_value("select p_id from parm_periode where
689 to_char(p_start,'DD.MM.YYYY') = $1", array('01.'.$p_date));
690 if ($R == "")
691 return -1;
692 return $R;
693}

References $p_date.

◆ getPeriodeName()

getPeriodeName ( $p_cn,
$p_id,
$pos = 'p_start' )

Show the periode which found thanks its id.

Parameters
$p_cndatabase connection
p_id
posStart or end
Returns
: string

Definition at line 658 of file ac_common.php.

659{
660 if ($pos != 'p_start' && $pos != 'p_end')
661 {
662 echo_error('lib/ac_common.php' . "-" . __LINE__ . ' UNDEFINED PERIODE');
663 throw new Exception(_("paramètre invalide"));
664 }
665 if ( isNumber($p_id) == 0 )
666 {
667 throw new Exception("Paramètre invalide");
668 return;
669 }
670 $ret = $p_cn->get_value("select to_char($pos,'Mon YYYY') as t from parm_periode where p_id=$1",
671 array( $p_id));
672 return $ret;
673}
isNumber($p_int)
echo_error($p_log, $p_line="", $p_message="")
log error into the /tmp/noalyss_error.log it doesn't work on windows

References $p_id, $pos, $ret, _, echo_error(), and isNumber().

+ Here is the call graph for this function:

◆ guidv4()

guidv4 ( $data = null)

generate an UUID

Parameters
$data(string)if null use randow
Returns
string

Definition at line 1925 of file ac_common.php.

1925 {
1926 // Generate 16 bytes (128 bits) of random data or use the data passed into the function.
1927 $data = $data ?? random_bytes(16);
1928
1929
1930 // Set version to 0100
1931 $data[6] = chr(ord($data[6]) & 0x0f | 0x40);
1932 // Set bits 6-7 to 10
1933 $data[8] = chr(ord($data[8]) & 0x3f | 0x80);
1934
1935 // Output the 36 character UUID.
1936 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
1937}

References $data.

Referenced by Noalyss_User\send_code_otp(), and Noalyss_User\send_link_otp().

◆ h()

h ( $p_string)

to protect again bad characters which can lead to a cross scripting attack the string to be diplayed must be protected.

Side effects with htmlentities, especially for the date (transform dot in &periode;) and number

Definition at line 35 of file ac_common.php.

36{
37 return ( $p_string === null)?"":htmlspecialchars($p_string,ENT_QUOTES|ENT_HTML5,'UTF-8',true);
38}

References ENT_QUOTES.

◆ h1()

h1 ( $p_string,
$p_class = "" )
Examples
acc_ledger_historyTest.php, and inplace_edit.test.php.

Definition at line 72 of file ac_common.php.

73{
74 return '<h1 ' . $p_class . '>' . h($p_string) . '</h1>';
75}

References h.

Referenced by display_test(), Acc_Operation\test_me(), and Fiche\test_me().

◆ h2()

◆ h2info()

h2info ( $p_string)

Definition at line 63 of file ac_common.php.

64{
65 return '<h2 class="info">' . h($p_string) . '</h2>';
66}

References h.

Referenced by Anc_Balance_Double\display_html().

◆ hb()

hb ( $p_string)

Definition at line 53 of file ac_common.php.

54{
55 return '<b>' . h($p_string) . '</b>';
56}

References h.

Referenced by Acc_Ledger_Purchase\confirm(), and Acc_Ledger_Sale\confirm().

◆ header_csv()

header_csv ( $p_filename)

Send an header CSV with a filename.

Parameters
string$p_filename,filename , caution , it must be sanitized BEFORE calling this function

Definition at line 1268 of file ac_common.php.

1269{
1270
1271 header('Pragma: public');
1272 header('Content-type: application/csv');
1273 header("Content-Disposition: attachment;filename=\"{$p_filename}\"",
1274 FALSE);
1275 header('Cache-Control: no-store, no-cache, must-revalidate');
1276 header('Expires: Sun, 1 Jan 2000 12:00:00 GMT');
1277 header('Last-Modified: '.gmdate('D, d M Y H:i:s').'GMT');
1278}

◆ hi()

hi ( $p_string)

Definition at line 48 of file ac_common.php.

49{
50 return '<i>' . h($p_string) . '</i>';
51}

References h.

Referenced by Template_Card_Category\input().

◆ html_min_page_start()

html_min_page_start ( $p_theme = "",
$p_script = "",
$p_script2 = "" )

Minimal page header for each page, used for small popup window.

Parameters
p_themedefault theme
$p_script
$p_script2another js script
Returns
none

Definition at line 408 of file ac_common.php.

409{
410
411 $cn = new Database();
412 if ($p_theme != "")
413 {
414 $Res = $cn->exec_sql("select the_filestyle from theme
415 where the_name='" . $p_theme . "'");
416 if (Database::num_row($Res) == 0)
417 $style = "style-classic7.css";
418 else
419 {
421 $style = $s['the_filestyle'];
422 }
423 }
424 else
425 {
426 $style = "style-classic7.css";
427 } // end if
428 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN">';
429 echo "<HTML>";
430
431
432 if ($p_script2!="")
433 {
434 $p_script2='<script src="'.$p_script2.'" type="text/javascript"></script>';
435 }
436
437 echo "<HEAD>
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\">" .
442 $p_script2 . "
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>";
448
449 echo "<LINK id=\"pagestyle\" REL=\"stylesheet\" type=\"text/css\" href=\"css/font/fontello/css/fontello.css\" media=\"screen\"/>";
450
451 // Retrieve colors for this folder
452 if ( isset($_REQUEST['gDossier']) ) {
454 $noalyss_appearance->print_css();
455 }
456 echo '</HEAD>';
457 echo "<BODY $p_script>";
458 /* If we are on the user_login page */
459 if (basename($_SERVER['PHP_SELF']) == 'user_login.php')
460 {
461 return;
462 }
463}
$_REQUEST['ac']
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
Contains some parameters to change appearance of noalyss, the colors are saved into the table parm_ap...
$noalyss_appearance

References $_REQUEST, $cn, $noalyss_appearance, $Res, $s, $style, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ html_page_start()

html_page_start ( $p_theme = "",
$p_script = "",
$p_script2 = "" )

Default page header for each page.

Parameters
p_themedefault theme
$p_script
$p_script2another js script Must be called only once
Returns
none
Examples
acc_ledger_historyTest.php, and inplace_edit.test.php.

Definition at line 275 of file ac_common.php.

276{
277 // check not called twiced
278 static $already_call=0;
279 if ( $already_call==1)return;
280 $already_call=1;
281
282 $cn = new Database();
283 if ($p_theme != "")
284 {
285 $Res = $cn->exec_sql("select the_filestyle from theme
286 where the_name=$1" ,[$p_theme]);
287 if (Database::num_row($Res) == 0)
288 {
289 $style = "style-classic7.css";
290 }
291 else
292 {
294 $style = $s['the_filestyle'];
295 }
296 }
297 else
298 {
299 $style = "style-classic7.css";
300 } // end if
301 $title="NOALYSS";
302
303 if ( isset ($_REQUEST['ac'])) {
304 $ac=strip_tags($_REQUEST['ac']);
305 if (strpos($ac,'/') <> 0)
306 {
307 $m= explode('/',$ac);
308 $title=$m[count($m)-1]." ".$title;
309 }
310 else
311 $title=$ac." ".$title;
312 }
313 $is_msie=is_msie();
314
315 if ($is_msie == 0 )
316 {
317 echo '<!DOCTYPE html>';
318 printf("\n");
319
320 }
321 else {
322 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN" >';
323 printf("\n");
324 }
325 echo '<HTML>';
326
327 if ($p_script2!="")
328 {
329 $p_script2='<script src="'.$p_script2.'" type="text/javascript"></script>';
330 }
331 $style=trim($style);
332 echo "<HEAD>";
333 echo '<meta charset="utf-8">';
334 echo "<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
335 if ($is_msie==1)
336 {
337 echo ' <meta http-equiv="x-ua-compatible" content="IE=edge"/>';
338 }
339 global $version_noalyss;
340 echo <<<EOF
341 <TITLE>$title</TITLE>
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"/>
348 $p_script2
349EOF;
350 // preload font
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" />';
354
355 echo '<script language="javascript" src="js/calendar.js"></script>
356 <script type="text/javascript" src="js/lang/calendar-en.js"></script>';
357
358 if (isset($_SESSION[SESSION_KEY.'g_lang']) && $_SESSION[SESSION_KEY.'g_lang']=='fr_FR.utf8' )
359 {
360 echo '<script type="text/javascript" src="js/lang/calendar-fr.js"></script>';
361 }
362 if (isset($_SESSION[SESSION_KEY.'g_lang']) && $_SESSION[SESSION_KEY.'g_lang']=='nl_NL.utf8' )
363 {
364 echo '<script type="text/javascript" src="js/lang/calendar-nl.js"></script>';
365 }
366 echo '
367 <script language="javascript" src="js/calendar-setup.js"></script>
368 <LINK REL="stylesheet" type="text/css" href="css/calendar-blue.css" media="screen">
369 ';
370 // language
371 if (isset($_SESSION[SESSION_KEY.'g_lang']))
372 {
373 set_language();
374 }
375
376 echo load_all_script();
377
378 // Retrieve colors for this folder
379 if ( isset($_REQUEST['gDossier']) ) {
381 $noalyss_appearance->print_css();
382 }
383 echo ' </HEAD> ';
384
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">'.
390 '</div>'.
391 '<p style="text-align:center">'.
392 HtmlInput::button_action('Valider','$(\'error_div\').style.visibility=\'hidden\';$(\'error_content_div\').innerHTML=\'\';').
393 '</p>'.
394 '</div>';
395
396}
is_msie()
Check if we use IE 8 or 9.
if(isset( $_REQUEST[ 'show'])) if(isset($_REQUEST['del'])) $ac
$from_poste name
$input_from type
else $card content[$j]['j_montant']
static button_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
button Html with javascript
global $version_noalyss
Definition constant.php:26
load_all_script()
load all the javascript only one time

References $_REQUEST, $ac, $cn, $m, $noalyss_appearance, $Res, $s, $style, $title, $version_noalyss, _, content, DatabaseCore\fetch_array(), is_msie(), load_all_script(), name, DatabaseCore\num_row(), and type.

Referenced by Acc_Ledger\test_me().

+ Here is the call graph for this function:

◆ html_page_stop()

html_page_stop ( )

end tag

Definition at line 470 of file ac_common.php.

471{
472 echo "</BODY>";
473 echo "</HTML>";
474}

◆ is_msie()

is_msie ( )

Check if we use IE 8 or 9.

Returns
int 1 for IE8-9;0 otherwise

Definition at line 1379 of file ac_common.php.

1380{
1381 if ( strpos ($_SERVER['HTTP_USER_AGENT'],'MSIE 8.0') != 0 ||
1382 strpos ($_SERVER['HTTP_USER_AGENT'],'MSIE 9.0') != 0 )
1383 $is_msie=1;
1384 else
1385 $is_msie=0;
1386 return $is_msie;
1387}

Referenced by html_page_start().

◆ isDate()

isDate ( $p_date)

Verifie qu'une date est bien formaté en d.m.y et est valable.

Parameters
$p_date
Returns
  • null si la date est invalide ou malformaté
  • $p_date si tout est bon

Definition at line 236 of file ac_common.php.

237{
238 if (noalyss_strlentrim($p_date) == 0)
239 return null;
240 if (preg_match("/^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}$/", $p_date) == 0)
241 {
242
243 return null;
244 }
245 else
246 {
247 $l_date = explode(".", $p_date);
248
249 if (sizeof($l_date) != 3)
250 return null;
251
252 if ($l_date[2] > COMPTA_MAX_YEAR || $l_date[2] < COMPTA_MIN_YEAR)
253 {
254 return null;
255 }
256
257 if (checkdate($l_date[1], $l_date[0], $l_date[2]) == false)
258 {
259 return null;
260 }
261 }
262 return $p_date;
263}
noalyss_strlentrim($p_string)
const COMPTA_MIN_YEAR
Definition constant.php:145
const COMPTA_MAX_YEAR
Definition constant.php:144

References $p_date, COMPTA_MAX_YEAR, COMPTA_MIN_YEAR, and noalyss_strlentrim().

Referenced by Anc_Print\check(), Currency_MTable\check(), Todo_List\check(), HttpInput\check_type(), cmpDate(), Acc_Ledger_Fin\confirm(), Follow_Up\create_query(), Anc_Table\create_temp_table_account(), Anc_Table\create_temp_table_card(), Acc_Bilan\filter_date(), Acc_Reconciliation\filter_date(), Follow_Up\fromArray(), Acc_Currency\get_rate_date(), Periode\insert(), Acc_Operation\operation_update_date_limit(), Stock_Goods\record_save(), Acc_Ledger\reverse(), Tax_Summary\set_date_end(), Tax_Summary\set_date_start(), Anc_Acc_Link\set_sql_filter(), sql_filter_per(), Follow_Up\verify(), Todo_List\verify(), Acc_Ledger_Fin\verify_operation(), Acc_Ledger_Purchase\verify_operation(), and Acc_Ledger_Sale\verify_operation().

+ Here is the call graph for this function:

◆ isNumber()

◆ j()

j ( $p_string)

escape correctly php string to javascript

Definition at line 96 of file ac_common.php.

97{
98 $a = preg_replace("/\r?\n/", "\\n", addslashes($p_string));
99 $a = noalyss_str_replace("'", '\'', $a);
100 return $a;
101}

References $a, and noalyss_str_replace().

Referenced by alert().

+ Here is the call graph for this function:

◆ linkTo()

linkTo ( $p_url)

Definition at line 1761 of file ac_common.php.

1762{
1763 if (empty($p_url) ) return "";
1764 if (filter_var(trim($p_url,FILTER_VALIDATE_URL)) ) {
1765 return sprintf('<a href="%s" target="_blank">%s</a>',$p_url,$p_url);
1766 } else {
1767 return $p_url;
1768 }
1769}

References $p_url.

Referenced by Card_Property\add_link().

◆ mailTo()

mailTo ( $p_email)

compose a HTML string with email

Parameters
string$p_emailemail or emails separated by a comma
Returns
false|string returns false if email not valide

Definition at line 1727 of file ac_common.php.

1727 {
1728 if (empty($p_email )) return "";
1729 $nComma=preg_match("/,/",$p_email);
1730 if ( $nComma > 0) {
1731 $aEmail=explode(",",$p_email);
1732 } else {
1733 $aEmail[0]=$p_email;
1734 }
1735 $r="";
1736 foreach ($aEmail as $email) {
1737 if ( filter_var(trim($email),FILTER_VALIDATE_EMAIL) ) {
1738 $r.=sprintf('<a href="mailto:%s">%s</a> ',h($email),h($email));
1739 } else {
1740 $r.=sprintf("%s",h($email));
1742
1743 }
1744
1745 }
1746 return $r;
1747}
static warnbulle($p_comment)
Display a warning in a bubble, text is in message_javascript.

References $r, h, and Icon_Action\warnbulle().

Referenced by Card_Property\add_link().

+ Here is the call graph for this function:

◆ MaintenanceMode()

MaintenanceMode ( $p_file)

When you want to prevent users to connect, create a file in noalyss/ (NOALYSS_BASE) with the message in Html.

Parameters
string$p_filefile in NOALYSS_BASE

Definition at line 1775 of file ac_common.php.

1776{
1777 if ( file_exists(NOALYSS_BASE."/".$p_file )) {
1778 include NOALYSS_BASE."/".$p_file;
1779 exit;
1780 }
1781}

References exit.

◆ nb()

nb ( $p_number)

format the number for the CSV export

Parameters
$p_numbernumber

Definition at line 107 of file ac_common.php.

108{
109 $r=trim($p_number);
110 $r = sprintf('%.4f', $p_number);
111 $r = noalyss_str_replace('.', ',', $r);
112
113 return $r;
114}

References $r, and noalyss_str_replace().

Referenced by Acc_Ledger\__construct(), Sort_Table\__construct(), Sort_Table\add(), Acc_Ledger\convert_from_follow(), Tax_Detail\csv(), Anc_Balance_Double\display_pdf(), Calendar\fill_from_todo(), Sort_Table\get_header(), Acc_Ledger\input(), and PDF_Operation\print_operation_info().

+ Here is the call graph for this function:

◆ nbm()

nbm ( $p_number,
$p_dec = 2 )

format the number with a sep.

for the thousand

Parameters
$p_numbernumber
$p_decnumber of decimal to display

Definition at line 137 of file ac_common.php.

138{
139
140 if (noalyss_trim($p_number) == '')
141 return '';
142 if ($p_number == 0)
143 return "0,00";
144
145 $a = doubleval($p_number);
146 $r = number_format($a, $p_dec, ",", ".");
147 if (trim($r) == '')
148 {
149 var_dump($r);
150 var_dump($p_number);
151 var_dump($a);
152 exit();
153 }
154
155 return $r;
156}

References $a, $r, exit, and noalyss_trim().

Referenced by Acc_Ledger\confirm(), Acc_Ledger_Fin\confirm(), Acc_Ledger_Purchase\confirm(), Acc_Ledger_Sale\confirm(), Noalyss\Widget\Mini_Report\display(), Anc_Acc_List\display_html(), Anc_Balance_Double\display_html(), Anc_Balance_Simple\display_html(), Anc_GrandLivre\display_html(), Anc_Listing\display_html(), Anc_Table\display_html(), Anc_Balance_Simple\display_pdf(), Additional_Tax\display_row(), Forecast_Item_MTable\display_row(), Manage_Table_SQL\display_row(), Operation_Exercice\display_row(), Operation_Exercice\display_total(), Print_Ledger_Detail\export(), Print_Ledger_Detail_Item\export(), Print_Ledger_Financial\export(), Print_Ledger_Misc\export(), Print_Ledger_Simple\export(), Print_Operation_Currency\export_csv(), Print_Operation_Currency\export_html(), Acc_Ledger_History_Generic\export_oneline_html(), Print_Ledger_Financial\Footer(), Print_Ledger_Simple\Footer(), Acc_Operation\form_clone_operation(), Print_Ledger_Financial\Header(), Print_Ledger_Simple\Header(), Acc_Account_Ledger\HtmlTable(), Fiche\HtmlTable(), Acc_Ledger_Fin\insert(), Acc_Ledger_Search\list_operation(), Acc_Ledger_Search\list_operation_to_reconcile(), PDF_Anc_Acc_List\pdf_card(), PDF_Operation\print_acc_writing(), PDF_Operation\print_anc_detail(), PDF_Operation\print_operation_info(), PDF_Operation\print_other_tax(), PDF_Operation\print_purchase(), PDF_Operation\print_sale(), PDF_Anc_Acc_List\put_total(), Fiche\Summary(), Acc_Balance\summary_display(), and Acc_Balance\summary_display_pdf().

+ Here is the call graph for this function:

◆ NoAccess()

NoAccess ( $js = 1)

Echo no access and stop.

Returns
nothing

Definition at line 482 of file ac_common.php.

483{
484 if ($js == 1)
485 {
486 echo "<script>";
487 echo "alert ('" . _('Cette action ne vous est pas autorisée Contactez votre responsable') . "');";
488 echo "</script>";
489 }
490 else
491 {
492 echo '<div class="redcontent">';
493 echo '<h2 class="error">' . _(' Cette action ne vous est pas autorisée Contactez votre responsable') . '</h2>';
494 echo '</div>';
495 }
496 exit - 1;
497}

References $js, _, and exit.

◆ noalyss_bcadd()

noalyss_bcadd ( $p_first,
$p_second,
$p_decimal = 4 )

Definition at line 1675 of file ac_common.php.

1676{
1677 $p_first=(empty($p_first))?0:$p_first;
1678 $p_second=(empty($p_second))?0:$p_second;
1679 return bcadd($p_first,$p_second,$p_decimal);
1680}

Referenced by Print_Ledger_Detail_Item\export(), and Document\replace().

◆ noalyss_bcmul()

noalyss_bcmul ( $p_first,
$p_second )

Definition at line 1686 of file ac_common.php.

1687{
1688 $p_first=(empty($p_first))?0:$p_first;
1689 $p_second=(empty($p_second))?0:$p_second;
1690 return bcmul($p_first??0,$p_second??0);
1691}

Referenced by Document\replace().

◆ noalyss_bcsub()

noalyss_bcsub ( $p_first,
$p_second,
$p_decimal = 4 )

Definition at line 1669 of file ac_common.php.

1670{
1671 $p_first=(empty($p_first))?0:$p_first;
1672 $p_second=(empty($p_second))?0:$p_second;
1673 return bcsub($p_first,$p_second,$p_decimal);
1674}

Referenced by Print_Ledger_Detail_Item\export(), and Acc_Ledger\previous_amount().

◆ noalyss_explode()

noalyss_explode ( $separator,
$string )

to avoid deprecated in PHP8.1 : explode cannot use a null

Parameters
$separator
$string
Returns
array | empty string

Definition at line 1705 of file ac_common.php.

1705 {
1706 if ($string===null) return '';
1707 return explode($separator,$string);
1708}

References $string.

Referenced by Acc_Ledger\display_ledger().

◆ noalyss_round()

noalyss_round ( $p_first,
$p_second )

Definition at line 1692 of file ac_common.php.

1693{
1694 $p_first=(empty($p_first))?0:$p_first;
1695 $p_second=(empty($p_second))?0:$p_second;
1696 return round($p_first??0,$p_second??0);
1697}

Referenced by Document\replace().

◆ noalyss_str_replace()

◆ noalyss_strip_tags()

noalyss_strip_tags ( $p_string)

Definition at line 1681 of file ac_common.php.

1682{
1683 if ($p_string===null) return "";
1684 return strip_tags($p_string);
1685}

Referenced by Card_Property\update().

◆ noalyss_strlen()

noalyss_strlen ( $p_string)

Definition at line 1653 of file ac_common.php.

1653 :int{
1654 if ($p_string ==null ) return 0;
1655 else return strlen($p_string);
1656}

References if, and return.

Referenced by Manage_Table_SQL\input().

◆ noalyss_strlentrim()

◆ noalyss_trim()

noalyss_trim ( $p_string)

◆ p()

p ( $p_string,
$p_extra = '' )

Definition at line 39 of file ac_common.php.

40{
41 return '<p '.$p_extra.'>'.$p_string."</p.>";
42}

Referenced by ajax_disconnected(), and Fiche\test_me().

◆ phoneTo()

phoneTo ( $p_tel)

compose a HTML string with phone

Parameters
string$p_tel
Returns
false|string returns false if $p_tel is empty

Definition at line 1714 of file ac_common.php.

1714 {
1715 if (!empty($p_tel)) {
1716 $r=sprintf('<a href="tel:%s">%s</a>',h($p_tel),h($p_tel));
1717 return $r;
1718 }
1719 return false;
1720}

References $r, and h.

◆ put_global()

put_global ( $array)

Put in superglobal (get,post,request) the value contained in the parameter field (me_parameter)

Parameters
$array[key] [value]

Definition at line 1284 of file ac_common.php.

1285{
1286 for ($i=0;$i<count($array);$i++)
1287 {
1288 $key=$array[$i]['key'];
1289 $value=$array[$i]['value'];
1290 $_GET[$key]=$value;
1291 $_POST[$key]=$value;
1292 $_REQUEST[$key]=$value;
1293 }
1294}
$_GET['qcode']
$_POST['ac']
Definition do.php:323

References $_GET, $_POST, $_REQUEST, $array, $i, and $value.

Referenced by Noalyss\Mobile\execute_menu(), and Dossier\set_current().

◆ rebuild_access_code()

rebuild_access_code ( $pan_code)

rebuild the access code

See also
complete_default_menu
Parameters
arrayof number $pan_code index row [0] = index pm_id_v1 , pm_id_v2 and pm_id_v3

Definition at line 1620 of file ac_common.php.

1621{
1622 if ( empty ($pan_code)) {return;}
1623 $s_result="";
1625 $an_code=['pm_id_v3','pm_id_v2','pm_id_v1'];
1626 $sep="";
1627 for ($i=0;$i<3;$i++)
1628 {
1629 $ix=$an_code[$i];
1630 $s_result.=$sep.$cn->get_value("select me_code from profile_menu where pm_id=$1",[ $pan_code[0][$ix] ]);
1631 $sep=($s_result != "" )?"/":"";
1632 }
1633 return $s_result;
1634}

References $cn, $i, $ix, and $sep.

◆ record_log()

record_log ( $p_message)

Record an error message into the log file of the server or in the log folder of NOALYSS Record also the GET and POST data.

Parameters
$p_messagestring message to display

Definition at line 1393 of file ac_common.php.

1394{
1395 $date= date ('Y-m-d');
1396 // variable: $handle_log resource on log file ,
1397 $handle_log=fopen(NOALYSS_BASE."/log/noalyss-{$date}.log","a+");
1398
1399 if ($handle_log == false )
1400 {
1401 if ( isset ($_SERVER['REMOTE_ADDR']) ) error_log(sprintf("origin %s\n",$_SERVER['REMOTE_ADDR']));
1402 if ( isset ($_SERVER['HTTP_USER_AGENT']) ) error_log(sprintf("agent %s\n",$_SERVER['HTTP_USER_AGENT']));
1403 if ( gettype ($p_message) == "object" && method_exists($p_message,"getTraceAsString") == 1) {
1404 $exc=$p_message;
1405 do {
1406 error_log("noalyss exception File [".$exc->getFile().":".$exc->getLine()."]",0);
1407 error_log("noalyss exception Message [".$exc->getMessage()."]",0);
1408 error_log("noalyss exception Code [".$exc->getCode()."]",0);
1409 error_log("noalyss exception Trace ".$exc->getTraceAsString(),0);
1410 error_log("------ ",0);
1411 $exc=$exc->getPrevious();
1412 if ($exc != null )fwrite ($handle_log,"*********************** Previous *********************** \n");
1413 } while ($exc != null);
1414 } else {
1415 error_log("noalyss".var_export($p_message,true),0);
1416
1417 }
1418 error_log("noalyss GET [".json_encode($_GET,0,10)."]");
1419 error_log("_POST [".json_encode($_POST,0,10)."]",0);
1420 } else {
1421 if ( isset ($_SERVER['REMOTE_ADDR']) ) fwrite($handle_log,sprintf("origin %s\n",$_SERVER['REMOTE_ADDR']));
1422 if ( isset ($_SERVER['HTTP_USER_AGENT']) ) fwrite($handle_log,sprintf("agent %s\n",$_SERVER['HTTP_USER_AGENT']));
1423
1424 if ( gettype ($p_message) == "object" && method_exists($p_message,"getTraceAsString") == 1) {
1425
1426 error_log("noalyss exception ".$p_message->getMessage(),0);
1427 error_log("noalyss exception".$p_message->getTraceAsString(),0);
1428 } else {
1429 error_log("noalyss".var_export($p_message,true),0);
1430
1431 }
1432
1433 $now=date ('Y-m-d H:i:s');
1434 fwrite ($handle_log,str_repeat("=", 80)."\n");
1435 fwrite ($handle_log,"ERROR: {$now}\n");
1436 fwrite($handle_log,"noalyss GET [".var_export($_GET,true)."]");
1437 fwrite ($handle_log,"\n");
1438 fwrite($handle_log,"_POST [".var_export($_POST,true)."]");
1439 fwrite ($handle_log,"\n");
1440 if ( gettype ($p_message) == "object" && method_exists($p_message,"getTraceAsString") == 1) {
1441 $exc=$p_message;
1442 do {
1443 fwrite($handle_log,"noalyss exception File [".$exc->getFile().":".$exc->getLine()."]");
1444 fwrite ($handle_log,"\n");
1445 fwrite($handle_log,"noalyss exception Message [".$exc->getMessage()."]");
1446 fwrite ($handle_log,"\n");
1447 fwrite($handle_log,"noalyss exception Code [".$exc->getCode()."]");
1448 fwrite ($handle_log,"\n");
1449 fwrite($handle_log,"noalyss exception Trace \n".$exc->getTraceAsString());
1450 fwrite ($handle_log,"\n");
1451 $exc=$exc->getPrevious();
1452 if ($exc != null )fwrite ($handle_log,"*********************** Previous *********************** \n");
1453 } while ($exc != null);
1454 } else {
1455 fwrite($handle_log,"noalyss".var_export($p_message,true));
1456 fwrite ($handle_log,"\n");
1457
1458 }
1459
1460 fwrite ($handle_log,str_repeat("=", 80)."\n");
1461 fclose($handle_log);
1462
1463 }
1464
1465}
1466if(!function_exists('tracedebug')) {
1467 function tracedebug($file,$var, $label = NULL) {
1468
1469 $tmp_file = sys_get_temp_dir().DIRECTORY_SEPARATOR.$file;
1470 $file_loginput=fopen( $tmp_file,'a+');
1471 if ( $file_loginput == false) { return;}
1472 $output = '';
1473 $output .= date('d-m-y H:i');
1474 if(!is_null($label)) {
1475 $output .= $label . ': ';
1476 }
1477 if ( gettype ($var) == 'object' && get_class($var)=='DOMDocument')
1478 {
1479 $var->formatOutput=true;
1480 $output.=$var->saveXML() .PHP_EOL;
1481 } else
1482 {
1483 $output .= print_r($var, 1) . PHP_EOL;
1484 }
1485
1486 file_put_contents($tmp_file, $output, FILE_APPEND);
1487 }
1488}

References $_GET, $_POST, and $date.

Referenced by Anc_Group_Operation\add(), Sendmail_Core\compose(), Noalyss_Csv\correct_name(), Action_Document_Type_MTable\delete(), Acc_Ledger\delete_ledger(), Card_Multiple\display_option(), echo_error(), DatabaseCore\exec_sql(), Acc_Document\export_file(), Table_Data_SQL\get_all_to_array(), Anc_Operation\get_balance(), Fiche\get_bank_ledger(), Acc_Ledger\input(), Acc_Ledger_Purchase\input(), Action_Document_Type_MTable\input(), Acc_Ledger_Fin\insert(), Acc_Ledger_Info\insert(), Acc_Ledger_Purchase\insert(), Acc_Ledger_Sale\insert(), Fiche\insert(), Periode\insert(), Periode\insert_exercice(), Acc_Bilan\load(), Document_Export\make_zip(), Document\parseDocument(), Stock_Goods\record_save(), Acc_Ledger\reverse(), Document_Modele\Save(), Anc_Group_Operation\save(), Anc_Key\save(), Default_Menu\save(), Lettering\save(), Pre_op_ach\save(), Pre_Op_Advanced\save(), Pre_op_fin\save(), Pre_op_ods\save(), Pre_op_ven\save(), Pre_operation\save_insert(), Acc_Document\save_receipt(), Noalyss_User\send_code_otp(), Noalyss_User\send_link_otp(), Acc_Ledger_History\set_ledger_type(), Follow_Up\sql_security_filter(), Dossier\synchro_admin(), Acc_Ledger\test_me(), Document\transform2pdf(), Acc_Ledger_Info\update(), Card_Property\update(), Document_Modele\update(), DatabaseCore\upload(), and Acc_Ledger\verify_ledger().

◆ remove_divide_zero()

remove_divide_zero ( $p_formula)

When it is needed to eval a formula , this function prevent the divide by zero.

the formula is a math operation to evaluate like : 1.0+2.0/1 (...) , it is used in "report", it removes the operation "divide by 0 "

Parameters
string$p_formulastring containing a operation to evaluate
See also
Impress\parse_formula

Definition at line 1520 of file ac_common.php.

1521{
1522 $test=noalyss_str_replace(" ","",$p_formula).";";
1523 $p_formula=preg_replace("![0-9]+\.*[0-9]*/0\.{0,1}0*(\+|-|\*|/|;){1}!","0$1",$test);
1524 $p_formula=trim($p_formula,';');
1525 return $p_formula;
1526}

References noalyss_str_replace().

Referenced by Impress\parse_formula().

+ Here is the call graph for this function:

◆ sanitize_filename()

sanitize_filename ( $filename,
$with_date = true )

removed invalid character when computing a filename, the suffix is kept

Parameters
$filenameString filename to sanitize
$with_date(bool) true add the date in the filename, false do not add it
Returns
string without offending char

Definition at line 1897 of file ac_common.php.

1898{
1899 // save the suffix
1900 $pos_prefix=strrpos($filename, ".");
1901 if ($pos_prefix==0)
1902 {
1903 $filename_suff=".pdf";
1904 $filename.=$filename_suff;
1905 $pos_prefix=strrpos($filename, ".");
1906 }
1907 else
1908 $filename_suff=substr($filename, $pos_prefix, strlen($filename));
1909
1910 $filename=str_replace(array('/', '*', '<', '>', ';', ',', '\\', '.', ':', '(', ')', ' ', '[', ']'), "-", $filename);
1911
1912 $filename_no=substr($filename, 0, $pos_prefix);
1913 if ( $with_date)
1914 $new_filename=strtolower($filename_no)."-".date("Ymd-Hi").$filename_suff;
1915 else
1916 $new_filename=strtolower($filename_no).$filename_suff;
1917
1918 return $new_filename;
1919}

Referenced by Card_PDF\export().

◆ set_language()

set_language ( )

set the lang thanks the _SESSION['g_lang'] var.

Definition at line 807 of file ac_common.php.

808{
809 // desactivate local check
810 if (defined("LOCALE")&&LOCALE==0)
811 {
812 return;
813 }
814 if (!isset($_SESSION[SESSION_KEY.'g_lang']))
815 {
816 return;
817 }
818
819 /*
820 * If translation is not supported by current
821 */
822 if (!function_exists("bindtextdomain"))
823 {
824 return;
825 }
826
827 $dir = "";
828 // set differently the language depending of the operating system
829 if (what_os() == 1)
830 {
831 $dir = setlocale(LC_MESSAGES, $_SESSION[SESSION_KEY.'g_lang']);
832 if ($dir == "")
833 {
834 $g_lang = 'fr_FR.utf8';
835 $dir = setlocale(LC_MESSAGES, $g_lang);
836 // echo '<span class="notice">' . $_SESSION[SESSION_KEY.'g_lang'] . ' domaine non supporté</h2>';
837 }
838 bindtextdomain('messages', NOALYSS_HOME.'/lang');
839 textdomain('messages');
840 bind_textdomain_codeset('messages', 'UTF8');
841
842 return;
843 }
844 // for windows
845 putenv('LANG=' . $_SESSION[SESSION_KEY.'g_lang']);
846 $dir = setlocale(LC_ALL, $_SESSION[SESSION_KEY.'g_lang']);
847 bindtextdomain('messages', '.\\lang');
848 textdomain('messages');
849 bind_textdomain_codeset('messages', 'UTF8');
850}
what_os()
try to determine on what os you are running the pĥpcompte server
if(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...

References domaine, and span().

+ Here is the call graph for this function:

◆ show_menu()

show_menu ( $module)

show the module

Parameters
$modulethe $_REQUEST['ac'] exploded into an array
$idxthe index of the array : the AD code is splitted into an array thanks the slash

Show the submenus

Definition at line 1123 of file ac_common.php.

1124{
1125 if ($module == 0)return;
1126 global $level, $g_user;
1127 $http=new HttpInput();
1128 $access_code=$http->request("ac");
1130 /**
1131 * Show the submenus
1132 */
1133 $amenu = $cn->get_array("
1134 select
1135 pm_id,
1136 me_code,
1137 pm_id_dep,
1138 me_file,
1139 me_javascript,
1140 me_url,
1141 me_menu,
1142 me_description,
1143 me_description_etendue
1144 from profile_menu
1145 join menu_ref using (me_code)
1146 where pm_id_dep=$1 and p_id=$2
1147 order by p_order", array($module, $g_user->get_profile()));
1148
1149 // There are submenuS, so show them
1150 if (!empty($amenu) && count($amenu) > 1)
1151 {
1152 $a_style_menu=array('topmenu','menu2','menu3');
1153 if ( $level >= count($a_style_menu))
1154 $style_menu='menu3';
1155 else {
1156 $style_menu=$a_style_menu[$level];
1157 }
1158 require NOALYSS_TEMPLATE.'/menu.php';
1159 $level++;
1160 return;
1161 } elseif (count($amenu) == 1)
1162 {
1163 // there is only one submenu so we include the code or javascript
1164 // or we show the submenu
1165 if ( trim($amenu[0]['me_url']??"") != "" ||
1166 trim ($amenu[0]['me_file']??"") != "" ||
1167 trim ($amenu[0]['me_javascript']??"") != "" )
1168 {
1169 echo '<div class="topmenu">';
1170 echo h2info(_($amenu[0]['me_menu']));
1171 echo '</div>';
1172 $module = $amenu[0]['pm_id'];
1174 $level++;
1175 return;
1176 } else {
1177 $url=$access_code.'/'.$amenu[0]['me_code'];
1178 echo '<a href="do.php?gDossier='.Dossier::id().'&ac='.$url.'">';
1179 echo _($amenu[0]['me_menu']);
1180 echo '</a>';
1181 $level++;
1182 return;
1183 }
1184 }
1185
1186 // !!! this point should never be reached
1187 // There is no submenu or only one
1188 if (empty($amenu) || count($amenu) == 1)
1189 {
1191
1192 }
1193 $level++;
1194}
display_menu($p_menuid)
Display a menu @global type $g_user.
h2info($p_string)
Definition ac_common.php:63
manage the http input (get , post, request) and extract from an array
foreach(array('magic_quotes_gpc', 'magic_quotes_runtime') as $a) $module
Definition install.php:411

References from, and p_id.

◆ show_menu_extension()

show_menu_extension ( $p_array,
$default = "",
$p_extra = "" )

Same menu for all extensions, with the right level, it calls ShowItem with the right parameters @global $level (int) global variable of the menu level.

Parameters
$p_array(array)
$default(string) selected item
$p_extra(string) extra code for the table tag (CSS or javascript)
See also
ShowItem

Definition at line 531 of file ac_common.php.

532{
533 global $level;
534
535
536 $level++;
537 switch ($level) {
538 case 3:
539 $p_dir='H';
540 $class="nav-item nav-item-underline";
541 $class_ref="nav-link";
542 $p_extra="noprint nav nav-pills nav-level3";
543 $class_div="menu3";
544 break;
545 case 2:
546 $p_dir='H';
547 $class="nav-item nav-item-underline";
548 $class_ref="nav-link";
549 $p_extra="noprint nav nav-pills nav-level2";
550 $class_div="menu2";
551 break;
552 case 1:
553 $p_dir='H';
554 $class="nav-item nav-item-underline";
555 $class_ref="nav-link";
556 $p_extra='noprint nav nav-pills nav-fill ';
557 $class_div="top_menu";
558 break;
559 default:
560 $p_dir='H';
561 $class="nav-item nav-item-underline";
562 $class_ref="nav-link";
563 $p_extra="noprint nav nav-level4";
564 $class_div="menu3";
565 break;
566 }
567 return "<div class=\"$class_div\">"
568 . ShowItem($p_array,$p_dir,$class,$class_ref,$default,$p_extra)
569 ."</div>";
570
571
572}
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
$class
Display the Plugin and for each profile were it is installed or not.

References $class, $p_array, and ShowItem().

Referenced by MenuAdmin().

+ Here is the call graph for this function:

◆ show_module()

show_module ( $selected)

Show the modules.

Parameters
int$selectedmodule selected profile_menu.pm_id

Definition at line 985 of file ac_common.php.

986{
987 global $g_user;
989 $amodule = $cn->get_array("select
990 me_code,me_menu,me_url,me_javascript,p_order,me_type,me_description
991 from v_all_menu
992 where
993 p_id=$1
994 and p_type_display='M'
995 order by p_order", array($g_user->get_profile()));
996
997 if ($selected != -1)
998 {
999 $selected_module=$cn->get_value('select me_code from profile_menu where'
1000 . ' pm_id = $1 ', array($selected));
1001 require_once NOALYSS_TEMPLATE.'/module.php';
1002 $file = $cn->get_array("select me_file,me_parameter,me_javascript,me_type,me_description from v_all_menu
1003 where pm_id=$1 and p_id=$2", array($selected,$g_user->get_profile()));
1004 if ( count($file ) == 0 )
1005 {
1006 echo '</div>';
1007 echo '</div>';
1008 echo '<div class="content">';
1009 echo_warning(_("Module inexistant")."[ $selected ] ");
1010 echo '</div>';
1011 exit();
1012 }
1013 if ($file[0]['me_file'] != '')
1014 {
1015 if ($file[0]['me_parameter'] != "")
1016 {
1017 // if there are paramter put them in superglobal
1018 $array=compute_variable($file[0]['me_parameter']);
1020 }
1021
1022 // if file is not a plugin, include the file, otherwise
1023 // include the plugin launcher
1024 if ($file[0]['me_type'] != 'PL')
1025 {
1026 require_once $file[0]['me_file'];
1027 }
1028 else
1029 {
1030 // nothing : direct call to plugin
1031 }
1032 }
1033 if ( $file[0]['me_javascript'] != '')
1034 {
1035 create_script($file[0]['me_javascript']);
1036 }
1037 }
1038}
$selected

References from.

◆ ShowItem()

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

Parameters
$p_arrayarray like ( 0=>HREF reference, 1=>visible item (name),2=>Help(opt), 3=>selected (opt) 4=>javascript (normally a onclick event) (opt)
$p_dirdirection of the menu (H Horizontal V vertical)
$classCSS for li tag
$class_refCSS for the A tag
$defaultselected item
$p_extraextra code for the table tag (CSS or javascript)

Definition at line 587 of file ac_common.php.

588{
589
590 $ret = '';
591 // for comptability with old application mtitle for anchor is replace by nav-link
592
593
594 // direction Vertical
595 if ($p_dir == 'V')
596 {
597 $ret .= "<ul class=\"$p_extra \" style=\"display:flex;flex-direction:column\">";
598 } else {
599 $ret .= "<ul class=\"$p_extra \" >";
600
601 }
602
603 foreach ($p_array as $all => $href)
604 {
605 $javascript = (isset($href[4])) ? $href[4] : "";
606 $title = "";
607 $set = "XX";
608 if (isset($href[2]))
609 {
610 $title=$href[2];
611 }
612 if (isset($href[3]))
613 {
614 $set=$href[3];
615 }
616
617 if ($set==$default)
618 {
619 $ret.='<li class="'.$class.' li-active "><A class="'.$class_ref.' active'.'" HREF="'.$href[0].'" title="'.$title.'" '.$javascript.'>'.$href[1].'</A></li>';
620 }
621 else
622 {
623 $ret.='<li class="'.$class.'"><A class="'.$class_ref.'" HREF="'.$href[0].'" title="'.$title.'" '.$javascript.'>'.$href[1].'</A></li>';
624 }
625
626 }
627
628 $ret.="</ul>";
629 return $ret;
630}
$href
Definition adm.inc.php:31

References $all, $class, $href, $p_array, $ret, and $title.

Referenced by show_menu_extension().

◆ shrink_date()

shrink_date ( $p_date)

shrink the date, make a date shorter for the printing

Parameters
$p_dateformat DD.MM.YYYY
Returns
date in the format DDMMYY (size = 13 mm in arial 8)

Definition at line 879 of file ac_common.php.

880{
882 $str_date = substr($date, 0, 4) . substr($date, 6, 2);
883 return $str_date;
884}

◆ smaller_date()

smaller_date ( $p_date)

shrink the date, make a date shorter for the printing

Parameters
$p_dateformat DD.MM.YYYY
Returns
date in the format DD.MM.YY (size = 13 mm in arial 8)

Definition at line 890 of file ac_common.php.

891{
892 if (empty ($p_date)) return "";
893 $str_date = substr($p_date, 0, 6) . substr($p_date, 8, 2);
894 return $str_date;
895}

Referenced by Print_Ledger_Misc\export().

◆ span()

◆ sql_filter_per()

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.

Parameters
$p_cndatabase conx
$p_fromstart date (date)
$p_toend date (date)
$p_formif the p_from and p_to are date or p_id
$p_fieldcolumn name
Returns
a string containg the query

Definition at line 735 of file ac_common.php.

736{
737
738 if ($p_form != 'p_id' && $p_form != 'date')
739 {
740 echo_error(__FILE__, __LINE__, 'Mauvais parametres ');
741 exit(-1);
742 }
743 $p_from= sql_string($p_from);
744 $p_to= sql_string($p_to);
745 $p_field= sql_string($p_field);
746 if ($p_form == 'p_id')
747 {
748 if ( isNUmber($p_from)==0 || isNUmber($p_to)==0){
749 throw new Exception("SFP1"._("Nombre invalide")."\$p_from=$p_from \$p_to=$p_to");
750 }
751 // retrieve the date
752 $pPeriode = new Periode($p_cn);
753 $a_start = $pPeriode->get_date_limit($p_from);
754 $a_end = $pPeriode->get_date_limit($p_to);
755 if ($a_start==null||$a_end==null)
756 {
757 throw new Exception(__FILE__.__LINE__.sprintf(_('Attention periode
758 non trouvee periode p_from= %s p_to_periode = %s'), $p_from, $p_to));
759 }
760
761
762 $p_from = $a_start['p_start'];
763 $p_to = $a_end['p_end'];
764 }else {
765 if ( isDate($p_from)==NULL || isDate($p_to)==NULL){
766 throw new Exception("SFP2"._("Date invalide")."\$p_from=$p_from \$p_to=$p_to");
767 }
768 }
769 if ($p_from==$p_to)
770 {
771 $periode=" $p_field = (select p_id from parm_periode ".
772 " where ".
773 " p_start = to_date('$p_from','DD.MM.YYYY')) ";
774 }
775 else
776 {
777 $periode="$p_field in (select p_id from parm_periode ".
778 " where p_start >= to_date('$p_from','DD.MM.YYYY') and p_end <= to_date('$p_to','DD.MM.YYYY')) ";
779 }
780 return $periode;
781}
if(sizeof($array)==0) $pPeriode

References $periode, $pPeriode, _, echo_error(), exit, isDate(), and sql_string().

Referenced by Impress\compute_periode(), Anc_Operation\get_balance(), Acc_Account_Ledger\get_row(), Acc_Ledger_History_Financial\get_row(), Acc_Ledger_History_Generic\get_row(), Acc_Ledger_History_Purchase\get_row(), Acc_Ledger_History_Sale\get_row(), Fiche\get_row(), Acc_Ledger_History_Generic\get_rowSimple(), Acc_Ledger\get_solde(), Impress\parse_formula(), Acc_Bilan\verify(), and Acc_Bilan\warning().

+ Here is the call graph for this function:

◆ sql_string()

sql_string ( $p_string)

Fix the problem with the quote char for the database.

Parameters
$p_string
Returns
a string which won't let strange char for the database

Definition at line 513 of file ac_common.php.

514{
515 $p_string = trim($p_string??"");
516 if (strlen($p_string) == 0)
517 return null;
518 $p_string = noalyss_str_replace("'", "''", $p_string);
519 $p_string = noalyss_str_replace('\\', '\\\\', $p_string);
520 return $p_string;
521}

References noalyss_str_replace().

Referenced by Fiche_Def\Add(), Anc_Plan\add(), Card_Multiple\build_sql(), contact\build_sql(), Fiche\build_sql(), Card_Multiple\count_sql(), Follow_Up\create_query(), Stock\create_query_histo(), Follow_Up\filter_by_tag(), FormatString(), Pre_operation\get_operation(), Acc_Ledger_Fin\insert(), Acc_Ledger_Purchase\insert(), Acc_Ledger_Sale\insert(), Fiche\insert(), Acc_Ledger_Purchase\insert_no_deductible(), Acc_Parm_Code\save(), Fiche_Def\save_class_base(), Fiche_Def\SaveLabel(), HtmlInput\select_stock(), sql_filter_per(), Fiche\Summary(), Anc_Plan\update(), and Card_Property\update().

+ Here is the call graph for this function:

◆ td()

td ( $p_string = '',
$p_extra = '' )

surround the string with td

Parameters
$p_stringstring to surround by TD
$p_extraextra info (class, style, javascript...)
Returns
string surrounded by td

Definition at line 83 of file ac_common.php.

84{
85 return '<td ' . $p_extra . '>' . $p_string . '</td>';
86}

Referenced by Acc_Ledger\confirm(), Acc_Ledger_Fin\confirm(), Acc_Ledger_Purchase\confirm(), Acc_Ledger_Sale\confirm(), Fiche\Display(), Pre_Op_Advanced\display(), Acc_Bilan\display_form(), Anc_Print\display_form(), Anc_Acc_List\display_html(), Anc_Balance_Double\display_html(), Anc_Balance_Simple\display_html(), Anc_GrandLivre\display_html(), Anc_Listing\display_html(), Anc_Table\display_html(), Acc_Plan_MTable\display_row(), Additional_Tax\display_row(), Fiche\display_row(), Follow_Up_Other_Concerned\display_row(), Forecast_Item_MTable\display_row(), Manage_Table_SQL\display_row(), Operation_Exercice\display_row(), Periode_Ledger_Table\display_row(), Acc_Report_MTable\display_row_custom(), Card_Attribut_MTable\display_row_custom(), Manage_Table_SQL\display_row_custom(), Mobile_Device_MTable\display_row_custom(), Periode\display_row_global(), display_security_fieldset(), Anc_Operation\display_table(), Acc_Ledger_History_Generic\export_accounting_html(), Print_Operation_Currency\export_html(), Acc_Ledger_History_Generic\export_oneline_html(), Anc_Group_Operation\form(), Document_Modele\form(), Periode\form_periode_add(), Anc_Operation\html_table(), Acc_Account_Ledger\HtmlTable(), Fiche\HtmlTable(), Acc_Ledger\input(), Acc_Ledger_Purchase\input(), Card_Property\input(), IAncCard\input(), ICard\input(), IPoste\input(), ITva_Popup\input(), Template_Card_Category\input(), Mobile_Device_MTable\input_custom(), Acc_Ledger_Fin\insert(), Acc_Ledger_Search\list_operation(), Acc_Ledger_Search\list_operation_to_reconcile(), Document_Modele\myList(), Follow_Up\myList(), Noalyss_User\show_dossier(), Html_Table\sql2table(), Fiche\Summary(), Acc_Balance\summary_display(), and Acc_Bilan\verify().

◆ th()

◆ tr()

◆ transform_sql_filter_per()

transform_sql_filter_per ( $p_sql)

transform the SQL for ANALYTIC table operation_analytique

See also
sql_filter_per
Parameters
string$p_sql

Definition at line 713 of file ac_common.php.

714{
715 $result=noalyss_str_replace("j_tech_per in (select p_id from parm_periode where","",$p_sql);
716 $result=noalyss_str_replace("jr_tech_per in (select p_id from parm_periode where","",$result);
717 $result=noalyss_str_replace("j_tech_per = (select p_id from parm_periode where p_start "," oa_date ",$result);
718 $result=noalyss_str_replace("p_start >= to_date","oa_date >= to_date",$result);
719 $result=noalyss_str_replace("p_end <= to_date","oa_date <= to_date",$result);
720
721 $result="( $result";
722 return $result;
723}

References $result, and noalyss_str_replace().

+ Here is the call graph for this function:

◆ what_os()

what_os ( )

try to determine on what os you are running the pĥpcompte server

Returns
0 it is a windows 1 it is a Unix like

Definition at line 859 of file ac_common.php.

860{
861 $inc_path = get_include_path();
862
863 if (strpos($inc_path, ";") != 0)
864 {
865 $os = 0; /* $os is 0 for windoz */
866 }
867 else
868 {
869 $os = 1; /* $os is 1 for unix */
870 }
871 return $os;
872}
$os
Definition constant.php:80
$inc_path
Definition constant.php:41