diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php
index 299260807a2..c798a36d538 100644
--- a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php
+++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php
@@ -1485,7 +1485,7 @@ class AskPriceSupplier extends CommonObject
/**
- * Close the commercial proposal
+ * Close the askprice
*
* @param User $user Object user that close
* @param int $statut Statut
@@ -1587,6 +1587,9 @@ class AskPriceSupplier extends CommonObject
dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG);
foreach ($this->lines as $product) {
+ if ($product->subprice <= 0)
+ continue;
+
$idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty);
$res = $productsupplier->fetch($idProductFourn);
@@ -2359,6 +2362,48 @@ class AskPriceSupplier extends CommonObject
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
+
+
+ function printOriginLinesList()
+ {
+ global $langs, $hookmanager;
+
+ print '
';
+ print '| '.$langs->trans('Ref').' | ';
+ print ''.$langs->trans('Description').' | ';
+ print ''.$langs->trans('VAT').' | ';
+ print ''.$langs->trans('PriceUHT').' | ';
+ print ''.$langs->trans('Qty').' | ';
+ print ''.$langs->trans('ReductionShort').' |
';
+
+ $num = count($this->lines);
+ $var = true;
+ $i = 0;
+
+ foreach ($this->lines as $line)
+ {
+ if (empty($line->subprice) || $line->qty <= 0)
+ continue;
+
+ $var=!$var;
+
+ if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
+ {
+ if (empty($line->fk_parent_line))
+ {
+ $parameters=array('line'=>$line,'var'=>$var,'i'=>$i);
+ $action='';
+ $reshook=$hookmanager->executeHooks('printOriginObjectLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ }
+ }
+ else
+ {
+ $this->printOriginLine($line,$var);
+ }
+
+ $i++;
+ }
+ }
}
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 749d430b2f9..5701edb22e5 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -854,15 +854,6 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer)
// If creation from another object of another module (Example: origin=propal, originid=1)
if (! empty($origin) && ! empty($originid)) {
- // Parse element/subelement (ex: project_task)
- /* PHFAVRE
- $element = $subelement = $origin;
- if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
- $element = $regs [1];
- $subelement = $regs [2];
- }
- */
-
$element = 'comm/askpricesupplier';
$subelement = 'askpricesupplier';
@@ -914,24 +905,15 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer)
for($i = 0; $i < $num; $i ++)
{
+
+ if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0)
+ continue;
+
$label = (! empty($lines [$i]->label) ? $lines [$i]->label : '');
$desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle);
$product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0);
- // Dates
- // TODO mutualiser
- $date_start = $lines [$i]->date_debut_prevue;
- if ($lines [$i]->date_debut_reel)
- $date_start = $lines [$i]->date_debut_reel;
- if ($lines [$i]->date_start)
- $date_start = $lines [$i]->date_start;
- $date_end = $lines [$i]->date_fin_prevue;
- if ($lines [$i]->date_fin_reel)
- $date_end = $lines [$i]->date_fin_reel;
- if ($lines [$i]->date_end)
- $date_end = $lines [$i]->date_end;
-
- // Reset fk_parent_line for no child products and special product
+ // Reset fk_parent_line for no child products and special product
if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) {
$fk_parent_line = 0;
}
@@ -944,9 +926,9 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer)
$array_option = $lines [$i]->array_options;
}
- $idprod = $productsupplier->find_min_price_product_fournisseur($lines [$i]->fk_product, $qty);
+ $idprod = $productsupplier->find_min_price_product_fournisseur($lines [$i]->fk_product, $lines [$i]->qty);
$res = $productsupplier->fetch($idProductFourn);
-
+
$result = $object->addline(
$desc,
$lines [$i]->subprice,
@@ -963,8 +945,8 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer)
$lines [$i]->product_type,
'',
'',
- $date_start,
- $date_end
+ null,
+ null
);
if ($result < 0) {