diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 1ef37552f1f..e00ff6a1763 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -210,6 +210,8 @@ if (empty($reshook))
$result = $object->deleteline($user, $lineid);
if ($result > 0)
{
+ // reorder lines
+ $object->line_order(true);
// Define output language
$outputlangs = $langs;
$newlang = '';
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index c517ddb2961..d3e5a0062b0 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -240,6 +240,8 @@ if (empty($reshook))
$result = $object->deleteline(GETPOST('lineid'));
if ($result > 0) {
+ // reorder lines
+ $object->line_order(true);
// Define output language
$outputlangs = $langs;
$newlang = '';
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index a4597fee291..183e88ffae3 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -1191,12 +1191,17 @@ if ($action == 'create')
{
// Quantity to send
print '
';
- if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
+ if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty = GETPOST('qtyl'.$indiceAsked, 'int');
print '';
print '';
- } else print $langs->trans("NA");
+ } else {
+ if (! empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) {
+ print '';
+ }
+
+ print $langs->trans("NA");
+ }
print ' | ';
// Stock
@@ -1361,7 +1366,13 @@ if ($action == 'create')
{
print '';
print '';
- } else print $langs->trans("NA");
+ } else {
+ if (! empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) {
+ print '';
+ }
+
+ print $langs->trans("NA");
+ }
print '';
// Stock
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index d27433522df..e9309b54c27 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -800,6 +800,8 @@ if (empty($reshook))
$result = $object->deleteline($lineid);
if ($result > 0)
{
+ // reorder lines
+ $object->line_order(true);
// Define output language
$outputlangs = $langs;
$newlang = '';
diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php
index f06542ab143..baefb2f1f27 100644
--- a/htdocs/fourn/commande/list.php
+++ b/htdocs/fourn/commande/list.php
@@ -521,7 +521,7 @@ $help_url = '';
// llxHeader('',$title,$help_url);
$sql = 'SELECT';
-if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
+if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
@@ -551,11 +551,6 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet";
// We'll need this table joined to the select in order to filter by sale
if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-if ($search_user > 0)
-{
- $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
- $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
-}
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
@@ -584,7 +579,15 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($se
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale);
-if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user);
+if ($search_user > 0) {
+ $sql .= " AND EXISTS (";
+ $sql .= " SELECT ec.rowid ";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "element_contact as ec";
+ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
+ $sql .= " WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
+ $sql .= " AND tc.element = 'order_supplier' AND tc.source = 'internal'";
+ $sql .= ")";
+}
if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1);
if ($search_total_vat != '') $sql .= natural_search('cf.tva', $search_total_vat, 1);
if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1);
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 61550e750e3..4b99853bfe2 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -244,6 +244,8 @@ if (empty($reshook))
$result = $object->deleteline($lineid);
if ($result > 0)
{
+ // reorder lines
+ $object->line_order(true);
// Define output language
/*$outputlangs = $langs;
$newlang = '';