diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index fb05f408e57..8adc5051bc2 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -10,6 +10,10 @@ on: type: string workflow_dispatch: +concurrency: + group: pre-commit-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref + }} + cancel-in-progress: true env: gh_event: ${{ inputs.gh_event || github.event_name }} jobs: @@ -47,12 +51,14 @@ jobs: cache: pip python-version: "3.11" - run: python -m pip install pre-commit + # Restore previous cache of precommit - uses: actions/cache/restore@v4 with: path: ~/.cache/pre-commit/ key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - # Run all the precommit tools (defined into pre-commit-config.yaml). + + # Run all the precommit tools (defined in pre-commit-config.yaml). # We can force exclusion of some of them here. - name: Run pre-commit hooks env: @@ -112,6 +118,7 @@ jobs: set -o pipefail ln -sf ~/.cache .cache # Absolute path in .pre-commit-config.yaml pre-commit run --hook-stage manual -a php-cs-with-cache | tee -a ${RAW_LOG} + pre-commit run --hook-stage manual -a sqlfluff-lint | tee -a ${RAW_LOG} ls -l ~/.cache/pre-commit/ - name: Convert Raw Log to Annotations @@ -135,4 +142,3 @@ jobs: path: | ${{ env.RAW_LOG }} ${{ env.CS_XML }} - retention-days: 2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 814f144508c..cf9d37d2cc3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,6 +43,7 @@ repos: - id: end-of-file-fixer # Check that there are no completely merged file conflicts - id: check-merge-conflict + stages: [pre-commit, pre-rebase, pre-commit, pre-merge-commit] # Check that files with shebangs have the executable bit set (in git) - id: check-executables-have-shebangs # Check that shell files are executables @@ -231,3 +232,26 @@ repos: hooks: - id: shellcheck args: [-W, "100"] + + - repo: https://github.com/sqlfluff/sqlfluff + rev: 3.0.4 + hooks: + - id: sqlfluff-lint + stages: [pre-commit, manual] # manual needed for ci + exclude: (?x)^ + (htdocs/includes/.* + |htdocs/install/doctemplates/websites/.*_template + |htdocs/core/menus/init_menu_auguria\.sql + |htdocs/install/doctemplates/websites/website_template-.*\.sql + |(htdocs/install/mysql/data/(llx_20_c_departements\.sql + |llx_accounting_account_.*\.sql) + |(htdocs/install/mysql/migration/3\.[256]\.0-.*\.sql) + ) + |htdocs/install/mysql/migration/(1[0-5]|[456789])\.0\.0-.*\.sql + |htdocs/install/mysql/migration/3\.([0134789])\.0-.*\.sql + |htdocs/install/mysql/migration/repair\.sql + |htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal\.sql + |htdocs/install/mysql/tables/llx_categorie(_(account|actioncomm|contact|fournisseur|knowledgemanagement-knowledgemanagement|member|product|project|societe|ticket-ticket|user|warehouse|website_page-website)?\.key\.sql) + |htdocs/install/mysql/tables/llx_rights_def\.key\.sql + |htdocs/install/pgsql/functions/functions(-(don|loan|mailing|opensurvey|partnership|recruitment|website))?\.sql + )$ diff --git a/README.md b/README.md index 52b74a1fcdf..8d661158efb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Dolibarr ERP & CRM is a modern software package that helps manage your organization's activities (contacts, suppliers, invoices, orders, stocks, agenda…). -It's an Open-Source Software suite (written in PHP with optional JavaScript enhancements) designed for small, medium or large companies, foundations and freelancers. +It's an Open-Source Software suite (written in PHP with JavaScript enhancements) designed for small, medium or large companies, foundations and freelancers. You can freely use, study, modify or distribute it according to its license. @@ -187,7 +187,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - APIs (REST, SOAP) - Code that is easy to understand, maintain and develop (PHP with no heavy framework; trigger and hook architecture) - Support a lot of country-specific features: - - Spanish Tax RE and ISPF + - Spanish Tax RE and IRPF - French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM) - Canadian double taxes (federal/province) and other countries using cumulative VAT - Tunisian tax stamp diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 992f00540a5..3af98b46915 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -10,21 +10,21 @@ return [ // # Issue statistics: // PhanPluginUnknownPropertyType : 2250+ occurrences - // PhanTypePossiblyInvalidDimOffset : 1560+ occurrences + // PhanTypePossiblyInvalidDimOffset : 1550+ occurrences // PhanTypeMismatchArgumentProbablyReal : 1450+ occurrences // PhanPossiblyUndeclaredGlobalVariable : 1400+ occurrences - // PhanPluginUnknownObjectMethodCall : 1050+ occurrences - // PhanUndeclaredProperty : 940+ occurrences + // PhanPluginUnknownObjectMethodCall : 1040+ occurrences + // PhanUndeclaredProperty : 840+ occurrences // PhanPluginUnknownArrayMethodParamType : 780+ occurrences // PhanUndeclaredGlobalVariable : 730+ occurrences // PhanPluginUnknownArrayMethodReturnType : 620+ occurrences // PhanPossiblyUndeclaredVariable : 420+ occurrences - // PhanTypeArraySuspiciousNullable : 360+ occurrences + // PhanTypeArraySuspiciousNullable : 340+ occurrences // PhanTypeMismatchProperty : 300+ occurrences // PhanPluginDuplicateExpressionAssignmentOperation : 280+ occurrences // PhanPluginUnknownArrayFunctionReturnType : 230+ occurrences // PhanTypeObjectUnsetDeclaredProperty : 230+ occurrences - // PhanPluginUnknownArrayFunctionParamType : 190+ occurrences + // PhanPluginUnknownArrayFunctionParamType : 180+ occurrences // PhanTypeMismatchArgumentNullableInternal : 180+ occurrences // PhanTypeInvalidDimOffset : 170+ occurrences // PhanTypeExpectedObjectPropAccess : 150+ occurrences @@ -53,10 +53,10 @@ return [ // PhanInvalidFQSENInClasslike : 4 occurrences // PhanParamTooMany : 4 occurrences // PhanTypeConversionFromArray : 3 occurrences + // PhanNoopStringLiteral : 2 occurrences // PhanTypeComparisonToArray : 2 occurrences // PhanAccessMethodProtected : 1 occurrence // PhanAccessPropertyStaticAsNonStatic : 1 occurrence - // PhanNoopStringLiteral : 1 occurrence // PhanPluginWhitespaceTrailing : 1 occurrence // PhanTypeArraySuspiciousNull : 1 occurrence // PhanTypeMismatchReturn : 1 occurrence @@ -172,7 +172,7 @@ return [ 'htdocs/admin/supplier_order.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredMethod'], 'htdocs/admin/supplier_payment.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'], 'htdocs/admin/supplier_proposal.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], - 'htdocs/admin/syslog.php' => ['PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredMethod'], + 'htdocs/admin/syslog.php' => ['PhanTypeMismatchArgumentNullableInternal'], 'htdocs/admin/system/constall.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/admin/system/database-tables.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/admin/system/dbtable.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeArraySuspiciousNullable'], @@ -613,7 +613,6 @@ return [ 'htdocs/core/lib/fiscalyear.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/fourn.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/ftp.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'], - 'htdocs/core/lib/functions.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeArraySuspiciousNullable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/core/lib/functions2.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypePossiblyInvalidDimOffset'], 'htdocs/core/lib/functions_ch.lib.php' => ['PhanTypeMismatchDimFetch'], 'htdocs/core/lib/functionsnumtoword.lib.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidLeftOperandOfNumericOp'], diff --git a/dev/translation/ignore_translation_keys.lst b/dev/translation/ignore_translation_keys.lst index 46c73e56d95..fbe32ef779a 100644 --- a/dev/translation/ignore_translation_keys.lst +++ b/dev/translation/ignore_translation_keys.lst @@ -102,7 +102,6 @@ Adherent AdherentNotLinkedToThirdParty AdvTgtUse Agents -AllEntities AllFilesDidAlreadyExist AlreadyInV7 AmountOfOrders @@ -311,7 +310,6 @@ Empty End EnterAnIP EnterNameOfDictionnaryToDeleteDesc -EntityNameNotDefined Entries ErrSCAAuthentication Error sql diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index a5365331a6b..0352cd5c713 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -51,7 +51,7 @@ $nbletter = GETPOSTINT('ACCOUNTING_LETTERING_NBLETTERS'); $list = array( 'ACCOUNTING_LENGTH_GACCOUNT', 'ACCOUNTING_LENGTH_AACCOUNT', -// 'ACCOUNTING_LIMIT_LIST_VENTILATION' // there is already a global parameter to define the nb of records in lists, we must use it in priority. Having one parameter for nb of record for each page is deprecated. +// 'ACCOUNTING_LIMIT_LIST_VENTILATION' // there is already a global parameter to define the nb of records in lists, we must use it in priority. Having one parameter for nb of record for each page is deprecated. // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc ); @@ -68,7 +68,7 @@ $error = 0; * Actions */ -if (in_array($action, array('setBANK_DISABLE_DIRECT_INPUT', 'setACCOUNTANCY_COMBO_FOR_AUX', 'setACCOUNTING_MANAGE_ZERO'))) { +if (in_array($action, array('setBANK_DISABLE_DIRECT_INPUT', 'setACCOUNTANCY_ER_DATE_RECORD', 'setACCOUNTANCY_COMBO_FOR_AUX', 'setACCOUNTING_MANAGE_ZERO'))) { $constname = preg_replace('/^set/', '', $action); $constvalue = GETPOSTINT('value'); $res = dolibarr_set_const($db, $constname, $constvalue, 'yesno', 0, '', $conf->entity); @@ -345,6 +345,19 @@ if (getDolGlobalString('BANK_DISABLE_DIRECT_INPUT')) { } print ''; +print ''; +print ''.$langs->trans("ACCOUNTANCY_ER_DATE_RECORD").''; +if (getDolGlobalInt('ACCOUNTANCY_ER_DATE_RECORD')) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + print ''; print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX"); print ' - '.$langs->trans("NotRecommended").''; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index fd3262620c1..a8aac1df719 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -110,7 +110,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; +$sql = "SELECT er.rowid, er.ref, er.date_debut as de, er.date_fin as df,"; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; @@ -183,7 +183,11 @@ if ($result) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); } - $taber[$obj->rowid]["date"] = $db->jdate($obj->de); + if (getDolGlobalInt('ACCOUNTANCY_ER_DATE_RECORD')) { + $taber[$obj->rowid]["date"] = $db->jdate($obj->df); + } else { + $taber[$obj->rowid]["date"] = $db->jdate($obj->de); + } $taber[$obj->rowid]["ref"] = $obj->ref; $taber[$obj->rowid]["comments"] = $obj->comments; $taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index cef180ab96b..88115b59295 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -308,19 +308,19 @@ if ($action == 'edit') { } } function change_smtp_auth_method() { - console.log(jQuery("#radio_pw").prop("checked")); + console.log("Call smtp auth method"); if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) { - jQuery(".smtp_oauth_service").show(); jQuery(".smtp_pw").hide(); + jQuery(".smtp_oauth_service").show(); } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) { + jQuery(".smtp_pw").hide(); jQuery(".smtp_oauth_service").show(); - jQuery(".smtp_pw").hide(); } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){ - jQuery(".smtp_oauth_service").hide(); jQuery(".smtp_pw").hide(); - } else { jQuery(".smtp_oauth_service").hide(); + } else { jQuery(".smtp_pw").show(); + jQuery(".smtp_oauth_service").hide(); } } initfields(); @@ -329,7 +329,7 @@ if ($action == 'edit') { initfields(); change_smtp_auth_method(); }); - jQuery("#radio_pw, #radio_oauth").change(function() { + jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() { change_smtp_auth_method(); }); jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() { @@ -450,7 +450,10 @@ if ($action == 'edit') { if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { // Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case) print ' '; - print ''; + print ''; + print '     '; + print ' '; + print ''; print '     '; print ' '; print ''; @@ -698,7 +701,14 @@ if ($action == 'edit') { // AUTH method if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) { $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN'); - $text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ; + $text = ''; + if ($authtype === "LOGIN") { + $text = $langs->trans("UseAUTHLOGIN"); + } elseif ($authtype === "PLAIN") { + $text = $langs->trans("UseAUTHPLAIN"); + } elseif ($authtype === "XOAUTH2") { + $text = $langs->trans("UseOauth"); + } print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''.$text.''; } diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 059a99a7a1b..5419731f0dc 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -192,6 +192,7 @@ if ($action == 'edit') { if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\') { + console.log("I choose php mail mode"); jQuery(".drag").hide(); jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(0); jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").prop("disabled", true); @@ -221,6 +222,7 @@ if ($action == 'edit') { } if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\') { + console.log("I choose smtps mail mode"); jQuery(".drag").show(); jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_EMAILING').'); jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled"); @@ -232,14 +234,15 @@ if ($action == 'edit') { jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show(); jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show(); - jQuery("#smtp_port_mess").hide(); + jQuery("#smtp_port_mess").hide(); jQuery("#smtp_server_mess").hide(); - jQuery(".smtp_method").show(); + jQuery(".smtp_method").show(); jQuery(".smtp_auth_method").show(); } if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\') { - jQuery(".drag").show(); + console.log("I choose swiftmailer mail mode"); + jQuery(".drag").show(); jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_EMAILING').'); jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").removeAttr("disabled"); jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_STARTTLS_EMAILING').'); @@ -252,35 +255,37 @@ if ($action == 'edit') { jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show(); jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide(); - jQuery(".smtp_method").show(); - jQuery(".smtp_auth_method").show(); + jQuery(".smtp_method").show(); + jQuery(".smtp_auth_method").show(); } } - function change_smtp_auth_method() { - console.log(jQuery("#radio_pw").prop("checked")); - if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) { - jQuery(".smtp_oauth_service").show(); - jQuery(".smtp_pw").hide(); - } else if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) { - jQuery(".smtp_oauth_service").show(); - jQuery(".smtp_pw").hide(); - } else if(jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\'){ - jQuery(".smtp_oauth_service").hide(); - jQuery(".smtp_pw").hide(); - } else { - jQuery(".smtp_oauth_service").hide(); - jQuery(".smtp_pw").show(); - } - } + function change_smtp_auth_method() { + console.log("Call smtp auth method"); + if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) { + jQuery(".smtp_pw").hide(); + jQuery(".smtp_oauth_service").show(); + } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) { + jQuery(".smtp_pw").hide(); + jQuery(".smtp_oauth_service").show(); + } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){ + jQuery(".smtp_pw").hide(); + jQuery(".smtp_oauth_service").hide(); + } else { + jQuery(".smtp_pw").show(); + jQuery(".smtp_oauth_service").hide(); + } + } + + change_smtp_auth_method(); initfields(); - change_smtp_auth_method(); - jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() { + + jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() { + change_smtp_auth_method(); initfields(); - change_smtp_auth_method(); - }); - jQuery("#radio_pw, #radio_oauth").change(function() { - change_smtp_auth_method(); - }); + }); + jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() { + change_smtp_auth_method(); + }); jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() { if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1) jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0); @@ -401,8 +406,11 @@ if ($action == 'edit') { if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { // Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case) print ' '; - print ''; - print '            '; + print ''; + print '     '; + print ' '; + print ''; + print '     '; print ' '; print ''; } else { @@ -552,7 +560,14 @@ if ($action == 'edit') { // AUTH method if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) { $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN'); - $text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ; + $text = ''; + if ($authtype === "LOGIN") { + $text = $langs->trans("UseAUTHLOGIN"); + } elseif ($authtype === "PLAIN") { + $text = $langs->trans("UseAUTHPLAIN"); + } elseif ($authtype === "XOAUTH2") { + $text = $langs->trans("UseOauth"); + } print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''.$text.''; } diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index dd9f63c3ef6..ddc149c8a45 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -93,6 +93,7 @@ if ($action == 'update' && !$cancel) { } dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_TICKET"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET"), 'chaine', 0, '', $conf->entity); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -190,6 +191,7 @@ if ($action == 'edit') { if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\') { + console.log("I choose php mail mode"); jQuery(".drag").hide(); jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(0); jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true); @@ -217,6 +219,7 @@ if ($action == 'edit') { } if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\') { + console.log("I choose smtps mail mode"); jQuery(".drag").show(); jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET').'); jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled"); @@ -233,6 +236,7 @@ if ($action == 'edit') { } if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\') { + console.log("I choose swiftmailer mail mode"); jQuery(".drag").show(); jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").val(' . getDolGlobalString('MAIN_MAIL_EMAIL_TLS_TICKET').'); jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").removeAttr("disabled"); @@ -248,33 +252,33 @@ if ($action == 'edit') { jQuery(".smtp_auth_method").show(); } } - function change_smtp_auth_method() { - console.log(jQuery("#radio_pw").prop("checked")); - if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) { - jQuery(".smtp_oauth_service").show(); - jQuery(".smtp_pw").hide(); - } else if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) { - jQuery(".smtp_oauth_service").show(); - jQuery(".smtp_pw").hide(); - } else if(jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\'){ - jQuery(".smtp_oauth_service").hide(); - jQuery(".smtp_pw").hide(); - } else { - jQuery(".smtp_oauth_service").hide(); - jQuery(".smtp_pw").show(); - } - } + function change_smtp_auth_method() { + console.log("Call smtp auth method"); + if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) { + jQuery(".smtp_pw").hide(); + jQuery(".smtp_oauth_service").show(); + } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) { + jQuery(".smtp_pw").hide(); + jQuery(".smtp_oauth_service").show(); + } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){ + jQuery(".smtp_pw").hide(); + jQuery(".smtp_oauth_service").hide(); + } else { + jQuery(".smtp_pw").show(); + jQuery(".smtp_oauth_service").hide(); + } + } + initfields(); - change_smtp_auth_method(); + change_smtp_auth_method(); jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() { initfields(); - change_smtp_auth_method(); - + change_smtp_auth_method(); }); - jQuery("#radio_pw, #radio_oauth").change(function() { - change_smtp_auth_method(); - }); + jQuery("#radio_pw, #radio_plain, #radio_oauth").change(function() { + change_smtp_auth_method(); + }); jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() { if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1) jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0); @@ -391,8 +395,11 @@ if ($action == 'edit') { if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { // Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case) print ' '; - print ''; - print '            '; + print ''; + print '     '; + print ' '; + print ''; + print '     '; print ' '; print ''; } else { @@ -480,6 +487,19 @@ if ($action == 'edit') { } print ''; + // SMTP_ALLOW_SELF_SIGNED_TICKET + print ''.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) { + if (function_exists('openssl_open')) { + print $form->selectyesno('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET', (getDolGlobalString('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET') ? $conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET : 0), 1); + } else { + print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } + } else { + print yn(0).' ('.$langs->trans("NotSupported").')'; + } + print ''; + print ''; print dol_get_fiche_end(); @@ -528,7 +548,14 @@ if ($action == 'edit') { // AUTH method if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) { $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN'); - $text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ; + $text = ''; + if ($authtype === "LOGIN") { + $text = $langs->trans("UseAUTHLOGIN"); + } elseif ($authtype === "PLAIN") { + $text = $langs->trans("UseAUTHPLAIN"); + } elseif ($authtype === "XOAUTH2") { + $text = $langs->trans("UseOauth"); + } print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''.$text.''; } @@ -539,7 +566,7 @@ if ($action == 'edit') { // SMTPS PW if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') != "XOAUTH2") { - print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).''; + print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW_TICKET')).''; } // SMTPS oauth service @@ -584,6 +611,23 @@ if ($action == 'edit') { } print ''; } + + // SMTP_ALLOW_SELF_SIGNED_EMAILING + if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') == 'mail')) { + // Nothing + } else { + print ''.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) { + if (function_exists('openssl_open')) { + print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_TICKET')); + } else { + print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } + } else { + print ''.yn(0).' ('.$langs->trans("NotSupported").')'; + } + print ''; + } } print ''; diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index d68b7c054ef..5a4fd73faab 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -119,6 +119,14 @@ $workflowcodes = array( 'warning' => '' ), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. + 'WORKFLOW_SUM_INVOICES_AMOUNT_CLASSIFY_BILLED_ORDER' => array( + 'family' => 'classify_order', + 'position' => 43, + 'enabled' => (isModEnabled('invoice') && isModEnabled('order')), + 'picto' => 'order', + 'warning' => '' + ), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. + // Automatic classification supplier proposal 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL' => array( 'family' => 'classify_supplier_proposal', @@ -196,12 +204,14 @@ $workflowcodes = array( 'family' => 'link_ticket', 'position' => 500, 'enabled' => (isModEnabled('ticket') && isModEnabled('contract')), - 'picto' => 'ticket' + 'picto' => 'ticket', + 'reloadpage' => 1 // So next option can be shown ), + // This one depends on previous one WORKFLOW_TICKET_LINK_CONTRACT 'WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS' => array( 'family' => 'link_ticket', 'position' => 501, - 'enabled' => (isModEnabled('ticket') && isModEnabled('contract')), + 'enabled' => (isModEnabled('ticket') && isModEnabled('contract') && getDolGlobalString('WORKFLOW_TICKET_LINK_CONTRACT')), 'picto' => 'ticket' ), ); @@ -323,7 +333,11 @@ foreach ($workflowcodes as $key => $params) { print ''; if (!empty($conf->use_javascript_ajax)) { - print ajax_constantonoff($key); + if (!empty($params['reloadpage'])) { + print ajax_constantonoff($key, array(), null, 0, 0, 1); + } else { + print ajax_constantonoff($key); + } } else { if (getDolGlobalString($key)) { print ''; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index a952b9565d7..2586f80790d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -482,7 +482,7 @@ if ($object->id > 0) { print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; if ($user->hasRight('societe', 'creer') && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print ''; print ''; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 12888f2f24e..4f6fae9823a 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -378,7 +378,7 @@ if ($socid > 0) { // VAT print ''.$langs->trans("VAT").''; print ''; - print $form->load_tva('tva_tx', GETPOSTISSET('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0, $mysoc, $object, 0, 0, '', 0, 1); + print $form->load_tva('tva_tx', (GETPOSTISSET('tva_tx') ? GETPOST('tva_tx', 'alpha') : getDolGlobalString('MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS', 0)), $mysoc, $object, 0, 0, '', 0, 1); print ''; print ''.$langs->trans("NoteReason").''; print ''; diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 0d364c64625..198a0e3d646 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2018 Frédéric France * Copyright (C) 2022 Alexandre Spangaro + * Copyright (C) 2024 Charlene Benke * * 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 @@ -21,7 +22,7 @@ /** * \file htdocs/compta/stats/cabyprodserv.php - * \brief Page reporting TO by Products & Services + * \brief Page reporting Turnover billed by Products & Services */ // Load Dolibarr environment @@ -64,8 +65,9 @@ if (!$sortfield) { } // Category -$selected_cat = GETPOSTINT('search_categ'); -$selected_soc = GETPOSTINT('search_soc'); +$selected_cat = GETPOST('search_categ', 'intcomma'); +$selected_catsoc = GETPOST('search_categ_soc', 'intcomma'); +$selected_soc = GETPOST('search_soc', 'intcomma'); $subcat = false; if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; @@ -73,7 +75,7 @@ if (GETPOST('subcat', 'alpha') === 'yes') { $categorie = new Categorie($db); // product/service -$selected_type = GETPOSTINT('search_type'); +$selected_type = GETPOST('search_type', 'intcomma'); if ($selected_type == '') { $selected_type = -1; } @@ -196,6 +198,9 @@ $tableparams = array(); if (!empty($selected_cat)) { $tableparams['search_categ'] = $selected_cat; } +if (!empty($selected_catsoc)) { + $tableparams['search_categ_soc'] = $selected_catsoc; +} if (!empty($selected_soc)) { $tableparams['search_soc'] = $selected_soc; } @@ -211,7 +216,7 @@ $tableparams = array_merge($commonparams, $tableparams); $paramslink = ""; foreach ($allparams as $key => $value) { - $paramslink .= '&'.$key.'='.$value; + $paramslink .= '&'.urlencode($key).'='.urlencode($value); } @@ -277,7 +282,6 @@ if (isModEnabled('accounting') && $modecompta != 'BOOKKEEPING') { } - $name = array(); // SQL request @@ -286,7 +290,7 @@ $catotal_ht = 0; $qtytotal = 0; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,"; + $sql = "SELECT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,"; $sql .= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,"; $sql .= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty"; @@ -295,14 +299,8 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; - if ($selected_soc > 0) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)"; - } $sql .= ",".MAIN_DB_PREFIX."facturedet as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; - if ($selected_cat === -2) { // Without any category - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; - } $parameters = array(); $hookmanager->executeHooks('printFieldListFrom', $parameters); @@ -322,32 +320,78 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_type >= 0) { $sql .= " AND l.product_type = ".((int) $selected_type); } - if ($selected_cat === -2) { // Without any category - $sql .= " AND cp.fk_product is null"; - } elseif ($selected_cat > 0) { // Into a specific category - if ($subcat) { - $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1); - $listofcatsql = ""; - foreach ($TListOfCats as $key => $cat) { - if ($key !== 0) { - $listofcatsql .= ","; + // Search for tag/category ($searchCategoryProductList is an array of ID) + $searchCategoryProductOperator = -1; + $searchCategoryProductList = array($selected_cat); + if ($subcat) { + $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1); + $searchCategoryProductList = array(); + foreach ($TListOfCats as $key => $cat) { + $searchCategoryProductList[] = $cat['rowid']; + } + } + if (!empty($searchCategoryProductList)) { + $searchCategoryProductSqlList = array(); + $listofcategoryid = ''; + foreach ($searchCategoryProductList as $searchCategoryProduct) { + if (intval($searchCategoryProduct) == -2) { + $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE l.fk_product = ck.fk_product)"; + } elseif (intval($searchCategoryProduct) > 0) { + if ($searchCategoryProductOperator == 0) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE l.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); } - $listofcatsql .= $cat['rowid']; } } - - $sql .= " AND (p.rowid IN "; - $sql .= " (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product cp WHERE "; - if ($subcat) { - $sql .= "cp.fk_categorie IN (".$db->sanitize($listofcatsql).")"; - } else { - $sql .= "cp.fk_categorie = ".((int) $selected_cat); + if ($listofcategoryid) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE l.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; + } + if ($searchCategoryProductOperator == 1) { + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; + } + } else { + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; + } } - $sql .= "))"; } + + // Search for tag/category ($searchCategorySocieteList is an array of ID) + $searchCategorySocieteOperator = -1; + $searchCategorySocieteList = array($selected_catsoc); + if (!empty($searchCategorySocieteList)) { + $searchCategorySocieteSqlList = array(); + $listofcategoryid = ''; + foreach ($searchCategorySocieteList as $searchCategorySociete) { + if (intval($searchCategorySociete) == -2) { + $searchCategorySocieteSqlList[] = "NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE f.fk_soc = cs.fk_soc)"; + } elseif (intval($searchCategorySociete) > 0) { + if ($searchCategorySocieteOperator == 0) { + $searchCategorySocieteSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE f.fk_soc = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategorySociete).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySociete); + } + } + } + if ($listofcategoryid) { + $searchCategorySocieteSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE f.fk_soc = cs.fk_soc AND cs.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; + } + if ($searchCategorySocieteOperator == 1) { + if (!empty($searchCategorySocieteSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategorySocieteSqlList).")"; + } + } else { + if (!empty($searchCategorySocieteSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategorySocieteSqlList).")"; + } + } + } + if ($selected_soc > 0) { - $sql .= " AND soc.rowid=".((int) $selected_soc); + $sql .= " AND f.fk_soc = ".((int) $selected_soc); } $sql .= " AND f.entity IN (".getEntity('invoice').")"; @@ -360,6 +404,7 @@ if ($modecompta == 'CREANCES-DETTES') { dol_syslog("cabyprodserv", LOG_DEBUG); $result = $db->query($sql); + $amount_ht = array(); $amount = array(); $qty = array(); @@ -368,6 +413,7 @@ if ($modecompta == 'CREANCES-DETTES') { $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); + $amount_ht[$obj->rowid] = $obj->amount; $amount[$obj->rowid] = $obj->amount_ttc; $qty[$obj->rowid] = $obj->qty; @@ -399,24 +445,25 @@ if ($modecompta == 'CREANCES-DETTES') { // Category filter print ''; print ''; - print img_picto('', 'category', 'class="paddingrightonly"'); + print img_picto('', 'category', 'class="pictofixedwidth"'); print $formother->select_categories(Categorie::TYPE_PRODUCT, $selected_cat, 'search_categ', 0, $langs->trans("Category")); print ' '; - print $langs->trans("SubCats").'? '; - print ''; + print ''; // type filter (produit/service) - print ' '; - print $langs->trans("Type").': '; - $form->select_type_of_lines(isset($selected_type) ? $selected_type : -1, 'search_type', 1, 1, 1); + $form->select_type_of_lines(isset($selected_type) ? $selected_type : -1, 'search_type', $langs->trans("Type"), 1, 1); //select thirdparty - print '
'; - print img_picto('', 'company', 'class="paddingrightonly"'); - print $form->select_thirdparty_list($selected_soc, 'search_soc', '', $langs->trans("ThirdParty")); + print '
'; + print img_picto('', 'category', 'class="pictofixedwidth"'); + print $formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_catsoc, 'search_categ_soc', 0, $langs->trans("CustomersProspectsCategoriesShort")); + print '
'; + print img_picto('', 'company', 'class="pictofixedwidth"'); + print $form->select_company($selected_soc, 'search_soc', '', $langs->trans("ThirdParty")); print ''; print ''; @@ -554,6 +601,8 @@ if ($modecompta == 'CREANCES-DETTES') { print ''; $db->free($result); + } else { + print ''.$langs->trans("NoRecordFound").''; } print ""; print ''; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index bbe653114a4..4d7da8fe848 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -584,7 +584,7 @@ class CMailFile $smtps->setBCC($this->addr_bcc); $smtps->setErrorsTo($this->errors_to); $smtps->setDeliveryReceipt($this->deliveryreceipt); - if (!empty($conf->global->$keyforsslseflsigned)) { + if (getDolGlobalString($keyforsslseflsigned)) { $smtps->setOptions(array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true))); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a93623dda8a..397436e7496 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3763,7 +3763,7 @@ abstract class CommonObject * @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object (used to analyze lines to check corrupted data). * @return int Return integer <0 if KO, >0 if OK */ - public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) + public function update_price($exclspec = 0, $roundingadjust = 'auto', $nodatabaseupdate = 0, $seller = null) { // phpcs:enable global $conf, $hookmanager, $action; @@ -3777,6 +3777,8 @@ abstract class CommonObject } // reshook = 0 => execute normal code // Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield) + $isElementForSupplier = false; + $roundTotalConstName = 'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND'; // const for customer by default $MODULE = ""; if ($this->element == 'propal') { $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; @@ -3785,12 +3787,18 @@ abstract class CommonObject } elseif ($this->element == 'facture' || $this->element == 'invoice') { $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; } elseif ($this->element == 'facture_fourn' || $this->element == 'supplier_invoice' || $this->element == 'invoice_supplier' || $this->element == 'invoice_supplier_rec') { + $isElementForSupplier = true; $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE"; } elseif ($this->element == 'order_supplier' || $this->element == 'supplier_order') { + $isElementForSupplier = true; $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER"; } elseif ($this->element == 'supplier_proposal') { + $isElementForSupplier = true; $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL"; } + if ($isElementForSupplier === true) { + $roundTotalConstName = 'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND_SUPPLIER'; // const for supplier + } if (!empty($MODULE)) { if (getDolGlobalString($MODULE)) { @@ -3806,8 +3814,8 @@ abstract class CommonObject include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $forcedroundingmode = $roundingadjust; - if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) { - $forcedroundingmode = getDolGlobalString('MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND'); + if ($forcedroundingmode == 'auto' && isset($conf->global->{$roundTotalConstName})) { + $forcedroundingmode = getDolGlobalString($roundTotalConstName); } elseif ($forcedroundingmode == 'auto') { $forcedroundingmode = '0'; } @@ -3898,7 +3906,7 @@ abstract class CommonObject } $obj->total_tva = $tmpcal[1]; $obj->total_ttc = $tmpcal[2]; - } elseif ($diff_when_using_price_ht && $roundingadjust == '0') { + } elseif ($diff_when_using_price_ht) { // After calculation from HT, total is consistent but we have found a difference between VAT part in calculation and into database and // we ask to force the use of rounding on line (like done on calculation) so we force update of line $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num((float) $tmpcal[1]).", total_ttc = ".price2num((float) $tmpcal[2])." WHERE rowid = ".((int) $obj->rowid); @@ -9141,26 +9149,26 @@ abstract class CommonObject /** * Show photos of an object (nbmax maximum), into several columns * - * @param string $modulepart 'product', 'ticket', ... - * @param string $sdir Directory to scan (full absolute path) - * @param int $size 0=original size, 1='small' use thumbnail if possible - * @param int $nbmax Nombre maximum de photos (0=pas de max) - * @param int $nbbyrow Number of image per line or -1 to use div separator or 0 to use no separator. Used only if size=1 or 'small'. - * @param int $showfilename 1=Show filename - * @param int $showaction 1=Show icon with action links (resize, delete) - * @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image. - * @param int $maxWidth Max width of original image when size='small' - * @param int $nolink Do not add a href link to view enlarged imaged into a new tab - * @param int|string $overwritetitle Do not add title tag on image - * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) - * @param string $cache A string if we want to use a cached version of image - * @param string $addphotorefcss Add CSS to img of photos - * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto + * @param string $modulepart 'product', 'ticket', ... + * @param string $sdir Directory to scan (full absolute path) + * @param int<0,1>|''|'small' $size 0 or ''=original size, 1 or 'small'=use thumbnail if possible + * @param int $nbmax Nombre maximum de photos (0=pas de max) + * @param int $nbbyrow Number of image per line or -1 to use div separator or 0 to use no separator. Used only if size=1 or 'small'. + * @param int $showfilename 1=Show filename + * @param int $showaction 1=Show icon with action links (resize, delete) + * @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image. + * @param int $maxWidth Max width of original image when size='small' + * @param int $nolink Do not add a href link to view enlarged imaged into a new tab + * @param int|string $overwritetitle Do not add title tag on image + * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) + * @param string $cache A string if we want to use a cached version of image + * @param string $addphotorefcss Add CSS to img of photos + * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $overwritetitle = 0, $usesharelink = 0, $cache = '', $addphotorefcss = 'photoref') { // phpcs:enable - global $conf, $user, $langs; + global $user, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 33de02e5f6d..7c96c34a295 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1148,11 +1148,11 @@ class Form * Return list of types of lines (product or service) * Example: 0=product, 1=service, 9=other (for external module) * - * @param string $selected Preselected type - * @param string $htmlname Name of field in html form - * @param int<0,1> $showempty Add an empty field - * @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select) - * @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service') + * @param string $selected Preselected type + * @param string $htmlname Name of field in html form + * @param int<0,1>|string $showempty Add an empty field + * @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select) + * @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service') * @return void */ public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0) @@ -1172,7 +1172,13 @@ class Form if ($selected == -1) { print ' selected'; } - print '> '; + print '>'; + if (is_numeric($showempty)) { + print ' '; + } else { + print $showempty; + } + print ''; } print '