NEW Checkbox 'close order to "Everything received" automatically if all
products are received' is visible on supplier orders.
This commit is contained in:
parent
1522d6060d
commit
c71fc18942
@ -1924,7 +1924,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
}
|
||||
}
|
||||
|
||||
// TODO LDR01 Add option to accept only if ALL predefined products are received (same qty).
|
||||
// TODO LDR01 Add a control test to accept only if ALL predefined products are received (same qty).
|
||||
|
||||
|
||||
if (! $error && ! ($statut == 4 or $statut == 5 or $statut == 7))
|
||||
@ -2753,10 +2753,11 @@ class CommandeFournisseur extends CommonOrder
|
||||
/**
|
||||
* Calc status regarding dispatch stock
|
||||
*
|
||||
* @param User $user User action
|
||||
* @return int <0 if KO, 0 if not applicable, >0 if OK
|
||||
* @param User $user User action
|
||||
* @param int $closeopenorder Close if received
|
||||
* @return int <0 if KO, 0 if not applicable, >0 if OK
|
||||
*/
|
||||
public function calcAndSetStatusDispatch(User $user)
|
||||
public function calcAndSetStatusDispatch(User $user, $closeopenorder=1)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -2794,18 +2795,30 @@ class CommandeFournisseur extends CommonOrder
|
||||
if (count($diff_array)==0)
|
||||
{
|
||||
//No diff => mean everythings is received
|
||||
$ret=$this->setStatus($user,5);
|
||||
if ($ret<0) {
|
||||
$this->error=$object->error; $this->errors=$object->errors;
|
||||
if ($closeopenorder)
|
||||
{
|
||||
$ret=$this->setStatus($user,5);
|
||||
if ($ret<0) {
|
||||
return -1;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Diff => received partially
|
||||
$ret=$this->setStatus($user,4);
|
||||
if ($ret<0) {
|
||||
return -1;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Diff => received partially
|
||||
$ret=$this->setStatus($user,4);
|
||||
if ($ret<0) {
|
||||
$this->error=$object->error; $this->errors=$object->errors;
|
||||
return -1;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
@ -831,7 +831,7 @@ if (empty($reshook))
|
||||
{
|
||||
$date_liv = dol_mktime(GETPOST('rehour'),GETPOST('remin'),GETPOST('resec'),GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear"));
|
||||
|
||||
$result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment"));
|
||||
$result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
|
||||
if ($result > 0)
|
||||
{
|
||||
$langs->load("deliveries");
|
||||
|
||||
@ -77,6 +77,8 @@ if ($id > 0 || ! empty($ref)) {
|
||||
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -147,9 +149,11 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
||||
$db->begin();
|
||||
|
||||
$pos = 0;
|
||||
foreach ( $_POST as $key => $value ) {
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
// without batch module enabled
|
||||
if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
|
||||
if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg))
|
||||
{
|
||||
$pos ++;
|
||||
|
||||
// $numline=$reg[2] + 1; // line of product
|
||||
@ -179,7 +183,8 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
||||
}
|
||||
}
|
||||
// with batch module enabled
|
||||
if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
|
||||
if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg))
|
||||
{
|
||||
$pos ++;
|
||||
|
||||
// eat-by date dispatch
|
||||
@ -224,7 +229,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$result = $commande->calcAndSetStatusDispatch($user);
|
||||
$result = $commande->calcAndSetStatusDispatch($user, GETPOST('closeopenorder')?1:0);
|
||||
if ($result < 0) {
|
||||
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||
$error ++;
|
||||
@ -543,15 +548,21 @@ if ($id > 0 || ! empty($ref)) {
|
||||
print "</table>\n";
|
||||
print "<br/>\n";
|
||||
|
||||
if ($nbproduct) {
|
||||
print $langs->trans("Comment") . ' : ';
|
||||
if ($nbproduct)
|
||||
{
|
||||
$checkboxlabel=$langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv($commande->statuts[5]));
|
||||
|
||||
print '<br><div class="center">';
|
||||
print $langs->trans("Comment") . ' : ';
|
||||
print '<input type="text" size="60" maxlength="128" name="comment" value="';
|
||||
print $_POST["comment"] ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $commande->ref);
|
||||
// print ' / '.$commande->ref_supplier; // Not yet available
|
||||
print '" class="flat"> ';
|
||||
print '" class="flat"><br>';
|
||||
|
||||
print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel;
|
||||
|
||||
// print '<div class="center">';
|
||||
print '<input type="submit" class="button" value="' . $langs->trans("DispatchVerb") . '"';
|
||||
print '<br><input type="submit" class="button" value="' . $langs->trans("DispatchVerb") . '"';
|
||||
if (count($listwarehouses) <= 0)
|
||||
print ' disabled';
|
||||
print '>';
|
||||
|
||||
@ -157,3 +157,4 @@ OrderCreated=Your orders have been created
|
||||
OrderFail=An error happened during your orders creation
|
||||
CreateOrders=Create orders
|
||||
ToBillSeveralOrderSelectCustomer=To create an invoice for several orders, click first onto customer, then choose "%s".
|
||||
CloseReceivedSupplierOrdersAutomatically=Close order to "%s" automatically if all products are received.
|
||||
Loading…
Reference in New Issue
Block a user