diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index f39b1262064..52c70f4f641 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -47,7 +47,7 @@ return [ 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanRedefineFunctionInternal'], 'htdocs/core/lib/price.lib.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/core/modules/movement/doc/pdf_standard.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp'], - 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull'], + 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidRightOperandOfAdd'], 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'], 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 01043b3adc3..5de8de73754 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -463,7 +463,7 @@ return [ // 'PhanTypeMismatchPropertyProbablyReal', // 'PhanPluginNoCommentOnPrivateMethod', 'PhanPluginUnknownArrayFunctionReturnType', - 'PhanTypeInvalidLeftOperandOfAdd', + // 'PhanTypeInvalidLeftOperandOfAdd', // 'PhanPluginNoCommentOnPrivateProperty', // 'PhanPluginNoCommentOnFunction', 'PhanPluginUnknownArrayFunctionParamType', @@ -473,14 +473,14 @@ return [ // 'PhanPluginRedundantAssignment', 'PhanTypeExpectedObjectPropAccess', - 'PhanTypeInvalidRightOperandOfNumericOp', + // 'PhanTypeInvalidRightOperandOfNumericOp', // 'PhanPluginInlineHTML', // 'PhanPluginInlineHTMLTrailing', // 'PhanPluginUnknownFunctionReturnType', // 'PhanPluginDescriptionlessCommentOnProtectedProperty', 'PhanPluginRedundantAssignmentInGlobalScope', // 'PhanTypeMismatchDeclaredParamNullable', - 'PhanTypeInvalidRightOperandOfAdd', + // 'PhanTypeInvalidRightOperandOfAdd', // 'PhanPluginDescriptionlessCommentOnPrivateProperty', // 'PhanUndeclaredVariableDim', // Array initialisation on undeclared var: $abc['x']='ab' 'PhanTypeInvalidPropertyName', @@ -600,7 +600,7 @@ return [ // 'PhanPluginUnreachableCode', // 'PhanTypeMismatchArgumentInternal', // 'PhanPluginAlwaysReturnMethod', - 'PhanUndeclaredClassMethod', + // 'PhanUndeclaredClassMethod', 'PhanUndeclaredMethod', 'PhanTypeMismatchArgumentProbablyReal', 'PhanPluginDuplicateExpressionAssignmentOperation', // Suggestions for optimisation @@ -608,7 +608,7 @@ return [ // 'PhanPluginAlwaysReturnMethod', // 'PhanPluginMissingReturnMethod', // 'PhanUndeclaredTypeReturnType', - 'PhanUndeclaredClassProperty', + // 'PhanUndeclaredClassProperty', 'PhanTypeArraySuspiciousNullable', // 'PhanPluginInconsistentReturnMethod', 'PhanTypeExpectedObjectPropAccessButGotNull', @@ -643,11 +643,13 @@ return [ 'ftp' => PHAN_DIR . '/stubs/ftp.phan_php', 'gd' => PHAN_DIR . '/stubs/gd.phan_php', 'geoip' => PHAN_DIR . '/stubs/geoip.phan_php', + 'imagick' => PHAN_DIR . '/stubs/imagick.phan_php', 'imap' => PHAN_DIR . '/stubs/imap.phan_php', 'intl' => PHAN_DIR . '/stubs/intl.phan_php', 'ldap' => PHAN_DIR . '/stubs/ldap.phan_php', 'mcrypt' => PHAN_DIR . '/stubs/mcrypt.phan_php', 'memcache' => PHAN_DIR . '/stubs/memcache.phan_php', + 'memcached' => PHAN_DIR . '/stubs/memcached.phan_php', 'mysqli' => PHAN_DIR . '/stubs/mysqli.phan_php', 'pdo_cubrid' => PHAN_DIR . '/stubs/pdo_cubrid.phan_php', 'pdo_mysql' => PHAN_DIR . '/stubs/pdo_mysql.phan_php', @@ -658,6 +660,7 @@ return [ 'simplexml' => PHAN_DIR . '/stubs/SimpleXML.phan_php', 'soap' => PHAN_DIR . '/stubs/soap.phan_php', 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', + 'tidy' => PHAN_DIR . '/stubs/tidy.phan_php', 'zip' => PHAN_DIR . '/stubs/zip.phan_php', ], ]; diff --git a/dev/tools/phan/config_extended.php b/dev/tools/phan/config_extended.php index b5f0123526c..6fdb39c0621 100644 --- a/dev/tools/phan/config_extended.php +++ b/dev/tools/phan/config_extended.php @@ -397,10 +397,12 @@ return [ 'gd' => PHAN_DIR . '/stubs/gd.phan_php', 'geoip' => PHAN_DIR . '/stubs/geoip.phan_php', 'imap' => PHAN_DIR . '/stubs/imap.phan_php', + 'imagick' => PHAN_DIR . '/stubs/imagick.phan_php', 'intl' => PHAN_DIR . '/stubs/intl.phan_php', 'ldap' => PHAN_DIR . '/stubs/ldap.phan_php', 'mcrypt' => PHAN_DIR . '/stubs/mcrypt.phan_php', 'memcache' => PHAN_DIR . '/stubs/memcache.phan_php', + 'memcached' => PHAN_DIR . '/stubs/memcached.phan_php', 'mysqli' => PHAN_DIR . '/stubs/mysqli.phan_php', 'pdo_cubrid' => PHAN_DIR . '/stubs/pdo_cubrid.phan_php', 'pdo_mysql' => PHAN_DIR . '/stubs/pdo_mysql.phan_php', @@ -411,6 +413,7 @@ return [ 'simplexml' => PHAN_DIR . '/stubs/SimpleXML.phan_php', 'soap' => PHAN_DIR . '/stubs/soap.phan_php', 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', + 'tidy' => PHAN_DIR . '/stubs/tidy.phan_php', 'zip' => PHAN_DIR . '/stubs/zip.phan_php', ], diff --git a/dev/tools/phan/config_fixer.php b/dev/tools/phan/config_fixer.php index b12c94d6468..5df01eb7ae6 100644 --- a/dev/tools/phan/config_fixer.php +++ b/dev/tools/phan/config_fixer.php @@ -228,10 +228,12 @@ return [ 'gd' => PHAN_DIR . '/stubs/gd.phan_php', 'geoip' => PHAN_DIR . '/stubs/geoip.phan_php', 'imap' => PHAN_DIR . '/stubs/imap.phan_php', + 'imagick' => PHAN_DIR . '/stubs/imagick.phan_php', 'intl' => PHAN_DIR . '/stubs/intl.phan_php', 'ldap' => PHAN_DIR . '/stubs/ldap.phan_php', 'mcrypt' => PHAN_DIR . '/stubs/mcrypt.phan_php', 'memcache' => PHAN_DIR . '/stubs/memcache.phan_php', + 'memcached' => PHAN_DIR . '/stubs/memcached.phan_php', 'mysqli' => PHAN_DIR . '/stubs/mysqli.phan_php', 'pdo_cubrid' => PHAN_DIR . '/stubs/pdo_cubrid.phan_php', 'pdo_mysql' => PHAN_DIR . '/stubs/pdo_mysql.phan_php', @@ -241,6 +243,7 @@ return [ 'session' => PHAN_DIR . '/stubs/session.phan_php', 'simplexml' => PHAN_DIR . '/stubs/SimpleXML.phan_php', 'soap' => PHAN_DIR . '/stubs/soap.phan_php', + 'tidy' => PHAN_DIR . '/stubs/tidy.phan_php', 'sockets' => PHAN_DIR . '/stubs/sockets.phan_php', 'zip' => PHAN_DIR . '/stubs/zip.phan_php', ], diff --git a/dev/tools/phan/stubs/imagick.phan_php b/dev/tools/phan/stubs/imagick.phan_php new file mode 100644 index 00000000000..e9bb9db450a --- /dev/null +++ b/dev/tools/phan/stubs/imagick.phan_php @@ -0,0 +1,1216 @@ + + */ +class ActionsMulticompany +{ + /** + * @param DoliDB $db + */ + public function __construct($db) + { + } + /** @ver string */ + public $id; + /** @ver string */ + public $label; + /** @var array{stock:string[],referent:string} */ + public $sharings; + /** @ver DoliDB */ + public $db; +} diff --git a/dev/tools/phan/stubs/tidy.phan_php b/dev/tools/phan/stubs/tidy.phan_php new file mode 100644 index 00000000000..5ac1bc69f4e --- /dev/null +++ b/dev/tools/phan/stubs/tidy.phan_php @@ -0,0 +1,244 @@ + * Copyright (C) 2021-2023 Frédéric France * Copyright (C) 2021-2023 Waël Almoman + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,13 +91,13 @@ print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist $boxgraph = ''; if ($conf->use_javascript_ajax) { - $year = date('Y'); + $year = idate('Y'); $numberyears = getDolGlobalInt("MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH"); - $boxgraph .='
'; - $boxgraph .=''; - $boxgraph .=''; - $boxgraph .=''; @@ -604,7 +605,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if ($modetax != 1) { print ''; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 14984794eab..1d549dc2d02 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -83,7 +83,7 @@ $formquestion = array(); $usercanissuepayment = $user->hasRight('facture', 'paiement'); $fieldid = 'rowid'; -$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); +$isdraft = (($object->status == Facture::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft); @@ -115,8 +115,8 @@ if (empty($reshook)) { if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') { $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(GETPOST($key)); - $totalpayment = $totalpayment + $amounts[$cursorfacid]; if (!empty($amounts[$cursorfacid])) { + $totalpayment += (float) $amounts[$cursorfacid]; $atleastonepaymentnotnull++; } $result = $tmpinvoice->fetch($cursorfacid); @@ -463,7 +463,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie //Add js for AutoFill print ' $(document).ready(function () {'; - print ' $(".AutoFillAmout").on(\'click touchstart\', function(){ + print ' $(".AutoFillAmount").on(\'click touchstart\', function(){ $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change"); });'; print ' });'."\n"; @@ -730,7 +730,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Multicurrency remain to pay print ''; @@ -743,7 +743,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { if ($action != 'add_paiement') { if (!empty($conf->use_javascript_ajax)) { - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowname='".$namef."' data-value='".($sign * (float) $multicurrency_remaintopay)."'"); } print ''; print ''; @@ -770,7 +770,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Remain to take or to pay back print ''; - print ''; + print ''; print ''; // Autofilled print ''; print "\n"; diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index e2e45bac9dd..060072bdb95 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -5,6 +5,7 @@ * Copyright (C) 2006 Yannick Warnier * Copyright (C) 2014 Ferran Marcet * 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 @@ -122,7 +123,7 @@ $calcmode .= ' ('.$langs->trans("TaxModuleSetupToMod // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $prevyear = $date_start_year; -$q=0; +$q = 0; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -254,32 +255,32 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $company_static->code_compta_fournisseur = $x_coll[$my_coll_thirdpartyid]['company_supplier_accounting_code'][$id]; $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], - 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], + 'id' => $x_coll[$my_coll_thirdpartyid]['facid'][$id], + 'descr' => $x_coll[$my_coll_thirdpartyid]['descr'][$id], - 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], - 'pref' =>isset($x_coll[$my_coll_thirdpartyid]['pref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['pref'][$id] : '', - 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], - 'pstatus' =>isset($x_paye[$my_coll_thirdpartyid]['pstatus'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatus'][$id] : '', - 'pstatusbuy'=>isset($x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id] : '', + 'pid' => $x_coll[$my_coll_thirdpartyid]['pid'][$id], + 'pref' => isset($x_coll[$my_coll_thirdpartyid]['pref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['pref'][$id] : '', + 'ptype' => $x_coll[$my_coll_thirdpartyid]['ptype'][$id], + 'pstatus' => isset($x_paye[$my_coll_thirdpartyid]['pstatus'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatus'][$id] : '', + 'pstatusbuy' => isset($x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id] : '', - 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], - 'payment_ref'=>isset($x_coll[$my_coll_thirdpartyid]['payment_ref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['payment_ref'][$id] : '', - 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], - 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], - 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], + 'payment_id' => $x_coll[$my_coll_thirdpartyid]['payment_id'][$id], + 'payment_ref' => isset($x_coll[$my_coll_thirdpartyid]['payment_ref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['payment_ref'][$id] : '', + 'payment_amount' => $x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' => $x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], + 'dtotal_ttc' => $x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], + 'dtype' => $x_coll[$my_coll_thirdpartyid]['dtype'][$id], + 'drate' => $x_coll[$my_coll_thirdpartyid]['drate'][$id], + 'datef' => $x_coll[$my_coll_thirdpartyid]['datef'][$id], + 'datep' => $x_coll[$my_coll_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'company_link' => $company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], - 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1, '', 12) + 'ddate_start' => $x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], + 'ddate_end' => $x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], + 'totalht' => $x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], + 'vat' => $x_coll[$my_coll_thirdpartyid]['vat_list'][$id], + 'link' => $invoice_customer->getNomUrl(1, '', 12) ); } } @@ -302,27 +303,27 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'id' => $x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' => $x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'pstatus' =>$x_paye[$my_paye_thirdpartyid]['pstatus'][$id], - 'pstatusbuy' =>$x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], + 'pid' => $x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' => $x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' => $x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'pstatus' => $x_paye[$my_paye_thirdpartyid]['pstatus'][$id], + 'pstatusbuy' => $x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], - 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_ref' =>$x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], - 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$expensereport->getNomUrl(1) + 'payment_id' => $x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_ref' => $x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], + 'payment_amount' => $x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' => $x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'ddate_start' => $x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' => price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' => $expensereport->getNomUrl(1) ); } else { $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; @@ -344,32 +345,32 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $company_static->code_compta_fournisseur = $x_paye[$my_paye_thirdpartyid]['company_supplier_accounting_code'][$id]; $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'id' => $x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' => $x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'pstatus' =>$x_paye[$my_paye_thirdpartyid]['pstatus'][$id], - 'pstatusbuy'=>$x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], + 'pid' => $x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' => $x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' => $x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'pstatus' => $x_paye[$my_paye_thirdpartyid]['pstatus'][$id], + 'pstatusbuy' => $x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], - 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_ref'=>$x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], - 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], - 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], + 'payment_id' => $x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_ref' => $x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], + 'payment_amount' => $x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' => $x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'datef' => $x_paye[$my_paye_thirdpartyid]['datef'][$id], + 'datep' => $x_paye[$my_paye_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'company_link' => $company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1, '', 12) + 'ddate_start' => $x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' => price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' => $invoice_supplier->getNomUrl(1, '', 12) ); } } @@ -699,7 +700,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + $ratiolineinvoice = ((float) $fields['dtotal_ttc'] / (float) $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } print ''; @@ -720,7 +721,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } print ''.price(price2num($fields['payment_amount'], 'MT')).''; if (isset($fields['payment_amount'])) { @@ -732,7 +733,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // VAT paid print ''; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index db73cc25e56..994123bc0db 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -7,6 +7,7 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2021 Open-Dsi + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -464,12 +465,12 @@ if ($refresh === true) { //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } } } //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; $temp_vat = $fields['vat'] * $ratiopaymentinvoice; $subtot_paye_total_ht += $temp_ht; $subtot_paye_vat += $temp_vat; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 0873ab75072..441c6bee6cd 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -7,6 +7,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Eric Seigne * Copyright (C) 2021-2022 Open-Dsi + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -131,7 +132,7 @@ $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', $period .= ' - '; $period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); $prevyear = $date_start_year; -$q=0; +$q = 0; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -684,13 +685,13 @@ if (!is_array($x_coll) || !is_array($x_paye)) { || ($type == 1 && getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'invoice')) { } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } } } // VAT paid - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; // VAT $temp_vat = $fields['vat'] * $ratiopaymentinvoice; @@ -787,7 +788,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + $ratiolineinvoice = ((float) $fields['dtotal_ttc'] / (float) $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } print ''; @@ -808,7 +809,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } print price(price2num($fields['payment_amount'], 'MT')); if (isset($fields['payment_amount'])) { @@ -820,7 +821,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // VAT paid print ''; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 5877525b7fe..97ce15937e2 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -551,11 +551,11 @@ if (empty($reshook)) { // Set unit price to use if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); $price_base_type = 'HT'; } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); $price_base_type = 'TTC'; } @@ -591,11 +591,11 @@ if (empty($reshook)) { // Set unit price to use if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); $price_base_type = 'HT'; } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); $price_base_type = 'TTC'; } } @@ -617,7 +617,7 @@ if (empty($reshook)) { } if (((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) - || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) && ($price_min && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) && ($price_min && ((float) price2num($pu_ht) * (1 - (float) price2num($remise_percent) / 100) < (float) price2num($price_min)))) { $object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); $result = -1; } else { @@ -769,7 +769,7 @@ if (empty($reshook)) { $price_ht = price2num(GETPOST('elprice'), 'MU'); $remise_percent = price2num(GETPOST('elremise_percent'), '', 2); if ($remise_percent > 0) { - $remise = round(($price_ht * $remise_percent / 100), 2); + $remise = round(((float) $price_ht * (float) $remise_percent / 100), 2); } $objectline->fk_product = GETPOSTINT('idprod'); diff --git a/htdocs/core/ajax/flowjs-server.php b/htdocs/core/ajax/flowjs-server.php index 73617cbc008..dfe8b4ad2ce 100644 --- a/htdocs/core/ajax/flowjs-server.php +++ b/htdocs/core/ajax/flowjs-server.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 @@ -162,10 +163,10 @@ function createFileFromChunks($temp_dir, $upload_dir, $fileName, $chunkSize, $to // check that all the parts are present // the size of the last part is between chunkSize and 2*$chunkSize - if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { + if ($total_files * (float) $chunkSize >= ((float) $totalSize - (float) $chunkSize + 1)) { // create the final destination file if (($fp = fopen($upload_dir.'/'.$fileName, 'w')) !== false) { - for ($i=1; $i<=$total_files; $i++) { + for ($i = 1; $i <= $total_files; $i++) { fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i)); dol_syslog('writing chunk '.$i); } diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 3abab74e28a..050611acc00 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic 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 @@ -121,7 +122,7 @@ class box_birthdays extends ModeleBoxes $userstatic->statut = $data[$j]->status; $dateb = $this->db->jdate($data[$j]->datea); - $age = date('Y', dol_now()) - date('Y', $dateb); + $age = idate('Y', dol_now()) - idate('Y', $dateb); $picb = ''; $pice = ''; diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 8ac73aa4bd0..062eeb31506 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2023 Frederic 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 @@ -115,7 +116,7 @@ class box_birthdays_members extends ModeleBoxes $memberstatic->datefin = $this->db->jdate($data[$j]->datefin); $dateb = $this->db->jdate($data[$j]->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $age = idate('Y', dol_now()) - idate('Y', $dateb); $typea = ''; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ab8c695c143..6d1a31a1677 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -147,18 +147,18 @@ abstract class CommonDocGenerator public $emetteur; /** - * @var array Minimum version of PHP required by module. + * @var array{0:int,1:int} Minimum version of PHP required by module. * e.g.: PHP ≥ 7.1 = array(7, 1) */ public $phpmin = array(7, 1); /** - * @var array Array of columns + * @var array Array of columns */ public $cols; /** - * @var array Array with result of doc generation. content is array('fullpath'=>$file) + * @var array{fullpath:string} Array with result of doc generation. content is array('fullpath'=>$file) */ public $result; @@ -856,7 +856,7 @@ abstract class CommonDocGenerator include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; $object->list_delivery_methods($object->shipping_method_id); - $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); + $calculatedVolume = ((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth); $array_shipment = array( $array_key.'_id' => $object->id, diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 41a9a69114d..1cfcea32108 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3861,7 +3861,7 @@ abstract class CommonObject if ($forcedroundingmode == '1') { // Check if we need adjustment onto line for vat. TODO This works on the company currency but not on foreign currency $tmpvat = price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); - $diff = price2num($total_tva_by_vats[$obj->vatrate] - $tmpvat, 'MT', 1); + $diff = price2num($total_tva_by_vats[$obj->vatrate] - (float) $tmpvat, 'MT', 1); //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."
\n"; if ($diff) { if (abs((float) $diff) > (10 * pow(10, -1 * getDolGlobalInt('MAIN_MAX_DECIMALS_TOT', 0)))) { @@ -3872,7 +3872,7 @@ abstract class CommonObject $error++; break; } - $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - $diff).", total_ttc = ".price2num($obj->total_ttc - $diff)." WHERE rowid = ".((int) $obj->rowid); + $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - (float) $diff).", total_ttc = ".price2num($obj->total_ttc - (float) $diff)." WHERE rowid = ".((int) $obj->rowid); dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); $resqlfix = $this->db->query($sqlfix); @@ -3881,10 +3881,10 @@ abstract class CommonObject dol_print_error($this->db, 'Failed to update line'); } - $this->total_tva = (float) price2num($this->total_tva - $diff, '', 1); - $this->total_ttc = (float) price2num($this->total_ttc - $diff, '', 1); - $total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - $diff, '', 1); - $total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - $diff, '', 1); + $this->total_tva = (float) price2num($this->total_tva - (float) $diff, '', 1); + $this->total_ttc = (float) price2num($this->total_ttc - (float) $diff, '', 1); + $total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - (float) $diff, '', 1); + $total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - (float) $diff, '', 1); } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fccbbfe9ed8..8baf4c7c86a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6920,8 +6920,8 @@ class Form } elseif ($usecalendar == 'jquery' || $usecalendar == 'html') { if (!$disabled && $usecalendar != 'html') { // Output javascript for datepicker - $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (date('Y') - 100)); - $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (date('Y') + 100)); + $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (idate('Y') - 100)); + $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (idate('Y') + 100)); $retstring .= '
'.$langs->trans("Statistics").($numberyears ? ' ('.($year-$numberyears).' - '.$year.')' : '').'
'; + $boxgraph .= '
'; + $boxgraph .= ''; + $boxgraph .= ''; + $boxgraph .= ''; $boxgraph .= ''; print ''; if (!$foundphy) { - $data[] = array('label'=>'phy', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); + $data[] = array('label' => 'phy', 'nb' => '0', 'nbactive' => '0', 'lastdate' => '', 'lastsubscriptiondate' => ''); } if (!$foundmor) { - $data[] = array('label'=>'mor', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); + $data[] = array('label' => 'mor', 'nb' => '0', 'nbactive' => '0', 'lastdate' => '', 'lastsubscriptiondate' => ''); } foreach ($data as $val) { diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 443249a525b..b9d09f6f683 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.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 @@ -42,7 +43,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); -$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); +$year = (int) dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; @@ -162,40 +163,40 @@ if ($mode) { while ($i < $num) { $obj = $db->fetch_object($resql); if ($mode == 'memberbycountry') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'code'=>$obj->code, - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + $data[] = array('label' => (($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label_en' => (($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'code' => $obj->code, + 'nb' => $obj->nb, + 'lastdate' => $db->jdate($obj->lastdate), + 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbyregion') { //+ $data[] = array( - 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label2'=>($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + 'label' => (($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label_en' => (($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label2' => ($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), + 'nb' => $obj->nb, + 'lastdate' => $db->jdate($obj->lastdate), + 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbystate') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label2'=>($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + $data[] = array('label' => (($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label_en' => (($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label2' => ($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), + 'nb' => $obj->nb, + 'lastdate' => $db->jdate($obj->lastdate), + 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbytown') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), - 'label2'=>($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + $data[] = array('label' => (($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? img_picto('', DOL_URL_ROOT.'/theme/common/flags/'.strtolower($obj->code).'.png', '', 1).' '.$langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label_en' => (($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : ''.$langs->trans("Unknown").'')), + 'label2' => ($obj->label2 ? $obj->label2 : ''.$langs->trans("Unknown").''), + 'nb' => $obj->nb, + 'lastdate' => $db->jdate($obj->lastdate), + 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate) ); } diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 0672b5f90c0..17488f72508 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * 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 @@ -49,7 +50,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); -$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); +$year = (int) dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $startyear = $year - (!getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER')) { diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 99d56c35658..b8d523666aa 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2022 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry + * 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 @@ -177,7 +178,7 @@ if ($action == 'switch') { $newsecond = $objfrom->box_order; if ($newfirst == $newsecond) { $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond); - $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond); + $newsecondnum = (int) preg_replace('/[a-zA-Z]+/', '', $newsecond); $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1); } diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index a4911e94e52..c3a08c3612f 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -3,6 +3,7 @@ * Copyright (C) 2009-2018 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2023 Alexandre Spangaro + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -80,7 +81,7 @@ if ($action == 'update' && !$cancel) { } if ($valmainroundingruletot) { - if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1) { + if ((float) $valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1) { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT"), null, 'errors'); @@ -239,7 +240,7 @@ if (empty($mysoc->country_code)) { $s = 2 / 3; $qty = 1; $vat = 0; - $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $tmparray = calcul_price_total(1, $qty * (float) price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print ' x '.$langs->trans("Quantity").": ".$qty; print ' - '.$langs->trans("VAT").": ".$vat.'%'; @@ -248,7 +249,7 @@ if (empty($mysoc->country_code)) { $s = 10 / 3; $qty = 1; $vat = 0; - $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $tmparray = calcul_price_total(1, $qty * (float) price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print ' x '.$langs->trans("Quantity").": ".$qty; print ' - '.$langs->trans("VAT").": ".$vat.'%'; @@ -257,7 +258,7 @@ if (empty($mysoc->country_code)) { $s = 10 / 3; $qty = 2; $vat = 0; - $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $tmparray = calcul_price_total(1, $qty * (float) price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print ' x '.$langs->trans("Quantity").": ".$qty; print ' - '.$langs->trans("VAT").": ".$vat.'%'; @@ -277,7 +278,7 @@ if (empty($mysoc->country_code)) { if ($num) { for ($i = 0; $i < $num; $i++) { $obj = $db->fetch_object($resql); - $vat_rates[] = array('vat_rate'=>$obj->vat_rate, 'code'=>$obj->vat_code, 'localtax_rate1'=>$obj->localtax_rate1, 'locltax_rate2'=>$obj->localtax_rate2); + $vat_rates[] = array('vat_rate' => $obj->vat_rate, 'code' => $obj->vat_code, 'localtax_rate1' => $obj->localtax_rate1, 'locltax_rate2' => $obj->localtax_rate2); } } } else { diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index ab111f7c67f..dd8278f19bf 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -144,14 +144,14 @@ if ($action == 'activate_MAIN_SECURITY_DISABLEFORGETPASSLINK') { if ($action == 'updatepattern') { $pattern = GETPOST("pattern", "alpha"); - $explodePattern = explode(';', $pattern); + $explodePattern = explode(';', $pattern); // List of ints separated with ';' containing counts $patternInError = false; - if ($explodePattern[0] < 1 || $explodePattern[4] < 0) { + if ((int) $explodePattern[0] < 1 || (int) $explodePattern[4] < 0) { $patternInError = true; } - if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) { + if ((int) $explodePattern[0] < (int) $explodePattern[1] + (int) $explodePattern[2] + (int) $explodePattern[3]) { $patternInError = true; } diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 38da2d0077c..cf6ca335125 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -6,6 +6,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry * Copyright (C) 2017 Juanjo Menent + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,7 +35,14 @@ * $type, $text, $description, $line */ -/** var ObjectLine $line */ +/** + * @var CommonObjectLine $line + * @var int $num + */ +'@phan-var-force CommonObjectLine $line + @phan-var-force int $num + @phan-var-force CommonObject $this + @phan-var-force CommonObject $object'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; @@ -44,8 +52,6 @@ if (empty($object) || !is_object($object)) { exit(1); } -'@phan-var-force CommonObject $this - @phan-var-force CommonObject $object'; global $filtertype; if (empty($filtertype)) { @@ -249,7 +255,7 @@ print ''; // Select of all the sub-BOM lines // From this point to the end of the file, we only take care of sub-BOM lines $sql = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; -$sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; +$sql .= ' WHERE fk_bom ='. (int) $tmpbom->id; $resql = $object->db->query($sql); if ($resql) { @@ -323,7 +329,7 @@ if ($resql) { if (!empty($sub_bom->id)) { $sub_bom->calculateCosts(); print ''; - $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty; + $total_cost += $sub_bom->total_cost * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->type == Product::TYPE_SERVICE && isModEnabled('workstation') && !empty($sub_bom_product->fk_default_workstation)) { //Convert qty to hour $unit = measuringUnitString($sub_bom_line->fk_unit, '', '', 1); @@ -339,24 +345,24 @@ if ($resql) { } elseif ($sub_bom_product->cost_price > 0) { print ''; - $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty; + $total_cost += $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined print ''; - $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty; + $total_cost .= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty; } else { // Minimum purchase price if cost price and PMP aren't defined $sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; - $sql_supplier_price.= ' WHERE fk_product = '. (int) $sub_bom_product->id; + $sql_supplier_price .= ' WHERE fk_product = '. (int) $sub_bom_product->id; $resql_supplier_price = $object->db->query($sql_supplier_price); if ($resql_supplier_price) { $obj = $object->db->fetch_object($resql_supplier_price); if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) { - $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty; + $line_cost = $obj->min_price / $obj->qty * $sub_bom_line->qty * $line->qty; } else { $line_cost = $obj->min_price; } print ''; - $total_cost+= $line_cost; + $total_cost += $line_cost; } } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index cae65bdc3f5..cf1ba00ba66 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -495,10 +495,10 @@ if (empty($reshook) && $action == 'add') { $selectedrecurrulefreq = $reg1[1]; } if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) { - $selectedrecurrulebymonthday = $reg2[1]; + $selectedrecurrulebymonthday = (int) $reg2[1]; } if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) { - $selectedrecurrulebyday = $reg3[1]; + $selectedrecurrulebyday = (int) $reg3[1]; } // Is event recurrent ? @@ -1300,10 +1300,10 @@ if ($action == 'create') { $selectedrecurrulefreq = $reg[1]; } if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebymonthday = $reg[1]; + $selectedrecurrulebymonthday = (int) $reg[1]; } if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebyday = $reg[1]; + $selectedrecurrulebyday = (int) $reg[1]; } print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 42673dea754..652f771cb4e 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2010 Regis Houssin + * 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 @@ -45,7 +46,7 @@ $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hier $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOSTINT("page"); +$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; @@ -80,7 +81,7 @@ if (!$sortfield) { // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'm.titre'=>'Ref', + 'm.titre' => 'Ref', ); $permissiontoread = $user->hasRight('mailing', 'lire'); @@ -370,7 +371,7 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array('type'=>$type); + $parameters = array('type' => $type); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; @@ -415,7 +416,7 @@ print '
'; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -466,7 +467,7 @@ if (!$filteremail) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail ? "mc.statut" : "m.statut"), $param, "", '', $sortfield, $sortorder, 'center '); @@ -603,7 +604,7 @@ if (empty($num)) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 444a2c97a66..8044e284b73 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -974,20 +974,20 @@ if (empty($reshook)) { setEventMessages($prod->ref.' - '.$prod->label.' ('.$price_subprice.' < '.$price_price_min.' '.strtolower($langs->trans("MinPrice")).')'."\n", null, 'warnings'); } // Manage $line->subprice and $line->multicurrency_subprice - $multicurrency_subprice = $subprice * $line->multicurrency_subprice / $line->subprice; + $multicurrency_subprice = (float) $subprice * $line->multicurrency_subprice / $line->subprice; // Update DB $result = $object->updateline($line->id, $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_rate, $line->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->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice); // Update $object with new margin info $line->price = $subprice; $line->marge_tx = $margin_rate; - $line->marque_tx = $margin_rate * $line->pa_ht / $subprice; - $line->total_ht = $line->qty * $subprice; - $line->total_tva = $line->tva_tx * $line->qty * $subprice; - $line->total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice; + $line->marque_tx = $margin_rate * $line->pa_ht / (float) $subprice; + $line->total_ht = $line->qty * (float) $subprice; + $line->total_tva = $line->tva_tx * $line->qty * (float) $subprice; + $line->total_ttc = (1 + $line->tva_tx) * $line->qty * (float) $subprice; // Manage $line->subprice and $line->multicurrency_subprice - $line->multicurrency_total_ht = $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - $line->multicurrency_total_tva = $line->tva_tx * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_ht = $line->qty * (float) $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_tva = $line->tva_tx * $line->qty * (float) $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * (float) $subprice * $line->multicurrency_subprice / $line->subprice; // Used previous $line->subprice and $line->multicurrency_subprice above, now they can be set to their new values $line->subprice = $subprice; $line->multicurrency_subprice = $multicurrency_subprice; @@ -1206,20 +1206,20 @@ if (empty($reshook)) { // Set unit price to use if (!empty($price_ht) || (string) $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); } elseif (!empty($price_ht_devise) || (string) $price_ht_devise === '0') { $pu_ht_devise = price2num($price_ht_devise, 'MU'); $pu_ht = ''; $pu_ttc = ''; } elseif (!empty($price_ttc) || (string) $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); } elseif ($tmpvat != $tmpprodvat) { // Is this still used ? if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } else { - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } @@ -1344,10 +1344,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -1366,11 +1366,11 @@ if (empty($reshook)) { // Check price is not lower than minimum if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1482,10 +1482,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -1539,12 +1539,12 @@ if (empty($reshook)) { // Check price is not lower than minimum if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 04b4a6e99b2..f7e4da009f9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -694,9 +694,9 @@ class Propal extends CommonObject // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; $remise = 0; - if ($remise_percent > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; + if ((float) $remise_percent > 0) { + $remise = round(((float) $pu * (float) $remise_percent / 100), 2); + $price = (float) $pu - $remise; } // Insert line @@ -901,9 +901,9 @@ class Propal extends CommonObject // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; $remise = 0; - if ($remise_percent > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; + if ((float) $remise_percent > 0) { + $remise = round(((float) $pu * (float) $remise_percent / 100), 2); + $price = (float) $pu - $remise; } //Fetch current line from the database and then clone the object and set it in $oldline property diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 1ed17699c6d..f98eb74fcee 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -84,7 +84,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permi $error++; setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors'); } - if (!$error && price2num($amount_ttc_1 + $amount_ttc_2) != $discount->amount_ttc) { + if (!$error && price2num((float) $amount_ttc_1 + (float) $amount_ttc_2) != $discount->amount_ttc) { $error++; setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors'); } @@ -134,7 +134,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permi $newdiscount1->amount_tva = price2num($newdiscount1->amount_ttc - $newdiscount1->amount_ht); $newdiscount2->amount_tva = price2num($newdiscount2->amount_ttc - $newdiscount2->amount_ht); - $newdiscount1->multicurrency_amount_ttc = $amount_ttc_1 * ($discount->multicurrency_amount_ttc / $discount->amount_ttc); + $newdiscount1->multicurrency_amount_ttc = (float) $amount_ttc_1 * ($discount->multicurrency_amount_ttc / $discount->amount_ttc); $newdiscount2->multicurrency_amount_ttc = price2num($discount->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ttc); $newdiscount1->multicurrency_amount_ht = price2num($newdiscount1->multicurrency_amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT'); $newdiscount2->multicurrency_amount_ht = price2num($newdiscount2->multicurrency_amount_ttc / (1 + $newdiscount2->tva_tx / 100), 'MT'); @@ -558,7 +558,7 @@ if ($socid > 0) { if (count($showconfirminfo)) { $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); - $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); + $amount2 = ($showconfirminfo['amount_ttc'] - (float) $amount1); $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), 0 => array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), @@ -705,7 +705,7 @@ if ($socid > 0) { if (count($showconfirminfo)) { $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); - $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); + $amount2 = ($showconfirminfo['amount_ttc'] - (float) $amount1); $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), 0 => array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index eb3b5fd0fa5..46309e4168e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -899,10 +899,10 @@ if (empty($reshook)) { // Set unit price to use if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU'); } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } elseif ($tmpvat != $tmpprodvat) { // Is this still used ? if ($price_base_type != 'HT') { @@ -1031,10 +1031,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one defined @@ -1052,11 +1052,11 @@ if (empty($reshook)) { // Check price is not lower than minimum if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1161,10 +1161,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -1221,12 +1221,12 @@ if (empty($reshook)) { // Check price is not lower than minimum if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 291ead61cd3..d2ee2bb3079 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1634,8 +1634,8 @@ class Commande extends CommonOrder $price = $pu; $remise = 0; if ($remise_percent > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; + $remise = round(((float) $pu * $remise_percent / 100), 2); + $price = (float) $pu - $remise; } // Insert line @@ -3187,8 +3187,8 @@ class Commande extends CommonOrder } $remise = 0; if ($remise_percent > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = ($pu - $remise); + $remise = round(((float) $pu * $remise_percent / 100), 2); + $price = ((float) $pu - $remise); } //Fetch current line from the database and then clone the object and set it in $oldline property diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index 7a593ad368d..849e13a5ed8 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.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 @@ -69,7 +70,7 @@ if (is_array($amounts)) { if (is_array($remains)) { foreach ($remains as $key => $value) { $value = price2num($value); - $remains[$key] = (($invoice_type) == 2 ? -1 : 1) * $value; + $remains[$key] = ($invoice_type == 2 ? -1 : 1) * (float) $value; if (empty($value)) { unset($remains[$key]); } @@ -81,7 +82,7 @@ if (is_array($remains)) { } // Treatment -$result = ($amountPayment != '') ? ($amountPayment - array_sum($amounts)) : array_sum($amounts); // Remaining amountPayment +$result = ($amountPayment != '') ? ((float) $amountPayment - array_sum($amounts)) : array_sum($amounts); // Remaining amountPayment $toJsonArray = array(); $totalRemaining = price2num(array_sum($remains)); $toJsonArray['label'] = $amountPayment == '' ? '' : $langs->transnoentities('RemainingAmountPayment'); diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index bc973b0045b..a05b8dfd965 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -1,6 +1,7 @@ + * 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 @@ -265,7 +266,7 @@ class BankAccounts extends DolibarrApi */ if (!$error) { - $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1 * price2num($amount), '', '', $user, $cheque_number); + $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1 * (float) price2num($amount), '', '', $user, $cheque_number); } if (!($bank_line_id_from > 0)) { $error++; diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 8d2b44c40af..97e362145ae 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -125,12 +126,14 @@ if ($result < 0) { // Loading table $amounts $amounts = array(); - $monthnext = $month + 1; - $yearnext = $year; + $monthnext = (int) $month + 1; + $yearnext = (int) $year; if ($monthnext > 12) { $monthnext = 1; $yearnext++; } + $monthnext = sprintf('%02d', $monthnext); + $yearnext = sprintf('%04d', $yearnext); $sql = "SELECT date_format(b.datev,'%Y%m%d')"; $sql .= ", SUM(b.amount)"; @@ -534,12 +537,14 @@ if ($result < 0) { $credits = array(); $debits = array(); - $monthnext = $month + 1; - $yearnext = $year; + $monthnext = (int) $month + 1; + $yearnext = (int) $year; if ($monthnext > 12) { $monthnext = 1; $yearnext++; } + $monthnext = sprintf('%02d', $monthnext); + $yearnext = sprintf('%04d', $yearnext); $sql = "SELECT date_format(b.datev,'%d')"; $sql .= ", SUM(b.amount)"; @@ -569,12 +574,14 @@ if ($result < 0) { dol_print_error($db); } - $monthnext = $month + 1; - $yearnext = $year; + $monthnext = (int) $month + 1; + $yearnext = (int) $year; if ($monthnext > 12) { $monthnext = 1; $yearnext++; } + $monthnext = sprintf('%02d', $monthnext); + $yearnext = sprintf('%04d', $yearnext); $sql = "SELECT date_format(b.datev,'%d')"; $sql .= ", SUM(b.amount)"; @@ -805,10 +812,10 @@ print '
'.$langs->trans("Statistics").($numberyears ? ' ('.($year - $numberyears).' - '.$year.')' : '').'
'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; $stats = new AdherentStats($db, 0, $userid); @@ -133,7 +134,7 @@ if ($conf->use_javascript_ajax) { $dolgraph->SetType(array('pie')); $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); - $boxgraph .=$dolgraph->show($total ? 0 : 1); + $boxgraph .= $dolgraph->show($total ? 0 : 1); $boxgraph .= '
'.$langs->trans("Total").''; diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 43875336810..f7d530f0f62 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.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,7 +41,7 @@ if ($user->socid > 0) { } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); -$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); +$year = (int) dol_print_date(dol_now('gmt'), "%Y", 'gmt'); $startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; @@ -90,7 +91,7 @@ if ($resql) { $foundmor++; } - $data[$obj->code] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'nbsubscriptions'=>$obj->nbsubscriptions, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)); + $data[$obj->code] = array('label' => $obj->code, 'nb' => $obj->nb, 'nbsubscriptions' => $obj->nbsubscriptions, 'lastdate' => $db->jdate($obj->lastdate), 'lastsubscriptiondate' => $db->jdate($obj->lastsubscriptiondate)); $i++; } @@ -162,10 +163,10 @@ print ''.$langs->trans("LatestSubscriptionDate").'
'.price(price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT')).''; print ''.price(price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT')).''; print ''.price(price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT')).''.price2num($line_cost, 'MT').' 
'; // Graphs if ($mode == 'standard') { - $prevyear = $year; - $nextyear = $year; - $prevmonth = $month - 1; - $nextmonth = $month + 1; + $prevyear = (int) $year; + $nextyear = (int) $year; + $prevmonth = (int) $month - 1; + $nextmonth = (int) $month + 1; if ($prevmonth < 1) { $prevmonth = 12; $prevyear--; @@ -817,6 +824,10 @@ if ($mode == 'standard') { $nextmonth = 1; $nextyear++; } + $nextmonth = sprintf('%02d', $nextmonth); + $prevmonth = sprintf('%02d', $prevmonth); + $nextyear = sprintf('%04d', $nextyear); + $prevyear = sprintf('%04d', $prevyear); // For month $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; @@ -832,8 +843,10 @@ if ($mode == 'standard') { print '
'; // For year - $prevyear = $year - 1; - $nextyear = $year + 1; + $prevyear = (int) $year - 1; + $nextyear = (int) $year + 1; + $nextyear = sprintf('%04d', $nextyear); + $prevyear = sprintf('%04d', $prevyear); $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; print '
'.$link.'
'; diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 1ecfab6693c..f0aef136fd4 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -8,6 +8,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2023 Maxime Nicolas * Copyright (C) 2023 Benjamin GREMBI + * 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 @@ -164,7 +165,7 @@ if ($action == 'add' && $user->hasRight('banque', 'transfer')) { } if (!$error) { - $bank_line_id_from = $tmpaccountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * $amount[$n]), '', '', $user); + $bank_line_id_from = $tmpaccountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * (float) $amount[$n]), '', '', $user); } if (!($bank_line_id_from > 0)) { $error++; diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index bf6a7310720..c59c5be8b34 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -356,7 +356,7 @@ if ($resql) { print ""; //$cash = $amountpertype['LIQ'] + $object->opening; - $cash = price2num($cash + $object->opening, 'MT'); + $cash = price2num($cash + (float) $object->opening, 'MT'); print '
'; print '

'; @@ -387,7 +387,7 @@ if ($resql) { print '
'; } - print $langs->trans("Total").' ('.$totalqty.' '.$langs->trans("Articles").') :
'.price($cash + $cheque + $bank + $other).'
'; + print $langs->trans("Total").' ('.$totalqty.' '.$langs->trans("Articles").') :
'.price((float) $cash + (float) $cheque + (float) $bank + (float) $other).'
'; print '
'.$langs->trans("TotalVAT").' :
'.price($totalvat).'
'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 69c113e86d7..4293ae1abe0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1599,7 +1599,7 @@ if (empty($reshook)) { if ($qualified) { $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 * $valuedeposit) / 100; + $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100; } } @@ -1691,7 +1691,7 @@ if (empty($reshook)) { if (is_array($lines)) { foreach ($lines as $line) { // We keep ->subprice and ->pa_ht, but we change the qty - $line->qty = price2num($line->qty * $valuestandardinvoice / 100, 'MS'); + $line->qty = price2num($line->qty * (float) $valuestandardinvoice / 100, 'MS'); } } } @@ -1700,7 +1700,7 @@ if (empty($reshook)) { if (is_array($lines)) { foreach ($lines as $line) { // We keep ->subprice and ->pa_ht, but we change the qty - $line->qty = price2num($line->qty * $valuedeposit / 100, 'MS'); + $line->qty = price2num($line->qty * (float) $valuedeposit / 100, 'MS'); } } } @@ -2253,14 +2253,14 @@ if (empty($reshook)) { // TODO We should not have this if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ttc = price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU'); } elseif (!empty($price_ht_devise) || $price_ht_devise === '0') { $pu_ht_devise = price2num($price_ht_devise, 'MU'); $pu_ht = ''; $pu_ttc = ''; } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } elseif ($tmpvat != $tmpprodvat) { // Is this still used ? if ($price_base_type != 'HT') { @@ -2399,7 +2399,7 @@ if (empty($reshook)) { $pu_equivalent = $pu_ht_devise * $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -2437,11 +2437,11 @@ if (empty($reshook)) { // Check price is not lower than minimum (check is done only for standard or replacement invoices) if ($usermustrespectpricemin && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -2572,10 +2572,10 @@ if (empty($reshook)) { // Check if we have a foreign currency // If so, we update the pu_equiv as the equivalent price in base currency if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; } if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; } // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes @@ -2659,7 +2659,7 @@ if (empty($reshook)) { setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -4195,7 +4195,7 @@ if ($action == 'create') { // TODO We should not need this. Also data comes from a not reliable value of $object->multicurrency_total_ttc that may be wrong if it was // calculated by summing lines that were in a currency for some of them and into another for others (lines from discount/down payment into another currency for example) if ($resteapayer == 0 && $multicurrency_resteapayer != 0 && $object->multicurrency_code != $conf->currency) { - $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + $resteapayer = price2num((float) $multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); } } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index ef52e74f6c8..8ca14c775a7 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2023 Joachim Kueter * 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 @@ -1480,10 +1481,10 @@ class Invoices extends DolibarrApi // Clean parameters amount if payment is for a credit note if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { $resteapayer = price2num($resteapayer, 'MT'); - $amounts[$id] = (float) price2num(-1 * $resteapayer, 'MT'); + $amounts[$id] = (float) price2num(-1 * (float) $resteapayer, 'MT'); // Multicurrency $newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT'); - $multicurrency_amounts[$id] = (float) price2num(-1 * $newvalue, 'MT'); + $multicurrency_amounts[$id] = (float) price2num(-1 * (float) $newvalue, 'MT'); } else { $resteapayer = price2num($resteapayer, 'MT'); $amounts[$id] = (float) $resteapayer; @@ -1626,7 +1627,7 @@ class Invoices extends DolibarrApi } if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $amount = price2num(-1 * $amount, 'MT'); + $amount = price2num(-1 * (float) $amount, 'MT'); } if ($is_multicurrency) { diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 0e6ffde780c..1c277b80f3f 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2018 Laurent Destailleur * 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 @@ -333,26 +334,26 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); $x_both[$my_coll_rate]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_rate]['facid'][$id], - 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], - 'pid' =>$x_coll[$my_coll_rate]['pid'][$id], - 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], - 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], - 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], - 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], - 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], - 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + 'id' => $x_coll[$my_coll_rate]['facid'][$id], + 'descr' => $x_coll[$my_coll_rate]['descr'][$id], + 'pid' => $x_coll[$my_coll_rate]['pid'][$id], + 'pref' => $x_coll[$my_coll_rate]['pref'][$id], + 'ptype' => $x_coll[$my_coll_rate]['ptype'][$id], + 'payment_id' => $x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_amount' => $x_coll[$my_coll_rate]['payment_amount'][$id], + 'ftotal_ttc' => $x_coll[$my_coll_rate]['ftotal_ttc'][$id], + 'dtotal_ttc' => $x_coll[$my_coll_rate]['dtotal_ttc'][$id], + 'dtype' => $x_coll[$my_coll_rate]['dtype'][$id], + 'datef' => $x_coll[$my_coll_rate]['datef'][$id], + 'datep' => $x_coll[$my_coll_rate]['datep'][$id], //'company_link'=>$company_static->getNomUrl(1,'',20), - 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], + 'ddate_start' => $x_coll[$my_coll_rate]['ddate_start'][$id], + 'ddate_end' => $x_coll[$my_coll_rate]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], - 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], - 'localtax1' =>$x_coll[$my_coll_rate]['localtax1_list'][$id], - 'localtax2' =>$x_coll[$my_coll_rate]['localtax2_list'][$id], + 'totalht' => $x_coll[$my_coll_rate]['totalht_list'][$id], + 'vat' => $x_coll[$my_coll_rate]['vat_list'][$id], + 'localtax1' => $x_coll[$my_coll_rate]['localtax1_list'][$id], + 'localtax2' => $x_coll[$my_coll_rate]['localtax2_list'][$id], //'link' =>$invoice_customer->getNomUrl(1,'',12) ); } @@ -381,23 +382,23 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id]; $x_both[$my_paye_rate]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_rate]['facid'][$id], - 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], - 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], - 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], - 'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id], - 'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id], - 'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), - 'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], - 'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + 'id' => $x_paye[$my_paye_rate]['facid'][$id], + 'descr' => $x_paye[$my_paye_rate]['descr'][$id], + 'pid' => $x_paye[$my_paye_rate]['pid'][$id], + 'pref' => $x_paye[$my_paye_rate]['pref'][$id], + 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id], + 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'localtax1' =>$x_paye[$my_paye_rate]['localtax1_list'][$id], - 'localtax2' =>$x_paye[$my_paye_rate]['localtax2_list'][$id], + 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id], + 'localtax1' => $x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' => $x_paye[$my_paye_rate]['localtax2_list'][$id], //'link' =>$expensereport->getNomUrl(1) ); } else { @@ -406,26 +407,26 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; //$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]); $x_both[$my_paye_rate]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_rate]['facid'][$id], - 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], - 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], - 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], - 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], - 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], - 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], - 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + 'id' => $x_paye[$my_paye_rate]['facid'][$id], + 'descr' => $x_paye[$my_paye_rate]['descr'][$id], + 'pid' => $x_paye[$my_paye_rate]['pid'][$id], + 'pref' => $x_paye[$my_paye_rate]['pref'][$id], + 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id], + 'datef' => $x_paye[$my_paye_rate]['datef'][$id], + 'datep' => $x_paye[$my_paye_rate]['datep'][$id], //'company_link'=>$company_static->getNomUrl(1,'',20), - 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'localtax1' =>$x_paye[$my_paye_rate]['localtax1_list'][$id], - 'localtax2' =>$x_paye[$my_paye_rate]['localtax2_list'][$id], + 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id], + 'localtax1' => $x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' => $x_paye[$my_paye_rate]['localtax2_list'][$id], //'link' =>$invoice_supplier->getNomUrl(1,'',12) ); } @@ -514,12 +515,12 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } } } //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; $temp_vat = $fields['localtax'.$localTaxType] * $ratiopaymentinvoice; $subtot_paye_total_ht += $temp_ht; $subtot_paye_vat += $temp_vat; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 63df3750d22..6644378a926 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -5,6 +5,7 @@ * Copyright (C) 2006-2007 Yannick Warnier * Copyright (C) 2014-2016 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 @@ -169,7 +170,7 @@ $calcmode .= ' ('.$langs->trans("TaxModuleSetupToMod // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $prevyear = $year_start; -$q=0; +$q = 0; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -277,26 +278,26 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $invoice_customer->type = $x_coll[$my_coll_rate]['type'][$id]; $company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); $x_both[$my_coll_rate]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_rate]['facid'][$id], - 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], - 'pid' =>$x_coll[$my_coll_rate]['pid'][$id], - 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], - 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], - 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], - 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], - 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], - 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], - 'localtax1'=> $x_coll[$my_coll_rate]['localtax1_list'][$id], - 'localtax2'=> $x_coll[$my_coll_rate]['localtax2_list'][$id], - 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1, '', 12) + 'id' => $x_coll[$my_coll_rate]['facid'][$id], + 'descr' => $x_coll[$my_coll_rate]['descr'][$id], + 'pid' => $x_coll[$my_coll_rate]['pid'][$id], + 'pref' => $x_coll[$my_coll_rate]['pref'][$id], + 'ptype' => $x_coll[$my_coll_rate]['ptype'][$id], + 'payment_id' => $x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_amount' => $x_coll[$my_coll_rate]['payment_amount'][$id], + 'ftotal_ttc' => $x_coll[$my_coll_rate]['ftotal_ttc'][$id], + 'dtotal_ttc' => $x_coll[$my_coll_rate]['dtotal_ttc'][$id], + 'dtype' => $x_coll[$my_coll_rate]['dtype'][$id], + 'datef' => $x_coll[$my_coll_rate]['datef'][$id], + 'datep' => $x_coll[$my_coll_rate]['datep'][$id], + 'company_link' => $company_static->getNomUrl(1, '', 20), + 'ddate_start' => $x_coll[$my_coll_rate]['ddate_start'][$id], + 'ddate_end' => $x_coll[$my_coll_rate]['ddate_end'][$id], + 'totalht' => $x_coll[$my_coll_rate]['totalht_list'][$id], + 'localtax1' => $x_coll[$my_coll_rate]['localtax1_list'][$id], + 'localtax2' => $x_coll[$my_coll_rate]['localtax2_list'][$id], + 'vat' => $x_coll[$my_coll_rate]['vat_list'][$id], + 'link' => $invoice_customer->getNomUrl(1, '', 12) ); } } @@ -316,26 +317,26 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $invoice_supplier->ref = $x_paye[$my_paye_rate]['facnum'][$id]; $invoice_supplier->type = $x_paye[$my_paye_rate]['type'][$id]; $x_both[$my_paye_rate]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_rate]['facid'][$id], - 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], - 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], - 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], - 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], - 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], - 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], - 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), - 'localtax1'=> $x_paye[$my_paye_rate]['localtax1_list'][$id], - 'localtax2'=> $x_paye[$my_paye_rate]['localtax2_list'][$id], - 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1, '', 12) + 'id' => $x_paye[$my_paye_rate]['facid'][$id], + 'descr' => $x_paye[$my_paye_rate]['descr'][$id], + 'pid' => $x_paye[$my_paye_rate]['pid'][$id], + 'pref' => $x_paye[$my_paye_rate]['pref'][$id], + 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id], + 'datef' => $x_paye[$my_paye_rate]['datef'][$id], + 'datep' => $x_paye[$my_paye_rate]['datep'][$id], + 'company_link' => $company_static->getNomUrl(1, '', 20), + 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id], + 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'localtax1' => $x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' => $x_paye[$my_paye_rate]['localtax2_list'][$id], + 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id], + 'link' => $invoice_supplier->getNomUrl(1, '', 12) ); } } @@ -593,7 +594,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + $ratiolineinvoice = ((float) $fields['dtotal_ttc'] / (float) $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } print '

'; if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']); } if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $paymentfourn_static->id = $fields['payment_id']; @@ -623,7 +624,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // VAT paid print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); print ''; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - print price($sign * $multicurrency_remaintopay); + print price($sign * (float) $multicurrency_remaintopay); } print ''; - print price($sign * $remaintopay); + print price($sign * (float) $remaintopay); if (isModEnabled('prelevement')) { $numdirectdebitopen = 0; $totaldirectdebit = 0; @@ -805,7 +805,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($action != 'add_paiement') { if (!empty($conf->use_javascript_ajax)) { - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowname='".$namef."' data-value='".($sign * (float) $remaintopay)."'"); } print ''; print ''; @@ -856,7 +856,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '+'.price($totalrecudeposits); } print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).''.price($sign * (float) price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).' 
'; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); print '