From 455dcd8eb91c5a18305c28cf1aae8a4b7f6daf67 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Fri, 10 Nov 2023 20:03:39 +0200 Subject: [PATCH] NEW: Propagate invoice extrafields into template invoice (#26529) * NEW: Propagate invoice extrafields into template invoice Also rearrange form fields to be on par with other invoice creation screens look and feel * fix PHPCS --- htdocs/compta/facture/card-rec.php | 101 +++++++++++++++++------------ 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index b2a7d1b0a8d39..a14eff9a1bb57 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -9,6 +9,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Meziane Sof * Copyright (C) 2017-2018 Frédéric France + * Copyright (C) 2023 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -222,6 +223,11 @@ $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); $object->date_when = $date_next_execution; + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + // Get first contract linked to invoice used to generate template (facid is id of source invoice) if (GETPOST('facid', 'int') > 0) { $srcObject = new Facture($db); @@ -1023,28 +1029,6 @@ } $htmltext .= ''; - // Public note - print ''; - print ''; - print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); - print ''; - print ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); - print $doleditor->Create(1); - - // Private note - if (empty($user->socid)) { - print ''; - print ''; - print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); - print ''; - print ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); - print $doleditor->Create(1); - // print ' - print ''; - } - // Author print "".$langs->trans("Author")."".$user->getFullName($langs).""; @@ -1068,6 +1052,18 @@ print ""; } + //extrafields + $draft = new Facture($db); + $draft->fetch(GETPOST('facid', 'int')); + + $extralabels = new ExtraFields($db); + $extralabels = $extrafields->fetch_name_optionals_label($draft->table_element); + if ($draft->fetch_optionals() > 0) { + $object->array_options = array_merge($object->array_options, $draft->array_options); + } + + print $object->showOptionals($extrafields, 'create', $parameters); + // Project if (isModEnabled('project') && is_object($object->thirdparty) && $object->thirdparty->id > 0) { $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; @@ -1087,11 +1083,32 @@ print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); print ""; + // Public note + print ''; + print ''; + print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); + print ''; + print ''; + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); + print $doleditor->Create(1); + + // Private note + if (empty($user->socid)) { + print ''; + print ''; + print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); + print ''; + print ''; + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); + print $doleditor->Create(1); + // print ' + print ''; + } + print ""; print dol_get_fiche_end(); - // Autogeneration $title = $langs->trans("Recurrence"); print load_fiche_titre(img_picto('', 'recurring', 'class="pictofixedwidth"').$title, '', ''); @@ -1407,22 +1424,6 @@ } $htmltext .= ''; - // Note public - print ''; - print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer')); - print ''; - print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); - print ''; - print ''; - - // Note private - print ''; - print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer')); - print ''; - print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); - print ''; - print ''; - // Bank Account print ''; print '"; print ''; + // Extrafields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + + // Note public + print ''; + print ''; + + // Note private + print ''; + print ''; + // Model pdf print '
'; @@ -1441,6 +1442,26 @@ print "
'; + print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer')); + print ''; + print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); + print '
'; + print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer')); + print ''; + print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); + print '
'; print '
'; @@ -1468,7 +1489,7 @@ // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + print '
';