diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 3150625ba87..1134d3f0945 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2573,39 +2573,38 @@ abstract class CommonObject
*/
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $permtoedit=0)
{
- global $conf, $hookmanager, $inputalsopricewithtax, $usermargins, $langs, $user;
+ global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $langs, $user;
# Define usemargins
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1;
-
print '
';
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ' ';
// Description
- print ''.$langs->trans('Description').' ';
+ print ''.$langs->trans('Description').' ';
// VAT
- print ''.$langs->trans('VAT').' ';
+ print ''.$langs->trans('VAT').' ';
// Price HT
- print ''.$langs->trans('PriceUHT').' ';
+ print ''.$langs->trans('PriceUHT').' ';
- if ($inputalsopricewithtax) print ' ';
+ if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').' ';
// Qty
- print ''.$langs->trans('Qty').' ';
+ print ''.$langs->trans('Qty').' ';
// Reduction short
- print ''.$langs->trans('ReductionShort').' ';
+ print ''.$langs->trans('ReductionShort').' ';
if ($this->situation_cycle_ref) {
- print '' . $langs->trans('Progress') . ' ';
+ print '' . $langs->trans('Progress') . ' ';
}
- if ($usermargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
+ if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
{
if ($conf->global->MARGIN_TYPE == "1")
print ''.$langs->trans('BuyingPrice').' ';
diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php
index d844cc09c76..98f1b842f1a 100644
--- a/htdocs/core/tpl/objectline_edit.tpl.php
+++ b/htdocs/core/tpl/objectline_edit.tpl.php
@@ -43,7 +43,7 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
// Define colspan for button Add
$colspan = 3; // Col total ht + col edit + col delete
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
-if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button
+if (in_array($object->element,array('propal','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
?>
@@ -109,20 +109,18 @@ $coldisplay=-1; // We remove first td
}
$coldisplay++;
- print ' situation_counter > 1) {
- print 'readonly="readonly" ';
- }
+ print ' situation_counter > 1) print ' readonly="readonly"';
print '> ';
- if ($inputalsopricewithtax) {
+ if ($inputalsopricewithtax)
+ {
$coldisplay++;
- print ' situation_counter > 1) {
- print 'readonly="readonly" ';
- }
+ print ' situation_counter > 1) print ' readonly="readonly"';
print '> ';
- } ?>
+ }
+ ?>
info_bits & 2) != 2) {
@@ -130,11 +128,9 @@ $coldisplay=-1; // We remove first td
// for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
// must also not be output for most entities (proposal, intervention, ...)
//if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
- print ' situation_counter > 1) {
- print 'readonly="readonly" ';
- }
- print '/>';
+ print ' situation_counter > 1) print ' readonly="readonly"';
+ print '>';
} else { ?>
@@ -142,11 +138,9 @@ $coldisplay=-1; // We remove first td
info_bits & 2) != 2) {
- print ' situation_counter > 1) {
- print 'readonly="readonly" ';
- }
- print '/>%';
+ print ' situation_counter > 1) print ' readonly="readonly"';
+ print '>%';
} else { ?>
@@ -189,7 +183,8 @@ $coldisplay=-1; // We remove first td
$coldisplay++;
}
}
- } ?>
+ }
+ ?>
diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php
index a40e923fc39..0664d471dec 100644
--- a/htdocs/core/tpl/objectline_view.tpl.php
+++ b/htdocs/core/tpl/objectline_view.tpl.php
@@ -122,10 +122,10 @@ if (empty($usemargins)) $usemargins=0;
tva_tx,'%',$line->info_bits); ?>
- subprice); ?>
+ pu_ht)?price($line->pu_ht):price($line->subprice)); ?>
-
+ pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?>
@@ -139,7 +139,11 @@ if (empty($usemargins)) $usemargins=0;
remise_percent) && $line->special_code != 3) { ?>
- remise_percent,$langs); ?>
+ remise_percent,$langs);
+ ?>
' . $line->situation_percent . '%';
}
- if ($usermargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
+ if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
{
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
?>
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 14ba275d044..e626760f83e 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1873,8 +1873,19 @@ class CommandeFournisseur extends CommonOrder
if ($result > 0)
{
$this->rowid = $rowid;
+ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+ {
+ $tmpline = new CommandeFournisseurLigne($this->db);
+ $tmpline->id=$this->rowid;
+ $tmpline->array_options = $array_options;
+ $result=$tmpline->insertExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ }
+ }
- if (! $notrigger)
+ if (! $error && ! $notrigger)
{
global $conf, $langs, $user;
// Call trigger
@@ -1888,14 +1899,25 @@ class CommandeFournisseur extends CommonOrder
}
// Mise a jour info denormalisees au niveau facture
- $this->update_price('','auto');
+ if (! $error)
+ {
+ $this->update_price('','auto');
+ }
- $this->db->commit();
- return $result;
+ if (! $error)
+ {
+ $this->db->commit();
+ return $result;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
}
else
{
- $this->error=$this->db->error();
+ $this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
@@ -2163,17 +2185,22 @@ class CommandeFournisseur extends CommonOrder
*/
function getMaxDeliveryTimeDay($langs)
{
- if (empty($this->lines)) return $langs->trans('Undefined');
+ if (empty($this->lines)) return '';
+
+ $obj = new ProductFournisseur($this->db);
$nb = 0;
- foreach ($this->lines as $line) {
- $obj = new ProductFournisseur($this->db);
- $idp = $obj->find_min_price_product_fournisseur($line->fk_product, $line->qty);
- if ($idp) {
- $obj->fetch($idp);
- if ($obj->delivery_time_days > $nb) $nb = $obj->delivery_time_days;
+ foreach ($this->lines as $line)
+ {
+ if ($line->fk_product > 0)
+ {
+ $idp = $obj->find_min_price_product_fournisseur($line->fk_product, $line->qty);
+ if ($idp)
+ {
+ $obj->fetch($idp);
+ if ($obj->delivery_time_days > $nb) $nb = $obj->delivery_time_days;
+ }
}
-
}
if ($nb === 0) return $langs->trans('Undefined');
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index cada8c42af9..8283f1cb957 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -1323,9 +1323,16 @@ class FactureFournisseur extends CommonInvoice
// Update total price into invoice record
$result=$this->update_price('','auto');
- $this->db->commit();
-
- return $result;
+ if (! $error)
+ {
+ $this->db->commit();
+ return $result;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
}
else
{
@@ -1847,6 +1854,9 @@ class FactureFournisseurLigne extends CommonInvoice
var $db;
var $error;
+ var $pu_ht;
+ var $pu_ttc;
+
public $element='facture_fourn_det';
public $table_element='facture_fourn_det';
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 0fe73c981f4..68724345411 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -347,16 +347,16 @@ if (empty($reshook))
$localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty);
$localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty);
- if (!empty($_POST['price_ht']))
+ if (GETPOST('price_ht')!=='')
{
$price_base_type = 'HT';
- $ht = price2num($_POST['price_ht']);
+ $ht = price2num(GETPOST('price_ht'));
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type,'','', $date_start, $date_end, $array_options);
}
else
{
- $ttc = price2num($_POST['price_ttc']);
- $ht = $ttc / (1 + ($tauxtva / 100));
+ $ttc = price2num(GETPOST('price_ttc'));
+ $ht = $ttc / (1 + ($tva_tx / 100));
$price_base_type = 'HT';
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options);
}
@@ -426,18 +426,34 @@ if (empty($reshook))
*/
if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && ! GETPOST('cancel'))
{
- if ($_POST["elrowid"])
+ $tva_tx = GETPOST('tva_tx');
+
+ if (GETPOST('price_ht') != '')
+ {
+ $price_base_type = 'HT';
+ $ht = price2num(GETPOST('price_ht'));
+ $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type,'','', $date_start, $date_end);
+ }
+ else
+ {
+ $ttc = price2num(GETPOST('price_ttc'));
+ $ht = $ttc / (1 + ($tva_tx / 100));
+ $price_base_type = 'HT';
+ $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end);
+ }
+
+ if ($lineid)
{
$line = new CommandeFournisseurLigne($db);
- $res = $line->fetch($_POST["elrowid"]);
+ $res = $line->fetch($lineid);
if (!$res) dol_print_error($db);
}
$date_start=dol_mktime(GETPOST('date_start'.$date_pf.'hour'), GETPOST('date_start'.$date_pf.'min'), 0, GETPOST('date_start'.$date_pf.'month'), GETPOST('date_start'.$date_pf.'day'), GETPOST('date_start'.$date_pf.'year'));
$date_end=dol_mktime(GETPOST('date_end'.$date_pf.'hour'), GETPOST('date_end'.$date_pf.'min'), 0, GETPOST('date_end'.$date_pf.'month'), GETPOST('date_end'.$date_pf.'day'), GETPOST('date_end'.$date_pf.'year'));
- $localtax1_tx=get_localtax($_POST['tva_tx'],1,$mysoc,$object->thirdparty);
- $localtax2_tx=get_localtax($_POST['tva_tx'],2,$mysoc,$object->thirdparty);
+ $localtax1_tx=get_localtax($tva_tx,1,$mysoc,$object->thirdparty);
+ $localtax2_tx=get_localtax($tva_tx,2,$mysoc,$object->thirdparty);
// Extrafields Lines
$extrafieldsline = new ExtraFields($db);
@@ -451,21 +467,21 @@ if (empty($reshook))
}
$result = $object->updateline(
- $_POST['elrowid'],
- $_POST['eldesc'],
- $_POST['pu'],
+ $lineid,
+ $_POST['product_desc'],
+ $ht,
$_POST['qty'],
$_POST['remise_percent'],
- $_POST['tva_tx'],
+ $tva_tx,
$localtax1_tx,
$localtax2_tx,
- 'HT',
+ $price_base_type,
0,
isset($_POST["type"])?$_POST["type"]:$line->product_type,
false,
$date_start,
$date_end,
- $array_option
+ $array_options
);
unset($_POST['qty']);
unset($_POST['type']);
@@ -1730,7 +1746,7 @@ elseif (! empty($object->id))
$forceall=1; $senderissupplier=1; $dateSelector=0;
// Show object lines
- $inputalsopricewithtax=1;
+ $inputalsopricewithtax=0;
if (! empty($object->lines))
$ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1, $user->rights->fournisseur->commande->creer);
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index c2628b0cd0c..01be69f1590 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -438,7 +438,10 @@ if (empty($reshook))
0,
$lines[$i]->info_bits,
'HT',
- $product_type
+ $product_type,
+ $lines[$i]->rang,
+ 1,
+ $lines[$i]->array_options
);
if ($result < 0)
@@ -492,7 +495,7 @@ if (empty($reshook))
$product=new Product($db);
$product->fetch($_POST['idprod'.$i]);
- $ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base);
+ $ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base, $_POST['rang'.$i], 1);
if ($ret < 0) $error++;
}
}
@@ -535,16 +538,20 @@ if (empty($reshook))
$object->fetch($id);
$object->fetch_thirdparty();
- if ($_POST['puht'])
- {
- $pu=$_POST['puht'];
- $price_base_type='HT';
- }
- if ($_POST['puttc'])
- {
- $pu=$_POST['puttc'];
- $price_base_type='TTC';
- }
+ $tva_tx = GETPOST('tva_tx');
+
+ if (GETPOST('price_ht') != '')
+ {
+ $up = price2num(GETPOST('price_ht'));
+ $price_base_type = 'HT';
+ $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type,'','', $date_start, $date_end);
+ }
+ else
+ {
+ $up = price2num(GETPOST('price_ttc'));
+ $price_base_type = 'TTC';
+ $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end);
+ }
if (GETPOST('idprod'))
{
@@ -579,7 +586,7 @@ if (empty($reshook))
}
}
- $result=$object->updateline(GETPOST('lineid'), $label, $pu, GETPOST('tauxtva'), $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('idprod'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options);
+ $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('idprod'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options);
if ($result >= 0)
{
unset($_POST['label']);