diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 9ce79e02889..1e15d8c3754 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -435,6 +435,62 @@ if ($action == 'setenabletabonthirdparty') { } } +if ($action == 'setexportenablelettering') { + $setexportenablelettering = GETPOSTINT('value'); + $res = dolibarr_set_const($db, "ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING", $setexportenablelettering, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + +if ($action == 'setexportenableexportdate') { + $setexportenableexportdate = GETPOSTINT('value'); + $res = dolibarr_set_const($db, "ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE", $setexportenableexportdate, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + +if ($action == 'setexportenablevalidationdate') { + $setexportenablevalidationdate = GETPOSTINT('value'); + $res = dolibarr_set_const($db, "ACCOUNTING_DEFAULT_NOTIFIED_VALIDATION_DATE", $setexportenablevalidationdate, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + +if ($action == 'setexportenablefull') { + $setexportenablefull = GETPOSTINT('value'); + $res = dolibarr_set_const($db, "ACCOUNTING_DEFAULT_NOTIFIED_EXPORTFULL", $setexportenablefull, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + if ($action == 'updateMask') { $maskconstbookkeeping = GETPOST('maskconstbookkeeping', 'aZ09'); $maskbookkeeping = GETPOST('maskbookkeeping', 'alpha'); @@ -989,10 +1045,66 @@ if ($num2) { print ''; } - - print "\n"; } +print ''; +print ''; +print $form->textwithpicto($langs->trans("AccountingDefaultNotExportLettering"), $langs->trans("AccountingDefaultNotExportLetteringDesc")) . ''; +if (getDolGlobalInt('ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING')) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''; +print $form->textwithpicto($langs->trans("AccountingDefaultNotNotifiedExportDate"), $langs->trans("AccountingDefaultNotNotifiedExportDateDesc")) . ''; +if (getDolGlobalInt('ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE')) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''; +print $form->textwithpicto($langs->trans("AccountingDefaultNotifiedValidationDate"), $langs->trans("AccountingDefaultNotifiedValidationDateDesc")) . ''; +if (getDolGlobalInt('ACCOUNTING_DEFAULT_NOTIFIED_VALIDATION_DATE')) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''; +print $form->textwithpicto($langs->trans("AccountingDefaultNotifiedExportFull"), $langs->trans("AccountingDefaultNotifiedExportFullDesc")) . ''; +if (getDolGlobalInt('ACCOUNTING_DEFAULT_NOTIFIED_EXPORTFULL')) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print "\n"; + print '
'; print ''; diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 515dda487ca..c4537358066 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -812,36 +812,36 @@ if ($action == 'export_file') { if (getDolGlobalInt("ACCOUNTING_ENABLE_LETTERING")) { // If 1, we check by default. - $checked = getDolGlobalString('ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING') ? 'true' : 'false'; + $checked_exportreconcile = getDolGlobalString('ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING') ? 'true' : 'false'; $form_question['notexportlettering'] = array( 'name' => 'notexportlettering', 'type' => 'checkbox', 'label' => $langs->trans('NotExportLettering'), - 'value' => $checked, + 'value' => $checked_exportreconcile, ); $form_question['separator1'] = array('name' => 'separator1', 'type' => 'separator'); } // If 1 or not set, we check by default. - $checked = (!isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) || getDolGlobalString('ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE')); + $checked_exportdate = getDolGlobalString('ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE') ? 'true' : 'false'; $form_question['notifiedexportdate'] = array( 'name' => 'notifiedexportdate', 'type' => 'checkbox', 'label' => $langs->trans('NotifiedExportDate'), - 'value' => (getDolGlobalString('ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE') ? 'false' : 'true'), + 'value' => $checked_exportdate, ); $form_question['separator2'] = array('name' => 'separator2', 'type' => 'separator'); if (!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")) { // If 0 or not set, we NOT check by default. - $checked = getDolGlobalString('ACCOUNTING_DEFAULT_NOTIFIED_VALIDATION_DATE'); + $checked_validationdate = getDolGlobalString('ACCOUNTING_DEFAULT_NOTIFIED_VALIDATION_DATE') ? 'true' : 'false'; $form_question['notifiedvalidationdate'] = array( 'name' => 'notifiedvalidationdate', 'type' => 'checkbox', 'label' => $langs->trans('NotifiedValidationDate', $langs->transnoentitiesnoconv("MenuAccountancyClosure")), - 'value' => $checked, + 'value' => $checked_validationdate, ); $form_question['separator3'] = array('name' => 'separator3', 'type' => 'separator'); @@ -865,11 +865,12 @@ if ($action == 'export_file') { $except[] = $langs->trans('SupplierInvoice'); } + $checked_exportfull = getDolGlobalString('ACCOUNTING_DEFAULT_NOTIFIED_EXPORTFULL') ? 'true' : 'false'; $form_question['notifiedexportfull'] = array( 'name' => 'notifiedexportfull', 'type' => 'checkbox', 'label' => $langs->trans('NotifiedExportFull').(empty($except) ? '' : ' ('.$langs->trans("except").' '.implode(', ', $except).')'), - 'value' => 'false', + 'value' => $checked_exportfull, ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").'...', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 500, 700); @@ -879,12 +880,18 @@ if ($action == 'export_file') { const exportTypesWithDocs = ['.implode(',', $exportTypesWithDocs).']; const $formatExport = jQuery("#formatexport"); + // We retrieve the configured default value (true or false in native JavaScript) + const defaultChecked = ' . $checked_exportfull . '; + function toggleExportFull() { const $checkbox = jQuery("#notifiedexportfull"); const show = exportTypesWithDocs.indexOf(parseInt($formatExport.val())) !== -1; $checkbox.closest(".tagtr").toggle(show); + if (!show) { $checkbox.prop("checked", false); // remove checked if hidden + } else { + $checkbox.prop("checked", defaultChecked); // Restore the default configuration if displayed } } diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index fe6beac22d5..0d1b7dc6390 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -41,7 +41,7 @@ class Login global $db; $this->db = $db; - if (!getDolGlobalString('API_ENABLE_LOGIN_API')) { + if (!getDolGlobalInt('API_ENABLE_LOGIN_API')) { throw new RestException(403, "Error: The login APIs are disabled. It is recommended to call the APIs using the DOLAPIKEY token of an allowed user instead of the login/password. API key can be set from the user card. If you really need to get the API token from the login API, you can set the constant API_ENABLE_LOGIN_API."); } } @@ -186,7 +186,7 @@ class Login 'success' => array( 'code' => 200, 'token' => $token, - 'entity' => $tmpuser->entity, + 'entity' => $tmpuser->entity ?? 1, 'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (recorded for your user). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') ) ); diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index f730c09dc1d..48fbd3eacbe 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -3,7 +3,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2026 Frédéric France * * 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 @@ -27,21 +27,20 @@ // Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - /** * @var Conf $conf * @var DoliDB $db + * @var ExtraFields $extrafields * @var HookManager $hookmanager * @var Translate $langs * @var User $user */ +require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; + // Load translation files required by the page $langs->loadLangs(array('categories', 'admin')); -$extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format diff --git a/htdocs/categories/admin/categorie_lang_extrafields.php b/htdocs/categories/admin/categorie_lang_extrafields.php new file mode 100644 index 00000000000..953bd871a59 --- /dev/null +++ b/htdocs/categories/admin/categorie_lang_extrafields.php @@ -0,0 +1,128 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2026 Frédéric France + * + * 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 admin/categorie_lang_extrafields.php + * \ingroup categorie + * \brief Page to setup extra fields of categorie lang + */ + +// Load Dolibarr environment +require '../../main.inc.php'; + +/** + * @var Conf $conf + * @var DoliDB $db + * @var ExtraFields $extrafields + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ + +require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'categories')); + +$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 = 'categorie_lang'; // 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("Category"); + +$help_url = ''; +$page_name = "CategoriesTranslationsExtrafields"; + +llxHeader('', $langs->trans($page_name), $help_url); + + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); + + +$head = categoriesadmin_prepare_head(); + +print dol_get_fiche_head($head, 'translationAttributes', $langs->trans($page_name), -1, 'categorie'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +print dol_get_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') { + print '
'; + print ''.$langs->trans("NewAttribute").''; + print "
"; +} + + +/* + * 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/categories/card.php b/htdocs/categories/card.php index 0127c4a6ede..9d70b0a8ab8 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2020-2024 Frédéric France + * Copyright (C) 2020-2026 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -30,18 +30,18 @@ // Load Dolibarr environment require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - /** * @var Conf $conf * @var DoliDB $db + * @var ExtraFields $extrafields * @var HookManager $hookmanager * @var Translate $langs * @var User $user */ +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + // Load translation files required by the page $langs->load("categories"); @@ -104,7 +104,6 @@ if (!GETPOSTISSET('parent') && $catorigin) { $object = new Categorie($db); -$extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array diff --git a/htdocs/categories/categorie_list.php b/htdocs/categories/categorie_list.php index c1ce32da04a..20fdef48fa7 100644 --- a/htdocs/categories/categorie_list.php +++ b/htdocs/categories/categorie_list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024-2025 Frédéric France + * Copyright (C) 2024-2026 Frédéric France * Copyright (C) 2025-2026 MDW * * This program is free software; you can redistribute it and/or modify @@ -25,20 +25,21 @@ // Load Dolibarr environment require '../main.inc.php'; +/** + * @var Conf $conf + * @var DoliDB $db + * @var ExtraFields $extrafields + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -/** - * @var Conf $conf - * @var DoliDB $db - * @var HookManager $hookmanager - * @var Translate $langs - * @var User $user - */ - // Load translation files required by the page $langs->loadLangs(array("accountancy", "agenda", "banks", "bills", "categories", "contracts", "interventions", "mrp")); $langs->loadLangs(array("knowledgemanagement", "members", "orders", "products", "stocks", "suppliers", "tickets")); @@ -84,7 +85,7 @@ $pagenext = $page + 1; // Initialize technical objects $object = new Categorie($db); -$extrafields = new ExtraFields($db); + $diroutputmassaction = $conf->category->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 53ccd935391..f33640e4732 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -663,11 +663,11 @@ class Categorie extends CommonObject /** * Update category * - * @param User $user Object user - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int 1 : OK - * -1 : SQL error - * -2 : invalid category + * @param User $user Object user + * @param int<0,1> $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int<-2,1> 1 : OK + * -1 : SQL error + * -2 : invalid category */ public function update(User $user, $notrigger = 0) { @@ -706,6 +706,14 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); if ($this->db->query($sql)) { + // Multilangs + if (getDolGlobalInt('MAIN_MULTILANGS')) { + if ($this->setMultiLangs($user, $notrigger) < 0) { + $this->db->rollback(); + return -2; + } + } + $action = 'update'; // Actions on extra fields @@ -2167,35 +2175,37 @@ class Categorie extends CommonObject if ($key == $current_lang) { $sql2 = ''; - if ($this->db->num_rows($result)) { // if no line in database + if ($this->db->num_rows($result)) { // if there is already a description line for this language $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; $sql2 .= " SET label = '".$this->db->escape($this->label)."',"; $sql2 .= " description = '".$this->db->escape($this->description)."'"; $sql2 .= " WHERE fk_category = ".((int) $this->id)." AND lang = '".$this->db->escape($key)."'"; - } elseif (isset($this->multilangs[$key])) { + } else { // if no line in database $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; $sql2 .= " VALUES(".((int) $this->id).", '".$this->db->escape($key)."', '".$this->db->escape($this->label)."'"; - $sql2 .= ", '".$this->db->escape($this->multilangs[$key]["description"])."')"; + $sql2 .= ", '".$this->db->escape($this->description)."')"; } dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if ($sql2 && !$this->db->query($sql2)) { + if (!$this->db->query($sql2)) { $this->error = $this->db->lasterror(); return -1; } - } elseif (isset($this->multilangs[$key])) { - if ($this->db->num_rows($result)) { // if no line in database + $this->multilangs[$key]["label"] = $this->label; + $this->multilangs[$key]["description"] = $this->description; + } elseif (isset($this->multilangs[$key])) { // if there is already a description line for this language + if ($this->db->num_rows($result)) { $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; $sql2 .= " SET label='".$this->db->escape($this->multilangs[$key]["label"])."',"; $sql2 .= " description='".$this->db->escape($this->multilangs[$key]["description"])."'"; $sql2 .= " WHERE fk_category=".((int) $this->id)." AND lang='".$this->db->escape($key)."'"; - } else { + } else { // if no line in database $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)"; $sql2 .= " VALUES(".((int) $this->id).", '".$this->db->escape($key)."', '".$this->db->escape($this->multilangs[$key]["label"])."'"; $sql2 .= ",'".$this->db->escape($this->multilangs[$key]["description"])."')"; } - // on ne sauvegarde pas des champs vides - if ($this->multilangs[$key]["label"] || $this->multilangs[$key]["description"] || $this->multilangs[$key]["note"]) { + // We do not save if main fields are empty + if ($this->multilangs[$key]["label"] || $this->multilangs[$key]["description"]) { dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); } if (!$this->db->query($sql2)) { diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 33d759d1bc9..fe084fd4906 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -3,7 +3,7 @@ * Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2020-2024 Frédéric France + * Copyright (C) 2020-2026 Frédéric France * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -29,12 +29,12 @@ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; /** * @var Conf $conf * @var DoliDB $db + * @var ExtraFields $extrafields * @var HookManager $hookmanager * @var Translate $langs * @var User $user @@ -82,7 +82,6 @@ if (is_numeric($type)) { $type = array_search($type, $object->MAP_ID); // For backward compatibility } -$extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); $error = 0; diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index c30e1eeb21b..f4fa2c44dd8 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -161,12 +161,18 @@ if ($object->id) { print '
'; print ''; - // Description + // Label print ''; + // Description + // print ''; + // Color print '
'; - print $langs->trans("Description").''; - print dol_htmlentitiesbr($object->description); + print $langs->trans("Label").''; + print dol_htmlentitiesbr($object->label); print '
'; + // print $langs->trans("Description").''; + // print dol_htmlentitiesbr($object->description); + // print '
'; print $langs->trans("Color").''; diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index a66e333fdf4..29d364b5595 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -3,7 +3,7 @@ * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2010-2016 Destailleur Laurent * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2026 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -29,20 +29,21 @@ // Load Dolibarr environment require '../main.inc.php'; +/** + * @var Conf $conf + * @var DoliDB $db + * @var ExtraFields $extrafields + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ + require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -/** - * @var Conf $conf - * @var DoliDB $db - * @var HookManager $hookmanager - * @var Translate $langs - * @var User $user - */ - // Load translation files required by the page $langs->loadLangs(array('categories', 'languages', 'mrp')); @@ -63,6 +64,10 @@ if ($result <= 0) { dol_print_error($db, $object->error); exit; } +$extralabels = $extrafields->fetch_name_optionals_label("categorie_lang"); + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('categorietranslationcard', 'globalcard')); $type = $object->type; if (is_numeric($type)) { @@ -73,21 +78,28 @@ if (is_numeric($type)) { $result = restrictedArea($user, 'categorie', $id, '&category'); $permissiontoadd = $user->hasRight('categorie', 'creer'); - +$permissiontodelete = $user->hasRight('categorie', 'supprimer'); /* * Actions */ $error = 0; - +$parameters = [ + 'id' => $id, + 'ref' => $label, +]; +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} // return to translation view if cancelled -if ($cancel == $langs->trans("Cancel")) { +if (empty($reshook) && $cancel == $langs->trans("Cancel")) { $action = ''; } // delete a translation -if ($action == 'delete' && $langtodelete && $user->hasRight('categorie', 'creer')) { +if (empty($reshook) && $action == 'delete' && $langtodelete && $permissiontodelete) { $res = $object->delMultiLangs($langtodelete, $user); if ($res < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -99,7 +111,7 @@ if ($action == 'delete' && $langtodelete && $user->hasRight('categorie', 'creer' } // validation of addition -if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $permissiontoadd) { +if (empty($reshook) && $action == 'vadd' && $cancel != $langs->trans("Cancel") && $permissiontoadd) { $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -148,7 +160,7 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $permissiontoadd) } // validation of the edition -if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $permissiontoadd) { +if (empty($reshook) && $action == 'vedit' && $cancel != $langs->trans("Cancel") && $permissiontoadd) { $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -164,6 +176,7 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $permissiontoadd if ($key == $current_lang) { $object->label = $libelle; $object->description = dol_htmlcleanlastbr($desc); + $object->update($user); } else { $object->multilangs[$key]["label"] = $libelle; $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($desc); @@ -231,12 +244,18 @@ print '
'; print ''; -// Description +// Label print ''; +// Description +// print ''; + // Color print '
'; -print $langs->trans("Description").''; -print dol_htmlentitiesbr($object->description); +print $langs->trans("Label").''; +print dol_htmlentitiesbr($object->label); print '
'; +// print $langs->trans("Description").''; +// print dol_htmlentitiesbr($object->description); +// print '
'; print $langs->trans("Color").''; @@ -249,18 +268,19 @@ print ''; print dol_get_fiche_end(); - /* * Action bar */ print "\n
\n"; -if ($action == '') { - if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { - print ''.$langs->trans('Add').''; +$parameters = array(); +$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been +if (empty($reshook)) { + if ($action == '' && $permissiontoadd) { + print ''.$langs->trans('Add').''; if ($cnt_trans > 0) { - print ''.$langs->trans('Update').''; + print ''.$langs->trans('Update').''; } } } @@ -268,7 +288,6 @@ if ($action == '') { print "\n
\n"; - if ($action == 'edit') { // WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -281,7 +300,8 @@ if ($action == 'edit') { if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - print "
".$langs->trans('Language_'.$key)." :
"; + $s = picto_from_langcode((string) $key); + print '
'.($s ? $s.' ' : '').''.$langs->trans('Language_'.$key).': ' . $langs->trans('Language_'.$key).' :
'; print ''; // Label @@ -314,7 +334,7 @@ if ($action == 'edit') { foreach ($object->multilangs as $key => $value) { $s = picto_from_langcode((string) $key); print '
'; - print ''; + print ''; print ''; print ''; if (getDolGlobalString('CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION')) { @@ -333,12 +353,12 @@ if ($action == 'edit') { * Form to add a new translation */ -if ($action == 'add' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { +if ($action == 'add' && $permissiontoadd) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; print '
'; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 82fc95fa9eb..f33eb263c5c 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -8,7 +8,7 @@ * Copyright (C) 2020 Josep Lluís Amador * Copyright (C) 2022-2023 Solution Libre SAS * Copyright (C) 2024-2025 MDW - * Copyright (C) 2024-2025 Frédéric France + * Copyright (C) 2024-2026 Frédéric France * Copyright (C) 2024-2025 Alexandre Spangaro * Copyright (C) 2023-2024 Charlene Benke * @@ -37,13 +37,13 @@ require '../main.inc.php'; /** * @var Conf $conf * @var DoliDB $db + * @var ExtraFields $extrafields * @var HookManager $hookmanager * @var Translate $langs * @var User $user */ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page @@ -104,7 +104,6 @@ if (is_numeric($type)) { $type = array_search($type, $object->MAP_ID); // For backward compatibility } -$extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); /* diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 9c06f5b90cb..4b27fa89f96 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Marcos García - * Copyright (C) 2017-2025 Frédéric France + * Copyright (C) 2017-2026 Frédéric France * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2024-2026 MDW * diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e4cdd021dc7..6075962331e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -47,6 +47,7 @@ require '../../main.inc.php'; /** * @var Conf $conf * @var DoliDB $db + * @var ExtraFields $extrafields * @var HookManager $hookmanager * @var Societe $mysoc * @var Translate $langs @@ -236,7 +237,6 @@ $error = 0; // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new Facture($db); $hookmanager->initHooks(array($contextpage)); -$extrafields = new ExtraFields($db); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 068a68404ea..6a0c7186cba 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -219,19 +219,14 @@ function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler if (!empty($reg[2])) { if (is_numeric($reg[2])) { // This is a version $versionrequest = explode('.', $reg[2]); - //var_dump($versionrequest); - //var_dump($versionarray); if (!count($versionrequest) || !count($versionarray) || versioncompare($versionrequest, $versionarray) > 0) { $qualified = 0; } } else { // This is a test on a constant. For example when we have -- VMYSQLUTF8UNICODE, we test constant $conf->global->UTF8UNICODE $dbcollation = strtoupper(preg_replace('/_/', '', $conf->db->dolibarr_main_db_collation)); - //var_dump($reg[2]); - //var_dump($dbcollation); if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) { $qualified = 0; } - //var_dump($qualified); } } } @@ -239,7 +234,7 @@ function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler if ($qualified) { // Version qualified, delete SQL comments $buf = preg_replace('/^--\sV(MYSQL|PGSQL)([^\s]*)/i', '', $buf); - //print "Ligne $i qualifi?e par version: ".$buf.'
'; + //print "Line $i qualified by version: ".$buf.'
'; } } diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index d312df286ea..217f949fcd0 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -1,7 +1,7 @@ * Copyright (C) 2024 MDW - * Copyright (C) 2024-2025 Frédéric France + * Copyright (C) 2024-2026 Frédéric France * * 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 @@ -86,9 +86,12 @@ function categories_prepare_head(Categorie $object, $type) */ function categoriesadmin_prepare_head() { - global $langs, $conf, $user, $db; + global $langs, $conf, $extrafields, $db; - $extrafields = new ExtraFields($db); + if (!is_object($extrafields)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($db); + } $extrafields->fetch_name_optionals_label('categorie'); $langs->load("categories"); @@ -110,6 +113,18 @@ function categoriesadmin_prepare_head() $head[$h][2] = 'attributes_categories'; $h++; + // Multilangs Extrafields + if (getDolGlobalInt('MAIN_MULTILANGS')) { + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/categories/admin/categorie_lang_extrafields.php'); + $head[$h][1] = $langs->trans("CategoriesTranslationsExtrafields"); + $nbExtrafields = isset($extrafields->attributes['categorie_lang']['count']) ? $extrafields->attributes['categorie_lang']['count'] : 0; + if ($nbExtrafields > 0) { + $head[$h][1] .= ''.$nbExtrafields.''; + } + $head[$h][2] = 'translationAttributes'; + $h++; + } + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 4b88f97a56e..2997ad591de 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -1019,6 +1019,7 @@ if (!empty($object->thirdparty)) { if (isNaN(pbq)) { console.log("We use experimental option PRODUIT_CUSTOMER_PRICES_BY_QTY or PRODUIT_CUSTOMER_PRICES_BY_QTY but we could not get the id of pbq from product combo list, so load of price may be 0 if product has different prices"); } } + let idProdFournPrice = $(this).val(); // Get the price for the product and display it console.log("Load unit price and set it into #price_ht or #price_ttc for product id="+$(this).val()+" socid=" + jsConf.docObject.socid); $.post(jsConf.url.fetchProductUrl, @@ -1145,6 +1146,11 @@ if (!empty($object->thirdparty)) { jQuery('div[class*="det'+key.replace('options_','_extras_')+'"] > #'+key).val(value); }); } + + // Execute js context Dolibarr Hooks + if (typeof Dolibarr != 'undefined') { + Dolibarr.executeHook('objectLineCreate:LoadUnitPrice', {idProdFournPrice, 'socid': jsConf.docObject.socid,ajaxResultData : data, jsConf}); + } }, 'json' ); @@ -1157,10 +1163,11 @@ if (!empty($object->thirdparty)) { $("#fournprice_predef").find("option").remove(); $("#fournprice_predef").hide(); $("#buying_price").val("").show(); + let idProd = $(this).val(); /* Call post to load content of combo list fournprice_predef */ var token = jsConf.conf.token; // For AJAX Call we use old 'token' and not 'newtoken' - $.post(jsConf.url.getSupplierPrices, { 'idprod': $(this).val(), 'token': token }, function(data) { + $.post(jsConf.url.getSupplierPrices, { 'idprod': idProd, 'token': token }, function(data) { if (data && data.length > 0) { var options = ''; var defaultkey = ''; var defaultprice = ''; var bestpricefound = 0; @@ -1248,6 +1255,12 @@ if (!empty($object->thirdparty)) { $('#buying_price').hide(); } }); + + + // Execute js context Dolibarr Hooks + if (typeof Dolibarr != 'undefined') { + Dolibarr.executeHook('objectLineCreate:GetSupplierPrices', {'idprod': idProd, ajaxResultData : data, jsConf}); + } } }, 'json'); @@ -1283,6 +1296,11 @@ if (!empty($object->thirdparty)) { jQuery("#remise_percent").val(pbqpercent); } } else { jQuery("#pbq").val(''); } + + // Execute js context Dolibarr Hooks + if (typeof Dolibarr != 'undefined') { + Dolibarr.executeHook('objectLineCreate:CustomerPriceByQty', { pbq, pbqup, pbqbase, pbqqty, pbqpercent }); + } } // Deal with supplier ref price (idprodfournprice = int) @@ -1397,7 +1415,6 @@ if (!empty($object->thirdparty)) { jQuery('#dp_desc').text(description); } } - } else if (jQuery('#idprodfournprice').length > 0) { console.log("objectline_create.tpl #idprodfournprice is not an int but is a string so we set only few properties into page"); @@ -1465,6 +1482,10 @@ if (!empty($object->thirdparty)) { setforpredef(); } + // Execute js context Dolibarr Hooks + if (typeof Dolibarr != 'undefined') { + Dolibarr.executeHook('objectLineCreate:ProductSelectionChange'); + } }); /* Function to set fields visibility after selecting a free product */ diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index f5e1c300c12..5985c78bf57 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -11,7 +11,7 @@ * Copyright (C) 2015-2016 Ferran Marcet * Copyright (C) 2017 Josep Lluís Amador * Copyright (C) 2018-2022 Charlene Benke - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2026 Frédéric France * Copyright (C) 2019-2026 Alexandre Spangaro * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2023 Joachim Kueter @@ -39,6 +39,16 @@ // Load Dolibarr environment require '../../main.inc.php'; +/** + * @var Conf $conf + * @var DoliDB $db + * @var ExtraFields $extrafields + * @var HookManager $hookmanager + * @var Societe $mysoc + * @var Translate $langs + * @var User $user + */ + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -50,15 +60,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; -/** - * @var Conf $conf - * @var DoliDB $db - * @var HookManager $hookmanager - * @var Societe $mysoc - * @var Translate $langs - * @var User $user - */ - // Load translation files required by the page $langs->loadLangs(array('products', 'bills', 'companies', 'projects', 'banks')); @@ -177,7 +178,6 @@ $now = dol_now(); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new FactureFournisseur($db); $hookmanager->initHooks(array('supplierinvoicelist')); -$extrafields = new ExtraFields($db); $diroutputmassaction = getMultidirTemp($object).'/massgeneration/'.$user->id; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 0eebc8b7244..062829a0db9 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -393,6 +393,14 @@ ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE=Activate the management of VAT revers ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC=When this option is enabled, you can define that a supplier or a given vendor invoice must be transferred into accountancy differently: A additional debit and a credit line will generated into the accounting on 2 given accounts from the chart of account defined into the "%s" setup page. ACCOUNTING_ENABLE_TABONTHIRDPARTY=Activate a tab on third-party cards to view the subsidiary ledger ACCOUNTING_ENABLE_TABONTHIRDPARTY_DESC=When this option is enabled, a new tab is showing in third-party cards to view and manage accounting for the third-party as to reconcile, print & more +AccountingDefaultNotExportLettering=By default, do not export lettering when generating the file +AccountingDefaultNotExportLetteringDesc=If enabled, the lettering information of accounting entries will not be included in the generated export file. +AccountingDefaultNotNotifiedExportDate=By default, mark not yet exported lines as "Exported" +AccountingDefaultNotNotifiedExportDateDesc=If enabled, each exported line will be stamped with the export date. To modify a line marked as exported, you will need to delete the entire accounting entry and re-transfer it to accounting. +AccountingDefaultNotifiedValidationDate=By default, validate and lock exported accounting entries +AccountingDefaultNotifiedValidationDateDesc=If enabled, exported accounting entries will be automatically validated and locked (same effect as the "Close" feature). Editing and deletion of these lines will be PERMANENTLY impossible. +AccountingDefaultNotifiedExportFull=By default, export source documents (Available only on some export models Quadra | FEC | FEC2) +AccountingDefaultNotifiedExportFullDesc=If enabled, source documents associated with accounting entries (invoices, credit notes, etc.) will be included or attached when generating the export file. ## Template MenuListBookkeepingTemplates=Bookkeeping templates BookkeepingTemplates=Bookkeeping templates diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 48fb8d21421..d619c8904d1 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -107,3 +107,4 @@ CategorieListOfType=Categories (or tags) can be used to categorize the objects m NumberOfCategories=Number of tags/categories MyTag=My tag BackToCategoryTypes=Back to types of category +CategoriesTranslationsExtrafields=Categorie translation attributes extrafields diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 9ff9bf0189c..a98519c895e 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -467,3 +467,4 @@ ProductType=Type of product UseBarCodeForProducts=Use barcode for products UseBarCodeForThirdParties=Use barcode for third parties NotSupportedOnKits=Not supported on kits +ProductLangExtrafieldsSetup=Product translations Extrafields diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 809aff66916..e1fdcd3a557 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -13,7 +13,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2020 Demarest Maxime * Copyright (C) 2020-2024 Charlene Benke - * Copyright (C) 2021-2025 Frédéric France + * Copyright (C) 2021-2026 Frédéric France * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2023 Joachim Küter * Copyright (C) 2023 Eric Seigne @@ -146,12 +146,13 @@ if (!defined('NOSESSION')) { } -// Init the 6 global objects, this include will make the 'new Xxx()' and set properties for: $conf, $db, $langs, $user, $mysoc, $hookmanager +// Init the 7 global objects, this include will make the 'new Xxx()' and set properties for: $conf, $db, $langs, $user, $mysoc, $hookmanager, $extrafields require_once 'master.inc.php'; /** * The master.inc.php has been included so the following variable are now defined: * @var Conf $conf * @var ?DoliDB $db May be null if NOREQUIREDB is defined + * @var ?ExtraFields $extrafields May be null if NOREQUIREDB is defined * @var ?HookManager $hookmanager May be null if NOHOOKMANAGER is defined * @var ?Translate $langs May be null if NOREQUIRETRAN is defined * @var ?User $user May be null if NOREQUIREUSER is defined diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 222538416be..80ad932eac6 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -11,7 +11,7 @@ * Copyright (C) 2011 Philippe Grand * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2024-2025 MDW - * Copyright (C) 2025 Frédéric France + * Copyright (C) 2025-2026 Frédéric France * * 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 @@ -272,6 +272,13 @@ if (!defined('NOREQUIREUSER')) { if (!defined('NOHOOKMANAGER')) { $hookmanager = new HookManager($db); } +/* + * Create $extrafields object + */ +if ($db !== null) { + require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($db); +} /* diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 8a8ac4f64bc..f8028c55fc6 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -16,7 +16,7 @@ * Copyright (C) 2016-2022 Charlene Benke * Copyright (C) 2016 Meziane Sof * Copyright (C) 2017 Josep Lluís Amador - * Copyright (C) 2019-2025 Frédéric France + * Copyright (C) 2019-2026 Frédéric France * Copyright (C) 2019-2020 Thibault FOUCART * Copyright (C) 2020 Pierre Ardoin * Copyright (C) 2022 Vincent de Grandpré @@ -46,8 +46,16 @@ // Load Dolibarr environment require '../main.inc.php'; +/** + * @var Conf $conf + * @var DoliDB $db + * @var ExtraFields $extrafields + * @var HookManager $hookmanager + * @var Societe $mysoc + * @var Translate $langs + * @var User $user + */ require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -57,14 +65,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.class.php' require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -/** - * @var Conf $conf - * @var DoliDB $db - * @var HookManager $hookmanager - * @var Societe $mysoc - * @var Translate $langs - * @var User $user - */ if (isModEnabled('propal')) { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; } @@ -157,7 +157,6 @@ if ($result > 0) { $object = new Product($db); $object->type = $type; // so test later to fill $usercancxxx is correct -$extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 6b5207a52f5..4d46b09d4bc 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -44,6 +44,7 @@ require '../main.inc.php'; /** * @var Conf $conf * @var DoliDB $db + * @var ExtraFields $extrafields * @var HookManager $hookmanager * @var Societe $mysoc * @var Translate $langs @@ -187,7 +188,6 @@ if ((string) $type == '0') { // Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array of hooks $object = new Product($db); $hookmanager->initHooks(array('productservicelist')); -$extrafields = new ExtraFields($db); $form = new Form($db); $formcompany = new FormCompany($db); $formproduct = new FormProduct($db); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 04a154aadc2..2fccc12e21e 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -5,6 +5,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry * Copyright (C) 2024 Frédéric France + * Copyright (C) 2026 Jon Bendtsen * * 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 @@ -32,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; /** * @var Conf $conf @@ -130,8 +132,29 @@ $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product /* - * View + * Actions */ +$toselect = GETPOST('toselect', 'array:int'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'invoicelist'; +$massaction = GETPOST('massaction', 'alpha'); +$diroutputmassaction = $conf->invoice->dir_output.'/temp/massgeneration/'.$user->id; + +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} +$arrayfields = array( + 'f.ref' => array('label' => "Ref", 'checked' => '1', 'position' => 5), + 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 50), + 's.code_client' => array('label' => "CustomerCodeShort", 'checked' => '-1', 'position' => 52), + 'f.datef' => array('label' => "DateInvoice", 'checked' => '1', 'position' => 60), + 'd.qty' => array('label' => "Qty", 'checked' => '1', 'position' => 65), + 'd.total_ht' => array('label' => "AmountHT", 'checked' => '1', 'position' => 70), + 'f.fk_statut' => array('label' => "Status", 'checked' => '1', 'position' => 1000), +); $invoicestatic = new Facture($db); $societestatic = new Societe($db); @@ -139,6 +162,75 @@ $societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); + + +$arrayofmassactions = array( + 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), +); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); +$arrayofselected = is_array($toselect) ? $toselect : array(); +$selectedfields = (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + + +$totalarray = array(); +$totalarray['nbfield'] = 0; + +$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} +if (empty($reshook)) { + $objectclass = 'Facture'; + $objectlabel = 'Invoices'; + $permissiontoread = $user->hasRight("facture", "lire"); + $permissiontoadd = $user->hasRight("facture", "creer"); + $permissiontodelete = $user->hasRight("facture", "supprimer"); + $uploaddir = $conf->invoice->dir_output; + + if (isset($_POST['massaction'])) { + $massaction = $_POST['massaction']; + } + + if (isset($_POST['confirmmassaction']) && isset($_POST['massaction']) && $_POST['massaction'] == 'presend') { + global $arrayofselected; + + $toselect = is_array($_POST['toselect']) ? $_POST['toselect'] : array(); + $arrayofselected = array(); + + // Store only VALID IDs (those with emails) + foreach ($toselect as $invoice_id) { + $objecttmp = new Facture($db); + if ($objecttmp->fetch((int) $invoice_id) > 0) { + // Force loading the thirdparty object + if (empty($objecttmp->thirdparty) || !is_object($objecttmp->thirdparty)) { + $objecttmp->fetch_thirdparty(); + } + + // Only add to array if email exists + if (!empty($objecttmp->thirdparty->email)) { + // Store just the ID, not the object + $arrayofselected[] = $invoice_id; + } + } + } + + if (empty($arrayofselected)) { + setEventMessages($langs->trans("DefaultStatusEmptyMandatory").' '.$langs->trans("Select"), null, 'errors'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + } else { + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + } +} + +/* + * View + */ + + + if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -287,6 +379,14 @@ if ($id > 0 || !empty($ref)) { $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); + // I am saving the result here, because some hooks a little later will change $result such that I can not get the contents + $all_rows = array(); + $num = $db->num_rows($result); + while ($row = $db->fetch_object($result)) { + $all_rows[] = $row; + } + $db->free($result); // Free immediately + $result = null; // Clear the variable $option .= '&id='.$product->id; @@ -297,6 +397,8 @@ if ($id > 0 || !empty($ref)) { // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Add $param from hooks + '@phan-var-force string $param'; + /** @var string $param */ $parameters = array('param' => &$param); $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $option .= $hookmanager->resPrint; @@ -311,7 +413,17 @@ if ($id > 0 || !empty($ref)) { } // @phan-suppress-next-line PhanPluginSuspiciousParamOrder - print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, $massactionbutton, $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if ($massaction == 'presend' && !empty($arrayofselected)) { + // Set variables expected by the template + $topicmail = "SendBillRef"; + $modelmail = "facture_send"; + $objecttmp = new Facture($db); + $trackid = 'inv'.$id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + } if (!empty($page)) { $option .= '&page='.urlencode((string) ($page)); @@ -337,6 +449,8 @@ if ($id > 0 || !empty($ref)) { print '
'; print '
'.($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
'.($s ? $s.' ' : '').' '.$langs->trans('Language_'.$key).': $object->id, 'action' => 'delete', 'langtodelete' => $key, 'type' => $type], true).'">'.img_delete('', '').'
'.$langs->trans('Label').''.($object->multilangs[$key]["label"] ?? '').'
'.$langs->trans('Description').''.($object->multilangs[$key]["description"] ?? '').'
'; print ''; + // Action column + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); @@ -352,8 +466,7 @@ if ($id > 0 || !empty($ref)) { if ($num > 0) { while ($i < min($num, $limit)) { - $objp = $db->fetch_object($result); - + $objp = $all_rows[$i]; if ($objp->type == Facture::TYPE_CREDIT_NOTE) { $objp->qty = -($objp->qty); } @@ -366,7 +479,24 @@ if ($id > 0 || !empty($ref)) { $societestatic->fetch($objp->socid); $paiement = $invoicestatic->getSommePaiement(); - print ''; + print ''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + print '\n"; @@ -401,7 +531,6 @@ if ($id > 0 || !empty($ref)) { } else { dol_print_error($db); } - $db->free($result); } } } else { diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 1a60d29b5c6..d5465236bfc 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -250,25 +250,27 @@ if (empty($reshook)) { $error++; } - $result = $object->create($user); - if (!$error && $result > 0) { - // Add myself as Owner Contact Selected in the form - $typeofcontact = GETPOST('typeofcontact'); - $result = $object->add_contact($user->id, $typeofcontact, 'internal'); + if (!$error) { + $result = $object->create($user); + if ($result > 0) { + // Add myself as Owner Contact Selected in the form + $typeofcontact = GETPOST('typeofcontact'); + $result = $object->add_contact($user->id, $typeofcontact, 'internal'); - // -3 means type not found (renamed, de-activated or deleted), so don't prevent creation if it has been the case - if ($result == -3) { - setEventMessage('ErrorPROJECTLEADERRoleMissingRestoreIt', 'errors'); - $error++; - } elseif ($result < 0) { + // -3 means type not found (renamed, de-activated or deleted), so don't prevent creation if it has been the case + if ($result == -3) { + setEventMessage('ErrorPROJECTLEADERRoleMissingRestoreIt', 'errors'); + $error++; + } elseif ($result < 0) { + $langs->load("errors"); + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } else { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; } - } else { - $langs->load("errors"); - setEventMessages($object->error, $object->errors, 'errors'); - $error++; } if (!$error && !empty($object->id) > 0) { // Category association diff --git a/htdocs/quickmemo/admin/memo_extrafields.php b/htdocs/quickmemo/admin/memo_extrafields.php index 6fd8da713e3..fe7b14f838e 100644 --- a/htdocs/quickmemo/admin/memo_extrafields.php +++ b/htdocs/quickmemo/admin/memo_extrafields.php @@ -5,7 +5,7 @@ * Copyright (C) 2012 Regis Houssin * Copyright (C) 2014 Florian Henry * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2026 Frédéric France * * 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 @@ -33,6 +33,7 @@ require '../../main.inc.php'; /** * @var Conf $conf * @var DoliDB $db + * @var ExtraFields $extrafields * @var HookManager $hookmanager * @var Translate $langs * @var User $user @@ -43,7 +44,6 @@ require_once '../lib/quickmemo.lib.php'; // Load translation files required by the page $langs->loadLangs(array('quickmemo', 'admin')); -$extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format diff --git a/htdocs/quickmemo/memo_list.php b/htdocs/quickmemo/memo_list.php index 648dd3de952..054cab562cb 100644 --- a/htdocs/quickmemo/memo_list.php +++ b/htdocs/quickmemo/memo_list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2026 Frédéric France * Copyright (C) 2026 John BOTELLA * * This program is free software; you can redistribute it and/or modify @@ -23,34 +23,13 @@ * \brief List page for memo */ -// General defined Options -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value -//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too. -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) - - // Load Dolibarr environment require '../main.inc.php'; /** * The main.inc.php has been included so the following variable are now defined: * @var Conf $conf * @var DoliDB $db + * @var ExtraFields $extrafields * @var HookManager $hookmanager * @var Translate $langs * @var User $user @@ -97,13 +76,11 @@ $pagenext = $page + 1; // Initialize technical objects $object = new Memo($db); -$extrafields = new ExtraFields($db); $diroutputmassaction = $conf->quickmemo->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -//$extrafields->fetch_name_optionals_label($object->table_element_line); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -512,21 +489,6 @@ if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $sear llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-quickmemo page-list bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for a horizontal scroll in the table instead of page -// Example : Adding jquery code -// print ''; - $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 507b28494fd..2aa0c822092 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -517,7 +517,7 @@ class Users extends DolibarrApi */ public function setPassword($id, $send_password = false) { - if (!getDolGlobalString('API_ENABLE_LOGIN_API')) { + if (!getDolGlobalInt('API_ENABLE_LOGIN_API')) { throw new RestException(403, "Error: login and password reset APIs are disabled. You can get access token from the backoffice to get access permission but permission and password manipulation from APIs are forbidden."); }
'; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($invoicestatic->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; print $invoicestatic->getNomUrl(1); print "