diff --git a/.travis.yml b/.travis.yml index 2479de608ef..3ae9f554f26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -120,7 +120,7 @@ install: - | echo "Adding path of binaries tools installed by composer to the PATH" - export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$TRAVIS_BUILD_DIR/vendor/bin:$TRAVIS_BUILD_DIR/htdocs/includes:$PATH" + export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" echo $PATH ls $TRAVIS_BUILD_DIR/vendor ls $TRAVIS_BUILD_DIR/htdocs/includes/bin diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 55797290058..232444b7d97 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -360,12 +360,12 @@ if ($action != 'export_csv') if (!empty($show_subgroup)) { - print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).''; + print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')).''; print "\n"; print ''; } - print ''.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_debit - $total_credit)).''; + print ''.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')).''; print "\n"; print ''; diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index aebd48963d2..713812b639b 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -250,11 +250,16 @@ class Subscription extends CommonObject $this->db->begin(); + if (!is_numeric($this->amount)) { + $this->error = 'BadValueForParameterAmount'; + return -1; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; $sql .= " fk_type = ".$this->fk_type.","; $sql .= " fk_adherent = ".$this->fk_adherent.","; $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; - $sql .= " subscription = '".price2num($this->amount)."',"; + $sql .= " subscription = ".price2num($this->amount).","; $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; $sql .= " datef='".$this->db->idate($this->datef)."',"; $sql .= " datec='".$this->db->idate($this->datec)."',"; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 49126ea1111..f634d62a6e4 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -145,7 +145,7 @@ print ''; // Description print ''; print ''.$langs->trans("Description").''; -print ''; +print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('description', $object->description, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, ROWS_6, '90%'); $doleditor->Create(); @@ -154,7 +154,7 @@ print ''; // Color print ''; print ''.$langs->trans("Color").''; -print ''; +print ''; print $formother->selectColor($object->color, 'color'); print ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7166a491118..ad3c9a10043 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3086,6 +3086,7 @@ class Commande extends CommonOrder // Clean vat code $vat_src_code = ''; + $reg = array(); if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index be938d3bf70..a7841a72b22 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -885,7 +885,7 @@ if ($action == 'create') print 'min_allowed).'">'; print ''.$langs->trans("BalanceMinimalDesired").''; - print 'min_desired).'">'; + print 'min_desired).'">'; // Web print ''.$langs->trans("Web").''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a3d64bb0c2e..23b9ff7e316 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3295,6 +3295,7 @@ class Facture extends CommonInvoice $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 99544b1037d..9e277fd706b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1469,9 +1469,9 @@ class Contrat extends CommonObject } $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); + $remise_percent = price2num($remise_percent); $qty = price2num($qty); if (empty($qty)) $qty = 1; diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index f2bfd523d75..16b96e23466 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -137,7 +137,7 @@ class box_task extends ModeleBoxes $boxcontent .= ''; } $this->info_box_contents[0][] = array( - 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', + 'tr' => 'class="nohover showiffilter'.$this->boxcode.' hideobject"', 'td' => 'class="nohover"', 'textnoformat' => $boxcontent, ); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index c25519e151f..8327a26ae41 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1389,7 +1389,7 @@ abstract class CommonDocGenerator if ($itemsInRow > 0) { // close table row and empty cols for ($i = $itemsInRow; $i <= $maxItemsInRow; $i++) { - $html .= ""; + $html .= ""; } $html .= ""; diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index d8c8d36d3a5..19965250727 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -207,7 +207,7 @@ class Interfaces if ($result < 0) { // Action KO - //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR); + //dol_syslog("Error in trigger ".$action." - result = ".$result." - Nb of error string returned = ".count($objMod->errors), LOG_ERR); $nbtotal++; $nbko++; if (!empty($objMod->errors)) $this->errors = array_merge($this->errors, $objMod->errors); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 97ed1fc1c81..51cf1f2487c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4755,14 +4755,15 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) * 'CR'=Currency rate * Numeric = Nb of digits for rounding - * @param int $alreadysqlnb Put 1 if you know that content is already universal format number + * @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done) + * Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator). * @return string Amount with universal numeric format (Example: '99.99999'). * If conversion fails, it return text unchanged if $rounding = '' or '0' if $rounding is defined. * If amount is null or '', it returns '' if $rounding = '' or '0' if $rounding is defined.. * * @see price() Opposite function of price2num */ -function price2num($amount, $rounding = '', $alreadysqlnb = 0) +function price2num($amount, $rounding = '', $option = 0) { global $langs, $conf; @@ -4777,14 +4778,16 @@ function price2num($amount, $rounding = '', $alreadysqlnb = 0) //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
"; // Convert value to universal number format (no thousand separator, '.' as decimal separator) - if ($alreadysqlnb != 1) { // If not a PHP number or unknown, we change or clean format + if ($option != 1) { // If not a PHP number or unknown, we change or clean format //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'
'; - if ($thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator, not as a decimal separator - $amount = str_replace($thousand, '', $amount); // Replace of thousand before test of is_numeric to avoid pb if thousand is . and there is 3 numbers after + if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123 + $amount = str_replace($thousand, '', $amount); } + // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number // to format defined by LC_NUMERIC after a calculation and we want source format to be like defined by Dolibarr setup. + // So if number was already a good number, it is converted into local Dolibarr setup. if (is_numeric($amount)) { // We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10 @@ -4793,7 +4796,7 @@ function price2num($amount, $rounding = '', $alreadysqlnb = 0) $nbofdec = max(0, dol_strlen($temps) - 2); // -2 to remove "0." $amount = number_format($amount, $nbofdec, $dec, $thousand); } - //print "QQ".$amount.'
'; + //print "QQ".$amount."
\n"; // Now make replace (the main goal of function) if ($thousand != ',' && $thousand != '.') { diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 7ab6dcdb233..89ca1bbc1bd 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -103,10 +103,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $seller = $mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc //var_dump($seller->country_id);exit; } - if (empty($localtaxes_array) || !is_array($localtaxes_array)) - { + if (empty($localtaxes_array) || !is_array($localtaxes_array)) { dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter localtaxes_array that is missing", LOG_WARNING); } + if (!is_numeric($txtva)) { + dol_syslog("Price.lib::calcul_price_total Warning: function was called with a parameter vat rate that is not a real numeric value. There is surely a bug.", LOG_ERR); + } elseif ($txtva >= 1000) { + dol_syslog("Price.lib::calcul_price_total Warning: function was called with a bad value for vat rate (should be often < 100, always < 1000). There is surely a bug.", LOG_ERR); + } // Too verbose. Enable for debug only //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index fe9ae98ec61..df4f4e79197 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2400,8 +2400,8 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide // this conf is actually hidden, by default we use 10% for "be carefull or warning" $warningRatio = !empty($conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT) ? (1 + $conf->global->PROJECT_TIME_SPEND_WARNING_PERCENT / 100) : 1.10; - $diffTitle = '
'.$langs->trans('ProgressDeclared').' : '.$task->progress.($task->progress ? '%' : ''); - $diffTitle .= '
'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.($progressCalculated ? '%' : ''); + $diffTitle = '
'.$langs->trans('ProgressDeclared').' : '.$task->progress.($task->progress ? '%' : ''); + $diffTitle .= '
'.$langs->trans('ProgressCalculated').' : '.$progressCalculated.($progressCalculated ? '%' : ''); //var_dump($progressCalculated.' '.$warningRatio.' '.$task->progress.' '.doubleval($task->progress * $warningRatio)); if (doubleval($progressCalculated) > doubleval($task->progress * $warningRatio)) { diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 78b4efa1567..092ceb17d79 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -300,6 +300,7 @@ class modBom extends DolibarrModules $this->export_dependencies_array[$r] = array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'bom_bom as t'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bom_extrafields as extra on (t.rowid = extra.fk_object)'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid'; $this->export_sql_end[$r] .= ' WHERE 1 = 1'; $this->export_sql_end[$r] .= ' AND t.entity IN ('.getEntity('bom').')'; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index c6f697f48aa..85f5a25da99 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -176,56 +176,20 @@ class modCategorie extends DolibarrModules 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", 's.fk_prospectlevel'=>'company', 's.fk_stcomm'=>'company' ); // We define here only fields that use another picto + + $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '; $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, '; - $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object '; + $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object '; $this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; $this->export_sql_end[$r] .= ' AND u.type = 2'; // Customer/Prospect categories - // Add extra fields - $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj = $this->db->fetch_object($resql)) - { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $typeFilter = "Text"; - switch ($obj->type) - { - case 'int': - case 'double': - case 'price': - $typeFilter = "Numeric"; - break; - case 'date': - case 'datetime': - $typeFilter = "Date"; - break; - case 'boolean': - $typeFilter = "Boolean"; - break; - case 'sellist': - $typeFilter = "List:".$obj->param; - break; - case 'select': - $typeFilter = "Select:".$obj->param; - break; - } - $this->export_fields_array[$r][$fieldname] = $fieldlabel; - $this->export_TypeFields_array[$r][$fieldname] = $typeFilter; - $this->export_entities_array[$r][$fieldname] = 'company'; - } - } - // End add axtra fields - - - - - $r++; $this->export_code[$r] = 'category_'.$r; $this->export_label[$r] = 'CatProdList'; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 02c315b8e70..c61dff46b38 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1805,6 +1805,7 @@ class ExpenseReport extends CommonObject $localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $mysoc, $this->thirdparty); $vat_src_code = ''; + $reg = array(); if (preg_match('/\s*\((.*)\)/', $vatrate, $reg)) { $vat_src_code = $reg[1]; @@ -2038,6 +2039,7 @@ class ExpenseReport extends CommonObject $localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $buyer, $seller); // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $vatrate, $reg)) { @@ -2053,10 +2055,6 @@ class ExpenseReport extends CommonObject $tx_tva = $vatrate / 100; $tx_tva = $tx_tva + 1; - $total_ht = price2num($total_ttc / $tx_tva, 'MT'); - - $total_tva = price2num($total_ttc - $total_ht, 'MT'); - // fin calculs $this->line = new ExpenseReportLine($this->db); $this->line->comments = $comments; diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 9b666af779c..cf63b85879c 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -102,6 +102,7 @@ class Export // Search module files while (($file = readdir($handle)) !== false) { + $reg = array(); if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) { $modulename = $reg[1]; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 749c762200c..56835f03ee4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1723,8 +1723,6 @@ class CommandeFournisseur extends CommonOrder $localtax1_type = $localtaxes_type[0]; $localtax2_type = $localtaxes_type[2]; - $subprice = price2num($pu, 'MU'); - $rangmax = $this->line_max(); $rang = $rangmax + 1; @@ -2578,6 +2576,7 @@ class CommandeFournisseur extends CommonOrder $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { @@ -2604,12 +2603,9 @@ class CommandeFournisseur extends CommonOrder $localtax1_type = $localtaxes_type[0]; $localtax2_type = $localtaxes_type[2]; - $subprice = price2num($pu_ht, 'MU'); - //Fetch current line from the database and then clone the object and set it in $oldline property $this->line = new CommandeFournisseurLigne($this->db); $this->line->fetch($rowid); - $this->line->fetch_optionals(); $oldline = clone $this->line; $this->line->oldline = $oldline; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index cac27a2585e..f35db176b83 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1634,11 +1634,11 @@ class FactureFournisseur extends CommonInvoice $remise_percent = price2num($remise_percent); $qty = price2num($qty); $pu = price2num($pu); - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); if (!preg_match('/\((.*)\)/', $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' } + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); @@ -1884,8 +1884,6 @@ class FactureFournisseur extends CommonInvoice $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - $localtaxes_type = array($txlocaltax1, $txlocaltax2); - // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index e8965adedb3..798eb4472e6 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -225,7 +225,7 @@ if ($ok && GETPOST('standard', 'alpha')) $listofmodulesextra = array('societe'=>'societe', 'adherent'=>'adherent', 'product'=>'product', 'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture', 'supplier_proposal'=>'supplier_proposal', 'commande_fournisseur'=>'commande_fournisseur', 'facture_fourn'=>'facture_fourn', - 'actioncomm'=>'actioncomm', + 'actioncomm'=>'actioncomm', 'bom_bom'=>'bom_bom', 'mrp_mo'=>'mrp_mo', 'adherent_type'=>'adherent_type', 'user'=>'user', 'projet'=>'projet', 'projet_task'=>'projet_task'); print '
*** Check fields into extra table structure match table of definition. If not add column into table'; foreach ($listofmodulesextra as $tablename => $elementtype) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 72b7845fe8c..585cf1d9a64 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1714,7 +1714,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead } if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $text = ''.DOL_VERSION.''; + $text = ''.DOL_VERSION.''; $toprightmenu .= $form->textwithtooltip('', $appli, 2, 1, $text, 'login_block_elem', 2); } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index b950aa2af93..74d6946d6e4 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -33,6 +33,7 @@ * \ingroup product * \brief Page to show product prices */ + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -111,6 +112,7 @@ if (empty($reshook)) // We must define tva_tx, npr and local taxes $tva_tx = $tva_tx_txt; + $reg = array(); $vatratecode = ''; if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { @@ -262,8 +264,8 @@ if (empty($reshook)) } $pricestoupdate[$i] = array( - 'price' => price2num($newprice[$i]), - 'price_min' => price2num($newprice_min[$i]), + 'price' => price2num($newprice[$i], '', 2), + 'price_min' => price2num($newprice_min[$i], '', 2), 'price_base_type' => $newpricebase[$i], 'default_vat_code' => $vatratecode, 'vat_tx' => $tva_tx, // default_vat_code should be used in priority in a future @@ -278,8 +280,8 @@ if (empty($reshook)) } } elseif (!$error) { - $newprice = price2num(GETPOST('price', 'alpha')); - $newprice_min = price2num(GETPOST('price_min', 'alpha')); + $newprice = price2num(GETPOST('price', 'alpha'), '', 2); + $newprice_min = price2num(GETPOST('price_min', 'alpha'), '', 2); $newpricebase = GETPOST('price_base_type', 'alpha'); $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index cc650b36027..9939d8f0d32 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1398,7 +1398,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if (!empty($arrayfields['value']['checked'])) { print ''; - $value = price2num($task_time->thm * $task_time->task_duration / 3600, 'MT'); + $value = price2num($task_time->thm * $task_time->task_duration / 3600, 'MT', 1); print price($value, 1, $langs, 1, -1, -1, $conf->currency); print ''; if (!$i) $totalarray['nbfield']++; @@ -1598,7 +1598,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if (!empty($arrayfields['value']['checked'])) { print ''; - $value = price2num($task_time->thm * $task_time->task_duration / 3600); + $value = price2num($task_time->thm * $task_time->task_duration / 3600, 'MT', 1); print price($value, 1, $langs, 1, -1, -1, $conf->currency); print ''; } @@ -1607,7 +1607,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if (!empty($arrayfields['valuebilled']['checked'])) { print ''; - $valuebilled = price2num($task_time->total_ht); + $valuebilled = price2num($task_time->total_ht, '', 1); if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); print ''; } @@ -1745,7 +1745,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if (!empty($arrayfields['valuebilled']['checked'])) { print ''; - $valuebilled = price2num($task_time->total_ht); + $valuebilled = price2num($task_time->total_ht, '', 1); if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); print ''; } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 40495a66be4..3bac7265606 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1754,7 +1754,7 @@ if ($action == 'create') if ($action == 'editline' && $lines[$i]->id == $line_id) { - print ''; + print ''; } else { print ''.$lines[$i]->comment.''; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e67f28c4dab..6a819aa37f8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2070,7 +2070,7 @@ class Societe extends CommonObject $discount->amount_tva = $discount->multicurrency_amount_tva = price2num($remise * $vatrate / 100, 'MT'); $discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num($discount->amount_ht + $discount->amount_tva, 'MT'); - $discount->tva_tx = price2num($vatrate, 'MT'); + $discount->tva_tx = price2num($vatrate); $discount->vat_src_code = $vat_src_code; $discount->description = $desc; diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index f757b00944f..257e51a5891 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -1262,16 +1262,24 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // Test with 3 chars after . or , // If a . is used and there is 3 digits after, it is a thousand separator - $this->assertEquals(1234, price2num('1.234'), 'Test 1.234 give 1234 with spanish language'); + $this->assertEquals(1234, price2num('1.234', '', 2), 'Test 1.234 give 1234 with spanish language if user input'); + $this->assertEquals(1.234, price2num('1,234', '', 2), 'Test 1,234 give 1234 with spanish language if user input'); + $this->assertEquals(1234, price2num('1 234', '', 2), 'Test 1 234 give 1234 with spanish language if user input'); + $this->assertEquals(1.234, price2num('1.234'), 'Test 1.234 give 1.234 with spanish language'); + $this->assertEquals(1.234, price2num('1,234'), 'Test 1,234 give 1234 with spanish language'); $this->assertEquals(1234, price2num('1 234'), 'Test 1 234 give 1234 with spanish language'); - $this->assertEquals(1234, price2num('1.234'), 'Test 1.234 give 1234 with spanish language'); - $this->assertEquals(1.234, price2num('1,234'), 'Test 1,234 give 1.234 with spanish language'); $this->assertEquals(21500123, price2num('21.500.123'), 'Test 21.500.123 give 21500123 with spanish language'); - $this->assertEquals(21500123, price2num('21500.123'), 'Test 21500.123 give 21500123 with spanish language'); + $this->assertEquals(21500123, price2num('21500.123', 0, 2), 'Test 21500.123 give 21500123 with spanish language if user input'); + $this->assertEquals(21500.123, price2num('21500.123'), 'Test 21500.123 give 21500123 with spanish language'); $this->assertEquals(21500.123, price2num('21500,123'), 'Test 21500,123 give 21500.123 with spanish language'); // Test with 2 digits $this->assertEquals(21500.12, price2num('21500.12'), 'Test 21500.12 give 21500.12 with spanish language'); $this->assertEquals(21500.12, price2num('21500,12'), 'Test 21500,12 give 21500.12 with spanish language'); + // Test with 3 digits + $this->assertEquals(12123, price2num('12.123', '', 2), 'Test 12.123 give 12123 with spanish language if user input'); + $this->assertEquals(12.123, price2num('12,123', '', 2), 'Test 12,123 give 12.123 with spanish language if user input'); + $this->assertEquals(12.123, price2num('12.123'), 'Test 12.123 give 12.123 with spanish language'); + $this->assertEquals(12.123, price2num('12,123'), 'Test 12,123 give 12.123 with spanish language'); // For french language $newlangs3 = new Translate('', $conf); @@ -1279,9 +1287,12 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $newlangs3->load("main"); $langs = $newlangs3; + $this->assertEquals(1, price2num('1.000', '', 2), 'Test 1.000 give 1 with french language if user input'); $this->assertEquals(1, price2num('1.000'), 'Test 1.000 give 1 with french language'); $this->assertEquals(1000, price2num('1 000'), 'Test 1.000 give 1 with french language'); + $this->assertEquals(1.234, price2num('1.234', '', 2), 'Test 1.234 give 1.234 with french language if user input'); $this->assertEquals(1.234, price2num('1.234'), 'Test 1.234 give 1.234 with french language'); + $this->assertEquals(1.234, price2num('1,234', '', 2), 'Test 1,234 give 1.234 with french language if user input'); $this->assertEquals(1.234, price2num('1,234'), 'Test 1,234 give 1.234 with french language'); $this->assertEquals(21500000, price2num('21500 000'), 'Test 21500 000 give 21500000 with french language'); $this->assertEquals(21500000, price2num('21 500 000'), 'Test 21 500 000 give 21500000 with french language');