diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 3ab9f91c9ff..69adde70895 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1065,7 +1065,30 @@ if ($placeid > 0) $htmlforlines .= ''; $htmlforlines .= ''.vatrate($line->remise_percent, true).''; - $htmlforlines .= ''.$line->qty.''; + $htmlforlines .= ''; + if (!empty($conf->stock->enabled)) + { + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; + $sql .= " ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; + $sql .= " WHERE ps.reel != 0"; + $sql .= " AND ps.fk_entrepot = ".$conf->global->$constantforkey; + $sql .= " AND e.entity IN (".getEntity('stock').")"; + $sql .= " AND ps.fk_product = ".$line->fk_product; + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $stock_real = price2num($obj->reel, 'MS'); + $htmlforlines .= $line->qty + if ($line->qty>$stock_real) $htmlforlines .= ''; + $htmlforlines .= ' ('.$langs->trans("Stock").' '.$stock_real.')'; + if ($line->qty>$stock_real) $htmlforlines .= ""; + } + } + else $htmlforlines .= $line->qty; + $htmlforlines .= ''; $htmlforlines .= ''.price($line->total_ttc).''; } $htmlforlines .= ''."\n";