diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 568cd5dca21..e136d8663fe 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -280,6 +280,24 @@ if ($action == 'set_FAC_AUTO_FILLJS') } } +if ($action == 'set_INVOICE_CREDIT_NOTE_STANDALONE') +{ + $freetext = GETPOST('INVOICE_CREDIT_NOTE_STANDALONE'); // No alpha here, we want exact string + + $res = dolibarr_set_const($db, "INVOICE_CREDIT_NOTE_STANDALONE",$freetext,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + /* * View @@ -750,6 +768,34 @@ print '\n"; print ''; +// Add js auto fill amount on paiement form +$var=! $var; +print '
'; +print ''; +print ''; +print ''; +print $langs->trans("JSOnPaimentBill"); +print ''; +print $form->selectyesno("FAC_AUTO_FILLJS",$conf->global->FAC_AUTO_FILLJS,1); +print ''; +print ''; +print "\n"; +print '
'; + +// Allow to create credit note not related to an invoice +$var=! $var; +print '
'; +print ''; +print ''; +print ''; +print $langs->trans("AllowCreditNoteWithoutRelatedInvoice"); +print ''; +print $form->selectyesno("INVOICE_CREDIT_NOTE_STANDALONE",$conf->global->INVOICE_CREDIT_NOTE_STANDALONE,1); +print ''; +print ''; +print "\n"; +print '
'; + $var=! $var; print '
'; print ''; @@ -784,20 +830,6 @@ print '\n"; print '
'; -// Add js auto fill amount on paiement form -$var=! $var; -print '
'; -print ''; -print ''; -print ''; -print $langs->trans("JSOnPaimentBill"); -print ''; -print $form->selectyesno("FAC_AUTO_FILLJS",$conf->global->FAC_AUTO_FILLJS,1); -print ''; -print ''; -print "\n"; -print '
'; - print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 983331bd412..47f8b21eb6a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -713,7 +713,8 @@ if (empty($reshook)) // Credit note invoice if ($_POST['type'] == Facture::TYPE_CREDIT_NOTE) { - if (! ($_POST['fac_avoir'] > 0)) + $sourceinvoice = GETPOST('fac_avoir'); + if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) { $error ++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors'); @@ -746,7 +747,7 @@ if (empty($reshook)) $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); // Proprietes particulieres a facture avoir - $object->fk_facture_source = $_POST['fac_avoir']; + $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; $object->type = Facture::TYPE_CREDIT_NOTE; $id = $object->create($user); @@ -2033,7 +2034,7 @@ if ($action == 'create') $newinvoice_static->paye = $valarray ['paye']; $optionsav .= '