NEW Can include tag {uuu} into some numbering masks to replace with user

This commit is contained in:
Laurent Destailleur
2017-08-29 19:44:35 +02:00
parent 4d908c2dd0
commit 8f34de1036
5 changed files with 80 additions and 20 deletions

View File

@@ -118,11 +118,16 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
else
{
dol_syslog("mod_expensereport_jade::getNextValue", LOG_DEBUG);
return -1;
return 0;
}
$date=$object->date_valid; // $object->date does not exists
if (empty($date))
{
$this->error = 'Date valid not defined';
return 0;
}
//$date=time();
$date=$object->date;
$yymm = strftime("%y%m",$date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is

View File

@@ -82,12 +82,13 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport
*/
function getExample()
{
global $conf,$langs,$mysoc;
global $conf,$langs,$user;
$old_code_client=$mysoc->code_client;
$mysoc->code_client='CCCCCCCCCC';
$numExample = $this->getNextValue($mysoc,'');
$mysoc->code_client=$old_code_client;
$exp=new ExpenseReport($this->db);
$exp->initAsSpecimen();
$exp->fk_user_author = $user->id;
$numExample = $this->getNextValue($exp);
if (! $numExample)
{
@@ -99,11 +100,10 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport
/**
* Return next free value
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
function getNextValue($objsoc,$object)
function getNextValue($object)
{
global $db,$conf;
@@ -118,7 +118,21 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport
return 0;
}
$numFinal=get_next_value($db,$mask,'expensereport','ref','',$objsoc,$object->date);
$date=$object->date_valid; // $object->date does not exists
if (empty($date))
{
$this->error = 'Date valid not defined';
return 0;
}
$fuser = null;
if ($object->fk_user_author > 0)
{
$fuser=new User($db);
$fuser->fetch($object->fk_user_author);
}
$numFinal=get_next_value($db,$mask,'expensereport','ref','',null, $date, 'next', true, $fuser);
return $numFinal;
}

View File

@@ -80,6 +80,13 @@ class modExpenseReport extends DolibarrModules
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "EXPENSEREPORT_ADDON";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_expensereport_jade";
$this->const[$r][3] = 'Name of manager to generate expense report ref number';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "MAIN_DELAY_EXPENSEREPORTS";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "15";