diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 83a5ac69b64..c999e44d813 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -8,7 +8,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2021 Ferran Marcet - * Copyright (C) 2024-2025 Frédéric France + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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 ''; - print '


'; + print '

'; } -// Show form for main parameters +// Show form main options print $formSetup->generateOutput(true); - -print '


'; +print '

'; print '
'; print ''; -print ''; +print ''; print ''; // Binding params @@ -631,12 +655,11 @@ print ''; print ''; print ''; -print '
'; - +print '
'; +print '
'; // Show numbering options -print '


'; - +print '

'; // Accountancy Numbering model $dirmodels = array_merge(array('/'), $conf->modules_parts['models']); @@ -751,13 +774,12 @@ print ''; print ''; // Show advanced options -print '


'; - +print '

'; // Advanced params print '
'; print ''; -print ''; +print ''; print ''; print '
'; @@ -847,12 +869,17 @@ print '
'; print '
'; +print '
'; -print '


'; +print '

'; // Export options +print '
'; +print ''; +print ''; +print ''; print "\n".''."\n"; -// Main Options - print ''; print ''; print ''; @@ -961,7 +986,6 @@ if ($num2) { print '
'; - print ''; // End of page diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f2c11adb4db..463c5cee16d 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -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).''; - $inputHidden = ''; + // Reconstruct the selected date + $clonedate = dol_mktime(0, 0, 0, GETPOSTINT('clonedatemonth'), GETPOSTINT('clonedateday'), GETPOSTINT('clonedateyear')); - $formquestion = array( - array( - 'type' => 'date', - 'name' => 'clonedate', - 'label' => '' . $langs->trans("Docdate") . '', - 'value' => $input1 - ) - ); - - if (getDolGlobalString('ACCOUNTING_CLONING_ENABLE_INPUT_JOURNAL')) { - $formquestion[] = array( - 'type' => 'text', - 'name' => 'code_journal', - 'label' => '' . $langs->trans("Codejournal") . '', - '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' => '' . $langs->trans("Docdate") . '', + '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' => '' . $langs->trans("Codejournal") . '', + 'value' => $input2 + ); + } + + print $form->formconfirm( + $_SERVER["PHP_SELF"], + $langs->trans("ConfirmMassCloneBookkeepingWriting"), + $langs->trans("ConfirmMassCloneBookkeepingWritingQuestion", 1), + "clonebookkeepingwriting", + $formquestion, + '', 0, 300, 1000, 0 + ); + } + + print '
'; print '
'; diff --git a/htdocs/admin/remotestore/class/externalModules.class.php b/htdocs/admin/remotestore/class/externalModules.class.php index a7ca35f2f85..023ea44e7a9 100644 --- a/htdocs/admin/remotestore/class/externalModules.class.php +++ b/htdocs/admin/remotestore/class/externalModules.class.php @@ -105,6 +105,11 @@ class ExternalModules */ public $githubFileError; + /** + * @var string + */ + public $error; + /** * @var int // number of online providers */ diff --git a/htdocs/api/index.php b/htdocs/api/index.php index b4919f3d038..214f6fd9c64 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -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); diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 3302870c7f6..8cd8008bee6 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -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); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 1fd4776213c..2e91b4e2c7a 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -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); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index fc803820783..5abce624948 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -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; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index ebcd51defc6..d3875eed102 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -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 '
'; diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index d8f9c426919..dd37af32adc 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -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); diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 05c62e8384e..fec0574aea8 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -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 ''."\n"; } + $i++; } diff --git a/htdocs/index.php b/htdocs/index.php index 92b52adc521..b2c21e9f626 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -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 "
"; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 38ae7402bae..b85d34f761e 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -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) { diff --git a/htdocs/knowledgemanagement/knowledgerecord_agenda.php b/htdocs/knowledgemanagement/knowledgerecord_agenda.php index e3c315f70e6..c147a129589 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_agenda.php +++ b/htdocs/knowledgemanagement/knowledgerecord_agenda.php @@ -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 diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index 57fa240114d..ec19405e0f4 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -1,7 +1,8 @@ +/* Copyright (C) 2017-2021 Laurent Destailleur * Copyright (C) 2024-2025 MDW * Copyright (C) 2024-2025 Frédéric France + * Copyright (C) 2025 Alexandre Spangaro * * 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 ''.$langs->trans("SetObsolete").''."\n"; - } else { - print ''.$langs->trans("Re-Open").''."\n"; + } elseif ($object->status == $object::STATUS_CANCELED) { + print ''.$langs->trans("ReOpen").''."\n"; } } diff --git a/htdocs/knowledgemanagement/knowledgerecord_contact.php b/htdocs/knowledgemanagement/knowledgerecord_contact.php index 02df2c7d14a..a7cad0e5105 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_contact.php +++ b/htdocs/knowledgemanagement/knowledgerecord_contact.php @@ -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'); diff --git a/htdocs/knowledgemanagement/knowledgerecord_document.php b/htdocs/knowledgemanagement/knowledgerecord_document.php index 48a88f8384c..9f9709b502a 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_document.php +++ b/htdocs/knowledgemanagement/knowledgerecord_document.php @@ -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 diff --git a/htdocs/knowledgemanagement/knowledgerecord_note.php b/htdocs/knowledgemanagement/knowledgerecord_note.php index 6ad64a52c2c..dd3e38764c6 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_note.php +++ b/htdocs/knowledgemanagement/knowledgerecord_note.php @@ -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); /* diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e01246c1dfc..e935738a3d5 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -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; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index f5c415df9d8..26b47c10417 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -1194,7 +1194,7 @@ if ($resql) { if ($permissiontoupdatestock) { print ''.img_delete().''; } - $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 ''; print ''; } else { diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index e7a20b47359..dbce7207a4a 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -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 diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index c4c2b344af3..dfa29be6696 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -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 '
'.$langs->trans('ExportOptions').''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e8855c426ce..1fde2676b91 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3046,8 +3046,9 @@ class Form $out .= ''; // it's needed when to get parent value when extra-field list depend on parent extra-field list } print ''; 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 '
'."\n"; // Fields title search print ''; +// Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; } @@ -559,6 +562,7 @@ $totalarray['nbfield'] = 0; // Fields title label print ''; +// 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 ''; + print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 220efd493b7..9d80e0614b2 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -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'); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0dbff0b0854..e23e84f5cd8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -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") . ')';
'; - $searchpicto = $form->showFilterButtons(); + print ''; + $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print '