From 71db2603e15759585db8923fccce6a9c1bbfae96 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 19 Oct 2020 13:52:12 +0200 Subject: [PATCH] FIX pb of duplicate event on command when refreshing the page after command classification as billed or closed --- htdocs/commande/card.php | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3ee5b89e01a..cefe4dfccf6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1282,6 +1282,17 @@ if (empty($reshook)) exit(); } + //Used to not reclass as billed a command which is already billed by refreshing the page + if(strpos( $_SERVER["REQUEST_URI"],'action=classifybilled') && $object->billed){ + header("Location: $_SERVER[PHP_SELF]?id=$object->id"); + exit(); + } + //Used to not reclass as closed command which is already closed by refreshing the page + if(strpos( $_SERVER["REQUEST_URI"],'action=confirm_shipped') && Commande::STATUS_CLOSED){ + header("Location: $_SERVER[PHP_SELF]?id=$object->id"); + exit(); + } + // add lines from objectlinked if ($action == 'import_lines_from_object' && $usercancreate @@ -2490,7 +2501,7 @@ if ($action == 'create' && $usercancreate) if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $usercancreate) { print '
'.$langs->trans('ReOpen').'
'; } - + // Send if (empty($user->socid)) { if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { @@ -2499,7 +2510,7 @@ if ($action == 'create' && $usercancreate) } else print ''.$langs->trans('SendMail').''; } } - + // Valid if ($object->statut == Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || !empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate) { @@ -2517,7 +2528,7 @@ if ($action == 'create' && $usercancreate) // page. print '' . $langs->trans("AddAction") . ''; }*/ - + // Create a purchase order if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { @@ -2527,11 +2538,11 @@ if ($action == 'create' && $usercancreate) } } } - + // Create intervention if ($conf->ficheinter->enabled) { $langs->load("interventions"); - + if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($user->rights->ficheinter->creer) { print ''.$langs->trans('AddIntervention').''; @@ -2540,21 +2551,21 @@ if ($action == 'create' && $usercancreate) } } } - + // Create contract if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)) { $langs->load("contracts"); - + if ($user->rights->contrat->creer) { print ''.$langs->trans('AddContract').''; } } - + // Ship $numshipping = 0; if (!empty($conf->expedition->enabled)) { $numshipping = $object->nb_expedition(); - + if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { if ($user->rights->expedition->creer) { @@ -2568,12 +2579,11 @@ if ($action == 'create' && $usercancreate) } } } - + // Set to shipped if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $usercanclose) { print '
'.$langs->trans('ClassifyShipped').'
'; } - // Create bill and Classify billed // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" if ($object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0) { @@ -2593,13 +2603,13 @@ if ($action == 'create' && $usercancreate) if ($usercancreate) { print '
'.$langs->trans("ToClone").'
'; } - + // Cancel order if ($object->statut == Commande::STATUS_VALIDATED && (!empty($usercanclose) || !empty($usercancancel))) { print '
'.$langs->trans('Cancel').'
'; } - + // Delete order if ($usercandelete) { if ($numshipping == 0) { @@ -2611,7 +2621,7 @@ if ($action == 'create' && $usercancreate) } print ''; } - + // Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend';