diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php
index 27ce3380dd4..cccccb1fdfe 100644
--- a/htdocs/cashdesk/validation_verif.php
+++ b/htdocs/cashdesk/validation_verif.php
@@ -42,7 +42,7 @@ switch ($action)
default:
- $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=validation';
+ $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation';
break;
@@ -85,13 +85,13 @@ switch ($action)
$obj_facturation->paiementLe($txtDatePaiement);
}
- $redirection = 'affIndex.php?menu=validation';
+ $redirection = 'affIndex.php?menutpl=validation';
break;
case 'retour':
- $redirection = 'affIndex.php?menu=facturation';
+ $redirection = 'affIndex.php?menutpl=facturation';
break;
@@ -336,7 +336,7 @@ switch ($action)
if (! $error)
{
$db->commit();
- $redirection = 'affIndex.php?menu=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
+ $redirection = 'affIndex.php?menutpl=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
}
else
{
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 0fdf4365ae7..3594e6214ef 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3937,7 +3937,7 @@ class Form
/**
* Load into the cache vat rates of a country
*
- * @param string $country_code Country code
+ * @param string $country_code Country code with quotes ("'CA'", or "'CA,IN,...'")
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/
function load_cache_vatrates($country_code)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 19af4885086..5e3224622b5 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3503,20 +3503,52 @@ function get_localtax_by_third($local)
}
+/**
+ * Get vat rate and npr from id.
+ * You can call getLocalTaxesFromRate after to get other fields
+ *
+ * @param string $vatrate VAT Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
+ * @param int $usenpr Use npr
+ * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
+ */
+function getTaxesFromId($vatrowid)
+{
+ global $db, $mysoc;
+
+ dol_syslog("getTaxesFromId vatrowid=".$vatrowid);
+
+ // Search local taxes
+ $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t";
+ $sql.= " WHERE t.rowid ='".$vatrowid."'";
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+
+ return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr);
+ }
+ else dol_print_error($db);
+
+ return array();
+}
+
/**
* Get type and rate of localtaxes for a particular vat rate/country fo thirdparty
* TODO
- * This function is also called to retrieve type for building PDF. Such call of function must be removed.
+ * This function is ALSO called to retrieve type for building PDF. Such call of function must be removed.
* Instead this function must be called when adding a line to get the array of localtax and type, and then
* provide it to the function calcul_price_total.
*
- * @param float $vatrate VAT Rate. Value can be '8.5' or '8.5 (8.5NPR)'.
+ * @param string $vatrate VAT Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
* @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2)
* @param Societe $buyer Company object
* @param Societe $seller Company object
+ * @param int $firstparamisid 1 if first param is id into table (use this if you can)
* @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
*/
-function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller)
+function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
{
global $db, $mysoc;
@@ -3531,12 +3563,17 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller)
// Search local taxes
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
- if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'";
- else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
- $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
- if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'";
-
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
+ if ($firstparamisid) $sql.= " WHERE t.rowid ='".$vatrate."'";
+ else
+ {
+ $sql.=", ".MAIN_DB_PREFIX."c_country as c";
+ if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ??
+ else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
+ $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
+ if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'";
+ }
+
$resql=$db->query($sql);
if ($resql)
{