diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index b29ae8aa809..671a266c767 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -106,7 +106,7 @@ jobs: ls -l ~/.cache/pre-commit/ - name: Convert Raw Log to Annotations - uses: mdeweerd/logToCheckStyle@2024.3.2 + uses: mdeweerd/logToCheckStyle@v2024.3.4 if: ${{ failure() }} with: in: ${{ env.RAW_LOG }} diff --git a/.github/workflows/windows-ci.yaml b/.github/workflows/windows-ci.yaml index edcb9d39226..cb467055156 100644 --- a/.github/workflows/windows-ci.yaml +++ b/.github/workflows/windows-ci.yaml @@ -150,7 +150,7 @@ jobs: for /f "tokens=2 delims==" %%A in ('doskey /m:err') do EXIT /B %%A - name: Convert Raw Log to Annotations - uses: mdeweerd/logToCheckStyle@2024.3.2 + uses: mdeweerd/logToCheckStyle@v2024.3.4 if: ${{ failure() }} with: in: ${{ env.PHPUNIT_LOG }} diff --git a/ChangeLog b/ChangeLog index 60efdf1093b..6580a4e5dda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -104,7 +104,7 @@ FIX: #yogosha21416 For users: ---------- -NEW: Compatibility with PHP 8.2 +NEW: Compatibility with PHP 8.2 (warning must be disabled) NEW: Module Workstation (used to enhance the module BOM and Manufacturing Order) is now stable NEW: Add a CLI tool to regenerate all documents NEW: Add a confirmation popup when deleting extrafields diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 8c6c44e90f3..f39b1262064 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -10,25 +10,20 @@ return [ // # Issue statistics: // PhanParamSignatureMismatch : 25+ occurrences - // PhanTypeMismatchReturnNullable : 20+ occurrences // PhanPluginSuspiciousParamPosition : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanPluginDuplicateExpressionBinaryOp : 10+ occurrences - // PhanTypeArraySuspiciousNull : 10+ occurrences - // PhanTypeMismatchReturn : 10+ occurrences + // PhanTypeMismatchReturn : 8 occurrences // PhanRedefineFunctionInternal : 6 occurrences + // PhanTypeArraySuspiciousNull : 6 occurrences // PhanParamTooMany : 4 occurrences - // PhanTypeMismatchPropertyProbablyReal : 2 occurrences + // PhanTypeMismatchReturnNullable : 3 occurrences // PhanAccessMethodProtected : 1 occurrence // PhanAccessPropertyStaticAsNonStatic : 1 occurrence // PhanNoopStringLiteral : 1 occurrence - // PhanPluginAlwaysReturnFunction : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'htdocs/adherents/class/adherent.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/adherents/class/adherentstats.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/adherents/stats/geo.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/adherents/type.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/admin/receiptprinter.php' => ['PhanRedefineFunctionInternal'], 'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp'], @@ -36,10 +31,7 @@ return [ 'htdocs/categories/class/api_categories.class.php' => ['PhanAccessMethodProtected'], 'htdocs/categories/viewcat.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/collab/index.php' => ['PhanParamTooMany'], - 'htdocs/comm/action/class/actioncomm.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/comm/action/index.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/comm/propal/class/api_proposals.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/compta/cashcontrol/cashcontrol_card.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanParamTooMany'], 'htdocs/compta/prelevement/create.php' => ['PhanPluginSuspiciousParamPosition'], @@ -47,24 +39,15 @@ return [ 'htdocs/core/class/commonobject.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/class/extrafields.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/class/html.form.class.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/class/html.formprojet.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/core/class/smtps.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/core/class/stats.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/db/mysqli.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/db/pgsql.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/db/sqlite3.class.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturnNullable'], 'htdocs/core/get_info.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/lib/date.lib.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/lib/files.lib.php' => ['PhanPluginDuplicateExpressionBinaryOp'], - 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanPluginAlwaysReturnFunction', 'PhanRedefineFunctionInternal'], - 'htdocs/core/lib/functions2.lib.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/core/lib/pdf.lib.php' => ['PhanTypeMismatchReturnNullable'], + 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanRedefineFunctionInternal'], 'htdocs/core/lib/price.lib.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/lib/website.lib.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/core/modules/DolibarrModules.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/modules/movement/doc/pdf_standard.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull'], - 'htdocs/core/modules/societe/modules_societe.class.php' => ['PhanTypeMismatchReturn'], 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'], 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], @@ -76,17 +59,12 @@ return [ 'htdocs/mrp/class/mo.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/product/admin/product_tools.php' => ['PhanNoopStringLiteral'], 'htdocs/product/class/product.class.php' => ['PhanTypeMismatchReturn'], - 'htdocs/projet/class/project.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/projet/class/projectstats.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/projet/class/task.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/projet/tasks/list.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/public/payment/paymentok.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/societe/class/companybankaccount.class.php' => ['PhanParamSignatureMismatch'], - 'htdocs/stripe/admin/stripe.php' => ['PhanDeprecatedFunction'], 'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/takepos/invoice.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/variants/class/ProductCombination.class.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/website/class/website.class.php' => ['PhanTypeMismatchReturnNullable'], 'internal' => ['PhanUndeclaredConstant'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 4875cd7bafd..01043b3adc3 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -495,7 +495,7 @@ return [ 'PhanPossiblyNullTypeMismatchProperty', 'PhanRedefineClass', 'PhanRedefineFunction', - 'PhanTypeInvalidLeftOperandOfBitwiseOp', + // 'PhanTypeInvalidLeftOperandOfBitwiseOp', // 'PhanTypeMismatchDimAssignment', // 'PhanPluginDescriptionlessCommentOnProtectedMethod', // 'PhanPluginPrintfIncompatibleArgumentTypeWeak', diff --git a/dev/translation/dynamic_translation_keys.lst b/dev/translation/dynamic_translation_keys.lst index 6c62129fae6..47ab2e14a79 100644 --- a/dev/translation/dynamic_translation_keys.lst +++ b/dev/translation/dynamic_translation_keys.lst @@ -31,9 +31,6 @@ CodePaymentTerm IdPaymentTerm LabelPaymentTerm -# ticket -TicketAnswered - # website_template Message Map @@ -43,6 +40,7 @@ Reservation ACCOUNTING_ACCOUNT_CUSTOMER ACCOUNTING_ACCOUNT_CUSTOMER_Desc ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY +ACCOUNTING_ACCOUNT_EXPENSEREPORT ACCOUNTING_ACCOUNT_SUPPLIER ACCOUNTING_ACCOUNT_SUPPLIER_Desc ACCOUNTING_ACCOUNT_SUSPENSE @@ -3685,8 +3683,3 @@ WebPortalSetupPage XSubsriptionErrors YouCanChooseAModelForYouMailContent YouCanMakeSomeInstructionForEmail -helpWithAi -ExtrafieldLinestringGeo -ExtrafieldMultiPointGeo -ExtrafieldPointGeo -ExtrafieldPolygonGeo diff --git a/dev/translation/ignore_translation_keys.lst b/dev/translation/ignore_translation_keys.lst index 173355fe70a..21b8f270427 100644 --- a/dev/translation/ignore_translation_keys.lst +++ b/dev/translation/ignore_translation_keys.lst @@ -39,6 +39,7 @@ FieldsTitle FileIntegrityIsOkButFilesWereAdded FirstUseDate FollowingLinksArePublic +HelpWithAI HidePassword IPP_Device InstallChoiceRecommanded @@ -1025,15 +1026,10 @@ VideoGeneration ## pass - this list needs to be cleaned up ##################################################################### ##################################################################### -$minimum -AI_KEY_API_ AddService AnHelpMessage Analytic AnalyticLabel -BOOKCAL_MYPARAM10 -BOOKCAL_MYPARAM8 -BOOKCAL_MYPARAM9 BankId Bcc Birthdate @@ -1061,9 +1057,6 @@ Facture FailedToConnectToSFTPAfterSSHAuthentication FailedToLogin First -France -Germany -Greece GroupCreate GroupUpdate INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION @@ -1078,7 +1071,6 @@ InputValueIsNotAnNumber InterDate Inventory Code InvoiceReplace -Italy ItemID JobApplications JobPosition @@ -1092,7 +1084,6 @@ LocalTax1IsUsedExample LocalTax2IsNotUsedExample LocalTax2IsUsedExample Logs -Lot/Série MAIN_IMAP_USE_PHPIMAPDesc MYMODULE_CATEGORY_ID_XXX MYMODULE_MYPARAM1 @@ -1138,7 +1129,6 @@ Recruited Ref. Product RefNewContract Societe -Spain Stable Suggested TaskModifieddInDolibarr diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 2f1b22cf778..37f065d1c2e 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -328,6 +328,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { // delete // activate if ($action == $acts[0]) { + $sql = ''; $rowidcol = "rowid"; if ($rowid) { @@ -346,6 +347,7 @@ if ($action == $acts[0]) { // disable if ($action == $acts[1]) { + $sql = ''; $rowidcol = "rowid"; if ($rowid) { @@ -364,6 +366,7 @@ if ($action == $acts[1]) { // favorite if ($action == 'activate_favorite') { + $sql = ''; $rowidcol = "rowid"; if ($rowid) { @@ -382,6 +385,7 @@ if ($action == 'activate_favorite') { // disable favorite if ($action == 'disable_favorite') { + $sql = ''; $rowidcol = "rowid"; if ($rowid) { diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 8cb10b061e5..60c52103254 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -52,6 +52,10 @@ $list_account_main = array( 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', ); +if (isModEnabled('expensereport')) { + $list_account_main[] = 'ACCOUNTING_ACCOUNT_EXPENSEREPORT'; +} + $list_account = array(); $list_account[] = '---Product---'; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 9e6b39a9b00..d716ad9f3a0 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -221,6 +221,7 @@ if ($result) { $account_supplier = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER', 'NotDefined'); // NotDefined is a reserved word $account_customer = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER', 'NotDefined'); // NotDefined is a reserved word $account_employee = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'NotDefined'); // NotDefined is a reserved word + $account_expensereport = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT', 'NotDefined'); // NotDefined is a reserved word $account_pay_vat = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT', 'NotDefined'); // NotDefined is a reserved word $account_pay_donation = getDolGlobalString('DONATION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word $account_pay_subscription = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word @@ -625,6 +626,9 @@ if (!$error && $action == 'writebookkeeping') { $accountingaccountpayment = new AccountingAccount($db); $accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); + $accountingaccountexpensereport = new AccountingAccount($db); + $accountingaccountexpensereport->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true); + $accountingaccountsuspense = new AccountingAccount($db); $accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true); @@ -757,8 +761,8 @@ if (!$error && $action == 'writebookkeeping') { } elseif ($tabtype[$key] == 'payment_expensereport') { $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); - $bookkeeping->label_compte = $accountingaccountpayment->label; + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); + $bookkeeping->label_compte = $accountingaccountexpensereport->label; } elseif ($tabtype[$key] == 'payment_salary') { $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; @@ -1013,7 +1017,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! } elseif ($tabtype[$key] == 'payment') { print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; } elseif ($tabtype[$key] == 'payment_expensereport') { - print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT').'"'.$sep; } elseif ($tabtype[$key] == 'payment_salary') { print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; } else { @@ -1135,7 +1139,8 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1' - || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') { + || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1' + || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSERERPORT') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSERERPORT') == '-1') { print($desc ? '' : '
').'
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); @@ -1294,7 +1299,7 @@ if (empty($action) || $action == 'view') { $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); } if ($tabtype[$key] == 'payment_expensereport') { - $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); } if ($tabtype[$key] == 'payment_salary') { $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 881070ad6fd..077f8f755b1 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -162,7 +162,7 @@ if ($result) { $num = $db->num_rows($result); // Variables - $account_salary = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'NotDefined'); + $account_salary = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT', 'NotDefined'); $account_vat = getDolGlobalString('ACCOUNTING_VAT_BUY_ACCOUNT', 'NotDefined'); $i = 0; @@ -247,7 +247,7 @@ if ($action == 'writebookkeeping' && !$error) { $error = 0; $accountingaccountexpense = new AccountingAccount($db); - $accountingaccountexpense->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); + $accountingaccountexpense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true); foreach ($taber as $key => $val) { // Loop on each expense report $errorforline = 0; @@ -279,7 +279,7 @@ if ($action == 'writebookkeeping' && !$error) { $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); $bookkeeping->label_compte = $accountingaccountexpense->label; $bookkeeping->label_operation = $tabuser[$key]['name']; @@ -590,7 +590,7 @@ if (empty($action) || $action == 'view') { } // Button to write into Ledger - if (!getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') { + if (!getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1') { print '
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); @@ -602,7 +602,7 @@ if (empty($action) || $action == 'view') { if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { print ''; } - if (!getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') { + if (!getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1') { print ''; } else { if ($in_bookkeeping == 'notyet') { @@ -726,7 +726,7 @@ if (empty($action) || $action == 'view') { print "".$expensereportstatic->getNomUrl(1).""; // Account print ""; - $accountoshow = length_accountg(getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT')); + $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT')); if (($accountoshow == "") || $accountoshow == 'NotDefined') { print ''.$langs->trans("MainAccountForUsersNotDefined").''; } else { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c6ce7429708..f71fa705c3f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -560,12 +560,13 @@ class Adherent extends CommonObject * Return translated label by the nature of a adherent (physical or moral) * * @param string $morphy Nature of the adherent (physical or moral) - * @param int $addbadge Add badge (1=Full label, 2=First letters only) + * @param int<0,2> $addbadge Add badge (1=Full label, 2=First letters only) * @return string Label */ public function getmorphylib($morphy = '', $addbadge = 0) { global $langs; + $s = ''; // Clean var if (!$morphy) { @@ -573,7 +574,6 @@ class Adherent extends CommonObject } if ($addbadge) { - $s = ''; $labeltoshowm = $langs->trans("Moral"); $labeltoshowp = $langs->trans("Physical"); if ($morphy == 'phy') { diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index f99b20f86d5..612f408edd9 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -3,6 +3,7 @@ * Copyright (c) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2023 Waël Almoman + * Copyright (C) 2024 MDW * * 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 @@ -168,15 +169,15 @@ class AdherentStats extends Stats /** * Return count of member by status group by adh type, total and average * - * @param int $numberYears Number of years to scan (0 = all) - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type + * @param int $numberYears Number of years to scan (0 = all) + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type */ public function countMembersByTypeAndStatus($numberYears = 0) { global $user; $now = dol_now(); - $endYear = date('Y'); + $endYear = (int) date('Y'); $startYear = $endYear - $numberYears; $sql = "SELECT t.rowid as fk_adherent_type, t.libelle as label"; @@ -224,7 +225,7 @@ class AdherentStats extends Stats 'members_resiliated' => (int) $objp->members_resiliated ); $totalrow = 0; - foreach ($MembersCountArray[$objp->fk_adherent_type] as $key=>$nb) { + foreach ($MembersCountArray[$objp->fk_adherent_type] as $key => $nb) { if ($key != 'label') { $totalrow += $nb; $totalstatus[$key] += $nb; @@ -244,16 +245,17 @@ class AdherentStats extends Stats /** * Return count of member by status group by adh type, total and average * - * @param int $numberYears Number of years to scan (0 = all) - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag + * @param int $numberYears Number of years to scan (0 = all) + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag */ public function countMembersByTagAndStatus($numberYears = 0) { global $user; $now = dol_now(); - $endYear = date('Y'); + $endYear = (int) date('Y'); $startYear = $endYear - $numberYears; + $MembersCountArray = []; $sql = "SELECT c.rowid as fk_categorie, c.label as label"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; @@ -282,7 +284,6 @@ class AdherentStats extends Stats if ($result) { $num = $this->db->num_rows($result); $i = 0; - $MembersCountArray = []; $totalstatus = array( 'label' => 'Total', 'members_draft' => 0, @@ -304,7 +305,7 @@ class AdherentStats extends Stats 'members_resiliated' => (int) $objp->members_resiliated ); $totalrow = 0; - foreach ($MembersCountArray[$objp->fk_categorie] as $key=>$nb) { + foreach ($MembersCountArray[$objp->fk_categorie] as $key => $nb) { if ($key != 'label') { $totalrow += $nb; $totalstatus[$key] += $nb; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index e8d85f21c76..47bded0df29 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -6,6 +6,7 @@ * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2021-2023 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -203,6 +204,7 @@ foreach ($object->fields as $key => $val) { } } $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan //var_dump($arrayfields);exit; // Security check diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d895854ab2c..da9b0271b15 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -13,6 +13,7 @@ * Copyright (C) 2016 Raphaël Doursenaud * Copyright (C) 2019-2022 Frédéric France * Copyright (C) 2020-2022 Open-Dsi + * 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 @@ -2130,6 +2131,11 @@ if ($id > 0) { $canbemodified = 1; } + if ($tabname[$id] == "c_product_nature" && in_array($obj->code, array(0, 1))) { + $canbedisabled = 0; + $canbemodified = 0; + $iserasable = 0; + } // Build Url. The table is id=, the id of line is rowid= $rowidcol = empty($tabrowid[$id]) ? 'rowid' : $tabrowid[$id]; // If rowidcol not defined diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index a9c87ca61a3..14ea98ccc00 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -90,31 +90,31 @@ print ''; if (preg_match('/^fr_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("France")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryFR")).''; print '
  • '; } if (preg_match('/^el_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Greece")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryGR")).''; print '
  • '; } if (preg_match('/^es_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Spain")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryES")).''; print '
  • '; } if (preg_match('/^it_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Italy")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryIT")).''; print '
  • '; } if (preg_match('/^de_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Germany")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("CountryDE")).''; print '
  • '; }*/ print '
  • '; diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 8666a469aee..ed7a57e3af5 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -1548,7 +1548,7 @@ class Asset extends CommonObject $dir = dol_buildpath($reldir."core/modules/asset/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if ($mybool === false) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 702ddb9fb8f..6de866029f7 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -875,7 +875,7 @@ class BOM extends CommonObject $dir = dol_buildpath($reldir."core/modules/bom/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if ($mybool === false) { diff --git a/htdocs/bookcal/admin/setup.php b/htdocs/bookcal/admin/setup.php index dd16dfb720e..5d8a19b9d42 100644 --- a/htdocs/bookcal/admin/setup.php +++ b/htdocs/bookcal/admin/setup.php @@ -71,37 +71,6 @@ $formSetup = new FormSetup($db); // Setup conf BOOKCAL_PUBLIC_INTERFACE_TOPIC $item = $formSetup->newItem('BOOKCAL_PUBLIC_INTERFACE_TOPIC'); $item->defaultFieldValue = 'MyBigCompany public interface for Bookcal'; -/*// Setup conf BOOKCAL_MYPARAM8 -$item = $formSetup->newItem('BOOKCAL_MYPARAM8'); -$TField = array( - 'test01' => $langs->trans('test01'), - 'test02' => $langs->trans('test02'), - 'test03' => $langs->trans('test03'), - 'test04' => $langs->trans('test04'), - 'test05' => $langs->trans('test05'), - 'test06' => $langs->trans('test06'), -); -$item->setAsMultiSelect($TField); -$item->helpText = $langs->transnoentities('BOOKCAL_MYPARAM8'); - - -// Setup conf BOOKCAL_MYPARAM9 -$formSetup->newItem('BOOKCAL_MYPARAM9')->setAsSelect($TField); - - -// Setup conf BOOKCAL_MYPARAM10 -$item = $formSetup->newItem('BOOKCAL_MYPARAM10'); -$item->setAsColor(); -$item->defaultFieldValue = '#FF0000'; -$item->nameText = $item->getNameText().' more html text '; -$item->fieldInputOverride = ''; -$item->helpText = $langs->transnoentities('AnHelpMessage');*/ -//$item->fieldValue = ''; -//$item->fieldAttr = array() ; // fields attribute only for compatible fields like input text -//$item->fieldOverride = false; // set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too -//$item->fieldInputOverride = false; // set this var to override field input -//$item->fieldOutputOverride = false; // set this var to override field output - $setupnotempty = + count($formSetup->items); diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index ad34e08abcd..6a4553e15f2 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -975,7 +975,7 @@ class Availabilities extends CommonObject $dir = dol_buildpath($reldir."core/modules/bookcal/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if ($mybool === false) { diff --git a/htdocs/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php index b66f950fd12..d64aad6791c 100644 --- a/htdocs/bookcal/class/calendar.class.php +++ b/htdocs/bookcal/class/calendar.class.php @@ -964,7 +964,7 @@ class Calendar extends CommonObject $dir = dol_buildpath($reldir."core/modules/bookcal/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if ($mybool === false) { diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index f4f77bcaa9d..09e73b188f8 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1393,7 +1393,7 @@ class ActionComm extends CommonObject * * @param User $user Object user * @param int $load_state_board Load indicator array this->nb - * @return WorkboardResponse|int Return integer <0 if KO, WorkboardResponse if OK + * @return WorkboardResponse|int<-1,1> Return integer <0 if KO, WorkboardResponse if OK */ public function load_board($user, $load_state_board = 0) { @@ -1462,7 +1462,7 @@ class ActionComm extends CommonObject } $this->db->free($resql); - if (empty($load_state_board)) { + if (empty($load_state_board) && $response instanceof WorkboardResponse) { return $response; } else { return 1; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 6eb5db86056..3abd25ae840 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -177,6 +177,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($user->socid && $socid) { diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index aa1e3d0e980..546d40d052d 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2022 ATM Consulting * Copyright (C) 2022 OpenDSI + * Copyright (C) 2024 MDW * * 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 @@ -410,6 +411,7 @@ class Proposals extends DolibarrApi } $errors = []; + $updateRes = 0; $this->db->begin(); foreach ($request_data as $TData) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 97f818d82a3..04b4a6e99b2 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3615,7 +3615,7 @@ class Propal extends CommonObject $dir = dol_buildpath($reldir."core/modules/propale/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if (!$mybool) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 11e5a4adc8c..291ead61cd3 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -416,7 +416,7 @@ class Commande extends CommonOrder $dir = dol_buildpath($reldir."core/modules/commande/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if ($mybool === false) { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e01dd74859e..22703534d89 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -227,6 +227,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); //$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Security check diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 2046845b8db..d9435aea40f 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -231,6 +231,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if (!$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; @@ -1295,6 +1296,7 @@ if ($resql) { // Détail commande if (!empty($arrayfields['rowid']['checked'])) { print_liste_field_titre($arrayfields['rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', $param, '', $sortfield, $sortorder); + '@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan } if (!empty($arrayfields['pr.ref']['checked'])) { print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 480c36cd07e..76a3f8e2abd 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2024 MDW * * 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 @@ -125,6 +126,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $permissiontoadd = $user->hasRight('banque', 'modifier'); $permissiontodelete = $user->hasRight('banque', 'configurer'); diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 8a2aa9178f7..d41e3c2e4a6 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2024 MDW * * 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 @@ -172,6 +173,7 @@ $arrayfields = array( ); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Security check $socid = GETPOSTINT("socid"); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5ddd4d56809..69c113e86d7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3524,11 +3524,15 @@ if ($action == 'create') { setRadioForTypeOfInvoice(); }); function setRadioForTypeOfInvoice() { - console.log("Change radio"); + console.log("Change radio for type of invoice"); if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) { + jQuery("#checkforselects").prop("disabled", true); + jQuery("#checkforselects").prop("checked", false); jQuery(".checkforselect").prop("disabled", true); jQuery(".checkforselect").prop("checked", false); } else { + jQuery("#checkforselects").prop("disabled", false); + jQuery("#checkforselects").prop("checked", true); jQuery(".checkforselect").prop("disabled", false); jQuery(".checkforselect").prop("checked", true); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b3d8b940673..8f5c63a86f0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4609,7 +4609,7 @@ class Facture extends CommonInvoice // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir.$file; + $mybool = ((bool) include_once $dir.$file) || $mybool; } } @@ -4624,7 +4624,7 @@ class Facture extends CommonInvoice // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir.$file; + $mybool = (include_once $dir.$file) || $mybool; } } } diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 63e01dac397..0c5526d0ae9 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -9,6 +9,7 @@ * Copyright (C) 2015-2021 Alexandre Spangaro * Copyright (C) 2016 Meziane Sof * Copyright (C) 2023 William Mead + * Copyright (C) 2024 MDW * * 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 @@ -161,6 +162,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if ($socid > 0) { $tmpthirdparty = new Societe($db); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 13995e6cc0b..63cee7e8709 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -293,6 +293,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if (!$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 2be5b322d69..71496b46c6f 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2011-2016 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -423,7 +424,7 @@ class RemiseCheque extends CommonObject // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir.$file; + $mybool = (include_once $dir.$file) || $mybool; } } @@ -438,7 +439,7 @@ class RemiseCheque extends CommonObject // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir.$file; + $mybool = (include_once $dir.$file) || $mybool; } } } diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 7243c91f3c3..c639acd036e 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2014 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent + * Copyright (C) 2024 MDW * * 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 @@ -99,6 +100,7 @@ $arrayfields = array( 'bc.statut' => array('label' => "Status", 'checked' => 1, 'position' => 70) ); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('chequelist')); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index d60aa17ce3b..921ecddab78 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2021 OpenDsi * Copyright (C) 2023 Joachim Kueter * Copyright (C) 2023 Sylvain Legrand + * Copyright (C) 2024 MDW * * 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 @@ -847,7 +848,7 @@ class Paiement extends CommonObject // Add link to the Direct Debit if invoice refused ('InvoiceRefused') in bank_url if (!$error && $label == '(InvoiceRefused)') { - $result=$acc->add_url_line( + $result = $acc->add_url_line( $bank_line_id, $this->id_prelevement, DOL_URL_ROOT.'/compta/prelevement/card.php?id=', @@ -1182,7 +1183,7 @@ class Paiement extends CommonObject // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir.$file; + $mybool = (include_once $dir.$file) || $mybool; } } @@ -1197,7 +1198,7 @@ class Paiement extends CommonObject // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { - $mybool |= include_once $dir.$file; + $mybool = (include_once $dir.$file) || $mybool; } } } @@ -1352,7 +1353,7 @@ class Paiement extends CommonObject $result .= $linkend; global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 12c2ec797d8..2ae8ee73d74 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -9,6 +9,7 @@ * Copyright (C) 2018-2021 Ferran Marcet * Copyright (C) 2018 Charlene Benke * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2024 MDW * * 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 @@ -110,6 +111,7 @@ $arrayfields = array( 'p.statut' => array('label' => "Status", 'checked' => 1, 'position' => 90, 'enabled' => (getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION'))), ); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('paymentlist')); diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 5f07abd308a..d31e12f575b 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -7,6 +7,7 @@ * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2021-2023 Alexandre Spangaro + * Copyright (C) 2024 MDW * * 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 @@ -114,6 +115,7 @@ if (isModEnabled("bank")) { } $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('sclist')); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 573c3d50289..68e84da8be2 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2011-2019 Alexandre Spangaro * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 MDW * * 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 @@ -95,6 +96,7 @@ if (isModEnabled("bank")) { } $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('salestaxeslist')); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d391b2e8d4b..c7058f80d68 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -12,6 +12,7 @@ * Copyright (C) 2019 Frédéric France * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Open-Dsi + * Copyright (C) 2024 MDW * * 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 @@ -268,6 +269,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); //$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if (($id > 0 || !empty($ref)) && $action != 'add') { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ccd92dccf39..c3e5001b2af 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -337,7 +337,7 @@ class Contrat extends CommonObject $dir = dol_buildpath($reldir."core/modules/contract/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if (!$mybool) { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a9c49bbeaab..43c7b8da85b 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -9,6 +9,7 @@ * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2019 Nicolas Zabouri * Copyright (C) 2021 Alexandre Spangaro + * Copyright (C) 2024 MDW * * 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 @@ -194,6 +195,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if (!$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index a2542669485..c61e72867f2 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -7,6 +7,7 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2019 Juanjo Menent * Copyright (C) 2023-2024 William Mead + * Copyright (C) 2024 MDW * * 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 @@ -139,6 +140,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $permissiontoread = $user->hasRight('contrat', 'lire'); $permissiontoadd = $user->hasRight('contrat', 'creer'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b826ea69205..41a9a69114d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7269,7 +7269,7 @@ abstract class CommonObject if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); - $out = $doleditor->Create(1, '', true, '', '', '', $morecss); + $out = (string) $doleditor->Create(1, '', true, '', '', '', $morecss); } else { $out = ''; } @@ -7277,7 +7277,7 @@ abstract class CommonObject if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, isModEnabled('fckeditor') && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); - $out = $doleditor->Create(1, '', true, '', '', $moreparam, $morecss); + $out = (string) $doleditor->Create(1, '', true, '', '', $moreparam, $morecss); } else { $out = ''; } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 7d369ebe4f4..f5809abbe23 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1452,7 +1452,7 @@ class FormMail extends Form $out = ''; $out .= ''; - //$out .= $form->textwithpicto($langs->trans('helpWithAi'), $langs->trans("YouCanMakeSomeInstructionForEmail")); + //$out .= $form->textwithpicto($langs->trans('HelpWithAI'), $langs->trans("YouCanMakeSomeInstructionForEmail")); $out .= ''; $out .= ''; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 9bbc5e75018..b6f50754c6b 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Charlene Benke * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -686,7 +687,7 @@ class FormProjets extends Form * @param string $morecss Add more css * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $addcombojs 1=Add a js combo - * @return int|string The HTML select list of element or '' if nothing or -1 if KO + * @return int<-1,-1>|string The HTML select list of element or '' if nothing or -1 if KO */ public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '', $noadmininfo = 0, $addcombojs = 0) { @@ -701,6 +702,7 @@ class FormProjets extends Form if ($resql) { $num = $this->db->num_rows($resql); $i = 0; + $sellist = ''; if ($num > 0) { $sellist = ''; + print ' '; if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'integral') { print '
    '; print ''.$langs->trans("CreditOrDebitCard").' - '; diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 3df08fffe53..8e60a9adea9 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -120,6 +120,7 @@ $object = new stdClass(); // For triggers * Actions */ +// None @@ -127,6 +128,10 @@ $object = new stdClass(); // For triggers * View */ +// TODO check if we have redirtodomain to do. +$doactionsthenrediret = 0; + + dol_syslog("Callback url when an online payment is refused or canceled. query_string=".(empty($_SERVER["QUERY_STRING"]) ? '' : $_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"]) ? '' : $_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment'); $tracepost = ""; @@ -165,10 +170,7 @@ if (!empty($_SESSION['ipaddress'])) { // To avoid to make action twice } // Send an email - $sendemail = ''; - if (getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL')) { - $sendemail = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL'); - } + $sendemail = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL'); // Send warning of error to administrator if ($sendemail) { @@ -208,89 +210,99 @@ if (!empty($_SESSION['ipaddress'])) { // To avoid to make action twice unset($_SESSION['ipaddress']); } -$head = ''; -if (getDolGlobalString('ONLINE_PAYMENT_CSS_URL')) { - $head = ''."\n"; -} - -$conf->dol_hide_topmenu = 1; -$conf->dol_hide_leftmenu = 1; - -$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
    ' : '').'
    '; -llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); - - -// Show ko message -print ''."\n"; -print '
    '."\n"; - -// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) -// Define logo and logosmall -$logosmall = $mysoc->logo_small; -$logo = $mysoc->logo; -$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; -if (!empty($conf->global->$paramlogo)) { - $logosmall = getDolGlobalString($paramlogo); -} elseif (getDolGlobalString('ONLINE_PAYMENT_LOGO')) { - $logosmall = getDolGlobalString('ONLINE_PAYMENT_LOGO'); -} -//print ''."\n"; -// Define urllogo -$urllogo = ''; -$urllogofull = ''; -if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { - $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); - $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); -} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { - $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); - $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); -} - -// Output html code for logo -if ($urllogo) { - print '
    '; - print '
    '; - print ''; - print '
    '; - if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { - print ''; +// Show answer page +if (empty($doactionsthenrediret)) { + $head = ''; + if (getDolGlobalString('ONLINE_PAYMENT_CSS_URL')) { + $head = ''."\n"; } - print '
    '; -} -if (getDolGlobalString('MAIN_IMAGE_PUBLIC_PAYMENT')) { - print '
    '; - print ''; - print '
    '; + + $conf->dol_hide_topmenu = 1; + $conf->dol_hide_leftmenu = 1; + + $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
    ' : '').'
    '; + llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); + + + // Show ko message + print ''."\n"; + print '
    '."\n"; + + // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) + // Define logo and logosmall + $logosmall = $mysoc->logo_small; + $logo = $mysoc->logo; + $paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; + if (!empty($conf->global->$paramlogo)) { + $logosmall = getDolGlobalString($paramlogo); + } elseif (getDolGlobalString('ONLINE_PAYMENT_LOGO')) { + $logosmall = getDolGlobalString('ONLINE_PAYMENT_LOGO'); + } + //print ''."\n"; + // Define urllogo + $urllogo = ''; + $urllogofull = ''; + if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + } + + // Output html code for logo + if ($urllogo) { + print '
    '; + print '
    '; + print ''; + print '
    '; + if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { + print ''; + } + print '
    '; + } + if (getDolGlobalString('MAIN_IMAGE_PUBLIC_PAYMENT')) { + print '
    '; + print ''; + print '
    '; + } + + + print '

    '; + + + print $langs->trans("YourPaymentHasNotBeenRecorded")."

    "; + + $key = 'ONLINE_PAYMENT_MESSAGE_KO'; + if (!empty($conf->global->$key)) { + print $conf->global->$key; + } + + $type = GETPOST('s', 'alpha'); + $ref = GETPOST('ref', 'alphanohtml'); + $tag = GETPOST('tag', 'alpha'); + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + if ($type || $tag) { + $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type : 'free'), $ref, $FinalPaymentAmt, $tag); + + print $langs->trans("ClickHereToTryAgain", $urlsubscription); + } + + print "\n
    \n"; + + + htmlPrintOnlineFooter($mysoc, $langs, 0, $suffix); + + llxFooter('', 'public'); } -print '

    '; - - -print $langs->trans("YourPaymentHasNotBeenRecorded")."

    "; - -$key = 'ONLINE_PAYMENT_MESSAGE_KO'; -if (!empty($conf->global->$key)) { - print $conf->global->$key; -} - -$type = GETPOST('s', 'alpha'); -$ref = GETPOST('ref', 'alphanohtml'); -$tag = GETPOST('tag', 'alpha'); -require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; -if ($type || $tag) { - $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type : 'free'), $ref, $FinalPaymentAmt, $tag); - - print $langs->trans("ClickHereToTryAgain", $urlsubscription); -} - -print "\n
    \n"; - - -htmlPrintOnlineFooter($mysoc, $langs, 0, $suffix); - - -llxFooter('', 'public'); - $db->close(); + + +// If option to do a redirect somewhere else is defined. +if (empty($doactionsthenrediret)) { + // Do the redirect to an error page + // TODO +} diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 4e1c12dc196..4a6c958ba9a 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -159,15 +159,13 @@ $error = 0; /* - * Actions + * Actions and view */ +// TODO check if we have redirtodomain to do. +$doactionsthenrediret = 0; -/* - * View - */ - $now = dol_now(); dol_syslog("Callback url when a payment was done. query_string=".(empty($_SERVER["QUERY_STRING"]) ? '' : dol_escape_htmltag($_SERVER["QUERY_STRING"]))." script_uri=".(empty($_SERVER["SCRIPT_URI"]) ? '' : dol_escape_htmltag($_SERVER["SCRIPT_URI"])), LOG_DEBUG, 0, '_payment'); @@ -197,59 +195,64 @@ if (getDolGlobalString('ONLINE_PAYMENT_CSS_URL')) { $conf->dol_hide_topmenu = 1; $conf->dol_hide_leftmenu = 1; -$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
    ' : '').'
    '; -llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); + +// Show header +if (empty($doactionsthenrediret)) { + $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
    ' : '').'
    '; + llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); -// Show message -print ''."\n"; -print '
    '."\n"; + // Show page content id="dolpaymentdiv" + print ''."\n"; + print '
    '."\n"; -// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) -// Define logo and logosmall -$logosmall = $mysoc->logo_small; -$logo = $mysoc->logo; -$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; -if (!empty($conf->global->$paramlogo)) { - $logosmall = getDolGlobalString($paramlogo); -} elseif (getDolGlobalString('ONLINE_PAYMENT_LOGO')) { - $logosmall = getDolGlobalString('ONLINE_PAYMENT_LOGO'); -} -//print ''."\n"; -// Define urllogo -$urllogo = ''; -$urllogofull = ''; -if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { - $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); - $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); -} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { - $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); - $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); -} - -// Output html code for logo -if ($urllogo) { - print '
    '; - print '
    '; - print ''; - print '
    '; - if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { - print ''; + // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) + // Define logo and logosmall + $logosmall = $mysoc->logo_small; + $logo = $mysoc->logo; + $paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; + if (!empty($conf->global->$paramlogo)) { + $logosmall = getDolGlobalString($paramlogo); + } elseif (getDolGlobalString('ONLINE_PAYMENT_LOGO')) { + $logosmall = getDolGlobalString('ONLINE_PAYMENT_LOGO'); } - print '
    '; -} -if (getDolGlobalString('MAIN_IMAGE_PUBLIC_PAYMENT')) { - print '
    '; - print ''; - print '
    '; + //print ''."\n"; + // Define urllogo + $urllogo = ''; + $urllogofull = ''; + if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + } + + // Output html code for logo + if ($urllogo) { + print '
    '; + print '
    '; + print ''; + print '
    '; + if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { + print ''; + } + print '
    '; + } + if (getDolGlobalString('MAIN_IMAGE_PUBLIC_PAYMENT')) { + print '
    '; + print ''; + print '
    '; + } + + + print '


    '; } -print '


    '; - - +// Validate the payment (for payment mode that need another step after the callback return for this). if (isModEnabled('paypal')) { if ($paymentmethod === 'paypal') { // We call this page only if payment is ok on payment system if ($PAYPALTOKEN) { @@ -391,7 +394,7 @@ dol_syslog("ispaymentok=".$ispaymentok." tmptag=".var_export($tmptag, true), LOG $appli = $mysoc->name; -// Make complementary actions +// Make complementary actions (post payment actions if payment is ok) $ispostactionok = 0; $postactionmessages = array(); if ($ispaymentok) { @@ -1821,7 +1824,6 @@ if ($ispaymentok) { } } - if ($ispaymentok) { // Get on url call $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION['onlinetoken'] : $PAYPALTOKEN; @@ -1847,18 +1849,39 @@ if ($ispaymentok) { $error++; } } +} - print $langs->trans("YourPaymentHasBeenRecorded")."
    \n"; - if ($TRANSACTIONID) { - print $langs->trans("ThisIsTransactionId", $TRANSACTIONID)."

    \n"; + +// Show result message +if (empty($doactionsthenrediret)) { + if ($ispaymentok) { + print $langs->trans("YourPaymentHasBeenRecorded")."
    \n"; + if ($TRANSACTIONID) { + print $langs->trans("ThisIsTransactionId", $TRANSACTIONID)."

    \n"; + } + + // Show a custom message + $key = 'ONLINE_PAYMENT_MESSAGE_OK'; + if (getDolGlobalString($key)) { + print '
    '; + print getDolGlobalString($key); + } + } else { + print $langs->trans('DoExpressCheckoutPaymentAPICallFailed')."
    \n"; + print $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
    \n"; + print $langs->trans('ShortErrorMessage').": ".$ErrorShortMsg."
    \n"; + print $langs->trans('ErrorCode').": ".$ErrorCode."
    \n"; + print $langs->trans('ErrorSeverityCode').": ".$ErrorSeverityCode."
    \n"; + + if ($mysoc->email) { + print "\nPlease, send a screenshot of this page to ".$mysoc->email."
    \n"; + } } +} - $key = 'ONLINE_PAYMENT_MESSAGE_OK'; - if (!empty($conf->global->$key)) { - print '
    '; - print $conf->global->$key; - } +// Send email +if ($ispaymentok) { $sendemail = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL'); $tmptag = dolExplodeIntoArray($fulltag, '.', '='); @@ -1954,6 +1977,8 @@ if ($ispaymentok) { } } } else { + $sendemail = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL'); + // Get on url call $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION['onlinetoken'] : $PAYPALTOKEN; $payerID = empty($PAYPALPAYERID) ? $_SESSION['payerID'] : $PAYPALPAYERID; @@ -1971,29 +1996,6 @@ if ($ispaymentok) { // End call triggers } - print $langs->trans('DoExpressCheckoutPaymentAPICallFailed')."
    \n"; - print $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
    \n"; - print $langs->trans('ShortErrorMessage').": ".$ErrorShortMsg."
    \n"; - print $langs->trans('ErrorCode').": ".$ErrorCode."
    \n"; - print $langs->trans('ErrorSeverityCode').": ".$ErrorSeverityCode."
    \n"; - - if ($mysoc->email) { - print "\nPlease, send a screenshot of this page to ".$mysoc->email."
    \n"; - } - - $sendemail = ''; - if (getDolGlobalString('PAYMENTONLINE_SENDEMAIL')) { - $sendemail = getDolGlobalString('PAYMENTONLINE_SENDEMAIL'); - } - // TODO Remove local option to keep only the generic one ? - if ($paymentmethod == 'paypal' && getDolGlobalString('PAYPAL_PAYONLINE_SENDEMAIL')) { - $sendemail = getDolGlobalString('PAYPAL_PAYONLINE_SENDEMAIL'); - } elseif ($paymentmethod == 'paybox' && getDolGlobalString('PAYBOX_PAYONLINE_SENDEMAIL')) { - $sendemail = getDolGlobalString('PAYBOX_PAYONLINE_SENDEMAIL'); - } elseif ($paymentmethod == 'stripe' && getDolGlobalString('STRIPE_PAYONLINE_SENDEMAIL')) { - $sendemail = getDolGlobalString('STRIPE_PAYONLINE_SENDEMAIL'); - } - // Send warning of error to administrator if ($sendemail) { $companylangs = new Translate('', $conf); @@ -2036,19 +2038,37 @@ if ($ispaymentok) { } -print "\n
    \n"; - -print "\n"; - - -htmlPrintOnlineFooter($mysoc, $langs, 0, $suffix); - - // Clean session variables to avoid duplicate actions if post is resent unset($_SESSION["FinalPaymentAmt"]); unset($_SESSION["TRANSACTIONID"]); -llxFooter('', 'public'); +// Close page content id="dolpaymentdiv" +if (empty($doactionsthenrediret)) { + print "\n
    \n"; + + print "\n"; +} + + +// Show footer +if (empty($doactionsthenrediret)) { + htmlPrintOnlineFooter($mysoc, $langs, 0, $suffix); + + llxFooter('', 'public'); +} + $db->close(); + + +// If option to do a redirect somewhere else. +if (empty($doactionsthenrediret)) { + if ($ispaymentok) { + // Do the redirect to a success page + // TODO + } else { + // Do the redirect to an error page + // TODO + } +} diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index b3362854db6..28e7c1933f4 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1825,7 +1825,7 @@ if ($action == 'create') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; $sql .= " WHERE e.entity IN (".getEntity('reception').")"; $sql .= " AND obj.fk_commande = ".((int) $origin_id); - $sql .= " AND obj.rowid = ed.fk_commandefourndet"; + $sql .= " AND obj.rowid = ed.fk_elementdet"; $sql .= " AND ed.fk_reception = e.rowid"; $sql .= " AND ed.fk_reception !=".((int) $object->id); //if ($filter) $sql.= $filter; diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 8ba93145914..b91c791bb9d 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -180,7 +180,7 @@ class Reception extends CommonObject $dir = dol_buildpath($reldir."core/modules/reception/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if (!$mybool) { @@ -562,7 +562,7 @@ class Reception extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; $sql .= " ".MAIN_DB_PREFIX."receptiondet_batch as ed"; $sql .= " WHERE ed.fk_reception = ".((int) $this->id); - $sql .= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " AND cd.rowid = ed.fk_elementdet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); $resql = $this->db->query($sql); @@ -747,7 +747,7 @@ class Reception extends CommonObject $qty_wished = array(); $supplierorderdispatch = new CommandeFournisseurDispatch($this->db); - $filter = array('t.fk_commande' => $this->origin_id); + $filter = array('t.fk_element' => $this->origin_id); if (getDolGlobalInt('SUPPLIER_ORDER_USE_DISPATCH_STATUS')) { $filter['t.status'] = 1; // Restrict to lines with status validated } @@ -1071,7 +1071,7 @@ class Reception extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; $sql .= " ".MAIN_DB_PREFIX."receptiondet_batch as ed"; $sql .= " WHERE ed.fk_reception = ".((int) $this->id); - $sql .= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " AND cd.rowid = ed.fk_elementdet"; dol_syslog(get_class($this)."::delete select details", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1660,7 +1660,7 @@ class Reception extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; $sql .= " ".MAIN_DB_PREFIX."receptiondet_batch as ed"; $sql .= " WHERE ed.fk_reception = ".((int) $this->id); - $sql .= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " AND cd.rowid = ed.fk_elementdet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1818,7 +1818,7 @@ class Reception extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; $sql .= " ".MAIN_DB_PREFIX."receptiondet_batch as ed"; $sql .= " WHERE ed.fk_reception = ".((int) $this->id); - $sql .= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " AND cd.rowid = ed.fk_elementdet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1952,7 +1952,7 @@ class Reception extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; $sql .= " ".MAIN_DB_PREFIX."receptiondet_batch as ed"; $sql .= " WHERE ed.fk_reception = ".((int) $this->id); - $sql .= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " AND cd.rowid = ed.fk_elementdet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/reception/class/receptionlinebatch.class.php b/htdocs/reception/class/receptionlinebatch.class.php new file mode 100644 index 00000000000..81f93a32f37 --- /dev/null +++ b/htdocs/reception/class/receptionlinebatch.class.php @@ -0,0 +1,754 @@ + + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Christophe Battarel + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/fourn/class/fournisseur.commande.dispatch.class.php + * \ingroup fournisseur stock + * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * Initially built by build_class_from_table on 2015-02-24 10:38 + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; +require_once DOL_DOCUMENT_ROOT."/reception/class/reception.class.php"; + + +/** + * Class to manage table commandefournisseurdispatch + */ +class ReceptionLineBatch extends CommonObjectLine +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error code (or message) + */ + public $error; + + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); + + /** + * @var string ID to identify managed object + */ + public $element = 'receptionlinebatch'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'receptiondet_batch'; //!< Name of table without prefix where object is stored + public $lines = array(); + + /** + * @var int ID + */ + public $id; + + /** + * @var int ID + */ + public $fk_element; + + /** + * @var int ID + */ + public $fk_product; + + /** + * @var int ID + */ + public $fk_elementdet; + + public $fk_reception; + + + public $qty; + public $qty_asked; + + public $libelle; + public $label; + public $desc; + public $tva_tx; + public $vat_src_code; + public $ref_supplier; + + /** + * @var int ID + */ + public $fk_entrepot; + + /** + * @var int User ID + */ + public $fk_user; + + public $datec = ''; + public $comment; + + /** + * @var int Status + */ + public $status; + + public $batch; + public $eatby = ''; + public $sellby = ''; + public $cost_price = 0; + + + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + + // List of language codes for status + $this->labelStatus[0] = 'Received'; + $this->labelStatus[1] = 'Verified'; + $this->labelStatus[2] = 'Denied'; + $this->labelStatusShort[0] = 'Received'; + $this->labelStatusShort[1] = 'Verified'; + $this->labelStatusShort[2] = 'Denied'; + } + + + /** + * Create object into database + * + * @param User $user User that creates + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs, $hookmanager; + $error = 0; + + // Clean parameters + + if (isset($this->fk_element)) { + $this->fk_element = (int) $this->fk_element; + } + if (isset($this->fk_product)) { + $this->fk_product = (int) $this->fk_product; + } + if (isset($this->fk_elementdet)) { + $this->fk_elementdet = (int) $this->fk_elementdet; + } + if (isset($this->qty)) { + $this->qty = trim($this->qty); + } + if (isset($this->fk_entrepot)) { + $this->fk_entrepot = (int) $this->fk_entrepot; + } + if (isset($this->fk_user)) { + $this->fk_user = (int) $this->fk_user; + } + if (isset($this->comment)) { + $this->comment = trim($this->comment); + } + if (isset($this->status)) { + $this->status = (int) $this->status; + } + if (isset($this->batch)) { + $this->batch = trim($this->batch); + } + if (empty($this->datec)) { + $this->datec = dol_now(); + } + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; + $sql .= "fk_element,"; + $sql .= "fk_product,"; + $sql .= "fk_elementdet,"; + $sql .= "qty,"; + $sql .= "fk_entrepot,"; + $sql .= "fk_user,"; + $sql .= "datec,"; + $sql .= "comment,"; + $sql .= "status,"; + $sql .= "batch,"; + $sql .= "eatby,"; + $sql .= "sellby,"; + $sql .= "fk_reception,"; + $sql .= "cost_price"; + + + $sql .= ") VALUES ("; + $sql .= " ".(!isset($this->fk_element) ? 'NULL' : "'".$this->db->escape($this->fk_element)."'").","; + $sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").","; + $sql .= " ".(!isset($this->fk_elementdet) ? 'NULL' : "'".$this->db->escape($this->fk_elementdet)."'").","; + $sql .= " ".(!isset($this->qty) ? 'NULL' : "'".$this->db->escape($this->qty)."'").","; + $sql .= " ".(!isset($this->fk_entrepot) ? 'NULL' : "'".$this->db->escape($this->fk_entrepot)."'").","; + $sql .= " ".(!isset($this->fk_user) ? 'NULL' : "'".$this->db->escape($this->fk_user)."'").","; + $sql .= " ".(!isset($this->datec) || dol_strlen($this->datec) == 0 ? 'NULL' : "'".$this->db->idate($this->datec)."'").","; + $sql .= " ".(!isset($this->comment) ? 'NULL' : "'".$this->db->escape($this->comment)."'").","; + $sql .= " ".(!isset($this->status) ? 'NULL' : "'".$this->db->escape($this->status)."'").","; + $sql .= " ".(!isset($this->batch) ? 'NULL' : "'".$this->db->escape($this->batch)."'").","; + $sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").","; + $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").","; + $sql .= " ".(!isset($this->fk_reception) ? 'NULL' : "'".$this->db->escape($this->fk_reception)."'").","; + $sql .= " ".(!isset($this->cost_price) ? '0' : "'".$this->db->escape($this->cost_price)."'"); + $sql .= ")"; + + $this->db->begin(); + + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } + + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + + if (!$notrigger) { + // Call triggers + $result = $this->call_trigger('LINERECEPTION_CREATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + } + + // Create extrafields + if (!$error) { + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; + } + } + + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int Return integer <0 if KO, >0 if OK + */ + public function fetch($id, $ref = '') + { + global $langs; + $sql = "SELECT"; + $sql .= " t.rowid,"; + + $sql .= " t.fk_element,"; + $sql .= " t.fk_product,"; + $sql .= " t.fk_elementdet,"; + $sql .= " t.qty,"; + $sql .= " t.fk_entrepot,"; + $sql .= " t.fk_user,"; + $sql .= " t.datec,"; + $sql .= " t.comment,"; + $sql .= " t.status,"; + $sql .= " t.tms,"; + $sql .= " t.batch,"; + $sql .= " t.eatby,"; + $sql .= " t.sellby,"; + $sql .= " t.fk_reception"; + + + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + if ($ref) { + $sql .= " WHERE t.ref = '".$this->db->escape($ref)."'"; + } else { + $sql .= " WHERE t.rowid = ".((int) $id); + } + + dol_syslog(get_class($this)."::fetch"); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->fk_element = $obj->fk_element; + $this->fk_product = $obj->fk_product; + $this->fk_elementdet = $obj->fk_elementdet; + $this->qty = $obj->qty; + $this->fk_entrepot = $obj->fk_entrepot; + $this->fk_user = $obj->fk_user; + $this->datec = $this->db->jdate($obj->datec); + $this->comment = $obj->comment; + $this->status = $obj->status; + $this->tms = $this->db->jdate($obj->tms); + $this->batch = $obj->batch; + $this->eatby = $this->db->jdate($obj->eatby); + $this->sellby = $this->db->jdate($obj->sellby); + $this->fk_reception = $obj->fk_reception; + + $this->fetch_optionals(); + } + $this->db->free($resql); + + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update object into database + * + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + $error = 0; + + // Clean parameters + + if (isset($this->fk_element)) { + $this->fk_element = (int) $this->fk_element; + } + if (isset($this->fk_product)) { + $this->fk_product = (int) $this->fk_product; + } + if (isset($this->fk_elementdet)) { + $this->fk_elementdet = (int) $this->fk_elementdet; + } + if (isset($this->qty)) { + $this->qty = trim($this->qty); + } + if (isset($this->fk_entrepot)) { + $this->fk_entrepot = (int) $this->fk_entrepot; + } + if (isset($this->fk_user)) { + $this->fk_user = (int) $this->fk_user; + } + if (isset($this->comment)) { + $this->comment = trim($this->comment); + } + if (isset($this->status)) { + $this->status = (int) $this->status; + } + if (isset($this->batch)) { + $this->batch = trim($this->batch); + } + + + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; + $sql .= " fk_element=".(isset($this->fk_element) ? $this->fk_element : "null").","; + $sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").","; + $sql .= " fk_elementdet=".(isset($this->fk_elementdet) ? $this->fk_elementdet : "null").","; + $sql .= " qty=".(isset($this->qty) ? $this->qty : "null").","; + $sql .= " fk_entrepot=".(isset($this->fk_entrepot) ? $this->fk_entrepot : "null").","; + $sql .= " fk_user=".(isset($this->fk_user) ? $this->fk_user : "null").","; + $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql .= " comment=".(isset($this->comment) ? "'".$this->db->escape($this->comment)."'" : "null").","; + $sql .= " status=".(isset($this->status) ? $this->status : "null").","; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " batch=".(isset($this->batch) ? "'".$this->db->escape($this->batch)."'" : "null").","; + $sql .= " eatby=".(dol_strlen($this->eatby) != 0 ? "'".$this->db->idate($this->eatby)."'" : 'null').","; + $sql .= " sellby=".(dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null'); + $sql .= " WHERE rowid=".((int) $this->id); + + $this->db->begin(); + + dol_syslog(__METHOD__); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } + + if (!$error) { + if (!$error) { + if (empty($this->id) && !empty($this->rowid)) { + $this->id = $this->rowid; + } + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; + } + } + + if (!$notrigger) { + // Call triggers + $result = $this->call_trigger('LINERECEPTION_MODIFY', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + } + + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK + */ + public function delete($user, $notrigger = 0) + { + $error = 0; + + $this->db->begin(); + + if (!$error) { + if (!$notrigger) { + // Call triggers + $result = $this->call_trigger('LINERECEPTION_DELETE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + } + + // Remove extrafields + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this)."::delete error deleteExtraFields ".$this->error, LOG_ERR); + } + } + + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE rowid=".((int) $this->id); + + dol_syslog(__METHOD__); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } + + + /** + * Load an object from its id and create a new one in database + * + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromClone(User $user, $fromid) + { + $error = 0; + + $object = new ReceptionLineBatch($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + $object->id = 0; + $object->statut = 0; + + // Clear fields + // ... + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->create($user); + + // Other options + if ($result < 0) { + $this->error = $object->error; + $error++; + } + + if (!$error) { + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object->id; + } else { + $this->db->rollback(); + return -1; + } + } + + + + /** + * Return label of the status of object + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto + * @return string Label + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of a status + * + * @param int $status Id status + * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; + $langs->load('orders'); + + if ($mode == 0) { + return $langs->trans($this->labelStatus[$status]); + } elseif ($mode == 1) { + return $langs->trans($this->labelStatusShort[$status]); + } elseif ($mode == 2) { + return $langs->trans($this->labelStatus[$status]); + } elseif ($mode == 3) { + if ($status == 0) { + return img_picto($langs->trans($this->labelStatus[$status]), 'statut0'); + } elseif ($status == 1) { + return img_picto($langs->trans($this->labelStatus[$status]), 'statut4'); + } elseif ($status == 2) { + return img_picto($langs->trans($this->labelStatus[$status]), 'statut8'); + } + } elseif ($mode == 4) { + if ($status == 0) { + return img_picto($langs->trans($this->labelStatus[$status]), 'statut0').' '.$langs->trans($this->labelStatus[$status]); + } elseif ($status == 1) { + return img_picto($langs->trans($this->labelStatus[$status]), 'statut4').' '.$langs->trans($this->labelStatus[$status]); + } elseif ($status == 2) { + return img_picto($langs->trans($this->labelStatus[$status]), 'statut8').' '.$langs->trans($this->labelStatus[$status]); + } + } elseif ($mode == 5) { + if ($status == 0) { + return ''.$langs->trans($this->labelStatusShort[$status]).' '.img_picto($langs->trans($this->labelStatus[$status]), 'statut0'); + } elseif ($status == 1) { + return ''.$langs->trans($this->labelStatusShort[$status]).' '.img_picto($langs->trans($this->labelStatus[$status]), 'statut4'); + } elseif ($status == 2) { + return ''.$langs->trans($this->labelStatusShort[$status]).' '.img_picto($langs->trans($this->labelStatus[$status]), 'statut8'); + } + } + return ""; + } + + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return int + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->fk_element = 0; + $this->fk_product = 0; + $this->fk_elementdet = 0; + $this->qty = ''; + $this->fk_entrepot = 0; + $this->fk_user = 0; + $this->datec = ''; + $this->comment = ''; + $this->status = 0; + $this->tms = dol_now(); + $this->batch = ''; + $this->eatby = ''; + $this->sellby = ''; + + return 1; + } + + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset offset limit + * @param string|array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * @return int Return integer <0 if KO, >0 if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = "SELECT"; + $sql .= " t.rowid,"; + $sql .= " t.fk_element,"; + $sql .= " t.fk_product,"; + $sql .= " t.fk_elementdet,"; + $sql .= " t.qty,"; + $sql .= " t.fk_entrepot,"; + $sql .= " t.fk_user,"; + $sql .= " t.datec,"; + $sql .= " t.comment,"; + $sql .= " t.status,"; + $sql .= " t.tms,"; + $sql .= " t.batch,"; + $sql .= " t.eatby,"; + $sql .= " t.sellby"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + + // Manage filter + if (is_array($filter)) { + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.comment') { + $sqlwhere [] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'"; + } elseif ($key == 't.datec' || $key == 't.tms' || $key == 't.eatby' || $key == 't.sellby' || $key == 't.batch') { + $sqlwhere [] = $this->db->sanitize($key)." = '".$this->db->escape($value)."'"; + } elseif ($key == 'qty') { + $sqlwhere [] = $this->db->sanitize($key)." = ".((float) $value); + } else { + $sqlwhere [] = $this->db->sanitize($key)." = ".((int) $value); + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + } + + $filter = ''; + } + + // Manage filter + $errormessage = ''; + $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage); + if ($errormessage) { + $this->errors[] = $errormessage; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + return -1; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= $this->db->plimit($limit, $offset); + } + $this->lines = array(); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $line = new self($this->db); + + $line->id = $obj->rowid; + + $line->fk_element = $obj->fk_element; + $line->fk_product = $obj->fk_product; + $line->fk_elementdet = $obj->fk_elementdet; + $line->qty = $obj->qty; + $line->fk_entrepot = $obj->fk_entrepot; + $line->fk_user = $obj->fk_user; + $line->datec = $this->db->jdate($obj->datec); + $line->comment = $obj->comment; + $line->status = $obj->status; + $line->tms = $this->db->jdate($obj->tms); + $line->batch = $obj->batch; + $line->eatby = $this->db->jdate($obj->eatby); + $line->sellby = $this->db->jdate($obj->sellby); + $line->fetch_optionals(); + + $this->lines[$line->id] = $line; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + + return -1; + } + } +} diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php index b48ea7b4164..3d2ed4bd36c 100644 --- a/htdocs/reception/dispatch.php +++ b/htdocs/reception/dispatch.php @@ -462,7 +462,7 @@ if ($id > 0 || !empty($ref)) { $products_dispatched = array(); $sql = "SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty"; $sql .= " FROM ".MAIN_DB_PREFIX."receptiondet_batch as cfd"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."receptiondet_batch as l on l.rowid = cfd.fk_elementdet"; $sql .= " WHERE cfd.fk_reception = ".((int) $object->id); $sql .= " GROUP BY l.rowid, cfd.fk_product"; @@ -690,8 +690,8 @@ if ($id > 0 || !empty($ref)) { $sql = "SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product"; $sql .= " FROM ".MAIN_DB_PREFIX."receptiondet_batch as cfd"; // commande_fournisseur_dispatch should be named receptiondet_batch $sql .= " WHERE cfd.fk_reception = ".((int) $object->id); - $sql .= " AND cfd.fk_commande = ".((int) $objectsrc->id); - $sql .= " AND cfd.fk_commandefourndet = ".(int) $objp->rowid; + $sql .= " AND cfd.fk_element = ".((int) $objectsrc->id); + $sql .= " AND cfd.fk_elementdet = ".(int) $objp->rowid; //print $sql; $resultsql = $db->query($sql); diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 20b9262923f..e30f152fc61 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -140,6 +140,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $error = 0; diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index f80911e4381..59c152cac47 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -953,7 +953,7 @@ class RecruitmentCandidature extends CommonObject $dir = dol_buildpath($reldir."core/modules/recruitment/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if ($mybool === false) { diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 90fe44b212d..dbc9e11cce1 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -1010,7 +1010,7 @@ class RecruitmentJobPosition extends CommonObject $dir = dol_buildpath($reldir."core/modules/recruitment/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if ($mybool === false) { diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 33f21aa75bb..7f09a9d6b3a 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2024 William Mead + * Copyright (C) 2024 MDW * * 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 @@ -157,6 +158,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -703,7 +705,7 @@ if ($num == 0) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 498b869c92b..73fdb35e5af 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -319,6 +319,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Security check $socid = GETPOSTINT('socid'); diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index e79ccda49a0..4962c150888 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -260,7 +260,7 @@ if ($result > 0) { // Add notification form //print load_fiche_titre($titlelist.' ('.$num.')', '', ''); $num = $nbtotalofrecords; - print_barre_liste($titlelist, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, empty($nbtotalofrecords) ? -1 : $nbtotalofrecords, 'email', 0, $newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($titlelist, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, (empty($nbtotalofrecords) ? -1 : $nbtotalofrecords), 'email', 0, $newcardbutton, '', $limit, 0, 0, 1); print '
    '; print ''; diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index d5a27ba20fb..919e80088c6 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -4,6 +4,7 @@ * Copyright (C) 2017 Saasprov * Copyright (C) 2018-2022 Thibault FOUCART * Copyright (C) 2018 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -256,6 +257,7 @@ if (empty($conf->stripeconnect->enabled)) { } } $endpoint->url = $url; + // @phan-suppress-next-line PhanDeprecatedFunction $endpoint->save(); if ($endpoint->status == 'enabled') { @@ -328,6 +330,7 @@ if (empty($conf->stripeconnect->enabled)) { } } $endpoint->url = $url; + // @phan-suppress-next-line PhanDeprecatedFunction $endpoint->save(); if ($endpoint->status == 'enabled') { print ''; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index fee21d4365b..503f99b65aa 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2429,7 +2429,7 @@ class SupplierProposal extends CommonObject $dir = dol_buildpath($reldir."core/modules/supplier_proposal/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if (!$mybool) { diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index c34a60b581b..f6c08d20e4b 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -12,6 +12,7 @@ * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018-2023 Charlene Benke * Copyright (C) 2021 Alexandre Spangaro + * Copyright (C) 2024 MDW * * 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 @@ -197,6 +198,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if (!$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index b4541b45715..952b2d8a7ad 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -74,7 +74,6 @@ if ($setcurrency != "") { // We will recalculate amount for foreign currency at next call of invoice.php when $_SESSION["takeposcustomercurrency"] differs from invoice->multicurrency_code. } -$_SESSION["urlfrom"] = '/takepos/index.php'; $langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter", "banks")); @@ -959,11 +958,11 @@ function OpenDrawer(){ } function DolibarrOpenDrawer() { - console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=&term="); + console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&token=&term="); $.ajax({ type: "GET", data: { token: '' }, - url: "", + url: "", }); } @@ -1037,8 +1036,8 @@ $( document ).ready(function() { LoadProducts(0); Refresh(); 0 ? getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) : ''; +$keyCodeForEnter = ''; +if (!empty($_SESSION['takeposterminal'])) { + $keyCodeForEnter = getDolGlobalInt('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) > 0 ? getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']) : ''; +} ?> @@ -1416,7 +1422,7 @@ if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('T $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".((int) $conf->entity)." AND "; -$sql .= " posnumber = ".((int) $_SESSION["takeposterminal"])." AND "; +$sql .= " posnumber = ".((int) empty($_SESSION["takeposterminal"]) ? 0 : $_SESSION["takeposterminal"])." AND "; $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; $resql = $db->query($sql); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 1d2430e5d55..2592d778715 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1840,8 +1840,11 @@ if ($placeid > 0) { $sql .= " AND ps.fk_product = ".((int) $line->fk_product); $resql = $db->query($sql); if ($resql) { + $stock_real = 0; $obj = $db->fetch_object($resql); - $stock_real = price2num($obj->reel, 'MS'); + if ($obj) { + $stock_real = price2num($obj->reel, 'MS'); + } $htmlforlines .= $line->qty; if ($line->qty && $line->qty > $stock_real) { $htmlforlines .= ''; diff --git a/htdocs/user/list.php b/htdocs/user/list.php index e55dc5ea1bc..65955a4c39f 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -151,6 +151,7 @@ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Init search fields $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 75f2fa6f069..be39b2fda02 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -72,7 +72,7 @@ if ($reshook < 0) { } // Define url to go after disconnect -$urlfrom = empty($_SESSION["urlfrom"]) ? '' : $_SESSION["urlfrom"]; +$urlfrom = empty($_SESSION["urlfrom"]) ? GETPOST('urlfrom') : $_SESSION["urlfrom"]; // Define url to go $url = DOL_URL_ROOT."/index.php"; // By default go to login page diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php index 0bee01ba154..8c2a486c322 100644 --- a/htdocs/variants/list.php +++ b/htdocs/variants/list.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Open-Dsi + * Copyright (C) 2024 MDW * * 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 @@ -97,7 +98,7 @@ foreach ($object->fields as $key => $val) { $fieldstosearchall['t.'.$key] = $val['label']; } } -$parameters = array('fieldstosearchall'=>$fieldstosearchall); +$parameters = array('fieldstosearchall' => $fieldstosearchall); $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']; @@ -112,11 +113,11 @@ foreach ($object->fields as $key => $val) { if (!empty($val['visible'])) { $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && (int) dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' + 'label' => $val['label'], + 'checked' => (($visible < 0) ? 0 : 1), + 'enabled' => (abs($visible) != 3 && (int) dol_eval($val['enabled'], 1)), + 'position' => $val['position'], + 'help' => isset($val['help']) ? $val['help'] : '' ); } } @@ -139,6 +140,7 @@ $arrayfields['nb_products'] = array( $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $permissiontoread = $user->hasRight('variants', 'read'); $permissiontoadd = $user->hasRight('variants', 'write'); @@ -459,8 +461,8 @@ print ''; print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/variants/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); @@ -561,7 +563,7 @@ foreach ($object->fields as $key => $val) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -618,7 +620,7 @@ foreach ($object->fields as $key => $val) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -757,7 +759,7 @@ while ($i < $imaxinloop) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Other @@ -826,7 +828,7 @@ if ($num == 0) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index ef405bfadea..abd25cd844e 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -901,7 +901,7 @@ class Target extends CommonObject $dir = dol_buildpath($reldir."core/modules/webhook/"); // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } if ($mybool === false) { diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index bd5e25f1932..e8d198f61b3 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1868,6 +1868,8 @@ class Website extends CommonObject $numOfPageDest = $this->extractNumberFromFilename($fileNeeded['name']); $differences = $this->showDifferences($destContent, $sourceContent, array($numOfPageDest,$numOfPageSource)); $differences['file_destination'] = $fileNeeded; + } else { + $differences = array(); } return $differences; } diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index c4b4cecc710..bed11601dc0 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -878,7 +878,7 @@ class Workstation extends CommonObject // Load file with numbering class (if found) if (file_exists($dir.$file)) { - $mybool |= @include_once $dir.$file; + $mybool = ((bool) @include_once $dir.$file) || $mybool; } } diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 2d1e9d9fefc..3638739a101 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2020 Gauthier VERDOL + * Copyright (C) 2024 MDW * * 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 @@ -149,6 +150,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $permissiontoread = $user->hasRight('workstation', 'workstation', 'read'); $permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index bd3f7e45953..187db69db7c 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -53,7 +53,7 @@ if (isset($argv[2]) || !empty($argv[2])) { $login = ''; } -$max = 0; +$max = -1; if (isset($argv[3]) || !empty($argv[3])) { $max = $argv[3]; @@ -108,7 +108,7 @@ if (!empty($login)) { } // We get list of emailing id to process -$sql = "SELECT m.rowid"; +$sql = "SELECT m.rowid, m.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql .= " WHERE m.statut IN (1,2)"; if ($id != 'all') { @@ -122,12 +122,18 @@ if ($resql) { $j = 0; if ($num) { - for ($j = 0; $j < $num; $j++) { + for ($j = 0; $j < $num && $max != 0; $j++) { $obj = $db->fetch_object($resql); dol_syslog("Process mailing with id ".$obj->rowid); print "Process mailing with id ".$obj->rowid."\n"; + if ($obj->status == 1) { + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut = 2 WHERE rowid = ".((int) $obj->rowid); + $result_sql = $db->query($sql); + dol_syslog("Started mailing campaign ".$obj->rowid, LOG_DEBUG); + } + $emailing = new Mailing($db); $emailing->fetch($obj->rowid); @@ -154,7 +160,7 @@ if ($resql) { $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql2 .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".((int) $id); if (getDolGlobalInt('MAILING_LIMIT_SENDBYCLI') > 0 && empty($max)) { - $sql2 .= " LIMIT " . getDolGlobalString('MAILING_LIMIT_SENDBYCLI'); + $sql2 .= " LIMIT " . getDolGlobalInt('MAILING_LIMIT_SENDBYCLI'); } elseif (getDolGlobalInt('MAILING_LIMIT_SENDBYCLI') > 0 && $max > 0) { $sql2 .= " LIMIT ".min(getDolGlobalInt('MAILING_LIMIT_SENDBYCLI'), $max); } elseif ($max > 0) { @@ -188,6 +194,7 @@ if ($resql) { $now = dol_now(); $obj = $db->fetch_object($resql2); + $max--; // sendto en RFC2822 $sendto = str_replace(',', ' ', dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"); @@ -408,25 +415,16 @@ if ($resql) { $i++; } } else { - $mesg = "Emailing id ".$id." has no recipient to target"; + //$mesg = "Emailing id ".$id." has no recipient to target"; print $mesg."\n"; dol_syslog($mesg, LOG_ERR); - } - // Loop finished, set global statut of mail - $statut = 2; - if (!$nbko) { - $statut = 3; - } + // Loop finished, set global statut of mail + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=3 WHERE rowid=".$obj->rowid; + $result_sql = $db->query($sql); - $sqlenddate = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".((int) $statut)." WHERE rowid=".((int) $id); - - dol_syslog("update global status", LOG_DEBUG); - print "Update status of emailing id ".$id." to ".$statut."\n"; - $resqlenddate = $db->query($sqlenddate); - if (!$resqlenddate) { - dol_print_error($db); - $error++; + dol_syslog("update global status", LOG_DEBUG); + print "Update status of emailing id ".$id." to ".$statut."\n"; } } else { dol_print_error($db); diff --git a/test/phpunit/DoliDBTest.php b/test/phpunit/DoliDBTest.php index 7abc7557a91..5cc4cd695fe 100644 --- a/test/phpunit/DoliDBTest.php +++ b/test/phpunit/DoliDBTest.php @@ -48,6 +48,41 @@ $conf->global->MAIN_DISABLE_ALL_MAILS = 1; */ class DoliDBTest extends CommonClassTest { + /** + * testDDLUpdateField + * + * @return int + */ + public function testDDLCreateTable() + { + global $conf,$user,$langs,$db; + $conf = $this->savconf; + $user = $this->savuser; + $langs = $this->savlangs; + $db = $this->savdb; + + $namedic = MAIN_DB_PREFIX.'tmptesttabletoremove'; + + $res = $db->DDLDropTable($namedic); + + $columns = array( + 'rowid' => array('type' => 'integer', 'AUTO_INCREMENT PRIMARY KEY'), + 'code' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'), + 'label' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'), + 'position' => array('type' => 'integer', 'null'=>'NULL'), + 'use_default' => array('type' => 'varchar', 'value' => 1, 'default'=>'1'), + 'active' => array('type' => 'integer') + ); + $primaryKey = 'rowid'; + + print __METHOD__.' db->type = '.$db->type."\n"; + + $res = $db->DDLCreateTable($namedic, $columns, $primaryKey, ""); + + $this->assertEquals(1, $res); + print __METHOD__." result=".$res."\n"; + } + /** * testDDLUpdateField * @@ -81,9 +116,10 @@ class DoliDBTest extends CommonClassTest print __METHOD__." result=".$result."\n"; // TODO Use $savtype and $savnull instead of hard coded - $field_desc = array('type' => 'varchar', 'value' => '16', 'null' => 'NOT NULL'); + $field_desc = array('type'=>'varchar', 'value'=>'16', 'null'=>'NOT NULL', 'default'=>'aaaabbbbccccdddd'); $result = $db->DDLUpdateField($db->prefix().'c_paper_format', 'code', $field_desc); + $this->assertEquals(1, $result); print __METHOD__." result=".$result."\n";