Skip to content

Commit

Permalink
FIX: on shipment delete confirm dialog, a new checkbox allows the use…
Browse files Browse the repository at this point in the history
…r to choose if they want their stock re-incremented after the deletion.
  • Loading branch information
atm-florianm committed Jul 4, 2019
1 parent 9d50c67 commit 64d1ebf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
24 changes: 22 additions & 2 deletions htdocs/expedition/card.php
Expand Up @@ -468,7 +468,8 @@

else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer)
{
$result = $object->delete();
$also_update_stock = GETPOST('alsoUpdateStock', 'alpha') ?: 0;
$result = $object->delete($also_update_stock);
if ($result > 0)
{
header("Location: ".DOL_URL_ROOT.'/expedition/index.php');
Expand Down Expand Up @@ -1648,7 +1649,26 @@
// Confirm deleteion
if ($action == 'delete')
{
$formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('DeleteSending'),$langs->trans("ConfirmDeleteSending",$object->ref),'confirm_delete','',0,1);
$formquestion = array();
if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
$formquestion = array(
array(
'label' => $langs->trans('ShipmentIncrementStockOnDelete'),
'name' => 'alsoUpdateStock',
'type' => 'checkbox',
'value' => 0
),
);
}
$formconfirm=$form->formconfirm(
$_SERVER['PHP_SELF'].'?id='.$object->id,
$langs->trans('DeleteSending'),
$langs->trans("ConfirmDeleteSending",$object->ref),
'confirm_delete',
$formquestion,
0,
1
);
}

// Confirmation validation
Expand Down
4 changes: 2 additions & 2 deletions htdocs/expedition/class/expedition.class.php
Expand Up @@ -1079,7 +1079,7 @@ function update($user=null, $notrigger=0)
*
* @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO
*/
function delete()
function delete($also_update_stock = false)
{
global $conf, $langs, $user;

Expand Down Expand Up @@ -1111,7 +1111,7 @@ function delete()
}

// Stock control
if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT)
if (! $error && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT && $also_update_stock)
{
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");

Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/fr_FR/sendings.lang
Expand Up @@ -60,6 +60,8 @@ NoProductToShipFoundIntoStock=Aucun produit à expédier n'a été trouver dans
WeightVolShort=Poids/vol.
ValidateOrderFirstBeforeShipment=Vous devez d'abord valider la commande pour pouvoir créer une expédition.

ShipmentIncrementStockOnDelete=Remettre en stock les éléments de cette expédition

# Sending methods
# ModelDocument
DocumentModelTyphon=Modèle de bon de réception/livraison complet (logo…)
Expand Down

0 comments on commit 64d1ebf

Please sign in to comment.