diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 7aa1dc481e9..26c8a5beef9 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -696,15 +696,15 @@ if ($resql)
// Show shippable Icon (create subloop, so may be slow)
if ($conf->stock->enabled)
{
+ $notshippable=0;
+ $warning = 0;
+ $text_info='';
+ $text_warning='';
+ $nbprod=0;
+
$langs->load("stocks");
if (($obj->fk_statut > 0) && ($obj->fk_statut < 3))
{
- $notshippable=0;
- $warning = 0;
- $text_info='';
- $text_warning='';
- $nbprod=0;
-
$numlines = count($generic_commande->lines); // Loop on each line of order
for ($lig=0; $lig < $numlines; $lig++)
{
@@ -712,9 +712,11 @@ if ($resql)
{
$nbprod++; // order contains real products
$generic_product->id = $generic_commande->lines[$lig]->fk_product;
+
+ // Get local and virtual stock and store it into cache
if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
$generic_product->load_stock();
- $generic_product->load_virtual_stock();
+ //$generic_product->load_virtual_stock(); Already included into load_stock
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel;
$productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
} else {
@@ -722,7 +724,7 @@ if ($resql)
$generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique;
}
- if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code is when this option is not set, setting it create strange result
+ if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default is when this option is not set, setting it create strange result
{
$text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25);
$text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel;
@@ -795,7 +797,7 @@ if ($resql)
{
print $form->textwithtooltip('',$text_info,2,1,$text_icon,'',2);
}
- if ($warning) {
+ if ($warning) { // Always false in default mode
print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'),'',2);
}
print '';
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 55f259aa2fe..66b0df5969c 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -83,6 +83,7 @@ $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
$origin = GETPOST('origin', 'alpha');
$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
+$fac_rec=GETPOST('fac_rec','int');
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@@ -2082,8 +2083,9 @@ if ($action == 'create')
$(document).ready(function() {
$("#socid").change(function() {
var socid = $(this).val();
+ var fac_rec = $(\'#fac_rec\').val();
// reload page
- window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid;
+ window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec;
});
});
';
@@ -2098,6 +2100,8 @@ if ($action == 'create')
$invoice_predefined = new FactureRec($db);
$invoice_predefined->fetch(GETPOST('fac_rec','int'));
+ $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later
+
$sql = 'SELECT r.rowid, r.titre, r.total_ttc';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r';
$sql .= ' WHERE r.fk_soc = ' . $invoice_predefined->socid;
@@ -2111,7 +2115,7 @@ if ($action == 'create')
if ($num > 0)
{
print '