diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 732a381694d..7f091749660 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1747,18 +1747,37 @@ class CommandeFournisseur extends CommonOrder
if ($type == 'nev') $statut = 7;
if ($type == 'can') $statut = 7;
- if (! $error && ! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && ($type == 'tot'))
- {
- // If option SUPPLIER_ORDER_USE_DISPATCH_STATUS is on, we check all reception are approved to allow status "total/done"
- $dispatchedlinearray=$this->getDispachedLines(0);
- if (count($dispatchedlinearray) > 0)
+ // Some checks to accept the record
+ if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS))
+ {
+ // If option SUPPLIER_ORDER_USE_DISPATCH_STATUS is on, we check all reception are approved to allow status "total/done"
+ if (! $error && ($type == 'tot'))
+ {
+ $dispatchedlinearray=$this->getDispachedLines(0);
+ if (count($dispatchedlinearray) > 0)
+ {
+ $result=-1;
+ $error++;
+ $this->errors[]='ErrorCantSetReceptionToTotalDoneWithReceptionToApprove';
+ dol_syslog('ErrorCantSetReceptionToTotalDoneWithReceptionToApprove', LOG_DEBUG);
+ }
+
+ }
+ if (! $error && ! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS_NEED_APPROVE) && ($type == 'tot')) // Accept to move to rception done, only if status of all line are ok (refuse denied)
{
- $result=-1;
- $error++;
- $this->errors[]='ErrorCantSetReceptionToTotalDoneWithReceptionToApprove';
- dol_syslog('ErrorCantSetReceptionToTotalDoneWithReceptionToApprove', LOG_DEBUG);
+ $dispatcheddenied=$this->getDispachedLines(2);
+ if (count($dispatchedlinearray) > 0)
+ {
+ $result=-1;
+ $error++;
+ $this->errors[]='ErrorCantSetReceptionToTotalDoneWithReceptionDenied';
+ dol_syslog('ErrorCantSetReceptionToTotalDoneWithReceptionDenied', LOG_DEBUG);
+ }
}
- }
+ }
+
+ // TODO LDR01 Add option to accept only if ALL predefined products are received (same qty).
+
if (! $error && ! ($statut == 4 or $statut == 5 or $statut == 7))
{
diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php
index e7aea53945e..4d6f75444b8 100644
--- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php
@@ -495,16 +495,19 @@ class CommandeFournisseurDispatch extends CommonObject
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4');
+ if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut8');
}
if ($mode == 4)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
+ if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]);
}
if ($mode == 5)
{
if ($statut==0) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4');
+ if ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut8');
}
}
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index e2f7fb0ca03..755dd1249ea 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -192,10 +192,11 @@ if (empty($reshook))
if ($action == 'reopen') // no test on permission here, permission to use will depends on status
{
- if (in_array($object->statut, array(1, 2, 5, 6, 7, 9)))
+ if (in_array($object->statut, array(1, 2, 3, 5, 6, 7, 9)))
{
if ($object->statut == 1) $newstatus=0; // Validated->Draft
else if ($object->statut == 2) $newstatus=0; // Approved->Draft
+ else if ($object->statut == 3) $newstatus=2; // Ordered->Approved
else if ($object->statut == 5) $newstatus=4; // Received->Received partially
else if ($object->statut == 6) $newstatus=2; // Canceled->Approved
else if ($object->statut == 7) $newstatus=3; // Canceled->Process running
@@ -2671,7 +2672,7 @@ elseif (! empty($object->id))
print 'id.'&action=reopen">'.$langs->trans("Disapprove").'';
}
}
- if (in_array($object->statut, array(5, 6, 7, 9)))
+ if (in_array($object->statut, array(3, 5, 6, 7, 9)))
{
if ($user->rights->fournisseur->commande->commander)
{
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index 1da5f5eb29a..bac6ace77e3 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -109,7 +109,7 @@ if ($action == 'denydispatchline' &&
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
$result=$supplierorderdispatch->fetch($lineid);
if (! $result) dol_print_error($db);
- $result=$supplierorderdispatch->setStatut(-1);
+ $result=$supplierorderdispatch->setStatut(2);
if ($result < 0)
{
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
@@ -678,11 +678,16 @@ if ($id > 0 || ! empty($ref))
print 'dispatchlineid.'">'.$langs->trans("Approve").'';
print 'dispatchlineid.'">'.$langs->trans("Deny").'';
}
- else
+ if ($objp->status == 1)
{
- print 'dispatchlineid.'">'.$langs->trans("Disapprove").'';
+ print 'dispatchlineid.'">'.$langs->trans("Reinit").'';
print 'dispatchlineid.'">'.$langs->trans("Deny").'';
}
+ if ($objp->status == 2)
+ {
+ print 'dispatchlineid.'">'.$langs->trans("Reinit").'';
+ print 'dispatchlineid.'">'.$langs->trans("Approve").'';
+ }
}
print '';
}
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index 6a7da2d3ece..32a66564b07 100755
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -160,7 +160,8 @@ ErrorPriceExpressionInternal=Internal error '%s'
ErrorPriceExpressionUnknown=Unknown error '%s'
ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs
ErrorTryToMakeMoveOnProductRequiringBatchData=Error, trying to make a stock movement without batch/serial information, on a product requiring batch/serial information
-ErrorCantSetReceptionToTotalDoneWithReceptionToApprove=All recorded receptions must first be verified before being allowed to do this action
+ErrorCantSetReceptionToTotalDoneWithReceptionToApprove=All recorded receptions must first be verified (approved or denied) before being allowed to do this action
+ErrorCantSetReceptionToTotalDoneWithReceptionDenied=All recorded receptions must first be verified (approved) before being allowed to do this action
ErrorGlobalVariableUpdater0=HTTP request failed with error '%s'
ErrorGlobalVariableUpdater1=Invalid JSON format '%s'
ErrorGlobalVariableUpdater2=Missing parameter '%s'
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index bd2112cf871..ce4300e67c2 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -700,6 +700,7 @@ SelectElementAndClickRefresh=Select an element and click Refresh
PrintFile=Print File %s
ShowTransaction=Show transaction
GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into Home - Setup - Display to hide.
+Denied=Denied
# Week day
Monday=Monday
Tuesday=Tuesday