products now show up in the list even when they don't have a line in llx_product_stock
This commit is contained in:
parent
9792e5ad00
commit
80a9dbfb90
@ -90,52 +90,60 @@ if (! empty($_POST["button_removefilter_x"]))
|
|||||||
//orders creation
|
//orders creation
|
||||||
if($action == 'order'){
|
if($action == 'order'){
|
||||||
$linecount = GETPOST('linecount', 'int');
|
$linecount = GETPOST('linecount', 'int');
|
||||||
$suppliers = array();
|
if($linecount > 0){
|
||||||
for($i = 0; $i < $linecount; $i++) {
|
$suppliers = array();
|
||||||
if(GETPOST($i, 'alpha') === 'on') { //one line
|
for($i = 0; $i < $linecount; $i++) {
|
||||||
$supplierpriceid = GETPOST('fourn'.$i, 'int');
|
if(GETPOST($i, 'alpha') === 'on') { //one line
|
||||||
//get all the parameters needed to create a line
|
$supplierpriceid = GETPOST('fourn'.$i, 'int');
|
||||||
$qty = GETPOST('tobuy'.$i, 'int');
|
//get all the parameters needed to create a line
|
||||||
$desc = GETPOST('desc'.$i, 'alpha');
|
$qty = GETPOST('tobuy'.$i, 'int');
|
||||||
$sql = 'Select fk_product, fk_soc, ref_fourn';
|
$desc = GETPOST('desc'.$i, 'alpha');
|
||||||
$sql .= ', tva_tx, unitprice';
|
$sql = 'Select fk_product, fk_soc, ref_fourn';
|
||||||
$sql .= ' from '.MAIN_DB_PREFIX.'product_fournisseur_price';
|
$sql .= ', tva_tx, unitprice';
|
||||||
$sql .= ' where rowid = '.$supplierpriceid;
|
$sql .= ' from '.MAIN_DB_PREFIX.'product_fournisseur_price';
|
||||||
$resql = $db->query($sql);
|
$sql .= ' where rowid = '.$supplierpriceid;
|
||||||
if($resql && $db->num_rows($resql) > 0) {
|
$resql = $db->query($sql);
|
||||||
//might need some value checks
|
if($resql && $db->num_rows($resql) > 0) {
|
||||||
$obj = $db->fetch_object($resql);
|
//might need some value checks
|
||||||
$line = new CommandeFournisseurLigne($db);
|
$obj = $db->fetch_object($resql);
|
||||||
$line->qty = $qty;
|
$line = new CommandeFournisseurLigne($db);
|
||||||
$line->desc = $desc;
|
$line->qty = $qty;
|
||||||
$line->fk_product = $obj->fk_product;
|
$line->desc = $desc;
|
||||||
$line->tva_tx = $obj->tva_tx;
|
$line->fk_product = $obj->fk_product;
|
||||||
$line->subprice = $obj->unitprice;
|
$line->tva_tx = $obj->tva_tx;
|
||||||
$line->total_ht = $obj->unitprice * $qty;
|
$line->subprice = $obj->unitprice;
|
||||||
$line->total_tva = $line->total_ht * $line->tva_tx / 100;
|
$line->total_ht = $obj->unitprice * $qty;
|
||||||
$line->total_ttc = $line->total_ht + $line->total_tva;
|
$line->total_tva = $line->total_ht * $line->tva_tx / 100;
|
||||||
$line->ref_fourn = $obj->ref_fourn;
|
$line->total_ttc = $line->total_ht + $line->total_tva;
|
||||||
$suppliers[$obj->fk_soc]['lines'][] = $line;
|
$line->ref_fourn = $obj->ref_fourn;
|
||||||
|
$suppliers[$obj->fk_soc]['lines'][] = $line;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$error=$db->lasterror();
|
||||||
|
dol_print_error($db);
|
||||||
|
dol_syslog("replenish.php: ".$error, LOG_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
$db->free($resql);
|
||||||
//we now know how many orders we need and what lines they have
|
//we now know how many orders we need and what lines they have
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$orders = array();
|
$orders = array();
|
||||||
$suppliersid = array_keys($suppliers);
|
$suppliersid = array_keys($suppliers);
|
||||||
foreach($suppliers as $supplier){
|
foreach($suppliers as $supplier){
|
||||||
$order = new CommandeFournisseur($db);
|
$order = new CommandeFournisseur($db);
|
||||||
$order->socid = $suppliersid[$i];
|
$order->socid = $suppliersid[$i];
|
||||||
//little trick to know which orders have been generated this way
|
//little trick to know which orders have been generated this way
|
||||||
$order->source = 42;
|
$order->source = 42;
|
||||||
foreach($supplier['lines'] as $line){
|
foreach($supplier['lines'] as $line){
|
||||||
$order->lines[] = $line;
|
$order->lines[] = $line;
|
||||||
|
}
|
||||||
|
$id = $order->create($user);
|
||||||
|
if($id < 0) {
|
||||||
|
//error stuff
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
$id = $order->create($user);
|
|
||||||
if($id < 0) {
|
|
||||||
//error stuff
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +210,7 @@ $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.pr
|
|||||||
$sql.= " p.fk_product_type, p.tms,";
|
$sql.= " p.fk_product_type, p.tms,";
|
||||||
$sql.= " p.duration, p.tobuy, p.seuil_stock_alerte";
|
$sql.= " p.duration, p.tobuy, p.seuil_stock_alerte";
|
||||||
$sql .= ", p.desiredstock";
|
$sql .= ", p.desiredstock";
|
||||||
$sql.= ' HAVING p.desiredstock > SUM(s.reel)';
|
$sql.= ' HAVING p.desiredstock > SUM(s.reel) or SUM(s.reel) is NULL';
|
||||||
$sql.= $db->order($sortfield,$sortorder);
|
$sql.= $db->order($sortfield,$sortorder);
|
||||||
$sql.= $db->plimit($limit + 1, $offset);
|
$sql.= $db->plimit($limit + 1, $offset);
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
@ -357,6 +365,7 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
print '<td align="right">'.$objp->desiredstock.'</td>';
|
print '<td align="right">'.$objp->desiredstock.'</td>';
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
|
if(!$objp->stock_physique) $objp->stock_physique = 0;
|
||||||
if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' ';
|
if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' ';
|
||||||
print $objp->stock_physique;
|
print $objp->stock_physique;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user