mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
Merge branch 'develop' of github.com:Dolibarr/dolibarr into new-webportal-module
This commit is contained in:
@@ -53,7 +53,7 @@ function jsUnEscape($source)
|
||||
$unicodeHexVal = substr($source, $pos, 4);
|
||||
$unicode = hexdec($unicodeHexVal);
|
||||
$entity = "&#".$unicode.';';
|
||||
$decodedStr .= utf8_encode($entity);
|
||||
$decodedStr .= mb_convert_encoding($entity, 'UTF-8', 'ISO-8859-1');
|
||||
$pos += 4;
|
||||
} else {
|
||||
// we have an escaped ascii character
|
||||
@@ -97,7 +97,7 @@ function dolGetModulesDirs($subdir = '')
|
||||
continue; // We discard module if it contains disabled into name.
|
||||
}
|
||||
|
||||
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') {
|
||||
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS' && $file != 'includes') {
|
||||
if (is_dir($dirroot.'/'.$file.'/core/modules'.$subdir.'/')) {
|
||||
$modulesdir[$dirroot.'/'.$file.'/core/modules'.$subdir.'/'] = $dirroot.'/'.$file.'/core/modules'.$subdir.'/';
|
||||
}
|
||||
@@ -134,65 +134,6 @@ function dol_getDefaultFormat(Translate $outputlangs = null)
|
||||
return $selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output content of a file $filename in version of current language (otherwise may use an alternate language)
|
||||
*
|
||||
* @param Translate $langs Object language to use for output
|
||||
* @param string $filename Relative filename to output
|
||||
* @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)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Test if file is in lang directory
|
||||
foreach ($langs->dir as $searchdir) {
|
||||
$formfile = ($searchdir."/langs/".$langs->defaultlang."/".$filename);
|
||||
dol_syslog('functions2::dol_print_file search file '.$formfile, LOG_DEBUG);
|
||||
if (is_readable($formfile)) {
|
||||
$content = file_get_contents($formfile);
|
||||
$isutf8 = utf8_check($content);
|
||||
if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') {
|
||||
print utf8_encode($content);
|
||||
} elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') {
|
||||
print utf8_decode($content);
|
||||
} else {
|
||||
print $content;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);
|
||||
}
|
||||
|
||||
if ($searchalt) {
|
||||
// Test si fichier dans repertoire de la langue alternative
|
||||
if ($langs->defaultlang != "en_US") {
|
||||
$formfilealt = $searchdir."/langs/en_US/".$filename;
|
||||
} else {
|
||||
$formfilealt = $searchdir."/langs/fr_FR/".$filename;
|
||||
}
|
||||
dol_syslog('functions2::dol_print_file search alt file '.$formfilealt, LOG_DEBUG);
|
||||
//print 'getcwd='.getcwd().' htmlfilealt='.$formfilealt.' X '.file_exists(getcwd().'/'.$formfilealt);
|
||||
if (is_readable($formfilealt)) {
|
||||
$content = file_get_contents($formfilealt);
|
||||
$isutf8 = utf8_check($content);
|
||||
if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') {
|
||||
print mb_convert_encoding($content, 'UTF-8', 'ISO-8859-1');
|
||||
} elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') {
|
||||
print mb_convert_encoding($content, 'ISO-8859-1', 'UTF-8');
|
||||
} else {
|
||||
print $content;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show informations on an object
|
||||
@@ -1002,7 +943,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
$maskraz = -1;
|
||||
$maskoffset = 0;
|
||||
$resetEveryMonth = false;
|
||||
if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) {
|
||||
if (dol_strlen($maskcounter) < 3 && !getDolGlobalString('MAIN_COUNTER_WITH_LESS_3_DIGITS')) {
|
||||
return 'ErrorCounterMustHaveMoreThan3Digits';
|
||||
}
|
||||
|
||||
@@ -1117,8 +1058,8 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
//print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype;
|
||||
if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) {
|
||||
$maskraz = $yearoffsettype; // For backward compatibility
|
||||
} elseif ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) {
|
||||
$maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START;
|
||||
} elseif ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1)) {
|
||||
$maskraz = getDolGlobalString('SOCIETE_FISCAL_MONTH_START');
|
||||
}
|
||||
//print "maskraz=".$maskraz; // -1=no reset
|
||||
|
||||
@@ -1146,8 +1087,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
if (dol_strlen($reg[$posy]) < 2) {
|
||||
return 'ErrorCantUseRazWithYearOnOneDigit';
|
||||
}
|
||||
} else // if reset is for a specific month in year, we need year
|
||||
{
|
||||
} 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;
|
||||
@@ -1162,8 +1102,8 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
}
|
||||
}
|
||||
// Define length
|
||||
$yearlen = $posy ?dol_strlen($reg[$posy]) : 0;
|
||||
$monthlen = $posm ?dol_strlen($reg[$posm]) : 0;
|
||||
$yearlen = $posy ? dol_strlen($reg[$posy]) : 0;
|
||||
$monthlen = $posm ? dol_strlen($reg[$posm]) : 0;
|
||||
// Define pos
|
||||
$yearpos = (dol_strlen($reg[1]) + 1);
|
||||
$monthpos = ($yearpos + $yearlen);
|
||||
@@ -1269,13 +1209,13 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
$counter = 0;
|
||||
$sql = "SELECT MAX(".$sqlstring.") as val";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$table;
|
||||
$sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike) . (!empty($conf->global->SEARCH_FOR_NEXT_VAL_ON_START_ONLY) ? "%" : "") . "'";
|
||||
$sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike) . (getDolGlobalString('SEARCH_FOR_NEXT_VAL_ON_START_ONLY') ? "%" : "") . "'";
|
||||
$sql .= " AND ".$field." NOT LIKE '(PROV%)'";
|
||||
|
||||
// To ensure that all variables within the MAX() brackets are integers
|
||||
// This avoid bad detection of max when data are noised with non numeric values at the position of the numero
|
||||
if (getDolGlobalInt('MAIN_NUMBERING_FILTER_ON_INT_ONLY')) {
|
||||
$sql .= " AND ". $db->regexpsql($sqlstring, '^[0-9]+$', true);
|
||||
$sql .= " AND ". $db->regexpsql($sqlstring, '^[0-9]+$', 1);
|
||||
}
|
||||
|
||||
if ($bentityon) { // only if entity enable
|
||||
@@ -1306,7 +1246,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
} elseif (preg_match('/[^0-9]/i', $counter)) {
|
||||
dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR);
|
||||
$counter = 0;
|
||||
} elseif ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) {
|
||||
} elseif ($counter < $maskoffset && !getDolGlobalString('MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST')) {
|
||||
$counter = $maskoffset;
|
||||
}
|
||||
|
||||
@@ -1336,7 +1276,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
$ref = '';
|
||||
$sql = "SELECT ".$field." as ref";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$table;
|
||||
$sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike) . (!empty($conf->global->SEARCH_FOR_NEXT_VAL_ON_START_ONLY) ? "%" : "") . "'";
|
||||
$sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike) . (getDolGlobalString('SEARCH_FOR_NEXT_VAL_ON_START_ONLY') ? "%" : "") . "'";
|
||||
$sql .= " AND ".$field." NOT LIKE '%PROV%'";
|
||||
if ($bentityon) { // only if entity enable
|
||||
$sql .= " AND entity IN (".getEntity($sharetable).")";
|
||||
@@ -1398,7 +1338,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
$maskrefclient_sql = "SELECT MAX(".$maskrefclient_sqlstring.") as val";
|
||||
$maskrefclient_sql .= " FROM ".MAIN_DB_PREFIX.$table;
|
||||
//$sql.= " WHERE ".$field." not like '(%'";
|
||||
$maskrefclient_sql .= " WHERE ".$field." LIKE '".$db->escape($maskrefclient_maskLike) . (!empty($conf->global->SEARCH_FOR_NEXT_VAL_ON_START_ONLY) ? "%" : "") . "'";
|
||||
$maskrefclient_sql .= " WHERE ".$field." LIKE '".$db->escape($maskrefclient_maskLike) . (getDolGlobalString('SEARCH_FOR_NEXT_VAL_ON_START_ONLY') ? "%" : "") . "'";
|
||||
if ($bentityon) { // only if entity enable
|
||||
$maskrefclient_sql .= " AND entity IN (".getEntity($sharetable).")";
|
||||
} elseif (!empty($forceentity)) {
|
||||
@@ -1435,8 +1375,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
$numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date) + $yearoffset, $numFinal);
|
||||
$numFinal = preg_replace('/\{yy\}/i', date("y", $date) + $yearoffset, $numFinal);
|
||||
$numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1) + $yearoffset, $numFinal);
|
||||
} else // we want yyyy to be current year
|
||||
{
|
||||
} else { // we want yyyy to be current year
|
||||
$numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date), $numFinal);
|
||||
$numFinal = preg_replace('/\{yy\}/i', date("y", $date), $numFinal);
|
||||
$numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1), $numFinal);
|
||||
@@ -1491,13 +1430,13 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
|
||||
function get_string_between($string, $start, $end)
|
||||
{
|
||||
$string = " ".$string;
|
||||
$ini = strpos($string, $start);
|
||||
$ini = strpos($string, $start);
|
||||
if ($ini == 0) {
|
||||
return "";
|
||||
}
|
||||
$ini += strlen($start);
|
||||
$len = strpos($string, $end, $ini) - $ini;
|
||||
return substr($string, $ini, $len);
|
||||
$ini += strlen($start);
|
||||
$len = strpos($string, $end, $ini) - $ini;
|
||||
return substr($string, $ini, $len);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1505,7 +1444,7 @@ function get_string_between($string, $start, $end)
|
||||
*
|
||||
* @param string $mask Mask to use
|
||||
* @param string $value Value
|
||||
* @return int|string <0 or error string if KO, 0 if OK
|
||||
* @return int|string Return integer <0 or error string if KO, 0 if OK
|
||||
*/
|
||||
function check_value($mask, $value)
|
||||
{
|
||||
@@ -1707,15 +1646,14 @@ function numero_semaine($time)
|
||||
$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;
|
||||
} 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;
|
||||
} else // Jeudi
|
||||
{
|
||||
} else { // Jeudi
|
||||
$premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine));
|
||||
}
|
||||
|
||||
// Definition du numero de semaine: nb de jours entre "premier Jeudi de l'annee" et "Jeudi de la semaine";
|
||||
$numeroSemaine = (
|
||||
(
|
||||
date("z", mktime(12, 0, 0, date("m", $jeudiSemaine), date("d", $jeudiSemaine), date("Y", $jeudiSemaine)))
|
||||
(
|
||||
date("z", mktime(12, 0, 0, date("m", $jeudiSemaine), date("d", $jeudiSemaine), date("Y", $jeudiSemaine)))
|
||||
-
|
||||
date("z", mktime(12, 0, 0, date("m", $premierJeudiAnnee), date("d", $premierJeudiAnnee), date("Y", $premierJeudiAnnee)))
|
||||
) / 7
|
||||
@@ -1752,7 +1690,7 @@ function weight_convert($weight, &$from_unit, $to_unit)
|
||||
*
|
||||
*/
|
||||
$weight = is_numeric($weight) ? $weight : 0;
|
||||
while ($from_unit <> $to_unit) {
|
||||
while ($from_unit != $to_unit) {
|
||||
if ($from_unit > $to_unit) {
|
||||
$weight = $weight * 10;
|
||||
$from_unit = $from_unit - 1;
|
||||
@@ -1775,7 +1713,7 @@ function weight_convert($weight, &$from_unit, $to_unit)
|
||||
* @param Conf $conf Object conf
|
||||
* @param User $user Object user
|
||||
* @param array $tab Array (key=>value) with all parameters to save/update
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*
|
||||
* @see dolibarr_get_const(), dolibarr_set_const(), dolibarr_del_const()
|
||||
*/
|
||||
@@ -1883,6 +1821,20 @@ function version_php()
|
||||
return phpversion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return DB version
|
||||
*
|
||||
* @return string PHP version
|
||||
*/
|
||||
function version_db()
|
||||
{
|
||||
global $db;
|
||||
if (is_object($db) && method_exists($db, 'getVersion')) {
|
||||
return $db->getVersion();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Dolibarr version
|
||||
*
|
||||
@@ -1941,8 +1893,7 @@ function getListOfModels($db, $type, $maxfilenamelength = 0)
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$const = $obj->description;
|
||||
//irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const));
|
||||
$dirtoscan = preg_replace('/[\r\n]+/', ',', trim($conf->global->$const));
|
||||
$dirtoscan = preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString($const)));
|
||||
|
||||
$listoffiles = array();
|
||||
|
||||
@@ -2064,13 +2015,13 @@ function getSoapParams()
|
||||
global $conf;
|
||||
|
||||
$params = array();
|
||||
$proxyuse = (empty($conf->global->MAIN_PROXY_USE) ?false:true);
|
||||
$proxyhost = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_HOST);
|
||||
$proxyport = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PORT);
|
||||
$proxyuser = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_USER);
|
||||
$proxypass = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PASS);
|
||||
$timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout
|
||||
$response_timeout = (empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout
|
||||
$proxyuse = (!getDolGlobalString('MAIN_PROXY_USE') ? false : true);
|
||||
$proxyhost = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_HOST);
|
||||
$proxyport = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_PORT);
|
||||
$proxyuser = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_USER);
|
||||
$proxypass = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_PASS);
|
||||
$timeout = (!getDolGlobalString('MAIN_USE_CONNECT_TIMEOUT') ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout
|
||||
$response_timeout = (!getDolGlobalString('MAIN_USE_RESPONSE_TIMEOUT') ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout
|
||||
//print extension_loaded('soap');
|
||||
if ($proxyuse) {
|
||||
$params = array('connection_timeout'=>$timeout,
|
||||
@@ -2471,8 +2422,7 @@ function colorAgressiveness($hex, $ratio = -50, $brightness = 0)
|
||||
if ($color < 128) {
|
||||
$color -= ($color * ($ratio / 100));
|
||||
}
|
||||
} else // We decrease agressiveness
|
||||
{
|
||||
} else { // We decrease agressiveness
|
||||
if ($color > 128) {
|
||||
$color -= (($color - 128) * (abs($ratio) / 100));
|
||||
}
|
||||
@@ -2563,7 +2513,7 @@ function colorHexToRgb($hex, $alpha = false, $returnArray = false)
|
||||
$rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
|
||||
$rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
|
||||
if ($alpha !== false) {
|
||||
$rgb['a'] = floatval($alpha);
|
||||
$rgb['a'] = (float) $alpha;
|
||||
$string = 'rgba('.implode(',', $rgb).')';
|
||||
} else {
|
||||
$string = 'rgb('.implode(',', $rgb).')';
|
||||
@@ -2799,11 +2749,11 @@ function price2fec($amount)
|
||||
$amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number)
|
||||
|
||||
// Output decimal number by default
|
||||
$nbdecimal = (empty($conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH) ? 2 : $conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH);
|
||||
$nbdecimal = (!getDolGlobalString('ACCOUNTING_FEC_DECIMAL_LENGTH') ? 2 : $conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH);
|
||||
|
||||
// Output separators by default
|
||||
$dec = (empty($conf->global->ACCOUNTING_FEC_DECIMAL_SEPARATOR) ? ',' : $conf->global->ACCOUNTING_FEC_DECIMAL_SEPARATOR);
|
||||
$thousand = (empty($conf->global->ACCOUNTING_FEC_THOUSAND_SEPARATOR) ? '' : $conf->global->ACCOUNTING_FEC_THOUSAND_SEPARATOR);
|
||||
$dec = (!getDolGlobalString('ACCOUNTING_FEC_DECIMAL_SEPARATOR') ? ',' : $conf->global->ACCOUNTING_FEC_DECIMAL_SEPARATOR);
|
||||
$thousand = (!getDolGlobalString('ACCOUNTING_FEC_THOUSAND_SEPARATOR') ? '' : $conf->global->ACCOUNTING_FEC_THOUSAND_SEPARATOR);
|
||||
|
||||
// Format number
|
||||
$output = number_format($amount, $nbdecimal, $dec, $thousand);
|
||||
@@ -2976,7 +2926,8 @@ function removeGlobalParenthesis($string)
|
||||
}
|
||||
|
||||
$nbofchars = dol_strlen($string);
|
||||
$i = 0; $g = 0;
|
||||
$i = 0;
|
||||
$g = 0;
|
||||
$countparenthesis = 0;
|
||||
while ($i < $nbofchars) {
|
||||
$char = dol_substr($string, $i, 1);
|
||||
|
||||
Reference in New Issue
Block a user