2007-06-15 22:53:38 +02:00
< ? php
2020-07-19 00:02:02 +02:00
/* Copyright ( C ) 2007 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-11-12 08:37:21 +01:00
* Copyright ( C ) 2009 - 2018 Regis Houssin < regis . houssin @ inodbox . com >
2012-03-13 00:40:22 +01:00
* Copyright ( C ) 2010 Juanjo Menent < jmenent @ 2 byte . es >
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2012-03-13 00:40:22 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2012-03-13 00:40:22 +01:00
*/
2007-06-15 22:53:38 +02:00
/**
2009-12-30 15:48:10 +01:00
* \file htdocs / admin / limits . php
2012-03-13 00:40:22 +01:00
* \brief Page to setup limits
2009-12-30 15:48:10 +01:00
*/
2007-06-15 22:53:38 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php' ;
2007-06-15 22:53:38 +02:00
2018-05-26 18:41:16 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'companies' , 'products' , 'admin' ));
2007-06-15 22:53:38 +02:00
2020-04-10 10:59:32 +02:00
if ( ! $user -> admin ) accessforbidden ();
2007-06-15 22:53:38 +02:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2018-10-30 17:40:05 +01:00
$currencycode = GETPOST ( 'currencycode' , 'alpha' );
2020-07-07 09:03:11 +02:00
if ( ! empty ( $conf -> multicurrency -> enabled ) && ! empty ( $conf -> global -> MULTICURRENCY_USE_LIMIT_BY_CURRENCY )) {
2020-07-19 00:02:02 +02:00
// When MULTICURRENCY_USE_LIMIT_BY_CURRENCY is on, we use always a defined currency code instead of '' even for default.
$currencycode = ( ! empty ( $currencycode ) ? $currencycode : $conf -> currency );
2020-07-07 09:03:11 +02:00
}
2020-04-10 10:59:32 +02:00
$mainmaxdecimalsunit = 'MAIN_MAX_DECIMALS_UNIT' . ( ! empty ( $currencycode ) ? '_' . $currencycode : '' );
$mainmaxdecimalstot = 'MAIN_MAX_DECIMALS_TOT' . ( ! empty ( $currencycode ) ? '_' . $currencycode : '' );
$mainmaxdecimalsshown = 'MAIN_MAX_DECIMALS_SHOWN' . ( ! empty ( $currencycode ) ? '_' . $currencycode : '' );
$mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT' . ( ! empty ( $currencycode ) ? '_' . $currencycode : '' );
2007-06-15 22:53:38 +02:00
2020-07-19 01:03:37 +02:00
$valmainmaxdecimalsunit = GETPOST ( $mainmaxdecimalsunit , 'int' );
$valmainmaxdecimalstot = GETPOST ( $mainmaxdecimalstot , 'int' );
$valmainmaxdecimalsshown = GETPOST ( $mainmaxdecimalsshown , 'int' );
$valmainroundingruletot = price2num ( GETPOST ( $mainroundingruletot , 'alpha' ));
2012-01-08 10:53:05 +01:00
if ( $action == 'update' )
2007-06-15 22:53:38 +02:00
{
2020-04-10 10:59:32 +02:00
$error = 0 ;
$MAXDEC = 8 ;
2018-10-30 17:40:05 +01:00
if ( $_POST [ $mainmaxdecimalsunit ] > $MAXDEC
|| $_POST [ $mainmaxdecimalstot ] > $MAXDEC
|| $_POST [ $mainmaxdecimalsshown ] > $MAXDEC )
2012-01-09 00:02:42 +01:00
{
$error ++ ;
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( " ErrorDecimalLargerThanAreForbidden " , $MAXDEC ), null , 'errors' );
2012-01-09 00:02:42 +01:00
}
2020-04-10 10:59:32 +02:00
if ( $_POST [ $mainmaxdecimalsunit ] . ( ! empty ( $currencycode ) ? '_' . $currencycode : '' ) < 0
2018-10-30 17:40:05 +01:00
|| $_POST [ $mainmaxdecimalstot ] < 0
|| $_POST [ $mainmaxdecimalsshown ] < 0 )
2012-01-09 00:02:42 +01:00
{
$langs -> load ( " errors " );
$error ++ ;
2015-10-28 19:28:18 +01:00
setEventMessages ( $langs -> trans ( " ErrorNegativeValueNotAllowed " ), null , 'errors' );
2012-01-09 00:02:42 +01:00
}
2020-07-19 01:03:37 +02:00
if ( $valmainroundingruletot )
2012-01-09 00:02:42 +01:00
{
2020-07-19 01:03:37 +02:00
if ( $valmainroundingruletot * pow ( 10 , $valmainmaxdecimalstot ) < 1 )
2012-01-09 00:02:42 +01:00
{
$langs -> load ( " errors " );
$error ++ ;
2015-10-28 19:28:18 +01:00
setEventMessages ( $langs -> trans ( " ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT " ), null , 'errors' );
2012-01-09 00:02:42 +01:00
}
}
2020-04-10 10:59:32 +02:00
if ( ! $error )
2012-01-09 00:02:42 +01:00
{
2020-07-19 01:03:37 +02:00
dolibarr_set_const ( $db , $mainmaxdecimalsunit , $valmainmaxdecimalsunit , 'chaine' , 0 , '' , $conf -> entity );
dolibarr_set_const ( $db , $mainmaxdecimalstot , $valmainmaxdecimalstot , 'chaine' , 0 , '' , $conf -> entity );
dolibarr_set_const ( $db , $mainmaxdecimalsshown , $valmainmaxdecimalsshown , 'chaine' , 0 , '' , $conf -> entity );
2012-01-09 00:02:42 +01:00
2020-07-19 01:03:37 +02:00
dolibarr_set_const ( $db , $mainroundingruletot , $valmainroundingruletot , 'chaine' , 0 , '' , $conf -> entity );
2012-01-09 00:02:42 +01:00
2020-04-10 10:59:32 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?mainmenu=home&leftmenu=setup " . ( ! empty ( $currencycode ) ? '¤cycode=' . $currencycode : '' ));
2012-01-09 00:02:42 +01:00
exit ;
}
2007-06-15 22:53:38 +02:00
}
2009-12-28 01:56:27 +01:00
/*
* View
2018-10-30 17:40:05 +01:00
*/
2009-12-28 01:56:27 +01:00
2020-04-10 10:59:32 +02:00
$form = new Form ( $db );
2007-12-14 12:24:01 +01:00
2007-06-15 22:53:38 +02:00
llxHeader ();
2019-01-27 11:55:16 +01:00
print load_fiche_titre ( $langs -> trans ( " LimitsSetup " ), '' , 'title_setup' );
2007-06-15 22:53:38 +02:00
2020-04-10 10:59:32 +02:00
$aCurrencies = array ( $conf -> currency ); // Default currency always first position
2019-12-19 11:08:42 +01:00
2020-04-10 10:59:32 +02:00
if ( ! empty ( $conf -> multicurrency -> enabled ) && ! empty ( $conf -> global -> MULTICURRENCY_USE_LIMIT_BY_CURRENCY ))
2018-10-30 17:40:05 +01:00
{
require_once DOL_DOCUMENT_ROOT . '/core/lib/multicurrency.lib.php' ;
$sql = 'SELECT rowid, code FROM ' . MAIN_DB_PREFIX . 'multicurrency' ;
2020-04-10 10:59:32 +02:00
$sql .= ' WHERE entity = ' . $conf -> entity ;
$sql .= ' AND code != "' . $conf -> currency . '"' ; // Default currency always first position
2018-10-30 17:40:05 +01:00
$resql = $db -> query ( $sql );
if ( $resql )
{
while ( $obj = $db -> fetch_object ( $resql ))
{
$aCurrencies [] = $obj -> code ;
}
2019-12-19 11:08:42 +01:00
}
2018-10-30 17:40:05 +01:00
2020-04-10 10:59:32 +02:00
if ( ! empty ( $aCurrencies ) && count ( $aCurrencies ) > 1 )
2019-12-19 11:08:42 +01:00
{
$head = multicurrencyLimitPrepareHead ( $aCurrencies );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , $currencycode , '' , - 1 , " multicurrency " );
2018-10-30 17:40:05 +01:00
}
}
2007-12-14 12:24:01 +01:00
2019-10-11 14:42:55 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " LimitsDesc " ) . " </span><br> \n " ;
2007-06-15 22:53:38 +02:00
print " <br> \n " ;
2012-01-08 10:53:05 +01:00
if ( $action == 'edit' )
2007-06-15 22:53:38 +02:00
{
2012-01-08 10:53:05 +01:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2007-06-15 22:53:38 +02:00
print '<input type="hidden" name="action" value="update">' ;
2020-04-10 10:59:32 +02:00
if ( ! empty ( $conf -> multicurrency -> enabled ) && ! empty ( $conf -> global -> MULTICURRENCY_USE_LIMIT_BY_CURRENCY )) {
2018-10-30 17:40:05 +01:00
print '<input type="hidden" name="currencycode" value="' . $currencycode . '">' ;
}
2007-06-15 22:53:38 +02:00
clearstatcache ();
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2019-09-20 09:25:46 +02:00
print '<tr class="liste_titre"><td>' . $langs -> trans ( " Parameters " ) . '</td><td>' . $langs -> trans ( " Value " ) . '</td></tr>' ;
2007-06-15 22:53:38 +02:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' ;
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $langs -> trans ( " MAIN_MAX_DECIMALS_UNIT " ), $langs -> trans ( " ParameterActiveForNextInputOnly " ));
2020-04-10 10:59:32 +02:00
print '</td><td><input class="flat" name="' . $mainmaxdecimalsunit . '" size="3" value="' . ( isset ( $conf -> global -> $mainmaxdecimalsunit ) ? $conf -> global -> $mainmaxdecimalsunit : $conf -> global -> MAIN_MAX_DECIMALS_UNIT ) . '"></td></tr>' ;
2017-08-26 15:22:13 +02:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' ;
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $langs -> trans ( " MAIN_MAX_DECIMALS_TOT " ), $langs -> trans ( " ParameterActiveForNextInputOnly " ));
2020-04-10 10:59:32 +02:00
print '</td><td><input class="flat" name="' . $mainmaxdecimalstot . '" size="3" value="' . ( isset ( $conf -> global -> $mainmaxdecimalstot ) ? $conf -> global -> $mainmaxdecimalstot : $conf -> global -> MAIN_MAX_DECIMALS_TOT ) . '"></td></tr>' ;
2007-06-15 22:53:38 +02:00
2018-10-30 17:40:05 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAX_DECIMALS_SHOWN " ) . '</td>' ;
2020-04-10 10:59:32 +02:00
print '<td><input class="flat" name="' . $mainmaxdecimalsshown . '" size="3" value="' . ( isset ( $conf -> global -> $mainmaxdecimalsshown ) ? $conf -> global -> $mainmaxdecimalsshown : $conf -> global -> MAIN_MAX_DECIMALS_SHOWN ) . '"></td></tr>' ;
2017-08-26 15:22:13 +02:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' ;
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $langs -> trans ( " MAIN_ROUNDING_RULE_TOT " ), $langs -> trans ( " ParameterActiveForNextInputOnly " ));
2020-04-10 10:59:32 +02:00
print '</td><td><input class="flat" name="' . $mainroundingruletot . '" size="3" value="' . ( isset ( $conf -> global -> $mainroundingruletot ) ? $conf -> global -> $mainroundingruletot : $conf -> global -> MAIN_ROUNDING_RULE_TOT ) . '"></td></tr>' ;
2007-06-15 22:53:38 +02:00
print '</table>' ;
2019-09-20 09:25:46 +02:00
print '<br>' ;
print '<div class="center">' ;
2007-06-15 22:53:38 +02:00
print '<input class="button" type="submit" value="' . $langs -> trans ( " Save " ) . '">' ;
2014-11-25 20:13:43 +01:00
print '</div>' ;
2019-09-20 09:25:46 +02:00
print '<br>' ;
2007-06-15 22:53:38 +02:00
print '</form>' ;
print '<br>' ;
2020-07-07 09:03:11 +02:00
} else {
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2007-06-15 22:53:38 +02:00
print '<tr class="liste_titre"><td>' . $langs -> trans ( " Parameter " ) . '</td><td>' . $langs -> trans ( " Value " ) . '</td></tr>' ;
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' ;
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $langs -> trans ( " MAIN_MAX_DECIMALS_UNIT " ), $langs -> trans ( " ParameterActiveForNextInputOnly " ));
2020-04-10 10:59:32 +02:00
print '</td><td align="right">' . ( isset ( $conf -> global -> $mainmaxdecimalsunit ) ? $conf -> global -> $mainmaxdecimalsunit : $conf -> global -> MAIN_MAX_DECIMALS_UNIT ) . '</td></tr>' ;
2017-08-26 15:22:13 +02:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' ;
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $langs -> trans ( " MAIN_MAX_DECIMALS_TOT " ), $langs -> trans ( " ParameterActiveForNextInputOnly " ));
2020-04-10 10:59:32 +02:00
print '</td><td align="right">' . ( isset ( $conf -> global -> $mainmaxdecimalstot ) ? $conf -> global -> $mainmaxdecimalstot : $conf -> global -> MAIN_MAX_DECIMALS_TOT ) . '</td></tr>' ;
2007-06-15 22:53:38 +02:00
2018-10-30 17:40:05 +01:00
print '<tr class="oddeven"><td>' . $langs -> trans ( " MAIN_MAX_DECIMALS_SHOWN " ) . '</td>' ;
2020-04-10 10:59:32 +02:00
print '<td align="right">' . ( isset ( $conf -> global -> $mainmaxdecimalsshown ) ? $conf -> global -> $mainmaxdecimalsshown : $conf -> global -> MAIN_MAX_DECIMALS_SHOWN ) . '</td></tr>' ;
2017-08-26 15:22:13 +02:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' ;
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $langs -> trans ( " MAIN_ROUNDING_RULE_TOT " ), $langs -> trans ( " ParameterActiveForNextInputOnly " ));
2020-04-10 10:59:32 +02:00
print '</td><td align="right">' . ( isset ( $conf -> global -> $mainroundingruletot ) ? $conf -> global -> $mainroundingruletot : $conf -> global -> MAIN_ROUNDING_RULE_TOT ) . '</td></tr>' ;
2009-01-18 18:07:27 +01:00
print '</table>' ;
2007-06-15 22:53:38 +02:00
print '<div class="tabsAction">' ;
2020-04-10 10:59:32 +02:00
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?action=edit' . ( ! empty ( $currencycode ) ? '¤cycode=' . $currencycode : '' ) . '">' . $langs -> trans ( " Modify " ) . '</a>' ;
2007-06-15 22:53:38 +02:00
print '</div>' ;
}
2020-04-10 10:59:32 +02:00
if ( ! empty ( $conf -> multicurrency -> enabled ) && ! empty ( $conf -> global -> MULTICURRENCY_USE_LIMIT_BY_CURRENCY ))
2019-12-19 11:08:42 +01:00
{
2020-04-10 10:59:32 +02:00
if ( ! empty ( $aCurrencies ) && count ( $aCurrencies ) > 1 )
2019-12-19 11:08:42 +01:00
{
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2019-12-19 11:08:42 +01:00
}
}
2012-12-30 21:56:53 +01:00
if ( empty ( $mysoc -> country_code ))
2012-01-09 00:41:09 +01:00
{
2012-12-30 21:56:53 +01:00
$langs -> load ( " errors " );
2020-04-10 10:59:32 +02:00
$warnpicto = img_warning ( $langs -> trans ( " WarningMandatorySetupNotComplete " ));
2012-12-30 21:56:53 +01:00
print '<br><a href="' . DOL_URL_ROOT . '/admin/company.php?mainmenu=home">' . $warnpicto . ' ' . $langs -> trans ( " WarningMandatorySetupNotComplete " ) . '</a>' ;
2020-07-07 09:03:11 +02:00
} else {
2012-12-30 21:56:53 +01:00
// Show examples
2020-03-28 15:20:26 +01:00
print load_fiche_titre ( $langs -> trans ( " ExamplesWithCurrentSetup " ), '' , '' );
2012-12-30 21:56:53 +01:00
2020-04-22 18:34:52 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " Format " ) . ':</span> ' . price ( price2num ( 1234.56789 , 'MT' ), 0 , $langs , 1 , - 1 , - 1 , $currencycode ) . " <br> \n " ;
2012-12-30 21:56:53 +01:00
// Always show vat rates with vat 0
2020-04-10 10:59:32 +02:00
$s = 2 / 7 ; $qty = 1 ; $vat = 0 ;
$tmparray = calcul_price_total ( 1 , $qty * price2num ( $s , 'MU' ), 0 , $vat , 0 , 0 , 0 , 'HT' , 0 , 0 , $mysoc );
2020-03-28 15:20:26 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " UnitPriceOfProduct " ) . " :</span> " . price2num ( $s , 'MU' );
2012-12-30 21:56:53 +01:00
print " x " . $langs -> trans ( " Quantity " ) . " : " . $qty ;
print " - " . $langs -> trans ( " VAT " ) . " : " . $vat . '%' ;
2020-03-28 15:20:26 +01:00
print ' -> <span class="opacitymedium">' . $langs -> trans ( " TotalPriceAfterRounding " ) . " :</span> " . $tmparray [ 0 ] . ' / ' . $tmparray [ 1 ] . ' / ' . $tmparray [ 2 ] . " <br> \n " ;
2012-12-30 21:56:53 +01:00
2020-04-10 10:59:32 +02:00
$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 );
2020-03-28 15:20:26 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " UnitPriceOfProduct " ) . " :</span> " . price2num ( $s , 'MU' );
2012-12-30 21:56:53 +01:00
print " x " . $langs -> trans ( " Quantity " ) . " : " . $qty ;
print " - " . $langs -> trans ( " VAT " ) . " : " . $vat . '%' ;
2020-03-28 15:20:26 +01:00
print ' -> <span class="opacitymedium">' . $langs -> trans ( " TotalPriceAfterRounding " ) . " :</span> " . $tmparray [ 0 ] . ' / ' . $tmparray [ 1 ] . ' / ' . $tmparray [ 2 ] . " <br> \n " ;
2012-12-30 21:56:53 +01:00
2020-04-10 10:59:32 +02:00
$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 );
2020-03-28 15:20:26 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " UnitPriceOfProduct " ) . " :</span> " . price2num ( $s , 'MU' );
2012-12-30 21:56:53 +01:00
print " x " . $langs -> trans ( " Quantity " ) . " : " . $qty ;
print " - " . $langs -> trans ( " VAT " ) . " : " . $vat . '%' ;
2020-03-28 15:20:26 +01:00
print ' -> <span class="opacitymedium">' . $langs -> trans ( " TotalPriceAfterRounding " ) . " :</span> " . $tmparray [ 0 ] . ' / ' . $tmparray [ 1 ] . ' / ' . $tmparray [ 2 ] . " <br> \n " ;
2012-12-30 21:56:53 +01:00
// Add vat rates examples specific to country
2020-04-10 10:59:32 +02:00
$vat_rates = array ();
2012-12-30 21:56:53 +01:00
2020-07-19 01:03:37 +02:00
$sql = " SELECT taux as vat_rate, t.code as vat_code, t.localtax1 as localtax_rate1, t.localtax2 as localtax_rate2 " ;
2020-04-10 10:59:32 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " c_tva as t, " . MAIN_DB_PREFIX . " c_country as c " ;
2020-09-19 23:11:38 +02:00
$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code=' " . $db -> escape ( $mysoc -> country_code ) . " ' AND (t.taux <> 0 OR t.localtax1 <>0 OR t.localtax2 <>0) " ;
2020-04-10 10:59:32 +02:00
$sql .= " ORDER BY t.taux ASC " ;
$resql = $db -> query ( $sql );
2012-12-30 21:56:53 +01:00
if ( $resql )
{
$num = $db -> num_rows ( $resql );
if ( $num )
{
for ( $i = 0 ; $i < $num ; $i ++ )
{
$obj = $db -> fetch_object ( $resql );
2020-07-19 01:03:37 +02:00
$vat_rates [] = array ( 'vat_rate' => $obj -> vat_rate , 'code' => $obj -> vat_code , 'localtax_rate1' => $obj -> localtax_rate1 , 'locltax_rate2' => $obj -> localtax_rate2 );
2012-12-30 21:56:53 +01:00
}
}
2020-07-07 09:03:11 +02:00
} else dol_print_error ( $db );
2012-01-09 00:02:42 +01:00
2012-12-30 21:56:53 +01:00
if ( count ( $vat_rates ))
{
2020-07-19 01:03:37 +02:00
foreach ( $vat_rates as $vatarray )
2012-12-30 21:56:53 +01:00
{
2020-07-19 01:03:37 +02:00
$vat = $vatarray [ 'vat_rate' ];
2020-04-10 10:59:32 +02:00
for ( $qty = 1 ; $qty <= 2 ; $qty ++ )
2012-12-30 21:56:53 +01:00
{
2020-07-19 01:03:37 +02:00
$vattxt = $vat . ( $vatarray [ 'code' ] ? ' (' . $vatarray [ 'code' ] . ')' : '' );
$localtax_array = getLocalTaxesFromRate ( $vattxt , 0 , $mysoc , $mysoc );
2020-04-10 10:59:32 +02:00
$s = 10 / 3 ;
2020-07-19 01:03:37 +02:00
$tmparray = calcul_price_total ( $qty , price2num ( $s , 'MU' ), 0 , $vat , - 1 , - 1 , 0 , 'HT' , 0 , 0 , $mysoc , $localtax_array );
2020-03-28 15:20:26 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " UnitPriceOfProduct " ) . " :</span> " . price2num ( $s , 'MU' );
2012-12-30 21:56:53 +01:00
print " x " . $langs -> trans ( " Quantity " ) . " : " . $qty ;
print " - " . $langs -> trans ( " VAT " ) . " : " . $vat . '%' ;
2020-07-19 01:03:37 +02:00
print ( $vatarray [ 'code' ] ? ' (' . $vatarray [ 'code' ] . ')' : '' );
print ' -> <span class="opacitymedium">' . $langs -> trans ( " TotalPriceAfterRounding " ) . " :</span> " ;
print $tmparray [ 0 ] . ' / ' . $tmparray [ 1 ] . ( $tmparray [ 9 ] ? '+' . $tmparray [ 9 ] : '' ) . ( $tmparray [ 10 ] ? '+' . $tmparray [ 10 ] : '' ) . ' / ' . $tmparray [ 2 ];
print " <br> \n " ;
2012-12-30 21:56:53 +01:00
}
}
2020-07-07 09:03:11 +02:00
} else {
2012-12-30 21:56:53 +01:00
// More examples if not specific vat rate found
// This example must be kept for test purpose with current value because value used (2/7, 10/3, and vat 0, 10)
// were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule.
2020-07-19 01:03:37 +02:00
$localtax_array = array ();
2020-04-10 10:59:32 +02:00
$s = 10 / 3 ; $qty = 1 ; $vat = 10 ;
2020-07-19 01:03:37 +02:00
$tmparray = calcul_price_total ( $qty , price2num ( $s , 'MU' ), 0 , $vat , - 1 , - 1 , 0 , 'HT' , 0 , 0 , $mysoc , $localtax_array );
2020-03-28 15:20:26 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " UnitPriceOfProduct " ) . " :</span> " . price2num ( $s , 'MU' );
2012-12-30 21:56:53 +01:00
print " x " . $langs -> trans ( " Quantity " ) . " : " . $qty ;
print " - " . $langs -> trans ( " VAT " ) . " : " . $vat . '%' ;
2020-03-28 15:20:26 +01:00
print ' -> <span class="opacitymedium">' . $langs -> trans ( " TotalPriceAfterRounding " ) . " : " . $tmparray [ 0 ] . ' / ' . $tmparray [ 1 ] . ' / ' . $tmparray [ 2 ] . " <br> \n " ;
2012-12-30 21:56:53 +01:00
2020-04-10 10:59:32 +02:00
$s = 10 / 3 ; $qty = 2 ; $vat = 10 ;
2020-07-19 01:03:37 +02:00
$tmparray = calcul_price_total ( $qty , price2num ( $s , 'MU' ), 0 , $vat , - 1 , - 1 , 0 , 'HT' , 0 , 0 , $mysoc , $localtax_array );
2020-03-28 15:20:26 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " UnitPriceOfProduct " ) . " :</span> " . price2num ( $s , 'MU' );
2012-12-30 21:56:53 +01:00
print " x " . $langs -> trans ( " Quantity " ) . " : " . $qty ;
print " - " . $langs -> trans ( " VAT " ) . " : " . $vat . '%' ;
2020-03-28 15:20:26 +01:00
print ' -> <span class="opacitymedium">' . $langs -> trans ( " TotalPriceAfterRounding " ) . " :</span> " . $tmparray [ 0 ] . ' / ' . $tmparray [ 1 ] . ' / ' . $tmparray [ 2 ] . " <br> \n " ;
2012-12-30 21:56:53 +01:00
}
2012-01-09 09:55:20 +01:00
}
2012-12-30 21:56:53 +01:00
2018-07-28 18:03:14 +02:00
// End of page
2012-01-08 10:53:05 +01:00
llxFooter ();
2007-06-15 22:53:38 +02:00
$db -> close ();