diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 485b5b0daf9..229919d7e5d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -690,7 +690,7 @@ if (empty($reshook)) { } $deposit = null; - $locationTarget = $_SERVER['PHP_SELF'] . '?id=' . $object->id; + $locationTarget = ''; $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); @@ -720,6 +720,7 @@ if (empty($reshook)) { if (!$error) { $db->commit(); + if ($deposit && empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret = $deposit->fetch($deposit->id); // Reload to get new records $outputlangs = $langs; @@ -736,12 +737,15 @@ if (empty($reshook)) { setEventMessages($deposit->error, $deposit->errors, 'errors'); } } + + if ($locationTarget) { + header('Location: ' . $locationTarget); + exit; + } } else { $db->rollback(); + $action = ''; } - - header('Location: ' . $locationTarget); - exit; } } } elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { @@ -1706,7 +1710,7 @@ if ($action == 'create') { print ''.$langs->trans("ValidityDuration").''.img_picto('', 'clock', 'class="paddingright"').' '.$langs->trans("days").''; // Terms of payment - print ''.$langs->trans('PaymentConditionsShort').''; + print ''.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'paiment'); $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent)); print ''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 1a35ff937b9..6ba7b9086c3 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1177,7 +1177,7 @@ if (empty($reshook)) { } if (!$error) { - $locationTarget = $_SERVER['PHP_SELF'] . '?id=' . $object->id; + $locationTarget = ''; $db->begin(); $result = $object->valid($user, $idwarehouse); if ($result >= 0) { @@ -1205,6 +1205,7 @@ if (empty($reshook)) { setEventMessage('DepositGenerated'); $locationTarget = DOL_URL_ROOT . '/compta/facture/card.php?id=' . $deposit->id; } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1236,6 +1237,11 @@ if (empty($reshook)) { $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } + + if ($locationTarget) { + header('Location: ' . $locationTarget); + exit; + } } else { $db->rollback(); } @@ -1243,9 +1249,6 @@ if (empty($reshook)) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - - header('Location: ' . $locationTarget); - exit; } } elseif ($action == 'confirm_modif' && $usercancreate) { // Go back to draft status