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

This commit is contained in:
Laurent Destailleur 2025-11-03 14:27:58 +01:00
commit 74cc41c460
30 changed files with 247 additions and 123 deletions

View file

@ -8,7 +8,7 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2017 Laurent Destailleur <eldy@destailleur.fr>
* Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 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
@ -69,7 +69,6 @@ $formSetup = new FormSetup($db);
// Main options
$formSetup->newItem('BANK_DISABLE_DIRECT_INPUT')->setAsYesNo();
$formSetup->newItem('ACCOUNTANCY_COMBO_FOR_AUX')->setAsYesNo();
$item = $formSetup->newItem('ACCOUNTING_MANAGE_ZERO')->setAsYesNo();
@ -177,20 +176,27 @@ if ($action == 'updatemode') {
}
}
if ($action == 'update2') {
if ($action == 'update') {
$error = 0;
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if ($error) {
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
if ($action == 'update_binding') {
$error = 0;
// option in section binding
foreach ($list_binding as $constname) {
$constvalue = GETPOST($constname, 'alpha');
@ -203,16 +209,41 @@ if ($action == 'update2') {
}
}
// options in section other
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
if ($action == 'update_advanced') {
$error = 0;
if (GETPOSTISSET('ACCOUNTING_LETTERING_NBLETTERS')) {
if (!dolibarr_set_const($db, 'ACCOUNTING_LETTERING_NBLETTERS', GETPOST('ACCOUNTING_LETTERING_NBLETTERS'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
if ($action == 'update_export') {
$error = 0;
// Export options
$modelcsv = GETPOSTINT('ACCOUNTING_EXPORT_MODELCSV');
if (!$error) {
// reload
$configuration = $accountancyexport->getTypeConfig();
$listparam = $configuration['param'];
}
if (!empty($modelcsv)) {
if (!dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
$error++;
@ -243,12 +274,6 @@ if ($action == 'update2') {
}
}
if (!$error) {
// reload
$configuration = $accountancyexport->getTypeConfig();
$listparam = $configuration['param'];
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -483,20 +508,19 @@ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) {
print '</form>';
print '<br><br><br>';
print '<br><br>';
}
// Show form for main parameters
// Show form main options
print $formSetup->generateOutput(true);
print '<br><br><br>';
print '<br><br>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update2">';
print '<input type="hidden" name="action" value="update_binding">';
print '<input type="hidden" name="page_y" value="">';
// Binding params
@ -631,12 +655,11 @@ print '</tr>';
print '</table>';
print '</div>';
print '<div class="center"><input type="submit" class="button reposition" value="'.dol_escape_htmltag($langs->trans('Save')).'" name="button"></div>';
print '<div class="center"><input type="submit" class="button button-edit reposition" name="button" value="'.dol_escape_htmltag($langs->trans('Save')).'"></div>';
print '</form>';
// Show numbering options
print '<br><br><br>';
print '<br><br>';
// Accountancy Numbering model
$dirmodels = array_merge(array('/'), $conf->modules_parts['models']);
@ -751,13 +774,12 @@ print '</div>';
print '</form>';
// Show advanced options
print '<br><br><br>';
print '<br><br>';
// Advanced params
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update2">';
print '<input type="hidden" name="action" value="update_advanced">';
print '<input type="hidden" name="page_y" value="">';
print '<div class="div-table-responsive-no-min">';
@ -847,12 +869,17 @@ print '</div>';
print '<div class="center"><input type="submit" class="button button-edit reposition" name="button" value="'.$langs->trans('Save').'"></div>';
print '</form>';
print '<br><br><br>';
print '<br><br>';
// Export options
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update_export">';
print '<input type="hidden" name="page_y" value="">';
print "\n".'<script type="text/javascript">'."\n";
print 'jQuery(document).ready(function () {'."\n";
@ -898,8 +925,6 @@ print ' });'."\n";
print '})'."\n";
print '</script>'."\n";
// Main Options
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans('ExportOptions').'</td>';
@ -961,7 +986,6 @@ if ($num2) {
print '<div class="center"><input type="submit" class="button reposition" value="'.dol_escape_htmltag($langs->trans('Save')).'" name="button"></div>';
print '</form>';
// End of page

View file

@ -451,44 +451,14 @@ if (empty($reshook)) {
}
}
if ($action == 'clonebookkeepingwriting' && $permissiontoadd) {
if ($action == 'clonebookkeepingwriting' && $confirm == "yes" && $permissiontoadd) {
// Reread the values sent by the validated form
$piece_num = GETPOST('piece_num', 'alpha');
$formaccounting = new FormAccounting($db);
$journal_code = GETPOST('code_journal', 'alpha');
$form = new Form($db);
$input1 = $form->selectDate('', 'clonedate', 0, 0, 0, "create_mvt", 1, 1);
$input2 = $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1).'</td>';
$inputHidden = '<input type="hidden" name="piece_num_hidden" id="piece_num_hidden" value="'.$piece_num.'">';
// Reconstruct the selected date
$clonedate = dol_mktime(0, 0, 0, GETPOSTINT('clonedatemonth'), GETPOSTINT('clonedateday'), GETPOSTINT('clonedateyear'));
$formquestion = array(
array(
'type' => 'date',
'name' => 'clonedate',
'label' => '<span class="fieldrequired">' . $langs->trans("Docdate") . '</span>',
'value' => $input1
)
);
if (getDolGlobalString('ACCOUNTING_CLONING_ENABLE_INPUT_JOURNAL')) {
$formquestion[] = array(
'type' => 'text',
'name' => 'code_journal',
'label' => '<span class="fieldrequired">' . $langs->trans("Codejournal") . '</span>',
'value' => $input2
);
}
print $form->formconfirm(
$_SERVER["PHP_SELF"],
$langs->trans("ConfirmMassCloneBookkeepingWriting"),
$langs->trans("ConfirmMassCloneBookkeepingWritingQuestion", count($toselect)),
"clonebookkeepingwriting",
$formquestion,
'', 0, 300, 1000, 1
);
}
if ($action == 'preclonebookkeepingwriting' && $confirm == "yes" && $permissiontoadd) {
$result = $object->newClone($piece_num, $journal_code, $clonedate);
if ($result == -1) {
@ -497,7 +467,7 @@ if (empty($reshook)) {
if (!$error) {
$db->commit();
header("Location: " . $_SERVER['PHP_SELF'] . "?piece_num=" . $object->getNextNumMvt() - 1);
header("Location: " . $_SERVER['PHP_SELF'] . "?piece_num=" . ($object->getNextNumMvt() - 1));
exit();
} else {
$db->rollback();
@ -635,6 +605,7 @@ if ($action == 'create') {
}*/
$head = accounting_transaction_prepare_head($object, $mode, $type, $backtopage);
print dol_get_fiche_head($head, 'transaction', '', -1);
//$object->label = $object->doc_ref;
@ -651,6 +622,46 @@ if ($action == 'create') {
dol_banner_tab($object, 'ref', $backlink, 1, 'piece_num', 'piece_num', $morehtmlref);
if ($action == 'clonebookkeepingwriting' && $confirm != 'yes' && $permissiontoadd) {
$piece_num = GETPOST('piece_num', 'alpha');
$formaccounting = new FormAccounting($db);
$form = new Form($db);
$input1 = $form->selectDate('', 'clonedate', 0, 0, 0, "", 1, 1);
$input2 = $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1);
$formquestion = array(
array(
'type' => 'other',
'name' => 'clonedate',
'label' => '<span class="fieldrequired">' . $langs->trans("Docdate") . '</span>',
'value' => $input1
)
);
$formquestion[] = array('type' => 'hidden', 'name' => 'piece_num', 'value' => $piece_num);
if (getDolGlobalString('ACCOUNTING_CLONING_ENABLE_INPUT_JOURNAL')) {
$formquestion[] = array(
'type' => 'text',
'name' => 'code_journal',
'label' => '<span class="fieldrequired">' . $langs->trans("Codejournal") . '</span>',
'value' => $input2
);
}
print $form->formconfirm(
$_SERVER["PHP_SELF"],
$langs->trans("ConfirmMassCloneBookkeepingWriting"),
$langs->trans("ConfirmMassCloneBookkeepingWritingQuestion", 1),
"clonebookkeepingwriting",
$formquestion,
'', 0, 300, 1000, 0
);
}
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';

View file

@ -105,6 +105,11 @@ class ExternalModules
*/
public $githubFileError;
/**
* @var string
*/
public $error;
/**
* @var int // number of online providers
*/

View file

@ -255,6 +255,8 @@ if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $
$modulenameforenabled = 'supplier_proposal';
} elseif ($module == 'ficheinter') {
$modulenameforenabled = 'intervention';
} elseif ($module == 'product' && !isModEnabled('product') && isModEnabled('service')) {
$modulenameforenabled = 'service';
}
dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass);

View file

@ -486,17 +486,14 @@ if ($search_status != '') {
$sql .= ' AND c.fk_statut = '.((int) $search_status); // draft, validated, in process or canceled
}
}
if ($search_status == -2) { // To process
if ($search_status == -2) { // "validated + in progress"
//$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
$sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
$sql .= " AND c.fk_statut IN (1,2)";
}
if ($search_status == -3) { // To bill
if ($search_status == -3) { // "validated + in progress + shipped"
//$sql.= ' AND c.fk_statut in (1,2,3)';
//$sql.= ' AND c.facture = 0'; // invoice not created
$sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed
}
if ($search_status == -4) { // "validate and in progress"
$sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process
$sql .= ' AND c.fk_statut IN (1,2,3)'; // validated, in process or closed
}
}
@ -729,9 +726,6 @@ if ($resql) {
if ($search_status == -3) {
$title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('shipping') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill');
}
if ($search_status == -4) {
$title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort");
}
$num = $db->num_rows($resql);

View file

@ -395,6 +395,7 @@ class Invoices extends DolibarrApi
*
* @throws RestException 400
* @throws RestException 401
* @throws RestException 403 Access not allowed for login
* @throws RestException 404
* @throws RestException 405
*/
@ -411,6 +412,9 @@ class Invoices extends DolibarrApi
if (empty($orderid)) {
throw new RestException(400, 'Order ID is mandatory');
}
if (!DolibarrApi::_checkAccessToResource('commande', $orderid)) {
throw new RestException(403, 'Access not allowed on order for login '.DolibarrApiAccess::$user->login);
}
$order = new Commande($this->db);
$result = $order->fetch($orderid);

View file

@ -4226,7 +4226,7 @@ class Facture extends CommonInvoice
if (empty($fk_prev_id)) {
$fk_prev_id = 'null';
}
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent == null) {
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent === null) {
// INVOICE_USE_SITUATION = 2 - Lines situation percent on new lines must be 0 (No cumulative)
if ($this->isSituationInvoice() && getDolGlobalInt('INVOICE_USE_SITUATION') == 2) {
$situation_percent = 0;

View file

@ -868,6 +868,7 @@ while ($i < $imaxinloop) {
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Status
if (!empty($arrayfields['p.statut']['checked'])) {
print '<td class="right">';

View file

@ -3046,8 +3046,9 @@ class Form
$out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
$sql = 'SELECT b.rowid, b.ref, b.label, b.fk_product';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'bom_bom as b';
$sql = 'SELECT b.rowid, b.ref, b.label as bomLabel, p.label as productLabel';
$sql .= ' FROM ' . $this->db->prefix() . 'bom_bom as b';
$sql .= ' INNER JOIN ' . $this->db->prefix() . 'product as p ON b.fk_product = p.rowid';
$sql .= ' WHERE b.entity IN (' . getEntity('bom') . ')';
if (!empty($status)) {
$sql .= ' AND status = ' . (int) $status;
@ -3071,13 +3072,11 @@ class Form
$out .= '>&nbsp;</option>';
}
while ($obj = $db->fetch_object($resql)) {
$product = new Product($db);
$res = $product->fetch($obj->fk_product);
$out .= '<option value="' . $obj->rowid . '"';
if ($obj->rowid == $selected) {
$out .= 'selected';
}
$out .= '>' . $obj->ref . ' - ' . $product->label . ' - ' . $obj->label . '</option>';
$out .= '>' . $obj->ref . ' - ' . $obj->productLabel . ' - ' . $obj->bomLabel . '</option>';
}
} else {
$error++;

View file

@ -917,9 +917,9 @@ class FormSetupItem
$forcereload = empty($this->fieldParams['forcereload']) ? 0 : 1;
$suffixarray = array('ifoff' => empty($this->fieldParams['alertifoff']) ? '' : '_red', 'ifon' => empty($this->fieldParams['alertifon']) ? '' : '_red');
$out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, $suffixarray);
$out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, $suffixarray, '', $this->cssClass);
} else {
$out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1);
$out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1, false, 0, 0, $this->cssClass);
}
} elseif (preg_match('/emailtemplate:/', $this->type)) {
$out .= $this->generateInputFieldEmailTemplate();
@ -1298,7 +1298,7 @@ class FormSetupItem
$revertonoff = empty($this->fieldParams['revertonoff']) ? 0 : 1;
$forcereload = empty($this->fieldParams['forcereload']) ? 0 : 1;
$out .= ajax_constantonoff($this->confKey, array(), $this->entity, $revertonoff, 0, $forcereload);
$out .= ajax_constantonoff($this->confKey, array(), $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, '', '', $this->cssClass); // TODO possibility to add $input parameter
} else {
if ($this->fieldValue == 1) {
$out .= $langs->trans('yes');

View file

@ -668,7 +668,8 @@ class Notify
$application = (preg_match('/^\+/', $applicationcustom) ? $application : '').$applicationcustom;
}
$from = getDolGlobalString('NOTIFICATION_EMAIL_FROM');
$from = getDolGlobalString('NOTIFICATION_EMAIL_FROM', getDolGlobalString('MAIN_MAIL_EMAIL_FROM'));
$object_type = '';
$link = '';
$num = 0;

View file

@ -1585,14 +1585,20 @@ jQuery(document).ready(function() {
// Code to manage the js for combo list with dependencies (called by extrafields_view.tpl.php)
function showOptions(child_list, parent_list) {
var val = $("select[name="+parent_list+"]").val();
var parentVal = parent_list + ":" + val;
if(val > 0) {
$("select[name=\""+child_list+"\"] option[parent]").hide();
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
var parentInput = $("select[name="+parent_list+"]");
if (parentInput.length === 0) { // when parent extra-field is in view mode and the child is edited directly on card (on line edit)
parentInput = $("input[name="+parent_list+"]");
}
if (parentInput.length > 0) {
var val = parentInput.val();
var parentVal = parent_list + ":" + val;
if (val > 0) {
$("select[name=\""+child_list+"\"] option[parent]").prop("disabled", true).hide(); // hide not work with select2 element so disabled it
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").prop('disabled', false).show(); // show not work with select2 element so enabled it
} else {
$("select[name=\""+child_list+"\"] option").show();
$("select[name=\""+child_list+"\"] option").prop("disabled", false).show(); // show not work with select2 element so enabled it
}
}
}
function setListDependencies() {
console.log("setListDependencies");

View file

@ -236,7 +236,7 @@ function societe_prepare_head(Societe $object)
$sql .= " FROM " . MAIN_DB_PREFIX . "societe_rib as n";
$sql .= " WHERE n.fk_soc = " . ((int) $object->id);
if (!isModEnabled('stripe')) {
$sql .= " AND n.stripe_card_ref IS NULL";
$sql .= " AND (n.stripe_card_ref IS NULL OR n.stripe_card_ref ='')";
} else {
$sql .= " AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = " . ((int) $servicestatus) . "))";
}

View file

@ -1075,7 +1075,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sql .= " AND (sc.fk_user = ".((int) $user->id);
if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) {
$userschilds = $user->getAllChildIds();
$sql .= " OR sc.fk_user IN (".$db->sanitize(implode(',', $userschilds)).")";
if (!empty($userschilds)) $sql .= " OR sc.fk_user IN (".$db->sanitize(implode(',', $userschilds)).")";
}
$sql .= ")";
$sql .= " AND sc.fk_soc = s.rowid";
@ -1185,9 +1185,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sql .= " AND (sc.fk_user = ".((int) $user->id);
if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) {
$userschilds = $user->getAllChildIds();
foreach ($userschilds as $key => $value) {
$sql .= ' OR sc.fk_user = '.((int) $value);
}
if (!empty($userschilds)) $sql .= " OR sc.fk_user IN (".$db->sanitize(implode(',', $userschilds)).")";
}
$sql .= ')';
} else {

View file

@ -323,6 +323,7 @@ if (empty($reshook) && !empty($object->table_element) && isset($extrafields->att
//var_dump($tmpkeyextra.'-'.$value.'-'.$object->table_element);
print $extrafields->showOutputField($tmpkeyextra, $value, '', $object->table_element, null, $object);
print '<input type="hidden" value="' . $value . '" name="options_' . $tmpkeyextra . '" id="options_' . $tmpkeyextra . '"/>'; // it's needed when to get parent value when extra-field list depend on parent extra-field list
}
print '</td>';

View file

@ -204,7 +204,7 @@ if (!empty($captcha)) {
}
// List of directories where we can find captcha handlers
$dirModCaptcha = array_merge(array('main' => '/core/modules/security/captcha/'), is_array($conf->modules_parts['captcha']) ? $conf->modules_parts['captcha'] : array());
$dirModCaptcha = array_merge(array('main' => '/core/modules/security/captcha/'), ((isset($conf->modules_parts['captcha']) && is_array($conf->modules_parts['captcha'])) ? $conf->modules_parts['captcha'] : array()));
$fullpathclassfile = '';
foreach ($dirModCaptcha as $dir) {
$fullpathclassfile = dol_buildpath($dir."modCaptcha".ucfirst($captcha).'.class.php', 0, 2);

View file

@ -730,6 +730,11 @@ while ($i < $imaxinloop) {
}
}
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
@ -747,6 +752,7 @@ while ($i < $imaxinloop) {
print '</tr>'."\n";
}
$i++;
}

View file

@ -113,7 +113,7 @@ if (getDolGlobalString('MAIN_MOTD')) {
*/
// Specific warning to propose to upgrade invoice situation to progressive mode
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1 && (float) DOL_VERSION >= 22.0) {
$langs->loadLangs(array("admin"));
print info_admin($langs->trans("WarningExperimentalFeatureInvoiceSituationNeedToUpgradeToProgressiveMode", 'https://partners.dolibarr.org'));
//print "<br>";

View file

@ -87,8 +87,8 @@ $error = 0;
// This page can be long. We increase the allowed delay, but this does not work when we are in safe_mode.
$err = error_reporting();
error_reporting(0);
if (getDolGlobalString('MAIN_OVERRIDE_TIME_LIMIT')) {
@set_time_limit((int) $conf->global->MAIN_OVERRIDE_TIME_LIMIT);
if (getDolGlobalInt('MAIN_OVERRIDE_TIME_LIMIT')) {
@set_time_limit(getDolGlobalInt('MAIN_OVERRIDE_TIME_LIMIT'));
} else {
@set_time_limit(600);
}
@ -200,6 +200,53 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$conf->setValues($db);
// Reforce log activation (samecode than into the inc.php)
$conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
$conf->modules['syslog'] = 'syslog';
$conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG');
if (!defined('SYSLOG_HANDLERS')) {
define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
}
if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined
if (@is_writable('/tmp')) {
define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
} elseif (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) {
define('SYSLOG_FILE', $_ENV["TMP"].'/dolibarr_install.log');
} elseif (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) {
define('SYSLOG_FILE', $_ENV["TEMP"].'/dolibarr_install.log');
} elseif (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) {
define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp
} elseif (@is_writable('../../')) {
define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others
}
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
if (defined('SYSLOG_FILE')) {
$conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
}
if (!defined('SYSLOG_FILE_NO_ERROR')) {
define('SYSLOG_FILE_NO_ERROR', 1);
}
// We init log handler for install
$handlers = array('mod_syslog_file');
foreach ($handlers as $handler) {
$file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php';
if (!file_exists($file)) {
throw new Exception('Missing log handler file '.$handler.'.php');
}
require_once $file;
$loghandlerinstance = new $handler();
if (!$loghandlerinstance instanceof LogHandler) {
throw new Exception('Log handler does not extend LogHandler');
}
if (empty($conf->loghandlers[$handler])) {
$conf->loghandlers[$handler] = $loghandlerinstance;
}
}
$listofentities = array(1);
// Create the global $hookmanager object
@ -4323,7 +4370,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
$user = new User($db); // To avoid error during migration
}
dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".implode(',', array_keys($listofmodule)));
dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".implode(',', array_keys($listofmodule)), LOG_NOTICE);
$reloadactionformodules = array(
'MAIN_MODULE_AGENDA' => array('class' => 'modAgenda', 'remove' => 1),
@ -4392,7 +4439,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
$moduletoreloadshort = $reg[1];
}
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort." with mode ".$reloadmode." (generic code)");
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort." with mode ".$reloadmode." (generic code)", LOG_NOTICE);
$res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php';
if ($res) {
@ -4404,7 +4451,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
$mod->delete_menus(); // We must delete to be sure it is inserted with new values
$mod->init($reloadmode);
} else {
dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php');
dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php', LOG_ERR);
$res = @dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php');
if ($res) {

View file

@ -98,7 +98,7 @@ if ($id > 0 || !empty($ref)) {
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php

View file

@ -1,7 +1,8 @@
<?php
/* Copyright (C) 2017-2021 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2017-2021 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
* 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
@ -96,7 +97,7 @@ $upload_dir = $conf->knowledgemanagement->multidir_output[isset($object->entity)
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
//if (empty($conf->knowledgemanagement->enabled)) accessforbidden();
//if (empty($permissiontoread)) accessforbidden();
@ -516,8 +517,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($permissiontoadd) {
if ($object->status == $object::STATUS_VALIDATED) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken().'">'.$langs->trans("SetObsolete").'</a>'."\n";
} else {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans("Re-Open").'</a>'."\n";
} elseif ($object->status == $object::STATUS_CANCELED) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans("ReOpen").'</a>'."\n";
}
}

View file

@ -63,7 +63,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'inclu
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
$permission = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');

View file

@ -88,7 +88,7 @@ if ($id > 0 || !empty($ref)) {
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php

View file

@ -68,7 +68,7 @@ $permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'wr
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
/*

View file

@ -3080,8 +3080,8 @@ class Product extends CommonObject
$this->duration = $obj->duration;
$matches = [];
preg_match('/(\d+)(\w+)/', $obj->duration, $matches);
$this->duration_value = !empty($matches[1]) ? (int) $matches[1] : 0;
preg_match('/([\d.]+)(\w+)/', $obj->duration, $matches);
$this->duration_value = !empty($matches[1]) ? (float) $matches[1] : 0;
$this->duration_unit = !empty($matches[2]) ? (string) $matches[2] : null;
$this->canvas = $obj->canvas;
$this->net_measure = $obj->net_measure;

View file

@ -1194,7 +1194,7 @@ if ($resql) {
if ($permissiontoupdatestock) {
print '<a class="reposition" href="'.DOL_URL_ROOT.'/product/inventory/inventory.php?id='.$object->id.'&lineid='.$obj->rowid.'&action=deleteline&page='.$page.$paramwithsearch.'&token='.newToken().'">'.img_delete().'</a>';
}
$qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view;
$qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp"), 'MS') >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view;
print '<input type="hidden" class="maxwidth50 right realqty" name="id_'.$obj->rowid.'_input_tmp" id="id_'.$obj->rowid.'_input_tmp" value="'.$qty_tmp.'">';
print '</td>';
} else {

View file

@ -296,7 +296,7 @@ if (!empty($search_fk_warehouse)) {
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
@ -305,7 +305,7 @@ if (!empty($search_fk_warehouse)) {
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook
$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($productid > 0) {
@ -323,8 +323,24 @@ if ($search_ref) {
if ($search_nom) {
$sql .= natural_search('p.label', $search_nom);
}
$sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.pmp, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
$sql .= ' p.tms, p.duration, p.tobuy, p.stock';
$sqlGroupBy = ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.pmp, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
$sqlGroupBy .= ' p.tms, p.duration, p.tobuy, p.stock';
$parameters = array('sqlGroupBy' => $sqlGroupBy);
$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook == 0) {
// Allows the hook to add things (old behavior)
$sql .= $hookmanager->resPrint;
// Allows the hook to REPLACE the clause (new behavior)
if (!empty($hookmanager->resArray['sqlGroupBy'])) {
$sqlGroupBy = $hookmanager->resArray['sqlGroupBy'];
}
}
$sql .= $sqlGroupBy;
// Add where from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook

View file

@ -94,6 +94,8 @@ if (empty($sortfield)) {
$sortfield = "t.ref";
}
$search_all = trim(GETPOST('search_all', 'alphanohtml'));
// Load variable for pagination
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
@ -367,7 +369,7 @@ if (!$resql) {
$num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && !$page) {
if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".dol_buildpath('/resource/card.php', 1).'?id='.$id);
@ -480,9 +482,10 @@ print '<table class="tagtable liste">'."\n";
// Fields title search
print '<tr class="liste_titre_filter">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre center maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print '<td class="liste_titre maxwidthsearch center">';
$searchpicto = $form->showFilterButtons('left');
print $searchpicto;
print '</td>';
}
@ -559,6 +562,7 @@ $totalarray['nbfield'] = 0;
// Fields title label
print '<tr class="liste_titre">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
}
@ -626,7 +630,7 @@ while ($i < $imaxinloop) {
$objectstatic->max_users = $obj->max_users;
$objectstatic->url = $obj->url;
print '<tr class="oddeven row-with-select">';
print '<tr data-rowid="'.$obj->rowid.'" class="oddeven row-with-select">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {

View file

@ -197,6 +197,7 @@ class Salary extends CommonObject
$this->db = $db;
$this->element = 'salary';
$this->table_element = 'salary';
$this->isextrafieldmanaged = 1;
$this->fields['ref_ext']['visible'] = getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT');
}

View file

@ -1329,10 +1329,13 @@ class Societe extends CommonObject
$array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'TVA_INTRA', 'ACCOUNTANCY_CODE_CUSTOMER', 'ACCOUNTANCY_CODE_SUPPLIER');
foreach ($array_to_check as $key) {
$keymin = strtolower($key);
$keyfield_db = $keymin;
if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') {
$keymin = 'code_compta_client';
$keyfield_db = 'code_compta';
} elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') {
$keymin = 'code_compta_fournisseur';
$keyfield_db = 'code_compta_fournisseur';
}
$i = (int) preg_replace('/[^0-9]/', '', $key);
$vallabel = $this->$keymin;
@ -1392,7 +1395,7 @@ class Societe extends CommonObject
} elseif ($key == 'ACCOUNTANCY_CODE_CUSTOMER' && !empty($this->client)) {
// Check for unicity
if ($vallabel && getDolGlobalString('SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_UNIQUE')) {
if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) {
if ($this->id_prof_exists($keyfield_db, $vallabel, ($this->id > 0 ? $this->id : 0))) {
$langs->loadLangs(array("errors", 'compta'));
$error++;
$this->errors[] = $langs->trans('CustomerAccountancyCodeShort') . " " . $langs->trans("ErrorProdIdAlreadyExist", $vallabel) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')';
@ -1408,7 +1411,7 @@ class Societe extends CommonObject
} elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER' && !empty($this->fournisseur)) {
// Check for unicity
if ($vallabel && getDolGlobalString('SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_UNIQUE')) {
if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) {
if ($this->id_prof_exists($keyfield_db, $vallabel, ($this->id > 0 ? $this->id : 0))) {
$langs->loadLangs(array("errors", 'compta'));
$error++;
$this->errors[] = $langs->trans('SupplierAccountancyCodeShort') . " " . $langs->trans("ErrorProdIdAlreadyExist", $vallabel) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')';