From e570f59e2d4e2cc3093468ca300bd92d21f099db Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 14 Aug 2024 01:24:55 +0200 Subject: [PATCH] Qual: Phan fixes (mainly Initial type cannot be inferred) in popular changed classes (#30604) * Update setValueFrom $id type to include null * Only 2 arguments for ModeleNumRefMembers::getToolTip * Fix PhanTypeConversionFromArray * Only 6 args for PaymentSalary::addPaymentToBank * Fix typing hints (array -> string) * Fix uninitialized variables * Add cssview to attributes phpdoc * Avoid double typing specification (Phan notice) * Qual: Ensure variable is defined (phan) * Ensure phpdoc typing for verif method * Ensure phpdoc typing for getNextValue method * Add status as data key in cols array * Ensure preg_replace operates on string (phan) * Correct type for desiredstock * Fix typing with casts (phan) * Fix check that notification already exists * Initialise fk_parent_id to fix typing issue * Qual: Fix phan notices for Societe & related * Qual: Fix typing for Facture and related * Qual: Fix typing for Product & related * Update baseline * Fix new phpstan notices --- dev/tools/phan/baseline.txt | 36 +- htdocs/adherents/admin/member.php | 2 +- htdocs/categories/class/categorie.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 440 ++++++++++------- .../class/bonprelevement.class.php | 8 +- .../class/rejetprelevement.class.php | 9 +- htdocs/compta/prelevement/line.php | 5 +- .../core/class/commondocgenerator.class.php | 2 +- htdocs/core/class/commonobject.class.php | 18 +- htdocs/core/class/commonorder.class.php | 4 +- htdocs/core/class/extrafields.class.php | 2 +- .../asset/doc/pdf_standard_asset.modules.php | 2 +- .../barcode/mod_barcode_product_standard.php | 12 +- .../mod_barcode_thirdparty_standard.php | 11 +- .../modules/barcode/modules_barcode.class.php | 18 + .../commande/doc/pdf_eratosthene.modules.php | 2 +- .../facture/doc/pdf_octopus.modules.php | 2 +- .../facture/doc/pdf_sponge.modules.php | 2 +- .../core/modules/facture/mod_facture_mars.php | 6 +- .../modules/facture/mod_facture_mercure.php | 11 +- .../core/modules/facture/modules_facture.php | 11 +- .../modules/propale/doc/pdf_cyan.modules.php | 2 +- .../societe/mod_codeclient_elephant.php | 4 +- .../societe/mod_codeclient_leopard.php | 6 +- .../modules/societe/mod_codeclient_monkey.php | 6 +- .../modules/societe/modules_societe.class.php | 17 + .../takepos/mod_takepos_ref_universal.php | 3 +- htdocs/core/tpl/formlayoutai.tpl.php | 4 + ...e_20_modWorkflow_WorkflowManager.class.php | 1 + .../fourn/class/fournisseur.facture.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 6 +- htdocs/fourn/facture/card-rec.php | 2 +- .../doc/pdf_standard_myobject.modules.php | 2 +- htdocs/product/class/api_products.class.php | 2 +- htdocs/product/class/product.class.php | 444 ++++++++++++------ htdocs/product/stock/product.php | 10 +- htdocs/product/stock/replenish.php | 11 +- ...tandard_recruitmentjobposition.modules.php | 2 +- .../societe/class/api_thirdparties.class.php | 5 +- htdocs/societe/class/societe.class.php | 184 +++++--- htdocs/takepos/invoice.php | 2 + htdocs/ticket/class/ticket.class.php | 2 +- .../class/webportalinvoice.class.php | 2 +- 43 files changed, 873 insertions(+), 451 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 94b83291a3d..1fef6d775bf 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -57,7 +57,6 @@ return [ 'file_suppressions' => [ 'htdocs/accountancy/admin/productaccount.php' => ['PhanTypeMismatchArgumentNullableInternal'], 'htdocs/accountancy/bookkeeping/card.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/accountancy/bookkeeping/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/accountancy/bookkeeping/listbyaccount.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/accountancy/class/accountancycategory.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/accountancy/class/accountancyexport.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'], @@ -74,7 +73,7 @@ return [ 'htdocs/accountancy/journal/variousjournal.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/accountancy/supplier/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/accountancy/tpl/export_journal.tpl.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/adherents/admin/member.php' => ['PhanParamTooMany', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredMethod'], + 'htdocs/adherents/admin/member.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredMethod'], 'htdocs/adherents/agenda.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/adherents/canvas/actions_adherentcard_common.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeSuspiciousNonTraversableForeach'], 'htdocs/adherents/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], @@ -219,13 +218,13 @@ return [ 'htdocs/bookcal/calendar_card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/bookcal/calendar_document.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/bookcal/calendar_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/bookcal/class/availabilities.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], + 'htdocs/bookcal/class/availabilities.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/bookcal/class/calendar.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/bookmarks/card.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/bookmarks/class/bookmark.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/categories/card.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/categories/class/api_categories.class.php' => ['PhanAccessMethodProtected', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/categories/class/categorie.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeConversionFromArray', 'PhanTypeMismatchProperty'], + 'htdocs/categories/class/categorie.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchProperty'], 'htdocs/categories/edit.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch'], 'htdocs/categories/index.php' => ['PhanTypeMismatchDimFetch'], 'htdocs/categories/info.php' => ['PhanTypeMismatchDimFetch'], @@ -301,7 +300,7 @@ return [ 'htdocs/compta/facture/card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimFetchNullable', 'PhanUndeclaredGlobalVariable'], 'htdocs/compta/facture/class/api_invoices.class.php' => ['PhanEmptyForeach', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/facture/class/facture-rec.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/compta/facture/class/facture.class.php' => ['PhanEmptyForeach', 'PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], + 'htdocs/compta/facture/class/facture.class.php' => ['PhanUndeclaredProperty'], 'htdocs/compta/facture/class/facturestats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeInvalidLeftOperandOfNumericOp'], 'htdocs/compta/facture/class/paymentterm.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/compta/facture/contact.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -321,7 +320,7 @@ return [ 'htdocs/compta/localtax/list.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/paiement.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimFetch'], 'htdocs/compta/paiement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/compta/paiement/cheque/card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], + 'htdocs/compta/paiement/cheque/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/paiement/cheque/class/remisecheque.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanUndeclaredMethod'], 'htdocs/compta/paiement/cheque/list.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/paiement/class/cpaiement.class.php' => ['PhanPluginUnknownPropertyType'], @@ -332,12 +331,11 @@ return [ 'htdocs/compta/paiement_vat.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/payment_vat/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanParamTooMany', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'], + 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'], 'htdocs/compta/prelevement/class/rejetprelevement.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'], 'htdocs/compta/prelevement/create.php' => ['PhanPluginSuspiciousParamPosition', 'PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/demandes.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/factures.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/compta/prelevement/line.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeConversionFromArray'], 'htdocs/compta/prelevement/orders_list.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/stats.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/resultat/clientfourn.php' => ['PhanPossiblyUndeclaredGlobalVariable'], @@ -472,7 +470,7 @@ return [ 'htdocs/core/class/canvas.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType'], 'htdocs/core/class/ccountry.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/core/class/cgenericdic.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], - 'htdocs/core/class/commondocgenerator.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], + 'htdocs/core/class/commondocgenerator.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], 'htdocs/core/class/commonhookactions.class.php' => ['PhanPluginUnknownArrayMethodParamType'], 'htdocs/core/class/commonincoterm.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredProperty'], 'htdocs/core/class/commoninvoice.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable'], @@ -496,7 +494,7 @@ return [ 'htdocs/core/class/emailsenderprofile.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/core/class/evalmath.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/class/events.class.php' => ['PhanPluginUnknownPropertyType'], - 'htdocs/core/class/extrafields.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNull', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], + 'htdocs/core/class/extrafields.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], 'htdocs/core/class/extralanguages.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/class/fileupload.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'], 'htdocs/core/class/fiscalyear.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'], @@ -704,7 +702,7 @@ return [ 'htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredMethod'], 'htdocs/core/modules/stock/modules_stock.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], - 'htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredMethod'], + 'htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'], 'htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/core/modules/stocktransfer/modules_stocktransfer.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'], @@ -712,7 +710,7 @@ return [ 'htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'], - 'htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], + 'htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php' => ['PhanPossiblyUndeclaredVariable'], 'htdocs/core/modules/supplier_order/modules_commandefournisseur.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'], @@ -720,7 +718,7 @@ return [ 'htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/supplier_payment/modules_supplier_payment.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], - 'htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], + 'htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/syslog/logHandler.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], @@ -748,7 +746,7 @@ return [ 'htdocs/core/tpl/extrafields_list_print_fields.tpl.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/core/tpl/extrafields_view.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/core/tpl/filemanager.tpl.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/core/tpl/formlayoutai.tpl.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredVariableAssignOp'], + 'htdocs/core/tpl/formlayoutai.tpl.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable'], 'htdocs/core/tpl/login.tpl.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], 'htdocs/core/tpl/massactions_pre.tpl.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/core/tpl/notes.tpl.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], @@ -874,6 +872,7 @@ return [ 'htdocs/fourn/class/fournisseur.facture-rec.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/fourn/class/fournisseur.facture.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/fourn/class/fournisseur.product.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchProperty'], + 'htdocs/fourn/class/paiementfourn.class.php' => ['PhanEmptyForeach', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/fourn/commande/card.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/fourn/commande/contact.php' => ['PhanUndeclaredGlobalVariable'], @@ -935,7 +934,6 @@ return [ 'htdocs/install/fileconf.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'], 'htdocs/install/inc.php' => ['PhanRedefineFunction'], 'htdocs/install/index.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/install/install.forced.php' => ['PhanPluginWhitespaceTrailing'], 'htdocs/install/repair.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/install/step2.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'], 'htdocs/install/upgrade.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'], @@ -1004,7 +1002,7 @@ return [ 'htdocs/product/card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/class/api_products.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], 'htdocs/product/class/html.formproduct.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/product/class/product.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchReturn', 'PhanUndeclaredMethod'], + 'htdocs/product/class/product.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredMethod'], 'htdocs/product/class/productbatch.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownPropertyType'], 'htdocs/product/class/productcustomerprice.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanTypeInvalidLeftOperandOfNumericOp'], 'htdocs/product/class/productfournisseurprice.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], @@ -1020,7 +1018,6 @@ return [ 'htdocs/product/inventory/list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/price.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/product/price_suppliers.php' => ['PhanPluginUnknownObjectMethodCall'], 'htdocs/product/reassort.php' => ['PhanTypeExpectedObjectPropAccessButGotNull', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/reassortlot.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/stats/card.php' => ['PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'], @@ -1045,7 +1042,7 @@ return [ 'htdocs/product/stock/movement_card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/stock/movement_list.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/stock/product.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/product/stock/productlot_card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], + 'htdocs/product/stock/productlot_card.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/productlot_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/stock/replenish.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/stock/stats/commande_fournisseur.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], @@ -1196,7 +1193,6 @@ return [ 'htdocs/societe/class/api_thirdparties.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredProperty'], 'htdocs/societe/class/companybankaccount.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/societe/class/companypaymentmode.class.php' => ['PhanPluginUnknownPropertyType'], - 'htdocs/societe/class/societe.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], 'htdocs/societe/class/societeaccount.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'], 'htdocs/societe/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/societe/document.php' => ['PhanTypeInvalidLeftOperandOfNumericOp'], @@ -1250,7 +1246,7 @@ return [ 'htdocs/ticket/class/actions_ticket.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/ticket/class/api_tickets.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/ticket/class/cticketcategory.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/ticket/class/ticket.class.php' => ['PhanPluginRedundantReturnComment', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredProperty'], + 'htdocs/ticket/class/ticket.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredProperty'], 'htdocs/ticket/class/ticketstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'], 'htdocs/ticket/contact.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/ticket/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'], diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index f8c95fca83b..5a6a10d4fa3 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -315,7 +315,7 @@ foreach ($arrayofmodules as $file => $modCodeMember) { } print ''; - $s = $modCodeMember->getToolTip($langs, null, -1); + $s = $modCodeMember->getToolTip($langs, null); print $form->textwithpicto('', $s, 1); print ''; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b3fabcd497d..4ab4182c0bd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1827,7 +1827,7 @@ class Categorie extends CommonObject } if (file_exists($dir)) { - if (is_array($file['name']) && count($file['name']) > 0) { + if (is_array($file['name'])) { $nbfile = count($file['name']); for ($i = 0; $i < $nbfile; $i++) { $originImage = $dir.$file['name'][$i]; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index da36cdcaafa..30e28c432e7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -116,7 +116,9 @@ class Facture extends CommonInvoice */ public $fk_user_modif; - + /** + * @var string + */ public $datem; /** @@ -136,27 +138,58 @@ class Facture extends CommonInvoice */ public $ref_customer; + /** + * @var float + */ public $total_ht; + /** + * @var float + */ public $total_tva; + /** + * @var float + */ public $total_localtax1; + /** + * @var float + */ public $total_localtax2; + /** + * @var float + */ public $total_ttc; + /** + * @var float + */ public $revenuestamp; + /** + * @var float|string + */ public $resteapayer; /** - * 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) + * + * @var int<0,1> 1 if invoice paid COMPLETELY, 0 otherwise + * @deprecated * Use statut and close_code) */ public $paye; - //! key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...) + /** + * @var string key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...) + */ public $module_source; - //! key of pos source ('0', '1', ...) + /** + * @var int key of pos source ('0', '1', ...) + */ public $pos_source; - //! id of template invoice when generated from a template invoice + /** + * @var int id of template invoice when generated from a template invoice + */ public $fk_fac_rec_source; - //! id of source invoice if replacement invoice or credit note + /** + * @var int id of source invoice if replacement invoice or credit note + */ public $fk_facture_source; public $linked_objects = array(); @@ -174,6 +207,9 @@ class Facture extends CommonInvoice * @var FactureLigne */ public $line; + /** + * @var array (Encoded as JSON in database) + */ public $extraparams = array(); /** @@ -181,6 +217,9 @@ class Facture extends CommonInvoice */ public $fac_rec; + /** + * @var string + */ public $date_pointoftax; @@ -200,12 +239,12 @@ class Facture extends CommonInvoice public $situation_final; /** - * @var array Table of previous situations + * @var Facture[] Table of previous situations */ public $tab_previous_situation_invoice = array(); /** - * @var array Table of next situations + * @var Facture[] Table of next situations */ public $tab_next_situation_invoice = array(); @@ -215,7 +254,7 @@ class Facture extends CommonInvoice public $oldcopy; /** - * @var double percentage of retainage + * @var float percentage of retainage */ public $retained_warranty; @@ -234,6 +273,9 @@ class Facture extends CommonInvoice */ public $availability_id; + /** + * @var string + */ public $date_closing; /** @@ -280,7 +322,7 @@ class Facture extends CommonInvoice // BEGIN MODULEBUILDER PROPERTIES /** - * @var array|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull?:int,visible:int<-2,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 1), @@ -506,6 +548,8 @@ class Facture extends CommonInvoice $nextdatewhen = null; $previousdaynextdatewhen = null; + $_facrec = null; + // Erase some properties of the invoice to create with the one of the recurring invoice if ($this->fac_rec > 0) { $this->fk_fac_rec_source = $this->fac_rec; @@ -594,8 +638,9 @@ class Facture extends CommonInvoice if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->thirdparty->default_lang)) { $newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ... } + // @phan-suppress-next-line PhanUndeclaredProperty if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->default_lang)) { - $newlang = $this->default_lang; // for thirdparty + $newlang = $this->default_lang; // for thirdparty @phan-suppress-current-line PhanUndeclaredProperty } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); @@ -789,6 +834,7 @@ class Facture extends CommonInvoice dol_syslog("There is ".count($this->lines)." lines into ->lines that are InvoiceLines"); foreach ($this->lines as $i => $val) { $newinvoiceline = $this->lines[$i]; + '@phan-var-force FactureLigne $newinvoiceline'; $newinvoiceline->context = $this->context; @@ -819,7 +865,7 @@ class Facture extends CommonInvoice $newinvoiceline->fk_parent_line = $fk_parent_line; - if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { + if ($this->type == Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { $discount = new DiscountAbsolute($this->db); $discount->fetch($newinvoiceline->fk_remise_except); @@ -880,6 +926,7 @@ class Facture extends CommonInvoice foreach ($this->lines as $i => $val) { $line = $this->lines[$i]; + '@phan-var-force FactureLigne $line'; // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. @@ -963,7 +1010,7 @@ class Facture extends CommonInvoice /* * Insert lines coming from the template invoice */ - if (!$error && $this->fac_rec > 0) { + if (!$error && $this->fac_rec > 0 && is_object($_facrec)) { dol_syslog("There is ".count($_facrec->lines)." lines from recurring invoice"); $fk_parent_line = 0; @@ -1032,7 +1079,7 @@ class Facture extends CommonInvoice ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) ? $previousdaynextdatewhen : '', 0, $tva_npr, - '', + 0, // fk_remise_except 'HT', 0, $_facrec->lines[$i]->product_type, @@ -1046,7 +1093,7 @@ class Facture extends CommonInvoice $_facrec->lines[$i]->label, empty($_facrec->lines[$i]->array_options) ? null : $_facrec->lines[$i]->array_options, 100, // situation percent is undefined on recurring invoice lines - '', + 0, // fk_prev_id $_facrec->lines[$i]->fk_unit, $_facrec->lines[$i]->multicurrency_subprice, $_facrec->lines[$i]->ref_ext, @@ -1115,9 +1162,9 @@ class Facture extends CommonInvoice /** * Create a new invoice in database from current invoice * - * @param User $user Object user that ask creation - * @param int $invertdetail Reverse sign of amounts for lines - * @return int Return integer <0 if KO, >0 if OK + * @param User $user Object user that ask creation + * @param int<0,1> $invertdetail Reverse sign of amounts for lines + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function createFromCurrent(User $user, $invertdetail = 0) { @@ -1191,7 +1238,7 @@ class Facture extends CommonInvoice $this->error = $facture->error; $this->errors = $facture->errors; } elseif ($this->type == self::TYPE_SITUATION && getDolGlobalString('INVOICE_USE_SITUATION')) { - $this->fetchObjectLinked('', '', $this->id, 'facture'); + $this->fetchObjectLinked(null, '', $this->id, 'facture'); foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) { foreach ($Tfk_object as $fk_object) { @@ -1267,7 +1314,8 @@ class Facture extends CommonInvoice // Loop on each line of new invoice foreach ($object->lines as $i => $line) { - if (($object->lines[$i]->info_bits & 0x02) == 0x02) { // We do not clone line of discounts + '@phan-var-force FactureLigne $line'; + if (($line->info_bits & 0x02) == 0x02) { // We do not clone line of discounts unset($object->lines[$i]); continue; } @@ -1348,11 +1396,11 @@ class Facture extends CommonInvoice } /** - * Load an object from an order and create a new invoice into database + * Load an object from an order and create a new invoice into database * - * @param Object $object Object source - * @param User $user Object user - * @return int Return integer <0 if KO, 0 if nothing done, 1 if OK + * @param Facture $object Object source + * @param User $user Object user + * @return int<-1,1> Return integer <0 if KO, 0 if nothing done, 1 if OK */ public function createFromOrder($object, User $user) { @@ -1367,48 +1415,49 @@ class Facture extends CommonInvoice $num = count($object->lines); for ($i = 0; $i < $num; $i++) { $line = new FactureLigne($this->db); - - $line->libelle = $object->lines[$i]->libelle; // deprecated - $line->label = $object->lines[$i]->label; - $line->desc = $object->lines[$i]->desc; - $line->subprice = $object->lines[$i]->subprice; - $line->total_ht = $object->lines[$i]->total_ht; - $line->total_tva = $object->lines[$i]->total_tva; - $line->total_localtax1 = $object->lines[$i]->total_localtax1; - $line->total_localtax2 = $object->lines[$i]->total_localtax2; - $line->total_ttc = $object->lines[$i]->total_ttc; - $line->vat_src_code = $object->lines[$i]->vat_src_code; - $line->tva_tx = $object->lines[$i]->tva_tx; - $line->localtax1_tx = $object->lines[$i]->localtax1_tx; - $line->localtax2_tx = $object->lines[$i]->localtax2_tx; - $line->qty = $object->lines[$i]->qty; - $line->fk_remise_except = $object->lines[$i]->fk_remise_except; - $line->remise_percent = $object->lines[$i]->remise_percent; - $line->fk_product = $object->lines[$i]->fk_product; - $line->info_bits = $object->lines[$i]->info_bits; - $line->product_type = $object->lines[$i]->product_type; - $line->rang = $object->lines[$i]->rang; - $line->special_code = $object->lines[$i]->special_code; - $line->fk_parent_line = $object->lines[$i]->fk_parent_line; - $line->fk_unit = $object->lines[$i]->fk_unit; - $line->date_start = $object->lines[$i]->date_start; - $line->date_end = $object->lines[$i]->date_end; + $src_line = $object->lines[$i]; + '@phan-var-force FactureLigne $src_line'; + $line->libelle = $src_line->libelle; // deprecated + $line->label = $src_line->label; + $line->desc = $src_line->desc; + $line->subprice = $src_line->subprice; + $line->total_ht = $src_line->total_ht; + $line->total_tva = $src_line->total_tva; + $line->total_localtax1 = $src_line->total_localtax1; + $line->total_localtax2 = $src_line->total_localtax2; + $line->total_ttc = $src_line->total_ttc; + $line->vat_src_code = $src_line->vat_src_code; + $line->tva_tx = $src_line->tva_tx; + $line->localtax1_tx = $src_line->localtax1_tx; + $line->localtax2_tx = $src_line->localtax2_tx; + $line->qty = $src_line->qty; + $line->fk_remise_except = $src_line->fk_remise_except; + $line->remise_percent = $src_line->remise_percent; + $line->fk_product = $src_line->fk_product; + $line->info_bits = $src_line->info_bits; + $line->product_type = $src_line->product_type; + $line->rang = $src_line->rang; + $line->special_code = $src_line->special_code; + $line->fk_parent_line = $src_line->fk_parent_line; + $line->fk_unit = $src_line->fk_unit; + $line->date_start = $src_line->date_start; + $line->date_end = $src_line->date_end; // Multicurrency - $line->fk_multicurrency = $object->lines[$i]->fk_multicurrency; - $line->multicurrency_code = $object->lines[$i]->multicurrency_code; - $line->multicurrency_subprice = $object->lines[$i]->multicurrency_subprice; - $line->multicurrency_total_ht = $object->lines[$i]->multicurrency_total_ht; - $line->multicurrency_total_tva = $object->lines[$i]->multicurrency_total_tva; - $line->multicurrency_total_ttc = $object->lines[$i]->multicurrency_total_ttc; + $line->fk_multicurrency = $src_line->fk_multicurrency; + $line->multicurrency_code = $src_line->multicurrency_code; + $line->multicurrency_subprice = $src_line->multicurrency_subprice; + $line->multicurrency_total_ht = $src_line->multicurrency_total_ht; + $line->multicurrency_total_tva = $src_line->multicurrency_total_tva; + $line->multicurrency_total_ttc = $src_line->multicurrency_total_ttc; - $line->fk_fournprice = $object->lines[$i]->fk_fournprice; - $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); + $line->fk_fournprice = $src_line->fk_fournprice; + $marginInfos = getMarginInfos($src_line->subprice, $src_line->remise_percent, $src_line->tva_tx, $src_line->localtax1_tx, $src_line->localtax2_tx, $src_line->fk_fournprice, $src_line->pa_ht); $line->pa_ht = $marginInfos[0]; // get extrafields from original line - $object->lines[$i]->fetch_optionals(); - foreach ($object->lines[$i]->array_options as $options_key => $value) { + $src_line->fetch_optionals(); + foreach ($src_line->array_options as $options_key => $value) { $line->array_options[$options_key] = $value; } @@ -1477,11 +1526,11 @@ class Facture extends CommonInvoice } /** - * Load an object from an order and create a new invoice into database + * Load an object from a contract and create a new invoice into database * - * @param Object $object Object source + * @param Facture $object Object source * @param User $user Object user - * @param array $lines Ids of lines to use for invoice. If empty, all lines will be used. + * @param int[] $lines Ids of lines to use for invoice. If empty, all lines will be used. * @return int Return integer <0 if KO, 0 if nothing done, 1 if OK */ public function createFromContract($object, User $user, $lines = array()) @@ -1614,14 +1663,14 @@ class Facture extends CommonInvoice /** * Creates a deposit from a proposal or an order by grouping lines by VAT rates * - * @param Propal|Commande $origin The original proposal or order - * @param int $date Invoice date - * @param int $payment_terms_id Invoice payment terms - * @param User $user Object user - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @param bool $autoValidateDeposit Whether to aumatically validate the deposit created - * @param array $overrideFields Array of fields to force values - * @return Facture|null The deposit created, or null if error (populates $origin->error in this case) + * @param Propal|Commande $origin The original proposal or order + * @param int $date Invoice date + * @param int $payment_terms_id Invoice payment terms + * @param User $user Object user + * @param int<0,1> $notrigger 1=Does not execute triggers, 0= execute triggers + * @param bool $autoValidateDeposit Whether to automatically validate the deposit created + * @param array $overrideFields Array of fields to force values + * @return ?Facture The deposit created, or null if error (populates $origin->error in this case) */ public static function createDepositFromOrigin(CommonObject $origin, $date, $payment_terms_id, User $user, $notrigger = 0, $autoValidateDeposit = false, $overrideFields = array()) { @@ -1735,11 +1784,16 @@ class Facture extends CommonInvoice if (!empty($line->special_code)) { continue; } - $TTotalByTva[$line->tva_tx] += $line->total_ttc; - $descriptions[$line->tva_tx] .= '
  • ' . (!empty($line->product_ref) ? $line->product_ref . ' - ' : ''); - $descriptions[$line->tva_tx] .= (!empty($line->product_label) ? $line->product_label . ' - ' : ''); - $descriptions[$line->tva_tx] .= $langs->trans('Qty') . ' : ' . $line->qty; - $descriptions[$line->tva_tx] .= ' - ' . $langs->trans('TotalHT') . ' : ' . price($line->total_ht) . '
  • '; + $key = $line->tva_tx; + if (!array_key_exists($key, $TTotalByTva)) { + $TTotalByTva[$key] = 0; + $descriptions[$key] = ''; + } + $TTotalByTva[$key] += $line->total_ttc; + $descriptions[$key] .= '
  • ' . (!empty($line->product_ref) ? $line->product_ref . ' - ' : ''); + $descriptions[$key] .= (!empty($line->product_label) ? $line->product_label . ' - ' : ''); + $descriptions[$key] .= $langs->trans('Qty') . ' : ' . $line->qty; + $descriptions[$key] .= ' - ' . $langs->trans('TotalHT') . ' : ' . price($line->total_ht) . '
  • '; } foreach ($TTotalByTva as $tva => &$total) { @@ -1762,7 +1816,7 @@ class Facture extends CommonInvoice $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? $tva_tx = $lines[$i]->tva_tx; - $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $origin->deposit_percent) / 100; + $amountdeposit[$tva_tx] += ((float) $lines[$i]->total_ht * (float) $origin->deposit_percent) / 100; $descriptions[$tva_tx] .= '
  • ' . (!empty($lines[$i]->product_ref) ? $lines[$i]->product_ref . ' - ' : ''); $descriptions[$tva_tx] .= (!empty($lines[$i]->product_label) ? $lines[$i]->product_label . ' - ' : ''); $descriptions[$tva_tx] .= $langs->trans('Qty') . ' : ' . $lines[$i]->qty; @@ -1894,9 +1948,9 @@ class Facture extends CommonInvoice /** * getTooltipContentArray * - * @param array $params ex option, infologin + * @param array $params params to construct tooltip data + * @return array Data to show in tooltip * @since v18 - * @return array */ public function getTooltipContentArray($params) { @@ -3160,6 +3214,7 @@ class Facture extends CommonInvoice $productStatic = null; $warehouseStatic = null; + $productbatch = null; if ($batch_rule > 0) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; @@ -3343,9 +3398,11 @@ class Facture extends CommonInvoice } // We check if the invoice was provisional + /* if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) { // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne } + */ if (!$error) { // Define third party as a customer @@ -3378,7 +3435,7 @@ class Facture extends CommonInvoice $is_batch_line = false; if ($batch_rule > 0) { $productStatic->fetch($this->lines[$i]->fk_product); - if ($productStatic->hasbatch()) { + if ($productStatic->hasbatch() && is_object($productbatch)) { $is_batch_line = true; $product_qty_remain = $this->lines[$i]->qty; @@ -3561,13 +3618,15 @@ class Facture extends CommonInvoice $final = true; $nboflines = count($this->lines); while (($i < $nboflines) && $final) { + $line = $this->lines[$i]; + '@phan-var-force FactureLigne $line'; if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) { - $previousprogress = $this->lines[$i]->get_allprev_progress($this->lines[$i]->fk_facture); - $current_progress = floatval($this->lines[$i]->situation_percent); + $previousprogress = $line->get_allprev_progress($line->fk_facture); + $current_progress = (float) $line->situation_percent; $full_progress = $previousprogress + $current_progress; $final = ($full_progress == 100); } else { - $final = ($this->lines[$i]->situation_percent == 100); + $final = ($line->situation_percent == 100); } $i++; } @@ -3611,6 +3670,7 @@ class Facture extends CommonInvoice } foreach ($next_invoice->lines as $line) { + '@phan-var-force FactureLigne $line'; $result = $next_invoice->updateline( $line->id, $line->desc, @@ -3743,38 +3803,38 @@ class Facture extends CommonInvoice * par l'appelant par la method get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) * - * @param string $desc Description of line - * @param double $pu_ht Unit price without tax (> 0 even for credit note) - * @param double $qty Quantity - * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') - * @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) - * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) - * @param int $fk_product Id of predefined product/service - * @param double $remise_percent Percent of discount on line - * @param int|string $date_start Date start of service - * @param int|string $date_end Date end of service - * @param int $fk_code_ventilation Code of dispatching into accountancy - * @param int $info_bits Bits of type of lines - * @param int $fk_remise_except Id discount used - * @param string $price_base_type 'HT' or 'TTC' - * @param double $pu_ttc Unit price with tax (> 0 even for credit note) - * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. - * @param int $rang Position of line (-1 means last value + 1) - * @param int $special_code Special code (also used by externals modules!) - * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... - * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id - * @param int $fk_parent_line Id of parent line - * @param int $fk_fournprice Supplier price id (to calculate margin) or '' - * @param int $pa_ht Buying price of line (to calculate margin) or '' - * @param string $label Label of the line (deprecated, do not use) - * @param array $array_options extrafields array - * @param int $situation_percent Situation advance percentage - * @param int $fk_prev_id Previous situation line id reference - * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in foreign currency - * @param string $ref_ext External reference of the line - * @param int $noupdateafterinsertline No update after insert of line - * @return int Return integer <0 if KO, Id of line if OK + * @param string $desc Description of line + * @param float $pu_ht Unit price without tax (> 0 even for credit note) + * @param float $qty Quantity + * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') + * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) + * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) + * @param int $fk_product Id of predefined product/service + * @param float $remise_percent Percent of discount on line + * @param int|string $date_start Date start of service + * @param int|string $date_end Date end of service + * @param int $fk_code_ventilation Code of dispatching into accountancy + * @param int $info_bits Bits of type of lines + * @param int $fk_remise_except Id discount used + * @param string $price_base_type 'HT' or 'TTC' + * @param float $pu_ttc Unit price with tax (> 0 even for credit note) + * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. + * @param int $rang Position of line (-1 means last value + 1) + * @param int $special_code Special code (also used by externals modules!) + * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... + * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id + * @param int $fk_parent_line Id of parent line + * @param int $fk_fournprice Supplier price id (to calculate margin) or '' + * @param int $pa_ht Buying price of line (to calculate margin) or '' + * @param string $label Label of the line (deprecated, do not use) + * @param array $array_options extrafields array + * @param int $situation_percent Situation advance percentage + * @param int $fk_prev_id Previous situation line id reference + * @param int|null $fk_unit Code of the unit to use. Null to use the default one + * @param float $pu_ht_devise Unit price in foreign currency + * @param string $ref_ext External reference of the line + * @param int $noupdateafterinsertline No update after insert of line + * @return int Return integer <0 if KO, Id of line if OK */ public function addline( $desc, @@ -4044,33 +4104,33 @@ class Facture extends CommonInvoice /** * Update a detail line * - * @param int $rowid Id of line to update - * @param string $desc Description of line - * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines) - * @param double $qty Quantity - * @param double $remise_percent Percentage discount of the line - * @param int $date_start Date de debut de validite du service - * @param int $date_end Date de fin de validite du service - * @param double $txtva VAT Rate (Can be '8.5', '8.5 (ABC)') - * @param double $txlocaltax1 Local tax 1 rate - * @param double $txlocaltax2 Local tax 2 rate - * @param string $price_base_type HT or TTC - * @param int $info_bits Miscellaneous information - * @param int $type Type of line (0=product, 1=service) - * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). - * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) - * @param int $fk_fournprice Id of origin supplier price - * @param int $pa_ht Price (without tax) of product when it was bought - * @param string $label Label of the line (deprecated, do not use) - * @param int $special_code Special code (also used by externals modules!) - * @param array $array_options extrafields array - * @param int $situation_percent Situation advance percentage - * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in currency - * @param int $notrigger disable line update trigger - * @param string $ref_ext External reference of the line - * @param integer $rang rank of line - * @return int Return integer < 0 if KO, > 0 if OK + * @param int $rowid Id of line to update + * @param string $desc Description of line + * @param float $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines) + * @param float $qty Quantity + * @param float $remise_percent Percentage discount of the line + * @param int $date_start Date de debut de validite du service + * @param int $date_end Date de fin de validite du service + * @param float $txtva VAT Rate (Can be '8.5', '8.5 (ABC)') + * @param float $txlocaltax1 Local tax 1 rate + * @param float $txlocaltax2 Local tax 2 rate + * @param string $price_base_type HT or TTC + * @param int $info_bits Miscellaneous information + * @param int $type Type of line (0=product, 1=service) + * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). + * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) + * @param int $fk_fournprice Id of origin supplier price + * @param int $pa_ht Price (without tax) of product when it was bought + * @param string $label Label of the line (deprecated, do not use) + * @param int $special_code Special code (also used by externals modules!) + * @param array $array_options extrafields array + * @param int $situation_percent Situation advance percentage + * @param ?int $fk_unit Code of the unit to use. Null to use the default one + * @param float $pu_ht_devise Unit price in currency + * @param int<0,1> $notrigger disable line update trigger + * @param string $ref_ext External reference of the line + * @param integer $rang rank of line + * @return int Return integer < 0 if KO, > 0 if OK */ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = array(), $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { @@ -4334,10 +4394,10 @@ class Facture extends CommonInvoice $previous_progress = $line->get_allprev_progress($line->fk_facture); $current_progress = $percent - $previous_progress; $line->situation_percent = $current_progress; - $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $current_progress); + $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, array(), $current_progress); } else { $line->situation_percent = $percent; - $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $percent); + $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, array(), $percent); } $line->total_ht = $tabprice[0]; $line->total_tva = $tabprice[1]; @@ -4649,7 +4709,7 @@ class Facture extends CommonInvoice } $obj = new $classname(); - '@phan-var-force CommonNumRefGenerator $obj'; + '@phan-var-force ModeleNumRefFactures $obj'; $numref = $obj->getNextValue($soc, $this, $mode); @@ -4989,7 +5049,7 @@ class Facture extends CommonInvoice /** * Retourne id des contacts clients de facturation * - * @return array Liste des id contacts facturation + * @return int[] Liste des id contacts facturation */ public function getIdBillingContact() { @@ -4999,7 +5059,7 @@ class Facture extends CommonInvoice /** * Retourne id des contacts clients de livraison * - * @return array Liste des id contacts livraison + * @return int[] Liste des id contacts livraison */ public function getIdShippingContact() { @@ -5206,7 +5266,7 @@ class Facture extends CommonInvoice /** * Create an array of invoice lines * - * @return int >0 if OK, <0 if KO + * @return int<-1,1> >0 if OK, <0 if KO */ public function getLinesArray() { @@ -5218,11 +5278,11 @@ class Facture extends CommonInvoice * * @param string $modele Generator to use. Caller must set it to obj->model_pdf or GETPOST('model','alpha') for example. * @param Translate $outputlangs Object lang to use for translation - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information - * @return int Return integer <0 if KO, >0 if OK + * @param int<0,1> $hidedetails Hide details of lines + * @param int<0,1> $hidedesc Hide description + * @param int<0,1> $hideref Hide ref + * @param ?array $moreparams Array to provide more information + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { @@ -5946,8 +6006,8 @@ class Facture extends CommonInvoice /** * See if current invoice date is posterior to the last invoice date among validated invoices of same type. * - * @param boolean $allow_validated_drafts return true if the invoice has been validated before returning to DRAFT state. - * @return array return array + * @param boolean $allow_validated_drafts return true if the invoice has been validated before returning to DRAFT state. + * @return array{0?:bool,1?:string} return array */ public function willBeLastOfSameType($allow_validated_drafts = false) { @@ -5987,9 +6047,9 @@ class Facture extends CommonInvoice /** * Return clickable link of object (with eventually picto) * - * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) - * @param array $arraydata Array of data - * @return string HTML Code for Kanban thumb. + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. */ public function getKanbanView($option = '', $arraydata = null) { @@ -6062,23 +6122,55 @@ class FactureLigne extends CommonInvoiceLine public $oldline; //! From llx_facturedet - //! Id facture + /** + * @var int Id facture + */ public $fk_facture; - //! Id parent line + /** + * @var int Id parent line + */ public $fk_parent_line; - //! Description ligne + /** + * @var string Description ligne + */ public $desc; - public $ref_ext; // External reference of the line + /** + * @var string External reference of the line + */ + public $ref_ext; + /** + * @var int<0,6> + */ public $localtax1_type; // Local tax 1 type + /** + * @var int<0,6> + */ public $localtax2_type; // Local tax 2 type + /** + * @var int + */ public $fk_remise_except; // Link to line into llx_remise_except + /** + * @var int + */ public $rang = 0; - + /** + * @var int + */ public $fk_fournprice; + /** + * @var string|int|float + */ public $pa_ht; + /** + * @var string + */ public $marge_tx; + /** + * @var string + */ public $marque_tx; /** @@ -6086,6 +6178,9 @@ class FactureLigne extends CommonInvoiceLine */ public $tva_npr; + /** + * @var float + */ public $remise_percent; /** @@ -6093,23 +6188,38 @@ class FactureLigne extends CommonInvoiceLine */ public $batch; /** - * @var string To store the warehouse where to consume stock when using a POS module + * @var int To store the warehouse where to consume stock when using a POS module */ public $fk_warehouse; + /** + * @var string + */ public $origin; + /** + * @var int + */ public $origin_id; /** - * @var integer Id in table llx_accounting_bookeeping to know accounting account for product line + * @var int Id in table llx_accounting_bookeeping to know accounting account for product line */ public $fk_code_ventilation = 0; + /** + * @var string|int + */ public $date_start; + /** + * @var string|int + */ public $date_end; + /** + * @var int<0,1> + */ public $skip_update_total; // Skip update price total for special lines /** diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 468052be7e0..7385c90005c 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -634,7 +634,13 @@ class BonPrelevement extends CommonObject $addbankurl = 'direct-debit'; // = 'directdebit' } - $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', '', 0, '', $addbankurl); + + if ($paiement instanceof PaymentSalary) { + // Only 6 arguments for PaymentSalary + $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', ''); + } else { + $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', '', 0, '', $addbankurl); + } if ($result < 0) { $error++; diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 805176543cb..0db8f92ffef 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2021 OpenDsi * Copyright (C) 2024 Laurent Destailleur + * 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 @@ -47,20 +48,20 @@ class RejetPrelevement public $date_rejet; /** - * @var array Reason of error + * @var string Reason of error */ public $motif; /** - * @var array Label status of invoicing + * @var string Label status of invoicing */ public $invoicing; /** - * @var array Labels of reason + * @var string[] Labels of reason */ public $motifs; /** - * @var array Labels of invoicing status + * @var string[] Labels of invoicing status */ public $labelsofinvoicing; diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 96d9a2d6b2c..4bf3836cd5f 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * 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 @@ -84,6 +85,7 @@ $error = 0; if ($action == 'confirm_rejet' && $permissiontoadd) { if (GETPOST("confirm") == 'yes') { + $datarej = null; if (GETPOSTINT('remonth')) { $daterej = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')); } @@ -156,6 +158,7 @@ $h++; if ($id) { $lipre = new LignePrelevement($db); + $bon = null; if ($lipre->fetch($id) >= 0) { $bon = new BonPrelevement($db); @@ -264,7 +267,7 @@ if ($id) { print '
    '; if ($action == '') { - if ($bon->statut == BonPrelevement::STATUS_CREDITED) { + if (is_object($bon) && $bon->statut == BonPrelevement::STATUS_CREDITED) { if ($lipre->statut == 2) { if ($user->hasRight('prelevement', 'bons', 'credit')) { print ''.$langs->trans("StandingOrderReject").''; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 58948ec2aa8..38060f89b73 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -154,7 +154,7 @@ abstract class CommonDocGenerator public $phpmin = array(7, 1); /** - * @var array Array of columns + * @var array Array of columns */ public $cols; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 45e68e0abd4..29c7a9f6661 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -843,8 +843,8 @@ abstract class CommonObject public $cond_reglement_supplier_id; /** - * @var float Deposit percent for payment terms. - * Populated by setPaymentTerms(). + * @var float|string Deposit percent for payment terms. + * Populated by setPaymentTerms(). * @see setPaymentTerms() */ public $deposit_percent; @@ -2160,13 +2160,13 @@ abstract class CommonObject * Setter generic. Update a specific field into database. * Warning: Trigger is run only if param trigkey is provided. * - * @param string $field Field to update - * @param mixed $value New value - * @param string $table To force other table element or element line (should not be used) - * @param int $id To force other object id (should not be used) - * @param string $format Data format ('text', 'int', 'date'). 'text' is used if not defined - * @param string $id_field To force rowid field name. 'rowid' is used if not defined - * @param User|string $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none' + * @param string $field Field to update + * @param mixed $value New value + * @param string $table To force other table element or element line (should not be used) + * @param ?int $id To force other object id (should not be used) + * @param string $format Data format ('text', 'int', 'date'). 'text' is used if not defined + * @param string $id_field To force rowid field name. 'rowid' is used if not defined + * @param User|string|null $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none' * @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY') * @param string $fk_user_field Name of field to save user id making change * @return int<-2,1> Return integer <0 if KO, >0 if OK diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index c8dbda9c9bf..6d42c9de5f2 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -205,7 +205,7 @@ abstract class CommonOrderLine extends CommonObjectLine /** * Percent line discount - * @var float + * @var float|string */ public $remise_percent; @@ -217,7 +217,7 @@ abstract class CommonOrderLine extends CommonObjectLine /** * VAT % - * @var float + * @var float|string */ public $tva_tx; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d83543dabf9..7ec13372775 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -45,7 +45,7 @@ class ExtraFields public $db; /** - * @var array,type:array,size:array,default:array,computed:array,unique:array,required:array,param:array,perms:array,list:array,pos:array,totalizable:array,help:array,printable:array,enabled:array,langfile:array,css:array,csslist:array,hidden:array,mandatoryfieldsofotherentities:array,loaded?:int,count:int}> New array to store extrafields definition Note: count set as present to avoid static analysis notices + * @var array,type:array,size:array,default:array,computed:array,unique:array,required:array,param:array,perms:array,list:array,pos:array,totalizable:array,help:array,printable:array,enabled:array,langfile:array,css:array,csslist:array,cssview:array,hidden:array,mandatoryfieldsofotherentities:array,loaded?:int,count:int}> New array to store extrafields definition Note: count set as present to avoid static analysis notices */ public $attributes = array(); diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index 3c3b12131ae..7491eca24ff 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -81,7 +81,7 @@ class pdf_standard_asset extends ModelePDFAsset public $situationinvoice; /** - * @var array Array of document table columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 92bb510c107..c1470f290ef 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -224,18 +224,22 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * * @param DoliDB $db Database handler * @param string $code Code to check/correct - * @param Product $product Object product - * @param int $thirdparty_type 0 = customer/prospect , 1 = supplier + * @param Product|Societe $product Object product + * @param int<0,1> $thirdparty_type 0 = customer/prospect , 1 = supplier * @param string $type type of barcode (EAN, ISBN, ...) - * @return int 0 if OK + * @return int<-7,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired + * -7 ErrorBadClass */ public function verif($db, &$code, $product, $thirdparty_type, $type) { - global $conf; + if (!$product instanceof Product) { + dol_syslog(get_class($this)."::verif called with ".get_class($product)." Expected Product", LOG_ERR); + return -7; + } //var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit; diff --git a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php index bcaeeea69a5..036a5b4a4cb 100644 --- a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php @@ -231,17 +231,22 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode * * @param DoliDB $db Database handler * @param string $code Code to check/correct - * @param Societe $thirdparty Object third-party - * @param int $thirdparty_type 0 = customer/prospect , 1 = supplier + * @param Societe|Product $thirdparty Object third party + * @param int<0,1> $thirdparty_type 0 = customer/prospect , 1 = supplier * @param string $type type of barcode (EAN, ISBN, ...) - * @return int 0 if OK + * @return int<-7,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired + * -7 ErrorBadClass */ public function verif($db, &$code, $thirdparty, $thirdparty_type, $type) { + if (!$thirdparty instanceof Societe) { + dol_syslog(get_class($this)."::verif called with ".get_class($thirdparty)." Expected Societe", LOG_ERR); + return -7; + } require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $result = 0; diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index c531c97aeed..51ba9c9a0d6 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -156,4 +156,22 @@ abstract class ModeleNumRefBarCode extends CommonNumRefGenerator return $s; } + + + /** + * Check validity of code according to its rules + * + * @param DoliDB $db Database handler + * @param string $code Code to check/correct + * @param Product|Societe $object Object product or ThirdParty + * @param int<0,1> $thirdparty_type 0 = customer/prospect , 1 = supplier + * @param string $type type of barcode (EAN, ISBN, ...) + * @return int<-7,0> 0 if OK + * -1 ErrorBadCustomerCodeSyntax + * -2 ErrorCustomerCodeRequired + * -3 ErrorCustomerCodeAlreadyUsed + * -4 ErrorPrefixRequired + * -7 ErrorBadClass + */ + abstract public function verif($db, &$code, $object, $thirdparty_type, $type); } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 42ac7d00046..7627e5725c4 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -80,7 +80,7 @@ class pdf_eratosthene extends ModelePDFCommandes public $version = 'dolibarr'; /** - * @var array Array of document table columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index 7ddafc39eb3..0800058f148 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -117,7 +117,7 @@ class pdf_octopus extends ModelePDFFactures /** - * @var array Array of columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 13285e9aa25..3a9a320981b 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -109,7 +109,7 @@ class pdf_sponge extends ModelePDFFactures /** - * @var array Array of columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 65f5e84f0a4..348ee5bbaac 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -160,9 +160,9 @@ class mod_facture_mars extends ModeleNumRefFactures * Return next value not used or last value used * * @param Societe $objsoc Object third party - * @param Facture $invoice Object invoice - * @param string $mode 'next' for next value or 'last' for last value - * @return string|int Value if OK, 0 if KO + * @param Facture $invoice Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string|int<-1,0> Value if OK, <=0 if KO */ public function getNextValue($objsoc, $invoice, $mode = 'next') { diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index a3607cac7a0..55b74491ad4 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2022 Anthony Berton * 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 @@ -135,12 +136,12 @@ class mod_facture_mercure extends ModeleNumRefFactures } /** - * Return next value + * Return next value not used or last value used * - * @param Societe $objsoc Object third party - * @param Facture $invoice Object invoice - * @param string $mode 'next' for next value or 'last' for last value - * @return string|int Value if OK, 0 if KO + * @param Societe $objsoc Object third party + * @param Facture $invoice Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string|int<-1,0> Value if OK, <=0 if KO */ public function getNextValue($objsoc, $invoice, $mode = 'next') { diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 7c7392e30eb..05f3859c92e 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -4,6 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Marcos García + * 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 @@ -250,5 +251,13 @@ abstract class ModelePDFFactures extends CommonDocGenerator */ abstract class ModeleNumRefFactures extends CommonNumRefGenerator { - // No overload code + /** + * Return next value not used or last value used + * + * @param Societe $objsoc Object third party + * @param Facture $invoice Object invoice + * @param string $mode 'next' for next value or 'last' for last value + * @return string|int<-1,0> Value if OK, <=0 if KO + */ + abstract public function getNextValue($objsoc, $invoice, $mode = 'next'); } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 1296c735070..0e5e7cbecc5 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -74,7 +74,7 @@ class pdf_cyan extends ModelePDFPropales public $version = 'dolibarr'; /** - * @var array Array of columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 9f363057497..52180617a6e 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -289,8 +289,8 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * @param DoliDB $db Database handler * @param string $code Code to check/correct * @param Societe $soc Object third party - * @param int $type 0 = customer/prospect , 1 = supplier - * @return int 0 if OK + * @param int<0,1> $type 0 = customer/prospect , 1 = supplier + * @return int<-6,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index 39c7bda525b..d684dfa2040 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -106,12 +106,14 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode * @param DoliDB $db Database handler * @param string $code Code to check/correct * @param Societe $soc Object third party - * @param int $type 0 = customer/prospect , 1 = supplier - * @return int 0 if OK + * @param int<0,1> $type 0 = customer/prospect , 1 = supplier + * @return int<-6,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired + * -5 NotConfigured - Setup empty so any value may be ok or not + * -6 Other (see this->error) */ public function verif($db, &$code, $soc, $type) { diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index b0f6cc1114a..a9ba86c8c7e 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -151,12 +151,14 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * @param DoliDB $db Database handler * @param string $code Code to check/correct * @param Societe $soc Object third party - * @param int $type 0 = customer/prospect , 1 = supplier - * @return int 0 if OK + * @param int<0,1> $type 0 = customer/prospect , 1 = supplier + * @return int<-6,0> 0 if OK * -1 ErrorBadCustomerCodeSyntax * -2 ErrorCustomerCodeRequired * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired + * -5 NotConfigured - Setup empty so any value may be ok or not + * -6 Other (see this->error) */ public function verif($db, &$code, $soc, $type) { diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index f5ac07fb2ff..86c4103cf2b 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -194,6 +194,23 @@ abstract class ModeleThirdPartyCode extends CommonNumRefGenerator // phpcs:enable return 0; } + + /** + * Check validity of code according to its rules + * + * @param DoliDB $db Database handler + * @param string $code Code to check/correct + * @param Societe $soc Object third party + * @param int<0,1> $type 0 = customer/prospect , 1 = supplier + * @return int<-6,0> 0 if OK + * -1 ErrorBadCustomerCodeSyntax + * -2 ErrorCustomerCodeRequired + * -3 ErrorCustomerCodeAlreadyUsed + * -4 ErrorPrefixRequired + * -5 NotConfigured - Setup empty so any value may be ok or not + * -6 Other (see this->error) + */ + abstract public function verif($db, &$code, $soc, $type); } diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php index e11fa61a3b0..e9ee32958d1 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2020 Open-DSI * 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 @@ -142,7 +143,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos $date = (empty($invoice->date) ? dol_now() : $invoice->date); $pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0; - $mask = str_replace('{TN}', $pos_source, $mask); + $mask = str_replace('{TN}', (string) $pos_source, $mask); $numFinal = get_next_value($db, $mask, 'facture', 'ref', '', $objsoc, $date, $mode, false, null, $entity); return $numFinal; diff --git a/htdocs/core/tpl/formlayoutai.tpl.php b/htdocs/core/tpl/formlayoutai.tpl.php index 8cf9f934d32..088fc6d776b 100644 --- a/htdocs/core/tpl/formlayoutai.tpl.php +++ b/htdocs/core/tpl/formlayoutai.tpl.php @@ -1,5 +1,6 @@ + * 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 @@ -40,6 +41,9 @@ if (empty($htmlname)) { '; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 8270b068a7a..db51f5e36d9 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -106,6 +106,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (isModEnabled('invoice') && getDolGlobalString('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + '@phan-var-force Facture $object'; $newobject = new Facture($this->db); $newobject->context['createfromorder'] = 'createfromorder'; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 5bf5b0d930f..e403acb9cca 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -3885,7 +3885,7 @@ class SupplierInvoiceLine extends CommonObjectLine /** * Percent of discount - * @var float + * @var float|string */ public $remise_percent; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 326e927f5d5..c9badc4c1ef 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -61,6 +61,7 @@ class ProductFournisseur extends Product public $id; /** + * @var string * @deprecated * @see $ref_supplier */ @@ -82,11 +83,12 @@ class ProductFournisseur extends Product public $desc_supplier; /** - * @var float The VAT rate by default for this {supplier, qty, product}. Can be set by get_buyprice(). + * @var string The VAT rate by default for this {supplier, qty, product}. Can be set by get_buyprice(). */ public $vatrate_supplier; /** + * @var int * @deprecated * @see $product_id */ @@ -772,7 +774,7 @@ class ProductFournisseur extends Product * @param int $limit Limit * @param int $offset Offset * @param int $socid Filter on a third party id - * @return array|int Array of ProductFournisseur with new properties to define supplier price + * @return ProductFournisseur[]|int<-1,-1> Array of ProductFournisseur with new properties to define supplier price * @see find_min_price_product_fournisseur() */ public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0) diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index 19c64acc849..1d997d650eb 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -560,7 +560,7 @@ if (empty($reshook)) { $tva_tx = $datapriceofproduct['tva_tx']; $tva_npr = $datapriceofproduct['tva_npr']; - $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', (string) $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', (string) $prod->tva_tx)); // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 1b3fbeb2c44..f35f94dba18 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -93,7 +93,7 @@ class pdf_standard_myobject extends ModelePDFMyObject public $emetteur; /** - * @var array Array of columns + * @var array Array of document table columns */ public $cols; diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 4c869bc0203..fd2d9eaa115 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -2158,7 +2158,7 @@ class Products extends DolibarrApi $children[] = array_combine($keys, $values); } - $this->product->sousprods = $children; + $this->product->sousprods = $children; // @phpstan-ignore-line } if ($includeparentid) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d700fa9c81a..3ee571bb504 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -104,9 +104,14 @@ class Product extends CommonObject */ protected $table_ref_field = 'ref'; - public $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into images.lib.php + /** + * @var string + * @see images.lib.php + */ + public $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; /** + * @var string * @deprecated Use $label instead * @see $label */ @@ -147,6 +152,9 @@ class Product extends CommonObject */ public $price; + /** + * @var string + */ public $price_formated; // used by takepos/ajax/ajax.php /** @@ -156,6 +164,9 @@ class Product extends CommonObject */ public $price_ttc; + /** + * @var string + */ public $price_ttc_formated; // used by takepos/ajax/ajax.php /** @@ -177,22 +188,64 @@ class Product extends CommonObject * @var string */ public $price_base_type; + /** + * @var string + */ public $price_label; //! Arrays for multiprices + /** + * @var array + */ public $multiprices = array(); + /** + * @var array + */ public $multiprices_ttc = array(); + /** + * @var array + */ public $multiprices_base_type = array(); + /** + * @var array + */ public $multiprices_default_vat_code = array(); + /** + * @var array + */ public $multiprices_min = array(); + /** + * @var array + */ public $multiprices_min_ttc = array(); + /** + * @var array + */ public $multiprices_tva_tx = array(); + /** + * @var array + */ public $multiprices_recuperableonly = array(); + /** + * @var array + */ //! Price by quantity arrays + /** + * @var int<0,0>|float + */ public $price_by_qty; + /** + * @var array + */ public $prices_by_qty = array(); + /** + * @var array + */ public $prices_by_qty_id = array(); + /** + * @var array> + */ public $prices_by_qty_list = array(); /** @@ -200,13 +253,19 @@ class Product extends CommonObject */ public $level; - //! Array for multilangs + /** + * @var ?array Array for multilangs + */ public $multilangs = array(); - //! Default VAT code for product (link to code into llx_c_tva but without foreign keys) + /** + * @var string Default VAT code for product (link to code into llx_c_tva but without foreign keys) + */ public $default_vat_code; - //! Default VAT rate of product + /** + * @var string|int Default VAT rate of product + */ public $tva_tx; /** @@ -214,25 +273,65 @@ class Product extends CommonObject */ public $tva_npr = 0; - //! Default discount percent + /** + * @var string Default discount percent + */ public $remise_percent; - //! Other local taxes + /** + * @var string|int|float Other local taxes + */ public $localtax1_tx; + /** + * @var string|int|float + */ public $localtax2_tx; + /** + * @var string + */ public $localtax1_type; + /** + * @var string + */ public $localtax2_type; // Properties set by get_buyprice() for return + /** + * @var string + */ public $desc_supplier; + /** + * @var string + */ public $vatrate_supplier; + /** + * @var string + */ public $default_vat_code_supplier; + /** + * @var string|int + */ public $fourn_multicurrency_price; + /** + * @var string|int + */ public $fourn_multicurrency_unitprice; + /** + * @var string|int + */ public $fourn_multicurrency_tx; + /** + * @var string + */ public $fourn_multicurrency_id; + /** + * @var string + */ public $fourn_multicurrency_code; + /** + * @var float + */ public $packaging; @@ -273,7 +372,9 @@ class Product extends CommonObject */ public $cost_price; - //! Average price value for product entry into stock (PMP) + /** + * @var float Average price value for product entry in stock (PMP) + */ public $pmp; /** @@ -284,20 +385,20 @@ class Product extends CommonObject public $seuil_stock_alerte = 0; /** - * Ask for replenishment when $desiredstock < $stock_reel + * @var float Ask for replenishment when $desiredstock < $stock_reel */ public $desiredstock = 0; /** - * Service expiration + * @var ?int Service expiration */ public $duration_value; /** - * Service expiration unit + * @var string Service expiration unit */ public $duration_unit; /** - * Service expiration label (value + unit) + * @var string Service expiration label (value + unit) */ public $duration; @@ -407,28 +508,88 @@ class Product extends CommonObject */ public $url; - //! Metric of products + //! Metrics of products + /** + * @var float|string + */ public $weight; + /** + * @var int|string + */ public $weight_units; // scale -3, 0, 3, 6 + /** + * @var float|string + */ public $length; + /** + * @var int|string + */ public $length_units; // scale -3, 0, 3, 6 + /** + * @var float|string + */ public $width; + /** + * @var int|string + */ public $width_units; // scale -3, 0, 3, 6 + /** + * @var float|string|null + */ public $height; + /** + * @var int|string|null + */ public $height_units; // scale -3, 0, 3, 6 + /** + * @var float|string|null + */ public $surface; + /** + * @var int|string|null + */ public $surface_units; // scale -3, 0, 3, 6 + /** + * @var float|string|null + */ public $volume; + /** + * @var int|string|null + */ public $volume_units; // scale -3, 0, 3, 6 + /** + * @var float|string|null + */ public $net_measure; + /** + * @var ?string + */ public $net_measure_units; // scale -3, 0, 3, 6 + /** + * @var string + */ public $accountancy_code_sell; + /** + * @var string + */ public $accountancy_code_sell_intra; + /** + * @var string + */ public $accountancy_code_sell_export; + /** + * @var string + */ public $accountancy_code_buy; + /** + * @var string + */ public $accountancy_code_buy_intra; + /** + * @var string + */ public $accountancy_code_buy_export; /** @@ -461,8 +622,13 @@ class Product extends CommonObject public $stats_facturerec = array(); public $stats_facture_fournisseur = array(); - //! Size of image + /** + * @var int|string Size of image / height + */ public $imgWidth; + /** + * @var int|string Size of image / height + */ public $imgHeight; /** @@ -520,6 +686,7 @@ class Product extends CommonObject public $fourn_socid; /** + * @var string * @deprecated * @see $ref_supplier */ @@ -547,19 +714,19 @@ class Product extends CommonObject /** * Array with list of supplier prices of product * - * @var array + * @var ProductFournisseur[] */ public $supplierprices; /** * Array with list of sub-products for Kits * - * @var array + * @var array> */ public $sousprods; /** - * @var array Path of subproducts. Build from ->sousprods with get_arbo_each_prod() + * @var array,entity:CommonObject}> Path of subproducts. Build from ->sousprods with get_arbo_each_prod() */ public $res; @@ -594,6 +761,9 @@ class Product extends CommonObject */ public $is_sousproduit_incdec; + /** + * @var int + */ public $mandatory_period; @@ -623,7 +793,7 @@ class Product extends CommonObject */ /** - * @var array|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull?:int,visible:int<-2,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'), @@ -1141,19 +1311,19 @@ class Product extends CommonObject $this->note_private = (isset($this->note_private) ? trim($this->note_private) : null); $this->note_public = (isset($this->note_public) ? trim($this->note_public) : null); $this->net_measure = price2num($this->net_measure); - $this->net_measure_units = (empty($this->net_measure_units) ? '' : trim($this->net_measure_units)); + $this->net_measure_units = (empty($this->net_measure_units) ? '' : trim((string) $this->net_measure_units)); $this->weight = price2num($this->weight); - $this->weight_units = (empty($this->weight_units) ? '' : trim($this->weight_units)); + $this->weight_units = (empty($this->weight_units) ? '' : trim((string) $this->weight_units)); $this->length = price2num($this->length); - $this->length_units = (empty($this->length_units) ? '' : trim($this->length_units)); + $this->length_units = (empty($this->length_units) ? '' : trim((string) $this->length_units)); $this->width = price2num($this->width); - $this->width_units = (empty($this->width_units) ? '' : trim($this->width_units)); + $this->width_units = (empty($this->width_units) ? '' : trim((string) $this->width_units)); $this->height = price2num($this->height); - $this->height_units = (empty($this->height_units) ? '' : trim($this->height_units)); + $this->height_units = (empty($this->height_units) ? '' : trim((string) $this->height_units)); $this->surface = price2num($this->surface); - $this->surface_units = (empty($this->surface_units) ? '' : trim($this->surface_units)); + $this->surface_units = (empty($this->surface_units) ? '' : trim((string) $this->surface_units)); $this->volume = price2num($this->volume); - $this->volume_units = (empty($this->volume_units) ? '' : trim($this->volume_units)); + $this->volume_units = (empty($this->volume_units) ? '' : trim((string) $this->volume_units)); // set unit not defined if (is_numeric($this->length_units)) { @@ -1699,7 +1869,7 @@ class Product extends CommonObject /** * Get sell or eat by mandatory list * - * @return array Sell or eat by mandatory list + * @return array{0:string,1:string,2:string,3:string} Sell or eat by mandatory list */ public static function getSellOrEatByMandatoryList() { @@ -1782,7 +1952,7 @@ class Product extends CommonObject return -1; } } elseif (isset($this->multilangs[$key])) { - if (empty($this->multilangs["$key"]["label"])) { + if (empty($this->multilangs[$key]["label"])) { $this->errors[] = $key . ' : ' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")); return -1; } @@ -1974,7 +2144,7 @@ class Product extends CommonObject * used to check if price have really change to avoid log pollution * * @param int $level price level to change - * @return array + * @return array{level:int,multiprices:float,multiprices_ttc:float,multiprices_base_type:string,multiprices_min:float,multiprices_min_ttc:float,multiprices_tva_tx:float,multiprices_recuperableonly:float}|array{} */ private function getArrayForPriceCompare($level = 0) { @@ -2048,9 +2218,9 @@ class Product extends CommonObject /** * Delete a price line * - * @param User $user Object user - * @param int $rowid Line id to delete - * @return int Return integer <0 if KO, >0 if OK + * @param User $user Object user + * @param int $rowid Line id to delete + * @return int Return integer <0 if KO, >0 if OK */ public function log_price_delete($user, $rowid) { @@ -2077,7 +2247,7 @@ class Product extends CommonObject * @param Societe $thirdparty_seller Seller * @param Societe $thirdparty_buyer Buyer * @param int $pqp Id of product price per quantity if a selection was done of such a price - * @return array Array of price information array('pu_ht'=> , 'pu_ttc'=> , 'tva_tx'=>'X.Y (code)', ...), 'tva_npr'=>0, ...) + * @return array{pu_ht:float|int|string,pu_ttc:float|int|string,price_min:float|int|string,price_base_type:string,tva_tx:float|string|null|int,tva_npr:float|int} * @see get_buyprice(), find_min_price_product_fournisseur() */ public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0) @@ -2195,12 +2365,12 @@ class Product extends CommonObject * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. * This also set some properties on product like ->buyprice, ->fourn_pu, ... * - * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price - * @param double $qty Quantity asked or -1 to get first entry found - * @param int $product_id Filter on a particular product id - * @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search. - * @param int $fk_soc If of supplier - * @return int|string Return integer <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...), or printable result of hook + * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price + * @param float|int<-1,-1> $qty Quantity asked or -1 to get first entry found + * @param int $product_id Filter on a particular product id + * @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search. + * @param int $fk_soc If of supplier + * @return int|string|mixed[] Return integer <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...), or printable result of hook * @see getSellPrice(), find_min_price_product_fournisseur() */ public function get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0) @@ -2362,20 +2532,20 @@ class Product extends CommonObject /** * Modify customer price of a product/Service for a given level * - * @param double $newprice New price - * @param string $newpricebase HT or TTC - * @param User $user Object user that make change - * @param ?double $newvat New VAT Rate (For example 8.5. Should not be a string) - * @param double|int $newminprice New price min - * @param int $level 0=standard, >0 = level if multilevel prices - * @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT - * @param int $newpbq 1 if it has price by quantity - * @param int $ignore_autogen Used to avoid infinite loops - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param string $newdefaultvatcode Default vat code - * @param string $price_label Price Label - * @param int $notrigger Disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param double $newprice New price + * @param string $newpricebase HT or TTC + * @param User $user Object user that make change + * @param ?float $newvat New VAT Rate (For example 8.5. Should not be a string) + * @param float|int $newminprice New price min + * @param int $level 0=standard, >0 = level if multilevel prices + * @param int<0,1> $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT + * @param int<0,1> $newpbq 1 if it has price by quantity + * @param int<0,1> $ignore_autogen Used to avoid infinite loops + * @param array{}|array{0:string,1:int|string,2:string,3:string}|array{0:string,1:int|string,2:string,3:int|string,4:string,5:string} $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). + * @param string $newdefaultvatcode Default vat code + * @param string $price_label Price Label + * @param int $notrigger Disable triggers + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function updatePrice($newprice, $newpricebase, $user, $newvat = null, $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '', $price_label = '', $notrigger = 0) { @@ -2401,6 +2571,9 @@ class Product extends CommonObject $newvat = $this->tva_tx; } + $localtaxtype1 = ''; + $localtaxtype2 = ''; + // If multiprices are enabled, then we check if the current product is subject to price autogeneration // Price will be modified ONLY when the first one is the one that is being modified if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) && !$ignore_autogen && $this->price_autogen && ($level == 1)) { @@ -2442,7 +2615,6 @@ class Product extends CommonObject } } //print 'x'.$id.'-'.$newprice.'-'.$newpricebase.'-'.$price.'-'.$price_ttc.'-'.$price_min.'-'.$price_min_ttc; - if (count($localtaxes_array) > 0) { $localtaxtype1 = $localtaxes_array['0']; $localtax1 = $localtaxes_array['1']; @@ -3880,8 +4052,8 @@ class Product extends CommonObject /** * Charge tableau des stats facture recurrentes pour le produit/service * - * @param int $socid Id societe - * @return int Array of stats in $this->stats_facture, <0 if ko or >0 if ok + * @param int $socid Id societe + * @return int Array of stats in $this->stats_facture, <0 if ko or >0 if ok */ public function load_stats_facturerec($socid = 0) { @@ -4007,10 +4179,10 @@ class Product extends CommonObject /** * Return an array formatted for showing graphs * - * @param string $sql Request to execute - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @param int $year Year (0=current year, -1=all years) - * @return array|int Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param string $sql Request to execute + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $year Year (0=current year, -1=all years) + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ private function _get_stats($sql, $mode, $year = 0) { @@ -4090,7 +4262,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_vente($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4143,7 +4315,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_achat($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4195,7 +4367,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4247,7 +4419,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_propalsupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4299,7 +4471,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_order($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4346,12 +4518,12 @@ class Product extends CommonObject /** * Return nb of units in orders in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only - * @param int $year Year (0=last 12 month, -1=all years) - * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @param int $year Year (0=last 12 month, -1=all years) + * @param string $morefilter More sql filters + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_ordersupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4403,7 +4575,7 @@ class Product extends CommonObject * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only * @param int $year Year (0=last 12 month, -1=all years) * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_contract($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4452,12 +4624,12 @@ class Product extends CommonObject /** * Return nb of units in orders in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only - * @param int $year Year (0=last 12 month, -1=all years) - * @param string $morefilter More sql filters - * @return array Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @param int $year Year (0=last 12 month, -1=all years) + * @param string $morefilter More sql filters + * @return array,array>|int<-1,-1> Return integer <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ public function get_nb_mos($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') { @@ -4696,9 +4868,9 @@ class Product extends CommonObject /** * Check if it is a sub-product into a kit * - * @param int $fk_parent Id of parent kit product - * @param int $fk_child Id of child product - * @return int Return 1 or 0; -1 if error + * @param int $fk_parent Id of parent kit product + * @param int $fk_child Id of child product + * @return int<-1,1> Return 1 or 0; -1 if error */ public function is_sousproduit($fk_parent, $fk_child) { @@ -4734,11 +4906,11 @@ class Product extends CommonObject * Add a supplier price for the product. * Note: Duplicate ref is accepted for different quantity only, or for different companies. * - * @param User $user User that make link - * @param int $id_fourn Supplier id - * @param string $ref_fourn Supplier ref - * @param float $quantity Quantity minimum for price - * @return int Return integer < 0 if KO, 0 if link already exists for this product, > 0 if OK + * @param User $user User that make link + * @param int $id_fourn Supplier id + * @param string $ref_fourn Supplier ref + * @param float $quantity Quantity minimum for price + * @return int<-3,1> Return integer < 0 if KO, 0 if link already exists for this product, > 0 if OK */ public function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity) { @@ -4834,7 +5006,7 @@ class Product extends CommonObject /** * Return list of suppliers providing the product or service * - * @return array Array of vendor ids + * @return int[] Array of vendor ids */ public function list_suppliers() { @@ -5095,9 +5267,9 @@ class Product extends CommonObject * Build the tree of subproducts and return it. * this->sousprods must have been loaded by this->get_sousproduits_arbo() * - * @param int $multiply Because each sublevel must be multiplicated by parent nb - * @param int $ignore_stock_load Ignore stock load - * @return array Array with tree + * @param int $multiply Because each sublevel must be multiplicated by parent nb + * @param int $ignore_stock_load Ignore stock load + * @return array,entity:CommonObject}> Array with tree */ public function get_arbo_each_prod($multiply = 1, $ignore_stock_load = 0) { @@ -5238,11 +5410,11 @@ class Product extends CommonObject /** * Return children of product $id * - * @param int $id Id of product to search children of - * @param int $firstlevelonly Return only direct child - * @param int $level Level of recursing call (start to 1) - * @param array $parents Array of all parents of $id - * @return array|int Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref) + * @param int $id Id of product to search children of + * @param int $firstlevelonly Return only direct child + * @param int $level Level of recursing call (start to 1) + * @param int[] $parents Array of all parents of $id + * @return array|array{}|int<-1,-1> Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref,6:int,7:int) */ public function getChildsArbo($id, $firstlevelonly = 0, $level = 1, $parents = array()) { @@ -5327,15 +5499,16 @@ class Product extends CommonObject $parent[$this->label][$keyChild] = $valueChild; } foreach ($parent as $key => $value) { // key=label, value is array of children - $this->sousprods[$key] = $value; + $this->sousprods[$key] = $value; // @phan-suppress-current-line PhanTypeMismatchProperty } } /** * getTooltipContentArray - * @param array $params params to construct tooltip data + * + * @param array $params params to construct tooltip data + * @return array Data to show in tooltip * @since v18 - * @return array */ public function getTooltipContentArray($params) { @@ -5731,18 +5904,18 @@ class Product extends CommonObject /** * Adjust stock in a warehouse for product * - * @param User $user user asking change - * @param int $id_entrepot id of warehouse - * @param double $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove) - * @param int $movement 0 = add, 1 = remove - * @param string $label Label of stock movement - * @param double $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed. - * @param string $inventorycode Inventory code - * @param string $origin_element Origin element type - * @param int $origin_id Origin id of element - * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) - * @param Extrafields $extrafields Array of extrafields - * @return int Return integer <0 if KO, >0 if OK + * @param User $user user asking change + * @param int $id_entrepot id of warehouse + * @param float $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove) + * @param int<0,1> $movement 0 = add, 1 = remove + * @param string $label Label of stock movement + * @param float $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed. + * @param string $inventorycode Inventory code + * @param string $origin_element Origin element type + * @param ?int $origin_id Origin id of element + * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) + * @param ?ExtraFields $extrafields Array of extrafields + * @return int Return integer <0 if KO, >0 if OK */ public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null) { @@ -5790,21 +5963,21 @@ class Product extends CommonObject /** * Adjust stock in a warehouse for product with batch number * - * @param User $user user asking change - * @param int $id_entrepot id of warehouse - * @param double $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove) - * @param int $movement 0 = add, 1 = remove - * @param string $label Label of stock movement - * @param double $price Price to use for stock eval - * @param int|string $dlc eat-by date - * @param int|string $dluo sell-by date - * @param string $lot Lot number - * @param string $inventorycode Inventory code - * @param string $origin_element Origin element type - * @param int $origin_id Origin id of element - * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) - * @param Extrafields $extrafields Array of extrafields - * @param boolean $force_update_batch Force update batch + * @param User $user user asking change + * @param int $id_entrepot id of warehouse + * @param float $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove) + * @param int<0,1> $movement 0 = add, 1 = remove + * @param string $label Label of stock movement + * @param float $price Price to use for stock eval + * @param int|string $dlc eat-by date + * @param int|string $dluo sell-by date + * @param string $lot Lot number + * @param string $inventorycode Inventory code + * @param string $origin_element Origin element type + * @param ?int $origin_id Origin id of element + * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) + * @param ?ExtraFields $extrafields Array of extrafields + * @param boolean $force_update_batch Force update batch * @return int Return integer <0 if KO, >0 if OK */ public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null, $force_update_batch = false) @@ -6061,9 +6234,9 @@ class Product extends CommonObject /** * Load existing information about a serial * - * @param string $batch Lot/serial number - * @return array Array with record into product_batch - * @see load_stock(), load_virtual_stock() + * @param string $batch Lot/serial number + * @return array Array with record into product_batch + * @see load_stock(), load_virtual_stock() */ public function loadBatchInfo($batch) { @@ -6094,9 +6267,10 @@ class Product extends CommonObject /** * Move an uploaded file described into $file array into target directory $sdir. * - * @param string $sdir Target directory - * @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) - * @return int Return integer <0 if KO, >0 if OK + * @param string $sdir Target directory + + * @param array{name:string,tmp_name:string} $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) + * @return int Return integer <0 if KO, >0 if OK */ public function add_photo($sdir, $file) { @@ -6179,7 +6353,7 @@ class Product extends CommonObject * * @param string $dir Directory to scan * @param int $nbmax Number maximum of photos (0=no maximum) - * @return array Array of photos + * @return array Array of photos */ public function liste_photos($dir, $nbmax = 0) { @@ -6400,7 +6574,7 @@ class Product extends CommonObject } $var = getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM'); $mod = new $var(); - '@phan-var-force ModeleNumRefBarCode $module'; + '@phan-var-force ModeleNumRefBarCode $mod'; $result = $mod->getNextValue($object, $type); @@ -6709,9 +6883,9 @@ class Product extends CommonObject /** * Return clickable link of object (with eventually picto) * - * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) - * @param array $arraydata Array of data - * @return string HTML Code for Kanban thumb. + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param ?array{string,mixed} $arraydata Array of data + * @return string HTML Code for Kanban thumb. */ public function getKanbanView($option = '', $arraydata = null) { @@ -6773,7 +6947,7 @@ class Product extends CommonObject /** * Class to manage products or services. - * Do not use 'Service' as class name since it is already used by APIs. + * Do not use 'Service' as class name since it is already used by APIs (Note: in namespace Stripe\Service) */ class ProductService extends Product { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 791577fe95a..5652daf890f 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -68,8 +68,8 @@ $cancel = GETPOST('cancel', 'alpha'); $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); -$stocklimit = (float) GETPOST('seuil_stock_alerte'); -$desiredstock = GETPOST('desiredstock'); +$stocklimit = GETPOSTFLOAT('seuil_stock_alerte'); +$desiredstock = GETPOSTFLOAT('desiredstock'); $cancel = GETPOST('cancel', 'alpha'); $fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; $d_eatby = dol_mktime(0, 0, 0, GETPOSTINT('eatbymonth'), GETPOSTINT('eatbyday'), GETPOSTINT('eatbyyear')); @@ -175,11 +175,13 @@ if ($action == 'addlimitstockwarehouse' && $user->hasRight('produit', 'creer')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("StockLimit")), null, 'errors'); $maj_ok = false; } - if ($desiredstock == '') { + if ($desiredstock == '' || is_array($desiredstock)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DesiredStock")), null, 'errors'); $maj_ok = false; } + $desiredstock = (float) $desiredstock; + if ($maj_ok) { $pse = new ProductStockEntrepot($db); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition @@ -195,7 +197,7 @@ if ($action == 'addlimitstockwarehouse' && $user->hasRight('produit', 'creer')) $pse->fk_entrepot = GETPOSTINT('fk_entrepot'); $pse->fk_product = $id; $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); - $pse->desiredstock = GETPOST('desiredstock'); + $pse->desiredstock = GETPOSTFLOAT('desiredstock'); if ($pse->create($user) > 0) { setEventMessages($langs->trans('ProductStockWarehouseCreated'), null, 'mesgs'); } diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index f7640d2a2bf..cf358161eb4 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -7,6 +7,7 @@ * Copyright (C) 2019 Frédéric France * Copyright (C) 2021 Ferran Marcet * Copyright (C) 2021 Antonin MARCHAL + * 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 @@ -202,7 +203,7 @@ if ($action == 'order' && GETPOST('valid')) { $tva = $line->tva_tx / 100; $line->total_tva = $line->total_ht * $tva; $line->total_ttc = $line->total_ht + $line->total_tva; - $line->remise_percent = $productsupplier->remise_percent; + $line->remise_percent = (float) $productsupplier->remise_percent; $line->ref_fourn = $productsupplier->ref_supplier; $line->type = $productsupplier->type; $line->fk_unit = $productsupplier->fk_unit; @@ -243,7 +244,7 @@ if ($action == 'order' && GETPOST('valid')) { foreach ($supplier['lines'] as $line) { if (empty($line->remise_percent)) { - $line->remise_percent = $order->thirdparty->remise_supplier_percent; + $line->remise_percent = (float) $order->thirdparty->remise_supplier_percent; } $result = $order->addline( $line->desc, @@ -285,12 +286,12 @@ if ($action == 'order' && GETPOST('valid')) { foreach ($supplier['lines'] as $line) { if (empty($line->remise_percent)) { - $line->remise_percent = $order->thirdparty->remise_supplier_percent; + $line->remise_percent = (float) $order->thirdparty->remise_supplier_percent; } $order->lines[] = $line; } - $order->cond_reglement_id = $order->thirdparty->cond_reglement_supplier_id; - $order->mode_reglement_id = $order->thirdparty->mode_reglement_supplier_id; + $order->cond_reglement_id = (int) $order->thirdparty->cond_reglement_supplier_id; + $order->mode_reglement_id = (int) $order->thirdparty->mode_reglement_supplier_id; $id = $order->create($user); if ($id < 0) { diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index a0b165e98e8..fd1189fcfba 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -108,7 +108,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio public $defaultTitlesFieldsStyle = array(); /** - * @var array Array of document tablecolumns + * @var array Array of document table columns */ public $cols = array(); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index dd781cbc3b0..64ea19bf2fd 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1213,7 +1213,7 @@ class Thirdparties extends DolibarrApi $exists_sql .= " AND fk_contact = '".$this->db->escape($contact_id)."'"; $exists_result = $this->db->query($exists_sql); - if ($this->db->num_rows($exists_sql) > 0) { + if ($this->db->num_rows($exists_result) > 0) { throw new RestException(403, 'Notification already exists'); } @@ -1235,6 +1235,7 @@ class Thirdparties extends DolibarrApi * @param array $request_data Request data * * @return array|mixed Notification of thirdparty + * @phan-return Notify * * @url POST {id}/notificationsbycode/{code} */ @@ -1279,7 +1280,7 @@ class Thirdparties extends DolibarrApi $exists_sql .= " AND fk_contact = '".$this->db->escape($contact_id)."'"; $exists_result = $this->db->query($exists_sql); - if ($this->db->num_rows($exists_sql) > 0) { + if ($this->db->num_rows($exists_result) > 0) { throw new RestException(403, 'Notification already exists'); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 97054dcf2e7..aa67f97c5a4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -129,7 +129,7 @@ class Societe extends CommonObject /** * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user - * @var integer + * @var int<0,1> */ public $restrictiononfksoc = 1; @@ -140,7 +140,7 @@ class Societe extends CommonObject /** * array of supplier categories - * @var array + * @var string[] */ public $SupplierCategories = array(); @@ -511,14 +511,26 @@ class Societe extends CommonObject public $tva_intra; /** - * @var int Vat reverse-charge concerned + * @var int<0,1> Vat reverse-charge concerned */ public $vat_reverse_charge = 0; // Local taxes + /** + * @var int + */ public $localtax1_assuj; + /** + * @var string + */ public $localtax1_value; + /** + * @var int + */ public $localtax2_assuj; + /** + * @var string + */ public $localtax2_value; /** @@ -535,20 +547,60 @@ class Societe extends CommonObject * @var int Type thirdparty */ public $typent_id = 0; + /** + * @var string + */ public $typent_code; + /** + * @var int + */ public $effectif; + /** + * @var int + */ public $effectif_id = 0; - public $forme_juridique_code; - public $forme_juridique = 0; + /** + * @var int + */ + public $forme_juridique_code = 0; + /** + * @var string Label for Legal Form (of company) + * @see CommonDocGenerator::get_substitutionarray_mysoc() + */ + public $forme_juridique; + /** + * @var string + */ public $remise_percent; + /** + * @var string + */ public $remise_supplier_percent; + /** + * @var int + */ public $mode_reglement_id; + /** + * @var int + */ public $cond_reglement_id; + /** + * @var string|float + */ public $deposit_percent; + /** + * @var int + */ public $mode_reglement_supplier_id; + /** + * @var int + */ public $cond_reglement_supplier_id; + /** + * @var int + */ public $transport_mode_supplier_id; /** @@ -1084,11 +1136,11 @@ class Societe extends CommonObject /** * Create a contact/address from thirdparty * - * @param User $user Object user - * @param int $no_email 1=Do not send mailing, 0=Ok to receive mailing - * @param array $tags Array of tag to affect to contact - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user Object user + * @param int<0,1> $no_email 1=Do not send mailing, 0=Ok to receive mailing + * @param string[] $tags Array of tag to affect to contact + * @param int<0,1> $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function create_individual(User $user, $no_email = 0, $tags = array(), $notrigger = 0) { @@ -1401,16 +1453,16 @@ class Societe extends CommonObject } // Local taxes - $this->localtax1_assuj = trim($this->localtax1_assuj); - $this->localtax2_assuj = trim($this->localtax2_assuj); + $this->localtax1_assuj = (int) trim((string) $this->localtax1_assuj); + $this->localtax2_assuj = (int) trim((string) $this->localtax2_assuj); $this->localtax1_value = trim($this->localtax1_value); $this->localtax2_value = trim($this->localtax2_value); $this->capital = ($this->capital != '') ? (float) price2num(trim((string) $this->capital)) : null; - $this->effectif_id = trim((string) $this->effectif_id); - $this->forme_juridique_code = trim((string) $this->forme_juridique_code); + $this->effectif_id = (int) trim((string) $this->effectif_id); + $this->forme_juridique_code = (int) trim((string) $this->forme_juridique_code); //Gencod $this->barcode = trim($this->barcode); @@ -2151,6 +2203,7 @@ class Societe extends CommonObject $columnName = $deleteFromObject[2]; if (dol_include_once($filepath)) { $child_object = new $className($this->db); + '@phan-var-force CommonObject $child_object'; $result = $child_object->deleteByParentField($id, $columnName); if ($result < 0) { $error++; @@ -2701,9 +2754,9 @@ class Societe extends CommonObject /** * getTooltipContentArray * - * @param array $params params to construct tooltip data + * @param array $params params to construct tooltip data + * @return array Data to show in tooltip * @since v18 - * @return array */ public function getTooltipContentArray($params) { @@ -2727,11 +2780,11 @@ class Societe extends CommonObject $photo .= Form::showphoto('societe', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. $photo .= '
    '; $datas['photo'] = $photo; - } elseif (!empty($this->logo_squarred) && class_exists('Form')) { - /*$label.= '
    '; - $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. - $label.= '
    ';*/ - } + } //elseif (!empty($this->logo_squarred) && class_exists('Form')) { + /*$label.= '
    '; + $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. + $label.= '
    ';*/ + // } $datas['divopen'] = '
    '; @@ -3049,10 +3102,10 @@ class Societe extends CommonObject /** - * Return label of status (activity, closed) + * Return label of status (activity, closed) * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -3063,8 +3116,8 @@ class Societe extends CommonObject /** * Return the label of a given status * - * @param int $status Status id - * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto + * @param int $status Status id + * @param int<0,6> $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Status label */ public function LibStatut($status, $mode = 0) @@ -3090,10 +3143,10 @@ class Societe extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of contacts emails existing for third party + * Return list of contacts emails existing for third party * - * @param int $addthirdparty 1=Add also a record for thirdparty email, 2=Same than 1 but add text ThirdParty in grey - * @return array Array of contacts emails + * @param int<0,2> $addthirdparty 1=Add also a record for thirdparty email, 2=Same than 1 but add text ThirdParty in grey + * @return array<'thirdparty'|int,string> Array of contact's emails */ public function thirdparty_and_contact_email_array($addthirdparty = 0) { @@ -3115,9 +3168,9 @@ class Societe extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of contacts mobile phone existing for third party + * Return list of contacts mobile phone existing for third party * - * @return array Array of contacts emails + * @return array<'thirdparty'|int,string> Array of contacts mobile phone */ public function thirdparty_and_contact_phone_array() { @@ -3140,9 +3193,9 @@ class Societe extends CommonObject /** * Return list of contacts emails or mobile existing for third party * - * @param string $mode 'email' or 'mobile' - * @param int $hidedisabled 1=Hide contact if disabled - * @return array Array of contacts emails or mobile. Example: array(id=>'Name ') + * @param 'email'|'mobile' $mode 'email' or 'mobile' + * @param int<0,1> $hidedisabled 1=Hide contact if disabled + * @return string[] Array of contacts emails or mobile. Example: array(id=>'Name ') */ public function contact_property_array($mode = 'email', $hidedisabled = 0) { @@ -3208,9 +3261,9 @@ class Societe extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns the contact list of this company + * Return the contact list of this company * - * @return array array of contacts + * @return string[] $contacts array of contacts */ public function contact_array() { @@ -3237,9 +3290,9 @@ class Societe extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns the contact list of this company + * Return the contact list of this company * - * @return array $contacts array of contacts + * @return Contact[] $contacts array of contacts */ public function contact_array_objects() { @@ -3360,8 +3413,8 @@ class Societe extends CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE type='ban' AND fk_soc = ".((int) $this->id); $result = $this->db->query($sql); if (!$result) { - $this->error++; - $this->errors[] = $this->db->lasterror; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); return 0; } else { $num_rows = $this->db->num_rows($result); @@ -3402,6 +3455,7 @@ class Societe extends CommonObject } /** @var ModeleThirdPartyCode $mod */ $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; $this->code_client = $mod->getNextValue($objsoc, $type); $this->prefixCustomerIsRequired = $mod->prefixIsRequired; @@ -3435,6 +3489,7 @@ class Societe extends CommonObject } /** @var ModeleThirdPartyCode $mod */ $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; $this->code_fournisseur = $mod->getNextValue($objsoc, $type); @@ -3465,6 +3520,7 @@ class Societe extends CommonObject } $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; dol_syslog(get_class($this)."::codeclient_modifiable code_client=".$this->code_client." module=".$module); if ($mod->code_modifiable_null && !$this->code_client) { @@ -3505,6 +3561,7 @@ class Societe extends CommonObject } $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; dol_syslog(get_class($this)."::codefournisseur_modifiable code_founisseur=".$this->code_fournisseur." module=".$module); if ($mod->code_modifiable_null && !$this->code_fournisseur) { @@ -3551,6 +3608,7 @@ class Societe extends CommonObject } $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; dol_syslog(get_class($this)."::check_codeclient code_client=".$this->code_client." module=".$module); $result = $mod->verif($this->db, $this->code_client, $this, 0); @@ -3592,6 +3650,7 @@ class Societe extends CommonObject } $mod = new $module($this->db); + '@phan-var-force ModeleThirdPartyCode $mod'; dol_syslog(get_class($this)."::check_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$module); $result = $mod->verif($this->db, $this->code_fournisseur, $this, 1); @@ -3632,6 +3691,7 @@ class Societe extends CommonObject if ($res) { $mod = new $module(); + '@phan-var-force ModeleAccountancyCode $mod'; // Set code count in $mod->code $result = $mod->get_code($this->db, $this, $type); @@ -3735,8 +3795,8 @@ class Societe extends CommonObject * Get parents for company * * @param int $company_id ID of company to search parent - * @param array $parents List of companies ID found - * @return array + * @param int[] $parents List of companies ID found + * @return int[] */ public function getParentsForCompany($company_id, $parents = array()) { @@ -4445,7 +4505,7 @@ class Societe extends CommonObject $this->tva_intra = getDolGlobalString('MAIN_INFO_TVAINTRA'); // VAT number, not necessarily INTRA. $this->managers = getDolGlobalString('MAIN_INFO_SOCIETE_MANAGERS'); $this->capital = is_numeric(getDolGlobalString('MAIN_INFO_CAPITAL')) ? (float) price2num(getDolGlobalString('MAIN_INFO_CAPITAL')) : 0; - $this->forme_juridique_code = getDolGlobalString('MAIN_INFO_SOCIETE_FORME_JURIDIQUE'); + $this->forme_juridique_code = getDolGlobalInt('MAIN_INFO_SOCIETE_FORME_JURIDIQUE'); $this->email = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'); $this->default_lang = getDolGlobalString('MAIN_LANG_DEFAULT', 'auto'); $this->logo = getDolGlobalString('MAIN_INFO_SOCIETE_LOGO'); @@ -4716,8 +4776,8 @@ class Societe extends CommonObject /** * Return amount of proposal not yet paid and total an dlist of all proposals * - * @param string $mode 'customer' or 'supplier' - * @return array array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) + * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ public function getOutstandingProposals($mode = 'customer') { @@ -4760,8 +4820,8 @@ class Societe extends CommonObject /** * Return amount of order not yet paid and total and list of all orders * - * @param string $mode 'customer' or 'supplier' - * @return array array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) + * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ public function getOutstandingOrders($mode = 'customer') { @@ -4803,9 +4863,9 @@ class Societe extends CommonObject /** * Return amount of bill not yet paid and total of all invoices * - * @param string $mode 'customer' or 'supplier' - * @param int $late 0 => all invoice, 1=> only late - * @return array array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) + * @param 'customer'|'supplier' $mode 'customer' or 'supplier' + * @param int<0,1> $late 0 => all invoice, 1=> only late + * @return array{opened:float,total_ht:float,total_ttc:float}|array{} array('opened'=>Amount including tax that remains to pay, 'total_ht'=>Total amount without tax of all objects paid or not, 'total_ttc'=>Total amount including tax of all object paid or not) */ public function getOutstandingBills($mode = 'customer', $late = 0) { @@ -4933,13 +4993,13 @@ class Societe extends CommonObject /** * Create a document onto disk according to template module. * - * @param string $modele Generator to use. Caller must set it to obj->model_pdf. - * @param Translate $outputlangs object lang a utiliser pour traduction - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information - * @return int Return integer <0 if KO, >0 if OK + * @param string $modele Generator to use. Caller must set it to obj->model_pdf. + * @param Translate $outputlangs object lang a utiliser pour traduction + * @param int<0,1> $hidedetails Hide details of lines + * @param int<0,1> $hidedesc Hide description + * @param int<0,1> $hideref Hide ref + * @param ?array $moreparams Array to provide more information + * @return int Return integer <0 if KO, >0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { @@ -5017,7 +5077,7 @@ class Societe extends CommonObject * * @param int[]|int $salesrep User ID or array of user IDs * @param bool $onlyAdd Only add (no delete before) - * @return int Return integer <0 if KO, >0 if OK + * @return int<-1,1> Return integer <0 if KO, >0 if OK */ public function setSalesRep($salesrep, $onlyAdd = false) { @@ -5196,11 +5256,11 @@ class Societe extends CommonObject } /** - * Return clickable link of object (with eventually picto) + * Return clickable link of object (with optional picto) * - * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) - * @param array $arraydata Array of data - * @return string HTML Code for Kanban thumb. + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. */ public function getKanbanView($option = '', $arraydata = array()) { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index be7bfbc6c87..4992081e976 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -384,6 +384,8 @@ if (empty($reshook)) { //$creditnote->remise_percent = $invoice->remise_percent; $creditnote->create($user); + $fk_parent_line = 0; // Initialise + foreach ($invoice->lines as $line) { // Extrafields if (method_exists($line, 'fetch_optionals')) { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 316accdfcd6..7ea228c62c4 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -474,7 +474,7 @@ class Ticket extends CommonObject * @param string $getRef Reference of object * @return bool */ - public function checkExistingRef(string $action, string $getRef): bool + public function checkExistingRef(string $action, string $getRef) { $test = new self($this->db); diff --git a/htdocs/webportal/class/webportalinvoice.class.php b/htdocs/webportal/class/webportalinvoice.class.php index 94d92ffde54..2a55e8af420 100644 --- a/htdocs/webportal/class/webportalinvoice.class.php +++ b/htdocs/webportal/class/webportalinvoice.class.php @@ -93,7 +93,7 @@ class WebPortalInvoice extends Facture // BEGIN MODULEBUILDER PROPERTIES /** - * @var array|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + * @var array|string,position:int,notnull?:int,visible:int<-2,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 1,),