Fix end of workflow of MO
This commit is contained in:
parent
d66f54d06d
commit
c4d1db263c
@ -112,8 +112,10 @@ BOM_CLOSEInDolibarr=BOM disabled
|
||||
BOM_REOPENInDolibarr=BOM reopen
|
||||
BOM_DELETEInDolibarr=BOM deleted
|
||||
MRP_MO_VALIDATEInDolibarr=MO validated
|
||||
MRP_MO_UNVALIDATEInDolibarr=MO set to draft status
|
||||
MRP_MO_PRODUCEDInDolibarr=MO produced
|
||||
MRP_MO_DELETEInDolibarr=MO deleted
|
||||
MRP_MO_CANCELInDolibarr=MO canceled
|
||||
##### End agenda events #####
|
||||
AgendaModelModule=Document templates for event
|
||||
DateActionStart=Start date
|
||||
|
||||
@ -929,7 +929,7 @@ class Mo extends CommonObject
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'MO_UNVALIDATE');
|
||||
return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'MRP_MO_UNVALIDATE');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -954,7 +954,7 @@ class Mo extends CommonObject
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'MO_CLOSE');
|
||||
return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'MRP_MO_CANCEL');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -967,7 +967,7 @@ class Mo extends CommonObject
|
||||
public function reopen($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_CANCELED)
|
||||
if ($this->status != self::STATUS_PRODUCED && $this->status != self::STATUS_CANCELED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -169,6 +169,35 @@ if (empty($reshook))
|
||||
{
|
||||
$object->setProject(GETPOST('projectid', 'int'));
|
||||
}
|
||||
|
||||
// Action close produced
|
||||
if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd)
|
||||
{
|
||||
$result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED');
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Define output language
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -630,10 +659,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
{
|
||||
if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS)
|
||||
{
|
||||
// TODO If production is already > 1, show only close, else show cancel
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_produced&confirm=yes">'.$langs->trans("Close").'</a>'."\n";
|
||||
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes">'.$langs->trans("Cancel").'</a>'."\n";
|
||||
}
|
||||
|
||||
if ($object->status == $object::STATUS_CANCELED)
|
||||
if ($object->status == $object::STATUS_PRODUCED || $object->status == $object::STATUS_CANCELED)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("Re-Open").'</a>'."\n";
|
||||
}
|
||||
|
||||
@ -383,6 +383,35 @@ if (empty($reshook))
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Action close produced
|
||||
if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd)
|
||||
{
|
||||
$result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED');
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Define output language
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->modelpdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$object->generateDocument($model, $outputlangs, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -599,6 +628,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
{
|
||||
if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS)
|
||||
{
|
||||
// TODO If production is already > 1, show only close, else show cancel
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_produced&confirm=yes">'.$langs->trans("Close").'</a>'."\n";
|
||||
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes">'.$langs->trans("Cancel").'</a>'."\n";
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user