Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2020-01-16 18:13:46 +01:00
commit 908a012c21
9 changed files with 434 additions and 434 deletions

View File

@ -415,17 +415,17 @@ print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans(
// Name
print '<tr class="oddeven"><td class="fieldrequired"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" id="name" class="minwidth200" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM?$conf->global->MAIN_INFO_SOCIETE_NOM: GETPOST("nom", 'nohtml')) . '"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM ? $conf->global->MAIN_INFO_SOCIETE_NOM : GETPOST("nom", 'nohtml')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
// Address
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_SOCIETE_ADDRESS?$conf->global->MAIN_INFO_SOCIETE_ADDRESS:GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml')) . '</textarea></td></tr>'."\n";
print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'.($conf->global->MAIN_INFO_SOCIETE_ADDRESS ? $conf->global->MAIN_INFO_SOCIETE_ADDRESS : GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml')).'</textarea></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<input class="minwidth100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP?$conf->global->MAIN_INFO_SOCIETE_ZIP:GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha')) . '"></td></tr>'."\n";
print '<input class="minwidth100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP ? $conf->global->MAIN_INFO_SOCIETE_ZIP : GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha')).'"></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth100" id="MAIN_INFO_SOCIETE_TOWN" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN?$conf->global->MAIN_INFO_SOCIETE_TOWN:GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml')) . '"></td></tr>'."\n";
print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth100" id="MAIN_INFO_SOCIETE_TOWN" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN ? $conf->global->MAIN_INFO_SOCIETE_TOWN : GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml')).'"></td></tr>'."\n";
// Country
print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';

View File

@ -898,90 +898,90 @@ class DolGraph
return;
}
$legends=array();
$nblot=0;
$legends = array();
$nblot = 0;
if (is_array($this->data) && is_array($this->data[0])) {
$nblot=count($this->data[0])-1; // -1 to remove legend
$nblot = count($this->data[0]) - 1; // -1 to remove legend
}
if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
$firstlot=0;
$firstlot = 0;
// Works with line but not with bars
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
$i=$firstlot;
$serie=array();
$i = $firstlot;
$serie = array();
while ($i < $nblot) // Loop on each serie
{
$values=array(); // Array with horizontal y values (specific values of a serie) for each abscisse x
$serie[$i]="var d".$i." = [];\n";
$values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x
$serie[$i] = "var d".$i." = [];\n";
// Fill array $values
$x=0;
foreach($this->data as $valarray) // Loop on each x
$x = 0;
foreach ($this->data as $valarray) // Loop on each x
{
$legends[$x] = $valarray[0];
$values[$x] = (is_numeric($valarray[$i+1]) ? $valarray[$i+1] : null);
$values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] : null);
$x++;
}
// TODO Avoid push by adding generated long array...
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie')
{
foreach($values as $x => $y) {
if (isset($y)) $serie[$i].='d'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n";
foreach ($values as $x => $y) {
if (isset($y)) $serie[$i] .= 'd'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n";
}
}
else
{
foreach($values as $x => $y) {
if (isset($y)) $serie[$i].='d'.$i.'.push(['.$x.', '.$y.']);'."\n";
foreach ($values as $x => $y) {
if (isset($y)) $serie[$i] .= 'd'.$i.'.push(['.$x.', '.$y.']);'."\n";
}
}
unset($values);
$i++;
}
$tag=dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-','.'))));
$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
$this->stringtoshow ='<!-- Build using '.$this->_library.' -->'."\n";
if (! empty($this->title)) $this->stringtoshow.='<div class="center dolgraphtitle'.(empty($this->cssprefix)?'':' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
if (! empty($this->shownographyet))
$this->stringtoshow = '<!-- Build using '.$this->_library.' -->'."\n";
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle'.(empty($this->cssprefix) ? '' : ' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
if (!empty($this->shownographyet))
{
$this->stringtoshow.='<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
$this->stringtoshow.='<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
$this->stringtoshow .= '<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
$this->stringtoshow .= '<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
return;
}
$this->stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix)?'':' dolgraph'.$this->cssprefix).' center"></div>'."\n";
$this->stringtoshow .= '<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix) ? '' : ' dolgraph'.$this->cssprefix).' center"></div>'."\n";
$this->stringtoshow.='<script id="'.$tag.'">'."\n";
$this->stringtoshow.='$(function () {'."\n";
$i=$firstlot;
$this->stringtoshow .= '<script id="'.$tag.'">'."\n";
$this->stringtoshow .= '$(function () {'."\n";
$i = $firstlot;
if ($nblot < 0)
{
$this->stringtoshow.='<!-- No series of data -->';
$this->stringtoshow .= '<!-- No series of data -->';
}
else
{
while ($i < $nblot)
{
$this->stringtoshow.=$serie[$i];
$this->stringtoshow .= $serie[$i];
$i++;
}
}
$this->stringtoshow.="\n";
$this->stringtoshow .= "\n";
// Special case for Graph of type 'pie'
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie')
{
$datacolor=array();
foreach($this->datacolor as $val) $datacolor[]="#".sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]);
$datacolor = array();
foreach ($this->datacolor as $val) $datacolor[] = "#".sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]);
$urltemp=''; // TODO Add support for url link into labels
$showlegend=$this->showlegend;
$showpointvalue=$this->showpointvalue;
$showpercent=$this->showpercent;
$urltemp = ''; // TODO Add support for url link into labels
$showlegend = $this->showlegend;
$showpointvalue = $this->showpointvalue;
$showpercent = $this->showpercent;
$this->stringtoshow.= '
$this->stringtoshow .= '
function plotWithOptions_'.$tag.'() {
$.plot($("#placeholder_'.$tag.'"), d0,
{

View File

@ -29,17 +29,17 @@
*/
class Translate
{
public $dir; // Directories that contains /langs subdirectory
public $dir; // Directories that contains /langs subdirectory
public $defaultlang; // Current language for current user
public $charset_output='UTF-8'; // Codage used by "trans" method outputs
public $defaultlang; // Current language for current user
public $charset_output = 'UTF-8'; // Codage used by "trans" method outputs
public $tab_translate=array(); // Array of all translations key=>value
private $_tab_loaded=array(); // Array to store result after loading each language file
public $tab_translate = array(); // Array of all translations key=>value
private $_tab_loaded = array(); // Array to store result after loading each language file
public $cache_labels=array(); // Cache for labels return by getLabelFromKey method
public $cache_currencies=array(); // Cache to store currency symbols
private $cache_currencies_all_loaded=false;
public $cache_labels = array(); // Cache for labels return by getLabelFromKey method
public $cache_currencies = array(); // Cache to store currency symbols
private $cache_currencies_all_loaded = false;
/**
@ -50,9 +50,9 @@ class Translate
*/
public function __construct($dir, $conf)
{
if (! empty($conf->file->character_set_client)) $this->charset_output=$conf->file->character_set_client; // If charset output is forced
if ($dir) $this->dir=array($dir);
else $this->dir=$conf->file->dol_document_root;
if (!empty($conf->file->character_set_client)) $this->charset_output = $conf->file->character_set_client; // If charset output is forced
if ($dir) $this->dir = array($dir);
else $this->dir = $conf->file->dol_document_root;
}
@ -69,59 +69,59 @@ class Translate
//dol_syslog(get_class($this)."::setDefaultLang srclang=".$srclang,LOG_DEBUG);
// If a module ask to force a priority on langs directories (to use its own lang files)
if (! empty($conf->global->MAIN_FORCELANGDIR))
if (!empty($conf->global->MAIN_FORCELANGDIR))
{
$more=array();
$i=0;
foreach($conf->file->dol_document_root as $dir)
$more = array();
$i = 0;
foreach ($conf->file->dol_document_root as $dir)
{
$newdir=$dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX'
if (! in_array($newdir, $this->dir))
$newdir = $dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX'
if (!in_array($newdir, $this->dir))
{
$more['module_'.$i]=$newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir.
$more['module_'.$i] = $newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir.
}
}
$this->dir=array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir)
$this->dir = array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir)
}
$this->origlang=$srclang;
$this->origlang = $srclang;
if (empty($srclang) || $srclang == 'auto')
{
// $_SERVER['HTTP_ACCEPT_LANGUAGE'] can be 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,it;q=0.6' but can contains also malicious content
$langpref=empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])?'':$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$langpref=preg_replace("/;([^,]*)/i", "", $langpref); // Remove the 'q=x.y,' part
$langpref=str_replace("-", "_", $langpref);
$langlist=preg_split("/[;,]/", $langpref);
$codetouse=preg_replace('/[^_a-zA-Z]/', '', $langlist[0]);
$langpref = empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? '' : $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$langpref = preg_replace("/;([^,]*)/i", "", $langpref); // Remove the 'q=x.y,' part
$langpref = str_replace("-", "_", $langpref);
$langlist = preg_split("/[;,]/", $langpref);
$codetouse = preg_replace('/[^_a-zA-Z]/', '', $langlist[0]);
}
else $codetouse=$srclang;
else $codetouse = $srclang;
// We redefine $srclang
$langpart=explode("_", $codetouse);
$langpart = explode("_", $codetouse);
//print "Short code before _ : ".$langpart[0].' / Short code after _ : '.$langpart[1].'<br>';
if (! empty($langpart[1])) // If it's for a codetouse that is a long code xx_YY
if (!empty($langpart[1])) // If it's for a codetouse that is a long code xx_YY
{
// Array force long code from first part, even if long code is defined
$longforshort=array('ar'=>'ar_SA');
$longforshortexcep=array('ar_EG');
if (isset($longforshort[strtolower($langpart[0])]) && ! in_array($codetouse, $longforshortexcep)) $srclang=$longforshort[strtolower($langpart[0])];
elseif (! is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser
$srclang=strtolower($langpart[0])."_".strtoupper($langpart[1]);
$longforlong=array('no_nb'=>'nb_NO');
if (isset($longforlong[strtolower($srclang)])) $srclang=$longforlong[strtolower($srclang)];
$longforshort = array('ar'=>'ar_SA');
$longforshortexcep = array('ar_EG');
if (isset($longforshort[strtolower($langpart[0])]) && !in_array($codetouse, $longforshortexcep)) $srclang = $longforshort[strtolower($langpart[0])];
elseif (!is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser
$srclang = strtolower($langpart[0])."_".strtoupper($langpart[1]);
$longforlong = array('no_nb'=>'nb_NO');
if (isset($longforlong[strtolower($srclang)])) $srclang = $longforlong[strtolower($srclang)];
}
else $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]);
else $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
}
else { // If it's for a codetouse that is a short code xx
// Array to convert short lang code into long code.
$longforshort=array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'nb'=>'nb_NO', 'no'=>'nb_NO');
if (isset($longforshort[strtolower($langpart[0])])) $srclang=$longforshort[strtolower($langpart[0])];
elseif (! empty($langpart[0])) $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]);
else $srclang='en_US';
$longforshort = array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'nb'=>'nb_NO', 'no'=>'nb_NO');
if (isset($longforshort[strtolower($langpart[0])])) $srclang = $longforshort[strtolower($langpart[0])];
elseif (!empty($langpart[0])) $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
else $srclang = 'en_US';
}
$this->defaultlang=$srclang;
$this->defaultlang = $srclang;
//print 'this->defaultlang='.$this->defaultlang;
}
@ -148,7 +148,7 @@ class Translate
*/
public function loadLangs($domains)
{
foreach($domains as $domain)
foreach ($domains as $domain)
{
$this->load($domain);
}
@ -176,7 +176,7 @@ class Translate
*/
public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0)
{
global $conf,$db;
global $conf, $db;
//dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang);
@ -186,18 +186,18 @@ class Translate
dol_print_error('', get_class($this)."::Load ErrorWrongParameters");
return -1;
}
if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys
if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys
// Load $this->tab_translate[] from database
if (empty($loadfromfileonly) && count($this->tab_translate) == 0) $this->loadFromDatabase($db); // No translation was never loaded yet, so we load database.
if (empty($loadfromfileonly) && count($this->tab_translate) == 0) $this->loadFromDatabase($db); // No translation was never loaded yet, so we load database.
$newdomain = $domain;
$modulename = '';
// Search if a module directory name is provided into lang file name
$regs=array();
$regs = array();
if (preg_match('/^([^@]+)@([^@]+)$/i', $domain, $regs))
{
$newdomain = $regs[1];
@ -205,19 +205,19 @@ class Translate
}
// Check cache
if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain
if (!empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain
{
//dol_syslog("Translate::Load already loaded for newdomain=".$newdomain);
return 0;
}
$fileread=0;
$langofdir=(empty($forcelangdir)?$this->defaultlang:$forcelangdir);
$fileread = 0;
$langofdir = (empty($forcelangdir) ? $this->defaultlang : $forcelangdir);
// Redefine alt
$langarray=explode('_', $langofdir);
if ($alt < 1 && isset($langarray[1]) && (strtolower($langarray[0]) == strtolower($langarray[1]) || in_array(strtolower($langofdir), array('el_gr')))) $alt=1;
if ($alt < 2 && strtolower($langofdir) == 'en_us') $alt=2;
$langarray = explode('_', $langofdir);
if ($alt < 1 && isset($langarray[1]) && (strtolower($langarray[0]) == strtolower($langarray[1]) || in_array(strtolower($langofdir), array('el_gr')))) $alt = 1;
if ($alt < 2 && strtolower($langofdir) == 'en_us') $alt = 2;
if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir
{
@ -225,13 +225,13 @@ class Translate
return -1;
}
foreach($this->dir as $searchdir)
foreach ($this->dir as $searchdir)
{
// Directory of translation files
$file_lang = $searchdir.($modulename?'/'.$modulename:'')."/langs/".$langofdir."/".$newdomain.".lang";
$file_lang_osencoded=dol_osencode($file_lang);
$file_lang = $searchdir.($modulename ? '/'.$modulename : '')."/langs/".$langofdir."/".$newdomain.".lang";
$file_lang_osencoded = dol_osencode($file_lang);
$filelangexists=is_file($file_lang_osencoded);
$filelangexists = is_file($file_lang_osencoded);
//dol_syslog(get_class($this).'::Load Try to read for alt='.$alt.' langofdir='.$langofdir.' domain='.$domain.' newdomain='.$newdomain.' modulename='.$modulename.' file_lang='.$file_lang." => filelangexists=".$filelangexists);
//print 'Try to read for alt='.$alt.' langofdir='.$langofdir.' domain='.$domain.' newdomain='.$newdomain.' modulename='.$modulename.' this->_tab_loaded[newdomain]='.$this->_tab_loaded[$newdomain].' file_lang='.$file_lang." => filelangexists=".$filelangexists."\n";
@ -239,19 +239,19 @@ class Translate
if ($filelangexists)
{
// TODO Move cache read out of loop on dirs or at least filelangexists
$found=false;
$found = false;
// Enable caching of lang file in memory (not by default)
$usecachekey='';
$usecachekey = '';
// Using a memcached server
if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER))
if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER))
{
$usecachekey=$newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars
$usecachekey = $newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars
}
// Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
{
$usecachekey=$newdomain;
$usecachekey = $newdomain;
}
if ($usecachekey)
@ -259,23 +259,23 @@ class Translate
//dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey);
//global $aaa; $aaa+=1;
//print $aaa." ".$usecachekey."\n";
require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php';
$tmparray=dol_getcache($usecachekey);
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$tmparray = dol_getcache($usecachekey);
if (is_array($tmparray) && count($tmparray))
{
$this->tab_translate+=$tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added.
$this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added.
//print $newdomain."\n";
//var_dump($this->tab_translate);
if ($alt == 2) $fileread=1;
$found=true; // Found in dolibarr PHP cache
if ($alt == 2) $fileread = 1;
$found = true; // Found in dolibarr PHP cache
}
}
if (! $found)
if (!$found)
{
if ($fp = @fopen($file_lang, "rt"))
{
if ($usecachekey) $tabtranslatedomain=array(); // To save lang content in cache
if ($usecachekey) $tabtranslatedomain = array(); // To save lang content in cache
/**
* Read each lines until a '=' (with any combination of spaces around it)
@ -316,21 +316,21 @@ class Translate
}
}
fclose($fp);
$fileread=1;
$fileread = 1;
// TODO Move cache write out of loop on dirs
// To save lang content for usecachekey into cache
if ($usecachekey && count($tabtranslatedomain))
{
$ressetcache=dol_setcache($usecachekey, $tabtranslatedomain);
$ressetcache = dol_setcache($usecachekey, $tabtranslatedomain);
if ($ressetcache < 0)
{
$error='Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
$error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
dol_syslog($error, LOG_ERR);
}
}
if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop.
if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop.
}
}
}
@ -341,10 +341,10 @@ class Translate
{
// This function MUST NOT contains call to syslog
//dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG);
$langofdir=strtolower($langarray[0]).'_'.strtoupper($langarray[0]);
if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR'
if ($langofdir == 'ar_AR') $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA'
$this->load($domain, $alt+1, $stopafterdirection, $langofdir);
$langofdir = strtolower($langarray[0]).'_'.strtoupper($langarray[0]);
if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR'
if ($langofdir == 'ar_AR') $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA'
$this->load($domain, $alt + 1, $stopafterdirection, $langofdir);
}
// Now we complete with reference file (en_US)
@ -352,38 +352,38 @@ class Translate
{
// This function MUST NOT contains call to syslog
//dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG);
$langofdir='en_US';
$this->load($domain, $alt+1, $stopafterdirection, $langofdir);
$langofdir = 'en_US';
$this->load($domain, $alt + 1, $stopafterdirection, $langofdir);
}
// We are in the pass of the reference file. No more files to scan to complete.
if ($alt == 2)
{
if ($fileread) $this->_tab_loaded[$newdomain]=1; // Set domain file as found so loaded
if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as found so loaded
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain]=2; // Set this file as not found
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Set this file as not found
}
// This part is deprecated and replaced with table llx_overwrite_trans
// Kept for backward compatibility.
if (empty($loadfromfileonly))
{
$overwritekey='MAIN_OVERWRITE_TRANS_'.$this->defaultlang;
if (! empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2
$overwritekey = 'MAIN_OVERWRITE_TRANS_'.$this->defaultlang;
if (!empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2
{
// Overwrite translation with param MAIN_OVERWRITE_TRANS_xx_XX
$tmparray=explode(',', $conf->global->$overwritekey);
foreach($tmparray as $tmp)
$tmparray = explode(',', $conf->global->$overwritekey);
foreach ($tmparray as $tmp)
{
$tmparray2=explode(':', $tmp);
if (! empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]]=$tmparray2[1];
$tmparray2 = explode(':', $tmp);
if (!empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]] = $tmparray2[1];
}
}
}
// Check to be sure that SeparatorDecimal differs from SeparatorThousand
if (! empty($this->tab_translate["SeparatorDecimal"]) && ! empty($this->tab_translate["SeparatorThousand"])
&& $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"]='';
if (!empty($this->tab_translate["SeparatorDecimal"]) && !empty($this->tab_translate["SeparatorThousand"])
&& $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"] = '';
return 1;
}
@ -404,26 +404,26 @@ class Translate
{
global $conf;
$domain='database';
$domain = 'database';
// Check parameters
if (empty($db)) return 0; // Database handler can't be used
if (empty($db)) return 0; // Database handler can't be used
//dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang);
$newdomain = $domain;
// Check cache
if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain 'database'
if (!empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain 'database'
{
//dol_syslog("Translate::Load already loaded for newdomain=".$newdomain);
return 0;
}
$this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database'
$this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database'
$fileread=0;
$langofdir=$this->defaultlang;
$fileread = 0;
$langofdir = $this->defaultlang;
if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir
{
@ -432,19 +432,19 @@ class Translate
}
// TODO Move cache read out of loop on dirs or at least filelangexists
$found=false;
$found = false;
// Enable caching of lang file in memory (not by default)
$usecachekey='';
$usecachekey = '';
// Using a memcached server
if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER))
if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER))
{
$usecachekey=$newdomain.'_'.$langofdir; // Should not contains special chars
$usecachekey = $newdomain.'_'.$langofdir; // Should not contains special chars
}
// Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
{
$usecachekey=$newdomain;
$usecachekey = $newdomain;
}
if ($usecachekey)
@ -452,40 +452,40 @@ class Translate
//dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey);
//global $aaa; $aaa+=1;
//print $aaa." ".$usecachekey."\n";
require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php';
$tmparray=dol_getcache($usecachekey);
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$tmparray = dol_getcache($usecachekey);
if (is_array($tmparray) && count($tmparray))
{
$this->tab_translate+=$tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added.
$this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added.
//print $newdomain."\n";
//var_dump($this->tab_translate);
$fileread=1;
$found=true; // Found in dolibarr PHP cache
$fileread = 1;
$found = true; // Found in dolibarr PHP cache
}
}
if (! $found && ! empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
if (!$found && !empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
{
// Overwrite translation with database read
$sql ="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL";
$sql.=" AND entity IN (0, ".getEntity('overwrite_trans').")";
$sql.=$db->order("lang", "DESC");
$resql=$db->query($sql);
$sql = "SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL";
$sql .= " AND entity IN (0, ".getEntity('overwrite_trans').")";
$sql .= $db->order("lang", "DESC");
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
if ($usecachekey) $tabtranslatedomain=array(); // To save lang content in cache
if ($usecachekey) $tabtranslatedomain = array(); // To save lang content in cache
$i = 0;
while ($i < $num) // Ex: Need 225ms for all fgets on all lang file for Third party page. Same speed than file_get_contents
{
$obj=$db->fetch_object($resql);
$obj = $db->fetch_object($resql);
$key=$obj->transkey;
$value=$obj->transvalue;
$key = $obj->transkey;
$value = $obj->transvalue;
//print "Domain=$domain, found a string for $tab[0] with value $tab[1]<br>";
if (empty($this->tab_translate[$key])) // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries)
@ -493,22 +493,22 @@ class Translate
// Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s'
$this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value);
if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache
if ($usecachekey) $tabtranslatedomain[$key] = $value; // To save lang content in cache
}
$i++;
}
$fileread=1;
$fileread = 1;
// TODO Move cache write out of loop on dirs
// To save lang content for usecachekey into cache
if ($usecachekey && count($tabtranslatedomain))
{
$ressetcache=dol_setcache($usecachekey, $tabtranslatedomain);
$ressetcache = dol_setcache($usecachekey, $tabtranslatedomain);
if ($ressetcache < 0)
{
$error='Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
$error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
dol_syslog($error, LOG_ERR);
}
}
@ -520,9 +520,9 @@ class Translate
}
}
if ($fileread) $this->_tab_loaded[$newdomain]=1; // Set domain file as loaded
if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as loaded
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain]=2; // Marque ce cas comme non trouve (no lines found for language)
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Marque ce cas comme non trouve (no lines found for language)
return 1;
}
@ -544,28 +544,28 @@ class Translate
{
global $conf, $db;
if (! is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
if (!is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
$newstr=$key;
$newstr = $key;
if (preg_match('/^Civility([0-9A-Z]+)$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label');
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label');
}
elseif (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_currencies', 'code_iso', 'label');
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_currencies', 'code_iso', 'label');
}
elseif (preg_match('/^SendingMethod([0-9A-Z]+)$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_shipment_mode', 'code', 'libelle');
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_shipment_mode', 'code', 'libelle');
}
elseif (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_paiement', 'code', 'libelle', '', 1);
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_paiement', 'code', 'libelle', '', 1);
}
elseif (preg_match('/^OppStatus([0-9A-Z]+)$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label');
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label');
}
elseif (preg_match('/^OrderSource([0-9A-Z]+)$/i', $key, $reg))
{
@ -601,37 +601,37 @@ class Translate
{
global $conf;
if (! empty($this->tab_translate[$key])) // Translation is available
if (!empty($this->tab_translate[$key])) // Translation is available
{
$str=$this->tab_translate[$key];
$str = $this->tab_translate[$key];
// Make some string replacement after translation
$replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
$replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (!empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
{
$tmparray=explode(';', $conf->global->$replacekey);
foreach($tmparray as $tmp)
$tmparray = explode(';', $conf->global->$replacekey);
foreach ($tmparray as $tmp)
{
$tmparray2=explode(':', $tmp);
$str=preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
$tmparray2 = explode(':', $tmp);
$str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
}
}
if (strpos($key, 'Format') !== 0)
{
$str=sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
$str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
}
if ($maxsize) $str=dol_trunc($str, $maxsize);
if ($maxsize) $str = dol_trunc($str, $maxsize);
// We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities
$str=str_replace(array('<','>','"',), array('__lt__','__gt__','__quot__'), $str);
$str = str_replace(array('<', '>', '"',), array('__lt__', '__gt__', '__quot__'), $str);
// Crypt string into HTML
$str=htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are enmbraced by "). Use dol_escape_htmltag around text in HTML content
$str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are enmbraced by "). Use dol_escape_htmltag around text in HTML content
// Restore HTML tags
$str=str_replace(array('__lt__','__gt__','__quot__'), array('<','>','"',), $str);
$str = str_replace(array('__lt__', '__gt__', '__quot__'), array('<', '>', '"',), $str);
return $str;
}
@ -682,26 +682,26 @@ class Translate
{
global $conf;
if (! empty($this->tab_translate[$key])) // Translation is available
if (!empty($this->tab_translate[$key])) // Translation is available
{
$str=$this->tab_translate[$key];
$str = $this->tab_translate[$key];
// Make some string replacement after translation
$replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
$replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (!empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
{
$tmparray=explode(';', $conf->global->$replacekey);
foreach($tmparray as $tmp)
$tmparray = explode(';', $conf->global->$replacekey);
foreach ($tmparray as $tmp)
{
$tmparray2=explode(':', $tmp);
$str=preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
$tmparray2 = explode(':', $tmp);
$str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
}
}
if (! preg_match('/^Format/', $key))
if (!preg_match('/^Format/', $key))
{
//print $str;
$str=sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings.
$str = sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings.
}
return $str;
@ -751,8 +751,8 @@ class Translate
*/
public function convToOutputCharset($str, $pagecodefrom = 'UTF-8')
{
if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str=utf8_encode($str);
if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str=utf8_decode(str_replace('€', chr(128), $str));
if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str = utf8_encode($str);
if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str = utf8_decode(str_replace('€', chr(128), $str));
return $str;
}
@ -772,21 +772,21 @@ class Translate
global $conf;
// We scan directory langs to detect available languages
$handle=opendir($langdir."/langs");
$langs_available=array();
$handle = opendir($langdir."/langs");
$langs_available = array();
while ($dir = trim(readdir($handle)))
{
if (preg_match('/^[a-z]+_[A-Z]+/i', $dir))
{
$this->load("languages");
if (! empty($conf->global->MAIN_LANGUAGES_ALLOWED) && ! in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED)) ) continue;
if (!empty($conf->global->MAIN_LANGUAGES_ALLOWED) && !in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED))) continue;
if ($usecode == 2)
{
$langs_available[$dir] = $dir;
}
if ($usecode == 1 || ! empty($conf->global->MAIN_SHOW_LANGUAGE_CODE))
if ($usecode == 1 || !empty($conf->global->MAIN_SHOW_LANGUAGE_CODE))
{
$langs_available[$dir] = $dir.': '.dol_trunc($this->trans('Language_'.$dir), $maxlength);
}
@ -812,7 +812,7 @@ class Translate
{
// phpcs:enable
// Test si fichier dans repertoire de la langue
foreach($this->dir as $searchdir)
foreach ($this->dir as $searchdir)
{
if (is_readable(dol_osencode($searchdir."/langs/".$this->defaultlang."/".$filename))) return true;
@ -844,22 +844,22 @@ class Translate
{
global $conf;
$newnumber=$number;
$newnumber = $number;
$dirsubstitutions=array_merge(array(), $conf->modules_parts['substitutions']);
foreach($dirsubstitutions as $reldir)
$dirsubstitutions = array_merge(array(), $conf->modules_parts['substitutions']);
foreach ($dirsubstitutions as $reldir)
{
$dir=dol_buildpath($reldir, 0);
$newdir=dol_osencode($dir);
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
// Check if directory exists
if (! is_dir($newdir)) continue; // We must not use dol_is_dir here, function may not be loaded
if (!is_dir($newdir)) continue; // We must not use dol_is_dir here, function may not be loaded
$fonc='numberwords';
$fonc = 'numberwords';
if (file_exists($newdir.'/functions_'.$fonc.'.lib.php'))
{
include_once $newdir.'/functions_'.$fonc.'.lib.php';
$newnumber=numberwords_getLabelFromNumber($this, $number, $isamount);
$newnumber = numberwords_getLabelFromNumber($this, $number, $isamount);
break;
}
}
@ -891,36 +891,36 @@ class Translate
//print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit;
// Check if a translation is available (this can call getTradFromKey)
$tmp=$this->transnoentitiesnoconv($key);
$tmp = $this->transnoentitiesnoconv($key);
if ($tmp != $key && $tmp != 'ErrorBadValueForParamNotAString')
{
return $tmp; // Found in language array
return $tmp; // Found in language array
}
// Check in cache
if (isset($this->cache_labels[$tablename][$key])) // Can be defined to 0 or ''
{
return $this->cache_labels[$tablename][$key]; // Found in cache
return $this->cache_labels[$tablename][$key]; // Found in cache
}
$sql = "SELECT ".$fieldlabel." as label";
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
$sql.= " WHERE ".$fieldkey." = '".$db->escape($keyforselect?$keyforselect:$key)."'";
if ($filteronentity) $sql.= " AND entity IN (" . getEntity($tablename). ')';
$sql .= " FROM ".MAIN_DB_PREFIX.$tablename;
$sql .= " WHERE ".$fieldkey." = '".$db->escape($keyforselect ? $keyforselect : $key)."'";
if ($filteronentity) $sql .= " AND entity IN (".getEntity($tablename).')';
dol_syslog(get_class($this).'::getLabelFromKey', LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $this->cache_labels[$tablename][$key]=$obj->label;
else $this->cache_labels[$tablename][$key]=$key;
if ($obj) $this->cache_labels[$tablename][$key] = $obj->label;
else $this->cache_labels[$tablename][$key] = $key;
$db->free($resql);
return $this->cache_labels[$tablename][$key];
}
else
{
$this->error=$db->lasterror();
$this->error = $db->lasterror();
return -1;
}
}
@ -937,7 +937,7 @@ class Translate
*/
public function getCurrencyAmount($currency_code, $amount)
{
$symbol=$this->getCurrencySymbol($currency_code);
$symbol = $this->getCurrencySymbol($currency_code);
if (in_array($currency_code, array('USD'))) return $symbol.$amount;
else return $amount.$symbol;
@ -953,22 +953,22 @@ class Translate
*/
public function getCurrencySymbol($currency_code, $forceloadall = 0)
{
$currency_sign = ''; // By default return iso code
$currency_sign = ''; // By default return iso code
if (function_exists("mb_convert_encoding"))
{
$this->loadCacheCurrencies($forceloadall?'':$currency_code);
$this->loadCacheCurrencies($forceloadall ? '' : $currency_code);
if (isset($this->cache_currencies[$currency_code]) && ! empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode']))
if (isset($this->cache_currencies[$currency_code]) && !empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode']))
{
foreach($this->cache_currencies[$currency_code]['unicode'] as $unicode)
foreach ($this->cache_currencies[$currency_code]['unicode'] as $unicode)
{
$currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES');
}
}
}
return ($currency_sign?$currency_sign:$currency_code);
return ($currency_sign ? $currency_sign : $currency_code);
}
/**
@ -981,13 +981,13 @@ class Translate
{
global $db;
if ($this->cache_currencies_all_loaded) return 0; // Cache already loaded for all
if (! empty($currency_code) && isset($this->cache_currencies[$currency_code])) return 0; // Cache already loaded for the currency
if ($this->cache_currencies_all_loaded) return 0; // Cache already loaded for all
if (!empty($currency_code) && isset($this->cache_currencies[$currency_code])) return 0; // Cache already loaded for the currency
$sql = "SELECT code_iso, label, unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE active = 1";
if (! empty($currency_code)) $sql.=" AND code_iso = '".$db->escape($currency_code)."'";
$sql .= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql .= " WHERE active = 1";
if (!empty($currency_code)) $sql .= " AND code_iso = '".$db->escape($currency_code)."'";
//$sql.= " ORDER BY code_iso ASC"; // Not required, a sort is done later
dol_syslog(get_class($this).'::loadCacheCurrencies', LOG_DEBUG);
@ -995,8 +995,8 @@ class Translate
if ($resql)
{
$this->load("dict");
$label=array();
if (! empty($currency_code)) foreach($this->cache_currencies as $key => $val) $label[$key]=$val['label']; // Label in already loaded cache
$label = array();
if (!empty($currency_code)) foreach ($this->cache_currencies as $key => $val) $label[$key] = $val['label']; // Label in already loaded cache
$num = $db->num_rows($resql);
$i = 0;
@ -1005,12 +1005,12 @@ class Translate
$obj = $db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$this->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso) != "Currency".$obj->code_iso ? $this->trans("Currency".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
$i++;
}
if (empty($currency_code)) $this->cache_currencies_all_loaded=true;
if (empty($currency_code)) $this->cache_currencies_all_loaded = true;
//print count($label).' '.count($this->cache_currencies);
// Resort cache
@ -1037,7 +1037,7 @@ class Translate
// phpcs:enable
$substitutionarray = array();
foreach($this->tab_translate as $code => $label) {
foreach ($this->tab_translate as $code => $label) {
$substitutionarray['lang_'.$code] = $label;
$substitutionarray['__('.$code.')__'] = $label;
}

View File

@ -30,7 +30,7 @@
* \ingroup agenda
* \brief File of class to describe and enable/disable module Agenda
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
* Class to describe and enable/disable module Agenda
@ -59,7 +59,7 @@ class modAgenda extends DolibarrModules
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->picto='action';
$this->picto = 'action';
// Data directories to create when module is enabled
$this->dirs = array("/agenda/temp");
@ -68,12 +68,12 @@ class modAgenda extends DolibarrModules
$this->config_page_url = array("agenda_other.php");
// Dependencies
$this->hidden = false; // A condition to hide module
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
$this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->hidden = false; // A condition to hide module
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
$this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->langfiles = array("companies");
$this->phpmin = array(5,4); // Minimum version of PHP required by module
$this->phpmin = array(5, 4); // Minimum version of PHP required by module
// Module parts
$this->module_parts = array();
@ -86,14 +86,14 @@ class modAgenda extends DolibarrModules
// );
$this->const = array();
//$this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current');
$sqlreadactions="SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang";
$sqlreadactions = "SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang";
$resql = $this->db->query($sqlreadactions);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
//if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation).
if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default.
if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default.
//if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default.
$this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current');
}
@ -109,11 +109,11 @@ class modAgenda extends DolibarrModules
// Boxes
//------
$this->boxes = array(0=>array('file'=>'box_actions.php','enabledbydefaulton'=>'Home'));
$this->boxes = array(0=>array('file'=>'box_actions.php', 'enabledbydefaulton'=>'Home'));
// Cronjobs
//------------
$datestart=dol_now();
$datestart = dol_now();
$this->cronjobs = array(
0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>10, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->agenda->enabled', 'datestart'=>$datestart),
);
@ -122,7 +122,7 @@ class modAgenda extends DolibarrModules
//------------
$this->rights = array();
$this->rights_class = 'agenda';
$r=0;
$r = 0;
// $this->rights[$r][0] Id permission (unique tous modules confondus)
// $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
@ -187,8 +187,8 @@ class modAgenda extends DolibarrModules
$this->rights[$r][4] = 'export';
// Main menu entries
$this->menu = array(); // List of menus to add
$r=0;
$this->menu = array(); // List of menus to add
$r = 0;
// Add here entries to declare new menus
// Example to declare the Top Menu entry:
@ -204,7 +204,7 @@ class modAgenda extends DolibarrModules
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
$this->menu[$r]=array(
$this->menu[$r] = array(
'fk_menu'=>0,
'type'=>'top',
'titre'=>'TMenuAgenda',
@ -424,50 +424,50 @@ class modAgenda extends DolibarrModules
// Exports
//--------
$r=0;
$r = 0;
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]="ExportDataset_event1";
$this->export_permission[$r]=array(array("agenda","export"));
$this->export_fields_array[$r]=array('ac.id'=>"IdAgenda",'ac.ref_ext'=>"ExternalRef",'ac.datec'=>"DateCreation",'ac.datep'=>"DateActionBegin",
'ac.datep2'=>"DateActionEnd",'ac.label'=>"Title",'ac.note'=>"Note",'ac.percent'=>"Percent",'ac.durationp'=>"Duration",
$this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r] = "ExportDataset_event1";
$this->export_permission[$r] = array(array("agenda", "export"));
$this->export_fields_array[$r] = array('ac.id'=>"IdAgenda", 'ac.ref_ext'=>"ExternalRef", 'ac.datec'=>"DateCreation", 'ac.datep'=>"DateActionBegin",
'ac.datep2'=>"DateActionEnd", 'ac.label'=>"Title", 'ac.note'=>"Note", 'ac.percent'=>"Percent", 'ac.durationp'=>"Duration",
'cac.libelle'=>"ActionType",
's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',
'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
's.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra',
's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town',
'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
'p.ref' => 'ProjectRef',
);
$this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date",
'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric",
$this->export_TypeFields_array[$r] = array('ac.ref_ext'=>"Text", 'ac.datec'=>"Date", 'ac.datep'=>"Date",
'ac.datep2'=>"Date", 'ac.label'=>"Text", 'ac.note'=>"Text", 'ac.percent'=>"Numeric",
'ac.durationp'=>"Duree",
'cac.libelle'=>"List:c_actioncomm:libelle:libelle",
's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text',
's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text',
's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text',
'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text',
's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
'p.ref' => 'Text',
);
$this->export_entities_array[$r]=array('ac.id'=>"action",'ac.ref_ext'=>"action",'ac.datec'=>"action",'ac.datep'=>"action",
'ac.datep2'=>"action",'ac.label'=>"action",'ac.note'=>"action",'ac.percent'=>"action",'ac.durationp'=>"action",
$this->export_entities_array[$r] = array('ac.id'=>"action", 'ac.ref_ext'=>"action", 'ac.datec'=>"action", 'ac.datep'=>"action",
'ac.datep2'=>"action", 'ac.label'=>"action", 'ac.note'=>"action", 'ac.percent'=>"action", 'ac.durationp'=>"action",
'cac.libelle'=>"action",
's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',
'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company',
's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company',
's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company',
'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company',
's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',
'p.ref' => 'project',
);
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
if (! empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
if (! empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet as p ON p.rowid = ac.fk_project";
$this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')';
if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)';
if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id);
$this->export_sql_order[$r] =' ORDER BY ac.datep';
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
if (!empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
if (!empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
$this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project";
$this->export_sql_end[$r] .= ' WHERE ac.entity IN ('.getEntity('agenda').')';
if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
$this->export_sql_order[$r] = ' ORDER BY ac.datep';
}
}

View File

@ -28,14 +28,14 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
// Load translation files required by the page
$langs->loadLangs(array("loan","compta","banks","bills"));
$langs->loadLangs(array("loan", "compta", "banks", "bills"));
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'loan', '', '', '');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -144,18 +144,18 @@ if ($resql)
{
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
if ($search_label) $param.="&search_label=".urlencode($search_label);
if ($search_amount) $param.="&search_amount=".urlencode($search_amount);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_amount) $param .= "&search_amount=".urlencode($search_amount);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
$newcardbutton='';
$newcardbutton = '';
if ($user->rights->loan->write)
{
$newcardbutton.= dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/loan/card.php?action=create');
$newcardbutton .= dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/loan/card.php?action=create');
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";

View File

@ -45,10 +45,10 @@ function moPrepareHead($object)
$head[$h][1] = $langs->trans("Production");
$arrayproduced = $object->fetchLinesLinked('produced', 0);
$nbProduced = 0;
foreach($arrayproduced as $lineproduced) {
foreach ($arrayproduced as $lineproduced) {
$nbProduced += $lineproduced['qty'];
}
$head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbProduced.' / '.$object->qty.'</span>';
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbProduced.' / '.$object->qty.'</span>';
$head[$h][2] = 'production';
$h++;
@ -59,19 +59,19 @@ function moPrepareHead($object)
if (!empty($object->note_public)) $nbNote++;
$head[$h][0] = dol_buildpath('/mrp/mo_note.php', 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
$head[$h][2] = 'note';
$h++;
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->mrp->dir_output . "/mo/" . dol_sanitizeFileName($object->ref);
$upload_dir = $conf->mrp->dir_output."/mo/".dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id);
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = dol_buildpath("/mrp/mo_document.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
$head[$h][2] = 'document';
$h++;

View File

@ -136,7 +136,7 @@ if (empty($reshook))
else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__');
}
}
if ($cancel && ! empty($backtopageforcancel)) {
if ($cancel && !empty($backtopageforcancel)) {
$backtopage = $backtopageforcancel;
}
@ -522,7 +522,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (!empty($object->lines))
{
$i = 0;
foreach($object->lines as $line) {
foreach ($object->lines as $line) {
if ($line->role == 'toconsume') {
if ($i) print ', ';
$tmpproduct = new Product($db);
@ -541,7 +541,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (!empty($object->lines))
{
$i = 0;
foreach($object->lines as $line) {
foreach ($object->lines as $line) {
if ($line->role == 'toproduce') {
if ($i) print ', ';
$tmpproduct = new Product($db);

View File

@ -124,19 +124,19 @@ class MouvementStock extends CommonObject
dol_syslog(get_class($this)."::_create start userid=$user->id, fk_product=$fk_product, warehouse_id=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode, datem=".$datem.", eatby=".$eatby.", sellby=".$sellby.", batch=".$batch.", skip_batch=".$skip_batch);
// Clean parameters
if (empty($price)) $price=0;
$now=(! empty($datem) ? $datem : dol_now());
if (empty($price)) $price = 0;
$now = (!empty($datem) ? $datem : dol_now());
// Check parameters
if (empty($fk_product)) return 0;
if ($eatby < 0)
{
$this->errors[]='ErrorBadValueForParameterEatBy';
$this->errors[] = 'ErrorBadValueForParameterEatBy';
return -1;
}
if ($sellby < 0)
{
$this->errors[]='ErrorBadValueForParameterSellBy';
$this->errors[] = 'ErrorBadValueForParameterSellBy';
return -1;
}
@ -155,7 +155,7 @@ class MouvementStock extends CommonObject
$mvid = 0;
$product = new Product($this->db);
$result=$product->fetch($fk_product);
$result = $product->fetch($fk_product);
if ($result < 0)
{
dol_print_error('', "Failed to fetch product");
@ -167,11 +167,11 @@ class MouvementStock extends CommonObject
$product->load_stock('novirtual');
// Test if product require batch data. If yes, and there is not, we throw an error.
if (! empty($conf->productbatch->enabled) && $product->hasbatch() && ! $skip_batch)
if (!empty($conf->productbatch->enabled) && $product->hasbatch() && !$skip_batch)
{
if (empty($batch))
{
$this->errors[]=$langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref);
$this->errors[] = $langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref);
dol_syslog("Try to make a movement of a product with status_batch on without any batch data");
$this->db->rollback();
@ -185,13 +185,13 @@ class MouvementStock extends CommonObject
// If found and eatby/sellby not defined into table and not provided, we do nothing
// If not found, we add record
$sql = "SELECT pb.rowid, pb.batch, pb.eatby, pb.sellby FROM ".MAIN_DB_PREFIX."product_lot as pb";
$sql.= " WHERE pb.fk_product = ".$fk_product." AND pb.batch = '".$this->db->escape($batch)."'";
$sql .= " WHERE pb.fk_product = ".$fk_product." AND pb.batch = '".$this->db->escape($batch)."'";
dol_syslog(get_class($this)."::_create scan serial for this product to check if eatby and sellby match", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i=0;
$i = 0;
if ($num > 0)
{
while ($i < $num)
@ -201,12 +201,12 @@ class MouvementStock extends CommonObject
{
if ($eatby)
{
$tmparray=dol_getdate($eatby, true);
$eatbywithouthour=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);
$tmparray = dol_getdate($eatby, true);
$eatbywithouthour = dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);
if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility
{
// If found and eatby/sellby defined into table and provided and differs, return error
$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatby, 'dayhour'));
$this->errors[] = $langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatby, 'dayhour'));
dol_syslog("ThisSerialAlreadyExistWithDifferentDate batch=".$batch.", eatby found into product_lot = ".$obj->eatby." = ".dol_print_date($this->db->jdate($obj->eatby), 'dayhourrfc')." so eatbywithouthour = ".$eatbywithouthour." = ".dol_print_date($eatbywithouthour)." - eatby provided = ".$eatby." = ".dol_print_date($eatby, 'dayhourrfc'), LOG_ERR);
$this->db->rollback();
return -3;
@ -238,12 +238,12 @@ class MouvementStock extends CommonObject
{
if ($sellby)
{
$tmparray=dol_getdate($sellby, true);
$sellbywithouthour=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);
$tmparray = dol_getdate($sellby, true);
$sellbywithouthour = dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);
if ($this->db->jdate($obj->sellby) != $sellby && $this->db->jdate($obj->sellby) != $sellbywithouthour) // We test date without hours and with hours for backward compatibility
{
// If found and eatby/sellby defined into table and provided and differs, return error
$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby));
$this->errors[] = $langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby));
dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR);
$this->db->rollback();
return -3;
@ -303,25 +303,25 @@ class MouvementStock extends CommonObject
}
// Define if we must make the stock change (If product type is a service or if stock is used also for services)
$movestock=0;
if ($product->type != Product::TYPE_SERVICE || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1;
$movestock = 0;
if ($product->type != Product::TYPE_SERVICE || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock = 1;
// Check if stock is enough when qty is < 0
// Note that qty should be > 0 with type 0 or 3, < 0 with type 1 or 2.
if ($movestock && $qty < 0 && empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER))
{
if (! empty($conf->productbatch->enabled) && $product->hasbatch() && ! $skip_batch)
if (!empty($conf->productbatch->enabled) && $product->hasbatch() && !$skip_batch)
{
$foundforbatch=0;
$qtyisnotenough=0;
foreach($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch)
$foundforbatch = 0;
$qtyisnotenough = 0;
foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch)
{
if ($batch != $batchcursor) continue;
$foundforbatch=1;
$foundforbatch = 1;
if ($prodbatch->qty < abs($qty)) $qtyisnotenough = $prodbatch->qty;
break;
}
if (! $foundforbatch || $qtyisnotenough)
if (!$foundforbatch || $qtyisnotenough)
{
$langs->load("stocks");
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
@ -350,10 +350,10 @@ class MouvementStock extends CommonObject
if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after
{
$fk_project = 0;
if(!empty($this->origin)) { // This is set by caller for tracking reason
if (!empty($this->origin)) { // This is set by caller for tracking reason
$origintype = $this->origin->element;
$fk_origin = $this->origin->id;
if($origintype == 'project') $fk_project = $fk_origin;
if ($origintype == 'project') $fk_project = $fk_origin;
else
{
$res = $this->origin->fetch($fk_origin);
@ -372,22 +372,22 @@ class MouvementStock extends CommonObject
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement(";
$sql.= " datem, fk_product, batch, eatby, sellby,";
$sql.= " fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype, fk_projet";
$sql.= ")";
$sql.= " VALUES ('".$this->db->idate($now)."', ".$this->product_id.", ";
$sql.= " ".($batch?"'".$batch."'":"null").", ";
$sql.= " ".($eatby?"'".$this->db->idate($eatby)."'":"null").", ";
$sql.= " ".($sellby?"'".$this->db->idate($sellby)."'":"null").", ";
$sql.= " ".$this->entrepot_id.", ".$this->qty.", ".$this->type.",";
$sql.= " ".$user->id.",";
$sql.= " '".$this->db->escape($label)."',";
$sql.= " ".($inventorycode?"'".$this->db->escape($inventorycode)."'":"null").",";
$sql.= " '".price2num($price)."',";
$sql.= " '".$fk_origin."',";
$sql.= " '".$origintype."',";
$sql.= " ". $fk_project;
$sql.= ")";
$sql .= " datem, fk_product, batch, eatby, sellby,";
$sql .= " fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype, fk_projet";
$sql .= ")";
$sql .= " VALUES ('".$this->db->idate($now)."', ".$this->product_id.", ";
$sql .= " ".($batch ? "'".$batch."'" : "null").", ";
$sql .= " ".($eatby ? "'".$this->db->idate($eatby)."'" : "null").", ";
$sql .= " ".($sellby ? "'".$this->db->idate($sellby)."'" : "null").", ";
$sql .= " ".$this->entrepot_id.", ".$this->qty.", ".$this->type.",";
$sql .= " ".$user->id.",";
$sql .= " '".$this->db->escape($label)."',";
$sql .= " ".($inventorycode ? "'".$this->db->escape($inventorycode)."'" : "null").",";
$sql .= " '".price2num($price)."',";
$sql .= " '".$fk_origin."',";
$sql .= " '".$origintype."',";
$sql .= " ".$fk_project;
$sql .= ")";
dol_syslog(get_class($this)."::_create insert record into stock_mouvement", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -399,24 +399,24 @@ class MouvementStock extends CommonObject
}
else
{
$this->errors[]=$this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error = -1;
}
// Define current values for qty and pmp
$oldqty=$product->stock_reel;
$oldpmp=$product->pmp;
$oldqtywarehouse=0;
$oldqty = $product->stock_reel;
$oldpmp = $product->pmp;
$oldqtywarehouse = 0;
// Test if there is already a record for couple (warehouse / product)
$alreadyarecord = 0;
if (! $error)
if (!$error)
{
$sql = "SELECT rowid, reel FROM ".MAIN_DB_PREFIX."product_stock";
$sql.= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product; // This is a unique key
$sql .= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product; // This is a unique key
dol_syslog(get_class($this)."::_create check if a record already exists in product_stock", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
@ -430,25 +430,25 @@ class MouvementStock extends CommonObject
}
else
{
$this->errors[]=$this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error = -2;
}
}
// Calculate new PMP.
$newpmp=0;
if (! $error)
$newpmp = 0;
if (!$error)
{
// Note: PMP is calculated on stock input only (type of movement = 0 or 3). If type == 0 or 3, qty should be > 0.
// Note: Price should always be >0 or 0. PMP should be always >0 (calculated on input)
if (($type == 0 || $type == 3) && $price > 0)
{
$oldqtytouse=($oldqty >= 0?$oldqty:0);
$oldqtytouse = ($oldqty >= 0 ? $oldqty : 0);
// We make a test on oldpmp>0 to avoid to use normal rule on old data with no pmp field defined
if ($oldpmp > 0) $newpmp=price2num((($oldqtytouse * $oldpmp) + ($qty * $price)) / ($oldqtytouse + $qty), 'MU');
if ($oldpmp > 0) $newpmp = price2num((($oldqtytouse * $oldpmp) + ($qty * $price)) / ($oldqtytouse + $qty), 'MU');
else
{
$newpmp=$price; // For this product, PMP was not yet set. We set it to input price.
$newpmp = $price; // For this product, PMP was not yet set. We set it to input price.
}
//print "oldqtytouse=".$oldqtytouse." oldpmp=".$oldpmp." oldqtywarehousetouse=".$oldqtywarehousetouse." ";
//print "qty=".$qty." newpmp=".$newpmp;
@ -465,25 +465,25 @@ class MouvementStock extends CommonObject
}
}
// Update stock quantity
if (! $error)
if (!$error)
{
if ($alreadyarecord > 0)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + ".$qty;
$sql.= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product;
$sql .= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product;
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock";
$sql.= " (reel, fk_entrepot, fk_product) VALUES ";
$sql.= " (".$qty.", ".$entrepot_id.", ".$fk_product.")";
$sql .= " (reel, fk_entrepot, fk_product) VALUES ";
$sql .= " (".$qty.", ".$entrepot_id.", ".$fk_product.")";
}
dol_syslog(get_class($this)."::_create update stock value", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
$resql = $this->db->query($sql);
if (!$resql)
{
$this->errors[]=$this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error = -3;
}
elseif (empty($fk_product_stock))
@ -493,61 +493,61 @@ class MouvementStock extends CommonObject
}
// Update detail stock for batch product
if (! $error && ! empty($conf->productbatch->enabled) && $product->hasbatch() && ! $skip_batch)
if (!$error && !empty($conf->productbatch->enabled) && $product->hasbatch() && !$skip_batch)
{
if ($id_product_batch > 0)
{
$result=$this->createBatch($id_product_batch, $qty);
$result = $this->createBatch($id_product_batch, $qty);
}
else
{
$param_batch=array('fk_product_stock' =>$fk_product_stock, 'batchnumber'=>$batch);
$result=$this->createBatch($param_batch, $qty);
$param_batch = array('fk_product_stock' =>$fk_product_stock, 'batchnumber'=>$batch);
$result = $this->createBatch($param_batch, $qty);
}
if ($result<0) $error++;
if ($result < 0) $error++;
}
// Update PMP and denormalized value of stock qty at product level
if (! $error)
if (!$error)
{
// $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty;
// $sql.= " WHERE rowid = ".$fk_product;
// Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql
$sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$newpmp.", ";
$sql.= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)";
$sql.= " WHERE rowid = ".$fk_product;
$sql .= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)";
$sql .= " WHERE rowid = ".$fk_product;
dol_syslog(get_class($this)."::_create update AWP", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
$resql = $this->db->query($sql);
if (!$resql)
{
$this->errors[]=$this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error = -4;
}
}
// If stock is now 0, we can remove entry into llx_product_stock, but only if there is no child lines into llx_product_batch (detail of batch, because we can imagine
// having a lot1/qty=X and lot2/qty=-X, so 0 but we must not loose repartition of different lot.
$sql="DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)";
$resql=$this->db->query($sql);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX."product_batch as pb)";
$resql = $this->db->query($sql);
// We do not test error, it can fails if there is child in batch details
}
// Add movement for sub products (recursive call)
if (! $error && ! empty($conf->global->PRODUIT_SOUSPRODUITS) && empty($conf->global->INDEPENDANT_SUBPRODUCT_STOCK))
if (!$error && !empty($conf->global->PRODUIT_SOUSPRODUITS) && empty($conf->global->INDEPENDANT_SUBPRODUCT_STOCK))
{
$error = $this->_createSubProduct($user, $fk_product, $entrepot_id, $qty, $type, 0, $label, $inventorycode); // we use 0 as price, because pmp is not changed for subproduct
$error = $this->_createSubProduct($user, $fk_product, $entrepot_id, $qty, $type, 0, $label, $inventorycode); // we use 0 as price, because pmp is not changed for subproduct
}
if ($movestock && ! $error)
if ($movestock && !$error)
{
// Call trigger
$result=$this->call_trigger('STOCK_MOVEMENT', $user);
$result = $this->call_trigger('STOCK_MOVEMENT', $user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
if (!$error)
{
$this->db->commit();
return $mvid;
@ -591,12 +591,12 @@ class MouvementStock extends CommonObject
$sql .= " t.eatby,";
$sql .= " t.sellby,";
$sql .= " t.fk_projet as fk_project";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql.= ' WHERE 1 = 1';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE 1 = 1';
//if (null !== $ref) {
//$sql .= ' AND t.ref = ' . '\'' . $ref . '\'';
//} else {
$sql .= ' AND t.rowid = ' . $id;
$sql .= ' AND t.rowid = '.$id;
//}
$resql = $this->db->query($sql);
@ -640,10 +640,10 @@ class MouvementStock extends CommonObject
return 0;
}
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
return - 1;
return -1;
}
}
@ -672,19 +672,19 @@ class MouvementStock extends CommonObject
$pqtys = array();
$sql = "SELECT fk_product_pere, fk_product_fils, qty";
$sql.= " FROM ".MAIN_DB_PREFIX."product_association";
$sql.= " WHERE fk_product_pere = ".$idProduct;
$sql.= " AND incdec = 1";
$sql .= " FROM ".MAIN_DB_PREFIX."product_association";
$sql .= " WHERE fk_product_pere = ".$idProduct;
$sql .= " AND incdec = 1";
dol_syslog(get_class($this)."::_createSubProduct for parent product ".$idProduct, LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$i=0;
while ($obj=$this->db->fetch_object($resql))
$i = 0;
while ($obj = $this->db->fetch_object($resql))
{
$pids[$i]=$obj->fk_product_fils;
$pqtys[$i]=$obj->qty;
$pids[$i] = $obj->fk_product_fils;
$pqtys[$i] = $obj->qty;
$i++;
}
$this->db->free($resql);
@ -695,12 +695,12 @@ class MouvementStock extends CommonObject
}
// Create movement for each subproduct
foreach($pids as $key => $value)
foreach ($pids as $key => $value)
{
if (! $error)
if (!$error)
{
$tmpmove = clone $this;
$result = $tmpmove->_create($user, $pids[$key], $entrepot_id, ($qty * $pqtys[$key]), $type, 0, $label, $inventorycode); // This will also call _createSubProduct making this recursive
$result = $tmpmove->_create($user, $pids[$key], $entrepot_id, ($qty * $pqtys[$key]), $type, 0, $label, $inventorycode); // This will also call _createSubProduct making this recursive
if ($result < 0)
{
$this->error = $tmpmove->error;
@ -736,7 +736,7 @@ class MouvementStock extends CommonObject
* @param string $inventorycode Inventory code
* @return int <0 if KO, >0 if OK
*/
public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0, $inventorycode='')
public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $id_product_batch = 0, $inventorycode = '')
{
global $conf;
@ -762,7 +762,7 @@ class MouvementStock extends CommonObject
* @param string $inventorycode Inventory code
* @return int <0 if KO, >0 if OK
*/
public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '', $datem = '', $id_product_batch = 0, $inventorycode='')
public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '', $datem = '', $id_product_batch = 0, $inventorycode = '')
{
global $conf;
@ -803,19 +803,19 @@ class MouvementStock extends CommonObject
*/
public function calculateBalanceForProductBefore($productidselected, $datebefore)
{
$nb=0;
$nb = 0;
$sql = 'SELECT SUM(value) as nb from '.MAIN_DB_PREFIX.'stock_mouvement';
$sql.= ' WHERE fk_product = '.$productidselected;
$sql.= " AND datem < '".$this->db->idate($datebefore)."'";
$sql .= ' WHERE fk_product = '.$productidselected;
$sql .= " AND datem < '".$this->db->idate($datebefore)."'";
dol_syslog(get_class($this).__METHOD__.'', LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$obj=$this->db->fetch_object($resql);
$obj = $this->db->fetch_object($resql);
if ($obj) $nb = $obj->nb;
return (empty($nb)?0:$nb);
return (empty($nb) ? 0 : $nb);
}
else
{
@ -837,14 +837,14 @@ class MouvementStock extends CommonObject
{
global $user;
$pdluo=new Productbatch($this->db);
$pdluo = new Productbatch($this->db);
$result=0;
$result = 0;
// Try to find an existing record with same batch number or id
if (is_numeric($dluo))
{
$result=$pdluo->fetch($dluo);
$result = $pdluo->fetch($dluo);
if (empty($pdluo->id))
{
// We didn't find the line. May be it was deleted before by a previous move in same transaction.
@ -857,10 +857,10 @@ class MouvementStock extends CommonObject
{
if (isset($dluo['fk_product_stock']))
{
$vfk_product_stock=$dluo['fk_product_stock'];
$vfk_product_stock = $dluo['fk_product_stock'];
$vbatchnumber = $dluo['batchnumber'];
$result = $pdluo->find($vfk_product_stock, '', '', $vbatchnumber); // Search on batch number only (eatby and sellby are deprecated here)
$result = $pdluo->find($vfk_product_stock, '', '', $vbatchnumber); // Search on batch number only (eatby and sellby are deprecated here)
}
else
{
@ -883,24 +883,24 @@ class MouvementStock extends CommonObject
$pdluo->qty += $qty;
if ($pdluo->qty == 0)
{
$result=$pdluo->delete($user, 1);
$result = $pdluo->delete($user, 1);
} else {
$result=$pdluo->update($user, 1);
$result = $pdluo->update($user, 1);
}
}
else // product_batch record not found
{
$pdluo->fk_product_stock=$vfk_product_stock;
$pdluo->fk_product_stock = $vfk_product_stock;
$pdluo->qty = $qty;
$pdluo->eatby = $veatby;
$pdluo->sellby = $vsellby;
$pdluo->batch = $vbatchnumber;
$result=$pdluo->create($user, 1);
$result = $pdluo->create($user, 1);
if ($result < 0)
{
$this->error=$pdluo->error;
$this->errors=$pdluo->errors;
$this->error = $pdluo->error;
$this->errors = $pdluo->errors;
}
}
}
@ -919,7 +919,7 @@ class MouvementStock extends CommonObject
public function get_origin($fk_origin, $origintype)
{
// phpcs:enable
$origin='';
$origin = '';
switch ($origintype) {
case 'commande':
@ -954,7 +954,7 @@ class MouvementStock extends CommonObject
default:
if ($origintype)
{
$result=dol_include_once('/'.$origintype.'/class/'.$origintype.'.class.php');
$result = dol_include_once('/'.$origintype.'/class/'.$origintype.'.class.php');
if ($result)
{
$classname = ucfirst($origintype);
@ -964,7 +964,7 @@ class MouvementStock extends CommonObject
break;
}
if (empty($origin) || ! is_object($origin)) return '';
if (empty($origin) || !is_object($origin)) return '';
if ($origin->fetch($fk_origin) > 0) {
return $origin->getNomUrl(1);
@ -985,7 +985,7 @@ class MouvementStock extends CommonObject
{
if (!empty($origin_element) && $origin_id > 0)
{
$origin='';
$origin = '';
if ($origin_element == 'project')
{
if (!class_exists('Project')) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@ -1010,10 +1010,10 @@ class MouvementStock extends CommonObject
*/
public function initAsSpecimen()
{
global $user,$langs,$conf,$mysoc;
global $user, $langs, $conf, $mysoc;
// Initialize parameters
$this->id=0;
$this->id = 0;
// There is no specific properties. All data into insert are provided as method parameter.
}
@ -1036,23 +1036,23 @@ class MouvementStock extends CommonObject
$result = '';
$companylink = '';
$label = '<u>' . $langs->trans("Movement") . ' '.$this->id.'</u>';
$label.= '<div width="100%">';
$label.= '<b>' . $langs->trans('Label') . ':</b> ' . $this->label;
$label.= '<br><b>' . $langs->trans('Qty') . ':</b> ' .$this->qty;
$label.= '</div>';
$label = '<u>'.$langs->trans("Movement").' '.$this->id.'</u>';
$label .= '<div width="100%">';
$label .= '<b>'.$langs->trans('Label').':</b> '.$this->label;
$label .= '<br><b>'.$langs->trans('Qty').':</b> '.$this->qty;
$label .= '</div>';
$link = '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$this->warehouse_id.'&msid='.$this->id.'"';
$link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
$link.= '>';
$linkend='</a>';
$link .= ($notooltip ? '' : ' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss ? ' '.$morecss : '').'"');
$link .= '>';
$linkend = '</a>';
if ($withpicto)
{
$result.=($link.img_object(($notooltip?'':$label), 'stock', ($notooltip?'':'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result.=' ';
$result .= ($link.img_object(($notooltip ? '' : $label), 'stock', ($notooltip ? '' : 'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result .= ' ';
}
$result.= $link . $this->id . $linkend;
$result .= $link.$this->id.$linkend;
return $result;
}
@ -1113,16 +1113,16 @@ class MouvementStock extends CommonObject
*/
public function generateDocument($modele, $outputlangs = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $conf,$user,$langs;
global $conf, $user, $langs;
$langs->load("stocks");
if (! dol_strlen($modele)) {
if (!dol_strlen($modele)) {
$modele = 'stdmovement';
if ($this->modelpdf) {
$modele = $this->modelpdf;
} elseif (! empty($conf->global->MOUVEMENT_ADDON_PDF)) {
} elseif (!empty($conf->global->MOUVEMENT_ADDON_PDF)) {
$modele = $conf->global->MOUVEMENT_ADDON_PDF;
}
}

View File

@ -436,14 +436,14 @@ class WebsitePage extends CommonObject
$object = new self($this->db);
// Clean parameters
if (empty($newref) && ! empty($newtitle)) {
$newref=strtolower(dol_sanitizeFileName(preg_replace('/\s+/', '-', $newtitle), '-', 1));
if (empty($newref) && !empty($newtitle)) {
$newref = strtolower(dol_sanitizeFileName(preg_replace('/\s+/', '-', $newtitle), '-', 1));
}
// Check parameters
if (empty($newref)) {
$langs->load("errors");
$this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE"));
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE"));
return -1;
}