From 17d5c385ff3716bb413102bfbdd6269932ab4410 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2019 15:46:48 +0100 Subject: [PATCH] FIX #12320 It is clearer that you can't change thirdparty when creating invoice from template with a recurring rule. --- htdocs/compta/facture/card.php | 42 ++++++++++++------- htdocs/compta/facture/class/facture.class.php | 5 ++- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index fce1fb7cb25..c9a536cc549 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1151,7 +1151,7 @@ if (empty($reshook)) } // Standard invoice or Deposit invoice, created from a Predefined template invoice - if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec') > 0) + if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) { $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($dateinvoice)) @@ -1661,6 +1661,7 @@ if (empty($reshook)) $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'none')); $object->note = trim(GETPOST('note', 'none')); + $object->note_private = trim(GETPOST('note', 'none')); $object->ref_client = GETPOST('ref_client', 'alpha'); $object->ref_int = GETPOST('ref_int', 'alpha'); $object->modelpdf = GETPOST('model', 'alpha'); @@ -2752,10 +2753,18 @@ if ($action == 'create') // Ref print '' . $langs->trans('Ref') . '' . $langs->trans('Draft') . ''; - // Thirdparty - print '' . $langs->trans('Customer') . ''; - if ($soc->id > 0 && ! GETPOST('fac_rec', 'int')) + $exampletemplateinvoice=new FactureRec($db); + $invoice_predefined = new FactureRec($db); + if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) { + $invoice_predefined->fetch(GETPOST('fac_rec', 'int')); + } + + // Thirdparty + if ($soc->id > 0 && (! GETPOST('fac_rec', 'int') || ! empty($invoice_predefined->frequency))) + { + // If thirdparty known and not a predefined invoiced without a recurring rule + print '' . $langs->trans('Customer') . ''; print ''; print $soc->getNomUrl(1); print ''; @@ -2771,9 +2780,11 @@ if ($action == 'create') } print ')'; print ''; + print '' . "\n"; } else { + print '' . $langs->trans('Customer') . ''; print ''; print $form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. Note, this clear other input @@ -2790,17 +2801,14 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + if (! GETPOST('fac_rec', 'int')) print ' '.$langs->trans("AddThirdParty").''; print ''; + print '' . "\n"; } - print '' . "\n"; - - $exampletemplateinvoice=new FactureRec($db); // Overwrite some values if creation of invoice is from a predefined invoice if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) { - $invoice_predefined = new FactureRec($db); $invoice_predefined->fetch(GETPOST('fac_rec', 'int')); $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later @@ -2827,13 +2835,14 @@ if ($action == 'create') if ($num > 0) { print '' . $langs->trans('CreateFromRepeatableInvoice') . ''; - print ''; + print 'id > 0) $text .= ' disabled'; $text .= '>'; if ($options) { @@ -3057,7 +3067,7 @@ if ($action == 'create') print '
'; $tmp='global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp.=' disabled'; + if ((! $optionsav && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) || $invoice_predefined->id > 0) $tmp.=' disabled'; $tmp.= '> '; // Show credit note options only if we checked credit note print '