Clean code

This commit is contained in:
Laurent Destailleur 2019-03-11 01:01:15 +01:00
parent d3479bebbc
commit fac329e637
19 changed files with 128 additions and 150 deletions

View File

@ -15,7 +15,7 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Method GetUrlTrackingStatus were renamed into getUrlTrackingStatus for consistency with naming rules.
* API getListOfCivility has been renamed into getListOfCivilities for consistency with naming rules.
* Deprecated function img_phone as been removed. You can use img_picto(..., 'call|call_out') instead.;
***** ChangeLog for 9.0.1 compared to 9.0.0 *****

View File

@ -145,7 +145,7 @@ function length_accounta($accounta)
* @param string $period Period of report
* @param string $periodlink Link to switch period
* @param string $description Description
* @param timestamp|integer $builddate Date generation
* @param integer $builddate Date of generation
* @param string $exportlink Link for export or ''
* @param array $moreparam Array with list of params to add into form
* @param string $calcmode Calculation mode

View File

@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
*
* @param array $versionarray Tableau de version (vermajeur,vermineur,autre)
* @return string Chaine version
* @see versioncompare
* @see versioncompare()
*/
function versiontostring($versionarray)
{
@ -55,7 +55,7 @@ function versiontostring($versionarray)
* @return int -4,-3,-2,-1 if versionarray1<versionarray2 (value depends on level of difference)
* 0 if same
* 1,2,3,4 if versionarray1>versionarray2 (value depends on level of difference)
* @see versiontostring
* @see versiontostring()
*/
function versioncompare($versionarray1, $versionarray2)
{
@ -432,7 +432,7 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle
* @param int $entity Multi company id, -1 for all entities
* @return int <0 if KO, >0 if OK
*
* @see dolibarr_get_const, dolibarr_set_const, dol_set_user_param
* @see dolibarr_get_const(), dolibarr_set_const(), dol_set_user_param()
*/
function dolibarr_del_const($db, $name, $entity = 1)
{
@ -472,7 +472,7 @@ function dolibarr_del_const($db, $name, $entity = 1)
* @param int $entity Multi company id
* @return string Valeur de la constante
*
* @see dolibarr_del_const, dolibarr_set_const, dol_set_user_param
* @see dolibarr_del_const(), dolibarr_set_const(), dol_set_user_param()
*/
function dolibarr_get_const($db, $name, $entity = 1)
{
@ -507,7 +507,7 @@ function dolibarr_get_const($db, $name, $entity = 1)
* @param int $entity Multi company id (0 means all entities)
* @return int -1 if KO, 1 if OK
*
* @see dolibarr_del_const, dolibarr_get_const, dol_set_user_param
* @see dolibarr_del_const(), dolibarr_get_const(), dol_set_user_param()
*/
function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, $note = '', $entity = 1)
{

View File

@ -369,7 +369,7 @@ function ajax_dialog($title, $message, $w = 350, $h = 150)
* @param int $forcefocus Force focus on field
* @param string $widthTypeOfAutocomplete 'resolve' or 'off'
* @return string Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason.
* @see selectArrayAjax of html.form.class
* @see selectArrayAjax() of html.form.class
*/
function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = 0, $forcefocus = 0, $widthTypeOfAutocomplete = 'resolve')
{

View File

@ -149,7 +149,7 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
* @param int $iMinutes Minutes
* @param int $iSeconds Seconds
* @return int Time into seconds
* @see convertSecondToTime
* @see convertSecondToTime()
*/
function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0)
{
@ -177,7 +177,7 @@ function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0)
* @param int $lengthOfWeek Length of week (default 7)
* @return string Formated text of duration
* Example: 0 return 00:00, 3600 return 1:00, 86400 return 1d, 90000 return 1 Day 01:00
* @see convertTime2Seconds
* @see convertTime2Seconds()
*/
function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $lengthOfWeek = 7)
{
@ -325,7 +325,7 @@ function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date)
* @return int Date as a timestamp
* 19700101020000 -> 7200 with gm=1
*
* @see dol_print_date, dol_mktime, dol_getdate
* @see dol_print_date(), dol_mktime(), dol_getdate()
*/
function dol_stringtotime($string, $gm = 1)
{
@ -603,7 +603,7 @@ function dol_get_first_day_week($day, $month, $year, $gm = false)
* @param string $countrycode Country code
* @param int $lastday Last day is included, 0: no, 1:yes
* @return int Nombre de jours feries
* @see num_between_day, num_open_day
* @see num_between_day(), num_open_day()
*/
function num_public_holiday($timestampStart, $timestampEnd, $countrycode = 'FR', $lastday = 0)
{
@ -809,7 +809,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode = 'FR',
// Easter sunday
// Monday after easter
$date_eastermonday = mktime(
$date_eastermonday = mktime(
date("H", $date_paques),
date("i", $date_paques),
date("s", $date_paques),
@ -895,7 +895,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode = 'FR',
* @param int $timestampEnd Timestamp end UTC
* @param int $lastday Last day is included, 0: no, 1:yes
* @return int Number of days
* @see also num_public_holiday, num_open_day
* @seealso num_public_holiday(), num_open_day()
*/
function num_between_day($timestampStart, $timestampEnd, $lastday = 0)
{
@ -925,7 +925,7 @@ function num_between_day($timestampStart, $timestampEnd, $lastday = 0)
* @param int $halfday Tag to define half day when holiday start and end
* @param string $country_code Country code (company country code if not defined)
* @return int Number of days or hours
* @see also num_between_day, num_public_holiday
* @seealso num_between_day(), num_public_holiday()
*/
function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $halfday = 0, $country_code = '')
{

View File

@ -31,7 +31,7 @@
/**
* Return line description translated in outputlangs and encoded into UTF8
*
* @param Line $line Current line number (0 = first line, 1 = second line, ...)
* @param Object $line Object of line
* @param Translate $outputlangs Object langs for output
* @param int $hideref Hide reference
* @param int $hidedesc Hide description

View File

@ -43,7 +43,7 @@ function donation_admin_prepare_head()
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin');
$head[$h][0] = DOL_URL_ROOT . '/don/admin/donation_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
@ -57,7 +57,7 @@ function donation_admin_prepare_head()
/**
* Prepare array with list of tabs
*
* @param Donation $object Donation
* @param Don $object Donation
* @return array Array of tabs to show
*/
function donation_prepare_head($object)
@ -97,7 +97,7 @@ function donation_prepare_head($object)
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'note';
$h++;
$head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';

View File

@ -55,7 +55,7 @@ function dol_basename($pathfile)
* @param string $relativename For recursive purpose only. Must be "" at first call.
* @param string $donotfollowsymlinks Do not follow symbolic links
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)
* @see dol_dir_list_indatabase
* @see dol_dir_list_in_database()
*/
function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excludefilter = null, $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0, $nohook = 0, $relativename = "", $donotfollowsymlinks = 0)
{
@ -225,7 +225,7 @@ function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excl
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like description
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','type'=>'dir|file',...)
* @see dol_dir_list
* @see dol_dir_list()
*/
function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0)
{
@ -449,7 +449,8 @@ function dol_is_dir($folder)
* @param string $dir Path of Directory
* @return boolean True or false
*/
function dol_is_dir_empty($dir) {
function dol_is_dir_empty($dir)
{
if (!is_readable($dir)) return false;
return (count(scandir($dir)) == 2);
}
@ -527,7 +528,7 @@ function dol_dir_is_emtpy($folder)
*
* @param string $file Filename
* @return int <0 if KO, Number of lines in files if OK
* @see dol_nboflines
* @see dol_nboflines()
*/
function dol_count_nb_of_line($file)
{
@ -588,7 +589,7 @@ function dol_filemtime($pathoffile)
* @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666'
* @param int $indexdatabase 1=index new file into database.
* @return int <0 if error, 0 if nothing done (dest file already exists), >0 if OK
* @see dol_copy dolReplaceRegExInFile
* @see dol_copy() dolReplaceRegExInFile()
*/
function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask = 0, $indexdatabase = 0)
{
@ -658,7 +659,7 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask
* @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666'
* @param int $indexdatabase Index new file into database.
* @return int <0 if error, 0 if nothing done (dest file already exists), >0 if OK
* @see dol_copy dolReplaceInFile
* @see dol_copy() dolReplaceInFile()
*/
function dolReplaceRegExInFile($srcfile, $arrayreplacement, $destfile = '', $newmask = 0, $indexdatabase = 0)
{
@ -673,7 +674,7 @@ function dolReplaceRegExInFile($srcfile, $arrayreplacement, $destfile = '', $new
* @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666'
* @param int $overwriteifexists Overwrite file if exists (1 by default)
* @return int <0 if error, 0 if nothing done (dest file already exists and overwriteifexists=0), >0 if OK
* @see dol_delete_file
* @see dol_delete_file() dolCopyDir()
*/
function dol_copy($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1)
{
@ -729,7 +730,7 @@ function dol_copy($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1)
* @param int $overwriteifexists Overwrite file if exists (1 by default)
* @param array $arrayreplacement Array to use to replace filenames with another one during the copy (works only on file names, not on directory names).
* @return int <0 if error, 0 if nothing done (all files already exists and overwriteifexists=0), >0 if OK
* @see dol_copy
* @see dol_copy()
*/
function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement = null)
{
@ -821,7 +822,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep
* @param int $testvirus Do an antivirus test. Move is canceled if a virus is found.
* @param int $indexdatabase Index new file into database.
* @return boolean True if OK, false if KO
* @see dol_move_uploaded_file
* @see dol_move_uploaded_file()
*/
function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $testvirus = 0, $indexdatabase = 1)
{
@ -1003,7 +1004,7 @@ function dolCheckVirus($src_file)
* @param int $nohook Disable all hooks
* @param string $varfiles _FILES var name
* @return int >0 if OK, <0 or string if KO
* @see dol_move
* @see dol_move()
*/
function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan = 0, $uploaderrorcode = 0, $nohook = 0, $varfiles = 'addedfile')
{
@ -1057,7 +1058,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
$checkvirusarray=dolCheckVirus($src_file);
if (count($checkvirusarray))
{
dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: result='.$result.' errors='.join(',', $checkvirusarray), LOG_WARNING);
dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: errors='.join(',', $checkvirusarray), LOG_WARNING);
return 'ErrorFileIsInfectedWithAVirus: '.join(',', $checkvirusarray);
}
}
@ -1146,7 +1147,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
* @param boolean $allowdotdot Allow to delete file path with .. inside. Never use this, it is reserved for migration purpose.
* @param int $indexdatabase Try to remove also index entries.
* @return boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error
* @see dol_delete_dir
* @see dol_delete_dir()
*/
function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, $object = null, $allowdotdot = false, $indexdatabase = 1)
{
@ -1256,7 +1257,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
* @param string $dir Directory to delete
* @param int $nophperrors Disable all PHP output errors
* @return boolean True if success, false if error
* @see dol_delete_file dol_copy
* @see dol_delete_file() dolCopyDir()
*/
function dol_delete_dir($dir, $nophperrors = 0)
{
@ -1331,7 +1332,7 @@ function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub =
*
* @param object $object Object to clean
* @return int 0 if error, 1 if OK
* @see dol_convert_file
* @see dol_convert_file()
*/
function dol_delete_preview($object)
{
@ -2116,7 +2117,7 @@ function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(
* @param string $refname Ref of object to check permission for external users (autodetect if not provided)
* @param string $mode Check permission for 'read' or 'write'
* @return mixed Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name)
* @see restrictedArea
* @see restrictedArea()
*/
function dol_check_secure_access_document($modulepart, $original_file, $entity, $fuser = '', $refname = '', $mode = 'read')
{
@ -2135,6 +2136,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
if ($modulepart == 'users') $modulepart='user';
dol_syslog('modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity);
// We define $accessallowed and $sqlprotectagainstexternals
$accessallowed=0;
$sqlprotectagainstexternals='';
@ -2143,8 +2145,6 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
// Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10'
if (empty($refname)) $refname=basename(dirname($original_file)."/");
$relative_original_file = $original_file;
// Define possible keys to use for permission check
$lire='lire'; $read='read'; $download='download';
if ($mode == 'write')

View File

@ -784,7 +784,7 @@ function dol_size($size, $type = '')
* @param int $unaccent 1=Remove also accent (default), 0 do not remove them
* @return string String cleaned (a-zA-Z_)
*
* @see dol_string_nospecial, dol_string_unaccent, dol_sanitizePathName
* @see dol_string_nospecial(), dol_string_unaccent(), dol_sanitizePathName()
*/
function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)
{
@ -800,7 +800,7 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)
* @param int $unaccent 1=Remove also accent (default), 0 do not remove them
* @return string String cleaned (a-zA-Z_)
*
* @see dol_string_nospecial, dol_string_unaccent, dol_sanitizeFileName
* @see dol_string_nospecial(), dol_string_unaccent(), dol_sanitizeFileName()
*/
function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1)
{
@ -814,7 +814,7 @@ function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1)
* @param string $str String to clean
* @return string Cleaned string
*
* @see dol_sanitizeFilename, dol_string_nospecial
* @see dol_sanitizeFilename(), dol_string_nospecial()
*/
function dol_string_unaccent($str)
{
@ -872,7 +872,7 @@ $string = strtr(
* @param array $badcharstoreplace List of forbidden characters
* @return string Cleaned string
*
* @see dol_sanitizeFilename, dol_string_unaccent
* @see dol_sanitizeFilename(), dol_string_unaccent()
*/
function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '')
{
@ -925,7 +925,7 @@ function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
* @param int $keepb 1=Preserve b tags (otherwise, remove them)
* @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value)
* @return string Escaped string
* @see dol_string_nohtmltag, dol_string_nospecial, dol_string_unaccent
* @see dol_string_nohtmltag(), dol_string_nospecial(), dol_string_unaccent()
*/
function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0)
{
@ -1604,7 +1604,7 @@ function dol_bc($var, $moreclass = '')
* @param Translate $outputlangs Object lang that contains language for text translation.
* @param int $mode 0=Standard output, 1=Remove address
* @return string Formated string
* @see dol_print_address
* @see dol_print_address()
*/
function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0)
{
@ -1707,7 +1707,7 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false)
* @param boolean $encodetooutput false=no convert into output pagecode
* @return string Formated date or '' if time is null
*
* @see dol_mktime, dol_stringtotime, dol_getdate
* @see dol_mktime(), dol_stringtotime(), dol_getdate()
*/
function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlangs = '', $encodetooutput = false)
{
@ -1884,7 +1884,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang
* 'yday' => floor($secsInYear/$_day_power),
* 'leap' => $leaf,
* 'ndays' => $ndays
* @see dol_print_date, dol_stringtotime, dol_mktime
* @see dol_print_date(), dol_stringtotime(), dol_mktime()
*/
function dol_getdate($timestamp, $fast = false)
{
@ -1923,7 +1923,7 @@ function dol_getdate($timestamp, $fast = false)
* 'tz,TimeZone' = use specified timezone
* @param int $check 0=No check on parameters (Can use day 32, etc...)
* @return int|string Date as a timestamp, '' or false if error
* @see dol_print_date, dol_stringtotime, dol_getdate
* @see dol_print_date(), dol_stringtotime(), dol_getdate()
*/
function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $check = 1)
{
@ -2711,7 +2711,7 @@ function dol_user_country()
* @param int $noprint No output. Result is the function return
* @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br.
* @return string|void Nothing if noprint is 0, formatted address if noprint is 1
* @see dol_format_address
* @see dol_format_address()
*/
function dol_print_address($address, $htmlid, $mode, $id, $noprint = 0, $charfornl = '')
{
@ -3614,30 +3614,6 @@ function img_mime($file, $titlealt = '', $morecss = '')
}
/**
* Show phone logo.
* Use img_picto instead.
*
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
* @param int $option Option
* @return string Return img tag
* @deprecated
* @see img_picto
*/
function img_phone($titlealt = 'default', $option = 0)
{
dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
global $conf,$langs;
if ($titlealt == 'default') $titlealt = $langs->trans('Call');
if ($option == 1) $img = 'call';
else $img = 'call_out';
return img_picto($titlealt, $img);
}
/**
* Show search logo
*
@ -3713,7 +3689,7 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss
* @param mixed $error String or array of errors strings to show
* @param array $errors Array of errors
* @return void
* @see dol_htmloutput_errors
* @see dol_htmloutput_errors()
*/
function dol_print_error($db = '', $error = '', $errors = null)
{
@ -4009,7 +3985,7 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin
* @param string $title Title to show
* @return string Title to show
* @deprecated Use load_fiche_titre instead
* @see load_fiche_titre
* @see load_fiche_titre()
*/
function print_titre($title)
{
@ -4045,7 +4021,7 @@ function print_fiche_titre($title, $mesg = '', $picto = 'title_generic.png', $pi
* @param string $morecssontable More css on table
* @param string $morehtmlcenter Added message to show on center
* @return string
* @see print_barre_liste
* @see print_barre_liste()
*/
function load_fiche_titre($titre, $morehtmlright = '', $picto = 'title_generic.png', $pictoisfullpath = 0, $id = '', $morecssontable = '', $morehtmlcenter = '')
{
@ -4431,7 +4407,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
* @param int $alreadysqlnb Put 1 if you know that content is already universal format number
* @return string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails. If amount is null or '', it returns ''.
*
* @see price Opposite function of price2num
* @see price() Opposite function of price2num
*/
function price2num($amount, $rounding = '', $alreadysqlnb = 0)
{
@ -4572,7 +4548,7 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round
* @param Societe $thirdparty_seller Object of selling third party ($mysoc if not defined)
* @param int $vatnpr If vat rate is NPR or not
* @return mixed 0 if not found, localtax rate if found
* @see get_default_tva
* @see get_default_tva()
*/
function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_seller = "", $vatnpr = 0)
{
@ -4762,7 +4738,7 @@ function get_localtax_by_third($local)
* @param Societe $seller Company object
* @param int $firstparamisid 1 if first param is id into table (use this if you can)
* @return array array('rowid'=> , 'code'=> ...)
* @see getLocalTaxesFromRate
* @see getLocalTaxesFromRate()
*/
function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid = 1)
{
@ -4818,7 +4794,7 @@ function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid
* @param Societe $seller Company object
* @param int $firstparamisid 1 if first param is ID into table instead of Rate+code (use this if you can)
* @return array array(localtax_type1(1-6/0 if not found), rate localtax1, localtax_type2, rate localtax2, accountancycodecust, accountancycodesupp)
* @see getTaxesFromId
* @see getTaxesFromId()
*/
function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid = 0)
{
@ -4876,7 +4852,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
* @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...)
* @param int $idprodfournprice Id product_fournisseur_price (for "supplier" proposal/order/invoice)
* @return float|string Vat rate to use with format 5.0 or '5.0 (XXX)'
* @see get_product_localtax_for_country
* @see get_product_localtax_for_country()
*/
function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice = 0)
{
@ -4953,7 +4929,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
* @param int $local 1 for localtax1, 2 for localtax 2
* @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...)
* @return int <0 if KO, Vat rate if OK
* @see get_product_vat_for_country
* @see get_product_vat_for_country()
*/
function get_product_localtax_for_country($idprod, $local, $thirdparty_seller)
{
@ -5026,7 +5002,7 @@ function get_product_localtax_for_country($idprod, $local, $thirdparty_seller)
* @param int $idprod Id product
* @param int $idprodfournprice Id product_fournisseur_price (for supplier order/invoice)
* @return float|string Vat rate to use with format 5.0 or '5.0 (XXX)', -1 if we can't guess it
* @see get_default_npr, get_default_localtax
* @see get_default_npr(), get_default_localtax()
*/
function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0)
{
@ -5113,7 +5089,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
* @param int $idprod Id product
* @param int $idprodfournprice Id supplier price for product
* @return float 0 or 1
* @see get_default_tva, get_default_localtax
* @see get_default_tva(), get_default_localtax()
*/
function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0)
{
@ -5150,7 +5126,7 @@ function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer,
* @param int $local Localtax to process (1 or 2)
* @param int $idprod Id product
* @return integer localtax, -1 si ne peut etre determine
* @see get_default_tva, get_default_npr
* @see get_default_tva(), get_default_npr()
*/
function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod = 0)
{
@ -5371,7 +5347,7 @@ function picto_required()
* @param integer $strip_tags 0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag)
* @return string String cleaned
*
* @see dol_escape_htmltag strip_tags dol_string_onlythesehtmltags dol_string_neverthesehtmltags
* @see dol_escape_htmltag() strip_tags() dol_string_onlythesehtmltags() dol_string_neverthesehtmltags()
*/
function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0)
{
@ -5409,7 +5385,7 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
* @param string $stringtoclean String to clean
* @return string String cleaned
*
* @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_neverthesehtmltags
* @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_neverthesehtmltags()
*/
function dol_string_onlythesehtmltags($stringtoclean)
{
@ -5435,7 +5411,7 @@ function dol_string_onlythesehtmltags($stringtoclean)
* @param array $disallowed_tags Array of tags not allowed
* @return string String cleaned
*
* @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_onlythesehtmltags
* @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_onlythesehtmltags()
*/
function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags = array('textarea'))
{
@ -5454,10 +5430,11 @@ function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags = array(
*
* @param string $text Input text
* @param int $nboflines Nb of lines to get (default is 1 = first line only)
* @param string $charset Charset of $text string (UTF-8 by default)
* @return string Output text
* @see dol_nboflines_bis, dol_string_nohtmltag, dol_escape_htmltag
* @see dol_nboflines_bis(), dol_string_nohtmltag(), dol_escape_htmltag()
*/
function dolGetFirstLineOfText($text, $nboflines = 1)
function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8')
{
if ($nboflines == 1)
{
@ -5513,7 +5490,7 @@ function dolGetFirstLineOfText($text, $nboflines = 1)
* @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br
* @param bool $forxml false=Use <br>, true=Use <br />
* @return string String encoded
* @see dol_nboflines, dolGetFirstLineOfText
* @see dol_nboflines(), dolGetFirstLineOfText()
*/
function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml = false)
{
@ -5650,7 +5627,7 @@ function dol_string_is_good_iso($s)
* @param string $s String to check
* @param int $maxchar Not yet used
* @return int Number of lines
* @see dol_nboflines_bis, dolGetFirstLineOfText
* @see dol_nboflines_bis(), dolGetFirstLineOfText()
*/
function dol_nboflines($s, $maxchar = 0)
{
@ -5669,7 +5646,7 @@ function dol_nboflines($s, $maxchar = 0)
* @param int $maxlinesize Largeur de ligne en caracteres (ou 0 si pas de limite - defaut)
* @param string $charset Give the charset used to encode the $text variable in memory.
* @return int Number of lines
* @see dol_nboflines, dolGetFirstLineOfText
* @see dol_nboflines(), dolGetFirstLineOfText()
*/
function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8')
{
@ -5724,7 +5701,7 @@ function dol_microtime_float()
* @param string $msg Content to check
* @param int $option 0=Full detection, 1=Fast check
* @return boolean true/false
* @see dol_concatdesc
* @see dol_concatdesc()
*/
function dol_textishtml($msg, $option = 0)
{
@ -5766,22 +5743,22 @@ function dol_textishtml($msg, $option = 0)
* @param bool $forxml false=Use <br>instead of \n if html content detected, true=Use <br /> instead of \n if html content detected
* @param bool $invert invert order of description lines if CONF CHANGE_ORDER_CONCAT_DESCRIPTION is active
* @return string Text 1 + new line + Text2
* @see dol_textishtml
* @see dol_textishtml()
*/
function dol_concatdesc($text1, $text2, $forxml = false, $invert = false)
{
if (!empty($invert))
{
$tmp = $text1;
$text1 = $text2;
$text2 = $tmp;
}
if (!empty($invert))
{
$tmp = $text1;
$text1 = $text2;
$text2 = $tmp;
}
$ret='';
$ret.= (! dol_textishtml($text1) && dol_textishtml($text2))?dol_nl2br($text1, 0, $forxml):$text1;
$ret.= (! empty($text1) && ! empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2))?($forxml?"<br \>\n":"<br>\n") : "\n") : "";
$ret.= (dol_textishtml($text1) && ! dol_textishtml($text2))?dol_nl2br($text2, 0, $forxml):$text2;
return $ret;
$ret='';
$ret.= (! dol_textishtml($text1) && dol_textishtml($text2))?dol_nl2br($text1, 0, $forxml):$text1;
$ret.= (! empty($text1) && ! empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2))?($forxml?"<br \>\n":"<br>\n") : "\n") : "";
$ret.= (dol_textishtml($text1) && ! dol_textishtml($text2))?dol_nl2br($text2, 0, $forxml):$text2;
return $ret;
}
@ -5794,7 +5771,7 @@ function dol_concatdesc($text1, $text2, $forxml = false, $invert = false)
* @param array $exclude Array of family keys we want to exclude. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...)
* @param Object $object Object for keys on object
* @return array Array of substitutions
* @see setSubstitFromObject
* @see setSubstitFromObject()
*/
function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $object = null)
{
@ -6087,7 +6064,7 @@ $substitutionarray=array_merge($substitutionarray, array(
$tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp5=dol_get_next_month($tmp['mon'], $tmp['year']);
$substitutionarray=array_merge($substitutionarray, array(
$substitutionarray=array_merge($substitutionarray, array(
'__DAY__' => (string) $tmp['mday'],
'__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday
'__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon
@ -6132,7 +6109,7 @@ $substitutionarray=array_merge($substitutionarray, array(
* @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...)
* @param Translate $outputlangs Output language
* @return string Output string after substitutions
* @see complete_substitutions_array, getCommonSubstitutionArray
* @see complete_substitutions_array(), getCommonSubstitutionArray()
*/
function make_substitutions($text, $substitutionarray, $outputlangs = null)
{
@ -6195,7 +6172,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null)
* @param mixed $parameters Add more parameters (useful to pass product lines)
* @param string $callfunc What is the name of the custom function that will be called? (default: completesubstitutionarray)
* @return void
* @see make_substitutions
* @see make_substitutions()
*/
function complete_substitutions_array(&$substitutionarray, $outputlangs, $object = null, $parameters = null, $callfunc = "completesubstitutionarray")
{
@ -6339,7 +6316,7 @@ function dolGetFirstLastname($firstname, $lastname, $nameorder = -1)
* @param mixed $mesgs Message string or array
* @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors')
* @return void
* @see dol_htmloutput_events
* @see dol_htmloutput_events()
*/
function setEventMessage($mesgs, $style = 'mesgs')
{
@ -6365,7 +6342,7 @@ function setEventMessage($mesgs, $style = 'mesgs')
* @param array $mesgs Message array
* @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors')
* @return void
* @see dol_htmloutput_events
* @see dol_htmloutput_events()
*/
function setEventMessages($mesg, $mesgs, $style = 'mesgs')
{
@ -6392,7 +6369,7 @@ function setEventMessages($mesg, $mesgs, $style = 'mesgs')
*
* @param int $disabledoutputofmessages Clear all messages stored into session without diplaying them
* @return void
* @see dol_htmloutput_mesg
* @see dol_htmloutput_mesg()
*/
function dol_htmloutput_events($disabledoutputofmessages = 0)
{
@ -6425,9 +6402,9 @@ function dol_htmloutput_events($disabledoutputofmessages = 0)
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return string Return html output
*
* @see dol_print_error
* @see dol_htmloutput_errors
* @see setEventMessages
* @see dol_print_error()
* @see dol_htmloutput_errors()
* @see setEventMessages()
*/
function get_htmloutput_mesg($mesgstring = '', $mesgarray = '', $style = 'ok', $keepembedded = 0)
{
@ -6502,8 +6479,8 @@ function get_htmloutput_mesg($mesgstring = '', $mesgarray = '', $style = 'ok', $
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return string Return html output
*
* @see dol_print_error
* @see dol_htmloutput_mesg
* @see dol_print_error()
* @see dol_htmloutput_mesg()
*/
function get_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembedded = 0)
{
@ -6519,9 +6496,9 @@ function get_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembe
* @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify)
* @return void
*
* @see dol_print_error
* @see dol_htmloutput_errors
* @see setEventMessages
* @see dol_print_error()
* @see dol_htmloutput_errors()
* @see setEventMessages()
*/
function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0)
{
@ -6574,8 +6551,8 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return void
*
* @see dol_print_error
* @see dol_htmloutput_mesg
* @see dol_print_error()
* @see dol_htmloutput_mesg()
*/
function dol_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembedded = 0)
{
@ -7692,7 +7669,7 @@ function ajax_autoselect($htmlname, $addlink = '')
* @param string $default Default mime type if extension not found in known list
* @param int $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language, 4=css of font fa
* @return string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive)
* @see image_format_supported (images.lib.php)
* @see image_format_supported() from images.lib.php
*/
function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
{

View File

@ -1453,7 +1453,7 @@ function weight_convert($weight, &$from_unit, $to_unit)
* @param array $tab Array (key=>value) with all parameters to save
* @return int <0 if KO, >0 if OK
*
* @see dolibarr_get_const, dolibarr_set_const, dolibarr_del_const
* @see dolibarr_get_const(), dolibarr_set_const(), dolibarr_del_const()
*/
function dol_set_user_param($db, $conf, &$user, $tab)
{
@ -1553,7 +1553,7 @@ function version_os()
* Return PHP version
*
* @return string PHP version
* @see versionphparray
* @see versionphparray()
*/
function version_php()
{
@ -1564,7 +1564,7 @@ function version_php()
* Return Dolibarr version
*
* @return string Dolibarr version
* @see versiondolibarrarray
* @see versiondolibarrarray()
*/
function version_dolibarr()
{
@ -2137,7 +2137,7 @@ function getElementProperties($element_type)
*
* @param int $element_id Element id
* @param string $element_type Element type
* @param ref $element_ref Element ref (Use this if element_id but not both)
* @param string $element_ref Element ref (Use this or element_id but not both)
* @return int|object object || 0 || -1 if error
*/
function fetchObjectByElement($element_id, $element_type, $element_ref = '')
@ -2167,7 +2167,7 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '')
* @param array $arraycolor Array
* @param string $colorifnotfound Color code to return if entry not defined or not a RGB format
* @return string RGB hex value (without # before). For example: 'FF00FF', '01FF02'
* @see colorStringToArray
* @see colorStringToArray()
*/
function colorArrayToHex($arraycolor, $colorifnotfound = '888888')
{
@ -2184,11 +2184,12 @@ function colorArrayToHex($arraycolor, $colorifnotfound = '888888')
* @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255')
* @param array $colorifnotfound Color code array to return if entry not defined
* @return string RGB hex value (without # before). For example: FF00FF
* @see colorArrayToHex
* @see colorArrayToHex()
*/
function colorStringToArray($stringcolor, $colorifnotfound = array(88,88,88))
{
if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is
$reg=array();
$tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/', $stringcolor, $reg);
if (! $tmp)
{

View File

@ -139,10 +139,10 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
* Function to return number or amount in text.
*
* @deprecated
* @param float $numero Number to convert
* @param Lang $langs Language
* @param string $numorcurrency 'number' or 'amount'
* @return string Text of the number or -1 in case TOO LONG (more than 1000000000000.99)
* @param float $numero Number to convert
* @param Translate $langs Language
* @param string $numorcurrency 'number' or 'amount'
* @return string Text of the number or -1 in case TOO LONG (more than 1000000000000.99)
*/
function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
{

View File

@ -36,10 +36,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
* @param string $diroutputpdf Dir to output file
* @param string $newlangid Lang id
* @param array $filter Array with filters
* @param date $dateafterdate Invoice after date
* @param date $datebeforedate Invoice before date
* @param date $paymentdateafter Payment after date (must includes hour)
* @param date $paymentdatebefore Payment before date (must includes hour)
* @param integer $dateafterdate Invoice after date
* @param integer $datebeforedate Invoice before date
* @param integer $paymentdateafter Payment after date (must includes hour)
* @param integer $paymentdatebefore Payment before date (must includes hour)
* @param int $usestdout Add information onto standard output
* @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template
* @param string $filesuffix Suffix to add into file name of generated PDF

View File

@ -35,7 +35,7 @@
* @param string $addfieldentry Array of the field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure')
* @param string $delfieldentry Id of field to remove
* @return int|object <=0 if KO, Object if OK
* @see rebuildObjectSql
* @see rebuildObjectSql()
*/
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = '', $addfieldentry = array(), $delfieldentry = '')
{
@ -208,7 +208,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
* @param string $readdir Directory source (use $destdir when not defined)
* @param Object $object If object was already loaded/known, it is pass to avaoid another include and new.
* @return int <=0 if KO, >0 if OK
* @see rebuildObjectClass
* @see rebuildObjectClass()
*/
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '', $object = null)
{

View File

@ -264,7 +264,7 @@ function pdf_getHeightForLogo($logo, $url = false)
* @param TCPDF $pdf PDF initialized object
* @param string $htmlcontent HTML Contect
* @return int Height
* @see getStringHeight
* @see getStringHeight()
*/
function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent)
{

View File

@ -31,7 +31,7 @@
* @param string $period Period of report
* @param string $periodlink Link to switch period
* @param string $description Description
* @param timestamp|integer $builddate Date generation
* @param integer $builddate Date generation
* @param string $exportlink Link for export or ''
* @param array $moreparam Array with list of params to add into form
* @param string $calcmode Calculation mode
@ -42,12 +42,12 @@ function report_header($reportname, $notused, $period, $periodlink, $description
{
global $langs;
if (empty($hselected)) $hselected='report';
print "\n\n<!-- start banner of report -->\n";
if(! empty($varlink)) $varlink = '?'.$varlink;
$head = array();
$h=0;
$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
$head[$h][1] = $langs->trans("Report");

View File

@ -32,7 +32,7 @@
* @param string $chain string to encode
* @param string $key rule to use for delta ('0', '1' or 'myownkey')
* @return string encoded string
* @see dol_decode
* @see dol_decode()
*/
function dol_encode($chain, $key = '1')
{
@ -68,7 +68,7 @@ function dol_encode($chain, $key = '1')
* @param string $chain string to decode
* @param string $key rule to use for delta ('0', '1' or 'myownkey')
* @return string decoded string
* @see dol_encode
* @see dol_encode()
*/
function dol_decode($chain, $key = '1')
{
@ -176,7 +176,7 @@ function dol_verifyHash($chain, $hash, $type = '0')
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
* @param int $isdraft 1=The object with id=$objectid is a draft
* @return int Always 1, die process if not allowed
* @see dol_check_secure_access_document
* @see dol_check_secure_access_document()
*/
function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid', $isdraft = 0)
{
@ -431,7 +431,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
* @return bool True if user has access, False otherwise
* @see restrictedArea
* @see restrictedArea()
*/
function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = '', $dbt_select = 'rowid')
{

View File

@ -446,7 +446,7 @@ function encodedecode_dbpassconf($level = 0)
* @param boolean $generic true=Create generic password (32 chars/numbers), false=Use the configured password generation module
* @param array $replaceambiguouschars Discard ambigous characters. For example array('I').
* @return string New value for password
* @see dol_hash
* @see dol_hash()
*/
function getRandomPassword($generic = false, $replaceambiguouschars = null)
{

View File

@ -194,8 +194,8 @@ function user_prepare_head($object)
/**
* Prepare array with list of tabs
*
* @param Group $object Object group
* @return array Array of tabs
* @param UserGroup $object Object group
* @return array Array of tabs
*/
function group_prepare_head($object)
{

View File

@ -30,7 +30,7 @@
* @param string $content Content to replace
* @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections.
* @return boolean True if OK
* @see dolWebsiteOutput for function used to replace content in a web server context
* @see dolWebsiteOutput() for function used to replace content in a web server context
*/
function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0)
{
@ -139,7 +139,7 @@ function dolStripPhpCode($str, $replacewith = '')
*
* @param string $content Content string
* @return void
* @see dolWebsiteReplacementOfLinks for function used to replace content in the backoffice context when USEDOLIBARREDITOR is not on
* @see dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context when USEDOLIBARREDITOR is not on
*/
function dolWebsiteOutput($content)
{