diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php
index 313a852e384..75c82157ddf 100644
--- a/htdocs/admin/barcode.php
+++ b/htdocs/admin/barcode.php
@@ -70,18 +70,8 @@ else if ($action == 'update')
$res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity);
$coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY','alpha');
$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity);
-}
-else if ($action == 'updateengine')
-{
- // TODO Update engines.
-
-}
-
-if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
-{
- if (! $res > 0) $error++;
-
- if (! $error)
+
+ if ($res > 0)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@@ -90,6 +80,42 @@ if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
+else if ($action == 'updateengine')
+{
+ $sql = "SELECT rowid, coder";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
+ $sql.= " WHERE entity = ".$conf->entity;
+ $sql.= " ORDER BY code";
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ if (GETPOST('coder'.$obj->rowid, 'alpha'))
+ {
+ $coder = GETPOST('coder'.$obj->rowid,'alpha');
+ $code_id = $obj->rowid;
+
+ $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
+ $sqlp.= " SET coder = '" . $coder."'";
+ $sqlp.= " WHERE rowid = ". $code_id;
+ $sqlp.= " AND entity = ".$conf->entity;
+
+ $upsql=$db->query($sqlp);
+ if (! $upsql) dol_print_error($db);
+ }
+
+ $i++;
+ }
+ }
+
+}
/*
* View
@@ -162,9 +188,12 @@ $var=true;
print '
';
print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'','');
-//print "
';
}
-//print '';
print "
";
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 2b3ae7834e1..e6d6272b977 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -13,6 +13,7 @@
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014-2015 Marcos García
* Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018 Ferran Marcet
*
* 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
@@ -415,38 +416,40 @@ class Propal extends CommonObject
global $mysoc, $conf, $langs;
dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type, fk_remise_except=".$fk_remise_except);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
-
- // Clean parameters
- if (empty($remise_percent)) $remise_percent=0;
- if (empty($qty)) $qty=0;
- if (empty($info_bits)) $info_bits=0;
- if (empty($rang)) $rang=0;
- if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
-
- $remise_percent=price2num($remise_percent);
- $qty=price2num($qty);
- $pu_ht=price2num($pu_ht);
- $pu_ht_devise=price2num($pu_ht_devise);
- $pu_ttc=price2num($pu_ttc);
- $txtva=price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
- $txlocaltax1=price2num($txlocaltax1);
- $txlocaltax2=price2num($txlocaltax2);
- $pa_ht=price2num($pa_ht);
- if ($price_base_type=='HT')
- {
- $pu=$pu_ht;
- }
- else
- {
- $pu=$pu_ttc;
- }
-
- // Check parameters
- if ($type < 0) return -1;
-
if ($this->statut == self::STATUS_DRAFT)
{
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+
+ // Clean parameters
+ if (empty($remise_percent)) $remise_percent=0;
+ if (empty($qty)) $qty=0;
+ if (empty($info_bits)) $info_bits=0;
+ if (empty($rang)) $rang=0;
+ if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
+
+ $remise_percent=price2num($remise_percent);
+ $qty=price2num($qty);
+ $pu_ht=price2num($pu_ht);
+ $pu_ht_devise=price2num($pu_ht_devise);
+ $pu_ttc=price2num($pu_ttc);
+ if (!preg_match('/\((.*)\)/', $txtva)) {
+ $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
+ }
+ $txlocaltax1=price2num($txlocaltax1);
+ $txlocaltax2=price2num($txlocaltax2);
+ $pa_ht=price2num($pa_ht);
+ if ($price_base_type=='HT')
+ {
+ $pu=$pu_ht;
+ }
+ else
+ {
+ $pu=$pu_ttc;
+ }
+
+ // Check parameters
+ if ($type < 0) return -1;
+
$this->db->begin();
$product_type=$type;
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 739a6538612..7aee83e34ba 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -9,7 +9,7 @@
* Copyright (C) 2012 Cedric Salvador
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014-2015 Marcos García
- * Copyright (C) 2016-2017 Ferran Marcet
+ * Copyright (C) 2016-2018 Ferran Marcet
*
* 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
@@ -1270,44 +1270,46 @@ class Commande extends CommonOrder
dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise", LOG_DEBUG);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ if ($this->statut == self::STATUS_DRAFT)
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- // Clean parameters
- if (empty($remise_percent)) $remise_percent=0;
- if (empty($qty)) $qty=0;
- if (empty($info_bits)) $info_bits=0;
- if (empty($rang)) $rang=0;
- if (empty($txtva)) $txtva=0;
- if (empty($txlocaltax1)) $txlocaltax1=0;
- if (empty($txlocaltax2)) $txlocaltax2=0;
- if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
- if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0;
+ // Clean parameters
+ if (empty($remise_percent)) $remise_percent=0;
+ if (empty($qty)) $qty=0;
+ if (empty($info_bits)) $info_bits=0;
+ if (empty($rang)) $rang=0;
+ if (empty($txtva)) $txtva=0;
+ if (empty($txlocaltax1)) $txlocaltax1=0;
+ if (empty($txlocaltax2)) $txlocaltax2=0;
+ if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
+ if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0;
- $remise_percent=price2num($remise_percent);
- $qty=price2num($qty);
- $pu_ht=price2num($pu_ht);
- $pu_ht_devise=price2num($pu_ht_devise);
- $pu_ttc=price2num($pu_ttc);
- $pa_ht=price2num($pa_ht);
- $txtva = price2num($txtva);
- $txlocaltax1 = price2num($txlocaltax1);
- $txlocaltax2 = price2num($txlocaltax2);
- if ($price_base_type=='HT')
- {
- $pu=$pu_ht;
- }
- else
- {
- $pu=$pu_ttc;
- }
- $label=trim($label);
- $desc=trim($desc);
+ $remise_percent=price2num($remise_percent);
+ $qty=price2num($qty);
+ $pu_ht=price2num($pu_ht);
+ $pu_ht_devise=price2num($pu_ht_devise);
+ $pu_ttc=price2num($pu_ttc);
+ $pa_ht=price2num($pa_ht);
+ if (!preg_match('/\((.*)\)/', $txtva)) {
+ $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
+ }
+ $txlocaltax1 = price2num($txlocaltax1);
+ $txlocaltax2 = price2num($txlocaltax2);
+ if ($price_base_type=='HT')
+ {
+ $pu=$pu_ht;
+ }
+ else
+ {
+ $pu=$pu_ttc;
+ }
+ $label=trim($label);
+ $desc=trim($desc);
- // Check parameters
- if ($type < 0) return -1;
+ // Check parameters
+ if ($type < 0) return -1;
- if ($this->statut == self::STATUS_DRAFT)
- {
$this->db->begin();
$product_type=$type;
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index f0601ba37af..d55974e288c 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -2580,55 +2580,47 @@ class Facture extends CommonInvoice
global $mysoc, $conf, $langs;
dol_syslog(get_class($this)."::addline id=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
-
- // Clean parameters
- if (empty($remise_percent)) $remise_percent=0;
- if (empty($qty)) $qty=0;
- if (empty($info_bits)) $info_bits=0;
- if (empty($rang)) $rang=0;
- if (empty($ventil)) $ventil=0;
- if (empty($txtva)) $txtva=0;
- if (empty($txlocaltax1)) $txlocaltax1=0;
- if (empty($txlocaltax2)) $txlocaltax2=0;
- if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
- if (empty($fk_prev_id)) $fk_prev_id = 'null';
- if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100;
-
- $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
-
- // Clean vat code
- $vat_src_code='';
- if (preg_match('/\((.*)\)/', $txtva, $reg))
- {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
-
- $remise_percent=price2num($remise_percent);
- $qty=price2num($qty);
- $pu_ht=price2num($pu_ht);
- $pu_ht_devise=price2num($pu_ht_devise);
- $pu_ttc=price2num($pu_ttc);
- $pa_ht=price2num($pa_ht);
- $txtva=price2num($txtva);
- $txlocaltax1=price2num($txlocaltax1);
- $txlocaltax2=price2num($txlocaltax2);
-
- if ($price_base_type=='HT')
- {
- $pu=$pu_ht;
- }
- else
- {
- $pu=$pu_ttc;
- }
-
- // Check parameters
- if ($type < 0) return -1;
-
if (! empty($this->brouillon))
{
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+
+ // Clean parameters
+ if (empty($remise_percent)) $remise_percent=0;
+ if (empty($qty)) $qty=0;
+ if (empty($info_bits)) $info_bits=0;
+ if (empty($rang)) $rang=0;
+ if (empty($ventil)) $ventil=0;
+ if (empty($txtva)) $txtva=0;
+ if (empty($txlocaltax1)) $txlocaltax1=0;
+ if (empty($txlocaltax2)) $txlocaltax2=0;
+ if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
+ if (empty($fk_prev_id)) $fk_prev_id = 'null';
+ if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100;
+
+ $remise_percent=price2num($remise_percent);
+ $qty=price2num($qty);
+ $pu_ht=price2num($pu_ht);
+ $pu_ht_devise=price2num($pu_ht_devise);
+ $pu_ttc=price2num($pu_ttc);
+ $pa_ht=price2num($pa_ht);
+ if (!preg_match('/\((.*)\)/', $txtva)) {
+ $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
+ }
+ $txlocaltax1=price2num($txlocaltax1);
+ $txlocaltax2=price2num($txlocaltax2);
+
+ if ($price_base_type=='HT')
+ {
+ $pu=$pu_ht;
+ }
+ else
+ {
+ $pu=$pu_ttc;
+ }
+
+ // Check parameters
+ if ($type < 0) return -1;
+
$this->db->begin();
$product_type=$type;
@@ -2651,6 +2643,16 @@ class Facture extends CommonInvoice
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
+
+ // Clean vat code
+ $vat_src_code='';
+ if (preg_match('/\((.*)\)/', $txtva, $reg))
+ {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
+
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise);
$total_ht = $tabprice[0];
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index a460f6aff51..f8cb7ed005c 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -8,7 +8,7 @@
* Copyright (C) 2013 Christophe Battarel
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014-2015 Marcos García
- * Copyright (C) 2015-2017 Ferran Marcet
+ * Copyright (C) 2015-2018 Ferran Marcet
*
* 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
@@ -1358,11 +1358,23 @@ class Contrat extends CommonObject
{
$this->db->begin();
+ $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc);
+
+ // Clean vat code
+ $vat_src_code='';
+ if (preg_match('/\((.*)\)/', $txtva, $reg))
+ {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
+
// Clean parameters
$pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc);
$pa_ht=price2num($pa_ht);
- $txtva=price2num($txtva);
+ if (!preg_match('/\((.*)\)/', $txtva)) {
+ $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
+ }
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
$remise_percent=price2num($remise_percent);
@@ -1392,16 +1404,6 @@ class Contrat extends CommonObject
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
- $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc);
-
- // Clean vat code
- $vat_src_code='';
- if (preg_match('/\((.*)\)/', $txtva, $reg))
- {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
-
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1,$mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php
index e1ee7ae04ff..d155c8a1a0c 100644
--- a/htdocs/core/class/html.formbarcode.class.php
+++ b/htdocs/core/class/html.formbarcode.class.php
@@ -59,7 +59,7 @@ class FormBarCode
$disable = '';
- if ($conf->use_javascript_ajax)
+ if (!empty($conf->use_javascript_ajax))
{
print "\n".'