Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2026-04-20 22:20:29 +02:00
commit 351531c10c
30 changed files with 606 additions and 185 deletions

View file

@ -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 '</td></tr>';
}
print "</table>\n";
}
print '<tr class="oddeven">';
print '<td>';
print $form->textwithpicto($langs->trans("AccountingDefaultNotExportLettering"), $langs->trans("AccountingDefaultNotExportLetteringDesc")) . '</td>';
if (getDolGlobalInt('ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING')) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setexportenablelettering&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setexportenablelettering&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr class="oddeven">';
print '<td>';
print $form->textwithpicto($langs->trans("AccountingDefaultNotNotifiedExportDate"), $langs->trans("AccountingDefaultNotNotifiedExportDateDesc")) . '</td>';
if (getDolGlobalInt('ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE')) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setexportenableexportdate&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setexportenableexportdate&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr class="oddeven">';
print '<td>';
print $form->textwithpicto($langs->trans("AccountingDefaultNotifiedValidationDate"), $langs->trans("AccountingDefaultNotifiedValidationDateDesc")) . '</td>';
if (getDolGlobalInt('ACCOUNTING_DEFAULT_NOTIFIED_VALIDATION_DATE')) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setexportenablevalidationdate&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setexportenablevalidationdate&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr class="oddeven">';
print '<td>';
print $form->textwithpicto($langs->trans("AccountingDefaultNotifiedExportFull"), $langs->trans("AccountingDefaultNotifiedExportFullDesc")) . '</td>';
if (getDolGlobalInt('ACCOUNTING_DEFAULT_NOTIFIED_EXPORTFULL')) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setexportenablefull&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setexportenablefull&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print "</table>\n";
print '<div class="center"><input type="submit" class="button reposition" value="'.dol_escape_htmltag($langs->trans('Save')).'" name="button"></div>';
print '</form>';

View file

@ -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) ? '' : ' <spanc class="opacitymedium">('.$langs->trans("except").' '.implode(', ', $except).')</span>'),
'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
}
}

View file

@ -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.')
)
);

View file

@ -3,7 +3,7 @@
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
*
* 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

View file

@ -0,0 +1,128 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \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 = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
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 '<div class="tabsAction">';
print '<a class="butAction reposition" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a>';
print "</div>";
}
/*
* Creation of an optional field
*/
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
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 "<br>";
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();

View file

@ -5,7 +5,7 @@
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2020-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025-2026 MDW <mdeweerd@users.noreply.github.com>
*
* 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

View file

@ -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)) {

View file

@ -3,7 +3,7 @@
* Copyright (C) 2006-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2020-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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;

View file

@ -161,12 +161,18 @@ if ($object->id) {
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
// Description
// Label
print '<tr><td class="titlefield notopnoleft">';
print $langs->trans("Description").'</td><td>';
print dol_htmlentitiesbr($object->description);
print $langs->trans("Label").'</td><td>';
print dol_htmlentitiesbr($object->label);
print '</td></tr>';
// Description
// print '<tr><td class="titlefield notopnoleft">';
// print $langs->trans("Description").'</td><td>';
// print dol_htmlentitiesbr($object->description);
// print '</td></tr>';
// Color
print '<tr><td class="notopnoleft">';
print $langs->trans("Color").'</td><td>';

View file

@ -3,7 +3,7 @@
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010-2016 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
// Description
// Label
print '<tr><td class="titlefield notopnoleft">';
print $langs->trans("Description").'</td><td>';
print dol_htmlentitiesbr($object->description);
print $langs->trans("Label").'</td><td>';
print dol_htmlentitiesbr($object->label);
print '</td></tr>';
// Description
// print '<tr><td class="titlefield notopnoleft">';
// print $langs->trans("Description").'</td><td>';
// print dol_htmlentitiesbr($object->description);
// print '</td></tr>';
// Color
print '<tr><td class="notopnoleft">';
print $langs->trans("Color").'</td><td>';
@ -249,18 +268,19 @@ print '</div>';
print dol_get_fiche_end();
/*
* Action bar
*/
print "\n<div class=\"tabsAction\">\n";
if ($action == '') {
if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=add&token='.newToken().'&id='.$object->id.'&type='.$type.'">'.$langs->trans('Add').'</a>';
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
if (empty($reshook)) {
if ($action == '' && $permissiontoadd) {
print '<a class="butAction" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'add', 'id' => $object->id, 'type' => $type], true).'">'.$langs->trans('Add').'</a>';
if ($cnt_trans > 0) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$object->id.'&type='.$type.'">'.$langs->trans('Update').'</a>';
print '<a class="butAction" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'edit', 'id' => $object->id, 'type' => $type], true).'">'.$langs->trans('Update').'</a>';
}
}
}
@ -268,7 +288,6 @@ if ($action == '') {
print "\n</div>\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 "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>";
$s = picto_from_langcode((string) $key);
print '<br><b><u>'.($s ? $s.' ' : '').'<b>'.$langs->trans('Language_'.$key).':</b> ' . $langs->trans('Language_'.$key).' :</u></b><br>';
print '<table class="border centpercent">';
// Label
@ -314,7 +334,7 @@ if ($action == 'edit') {
foreach ($object->multilangs as $key => $value) {
$s = picto_from_langcode((string) $key);
print '<table class="border centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'&type='.$type.'">'.img_delete('', '').'</a></td></tr>';
print '<tr class="liste_titre"><td colspan="2">'.($s ? $s.' ' : '').' <b>'.$langs->trans('Language_'.$key).':</b> <a href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'delete', 'langtodelete' => $key, 'type' => $type], true).'">'.img_delete('', '').'</a></td></tr>';
print '<tr><td class="titlefield">'.$langs->trans('Label').'</td><td>'.($object->multilangs[$key]["label"] ?? '').'</td></tr>';
print '<tr><td>'.$langs->trans('Description').'</td><td>'.($object->multilangs[$key]["description"] ?? '').'</td></tr>';
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 '<br>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<form action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="vadd">';
print '<input type="hidden" name="id" value="'.$id.'">';

View file

@ -8,7 +8,7 @@
* Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2022-2023 Solution Libre SAS <contact@solution-libre.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2023-2024 Charlene Benke <charlene@patas-monkey.com>
*
@ -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);
/*

View file

@ -6,7 +6,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2017-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2023 Nick Fragoulis
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
*

View file

@ -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);

View file

@ -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.'<br>';
//print "Line $i qualified by version: ".$buf.'<br>';
}
}

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
*
* 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] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
}
$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

View file

@ -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 */

View file

@ -11,7 +11,7 @@
* Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2018-2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2023 Nick Fragoulis
* Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
@ -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;

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -13,7 +13,7 @@
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2020 Demarest Maxime <maxime@indelog.fr>
* Copyright (C) 2020-2024 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2021-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2021-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2023 Joachim Küter <git-jk@bloxera.com>
* Copyright (C) 2023 Eric Seigne <eric.seigne@cap-rel.fr>
@ -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

View file

@ -11,7 +11,7 @@
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025-2026 Frédéric France <frederic.france@free.fr>
*
* 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);
}
/*

View file

@ -16,7 +16,7 @@
* Copyright (C) 2016-2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
* Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2019-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019-2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
* Copyright (C) 2022 Vincent de Grandpré <vincent@de-grandpre.quebec>
@ -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);

View file

@ -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);

View file

@ -5,6 +5,7 @@
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 Jon Bendtsen <jon.bendtsen.github@jonb.dk>
*
* 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 '<div class="div-table-responsive">';
print '<table class="tagtable liste listwithfilterbefore" width="100%">';
print '<tr class="liste_titre">';
// 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 '<tr class="oddeven">';
print '<tr data-row-id="'.$invoicestatic->id.'" class="oddeven row-with-select status2">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="nowrap center">';
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 '<input id="cb'.$invoicestatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$invoicestatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
print '<td>';
print $invoicestatic->getNomUrl(1);
print "</td>\n";
@ -401,7 +531,6 @@ if ($id > 0 || !empty($ref)) {
} else {
dol_print_error($db);
}
$db->free($result);
}
}
} else {

View file

@ -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

View file

@ -5,7 +5,7 @@
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
*
* 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

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
* 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 '<script type="text/javascript">
// jQuery(document).ready(function() {
// function init_myfunc()
// {
// jQuery("#myid").removeAttr(\'disabled\');
// jQuery("#myid").attr(\'disabled\',\'disabled\');
// }
// init_myfunc();
// jQuery("#mybutton").click(function() {
// init_myfunc();
// });
// });
// </script>';
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';

View file

@ -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.");
}