diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index af357257351..ef829fe6268 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -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 '
'; if ($object->status > 0) { - print '
'.$langs->trans("AddSubscription")."
"; + print '
'.$langs->trans("AddSubscription")."
"; } else { print '
'.$langs->trans("AddSubscription").'
'; } @@ -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 '
'; print load_fiche_titre($langs->trans("NewCotisation")); diff --git a/htdocs/admin/tools/ui/class/documentation.class.php b/htdocs/admin/tools/ui/class/documentation.class.php index aabc27c4724..e79cd369afc 100644 --- a/htdocs/admin/tools/ui/class/documentation.class.php +++ b/htdocs/admin/tools/ui/class/documentation.class.php @@ -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(), - ), ) ); diff --git a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/index.php b/htdocs/admin/tools/ui/dolibarr-context/index.php similarity index 96% rename from htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/index.php rename to htdocs/admin/tools/ui/dolibarr-context/index.php index 2dc299f64ab..c52afe96474 100644 --- a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/index.php +++ b/htdocs/admin/tools/ui/dolibarr-context/index.php @@ -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);', '', ); - echo $documentation->showCode($lines, 'php'); + $documentation->showCode($lines, 'php'); ?>
@@ -205,7 +202,7 @@ $documentation->showSidebar(); ?> ' });', '', ); - echo $documentation->showCode($lines, 'php'); ?> + $documentation->showCode($lines, 'php'); ?>

Practical usage

@@ -247,7 +244,7 @@ $documentation->showSidebar(); ?> ' });', '', ); - echo $documentation->showCode($lines, 'php'); ?> + $documentation->showCode($lines, 'php'); ?> Open your console F12 and click on ', ); - echo $documentation->showCode($lines, 'php'); ?> + $documentation->showCode($lines, 'php'); ?>

@@ -403,7 +400,7 @@ $documentation->showSidebar(); ?> ' });', '', ); - echo $documentation->showCode($lines, 'php'); ?> + $documentation->showCode($lines, 'php'); ?> Open your console F12 and click on @@ -469,7 +466,7 @@ $documentation->showSidebar(); ?> '});', '', ); - echo $documentation->showCode($lines, 'php'); ?> + $documentation->showCode($lines, 'php'); ?>

Protected Tools

@@ -488,7 +485,7 @@ $documentation->showSidebar(); ?> ' }', '', ); - echo $documentation->showCode($lines, 'php'); ?> + $documentation->showCode($lines, 'php'); ?>

Reading Tools

@@ -504,7 +501,7 @@ $documentation->showSidebar(); ?> ' if(Dolibarr.checkToolExist(\'Tool name to check\')){/* ... */}else{/* ... */}; ', '', ); - echo $documentation->showCode($lines, 'php'); ?> + $documentation->showCode($lines, 'php'); ?> @@ -551,7 +548,7 @@ $documentation->showSidebar(); ?> ' });', '', ); - echo $documentation->showCode($lines, 'php'); ?> + $documentation->showCode($lines, 'php'); ?> ', ); - echo $documentation->showCode($lines, 'php'); + $documentation->showCode($lines, 'php'); ?> @@ -645,7 +642,7 @@ $documentation->showSidebar(); ?> ' });', '', ); - echo $documentation->showCode($lines, 'php'); + $documentation->showCode($lines, 'php'); ?> @@ -660,7 +657,7 @@ $documentation->showSidebar(); ?> ' });', '', ); - echo $documentation->showCode($lines, 'php'); + $documentation->showCode($lines, 'php'); ?> diff --git a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/langs-tool.php b/htdocs/admin/tools/ui/dolibarr-context/langs-tool.php similarity index 87% rename from htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/langs-tool.php rename to htdocs/admin/tools/ui/dolibarr-context/langs-tool.php index 696ed2e48a6..d8e571983d6 100644 --- a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/langs-tool.php +++ b/htdocs/admin/tools/ui/dolibarr-context/langs-tool.php @@ -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(); ?> - +
showBreadCrumb(); ?> @@ -107,11 +98,11 @@ $documentation->showSidebar(); ?> 'Dolibarr.setContextVars( 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),', ']) ?>);', '', ); - echo $documentation->showCode($lines, 'php'); + $documentation->showCode($lines, 'php'); ?>
@@ -171,7 +162,7 @@ $documentation->showSidebar(); ?> '});', '', ); - echo $documentation->showCode($lines, 'php'); + $documentation->showCode($lines, 'php'); print implode("\n", $lines); ?> diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 1354894cf41..47e4ab90c02 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -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)) { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 3a4e100a982..e094ec390a3 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -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++; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 352802d3b02..cf36e105bfd 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -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 diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index e6b74e2d5bd..14ac4a79e3f 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -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 diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index a2f91b13861..6973f03e94e 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -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 diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 3189c8246ea..8a57776ff94 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -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 .= '&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 ''."\n"; + } + + // DEFINE FIRST NEEDED JS CONTEXT VARS + print ''."\n"; + + // -- END OF DEFINITION OF DOLIBARR JS CONTEXT AND TOOLS + + if (getDolGlobalString('MAIN_ENABLE_FONT_ROBOTO')) { print ''."\n"; print ''."\n"; diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index b55ebbc9770..ec19295a425 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -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 $request_data * @phpstan-param array $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 $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 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 Array of timespent objects * diff --git a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/assets/dolibarr-context.mock.js b/htdocs/public/includes/dolibarr-js-context/dolibarr-context.mock.js similarity index 100% rename from htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/assets/dolibarr-context.mock.js rename to htdocs/public/includes/dolibarr-js-context/dolibarr-context.mock.js diff --git a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/assets/dolibarr-context.umd.js b/htdocs/public/includes/dolibarr-js-context/dolibarr-context.umd.js similarity index 100% rename from htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/assets/dolibarr-context.umd.js rename to htdocs/public/includes/dolibarr-js-context/dolibarr-context.umd.js diff --git a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/assets/dolibarr-tool.langs.js b/htdocs/public/includes/dolibarr-js-context/dolibarr-tool.langs.js similarity index 89% rename from htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/assets/dolibarr-tool.langs.js rename to htdocs/public/includes/dolibarr-js-context/dolibarr-tool.langs.js index adeefc27ddb..becfdff5f32 100644 --- a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/assets/dolibarr-tool.langs.js +++ b/htdocs/public/includes/dolibarr-js-context/dolibarr-tool.langs.js @@ -24,8 +24,14 @@ document.addEventListener('Dolibarr:Init', function(e) { * @returns {Promise} */ 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 diff --git a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/assets/dolibarr-tool.seteventmessage.js b/htdocs/public/includes/dolibarr-js-context/dolibarr-tool.seteventmessage.js similarity index 100% rename from htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/assets/dolibarr-tool.seteventmessage.js rename to htdocs/public/includes/dolibarr-js-context/dolibarr-tool.seteventmessage.js diff --git a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/langs-tool-interface.php b/htdocs/public/langs/langs-tool-interface.php similarity index 89% rename from htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/langs-tool-interface.php rename to htdocs/public/langs/langs-tool-interface.php index 2404220fc31..179c9f04fc2 100644 --- a/htdocs/admin/tools/ui/experimental/experiments/dolibarr-context/langs-tool-interface.php +++ b/htdocs/public/langs/langs-tool-interface.php @@ -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'; /** diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 6d40cb76bbd..044700c89ef 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -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); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 56cbebb1175..4078819a665 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1222,7 +1222,12 @@ if ($action == 'create' || $action == 'adduserldap') { if ($_SESSION["dol_authmode"] == 'dolibarr') { print ''.$langs->trans("ForcePasswordChange").''; print ''; - print ''; + if ($object->hasRight('user', 'self', 'password')) { + print ''; + } else { + print ''; + print $langs->trans("UserDoesNotHaveRightsToChangeHisPassword"); + } print ''; print "\n"; } @@ -2025,10 +2030,15 @@ if ($action == 'create' || $action == 'adduserldap') { if ($_SESSION["dol_authmode"] == 'dolibarr') { print ''.$langs->trans("ForcePasswordChange").''; print ''; - if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') < 2) { - print 'force_pass_change ? ' checked="checked"' : '').'>'; + if ($object->hasRight('user', 'self', 'password')) { + if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') < 2) { + print 'force_pass_change ? ' checked="checked"' : '').'>'; + } else { + print yn($object->force_pass_change); + } } else { - print yn($object->force_pass_change); + print ''; + print $langs->trans("UserDoesNotHaveRightsToChangeHisPassword"); } print ''; print "\n"; @@ -2714,11 +2724,18 @@ if ($action == 'create' || $action == 'adduserldap') { if ($_SESSION["dol_authmode"] == 'dolibarr') { print ''; print ''.$form->editfieldkey('ForcePasswordChange', 'forcepasswordchange', '', $object, 0).''; - if ($permissiontoedit) { - print 'force_pass_change ? ' checked="checked"' : '').'>'; + + if ($object->hasRight('user', 'self', 'password')) { + if ($permissiontoedit) { + print 'force_pass_change ? ' checked="checked"' : '').'>'; + } else { + print 'force_pass_change ? ' checked="checked"' : '').'>'; + } } else { - print 'force_pass_change ? ' checked="checked"' : '').'>'; + print ''; + print $langs->trans("UserDoesNotHaveRightsToChangeHisPassword"); } + print ''; }