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

This commit is contained in:
Laurent Destailleur 2026-02-24 14:16:44 +01:00
commit 06d1b2bc14
18 changed files with 212 additions and 96 deletions

View file

@ -151,7 +151,7 @@ if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'ye
} else {
$object->socid = $result;
$action = 'addsubscription';
$action = 'createsubscription';
}
} else {
setEventMessages($object->error, $object->errors, 'errors');
@ -250,14 +250,14 @@ if (empty($reshook) && $user->hasRight('adherent', 'cotisation', 'creer') && $ac
$langs->load("errors");
$errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription"));
setEventMessages($errmsg, null, 'errors');
$action = 'addsubscription';
$action = 'createsubscription';
}
if (GETPOST('end') && !$datesubend) {
$error++;
$langs->load("errors");
$errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription"));
setEventMessages($errmsg, null, 'errors');
$action = 'addsubscription';
$action = 'createsubscription';
}
if (!$datesubend) {
$datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd');
@ -266,7 +266,7 @@ if (empty($reshook) && $user->hasRight('adherent', 'cotisation', 'creer') && $ac
$error++;
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment"));
setEventMessages($errmsg, null, 'errors');
$action = 'addsubscription';
$action = 'createsubscription';
}
// Check if a payment is mandatory or not
@ -276,7 +276,7 @@ if (empty($reshook) && $user->hasRight('adherent', 'cotisation', 'creer') && $ac
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
setEventMessages($errmsg, null, 'errors');
$error++;
$action = 'addsubscription';
$action = 'createsubscription';
} else {
// If an amount has been provided, we check also fields that becomes mandatory when amount is not null.
if (isModEnabled('bank') && GETPOST("paymentsave") != 'none') {
@ -285,26 +285,26 @@ if (empty($reshook) && $user->hasRight('adherent', 'cotisation', 'creer') && $ac
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
setEventMessages($errmsg, null, 'errors');
$error++;
$action = 'addsubscription';
$action = 'createsubscription';
}
if (GETPOST("paymentsave") != 'invoiceonly' && !GETPOST("operation")) {
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
setEventMessages($errmsg, null, 'errors');
$error++;
$action = 'addsubscription';
$action = 'createsubscription';
}
if (GETPOST("paymentsave") != 'invoiceonly' && !(GETPOSTINT("accountid") > 0)) {
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount"));
setEventMessages($errmsg, null, 'errors');
$error++;
$action = 'addsubscription';
$action = 'createsubscription';
}
} else {
if (GETPOSTINT("accountid")) {
$errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
setEventMessages($errmsg, null, 'errors');
$error++;
$action = 'addsubscription';
$action = 'createsubscription';
}
}
}
@ -337,7 +337,7 @@ if (empty($reshook) && $user->hasRight('adherent', 'cotisation', 'creer') && $ac
$db->commit();
} else {
$db->rollback();
$action = 'addsubscription';
$action = 'createsubscription';
}
if (!$error) {
@ -697,11 +697,11 @@ print dol_get_fiche_end();
// Button to create a new subscription if member no draft (-1) neither resiliated (0) neither excluded (-2)
if ($user->hasRight('adherent', 'cotisation', 'creer')) {
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
if ($action != 'createsubscription' && $action != 'create_thirdparty') {
print '<div class="tabsAction">';
if ($object->status > 0) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription&token='.newToken().'">'.$langs->trans("AddSubscription")."</a></div>";
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=createsubscription">'.$langs->trans("AddSubscription")."</a></div>";
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>';
}
@ -713,7 +713,7 @@ if ($user->hasRight('adherent', 'cotisation', 'creer')) {
/*
* List of subscriptions
*/
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
if ($action != 'createsubscription' && $action != 'create_thirdparty') {
$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
$sql .= " c.rowid as crowid, c.subscription,";
$sql .= " c.datec, c.fk_type as cfk_type,";
@ -822,7 +822,7 @@ if ($action != 'addsubscription' && $action != 'create_thirdparty') {
}
if (($action != 'addsubscription' && $action != 'create_thirdparty')) {
if (($action != 'createsubscription' && $action != 'create_thirdparty')) {
// Show online payment link
// The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods()
include_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
@ -841,7 +841,7 @@ if (($action != 'addsubscription' && $action != 'create_thirdparty')) {
/*
* Add new subscription form
*/
if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->hasRight('adherent', 'cotisation', 'creer')) {
if (($action == 'createsubscription' || $action == 'create_thirdparty') && $user->hasRight('adherent', 'cotisation', 'creer')) {
print '<br>';
print load_fiche_titre($langs->trans("NewCotisation"));

View file

@ -236,7 +236,34 @@ class Documentation
)
);
// Elements
$this->menu['UxDolibarrContext'] = array(
'url' => dol_buildpath($this->baseUrl.'/dolibarr-context/index.php', 1),
'icon' => 'fab fa-fort-awesome',
'submenu' => array(
'UxDolibarrContextHowItWork' => array(
'url' => dol_buildpath($this->baseUrl.'/dolibarr-context/index.php', 1),
'icon' => 'fab fa-fort-awesome',
'submenu' => array(),
'summary' => array(
'Introduction' => '#titlesection-basicusage',
'ConsoleHelp' => '#titlesection-console-help',
'JSDolibarrhooks' => '#titlesection-hooks',
'JSDolibarrhooksReadyVsInit' => '#titlesection-event-init-vs-ready',
'JSDolibarrAwaitHooks' => '#titlesection-await-hooks',
'ExampleOfCreatingNewContextTool' => '#titlesection-create-tool-example',
'SetEventMessageTool' => '#titlesection-tool-seteventmessage',
'SetAndUseContextVars' => '#titlesection-contextvars',
),
),
'UxDolibarrContextLangsTool' => array(
'url' => dol_buildpath($this->baseUrl.'/dolibarr-context/langs-tool.php', 1),
'icon' => 'far fa-flag',
'submenu' => array(),
'summary' => array(),
),
)
);
// Elements
$this->menu['ExperimentalUx'] = array(
@ -253,34 +280,6 @@ class Documentation
'ExperimentalUxContributionTitle' => '#experimental-ux-contribution',
),
),
'UxDolibarrContext' => array(
'url' => dol_buildpath($this->baseUrl.'/experimental/experiments/dolibarr-context/index.php', 1),
'icon' => 'fas fa-flask',
'submenu' => array(
'UxDolibarrContextHowItWork' => array(
'url' => dol_buildpath($this->baseUrl.'/experimental/experiments/dolibarr-context/index.php', 1),
'icon' => 'fas fa-flask',
'submenu' => array(),
'summary' => array(
'Introduction' => '#titlesection-basicusage',
'ConsoleHelp' => '#titlesection-console-help',
'JSDolibarrhooks' => '#titlesection-hooks',
'JSDolibarrhooksReadyVsInit' => '#titlesection-event-init-vs-ready',
'JSDolibarrAwaitHooks' => '#titlesection-await-hooks',
'ExampleOfCreatingNewContextTool' => '#titlesection-create-tool-example',
'SetEventMessageTool' => '#titlesection-tool-seteventmessage',
'SetAndUseContextVars' => '#titlesection-contextvars',
),
),
'UxDolibarrContextLangsTool' => array(
'url' => dol_buildpath($this->baseUrl.'/experimental/experiments/dolibarr-context/langs-tool.php', 1),
'icon' => 'fas fa-flask',
'submenu' => array(),
'summary' => array(),
),
),
'summary' => array(),
),
)
);

View file

@ -18,7 +18,7 @@
*/
// Load Dolibarr environment
require '../../../../../../main.inc.php';
require '../../../../main.inc.php';
/**
* @var DoliDB $db
@ -43,13 +43,10 @@ $documentation = new Documentation($db);
$group = 'ExperimentalUx';
$experimentName = 'UxDolibarrContext';
$experimentAssetsPath = $documentation->baseUrl . '/experimental/experiments/dolibarr-context/assets/';
$js = [
'/includes/ace/src/ace.js',
'/includes/ace/src/ext-statusbar.js',
'/includes/ace/src/ext-language_tools.js',
$experimentAssetsPath . '/dolibarr-context.umd.js',
$experimentAssetsPath . '/dolibarr-tool.seteventmessage.js',
];
$css = [];
@ -154,7 +151,7 @@ $documentation->showSidebar(); ?>
' Dolibarr.debugMode(false);',
'</script>',
);
echo $documentation->showCode($lines, 'php');
$documentation->showCode($lines, 'php');
?>
</div>
@ -205,7 +202,7 @@ $documentation->showSidebar(); ?>
' });',
'</script>',
);
echo $documentation->showCode($lines, 'php'); ?>
$documentation->showCode($lines, 'php'); ?>
</div>
<h3>Practical usage</h3>
@ -247,7 +244,7 @@ $documentation->showSidebar(); ?>
' });',
'</script>',
);
echo $documentation->showCode($lines, 'php'); ?>
$documentation->showCode($lines, 'php'); ?>
Open your console <code>F12</code> and click on <button class="button" id="try-event-yourCustomHookName">try</button>
<script nonce="<?php print getNonce() ?>" >
@ -336,7 +333,7 @@ $documentation->showSidebar(); ?>
' });',
'</script>',
);
echo $documentation->showCode($lines, 'php'); ?>
$documentation->showCode($lines, 'php'); ?>
</div>
<p>
@ -403,7 +400,7 @@ $documentation->showSidebar(); ?>
' });',
'</script>',
);
echo $documentation->showCode($lines, 'php'); ?>
$documentation->showCode($lines, 'php'); ?>
Open your console <code>F12</code> and click on <button class="button" id="try-event-yourCustomAwaitHookName">try</button>
@ -469,7 +466,7 @@ $documentation->showSidebar(); ?>
'});',
'</script>',
);
echo $documentation->showCode($lines, 'php'); ?>
$documentation->showCode($lines, 'php'); ?>
</div>
<h3>Protected Tools</h3>
@ -488,7 +485,7 @@ $documentation->showSidebar(); ?>
' }',
'</script>',
);
echo $documentation->showCode($lines, 'php'); ?>
$documentation->showCode($lines, 'php'); ?>
</div>
<h3>Reading Tools</h3>
@ -504,7 +501,7 @@ $documentation->showSidebar(); ?>
' if(Dolibarr.checkToolExist(\'Tool name to check\')){/* ... */}else{/* ... */}; ',
'</script>',
);
echo $documentation->showCode($lines, 'php'); ?>
$documentation->showCode($lines, 'php'); ?>
</div>
</div>
@ -551,7 +548,7 @@ $documentation->showSidebar(); ?>
' });',
'</script>',
);
echo $documentation->showCode($lines, 'php'); ?>
$documentation->showCode($lines, 'php'); ?>
<script nonce="<?php print getNonce() ?>" >
document.addEventListener('Dolibarr:Ready', function(e) {
@ -614,7 +611,7 @@ $documentation->showSidebar(); ?>
' });',
'</script>',
);
echo $documentation->showCode($lines, 'php');
$documentation->showCode($lines, 'php');
?>
</div>
@ -645,7 +642,7 @@ $documentation->showSidebar(); ?>
' });',
'</script>',
);
echo $documentation->showCode($lines, 'php');
$documentation->showCode($lines, 'php');
?>
</div>
@ -660,7 +657,7 @@ $documentation->showSidebar(); ?>
' });',
'</script>',
);
echo $documentation->showCode($lines, 'php');
$documentation->showCode($lines, 'php');
?>
</div>

View file

@ -18,7 +18,7 @@
*/
// Load Dolibarr environment
require '../../../../../../main.inc.php';
require '../../../../main.inc.php';
/**
* @var DoliDB $db
@ -43,14 +43,11 @@ $documentation = new Documentation($db);
$group = 'ExperimentalUx';
$experimentName = 'UxDolibarrContextLangsTool';
$experimentAssetsPath = $documentation->baseUrl . '/experimental/experiments/dolibarr-context/assets/';
$experimentAssetsPath = dolBuildUrl('/public/includes/dolibarr-js-context');
$js = [
'/includes/ace/src/ace.js',
'/includes/ace/src/ext-statusbar.js',
'/includes/ace/src/ext-language_tools.js',
$experimentAssetsPath . '/dolibarr-context.umd.js',
$experimentAssetsPath . '/dolibarr-tool.langs.js',
$experimentAssetsPath . '/dolibarr-tool.seteventmessage.js',
'/includes/ace/src/ext-language_tools.js'
];
$css = [];
@ -62,13 +59,7 @@ $documentation->view = [$group, 'UxDolibarrContext', $experimentName];
// Output sidebar
$documentation->showSidebar(); ?>
<script>
Dolibarr.setContextVars(<?php print json_encode([
'DOL_VERSION' => DOL_VERSION,
'MAIN_LANG_DEFAULT' => $langs->getDefaultLang(),
'DOL_LANG_INTERFACE_URL' => dol_buildpath('admin/tools/ui/experimental/experiments/dolibarr-context/langs-tool-interface.php', 1),
]) ?>);
</script>
<div class="doc-wrapper">
<?php $documentation->showBreadCrumb(); ?>
@ -107,11 +98,11 @@ $documentation->showSidebar(); ?>
'Dolibarr.setContextVars(<?php print json_encode([',
' \'DOL_VERSION\' => DOL_VERSION,',
' \'MAIN_LANG_DEFAULT\' => $langs->getDefaultLang(),',
' \'DOL_LANG_INTERFACE_URL\' => dol_buildpath(\'admin/tools/ui/experimental/experiments/dolibarr-context/langs-tool-interface.php\',1),',
' \'DOL_LANG_INTERFACE_URL\' => dol_buildpath(\'public/langs/langs-tool-interface.php\', 1),',
']) ?>);',
'</script>',
);
echo $documentation->showCode($lines, 'php');
$documentation->showCode($lines, 'php');
?>
</div>
</div>
@ -171,7 +162,7 @@ $documentation->showSidebar(); ?>
'});',
'</script>',
);
echo $documentation->showCode($lines, 'php');
$documentation->showCode($lines, 'php');
print implode("\n", $lines);
?>

View file

@ -100,11 +100,13 @@ class FileUpload
dol_include_once('/'.$parentElement.'/class/'.$parentObject.'.class.php');
$parent = new $parentClass($db);
$parent->fetch($object->$parentForeignKey);
if (!empty($parent->socid)) {
$parent->fetch_thirdparty();
if ($object->$parentForeignKey !== null) {
$parent->fetch((int) $object->$parentForeignKey);
if (!empty($parent->socid)) {
$parent->fetch_thirdparty();
}
$object->$parentObject = clone $parent;
}
$object->$parentObject = clone $parent;
$object_ref = dol_sanitizeFileName($object->project->ref).'/'.$object_ref;
}
@ -396,6 +398,7 @@ class FileUpload
// Remove path information and dots around the filename, to prevent uploading
// into different directories or replacing hidden system files.
$file_name = basename(dol_sanitizeFileName($name));
$file_name = preg_replace('/ {2,}/', ' ', $file_name); // replaces multiple spaces into one space like the upload flow via input field
// Add missing file extension for known image types:
$matches = array();
if (strpos($file_name, '.') === false && preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {

View file

@ -420,9 +420,39 @@ if (empty($reshook)) {
$numprlv = $db->num_rows($result_sql);
}
if ($numprlv > 0) {
// Calculate pending amount to check if more requests can be made
$pending = 0;
// Get pending requests open with no transfer receipt yet
$sqlPending1 = "SELECT SUM(pfd.amount) as amount";
$sqlPending1 .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
$sqlPending1 .= " WHERE pfd.fk_facture_fourn = ".((int) $objecttmp->id);
$sqlPending1 .= " AND pfd.traite = 0";
$resPending1 = $db->query($sqlPending1);
if ($resPending1) {
$objPending1 = $db->fetch_object($resPending1);
if ($objPending1) {
$pending += (float) $objPending1->amount;
}
}
$db->free($resPending1);
// Get pending request with a transfer receipt generated but not yet processed
$sqlPending2 = "SELECT SUM(pl.amount) as amount";
$sqlPending2 .= " FROM ".$db->prefix()."prelevement_lignes as pl";
$sqlPending2 .= " INNER JOIN ".$db->prefix()."prelevement as p ON p.fk_prelevement_lignes = pl.rowid";
$sqlPending2 .= " WHERE p.fk_facture_fourn = ".((int) $objecttmp->id);
$sqlPending2 .= " AND (pl.statut IS NULL OR pl.statut = 0)";
$resPending2 = $db->query($sqlPending2);
if ($resPending2) {
if ($objPending2 = $db->fetch_object($resPending2)) {
$pending += (float) $objPending2->amount;
}
}
$db->free($resPending2);
$remaintopaylesspendingdebit = $objecttmp->resteapayer - $pending;
// Check remaining amount (allows multiple partial requests as long as total doesn't exceed invoice amount)
if ($remaintopaylesspendingdebit <= 0) {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
setEventMessages($objecttmp->ref.' '.$langs->trans("AmountRequestedAlreadyReachesTotal"), $objecttmp->errors, 'warnings');
} elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') {
$langs->load("errors");
$error++;

View file

@ -721,3 +721,4 @@ InvoiceSentFromTemplate=Invoice %s sent from recurring invoice template %s
InvoiceSentFromTemplateError=Failed to send invoice %s from recurring invoice template %s : %s
BillStatusValidatedWithSendind=Validated (needs to be paid) and sending
sendAutoEmailInvoiceKO=Failed to send email from %s to %s
AmountRequestedAlreadyReachesTotal=The amount requested already reaches the total of the invoice

View file

@ -467,3 +467,4 @@ SomeShipmentExists=Error, there is some shipment linked to the order. Deletion r
WarningEvaluationEmptyValidate=Can't validate evaluation, levels on skills not defined
ErrorBadParametersForDirectDebitFileCreate=Can't create bank transfer file: expected format parameter is not provided.
ErrorBadParametersForDirectDebitFileCreateDids=Can't create bank transfer file: IDs of existing payment requests are not provided.
UserDoesNotHaveRightsToChangeHisPassword=That user doesn't have the rights to change his own password

View file

@ -715,6 +715,7 @@ DisputeWon=Victoire en litige
DisputeClosed=Litige clos
Dispute=Différend
Sales=Ventes
AmountRequestedAlreadyReachesTotal=Le montant demandé atteint déjà le total de la facture
AutoSendEmail=Envoi automatique d'e-mails
EmailTemplateForAutoSend=Modèle d'e-mail pour l'envoi automatique
InvoiceSentFromTemplate=facture %s envoyé depuis le modèle récurrent facture %s

View file

@ -45,7 +45,7 @@
// For optional tuning. Enabled if environment variable MAIN_SHOW_TUNING_INFO is defined.
$micro_start_time = 0; // Used as global var into printCommonFooter()
if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) {
list($usec, $sec) = explode(" ", microtime());
[$usec, $sec] = explode(" ", microtime());
$micro_start_time = ((float) $usec + (float) $sec);
// Add Xdebug code coverage
//define('XDEBUGCOVERAGE',1);
@ -1814,6 +1814,42 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
$themeparam .= '&amp;THEME_SATURATE_RATIO='.GETPOSTINT('THEME_SATURATE_RATIO');
}
/**
* ====================================
* DEFINE DOLIBARR JS CONTEXT AND TOOLS
* ====================================
* see Documentation at admin/tools/ui/dolibarr-context/index.php
*/
$jsContextVars = [
'DOL_VERSION' => DOL_VERSION,
'DOL_URL_ROOT' => DOL_URL_ROOT,
];
$jsContextPathUrl = DOL_URL_ROOT . '/public/includes/dolibarr-js-context';
$jsContextFiles = [
'dolibarr-context.umd.js', // The js Dolibarr context definition
'dolibarr-tool.seteventmessage.js' // The first tools to help dev for easy event in js
];
if (! defined('NOREQUIRETRAN')) {
// Langs tool see Documentation at admin/tools/ui/dolibarr-context/index.php
$jsContextFiles[] = 'dolibarr-tool.langs.js';
$jsContextVars['MAIN_LANG_DEFAULT'] = $langs->getDefaultLang();// For langs tool
$jsContextVars['DOL_LANG_INTERFACE_URL'] = dol_buildpath('public/langs/langs-tool-interface.php', 1);// For langs tool
}
// Load context and all js tools
foreach ($jsContextFiles as $jsContextFile) {
print '<script nonce="'.getNonce().'" src="'.$jsContextPathUrl.'/'.$jsContextFile.'?' . $ext . '" ></script>'."\n";
}
// DEFINE FIRST NEEDED JS CONTEXT VARS
print '<script nonce="'.getNonce().'">Dolibarr.setContextVars('.json_encode($jsContextVars).');</script>'."\n";
// -- END OF DEFINITION OF DOLIBARR JS CONTEXT AND TOOLS
if (getDolGlobalString('MAIN_ENABLE_FONT_ROBOTO')) {
print '<link rel="preconnect" href="https://fonts.gstatic.com">'."\n";
print '<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@200;300;400;500;600&display=swap" rel="stylesheet">'."\n";

View file

@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php';
/**
* API class for projects
*
* @since 5.0.0 Initial implementation
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
@ -68,6 +69,7 @@ class Projects extends DolibarrApi
*
* Return an array with project information
*
* @since 5.0.0 Initial implementation
* @param int $id ID of project
* @return Object Object with cleaned properties
*
@ -97,6 +99,7 @@ class Projects extends DolibarrApi
*
* Return an array with project information
*
* @since 20.0.0 Initial implementation
* @param string $ref Ref of project
* @return Object Object with cleaned properties
*
@ -128,6 +131,7 @@ class Projects extends DolibarrApi
*
* Return an array with project information
*
* @since 20.0.0 Initial implementation
* @param string $ref_ext Ref_Ext of project
* @return Object Object with cleaned properties
*
@ -159,6 +163,7 @@ class Projects extends DolibarrApi
*
* Return an array with project information
*
* @since 20.0.0 Initial implementation
* @param string $email_msgid Email msgid of project
* @return Object Object with cleaned properties
*
@ -190,6 +195,7 @@ class Projects extends DolibarrApi
*
* Get a list of projects
*
* @since 5.0.0 Initial implementation
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
@ -307,6 +313,7 @@ class Projects extends DolibarrApi
/**
* Create project object
*
* @since 5.0.0 Initial implementation
* @param array $request_data Request data
* @phan-param array<string,mixed> $request_data
* @phpstan-param array<string,mixed> $request_data
@ -390,6 +397,7 @@ class Projects extends DolibarrApi
/**
* Adds a contact to an project
*
* @since 23.0.0 Initial implementation
* @param int $id project ID
* @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if source = 'internal') to link
* @param string $type_contact Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING
@ -431,6 +439,7 @@ class Projects extends DolibarrApi
/**
* Delete a contact type of given project
*
* @since 23.0.0 Initial implementation
* @param int $id Id of project to update
* @param int $contactid Row key of the contact in the array contact_ids.
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
@ -475,6 +484,7 @@ class Projects extends DolibarrApi
* Get tasks of a project.
* See also API /tasks
*
* @since 5.0.0 Initial implementation
* @param int $id Id of project
* @param int $includetimespent 0=Return only list of tasks. 1=Include a summary of time spent, 2=Include details of time spent lines
* @return array
@ -515,6 +525,7 @@ class Projects extends DolibarrApi
/**
* Get roles a user is assigned to a project with
*
* @since 5.0.0 Initial implementation
* @param int $id Id of project
* @param int $userid Id of user (0 = connected user)
* @return array
@ -693,6 +704,7 @@ class Projects extends DolibarrApi
/**
* Update project general fields (won't touch lines of project)
*
* @since 5.0.0 Initial implementation
* @param int $id Id of project to update
* @param array $request_data Datas
* @phan-param ?array<string,mixed> $request_data
@ -744,6 +756,7 @@ class Projects extends DolibarrApi
/**
* Delete project
*
* @since 5.0.0 Initial implementation
* @param int $id Project ID
*
* @return array
@ -781,6 +794,7 @@ class Projects extends DolibarrApi
* You can test this API with the following input message
* { "notrigger": 0 }
*
* @since 5.0.0 Initial implementation
* @param int $id Project ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @phan-param int<0,1> $notrigger
@ -831,6 +845,7 @@ class Projects extends DolibarrApi
/**
* Get all timespent
*
* @since 23.0.0 Initial implementation
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
@ -1027,6 +1042,7 @@ class Projects extends DolibarrApi
*
* Return an array with contact information
*
* @since 23.0.0 Initial implementation
* @param int $id ID of project
* @param string $type Type of the contact
* @return array<int,mixed> Array with cleaned properties
@ -1061,6 +1077,7 @@ class Projects extends DolibarrApi
/**
* Adds a contact to a project
*
* @since 23.0.0 Initial implementation
* @param int $id Project ID
* @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if source = 'internal') to link
* @param string $type_contact Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING
@ -1121,6 +1138,7 @@ class Projects extends DolibarrApi
/**
* Delete a contact type of given project
*
* @since 23.0.0 Initial implementation
* @param int $id Id of project to update
* @param int $contactid Row key of the contact in the array contact_ids.
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
@ -1167,6 +1185,7 @@ class Projects extends DolibarrApi
/**
* Get timespent of a project (from all its tasks)
*
* @since 23.0.0 Initial implementation
* @param int $id ID of project
* @return array<int,mixed> Array of timespent objects
*

View file

@ -24,8 +24,14 @@ document.addEventListener('Dolibarr:Init', function(e) {
* @returns {Promise<IDBDatabase>}
*/
async function openDB() {
// Generate a unique name per instance
const path = Dolibarr.getContextVar('DOL_URL_ROOT'); // or a unique Dolibarr identifier if available
const hashedPath = await hashString(path);
const dbName = `DolibarrLangs_${hashedPath}`;
return new Promise((resolve, reject) => {
const request = indexedDB.open('DolibarrLangs', 1);
const request = indexedDB.open(dbName, 1);
request.onupgradeneeded = e => {
const db = e.target.result;
if (!db.objectStoreNames.contains('langs')) db.createObjectStore('langs');
@ -35,6 +41,22 @@ document.addEventListener('Dolibarr:Init', function(e) {
});
}
// Create a secure DB name
async function getSafeDbName() {
const path = window.location.pathname;
const hashedPath = await hashString(path);
return `DolibarrLangs_${hashedPath}`;
}
// Simple function to generate a hash from a string
async function hashString(str) {
const encoder = new TextEncoder();
const data = encoder.encode(str);
const hashBuffer = await crypto.subtle.digest('SHA-1', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
}
/**
* Get cached translation for a domain + locale
* @param {string} domain

View file

@ -17,17 +17,17 @@
*/
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
//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('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
@ -36,7 +36,7 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // I
// Load Dolibarr environment
require '../../../../../../main.inc.php';
require '../../main.inc.php';
/**

View file

@ -144,7 +144,6 @@ if ($action == "send" && $user->hasRight('takepos', 'run')) {
$object->context['email_msgid'] = $mail->msgid;
// Same code as in actions_sendmail.inc.php
// if ($triggersendname === 'BILL_SENTBYMAIL' && $object instanceof Facture) { // Always true ($triggersendname is set above, and $object = $invoice = Facture object
// If sending email for invoice, we increase the counter of invoices sent by email
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET email_sent_counter = email_sent_counter + 1";
$sql .= " WHERE rowid = ".((int) $object->id);

View file

@ -1222,7 +1222,12 @@ if ($action == 'create' || $action == 'adduserldap') {
if ($_SESSION["dol_authmode"] == 'dolibarr') {
print '<tr><td class="titlefieldcreate">'.$langs->trans("ForcePasswordChange").'</td>';
print '<td>';
print '<input type="checkbox" name="forcepasswordchange" value="1"'.(GETPOST('forcepasswordchange') == '1' ? ' checked="checked"' : '').'>';
if ($object->hasRight('user', 'self', 'password')) {
print '<input type="checkbox" name="forcepasswordchange" value="1"'.(GETPOST('forcepasswordchange') == '1' ? ' checked="checked"' : '').'>';
} else {
print '<input type="checkbox" name="forcepasswordchange" value="1" disabled>';
print $langs->trans("UserDoesNotHaveRightsToChangeHisPassword");
}
print '</td>';
print "</tr>\n";
}
@ -2025,10 +2030,15 @@ if ($action == 'create' || $action == 'adduserldap') {
if ($_SESSION["dol_authmode"] == 'dolibarr') {
print '<tr><td class="titlefieldcreate">'.$langs->trans("ForcePasswordChange").'</td>';
print '<td>';
if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') < 2) {
print '<input type="checkbox" disabled name="forcepasswordchange" value="1"'.($object->force_pass_change ? ' checked="checked"' : '').'>';
if ($object->hasRight('user', 'self', 'password')) {
if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') < 2) {
print '<input type="checkbox" disabled name="forcepasswordchange" value="1"'.($object->force_pass_change ? ' checked="checked"' : '').'>';
} else {
print yn($object->force_pass_change);
}
} else {
print yn($object->force_pass_change);
print '<input type="checkbox" name="forcepasswordchange" value="1" disabled>';
print $langs->trans("UserDoesNotHaveRightsToChangeHisPassword");
}
print '</td>';
print "</tr>\n";
@ -2714,11 +2724,18 @@ if ($action == 'create' || $action == 'adduserldap') {
if ($_SESSION["dol_authmode"] == 'dolibarr') {
print '<tr>';
print '<td>'.$form->editfieldkey('ForcePasswordChange', 'forcepasswordchange', '', $object, 0).'</td><td>';
if ($permissiontoedit) {
print '<input type="checkbox" name="forcepasswordchange" value="1"'.($object->force_pass_change ? ' checked="checked"' : '').'>';
if ($object->hasRight('user', 'self', 'password')) {
if ($permissiontoedit) {
print '<input type="checkbox" name="forcepasswordchange" value="1"'.($object->force_pass_change ? ' checked="checked"' : '').'>';
} else {
print '<input type="checkbox" name="forcepasswordchange" disabled value="1"'.($object->force_pass_change ? ' checked="checked"' : '').'>';
}
} else {
print '<input type="checkbox" name="forcepasswordchange" disabled value="1"'.($object->force_pass_change ? ' checked="checked"' : '').'>';
print '<input type="checkbox" name="forcepasswordchange" value="1" disabled>';
print $langs->trans("UserDoesNotHaveRightsToChangeHisPassword");
}
print '</td></tr>';
}