diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index be05dc5d762..6a051e0e047 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,16 +9,16 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 1580+ occurrences + // PhanTypeMismatchArgument : 1520+ occurrences // PhanUndeclaredProperty : 500+ occurrences - // PhanTypeMismatchArgumentNullable : 330+ occurrences + // PhanTypeMismatchArgumentNullable : 320+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences // PhanUndeclaredGlobalVariable : 160+ occurrences // PhanTypeMismatchProperty : 120+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences // PhanPossiblyUndeclaredGlobalVariable : 55+ occurrences // PhanTypeMismatchArgumentProbablyReal : 55+ occurrences - // PhanTypeExpectedObjectPropAccess : 35+ occurrences + // PhanTypeExpectedObjectPropAccess : 30+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanPluginUndeclaredVariableIsset : 15+ occurrences @@ -30,19 +30,20 @@ return [ // PhanTypeArraySuspiciousNull : 6 occurrences // PhanParamTooMany : 5 occurrences // PhanPluginDuplicateArrayKey : 4 occurrences - // PhanPluginSuspiciousParamPosition : 4 occurrences // PhanEmptyFQSENInClasslike : 3 occurrences // PhanInvalidFQSENInClasslike : 3 occurrences - // PhanPluginBothLiteralsBinaryOp : 3 occurrences + // PhanPluginSuspiciousParamPosition : 3 occurrences // PhanPluginEmptyStatementIf : 2 occurrences // PhanRedefineFunction : 2 occurrences // PhanTypeMismatchDimAssignment : 2 occurrences // PhanTypeSuspiciousStringExpression : 2 occurrences // PhanAccessMethodProtected : 1 occurrence + // PhanPluginBothLiteralsBinaryOp : 1 occurrence // PhanPluginDuplicateExpressionAssignmentOperation : 1 occurrence // PhanPluginUnknownArrayPropertyType : 1 occurrence // PhanPossiblyUndeclaredVariable : 1 occurrence // PhanTypeExpectedObjectPropAccessButGotNull : 1 occurrence + // PhanUndeclaredVariable : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ @@ -523,7 +524,6 @@ return [ 'htdocs/fichinter/agenda.php' => ['PhanTypeMismatchArgument'], 'htdocs/fichinter/card-rec.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/fichinter/class/api_interventions.class.php' => ['PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'], - 'htdocs/fichinter/class/fichinter.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/fichinter/class/fichinterrec.class.php' => ['PhanUndeclaredProperty'], 'htdocs/fichinter/contact.php' => ['PhanTypeMismatchArgument'], 'htdocs/fichinter/document.php' => ['PhanTypeMismatchArgument'], @@ -641,19 +641,10 @@ return [ 'htdocs/societe/class/api_thirdparties.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], 'htdocs/societe/class/societe.class.php' => ['PhanTypeMismatchProperty'], 'htdocs/societe/paymentmodes.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument'], - 'htdocs/stripe/admin/stripe.php' => ['PhanTypeMismatchArgument'], - 'htdocs/stripe/charge.php' => ['PhanTypeMismatchArgument'], - 'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginSuspiciousParamPosition', 'PhanTypeMismatchArgument'], - 'htdocs/stripe/class/stripe.class.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchProperty'], - 'htdocs/stripe/lib/stripe.lib.php' => ['PhanTypeMismatchArgument'], - 'htdocs/supplier_proposal/card.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], + 'htdocs/stripe/class/stripe.class.php' => ['PhanTypeExpectedObjectPropAccess'], + 'htdocs/supplier_proposal/card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/supplier_proposal/class/api_supplier_proposals.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'], - 'htdocs/supplier_proposal/class/supplier_proposal.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/supplier_proposal/contact.php' => ['PhanTypeMismatchArgument'], - 'htdocs/supplier_proposal/document.php' => ['PhanTypeMismatchArgument'], - 'htdocs/supplier_proposal/info.php' => ['PhanTypeMismatchArgument'], - 'htdocs/supplier_proposal/list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/supplier_proposal/note.php' => ['PhanTypeMismatchArgument'], + 'htdocs/supplier_proposal/class/supplier_proposal.class.php' => ['PhanUndeclaredProperty'], 'htdocs/takepos/admin/bar.php' => ['PhanTypeMismatchArgument'], 'htdocs/takepos/admin/terminal.php' => ['PhanTypeMismatchArgument'], 'htdocs/takepos/ajax/ajax.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 16b6a9bff32..ced465ac3f7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -956,7 +956,7 @@ abstract class CommonObject /** * setErrorsFromObject * - * @param CommonObject $object commonobject + * @param CommonObject|HookManager $object commonobject or HookManager * @return void */ public function setErrorsFromObject($object) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 77999453856..5a63260084d 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -4,7 +4,7 @@ * Copyright (C) 2017 Saasprov * Copyright (C) 2018-2022 Thibault FOUCART * Copyright (C) 2018-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -455,7 +455,7 @@ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // TODO Not used by current c // If $site_account not defined, then key not set and no way to call API Location $stripeacc = $stripe->getStripeAccount($service); if ($stripeacc) { - $locations = \Stripe\Terminal\Location::all('', array("stripe_account" => $stripeacc)); + $locations = \Stripe\Terminal\Location::all(null, array("stripe_account" => $stripeacc)); } else { $locations = \Stripe\Terminal\Location::all(); } diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 98ebb3690c6..a209a77b419 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -1,7 +1,7 @@ * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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,15 +202,15 @@ if (!$rowid) { // Save into $tmparray all metadata $tmparray = dolExplodeIntoArray($FULLTAG, '.', '='); // Load origin object according to metadata - if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0) { - $societestatic->fetch($tmparray['CUS']); + if (!empty($tmparray['CUS']) && (int) $tmparray['CUS'] > 0) { + $societestatic->fetch((int) $tmparray['CUS']); } elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) { $societestatic->fetch($charge->metadata->dol_thirdparty_id); } else { $societestatic->id = 0; } - if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0) { - $memberstatic->fetch($tmparray['MEM']); + if (!empty($tmparray['MEM']) && (int) $tmparray['MEM'] > 0) { + $memberstatic->fetch((int) $tmparray['MEM']); } else { $memberstatic->id = 0; } diff --git a/htdocs/stripe/class/actions_stripe.class.php b/htdocs/stripe/class/actions_stripe.class.php index 7dbf68d7fb9..571baa695ed 100644 --- a/htdocs/stripe/class/actions_stripe.class.php +++ b/htdocs/stripe/class/actions_stripe.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2009-2016 Regis Houssin * Copyright (C) 2011 Herve Prot * Copyright (C) 2014 Philippe Grand - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -126,7 +126,7 @@ class ActionsStripeconnect extends CommonHookActions $this->resprints .= ''; $this->resprints .= ''; $stripe = new Stripe($this->db); - if (7 == 4) { + if (7 == 4) { // @phan-suppress-current-line PhanPluginBothLiteralsBinaryOp $object->fetch_thirdparty(); $customer = $stripe->customerStripe($object, $stripe->getStripeAccount($service)); $this->resprints .= $customer->id; @@ -145,7 +145,7 @@ class ActionsStripeconnect extends CommonHookActions $this->resprints .= ''; $this->resprints .= ''; $stripe = new Stripe($this->db); - if (7 == 4) { + if (7 == 4) { // @phan-suppress-current-line PhanPluginBothLiteralsBinaryOp $object->fetch_thirdparty(); $customer = $stripe->customerStripe($object, $stripe->getStripeAccount($service)); $this->resprints .= $customer->id; @@ -196,7 +196,14 @@ class ActionsStripeconnect extends CommonHookActions if ($object->statut > Facture::STATUS_DRAFT && $object->statut < Facture::STATUS_ABANDONED && $object->paye == 0) { $stripe = new Stripe($this->db); if ($resteapayer > 0) { - if ($stripe->getStripeAccount($conf->entity)) { // a modifier avec droit stripe + if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha'))) { + $service = 'StripeTest'; + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), [], 'warning'); + } else { + $service = 'StripeLive'; + } + + if ($stripe->getStripeAccount($service, 0, $conf->entity)) { // To modify with stripe authorizations $langs->load("withdrawals"); print ''.$langs->trans("StripeConnectPay").''; } else { diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index d9df53069b4..5b519643dd7 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; // This set stripe global e /** * Stripe class - * @TODO No reason to extends CommonObject + * @TODO No reason to extend CommonObject */ class Stripe extends CommonObject { @@ -47,9 +47,9 @@ class Stripe extends CommonObject public $fk_key; /** - * @var int ID + * @var string Stripe ID (Note: Conflict with CommonObject) */ - public $id; + public $id; // @phpstan-ignore-line /** * @var string @@ -101,10 +101,10 @@ class Stripe extends CommonObject /** * Return main company OAuth Connect stripe account * - * @param string $mode 'StripeTest' or 'StripeLive' - * @param int $fk_soc Id of thirdparty - * @param int $entity Id of entity (-1 = current environment) - * @return string Stripe account 'acc_....' or '' if no OAuth token found + * @param 'StripeTest'|'StripeLive' $mode 'StripeTest' or 'StripeLive' + * @param int $fk_soc Id of third party + * @param int $entity Id of entity (-1 = current environment) + * @return string Stripe account 'acc_....' or '' if no OAuth token found */ public function getStripeAccount($mode = 'StripeTest', $fk_soc = 0, $entity = -1) { @@ -153,10 +153,10 @@ class Stripe extends CommonObject /** * getStripeCustomerAccount * - * @param int $id Id of third party - * @param int $status Status - * @param string $site_account Value to use to identify with account to use on site when site can offer several accounts. For example: 'pk_live_123456' when using Stripe service. - * @return string Stripe customer ref 'cu_xxxxxxxxxxxxx' or '' + * @param int $id Id of third party + * @param int<0,1> $status Status + * @param string $site_account Value to use to identify with account to use on site when site can offer several accounts. For example: 'pk_live_123456' when using Stripe service. + * @return string Stripe customer ref 'cu_xxxxxxxxxxxxx' or '' */ public function getStripeCustomerAccount($id, $status = 0, $site_account = '') { @@ -262,15 +262,15 @@ class Stripe extends CommonObject if (!empty($vatcleaned)) { $isineec = isInEEC($object); if ($object->country_code && $isineec) { - //$taxids = $customer->allTaxIds($customer->id); - $customer->createTaxId($customer->id, array('type' => 'eu_vat', 'value' => $vatcleaned)); + //$taxids = $customer->allTaxIds($customer); + $customer->createTaxId($customer, array('type' => 'eu_vat', 'value' => $vatcleaned)); } } } // Create customer in Dolibarr $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)"; - $sql .= " VALUES (".((int) $object->id).", '', '".$this->db->escape($customer->id)."', 'stripe', '".$this->db->escape($stripearrayofkeysbyenv[$status]['publishable_key'])."', ".((int) $status).", ".((int) $conf->entity).", '".$this->db->idate(dol_now())."', ".((int) $user->id).")"; + $sql .= " VALUES (".((int) $object->id).", '', '".$this->db->escape($customer)."', 'stripe', '".$this->db->escape($stripearrayofkeysbyenv[$status]['publishable_key'])."', ".((int) $status).", ".((int) $conf->entity).", '".$this->db->idate(dol_now())."', ".((int) $user->id).")"; $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->lasterror(); @@ -289,9 +289,9 @@ class Stripe extends CommonObject /** * Get the Stripe payment method Object from its ID * - * @param string $paymentmethod Payment Method ID - * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect - * @param int $status Status (0=test, 1=live) + * @param Stripe $paymentmethod Payment Method ID + * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect + * @param int<0,1> $status Status (0=test, 1=live) * @return \Stripe\PaymentMethod|null Stripe PaymentMethod or null if not found */ public function getPaymentMethodStripe($paymentmethod, $key = '', $status = 0) @@ -317,10 +317,10 @@ class Stripe extends CommonObject /** * Get the Stripe reader Object from its ID * - * @param string $reader Reader ID - * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect - * @param int $status Status (0=test, 1=live) - * @return \Stripe\Terminal\Reader|null Stripe Reader or null if not found + * @param string $reader Reader ID + * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect + * @param int<0,1> $status Status (0=test, 1=live) + * @return \Stripe\Terminal\Reader|null Stripe Reader or null if not found */ public function getSelectedReader($reader, $key = '', $status = 0) { @@ -351,21 +351,21 @@ class Stripe extends CommonObject * Note: This is used when option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is on when making a payment from the public/payment/newpayment.php page * but not when using the STRIPE_USE_NEW_CHECKOUT. * - * @param double $amount Amount - * @param string $currency_code Currency code - * @param string $tag Tag - * @param string $description Description - * @param ?CommonObject $object Object to pay with Stripe - * @param ?string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() - * @param ?string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect - * @param int $status Status (0=test, 1=live) - * @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt - * @param string $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent - * @param boolean $confirmnow false=default, true=try to confirm immediately after create (if conditions are ok) - * @param ?string $payment_method 'pm_....' (if known) - * @param int $off_session If we use an already known payment method to pay when customer is not available during the checkout flow. - * @param int $noidempotency_key Do not use the idempotency_key when creating the PaymentIntent - * @param int $did ID of an existing line into llx_prelevement_demande (Dolibarr intent). If provided, no new line will be created. + * @param float $amount Amount + * @param string $currency_code Currency code + * @param string $tag Tag + * @param string $description Description + * @param ?CommonObject $object Object to pay with Stripe + * @param ?string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() + * @param ?string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect + * @param int<0,1> $status Status (0=test, 1=live) + * @param int<0,1> $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt + * @param 'automatic'|'manual' $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent + * @param bool $confirmnow false=default, true=try to confirm immediately after create (if conditions are ok) + * @param ?string $payment_method 'pm_....' (if known) + * @param int<0,1> $off_session If we use an already known payment method to pay when customer is not available during the checkout flow. + * @param int<0,1> $noidempotency_key Do not use the idempotency_key when creating the PaymentIntent + * @param int $did ID of an existing line into llx_prelevement_demande (Dolibarr intent). If provided, no new line will be created. * @return ?\Stripe\PaymentIntent Stripe PaymentIntent or null if not found and failed to create */ public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false, $payment_method = null, $off_session = 0, $noidempotency_key = 1, $did = 0) @@ -664,14 +664,14 @@ class Stripe extends CommonObject * Note: This is used when option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is on when making a payment from the public/payment/newpayment.php page * but not when using the STRIPE_USE_NEW_CHECKOUT. * - * @param string $description Description - * @param Societe $object Object of company to link the Stripe payment mode with - * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() - * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect - * @param int $status Status (0=test, 1=live) - * @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt - * @param boolean $confirmnow false=default, true=try to confirm immediately after create (if conditions are ok) - * @return \Stripe\SetupIntent|null Stripe SetupIntent or null if not found and failed to create + * @param string $description Description + * @param Societe $object Object of company to link the Stripe payment mode with + * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() + * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect + * @param int<0,1> $status Status (0=test, 1=live) + * @param int<0,1> $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt + * @param bool $confirmnow false=default, true=try to confirm immediately after create (if conditions are ok) + * @return \Stripe\SetupIntent|null Stripe SetupIntent or null if not found and failed to create */ public function getSetupIntent($description, $object, $customer, $key, $status, $usethirdpartyemailforreceiptemail = 0, $confirmnow = false) { @@ -836,8 +836,8 @@ class Stripe extends CommonObject * @param \Stripe\Customer $cu Object stripe customer. * @param CompanyPaymentMode $object Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity) * @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect - * @param int $status Status (0=test, 1=live) - * @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card. Deprecated with new Stripe API and SCA. + * @param int<0,1> $status Status (0=test, 1=live) + * @param int<0,1> $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card. Deprecated with new Stripe API and SCA. * @return \Stripe\Card|\Stripe\PaymentMethod|null Stripe Card or null if not found */ public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0) @@ -988,8 +988,8 @@ class Stripe extends CommonObject * @param \Stripe\Customer $cu Object stripe customer. * @param CompanyPaymentMode $object Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity) * @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect - * @param int $status Status (0=test, 1=live) - * @param int $createifnotlinkedtostripe 1=Create the stripe sepa and the link if the sepa is not yet linked to a stripe sepa. Used by the "Create bank to Stripe" feature. + * @param int<0,1> $status Status (0=test, 1=live) + * @param int<0,1> $createifnotlinkedtostripe 1=Create the stripe sepa and the link if the sepa is not yet linked to a stripe sepa. Used by the "Create bank to Stripe" feature. * @return \Stripe\PaymentMethod|null Stripe SEPA or null if not found */ public function sepaStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0) @@ -1161,16 +1161,16 @@ class Stripe extends CommonObject * Create charge. * This was called by page htdocs/stripe/payment.php and may be deprecated. * - * @param int $amount Amount to pay - * @param string $currency EUR, GPB... - * @param string $origin Object type to pay (order, invoice, contract...) - * @param int $item Object id to pay - * @param string $source src_xxxxx or card_xxxxx or pm_xxxxx - * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() - * @param string $account Stripe account ref 'acc_xxxxxxxxxxxxx' via getStripeAccount() - * @param int $status Status (0=test, 1=live) - * @param int $usethirdpartyemailforreceiptemail Use thirdparty email as receipt email - * @param boolean $capture Set capture flag to true (take payment) or false (wait) + * @param float $amount Amount to pay + * @param string $currency EUR, GPB... + * @param string $origin Object type to pay (order, invoice, contract...) + * @param int $item Object id to pay + * @param string $source src_xxxxx or card_xxxxx or pm_xxxxx + * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() + * @param string $account Stripe account ref 'acc_xxxxxxxxxxxxx' via getStripeAccount() + * @param int<0,1> $status Status (0=test, 1=live) + * @param int<0,1> $usethirdpartyemailforreceiptemail Use thirdparty email as receipt email + * @param bool $capture Set capture flag to true (take payment) or false (wait) * @return Stripe * @deprecated */ @@ -1262,10 +1262,10 @@ class Stripe extends CommonObject dol_syslog("* createPaymentStripe get stripeacc", LOG_DEBUG); $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account if it exists (no network access here) - dol_syslog("* createPaymentStripe Create payment for customer ".$customer->id." on source card ".$stripecard->id.", amounttopay=".$amounttopay.", amountstripe=".$amountstripe.", FULLTAG=".$FULLTAG, LOG_DEBUG); + dol_syslog("* createPaymentStripe Create payment for customer ".$customer." on source card ".$stripecard.", amounttopay=".$amounttopay.", amountstripe=".$amountstripe.", FULLTAG=".$FULLTAG, LOG_DEBUG); // Create payment intent and charge payment (confirmnow = true) - $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1); + $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard, 1); $charge = new stdClass(); if ($paymentintent->status == 'succeeded') { @@ -1297,8 +1297,8 @@ class Stripe extends CommonObject "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, - "source" => "$source", - "customer" => "$customer" + "source" => (string) $source, + "customer" => (string) $customer ); if ($societe->email && $usethirdpartyemailforreceiptemail) { @@ -1329,8 +1329,8 @@ class Stripe extends CommonObject "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, - "source" => "$source", - "customer" => "$customer" + "source" => (string) $source, + "customer" => (string) $customer ); if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) { $paymentarray["application_fee_amount"] = $stripefee; @@ -1350,10 +1350,10 @@ class Stripe extends CommonObject dol_syslog("* createPaymentStripe get stripeacc", LOG_DEBUG); $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account if it exists (no network access here) - dol_syslog("* createPaymentStripe Create payment on card ".$stripecard->id.", amounttopay=".$amounttopay.", amountstripe=".$amountstripe.", FULLTAG=".$FULLTAG, LOG_DEBUG); + dol_syslog("* createPaymentStripe Create payment on card ".$stripecard.", amounttopay=".$amounttopay.", amountstripe=".$amountstripe.", FULLTAG=".$FULLTAG, LOG_DEBUG); // Create payment intent and charge payment (confirmnow = true) - $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1); + $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard, 1); $charge = new stdClass(); if ($paymentintent->status == 'succeeded') { diff --git a/htdocs/stripe/lib/stripe.lib.php b/htdocs/stripe/lib/stripe.lib.php index 9f94fadd5eb..0db5a3ce787 100644 --- a/htdocs/stripe/lib/stripe.lib.php +++ b/htdocs/stripe/lib/stripe.lib.php @@ -1,7 +1,7 @@ * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -74,7 +74,7 @@ function html_print_stripe_footer($fromcompany, $langs) } // Capital if ($fromcompany->capital) { - $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); + $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", (string) $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); } $reg = array(); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index b2db6563314..f6305ab1949 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -14,7 +14,7 @@ * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2024 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -291,8 +291,8 @@ if (empty($reshook)) { $db->begin(); // When a copy request was made, make the copy - if (GETPOST('createmode') == 'copy' && GETPOST('copie_supplier_proposal')) { - if ($object->fetch(GETPOST('copie_supplier_proposal')) > 0) { + if (GETPOST('createmode') == 'copy' && GETPOSTINT('copie_supplier_proposal') > 0) { + if ($object->fetch(GETPOSTINT('copie_supplier_proposal')) > 0) { $object->ref = GETPOST('ref'); $object->delivery_date = $date_delivery; $object->shipping_method_id = GETPOSTINT('shipping_method_id'); @@ -537,7 +537,7 @@ if (empty($reshook)) { } else { // prevent browser refresh from closing proposal several times if ($object->statut == SupplierProposal::STATUS_VALIDATED) { - $object->cloture($user, GETPOST('statut'), GETPOST('note', 'restricthtml')); + $object->cloture($user, GETPOSTINT('statut'), GETPOST('note', 'restricthtml')); } } } @@ -593,7 +593,7 @@ if (empty($reshook)) { $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); foreach ($object->lines as $line) { - $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->fk_unit, $line->multicurrency_subprice); + $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, (float) $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->fk_unit, $line->multicurrency_subprice); } } elseif ($action == 'addline' && $usercancreate) { $langs->load('errors'); @@ -674,7 +674,7 @@ if (empty($reshook)) { $reg = array(); if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { - $idprod = $reg[1]; + $idprod = (int) $reg[1]; $res = $productsupplier->fetch($idprod); // Load product from its id // Call to init some price properties of $productsupplier // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price @@ -688,10 +688,10 @@ if (empty($reshook)) { $fksoctosearch = $object->thirdparty->id; $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist } - } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { + } elseif (GETPOSTINT('idprodfournprice') > 0) { // id here. //$qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. $qtytosearch = -1; // We force qty to -1 to be sure to find if the supplier price that exists - $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); + $idprod = $productsupplier->get_buyprice(GETPOSTINT('idprodfournprice'), $qtytosearch); $res = $productsupplier->fetch($idprod); } @@ -785,7 +785,7 @@ if (empty($reshook)) { $result = $object->addline( $desc, ($price_base_type == 'HT' ? $pu : 0), - $qty, + (float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, @@ -797,7 +797,7 @@ if (empty($reshook)) { $type, min($rank, count($object->lines) + 1), 0, - GETPOST('fk_parent_line'), + GETPOSTINT('fk_parent_line'), $fournprice, $buyingprice, $label, @@ -839,9 +839,9 @@ if (empty($reshook)) { $tva_tx = str_replace('*', '', $tva_tx); $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $desc = $product_desc; - $type = GETPOST('type'); + $type = GETPOSTINT('type'); - $fk_unit = GETPOST('units', 'alpha'); + $fk_unit = GETPOSTINT('units'); if (!preg_match('/\((.*)\)/', $tva_tx)) { $tva_tx = price2num($tva_tx); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' @@ -863,20 +863,20 @@ if (empty($reshook)) { $result = $object->addline( $desc, - $pu_ht, - $qty, - $tva_tx, + (float) $pu_ht, + (float) $qty, + (float) $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, - $pu_ttc, + (float) $pu_ttc, $info_bits, $type, -1, // rang 0, // special_code - GETPOST('fk_parent_line'), + GETPOSTINT('fk_parent_line'), $fournprice, $buyingprice, $label, @@ -885,7 +885,7 @@ if (empty($reshook)) { $fk_unit, '', // origin 0, // origin_id - $pu_ht_devise + (float) $pu_ht_devise ); } @@ -1003,7 +1003,7 @@ if (empty($reshook)) { $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU', 2); // Add buying price - $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $fournprice = (GETPOST('fournprice') ? GETPOSTINT('fournprice') : ''); // foreigh key $buyingprice = (GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we must keep this value // Extrafields Lines @@ -1027,7 +1027,7 @@ if (empty($reshook)) { if (!empty($productid)) { $productsupplier = new ProductFournisseur($db); if (getDolGlobalInt('SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY') == 1) { // Not the common case - if ($productid > 0 && $productsupplier->get_buyprice(0, price2num(GETPOST('qty')), $productid, 'none', GETPOSTINT('socid')) < 0) { + if ($productid > 0 && $productsupplier->get_buyprice(0, (float) price2num(GETPOST('qty')), $productid, 'none', GETPOSTINT('socid')) < 0) { setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); } } @@ -1058,14 +1058,14 @@ if (empty($reshook)) { $db->begin(); $ref_supplier = GETPOST('fourn_ref', 'alpha'); - $fk_unit = GETPOST('units'); + $fk_unit = GETPOSTINT('units'); $result = $object->updateline( GETPOSTINT('lineid'), $ht, - price2num(GETPOST('qty'), 'MS', 2), - price2num(GETPOST('remise_percent'), '', 2), - $vat_rate, + (float) price2num(GETPOST('qty'), 'MS', 2), + (float) price2num(GETPOST('remise_percent'), '', 2), + (float) $vat_rate, $localtax1_rate, $localtax2_rate, $description, @@ -1074,14 +1074,14 @@ if (empty($reshook)) { $special_code, GETPOSTINT('fk_parent_line'), 0, - $fournprice, - $buyingprice, + (int) $fournprice, + (float) $buyingprice, $label, $type, $array_options, $ref_supplier, $fk_unit, - $pu_ht_devise + (float) $pu_ht_devise ); if ($result >= 0) { @@ -1155,7 +1155,7 @@ if (empty($reshook)) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { // Multicurrency rate - $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOSTINT('calculation_mode')); + $result = $object->setMulticurrencyRate((float) price2num(GETPOST('multicurrency_tx')), GETPOSTINT('calculation_mode')); } elseif ($action == 'update_extras' && $usercancreate) { $object->oldcopy = dol_clone($object, 2); $attribute_name = GETPOST('attribute', 'restricthtml'); @@ -1647,7 +1647,7 @@ if ($action == 'create') { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -1709,9 +1709,9 @@ if ($action == 'create') { print ''; print ''; if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->cond_reglement_id, 'cond_reglement_id', 1); } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->cond_reglement_id, 'none', 1); } print ''; print ''; @@ -1753,9 +1753,9 @@ if ($action == 'create') { print ''; print ''; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->mode_reglement_id, 'none'); } print ''; @@ -1784,9 +1784,9 @@ if ($action == 'create') { print ''; print ''; if ($action == 'editbankaccount') { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'fk_account', 1); } else { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'none'); } print ''; print ''; @@ -2052,7 +2052,7 @@ if ($action == 'create') { $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); // Show links to link elements diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index fd534683010..2b0f65ecfb7 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -572,7 +572,7 @@ class SupplierProposal extends CommonObject $pu = 0; } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, (float) $remise_percent, $txtva, (float) $txlocaltax1, (float) $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -717,9 +717,9 @@ class SupplierProposal extends CommonObject * @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 float $pa_ht Price (without tax) of product when it was bought * @param string $label ??? - * @param int $type 0/1=Product/service + * @param int<0,1> $type 0/1=Product/service * @param array $array_options extrafields array * @param string $ref_supplier Supplier price reference * @param int $fk_unit Id of the unit to use. @@ -772,7 +772,7 @@ class SupplierProposal extends CommonObject $pu = 0; } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, (float) $remise_percent, $txtva, (float) $txlocaltax1, (float) $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -1862,11 +1862,11 @@ class SupplierProposal extends CommonObject } /** - * Create ProductFournisseur + * Create Price Fournisseur * - * @param Product $product Object Product - * @param User $user Object user - * @return int Return integer <0 if KO, >0 if OK + * @param ProductFournisseur $product Object Product TODO: Determine the correct type + * @param User $user Object user + * @return int Return integer <0 if KO, >0 if OK */ public function createPriceFournisseur($product, $user) { @@ -1880,14 +1880,14 @@ class SupplierProposal extends CommonObject $values = array( "'".$this->db->idate($now)."'", - $product->fk_product, - $this->thirdparty->id, - "'".$product->ref_fourn."'", - $price, - $qty, - $unitPrice, - $product->tva_tx, - $user->id + (int) $product->fk_product, + (int) $this->thirdparty->id, + "'".$this->db->escape($product->ref_fourn)."'", + (float) $price, + (float) $qty, + (float) $unitPrice, + (float) $product->tva_tx, + (int) $user->id ); if (isModEnabled("multicurrency")) { if (!empty($product->multicurrency_code)) { @@ -1895,11 +1895,11 @@ class SupplierProposal extends CommonObject $multicurrency = new MultiCurrency($this->db); //need to fetch because empty fk_multicurrency and rate $multicurrency->fetch(0, $product->multicurrency_code); if (!empty($multicurrency->id)) { - $values[] = $multicurrency->id; - $values[] = "'".$product->multicurrency_code."'"; - $values[] = $product->multicurrency_subprice; - $values[] = $product->multicurrency_total_ht; - $values[] = $multicurrency->rate->rate; + $values[] = (int) $multicurrency->id; + $values[] = "'".$this->db->escape($product->multicurrency_code)."'"; + $values[] = (float) $product->multicurrency_subprice; + $values[] = (float) $product->multicurrency_total_ht; + $values[] = (float) $multicurrency->rate->rate; } else { for ($i = 0; $i < 5; $i++) { $values[] = 'NULL'; @@ -3306,7 +3306,7 @@ class SupplierProposalLine extends CommonObjectLine $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " '".$this->db->escape($this->desc)."',"; $sql .= " ".($this->fk_product ? ((int) $this->fk_product) : "null").","; - $sql .= " '".$this->db->escape($this->product_type)."',"; + $sql .= " '".$this->db->escape((string) $this->product_type)."',"; $sql .= " ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : "null").","; $sql .= " ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null").","; $sql .= " ".($this->fk_remise_except ? ((int) $this->fk_remise_except) : "null").","; @@ -3506,7 +3506,7 @@ class SupplierProposalLine extends CommonObjectLine $sql .= " , qty='".price2num($this->qty)."'"; $sql .= " , subprice=".price2num($this->subprice); $sql .= " , remise_percent=".price2num($this->remise_percent); - $sql .= " , info_bits='".$this->db->escape($this->info_bits)."'"; + $sql .= " , info_bits='".$this->db->escape((string) $this->info_bits)."'"; if (empty($this->skip_update_total)) { $sql .= " , total_ht=".price2num($this->total_ht); $sql .= " , total_tva=".price2num($this->total_tva); @@ -3514,7 +3514,7 @@ class SupplierProposalLine extends CommonObjectLine $sql .= " , total_localtax1=".price2num($this->total_localtax1); $sql .= " , total_localtax2=".price2num($this->total_localtax2); } - $sql .= " , fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); + $sql .= " , fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape((string) $this->fk_fournprice)."'" : "null"); $sql .= " , buy_price_ht=".price2num($this->pa_ht); $sql .= " , special_code=".((int) $this->special_code); $sql .= " , fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index 32fa86a340f..d2181e2a6e9 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -6,6 +6,7 @@ * Copyright (C) 2023 Christian Foellmann * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -70,7 +71,7 @@ $permissiontoedit = $user->hasRight('supplier_proposal', 'creer'); * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -84,8 +85,8 @@ if (empty($reshook)) { $result = $object->fetch($id); if ($result > 0 && $id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid')); + $typeid = (GETPOSTINT('typecontact') ? GETPOSTINT('typecontact') : GETPOSTINT('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source")); } @@ -170,7 +171,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 84dc220c10a..70aa85e623d 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -7,6 +7,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -143,7 +144,7 @@ if ($object->id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index 17a26d97b4f..ee9f1a453a2 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -5,6 +5,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -103,7 +104,7 @@ if (isModEnabled('project')) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index a6b657987a0..7e5662acfc3 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -12,7 +12,7 @@ * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018-2023 Charlene Benke * Copyright (C) 2021-2024 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Benjamin Falière * Copyright (C) 2024 Frédéric France * @@ -176,37 +176,36 @@ if (empty($user->socid)) { $fieldstosearchall["p.note_private"] = "NotePrivate"; } -$checkedtypetiers = 0; +$checkedtypetiers = '0'; $arrayfields = array( - 'sp.ref' => array('label' => $langs->trans("Ref"), 'checked' => 1), - 's.nom' => array('label' => $langs->trans("Supplier"), 'checked' => 1), - 's.name_alias' => array('label' => "AliasNameShort", 'checked' => 0), - 's.town' => array('label' => $langs->trans("Town"), 'checked' => 1), - 's.zip' => array('label' => $langs->trans("Zip"), 'checked' => 1), - 'state.nom' => array('label' => $langs->trans("StateShort"), 'checked' => 0), - 'country.code_iso' => array('label' => $langs->trans("Country"), 'checked' => 0), + 'sp.ref' => array('label' => $langs->trans("Ref"), 'checked' => '1'), + 's.nom' => array('label' => $langs->trans("Supplier"), 'checked' => '1'), + 's.name_alias' => array('label' => "AliasNameShort", 'checked' => '0'), + 's.town' => array('label' => $langs->trans("Town"), 'checked' => '1'), + 's.zip' => array('label' => $langs->trans("Zip"), 'checked' => '1'), + 'state.nom' => array('label' => $langs->trans("StateShort"), 'checked' => '0'), + 'country.code_iso' => array('label' => $langs->trans("Country"), 'checked' => '0'), 'typent.code' => array('label' => $langs->trans("ThirdPartyType"), 'checked' => $checkedtypetiers), - 'sp.date_valid' => array('label' => $langs->trans("DateValidation"), 'checked' => 1), - 'sp.date_livraison' => array('label' => $langs->trans("DateEnd"), 'checked' => 1), - 'sp.total_ht' => array('label' => $langs->trans("AmountHT"), 'checked' => 1), - 'sp.total_tva' => array('label' => $langs->trans("AmountVAT"), 'checked' => 0), - 'sp.total_ttc' => array('label' => $langs->trans("AmountTTC"), 'checked' => 0), - 'sp.multicurrency_code' => array('label' => 'Currency', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), - 'sp.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), - 'sp.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), - 'sp.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), - 'sp.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => 0, 'enabled' => (!isModEnabled("multicurrency") ? 0 : 1)), - 'u.login' => array('label' => $langs->trans("Author"), 'checked' => 1, 'position' => 10), - 'sp.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500), - 'sp.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 500), - 'sp.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => 1, 'position' => 1000), + 'sp.date_valid' => array('label' => $langs->trans("DateValidation"), 'checked' => '1'), + 'sp.date_livraison' => array('label' => $langs->trans("DateEnd"), 'checked' => '1'), + 'sp.total_ht' => array('label' => $langs->trans("AmountHT"), 'checked' => '1'), + 'sp.total_tva' => array('label' => $langs->trans("AmountVAT"), 'checked' => '0'), + 'sp.total_ttc' => array('label' => $langs->trans("AmountTTC"), 'checked' => '0'), + 'sp.multicurrency_code' => array('label' => 'Currency', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')), + 'sp.multicurrency_tx' => array('label' => 'CurrencyRate', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')), + 'sp.multicurrency_total_ht' => array('label' => 'MulticurrencyAmountHT', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')), + 'sp.multicurrency_total_vat' => array('label' => 'MulticurrencyAmountVAT', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')), + 'sp.multicurrency_total_ttc' => array('label' => 'MulticurrencyAmountTTC', 'checked' => '0', 'enabled' => (!isModEnabled("multicurrency") ? '0' : '1')), + 'u.login' => array('label' => $langs->trans("Author"), 'checked' => '1', 'position' => 10), + 'sp.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => '0', 'position' => 500), + 'sp.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => '0', 'position' => 500), + 'sp.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => '1', 'position' => 1000), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Check only if it's an internal user if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { @@ -711,7 +710,7 @@ if ($resql) { if ($user->hasRight('user', 'user', 'lire')) { $moreforfilter .= '
'; $tmptitle = $langs->trans('LinkedToSpecificUsers'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); $moreforfilter .= '
'; } // If the user can view products @@ -719,8 +718,8 @@ if ($resql) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); - $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, 0, 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, '', 'maxwidth300 widthcentpercentminusx', 1); $moreforfilter .= '
'; } $parameters = array(); @@ -761,7 +760,7 @@ if ($resql) { } if (!empty($arrayfields['s.nom']['checked'])) { print ''; - print ''; + print ''; print ''; } if (!empty($arrayfields['s.name_alias']['checked'])) { diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index 65f1d0d57d4..ec25d8c8cec 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -127,7 +128,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db);