mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-17 15:01:26 +01:00
Merge remote-tracking branch 'upstream/develop' into nospaceaftercomma
This commit is contained in:
@@ -78,7 +78,7 @@ function jsUnEscape($source)
|
||||
* @param string $subdir Sub directory (Example: '/mailings')
|
||||
* @return array Array of directories that can contains module descriptors
|
||||
*/
|
||||
function dolGetModulesDirs($subdir='')
|
||||
function dolGetModulesDirs($subdir = '')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@@ -142,7 +142,7 @@ function dol_getDefaultFormat(Translate $outputlangs = null)
|
||||
* @param int $searchalt 1=Search also in alternative languages
|
||||
* @return boolean true if OK, false if KO
|
||||
*/
|
||||
function dol_print_file($langs,$filename,$searchalt=0)
|
||||
function dol_print_file($langs, $filename, $searchalt = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@@ -192,7 +192,7 @@ function dol_print_file($langs,$filename,$searchalt=0)
|
||||
* @param int $usetable Output into a table
|
||||
* @return void
|
||||
*/
|
||||
function dol_print_object_info($object, $usetable=0)
|
||||
function dol_print_object_info($object, $usetable = 0)
|
||||
{
|
||||
global $langs, $db;
|
||||
|
||||
@@ -528,7 +528,7 @@ function isValidMailDomain($mail)
|
||||
* @param int $anchor 1: verify anchor is provided, 0: not verify anchor
|
||||
* @return int 1=Check is OK, 0=Check is KO
|
||||
*/
|
||||
function isValidUrl($url,$http=0,$pass=0,$port=0,$path=0,$query=0,$anchor=0)
|
||||
function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0, $anchor = 0)
|
||||
{
|
||||
$ValidUrl = 0;
|
||||
$urlregex = '';
|
||||
@@ -571,7 +571,7 @@ function isValidUrl($url,$http=0,$pass=0,$port=0,$path=0,$query=0,$anchor=0)
|
||||
* @param integer $http 1 = keep both http:// and https://, 0: remove http:// but not https://
|
||||
* @return string Cleaned url
|
||||
*/
|
||||
function clean_url($url,$http=1)
|
||||
function clean_url($url, $http = 1)
|
||||
{
|
||||
// Fixed by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-cleaning-url.html)
|
||||
// To include the minus sign in a char class, we must not escape it but put it at the end of the class
|
||||
@@ -617,7 +617,7 @@ function clean_url($url,$http=1)
|
||||
* @param bool $displaytld Display tld (default: true)
|
||||
* @return string Return email with hidden parts or '';
|
||||
*/
|
||||
function dolObfuscateEmail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true)
|
||||
function dolObfuscateEmail($mail, $replace = "*", $nbreplace = 8, $nbdisplaymail = 4, $nbdisplaydomain = 3, $displaytld = true)
|
||||
{
|
||||
if(!isValidEmail($mail))return '';
|
||||
$tab = explode('@', $mail);
|
||||
@@ -658,7 +658,7 @@ function dolObfuscateEmail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4,
|
||||
* @param string $tdoptions Options for td
|
||||
* @return string
|
||||
*/
|
||||
function array2tr($data,$troptions='',$tdoptions='')
|
||||
function array2tr($data, $troptions = '', $tdoptions = '')
|
||||
{
|
||||
$text = '<tr '.$troptions.'>' ;
|
||||
foreach($data as $key => $item){
|
||||
@@ -678,7 +678,7 @@ function array2tr($data,$troptions='',$tdoptions='')
|
||||
* @param string $tdoptions Options for td
|
||||
* @return string
|
||||
*/
|
||||
function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdoptions='')
|
||||
function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = '', $tdoptions = '')
|
||||
{
|
||||
$text='' ;
|
||||
if($tableMarkup) $text = '<table '.$tableoptions.'>' ;
|
||||
@@ -712,12 +712,12 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti
|
||||
* @param int $forceentity Entity id to force
|
||||
* @return string New value (numeric) or error message
|
||||
*/
|
||||
function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null, $forceentity=null)
|
||||
function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $date = '', $mode = 'next', $bentityon = true, $objuser = null, $forceentity = null)
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
if (! is_object($objsoc)) $valueforccc=$objsoc;
|
||||
else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur;
|
||||
elseif ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur;
|
||||
else $valueforccc=$objsoc->code_client;
|
||||
|
||||
$sharetable = $table;
|
||||
@@ -859,7 +859,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
//print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype;
|
||||
if (is_numeric($yearoffsettype) && $yearoffsettype >= 1)
|
||||
$maskraz=$yearoffsettype; // For backward compatibility
|
||||
else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1))
|
||||
elseif ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1))
|
||||
$maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START;
|
||||
//print "maskraz=".$maskraz; // -1=no reset
|
||||
|
||||
@@ -882,8 +882,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
else // if reset is for a specific month in year, we need year
|
||||
{
|
||||
if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy=3; $posm=2; }
|
||||
else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy=2; $posm=3; }
|
||||
else if (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy=2; $posm=0; }
|
||||
elseif (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy=2; $posm=3; }
|
||||
elseif (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy=2; $posm=0; }
|
||||
else return 'ErrorCantUseRazIfNoYearInMask';
|
||||
}
|
||||
// Define length
|
||||
@@ -917,10 +917,10 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1;
|
||||
}
|
||||
// If after or equal of current new year date
|
||||
else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1;
|
||||
elseif ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1;
|
||||
}
|
||||
// For backward compatibility
|
||||
else if (date("m", $date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year
|
||||
elseif (date("m", $date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year
|
||||
|
||||
if ($yearlen == 4) $yearcomp=sprintf("%04d", date("Y", $date)+$yearoffset);
|
||||
elseif ($yearlen == 2) $yearcomp=sprintf("%02d", date("y", $date)+$yearoffset);
|
||||
@@ -938,7 +938,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
$sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') ";
|
||||
$sqlwhere.=')';
|
||||
}
|
||||
else if ($resetEveryMonth)
|
||||
elseif ($resetEveryMonth)
|
||||
{
|
||||
$sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'";
|
||||
$sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')";
|
||||
@@ -989,7 +989,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
$sql.= " AND ".$field." NOT LIKE '(PROV%)'";
|
||||
if ($bentityon) // only if entity enable
|
||||
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||
else if (! empty($forceentity))
|
||||
elseif (! empty($forceentity))
|
||||
$sql.= " AND entity IN (".$forceentity.")";
|
||||
if ($where) $sql.=$where;
|
||||
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
|
||||
@@ -1006,12 +1006,12 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
|
||||
// Check if we must force counter to maskoffset
|
||||
if (empty($counter)) $counter=$maskoffset;
|
||||
else if (preg_match('/[^0-9]/i', $counter))
|
||||
elseif (preg_match('/[^0-9]/i', $counter))
|
||||
{
|
||||
$counter=0;
|
||||
dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR);
|
||||
}
|
||||
else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset;
|
||||
elseif ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset;
|
||||
|
||||
if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice.
|
||||
{
|
||||
@@ -1038,7 +1038,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
$sql.= " AND ".$field." NOT LIKE '%PROV%'";
|
||||
if ($bentityon) // only if entity enable
|
||||
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||
else if (! empty($forceentity))
|
||||
elseif (! empty($forceentity))
|
||||
$sql.= " AND entity IN (".$forceentity.")";
|
||||
if ($where) $sql.=$where;
|
||||
if ($sqlwhere) $sql.=' AND '.$sqlwhere;
|
||||
@@ -1054,7 +1054,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
|
||||
$numFinal=$ref;
|
||||
}
|
||||
else if ($mode == 'next')
|
||||
elseif ($mode == 'next')
|
||||
{
|
||||
$counter++;
|
||||
|
||||
@@ -1094,7 +1094,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
$maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'";
|
||||
if ($bentityon) // only if entity enable
|
||||
$maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||
else if (! empty($forceentity))
|
||||
elseif (! empty($forceentity))
|
||||
$sql.= " AND entity IN (".$forceentity.")";
|
||||
if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask
|
||||
if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask
|
||||
@@ -1193,7 +1193,7 @@ function get_string_between($string, $start, $end)
|
||||
* @param string $value Value
|
||||
* @return int|string <0 or error string if KO, 0 if OK
|
||||
*/
|
||||
function check_value($mask,$value)
|
||||
function check_value($mask, $value)
|
||||
{
|
||||
$result=0;
|
||||
|
||||
@@ -1302,7 +1302,7 @@ function check_value($mask,$value)
|
||||
* @param boolean $upper Convert to tupper
|
||||
* @return string x
|
||||
*/
|
||||
function binhex($bin, $pad=false, $upper=false)
|
||||
function binhex($bin, $pad = false, $upper = false)
|
||||
{
|
||||
$last = dol_strlen($bin)-1;
|
||||
for($i=0; $i<=$last; $i++){ $x += $bin[$last-$i] * pow(2, $i); }
|
||||
@@ -1355,12 +1355,12 @@ function numero_semaine($time)
|
||||
*/
|
||||
|
||||
// Definition du Jeudi de la semaine
|
||||
if (date("w", mktime(12, 0, 0, $mois, $jour, $annee))==0) // Dimanche
|
||||
if (date("w",mktime(12, 0, 0, $mois, $jour, $annee))==0) // Dimanche
|
||||
$jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee)-3*24*60*60;
|
||||
else if (date("w", mktime(12, 0, 0, $mois, $jour, $annee))<4) // du Lundi au Mercredi
|
||||
elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee))<4) // du Lundi au Mercredi
|
||||
$jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee)+(4-date("w", mktime(12, 0, 0, $mois, $jour, $annee)))*24*60*60;
|
||||
else if (date("w", mktime(12, 0, 0, $mois, $jour, $annee))>4) // du Vendredi au Samedi
|
||||
$jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee)-(date("w", mktime(12, 0, 0, $mois, $jour, $annee))-4)*24*60*60;
|
||||
elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee))>4) // du Vendredi au Samedi
|
||||
$jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60;
|
||||
else // Jeudi
|
||||
$jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee);
|
||||
|
||||
@@ -1369,11 +1369,11 @@ function numero_semaine($time)
|
||||
{
|
||||
$premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))+4*24*60*60;
|
||||
}
|
||||
else if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))<4) // du Lundi au Mercredi
|
||||
elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))<4) // du Lundi au Mercredi
|
||||
{
|
||||
$premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))+(4-date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))))*24*60*60;
|
||||
}
|
||||
else if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))>4) // du Vendredi au Samedi
|
||||
elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))>4) // du Vendredi au Samedi
|
||||
{
|
||||
$premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))+(7-(date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))-4))*24*60*60;
|
||||
}
|
||||
@@ -1418,7 +1418,7 @@ function numero_semaine($time)
|
||||
* @param int $to_unit Nouvelle unite en puissance de 10
|
||||
* @return float Masse convertie
|
||||
*/
|
||||
function weight_convert($weight,&$from_unit,$to_unit)
|
||||
function weight_convert($weight, &$from_unit, $to_unit)
|
||||
{
|
||||
/* Pour convertire 320 gr en Kg appeler
|
||||
* $f = -3
|
||||
@@ -1522,7 +1522,7 @@ function dol_set_user_param($db, $conf, &$user, $tab)
|
||||
* @param Translate $langs Output language
|
||||
* @return string Formated reduction
|
||||
*/
|
||||
function dol_print_reduction($reduction,$langs)
|
||||
function dol_print_reduction($reduction, $langs)
|
||||
{
|
||||
$string = '';
|
||||
if ($reduction == 100)
|
||||
@@ -1589,7 +1589,7 @@ function version_webserver()
|
||||
* @param int $maxfilenamelength Max length of value to show
|
||||
* @return mixed 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename".
|
||||
*/
|
||||
function getListOfModels($db,$type,$maxfilenamelength=0)
|
||||
function getListOfModels($db, $type, $maxfilenamelength = 0)
|
||||
{
|
||||
global $conf,$langs;
|
||||
$liste=array();
|
||||
@@ -1714,7 +1714,7 @@ function is_ip($ip)
|
||||
* @param string $firstname Firstname
|
||||
* @return string Login
|
||||
*/
|
||||
function dol_buildlogin($lastname,$firstname)
|
||||
function dol_buildlogin($lastname, $firstname)
|
||||
{
|
||||
$login=strtolower(dol_string_unaccent($firstname));
|
||||
$login.=($login?'.':'');
|
||||
@@ -1778,7 +1778,7 @@ function getSoapParams()
|
||||
* @param string $option More options
|
||||
* @return string URL of link to object id/type
|
||||
*/
|
||||
function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='')
|
||||
function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
|
||||
{
|
||||
global $db, $conf, $langs;
|
||||
|
||||
@@ -2140,7 +2140,7 @@ function getElementProperties($element_type)
|
||||
* @param ref $element_ref Element ref (Use this if element_id but not both)
|
||||
* @return int|object object || 0 || -1 if error
|
||||
*/
|
||||
function fetchObjectByElement($element_id, $element_type, $element_ref='')
|
||||
function fetchObjectByElement($element_id, $element_type, $element_ref = '')
|
||||
{
|
||||
global $conf;
|
||||
global $db,$conf;
|
||||
@@ -2170,7 +2170,7 @@ function fetchObjectByElement($element_id, $element_type, $element_ref='')
|
||||
* @return string RGB hex value (without # before). For example: 'FF00FF', '01FF02'
|
||||
* @see colorStringToArray
|
||||
*/
|
||||
function colorArrayToHex($arraycolor,$colorifnotfound='888888')
|
||||
function colorArrayToHex($arraycolor, $colorifnotfound = '888888')
|
||||
{
|
||||
if (! is_array($arraycolor)) return $colorifnotfound;
|
||||
if (empty($arraycolor)) return $colorifnotfound;
|
||||
@@ -2187,7 +2187,7 @@ function colorArrayToHex($arraycolor,$colorifnotfound='888888')
|
||||
* @return string RGB hex value (without # before). For example: FF00FF
|
||||
* @see colorArrayToHex
|
||||
*/
|
||||
function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88))
|
||||
function colorStringToArray($stringcolor, $colorifnotfound = array(88,88,88))
|
||||
{
|
||||
if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is
|
||||
$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);
|
||||
@@ -2316,7 +2316,7 @@ function getModuleDirForApiClass($module)
|
||||
* @param $max int Between 0 and 255
|
||||
* @return String
|
||||
*/
|
||||
function random_color_part($min=0,$max=255)
|
||||
function random_color_part($min = 0, $max = 255)
|
||||
{
|
||||
return str_pad( dechex( mt_rand( $min, $max) ), 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
@@ -2328,7 +2328,7 @@ function random_color_part($min=0,$max=255)
|
||||
* @param $max int Between 0 and 255
|
||||
* @return String
|
||||
*/
|
||||
function random_color($min=0, $max=255)
|
||||
function random_color($min = 0, $max = 255)
|
||||
{
|
||||
return random_color_part($min, $max) . random_color_part($min, $max) . random_color_part($min, $max);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user