From 0fbc5bd42377a7d34cc770987cbae74ef517bca6 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:46:48 +0200 Subject: [PATCH] NEW: Supplier template invoive extrafields (#26570) * NEW: Supplier template invoive extrafields * NEW: Supplier template invoive extrafields * NEW: Supplier template invoive extrafields --- .../admin/supplierinvoice_rec_extrafields.php | 109 +++++++++++++++++ .../supplierinvoicedet_rec_extrafields.php | 111 ++++++++++++++++++ htdocs/core/lib/fourn.lib.php | 21 ++++ htdocs/langs/en_US/admin.lang | 2 + 4 files changed, 243 insertions(+) create mode 100644 htdocs/admin/supplierinvoice_rec_extrafields.php create mode 100644 htdocs/admin/supplierinvoicedet_rec_extrafields.php diff --git a/htdocs/admin/supplierinvoice_rec_extrafields.php b/htdocs/admin/supplierinvoice_rec_extrafields.php new file mode 100644 index 00000000000..2fda69ff695 --- /dev/null +++ b/htdocs/admin/supplierinvoice_rec_extrafields.php @@ -0,0 +1,109 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2013-2018 Philippe Grand + * Copyright (C) 2013 Juanjo Menent + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/supplierinvoice_rec_extrafields.php + * \ingroup fourn + * \brief Page to setup extra fields of recurring supplierinvoice + */ + +// Load Dolibarr environment +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("admin", "other", "bills", "orders", "suppliers")); + +if (!$user->admin) { + accessforbidden(); +} + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} + +$action = GETPOST('action', 'aZ09'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'facture_fourn_rec'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) { + accessforbidden(); +} + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject = $langs->transnoentitiesnoconv("BillsSuppliers"); + +llxHeader('', $langs->trans("SuppliersSetup")); + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup'); +print "
\n"; + +$head = supplierorder_admin_prepare_head(); + +print dol_get_fiche_head($head, 'attributesrec', $langs->trans("Suppliers"), -1, 'company'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +print dol_get_fiche_end(); + + +// Creation of an optional field +if ($action == 'create') { + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +// Edition of an optional field +if ($action == 'edit' && !empty($attrname)) { + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/supplierinvoicedet_rec_extrafields.php b/htdocs/admin/supplierinvoicedet_rec_extrafields.php new file mode 100644 index 00000000000..666430611d8 --- /dev/null +++ b/htdocs/admin/supplierinvoicedet_rec_extrafields.php @@ -0,0 +1,111 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2015 Claudio Aschieri + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/supplierinvoicedet_rec_extrafields.php + * \ingroup fourn + * \brief Page to setup extra fields of recurring supplierinvoice line + */ + +// Load Dolibarr environment +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + + +if (!$user->admin) { + accessforbidden(); +} + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'other', 'bills', 'orders', 'suppliers')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} + +$action = GETPOST('action', 'aZ09'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'facture_fourn_det_rec'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) { + accessforbidden(); +} + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject = $langs->transnoentitiesnoconv("BillsSuppliers"); + +llxHeader('', $langs->trans("SuppliersSetup")); + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("SuppliersSetup"), $linkback, 'title_setup'); +print "
\n"; + +$head = supplierorder_admin_prepare_head(); + +print dol_get_fiche_head($head, 'attributeslinesrec', $langs->trans("Suppliers"), -1, 'company'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +print dol_get_fiche_end(); + + +// Creation of an optional field +if ($action == 'create') { + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +// Edition of an optional field +if ($action == 'edit' && !empty($attrname)) { + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 3f2bcd48da7..767d1912bb2 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2006 Marc Barilley * Copyright (C) 2011-2013 Philippe Grand * Copyright (C) 2022-2023 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 @@ -258,6 +259,8 @@ function supplierorder_admin_prepare_head() $extrafields->fetch_name_optionals_label('commande_fournisseurdet'); $extrafields->fetch_name_optionals_label('facture_fourn'); $extrafields->fetch_name_optionals_label('facture_fourn_det'); + $extrafields->fetch_name_optionals_label('facture_fourn_rec'); + $extrafields->fetch_name_optionals_label('facture_fourn_det_rec'); $h = 0; $head = array(); @@ -315,6 +318,24 @@ function supplierorder_admin_prepare_head() $head[$h][2] = 'supplierinvoicedet'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_rec_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoicesRec"); + $nbExtrafields = $extrafields->attributes['facture_fourn_rec']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } + $head[$h][2] = 'attributesrec'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoicedet_rec_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoicesLinesRec"); + $nbExtrafields = $extrafields->attributes['facture_fourn_det_rec']['count']; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } + $head[$h][2] = 'attributeslinesrec'; + $h++; + complete_head_from_modules($conf, $langs, null, $head, $h, 'supplierorder_admin', 'remove'); return $head; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d41cdccec91..3844ee142c0 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2427,3 +2427,5 @@ LargeModern=Large - Modern SpecialCharActivation=Enable the button to open a virtual keyboard to enter special characters DeleteExtrafield=Delete extrafield ConfirmDeleteExtrafield=Confirm delete %s extrafield ? All data is going to be lost +ExtraFieldsSupplierInvoicesRec=Complementary attributes (templates invoices) +ExtraFieldsSupplierInvoicesLinesRec=Complementary attributes (invoice lines)