Fix counter of BOM

This commit is contained in:
Laurent Destailleur 2019-10-16 02:05:23 +02:00
parent d3df04c5aa
commit ffc4820970
7 changed files with 16 additions and 16 deletions

View File

@ -97,8 +97,8 @@ if (empty($reshook))
$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0);
$backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
if (empty($backtopage)) { if (empty($backtopage)) {
if (empty($id)) $backtopage = $backurlforlist; if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist;
else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.$id; else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.($id > 0 ? $id : '__ID__');
} }
$triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record

View File

@ -524,7 +524,7 @@ class BOM extends CommonObject
// Protection // Protection
if ($this->statut == self::STATUS_VALIDATED) if ($this->statut == self::STATUS_VALIDATED)
{ {
dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING); dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
return 0; return 0;
} }
@ -560,7 +560,7 @@ class BOM extends CommonObject
$sql.= " fk_user_valid = ".$user->id; $sql.= " fk_user_valid = ".$user->id;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::valid()", LOG_DEBUG); dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) if (! $resql)
{ {
@ -597,7 +597,7 @@ class BOM extends CommonObject
$dirdest = $conf->bom->dir_output.'/'.$newref; $dirdest = $conf->bom->dir_output.'/'.$newref;
if (! $error && file_exists($dirsource)) if (! $error && file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {

View File

@ -234,7 +234,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiont
// Action validate object // Action validate object
if ($action == 'confirm_validate' && $confirm == 'yes' && $permissionedit) if ($action == 'confirm_validate' && $confirm == 'yes' && $permissionedit)
{ {
$result = $object->valid($user); $result = $object->validate($user);
if ($result >= 0) if ($result >= 0)
{ {
// Define output language // Define output language

View File

@ -118,11 +118,11 @@ class mod_bom_advanced extends ModeleNumRefboms
/** /**
* Return next free value * Return next free value
* *
* @param Societe $objsoc Object thirdparty * @param Product $objprod Object product
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO * @return string Value if KO, <0 if KO
*/ */
public function getNextValue($objsoc, $object) public function getNextValue($objprod, $object)
{ {
global $db,$conf; global $db,$conf;
@ -139,7 +139,7 @@ class mod_bom_advanced extends ModeleNumRefboms
$date = ($object->date_bom ? $object->date_bom : $object->date); $date = ($object->date_bom ? $object->date_bom : $object->date);
$numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', $objsoc, $date); $numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', null, $date);
return $numFinal; return $numFinal;
} }

View File

@ -108,16 +108,16 @@ class mod_bom_standard extends ModeleNumRefboms
/** /**
* Return next free value * Return next free value
* *
* @param Societe $objsoc Object thirdparty * @param Product $objprod Object product
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO * @return string Value if KO, <0 if KO
*/ */
public function getNextValue($objsoc, $object) public function getNextValue($objprod, $object)
{ {
global $db,$conf; global $db,$conf;
// D'abord on recupere la valeur max // D'abord on recupere la valeur max
$posindice=8; $posindice=9;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."bom_bom"; $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@ -137,9 +137,9 @@ class mod_bom_standard extends ModeleNumRefboms
} }
//$date=time(); //$date=time();
$date=$object->date; $date=$object->date_creation;
$yymm = strftime("%y%m", $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 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
else $num = sprintf("%04s", $max+1); else $num = sprintf("%04s", $max+1);

View File

@ -28,6 +28,6 @@ DateEndPlannedMo=Date end planned
KeepEmptyForAsap=Empty means 'As Soon As Possible' KeepEmptyForAsap=Empty means 'As Soon As Possible'
EstimatedDuration=Estimated duration EstimatedDuration=Estimated duration
EstimatedDurationDesc=Estimated duration to manufacture this product using this BOM EstimatedDurationDesc=Estimated duration to manufacture this product using this BOM
ConfirmValidateBom=Are you sure you want to validate this BOM (you will be able to use it to build new Manufacturing Orders) ConfirmValidateBom=Are you sure you want to validate the BOM with the reference <strong>%s</strong> (you will be able to use it to build new Manufacturing Orders)
ConfirmCloseBom=Are you sure you want to cancel this BOM (you won't be able to use it to build new Manufacturing Orders anymore) ? ConfirmCloseBom=Are you sure you want to cancel this BOM (you won't be able to use it to build new Manufacturing Orders anymore) ?
ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders) ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders)

View File

@ -129,7 +129,7 @@ if (empty($reshook))
$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0);
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1);
if (empty($backtopage)) { if (empty($backtopage)) {
if (empty($id)) $backtopage = $backurlforlist; if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
} }
$triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record