Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2020-01-09 23:03:10 +00:00
parent 0e58edd896
commit 8691194627
4 changed files with 201 additions and 201 deletions

View File

@ -573,7 +573,7 @@ function isValidVATID($company)
elseif ($vatprefix == 'MC') $vatprefix = 'FR'; // Monaco is using french VAT numbers elseif ($vatprefix == 'MC') $vatprefix = 'FR'; // Monaco is using french VAT numbers
else $vatprefix = preg_quote($vatprefix, '/');*/ else $vatprefix = preg_quote($vatprefix, '/');*/
$vatprefix = '[a-zA-Z][a-zA-Z]'; $vatprefix = '[a-zA-Z][a-zA-Z]';
if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra))) if (!preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra)))
{ {
return 0; return 0;
} }
@ -732,17 +732,17 @@ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = '
*/ */
function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $date = '', $mode = 'next', $bentityon = true, $objuser = null, $forceentity = null) function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $date = '', $mode = 'next', $bentityon = true, $objuser = null, $forceentity = null)
{ {
global $conf,$user; global $conf, $user;
if (! is_object($objsoc)) $valueforccc=$objsoc; if (!is_object($objsoc)) $valueforccc = $objsoc;
elseif ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=dol_string_unaccent($objsoc->code_fournisseur); elseif ($table == "commande_fournisseur" || $table == "facture_fourn") $valueforccc = dol_string_unaccent($objsoc->code_fournisseur);
else $valueforccc=dol_string_unaccent($objsoc->code_client); else $valueforccc = dol_string_unaccent($objsoc->code_client);
$sharetable = $table; $sharetable = $table;
if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function
// Clean parameters // Clean parameters
if ($date == '') $date=dol_now(); // We use local year and month of PHP server to search numbers if ($date == '') $date = dol_now(); // We use local year and month of PHP server to search numbers
// but we should use local year and month of user // but we should use local year and month of user
// For debugging // For debugging
@ -811,73 +811,73 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
$lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
if (is_object($objuser)) $lastname = $objuser->lastname; if (is_object($objuser)) $lastname = $objuser->lastname;
$maskuser=$regType[1]; $maskuser = $regType[1];
$maskuser_value=substr($lastname, 0, dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) $maskuser_value = substr($lastname, 0, dol_strlen($regType[1])); // get n first characters of user firstname (where n is length in mask)
$maskuser_value=str_pad($maskuser_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask $maskuser_value = str_pad($maskuser_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask
} }
else else
{ {
$maskuser=''; $maskuser = '';
$maskuser_value=''; $maskuser_value = '';
} }
// Personalized field {XXX-1} à {XXX-9} // Personalized field {XXX-1} à {XXX-9}
$maskperso=array(); $maskperso = array();
$maskpersonew=array(); $maskpersonew = array();
$tmpmask=$mask; $tmpmask = $mask;
while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey)) while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey))
{ {
$maskperso[$regKey[1]]='{'.$regKey[1].'-'.$regKey[2].'}'; $maskperso[$regKey[1]] = '{'.$regKey[1].'-'.$regKey[2].'}';
$maskpersonew[$regKey[1]]=str_pad('', $regKey[2], '_', STR_PAD_RIGHT); $maskpersonew[$regKey[1]] = str_pad('', $regKey[2], '_', STR_PAD_RIGHT);
$tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask); $tmpmask = preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask);
} }
if (strstr($mask, 'user_extra_')) if (strstr($mask, 'user_extra_'))
{ {
$start = "{user_extra_"; $start = "{user_extra_";
$end = "\}"; $end = "\}";
$extra= get_string_between($mask, "user_extra_", "}"); $extra = get_string_between($mask, "user_extra_", "}");
if (!empty($user->array_options['options_'.$extra])) { if (!empty($user->array_options['options_'.$extra])) {
$mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask);
} }
} }
$maskwithonlyymcode=$mask; $maskwithonlyymcode = $mask;
$maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode);
$maskwithonlyymcode=preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode);
$maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode);
$maskwithonlyymcode=preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode);
$maskwithonlyymcode=preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode);
foreach($maskperso as $key => $val) foreach ($maskperso as $key => $val)
{ {
$maskwithonlyymcode=preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode);
} }
$maskwithnocode=$maskwithonlyymcode; $maskwithnocode = $maskwithonlyymcode;
$maskwithnocode=preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode);
$maskwithnocode=preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode);
$maskwithnocode=preg_replace('/\{y\}/i', 'y', $maskwithnocode); $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode);
$maskwithnocode=preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode);
// Now maskwithnocode = 0000ddmmyyyyccc for example // Now maskwithnocode = 0000ddmmyyyyccc for example
// and maskcounter = 0000 for example // and maskcounter = 0000 for example
//print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>"; //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>";
//var_dump($reg); //var_dump($reg);
// If an offset is asked // If an offset is asked
if (! empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset=preg_replace('/^\+/', '', $reg[2]); if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]);
if (! empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset=preg_replace('/^\+/', '', $reg[3]); if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]);
// Define $sqlwhere // Define $sqlwhere
$sqlwhere=''; $sqlwhere = '';
$yearoffset=0; // Use year of current $date by default $yearoffset = 0; // Use year of current $date by default
$yearoffsettype=false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x $yearoffsettype = false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x
// If a restore to zero after a month is asked we check if there is already a value for this year. // If a restore to zero after a month is asked we check if there is already a value for this year.
if (! empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]); if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]);
if (! empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]); if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]);
//print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype;
if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) if (is_numeric($yearoffsettype) && $yearoffsettype >= 1)
$maskraz=$yearoffsettype; // For backward compatibility $maskraz = $yearoffsettype; // For backward compatibility
elseif ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) elseif ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1))
$maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START;
//print "maskraz=".$maskraz; // -1=no reset //print "maskraz=".$maskraz; // -1=no reset
@ -1161,24 +1161,24 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
if ($maskrefclient) if ($maskrefclient)
{ {
//print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskrefclient_clientcode=".$maskrefclient_clientcode."\n<br>";exit; //print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskrefclient_clientcode=".$maskrefclient_clientcode."\n<br>";exit;
$maskrefclient_maskbefore='{'.$maskrefclient.'}'; $maskrefclient_maskbefore = '{'.$maskrefclient.'}';
$maskrefclient_maskafter=$maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT); $maskrefclient_maskafter = $maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT);
$numFinal = str_replace($maskrefclient_maskbefore, $maskrefclient_maskafter, $numFinal); $numFinal = str_replace($maskrefclient_maskbefore, $maskrefclient_maskafter, $numFinal);
} }
// Now we replace the type // Now we replace the type
if ($masktype) if ($masktype)
{ {
$masktype_maskbefore='{'.$masktype.'}'; $masktype_maskbefore = '{'.$masktype.'}';
$masktype_maskafter=$masktype_value; $masktype_maskafter = $masktype_value;
$numFinal = str_replace($masktype_maskbefore, $masktype_maskafter, $numFinal); $numFinal = str_replace($masktype_maskbefore, $masktype_maskafter, $numFinal);
} }
// Now we replace the user // Now we replace the user
if ($maskuser) if ($maskuser)
{ {
$maskuser_maskbefore='{'.$maskuser.'}'; $maskuser_maskbefore = '{'.$maskuser.'}';
$maskuser_maskafter=$maskuser_value; $maskuser_maskafter = $maskuser_value;
$numFinal = str_replace($maskuser_maskbefore, $maskuser_maskafter, $numFinal); $numFinal = str_replace($maskuser_maskbefore, $maskuser_maskafter, $numFinal);
} }
} }
@ -1214,69 +1214,69 @@ function get_string_between($string, $start, $end)
*/ */
function check_value($mask, $value) function check_value($mask, $value)
{ {
$result=0; $result = 0;
$hasglobalcounter=false; $hasglobalcounter = false;
// Extract value for mask counter, mask raz and mask offset // Extract value for mask counter, mask raz and mask offset
if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg))
{ {
$masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:''); $masktri = $reg[1].(isset($reg[2]) ? $reg[2] : '').(isset($reg[3]) ? $reg[3] : '');
$maskcounter=$reg[1]; $maskcounter = $reg[1];
$hasglobalcounter=true; $hasglobalcounter = true;
} }
else else
{ {
// setting some defaults so the rest of the code won't fail if there is a third party counter // setting some defaults so the rest of the code won't fail if there is a third party counter
$masktri='00000'; $masktri = '00000';
$maskcounter='00000'; $maskcounter = '00000';
} }
$maskraz=-1; $maskraz = -1;
$maskoffset=0; $maskoffset = 0;
if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits';
// Extract value for third party mask counter // Extract value for third party mask counter
if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef))
{ {
$maskrefclient=$regClientRef[1].$regClientRef[2]; $maskrefclient = $regClientRef[1].$regClientRef[2];
$maskrefclient_maskclientcode=$regClientRef[1]; $maskrefclient_maskclientcode = $regClientRef[1];
$maskrefclient_maskcounter=$regClientRef[2]; $maskrefclient_maskcounter = $regClientRef[2];
$maskrefclient_maskoffset=0; //default value of maskrefclient_counter offset $maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset
$maskrefclient_clientcode=substr('', 0, dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode $maskrefclient_clientcode = substr('', 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code to form maskrefclient_clientcode
$maskrefclient_clientcode=str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode
$maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like
if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits';
} }
else $maskrefclient=''; else $maskrefclient = '';
// fail if there is neither a global nor a third party counter // fail if there is neither a global nor a third party counter
if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) if (!$hasglobalcounter && ($maskrefclient_maskcounter == ''))
{ {
return 'ErrorBadMask'; return 'ErrorBadMask';
} }
$maskwithonlyymcode=$mask; $maskwithonlyymcode = $mask;
$maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $maskcounter, $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $maskcounter, $maskwithonlyymcode);
$maskwithonlyymcode=preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode);
$maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode);
$maskwithnocode=$maskwithonlyymcode; $maskwithnocode = $maskwithonlyymcode;
$maskwithnocode=preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode);
$maskwithnocode=preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode);
$maskwithnocode=preg_replace('/\{y\}/i', 'y', $maskwithnocode); $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode);
$maskwithnocode=preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode);
// Now maskwithnocode = 0000ddmmyyyyccc for example // Now maskwithnocode = 0000ddmmyyyyccc for example
// and maskcounter = 0000 for example // and maskcounter = 0000 for example
//print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>"; //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>";
// If an offset is asked // If an offset is asked
if (! empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset=preg_replace('/^\+/', '', $reg[2]); if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]);
if (! empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset=preg_replace('/^\+/', '', $reg[3]); if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]);
// Define $sqlwhere // Define $sqlwhere
// If a restore to zero after a month is asked we check if there is already a value for this year. // If a restore to zero after a month is asked we check if there is already a value for this year.
if (! empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz=preg_replace('/^@/', '', $reg[2]); if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz = preg_replace('/^@/', '', $reg[2]);
if (! empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz=preg_replace('/^@/', '', $reg[3]); if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz = preg_replace('/^@/', '', $reg[3]);
if ($maskraz >= 0) if ($maskraz >= 0)
{ {
if ($maskraz == 99) { if ($maskraz == 99) {
@ -1286,8 +1286,8 @@ function check_value($mask, $value)
if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth';
// Define reg // Define reg
if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; if ($maskraz > 1 && !preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask'; if ($maskraz <= 1 && !preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask';
//print "x".$maskwithonlyymcode." ".$maskraz; //print "x".$maskwithonlyymcode." ".$maskraz;
} }
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n"; //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n";
@ -1616,16 +1616,16 @@ function version_webserver()
*/ */
function getListOfModels($db, $type, $maxfilenamelength = 0) function getListOfModels($db, $type, $maxfilenamelength = 0)
{ {
global $conf,$langs; global $conf, $langs;
$liste=array(); $liste = array();
$found=0; $found = 0;
$dirtoscan=''; $dirtoscan = '';
$sql = "SELECT nom as id, nom as doc_template_name, libelle as label, description as description"; $sql = "SELECT nom as id, nom as doc_template_name, libelle as label, description as description";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'"; $sql .= " WHERE type = '".$type."'";
$sql.= " AND entity IN (0,".$conf->entity.")"; $sql .= " AND entity IN (0,".$conf->entity.")";
$sql.= " ORDER BY description DESC"; $sql .= " ORDER BY description DESC";
dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
@ -1635,48 +1635,48 @@ function getListOfModels($db, $type, $maxfilenamelength = 0)
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$found=1; $found = 1;
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
// If this generation module needs to scan a directory, then description field is filled // If this generation module needs to scan a directory, then description field is filled
// with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...).
if (! empty($obj->description)) // A list of directories to scan is defined if (!empty($obj->description)) // A list of directories to scan is defined
{ {
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$const=$obj->description; $const = $obj->description;
//irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); //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($conf->global->$const));
$listoffiles=array(); $listoffiles = array();
// Now we add models found in directories scanned // Now we add models found in directories scanned
$listofdir=explode(',', $dirtoscan); $listofdir = explode(',', $dirtoscan);
foreach($listofdir as $key=>$tmpdir) foreach ($listofdir as $key=>$tmpdir)
{ {
$tmpdir=trim($tmpdir); $tmpdir = trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (! $tmpdir) { unset($listofdir[$key]); continue; } if (!$tmpdir) { unset($listofdir[$key]); continue; }
if (is_dir($tmpdir)) if (is_dir($tmpdir))
{ {
// all type of template is allowed // all type of template is allowed
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0);
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
} }
} }
if (count($listoffiles)) if (count($listoffiles))
{ {
foreach($listoffiles as $record) foreach ($listoffiles as $record)
{ {
$max=($maxfilenamelength?$maxfilenamelength:28); $max = ($maxfilenamelength ? $maxfilenamelength : 28);
$liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'], $max, 'middle'); $liste[$obj->id.':'.$record['fullname']] = dol_trunc($record['name'], $max, 'middle');
} }
} }
else else
{ {
$liste[0]=$obj->label.': '.$langs->trans("None"); $liste[0] = $obj->label.': '.$langs->trans("None");
} }
} }
else else
@ -1685,14 +1685,14 @@ function getListOfModels($db, $type, $maxfilenamelength = 0)
{ {
global $_Avery_Labels; global $_Avery_Labels;
include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
foreach($_Avery_Labels as $key => $val) foreach ($_Avery_Labels as $key => $val)
{ {
$liste[$obj->id.':'.$key]=($obj->label?$obj->label:$obj->doc_template_name).' '.$val['name']; $liste[$obj->id.':'.$key] = ($obj->label ? $obj->label : $obj->doc_template_name).' '.$val['name'];
} }
} }
else // Common usage else // Common usage
{ {
$liste[$obj->id]=$obj->label?$obj->label:$obj->doc_template_name; $liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name;
} }
} }
$i++; $i++;
@ -1762,7 +1762,7 @@ function getSoapParams()
$proxyport = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PORT); $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); $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); $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 $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 $response_timeout = (empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout
//print extension_loaded('soap'); //print extension_loaded('soap');
if ($proxyuse) if ($proxyuse)
@ -1829,18 +1829,18 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
// Special cases, to work with non standard path // Special cases, to work with non standard path
if ($objecttype == 'facture' || $objecttype == 'invoice') { if ($objecttype == 'facture' || $objecttype == 'invoice') {
$classpath = 'compta/facture/class'; $classpath = 'compta/facture/class';
$module='facture'; $module = 'facture';
$myobject='facture'; $myobject = 'facture';
} }
elseif ($objecttype == 'commande' || $objecttype == 'order') { elseif ($objecttype == 'commande' || $objecttype == 'order') {
$classpath = 'commande/class'; $classpath = 'commande/class';
$module='commande'; $module = 'commande';
$myobject='commande'; $myobject = 'commande';
} }
elseif ($objecttype == 'propal') { elseif ($objecttype == 'propal') {
$classpath = 'comm/propal/class'; $classpath = 'comm/propal/class';
} }
elseif ($objecttype == 'supplier_proposal') { elseif ($objecttype == 'supplier_proposal') {
$classpath = 'supplier_proposal/class'; $classpath = 'supplier_proposal/class';
} }
elseif ($objecttype == 'shipping') { elseif ($objecttype == 'shipping') {
@ -1855,43 +1855,43 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
} }
elseif ($objecttype == 'contract') { elseif ($objecttype == 'contract') {
$classpath = 'contrat/class'; $classpath = 'contrat/class';
$module='contrat'; $module = 'contrat';
$myobject='contrat'; $myobject = 'contrat';
} }
elseif ($objecttype == 'member') { elseif ($objecttype == 'member') {
$classpath = 'adherents/class'; $classpath = 'adherents/class';
$module='adherent'; $module = 'adherent';
$myobject='adherent'; $myobject = 'adherent';
} }
elseif ($objecttype == 'cabinetmed_cons') { elseif ($objecttype == 'cabinetmed_cons') {
$classpath = 'cabinetmed/class'; $classpath = 'cabinetmed/class';
$module='cabinetmed'; $module = 'cabinetmed';
$myobject='cabinetmedcons'; $myobject = 'cabinetmedcons';
} }
elseif ($objecttype == 'fichinter') { elseif ($objecttype == 'fichinter') {
$classpath = 'fichinter/class'; $classpath = 'fichinter/class';
$module='ficheinter'; $module = 'ficheinter';
$myobject='fichinter'; $myobject = 'fichinter';
} }
elseif ($objecttype == 'task') { elseif ($objecttype == 'task') {
$classpath = 'projet/class'; $classpath = 'projet/class';
$module='projet'; $module = 'projet';
$myobject='task'; $myobject = 'task';
} }
elseif ($objecttype == 'stock') { elseif ($objecttype == 'stock') {
$classpath = 'product/stock/class'; $classpath = 'product/stock/class';
$module='stock'; $module = 'stock';
$myobject='stock'; $myobject = 'stock';
} }
elseif ($objecttype == 'inventory') { elseif ($objecttype == 'inventory') {
$classpath = 'product/inventory/class'; $classpath = 'product/inventory/class';
$module='stock'; $module = 'stock';
$myobject='inventory'; $myobject = 'inventory';
} }
elseif ($objecttype == 'mo') { elseif ($objecttype == 'mo') {
$classpath = 'mrp/class'; $classpath = 'mrp/class';
$module='mrp'; $module = 'mrp';
$myobject='mo'; $myobject = 'mo';
} }
// Generic case for $classfile and $classname // Generic case for $classfile and $classname
@ -2257,9 +2257,9 @@ function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88))
*/ */
function colorValidateHex($color, $allow_white = true) function colorValidateHex($color, $allow_white = true)
{ {
if(!$allow_white && ($color === '#fff' || $color === '#ffffff') ) return false; if (!$allow_white && ($color === '#fff' || $color === '#ffffff')) return false;
if(preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid if (preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid
{ {
return true; return true;
} }
@ -2277,7 +2277,7 @@ function colorValidateHex($color, $allow_white = true)
*/ */
function colorAgressiveness($hex, $ratio = -50, $brightness = 0) function colorAgressiveness($hex, $ratio = -50, $brightness = 0)
{ {
if (empty($ratio)) $ratio = 0; // To avoid null if (empty($ratio)) $ratio = 0; // To avoid null
// Steps should be between -255 and 255. Negative = darker, positive = lighter // Steps should be between -255 and 255. Negative = darker, positive = lighter
$ratio = max(-100, min(100, $ratio)); $ratio = max(-100, min(100, $ratio));
@ -2293,7 +2293,7 @@ function colorAgressiveness($hex, $ratio = -50, $brightness = 0)
$return = '#'; $return = '#';
foreach ($color_parts as $color) { foreach ($color_parts as $color) {
$color = hexdec($color); // Convert to decimal $color = hexdec($color); // Convert to decimal
if ($ratio > 0) // We increase aggressivity if ($ratio > 0) // We increase aggressivity
{ {
if ($color > 127) $color += ((255 - $color) * ($ratio / 100)); if ($color > 127) $color += ((255 - $color) * ($ratio / 100));
@ -2607,9 +2607,9 @@ function convertBackOfficeMediasLinksToPublicLinks($notetoshow)
{ {
global $dolibarr_main_url_root; global $dolibarr_main_url_root;
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$notetoshow=preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow); $notetoshow = preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow);
return $notetoshow; return $notetoshow;
} }

View File

@ -491,7 +491,7 @@ class Mo extends CommonObject
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i=0; $i = 0;
while ($i < $num) { while ($i < $num) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) { if ($obj) {
@ -543,7 +543,7 @@ class Mo extends CommonObject
$error++; $error++;
} }
if (! $error) { if (!$error) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
$this->db->commit(); $this->db->commit();
return 1; return 1;
@ -602,14 +602,14 @@ class Mo extends CommonObject
} }
// Lines to consume // Lines to consume
if (! $error) { if (!$error) {
foreach ($bom->lines as $line) foreach ($bom->lines as $line)
{ {
$moline = new MoLine($this->db); $moline = new MoLine($this->db);
$moline->fk_mo = $this->id; $moline->fk_mo = $this->id;
if ($line->qty_frozen) { if ($line->qty_frozen) {
$moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce
} else { } else {
$moline->qty = round($line->qty * $this->qty / $bom->efficiency, 2); $moline->qty = round($line->qty * $this->qty / $bom->efficiency, 2);
} }
@ -1164,7 +1164,7 @@ class Mo extends CommonObject
if (!dol_strlen($modele)) { if (!dol_strlen($modele)) {
//$modele = 'standard'; //$modele = 'standard';
$modele = ''; // Remove this once a pdf_standard.php exists. $modele = ''; // Remove this once a pdf_standard.php exists.
if ($this->modelpdf) { if ($this->modelpdf) {
$modele = $this->modelpdf; $modele = $this->modelpdf;
@ -1175,7 +1175,7 @@ class Mo extends CommonObject
$modelpath = "core/modules/mrp/doc/"; $modelpath = "core/modules/mrp/doc/";
if (empty($modele)) return 1; // Remove this once a pdf_standard.php exists. if (empty($modele)) return 1; // Remove this once a pdf_standard.php exists.
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
} }

View File

@ -169,24 +169,24 @@ if (empty($reshook))
$db->begin(); $db->begin();
// Process line to consume // Process line to consume
foreach($object->lines as $line) { foreach ($object->lines as $line) {
if ($line->role == 'toconsume') { if ($line->role == 'toconsume') {
$tmpproduct = new Product($db); $tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product); $tmpproduct->fetch($line->fk_product);
$i=1; $i = 1;
while (GETPOSTISSET('qty-'.$line->id.'-'.$i)) { while (GETPOSTISSET('qty-'.$line->id.'-'.$i)) {
$qtytoprocess = price2num(GETPOST('qty-'.$line->id.'-'.$i)); $qtytoprocess = price2num(GETPOST('qty-'.$line->id.'-'.$i));
if ($qtytoprocess != 0) { if ($qtytoprocess != 0) {
// Check warehouse is set if we should have to // Check warehouse is set if we should have to
if (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i)) { // If there is a warehouse to set if (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i)) { // If there is a warehouse to set
if (! (GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. if (!(GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set.
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors');
$error++; $error++;
} }
if ($tmpproduct->status_batch && (! GETPOST('batch-'.$line->id.'-'.$i))) { if ($tmpproduct->status_batch && (!GETPOST('batch-'.$line->id.'-'.$i))) {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors');
$error++; $error++;
@ -194,7 +194,7 @@ if (empty($reshook))
} }
$idstockmove = 0; $idstockmove = 0;
if (! $error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) { if (!$error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) {
// Record stock movement // Record stock movement
$id_product_batch = 0; $id_product_batch = 0;
$stockmove->origin = $object; $stockmove->origin = $object;
@ -205,7 +205,7 @@ if (empty($reshook))
} }
} }
if (! $error) { if (!$error) {
$pos = 0; $pos = 0;
// Record consumption // Record consumption
$moline = new MoLine($db); $moline = new MoLine($db);
@ -236,24 +236,24 @@ if (empty($reshook))
} }
// Process line to produce // Process line to produce
foreach($object->lines as $line) { foreach ($object->lines as $line) {
if ($line->role == 'toproduce') { if ($line->role == 'toproduce') {
$tmpproduct = new Product($db); $tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product); $tmpproduct->fetch($line->fk_product);
$i=1; $i = 1;
while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) { while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) {
$qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i)); $qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i));
if ($qtytoprocess != 0) { if ($qtytoprocess != 0) {
// Check warehouse is set if we should have to // Check warehouse is set if we should have to
if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set
if (! (GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. if (!(GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set.
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors');
$error++; $error++;
} }
if ($tmpproduct->status_batch && (! GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { if ($tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors');
$error++; $error++;
@ -261,7 +261,7 @@ if (empty($reshook))
} }
$idstockmove = 0; $idstockmove = 0;
if (! $error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { if (!$error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) {
// Record stock movement // Record stock movement
$id_product_batch = 0; $id_product_batch = 0;
$stockmove->origin = $object; $stockmove->origin = $object;
@ -272,7 +272,7 @@ if (empty($reshook))
} }
} }
if (! $error) { if (!$error) {
$pos = 0; $pos = 0;
// Record production // Record production
$moline = new MoLine($db); $moline = new MoLine($db);
@ -302,16 +302,16 @@ if (empty($reshook))
} }
} }
if (! $error) { if (!$error) {
$consumptioncomplete = true; $consumptioncomplete = true;
$productioncomplete = true; $productioncomplete = true;
if (GETPOST('autoclose', 'int')) { if (GETPOST('autoclose', 'int')) {
foreach($object->lines as $line) { foreach ($object->lines as $line) {
if ($line->role == 'toconsume') { if ($line->role == 'toconsume') {
$arrayoflines = $object->fetchLinesLinked('consumed', $line->id); $arrayoflines = $object->fetchLinesLinked('consumed', $line->id);
$alreadyconsumed = 0; $alreadyconsumed = 0;
foreach($arrayoflines as $line2) { foreach ($arrayoflines as $line2) {
$alreadyconsumed += $line2['qty']; $alreadyconsumed += $line2['qty'];
} }
@ -322,7 +322,7 @@ if (empty($reshook))
if ($line->role == 'toproduce') { if ($line->role == 'toproduce') {
$arrayoflines = $object->fetchLinesLinked('produced', $line->id); $arrayoflines = $object->fetchLinesLinked('produced', $line->id);
$alreadyproduced = 0; $alreadyproduced = 0;
foreach($arrayoflines as $line2) { foreach ($arrayoflines as $line2) {
$alreadyproduced += $line2['qty']; $alreadyproduced += $line2['qty'];
} }
@ -649,8 +649,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>'.$tmpproduct->getNomUrl(1).'</td>'; print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
print '<td class="right">'; print '<td class="right">';
$help = ''; $help = '';
if ($line->qty_frozen) $help.=($help ? '<br>' : '').'<strong>'.$langs->trans("QuantityFrozen").'</strong>: '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; if ($line->qty_frozen) $help .= ($help ? '<br>' : '').'<strong>'.$langs->trans("QuantityFrozen").'</strong>: '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')';
if ($line->disable_stock_change) $help.=($help ? '<br>' : '').'<strong>'.$langs->trans("DisableStockChange").'</strong>: '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; if ($line->disable_stock_change) $help .= ($help ? '<br>' : '').'<strong>'.$langs->trans("DisableStockChange").'</strong>: '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')';
if ($help) { if ($help) {
print $form->textwithpicto($line->qty, $help, -1); print $form->textwithpicto($line->qty, $help, -1);
} else { } else {
@ -680,7 +680,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>'; // Warehouse print '<td>'; // Warehouse
print '</td>'; print '</td>';
if ($conf->productbatch->enabled) { if ($conf->productbatch->enabled) {
print '<td></td>'; // Lot print '<td></td>'; // Lot
} }
print '</tr>'; print '</tr>';
@ -811,7 +811,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>'; // Warehouse print '<td>'; // Warehouse
print '</td>'; print '</td>';
if ($conf->productbatch->enabled) { if ($conf->productbatch->enabled) {
print '<td></td>'; // Lot print '<td></td>'; // Lot
} }
print '</tr>'; print '</tr>';

View File

@ -36,58 +36,58 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('projects','users','companies')); $langs->loadLangs(array('projects', 'users', 'companies'));
$action=GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$mode=GETPOST("mode", 'alpha'); $mode = GETPOST("mode", 'alpha');
$id=GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$taskid=GETPOST('taskid', 'int'); $taskid = GETPOST('taskid', 'int');
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'perweekcard'; $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'perweekcard';
$mine=0; $mine = 0;
if ($mode == 'mine') $mine=1; if ($mode == 'mine') $mine = 1;
$projectid=''; $projectid = '';
$projectid=isset($_GET["id"])?$_GET["id"]:$_POST["projectid"]; $projectid = isset($_GET["id"]) ? $_GET["id"] : $_POST["projectid"];
$hookmanager->initHooks(array('timesheetperweekcard')); $hookmanager->initHooks(array('timesheetperweekcard'));
// Security check // Security check
$socid=0; $socid = 0;
// For external user, no check is done on company because readability is managed by public status of project and assignement. // For external user, no check is done on company because readability is managed by public status of project and assignement.
// if ($user->socid > 0) $socid=$user->socid; // if ($user->socid > 0) $socid=$user->socid;
$result = restrictedArea($user, 'projet', $projectid); $result = restrictedArea($user, 'projet', $projectid);
$now=dol_now(); $now = dol_now();
$nowtmp=dol_getdate($now); $nowtmp = dol_getdate($now);
$nowday=$nowtmp['mday']; $nowday = $nowtmp['mday'];
$nowmonth=$nowtmp['mon']; $nowmonth = $nowtmp['mon'];
$nowyear=$nowtmp['year']; $nowyear = $nowtmp['year'];
$year=GETPOST('reyear', 'int')?GETPOST('reyear', 'int'):(GETPOST("year", 'int')?GETPOST("year", "int"):date("Y")); $year = GETPOST('reyear', 'int') ?GETPOST('reyear', 'int') : (GETPOST("year", 'int') ?GETPOST("year", "int") : date("Y"));
$month=GETPOST('remonth', 'int')?GETPOST('remonth', 'int'):(GETPOST("month", 'int')?GETPOST("month", "int"):date("m")); $month = GETPOST('remonth', 'int') ?GETPOST('remonth', 'int') : (GETPOST("month", 'int') ?GETPOST("month", "int") : date("m"));
$day=GETPOST('reday', 'int')?GETPOST('reday', 'int'):(GETPOST("day", 'int')?GETPOST("day", "int"):date("d")); $day = GETPOST('reday', 'int') ?GETPOST('reday', 'int') : (GETPOST("day", 'int') ?GETPOST("day", "int") : date("d"));
$week=GETPOST("week", "int")?GETPOST("week", "int"):date("W"); $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W");
$day = (int) $day; $day = (int) $day;
$search_categ=GETPOST("search_categ", 'alpha'); $search_categ = GETPOST("search_categ", 'alpha');
$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_usertoprocessid = GETPOST('search_usertoprocessid', 'int');
$search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_ref = GETPOST('search_task_ref', 'alpha');
$search_task_label=GETPOST('search_task_label', 'alpha'); $search_task_label = GETPOST('search_task_label', 'alpha');
$search_project_ref=GETPOST('search_project_ref', 'alpha'); $search_project_ref = GETPOST('search_project_ref', 'alpha');
$search_thirdparty=GETPOST('search_thirdparty', 'alpha'); $search_thirdparty = GETPOST('search_thirdparty', 'alpha');
$search_declared_progress=GETPOST('search_declared_progress', 'alpha'); $search_declared_progress = GETPOST('search_declared_progress', 'alpha');
$startdayarray=dol_get_first_day_week($day, $month, $year); $startdayarray = dol_get_first_day_week($day, $month, $year);
$prev = $startdayarray; $prev = $startdayarray;
$prev_year = $prev['prev_year']; $prev_year = $prev['prev_year'];
$prev_month = $prev['prev_month']; $prev_month = $prev['prev_month'];
$prev_day = $prev['prev_day']; $prev_day = $prev['prev_day'];
$first_day = $prev['first_day']; $first_day = $prev['first_day'];
$first_month= $prev['first_month']; $first_month = $prev['first_month'];
$first_year = $prev['first_year']; $first_year = $prev['first_year'];
$week = $prev['week']; $week = $prev['week'];
@ -808,27 +808,27 @@ if (count($tasksarray) > 0)
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
print '<tr class="liste_total"> print '<tr class="liste_total">
<td class="liste_total" colspan="'.($colspan+$addcolspan).'">'; <td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
print $langs->trans("Total"); print $langs->trans("Total");
print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>'; print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
print '</td>'; print '</td>';
for ($idw = 0; $idw < 7; $idw++) for ($idw = 0; $idw < 7; $idw++)
{ {
$cssweekend=''; $cssweekend = '';
if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
{ {
$cssweekend='weekend'; $cssweekend = 'weekend';
} }
$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
$cssonholiday=''; $cssonholiday = '';
if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday ';
elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning ';
elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon ';
print '<td class="liste_total hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>'; print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
} }
print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td> print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>
</tr>'; </tr>';