';
$sql = "SELECT count(f.rowid), f.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
@@ -83,7 +83,7 @@ $sql .= " AND f.fk_soc = s.rowid";
if ($user->socid) {
$sql .= ' AND f.fk_soc = '.((int) $user->socid);
}
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " GROUP BY f.fk_statut";
@@ -176,7 +176,7 @@ if (isModEnabled('ficheinter')) {
$sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
@@ -185,7 +185,7 @@ if (isModEnabled('ficheinter')) {
if ($socid) {
$sql .= " AND f.fk_soc = ".((int) $socid);
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
@@ -226,7 +226,7 @@ $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.date_valid as datec, f.tms as date
$sql .= " s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
@@ -235,7 +235,7 @@ $sql .= " AND f.fk_soc = s.rowid";
if ($socid) {
$sql .= " AND f.fk_soc = ".((int) $socid);
}
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " ORDER BY f.tms DESC";
@@ -299,7 +299,7 @@ if (isModEnabled('ficheinter')) {
$sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
@@ -308,7 +308,7 @@ if (isModEnabled('ficheinter')) {
if ($socid) {
$sql .= " AND f.fk_soc = ".((int) $socid);
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " ORDER BY f.rowid DESC";
diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php
index 1aeaa3f89f4..b4d6eb6c20c 100644
--- a/htdocs/fichinter/list.php
+++ b/htdocs/fichinter/list.php
@@ -275,7 +275,7 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
-if (!$user->hasRight('societe', 'client', 'voir') && empty($socid)) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
@@ -306,7 +306,7 @@ if ($search_desc) {
if ($search_status != '' && $search_status >= 0) {
$sql .= ' AND f.fk_statut = '.urlencode($search_status);
}
-if (!$user->hasRight('societe', 'client', 'voir') && empty($socid)) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php
index c6ab74da2ae..6cb69cf99f6 100644
--- a/htdocs/fichinter/stats/index.php
+++ b/htdocs/fichinter/stats/index.php
@@ -80,7 +80,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
-if (!$user->hasRight('societe', 'client', 'voir') || $user->socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$filenamenb = $dir.'/interventionsnbinyear-'.$user->id.'-'.$year.'.png';
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png';
} else {
@@ -116,7 +116,7 @@ if (!$mesg) {
$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
-if (!$user->hasRight('societe', 'client', 'voir') || $user->socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$filenameamount = $dir.'/interventionsamountinyear-'.$user->id.'-'.$year.'.png';
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png';
} else {
@@ -151,7 +151,7 @@ if (!$mesg) {
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
-if (!$user->hasRight('societe', 'client', 'voir') || $user->socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$filename_avg = $dir.'/interventionsaverage-'.$user->id.'-'.$year.'.png';
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png';
} else {
diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php
index 4b407e30a42..66ffc072e74 100644
--- a/htdocs/margin/customerMargins.php
+++ b/htdocs/margin/customerMargins.php
@@ -231,14 +231,14 @@ if (!empty($TSelectedCats)) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=d.fk_product';
}
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid";
if ($socid > 0) {
$sql .= ' AND s.rowid = '.((int) $socid);
}
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " AND f.fk_statut NOT IN (".$db->sanitize(implode(', ', $invoice_status_except_list)).")";
diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php
index aaa25015c34..89de7e7d79f 100644
--- a/htdocs/margin/tabs/productMargins.php
+++ b/htdocs/margin/tabs/productMargins.php
@@ -142,7 +142,7 @@ if ($id > 0 || !empty($ref)) {
$sql = "SELECT s.nom as name, s.rowid as socid, s.code_client,";
$sql .= " f.rowid as facid, f.ref, f.total_ht,";
$sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " sc.fk_soc, sc.fk_user,";
}
$sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive
@@ -152,7 +152,7 @@ if ($id > 0 || !empty($ref)) {
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid";
@@ -160,11 +160,11 @@ if ($id > 0 || !empty($ref)) {
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND d.fk_facture = f.rowid";
$sql .= " AND d.fk_product = ".((int) $object->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if (!empty($socid)) {
- $sql .= " AND f.fk_soc = $socid";
+ $sql .= " AND f.fk_soc = ".((int) $socid);
}
$sql .= " AND d.buy_price_ht IS NOT NULL";
// We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report.
@@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) {
$sql .= " AND d.buy_price_ht <> 0";
}
$sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut, f.type";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user";
}
$sql .= $db->order($sortfield, $sortorder);
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 5ebb8808848..0377c74a0a5 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -348,6 +348,25 @@ foreach ($search as $key => $val) {
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
+/*
+// If the internal user must only see his customers, force searching by him
+$search_sale = 0;
+if (!$user->hasRight('societe', 'client', 'voir')) {
+ $search_sale = $user->id;
+}
+// Search on sale representative
+if ($search_sale && $search_sale != '-1') {
+ if ($search_sale == -2) {
+ $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
+ } elseif ($search_sale > 0) {
+ $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
+ }
+}
+// Search on socid
+if ($socid) {
+ $sql .= " AND t.fk_soc = ".((int) $socid);
+}
+*/
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index c32dc6f393b..443e3158683 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -2884,7 +2884,7 @@ class Product extends CommonObject
$sql .= " SUM(mp.qty) as qty";
$sql .= " FROM ".$this->db->prefix()."mrp_mo as c";
$sql .= " INNER JOIN ".$this->db->prefix()."mrp_production as mp ON mp.fk_mo=c.rowid";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " INNER JOIN ".$this->db->prefix()."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " WHERE ";
@@ -3007,7 +3007,7 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."propaldet as pd";
$sql .= ", ".$this->db->prefix()."propal as p";
$sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE p.rowid = pd.fk_propal";
@@ -3082,14 +3082,14 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."supplier_proposaldet as pd";
$sql .= ", ".$this->db->prefix()."supplier_proposal as p";
$sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE p.rowid = pd.fk_supplier_proposal";
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
$sql .= " AND pd.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
//$sql.= " AND pr.fk_statut != 0";
@@ -3138,14 +3138,14 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."commandedet as cd";
$sql .= ", ".$this->db->prefix()."commande as c";
$sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE c.rowid = cd.fk_commande";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'commande').")";
$sql .= " AND cd.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -3266,14 +3266,14 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."commande_fournisseurdet as cd";
$sql .= ", ".$this->db->prefix()."commande_fournisseur as c";
$sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE c.rowid = cd.fk_commande";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'supplier_order').")";
$sql .= " AND cd.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -3329,7 +3329,7 @@ class Product extends CommonObject
$sql .= ", ".$this->db->prefix()."commande as c";
$sql .= ", ".$this->db->prefix()."expedition as e";
$sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE e.rowid = ed.fk_expedition";
@@ -3338,7 +3338,7 @@ class Product extends CommonObject
$sql .= " AND e.entity IN (".getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'expedition').")";
$sql .= " AND ed.fk_origin_line = cd.rowid";
$sql .= " AND cd.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -3413,14 +3413,14 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as fd";
$sql .= ", ".$this->db->prefix()."commande_fournisseur as cf";
$sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE cf.rowid = fd.fk_commande";
$sql .= " AND cf.fk_soc = s.rowid";
$sql .= " AND cf.entity IN (".getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'supplier_order').")";
$sql .= " AND fd.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -3474,13 +3474,13 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."mrp_production as mp";
$sql .= ", ".$this->db->prefix()."mrp_mo as m";
$sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON s.rowid = m.fk_soc";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE m.rowid = mp.fk_mo";
$sql .= " AND m.entity IN (".getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'mrp').")";
$sql .= " AND mp.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid && !$forVirtualStock) {
+ if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= " AND m.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -3570,14 +3570,14 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."contratdet as cd";
$sql .= ", ".$this->db->prefix()."contrat as c";
$sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE c.rowid = cd.fk_contrat";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('contract').")";
$sql .= " AND cd.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
//$sql.= " AND c.statut != 0";
@@ -3644,14 +3644,14 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."facturedet as fd";
$sql .= ", ".$this->db->prefix()."facture as f";
$sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE f.rowid = fd.fk_facture";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND fd.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
//$sql.= " AND f.fk_statut != 0";
@@ -3719,14 +3719,14 @@ class Product extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet_rec as fd";
$sql .= ", ".MAIN_DB_PREFIX."facture_rec as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.rowid = fd.fk_facture";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND fd.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
//$sql.= " AND f.fk_statut != 0";
@@ -3793,14 +3793,14 @@ class Product extends CommonObject
$sql .= " FROM ".$this->db->prefix()."facture_fourn_det as fd";
$sql .= ", ".$this->db->prefix()."facture_fourn as f";
$sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE f.rowid = fd.fk_facture_fourn";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('facture_fourn').")";
$sql .= " AND fd.fk_product = ".((int) $this->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
//$sql.= " AND f.fk_statut != 0";
@@ -3931,7 +3931,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".$this->db->prefix()."product as p";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE f.rowid = d.fk_facture";
@@ -3945,7 +3945,7 @@ class Product extends CommonObject
}
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -3985,7 +3985,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".$this->db->prefix()."product as p";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE f.rowid = d.fk_facture_fourn";
@@ -3999,7 +3999,7 @@ class Product extends CommonObject
}
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('facture_fourn').")";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -4037,7 +4037,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".$this->db->prefix()."product as prod";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE p.rowid = d.fk_propal";
@@ -4051,7 +4051,7 @@ class Product extends CommonObject
}
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('propal').")";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -4090,7 +4090,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".$this->db->prefix()."product as prod";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE p.rowid = d.fk_supplier_proposal";
@@ -4104,7 +4104,7 @@ class Product extends CommonObject
}
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -4142,7 +4142,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".$this->db->prefix()."product as p";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE c.rowid = d.fk_commande";
@@ -4156,7 +4156,7 @@ class Product extends CommonObject
}
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('commande').")";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -4194,7 +4194,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".$this->db->prefix()."product as p";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE c.rowid = d.fk_commande";
@@ -4208,7 +4208,7 @@ class Product extends CommonObject
}
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('supplier_order').")";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -4246,10 +4246,9 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".$this->db->prefix()."product as p";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
-
$sql .= " WHERE c.entity IN (".getEntity('contract').")";
$sql .= " AND c.rowid = d.fk_contrat";
@@ -4263,7 +4262,7 @@ class Product extends CommonObject
}
$sql .= " AND c.fk_soc = s.rowid";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
@@ -4300,7 +4299,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".$this->db->prefix()."product as p";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
@@ -4316,7 +4315,7 @@ class Product extends CommonObject
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = ".((int) $filteronproducttype);
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND d.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid > 0) {
diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php
index 70ddfeed681..199469264e0 100644
--- a/htdocs/product/stats/commande.php
+++ b/htdocs/product/stats/commande.php
@@ -141,13 +141,13 @@ if ($id > 0 || !empty($ref)) {
$sql .= " c.ref_client,";
$sql .= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty,";
$sql .= " c.date_livraison as delivery_date";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande as c";
$sql .= ", ".MAIN_DB_PREFIX."commandedet as d";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
@@ -160,7 +160,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($search_year)) {
$sql .= ' AND YEAR(c.date_commande) IN ('.$db->sanitize($search_year).')';
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php
index ea342530ded..6a5500456d5 100644
--- a/htdocs/product/stats/commande_fournisseur.php
+++ b/htdocs/product/stats/commande_fournisseur.php
@@ -141,13 +141,13 @@ if ($id > 0 || !empty($ref)) {
$sql .= " c.rowid, d.total_ht as total_ht, c.ref,";
$sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.rowid, d.qty,";
$sql .= " c.date_livraison as delivery_date";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseurdet as d";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
@@ -160,7 +160,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($search_year)) {
$sql .= ' AND YEAR(c.date_commande) IN ('.$db->sanitize($search_year).')';
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php
index 24b61e92490..e8c773099e7 100644
--- a/htdocs/product/stats/contrat.php
+++ b/htdocs/product/stats/contrat.php
@@ -135,7 +135,7 @@ if ($id > 0 || !empty($ref)) {
$sql .= " c.rowid as rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut as statut,";
$sql .= " s.nom as name, s.rowid as socid, s.code_client";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."contrat as c";
@@ -144,7 +144,7 @@ if ($id > 0 || !empty($ref)) {
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('contract').")";
$sql .= " AND cd.fk_product = ".((int) $product->id);
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php
index a3ca3c744ad..9eaf04992a3 100644
--- a/htdocs/product/stats/facture.php
+++ b/htdocs/product/stats/facture.php
@@ -193,7 +193,7 @@ if ($id > 0 || !empty($ref)) {
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
$sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,";
$sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
// Add fields from extrafields
@@ -214,7 +214,7 @@ if ($id > 0 || !empty($ref)) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.'facture'."_extrafields as ef on (f.rowid = ef.fk_object)";
}
$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
// Add table from hooks
@@ -232,7 +232,7 @@ if ($id > 0 || !empty($ref)) {
if ($search_date_end) {
$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php
index 04f6d0ddf22..7951d82799e 100644
--- a/htdocs/product/stats/facture_fournisseur.php
+++ b/htdocs/product/stats/facture_fournisseur.php
@@ -140,13 +140,13 @@ if ($id > 0 || !empty($ref)) {
if ($user->hasRight('fournisseur', 'facture', 'lire')) {
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as line_total_ht,";
$sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.libelle as label, f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut as statut, d.qty";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn_det as d";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid";
@@ -159,7 +159,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($search_year)) {
$sql .= ' AND YEAR(f.datef) IN ('.$db->sanitize($search_year).')';
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stats/facturerec.php b/htdocs/product/stats/facturerec.php
index 7cc7c83d400..3374f353391 100644
--- a/htdocs/product/stats/facturerec.php
+++ b/htdocs/product/stats/facturerec.php
@@ -158,13 +158,13 @@ if ($id > 0 || !empty($ref)) {
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
$sql .= "f.titre as title, f.datec, f.rowid as facid, f.suspended as suspended,";
$sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture_rec as f";
$sql .= ", ".MAIN_DB_PREFIX."facturedet_rec as d";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid";
@@ -177,7 +177,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($search_year)) {
$sql .= ' AND YEAR(f.datec) IN ('.$db->sanitize($search_year).')';
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php
index 991290e9b58..e2f26e810b7 100644
--- a/htdocs/product/stats/propal.php
+++ b/htdocs/product/stats/propal.php
@@ -142,13 +142,13 @@ if ($id > 0 || !empty($ref)) {
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,";
$sql .= " p.ref_client,";
$sql .= "p.datep, p.fk_statut as statut, d.rowid, d.qty";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ",".MAIN_DB_PREFIX."propal as p";
$sql .= ", ".MAIN_DB_PREFIX."propaldet as d";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.fk_soc = s.rowid";
@@ -161,7 +161,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($search_year)) {
$sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')';
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php
index 1234dec1db8..3f178ee0b7e 100644
--- a/htdocs/product/stats/supplier_proposal.php
+++ b/htdocs/product/stats/supplier_proposal.php
@@ -141,13 +141,13 @@ if ($id > 0 || !empty($ref)) {
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,";
//$sql .= " p.ref_supplier,";
$sql .= "p.date_valid, p.fk_statut as statut, d.rowid, d.qty";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ",".MAIN_DB_PREFIX."supplier_proposal as p";
$sql .= ", ".MAIN_DB_PREFIX."supplier_proposaldet as d";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.fk_soc = s.rowid";
@@ -160,7 +160,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($search_year)) {
$sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')';
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php
index 0867aadde04..4a1974d57b2 100644
--- a/htdocs/product/stock/class/productlot.class.php
+++ b/htdocs/product/stock/class/productlot.class.php
@@ -767,12 +767,12 @@ class Productlot extends CommonObject
$sql .= " INNER JOIN ".$this->db->prefix()."expeditiondet as ed ON (ed.rowid = edb.fk_expeditiondet)";
$sql .= " INNER JOIN ".$this->db->prefix()."expedition as exp ON (exp.rowid = ed.fk_expedition)";
// $sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE exp.entity IN (".getEntity('expedition').")";
$sql .= " AND edb.batch = '".($this->db->escape($this->batch))."'";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND exp.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
//$sql.= " AND exp.fk_statut != 0";
@@ -842,12 +842,12 @@ class Productlot extends CommonObject
$sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)";
$sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)";
// $sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE cf.entity IN (".getEntity('expedition').")";
$sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
//$sql.= " AND cf.fk_statut != 0";
@@ -916,12 +916,12 @@ class Productlot extends CommonObject
$sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi";
$sql .= " INNER JOIN ".$this->db->prefix()."reception as recep ON (recep.rowid = cfdi.fk_reception)";
// $sql .= ", ".$this->db->prefix()."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".$this->db->prefix()."societe_commerciaux as sc";
}
$sql .= " WHERE recep.entity IN (".getEntity('reception').")";
$sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND recep.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
//$sql.= " AND exp.fk_statut != 0";
@@ -996,7 +996,7 @@ class Productlot extends CommonObject
$sql .= " SUM(mp.qty) as qty";
$sql .= " FROM ".$this->db->prefix()."mrp_mo as c";
$sql .= " INNER JOIN ".$this->db->prefix()."mrp_production as mp ON mp.fk_mo=c.rowid";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= "INNER JOIN ".$this->db->prefix()."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " WHERE ";
diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php
index 8102d10e48a..9a0e0847016 100644
--- a/htdocs/product/stock/replenishorders.php
+++ b/htdocs/product/stock/replenishorders.php
@@ -126,7 +126,7 @@ $sql .= ' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,';
$sql .= ' u.login';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande_fournisseur as cf';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON cf.fk_user_author = u.rowid';
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc';
}
$sql .= ' WHERE cf.fk_soc = s.rowid ';
@@ -138,7 +138,7 @@ if (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER')) {
} else {
$sql .= ' AND cf.fk_statut < 5';
}
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.((int) $user->id);
}
if ($sref) {
diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php
index 5fd0a1e425d..756f814f575 100644
--- a/htdocs/product/stock/stats/commande_fournisseur.php
+++ b/htdocs/product/stock/stats/commande_fournisseur.php
@@ -218,14 +218,14 @@ if ($id > 0 || !empty($ref)) {
$sql .= " cf.ref, cf.date_commande, cf.date_livraison as delivery_date, cf.fk_statut as statut, cf.rowid as facid,";
$sql .= " cfd.rowid, SUM(cfdi.qty) as qty";
// $sql.= ", cfd.total_ht * SUM(cfdi.qty) / cfd.qty as total_ht_pondere";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur as cf ON (cf.fk_soc = s.rowid)";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cfd ON (cfd.fk_commande = cf.rowid)";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfdi ON (cfdi.fk_commandefourndet = cfd.rowid)";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE cf.entity IN (".getEntity('product').")";
@@ -236,7 +236,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($search_year)) {
$sql .= ' AND YEAR(cf.date_commande) IN ('.$db->sanitize($search_year).')';
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php
index e8efff308f8..5596ff381d5 100644
--- a/htdocs/product/stock/stats/expedition.php
+++ b/htdocs/product/stock/stats/expedition.php
@@ -218,14 +218,14 @@ if ($id > 0 || !empty($ref)) {
$sql .= " exp.ref, exp.date_creation, exp.fk_statut as statut, exp.rowid as facid,";
$sql .= " d.rowid, db.qty";
// $sql.= ", d.total_ht as total_ht"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expedition as exp ON (exp.fk_soc = s.rowid)";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expeditiondet as d ON (d.fk_expedition = exp.rowid)";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as db ON (db.fk_expeditiondet = d.rowid)";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE exp.entity IN (".getEntity('product').")";
@@ -236,7 +236,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($search_year)) {
$sql .= ' AND YEAR(exp.date_creation) IN ('.$db->sanitize($search_year).')';
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php
index a117b2043fa..63c4b942310 100644
--- a/htdocs/product/stock/stats/reception.php
+++ b/htdocs/product/stock/stats/reception.php
@@ -218,13 +218,13 @@ if ($id > 0 || !empty($ref)) {
$sql .= " recep.ref, recep.date_creation, recep.fk_statut as statut, recep.rowid as facid,";
$sql .= " d.qty";
// $sql.= ", d.total_ht as total_ht"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", sc.fk_soc, sc.fk_user ";
}
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."reception as recep ON (recep.fk_soc = s.rowid)";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as d ON (d.fk_reception = recep.rowid)";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE recep.entity IN (".getEntity('product').")";
@@ -235,7 +235,7 @@ if ($id > 0 || !empty($ref)) {
if (!empty($search_year)) {
$sql .= ' AND YEAR(recep.date_creation) IN ('.$db->sanitize($search_year).')';
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index e04aa4cf676..6706558523f 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -2350,7 +2350,7 @@ class Task extends CommonObjectLine
$sql = "SELECT count(p.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
}
$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
@@ -2364,7 +2364,7 @@ class Task extends CommonObjectLine
if ($socid) {
$sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")";
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).") OR (s.rowid IS NULL))";
}
diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php
index 0a7d13fc47d..a314b848477 100644
--- a/htdocs/projet/class/taskstats.class.php
+++ b/htdocs/projet/class/taskstats.class.php
@@ -58,8 +58,8 @@ class TaskStats extends Stats
$sql = "SELECT";
$sql .= " COUNT(t.rowid), t.priority";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet";
- if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
+ if (!$user->hasRight('societe', 'client', 'voir')) {
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->buildWhere();
//$sql .= " AND t.fk_statut <> 0"; // We want historic also, so all task not draft
@@ -112,8 +112,8 @@ class TaskStats extends Stats
$sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet";
- if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
+ if (!$user->hasRight('societe', 'client', 'voir')) {
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->buildWhere();
$sql .= " GROUP BY year";
@@ -174,7 +174,7 @@ class TaskStats extends Stats
$sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(t.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet";
- if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=p.fk_soc AND sc.fk_user=".((int) $user->id);
}
$sql .= $this->buildWhere();
diff --git a/htdocs/reception/class/receptionstats.class.php b/htdocs/reception/class/receptionstats.class.php
index e0fe16e7854..b56211933dd 100644
--- a/htdocs/reception/class/receptionstats.class.php
+++ b/htdocs/reception/class/receptionstats.class.php
@@ -70,7 +70,7 @@ class ReceptionStats extends Stats
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
$this->where .= " AND c.entity IN (".getEntity('reception').")";
- if (!$user->hasRight('societe', 'client', 'voir') && !$this->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($this->socid) {
@@ -94,7 +94,7 @@ class ReceptionStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from;
- if (!$user->hasRight('societe', 'client', 'voir') && !$this->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
@@ -118,7 +118,7 @@ class ReceptionStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from;
- if (!$user->hasRight('societe', 'client', 'voir') && !$this->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE ".$this->where;
@@ -141,7 +141,7 @@ class ReceptionStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from;
- if (!$user->hasRight('societe', 'client', 'voir') && !$this->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
@@ -165,7 +165,7 @@ class ReceptionStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, AVG(c.".$this->field.")";
$sql .= " FROM ".$this->from;
- if (!$user->hasRight('societe', 'client', 'voir') && !$this->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
@@ -187,7 +187,7 @@ class ReceptionStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg";
$sql .= " FROM ".$this->from;
- if (!$user->hasRight('societe', 'client', 'voir') && !$this->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE ".$this->where;
diff --git a/htdocs/reception/index.php b/htdocs/reception/index.php
index 9baecc185e8..4c923a3f307 100644
--- a/htdocs/reception/index.php
+++ b/htdocs/reception/index.php
@@ -88,7 +88,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception'";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql .= $clause." sc.fk_user = ".((int) $user->id);
$clause = " AND ";
@@ -152,11 +152,11 @@ $sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception' AND el.sourcetype IN ('order_supplier')";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid AND el.sourcetype IN ('order_supplier') AND el.targettype = 'reception'";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
}
$sql .= " WHERE e.entity IN (".getEntity('reception').")";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND sc.fk_user = ".((int) $user->id);
}
$sql .= " AND e.fk_statut = 1";
@@ -213,7 +213,7 @@ if ($resql) {
$sql = "SELECT c.rowid, c.ref, c.ref_supplier as ref_supplier, c.fk_statut as status, c.billed as billed, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
@@ -222,7 +222,7 @@ $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".Comma
if ($socid > 0) {
$sql .= " AND c.fk_soc = ".((int) $socid);
}
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " ORDER BY c.rowid ASC";
diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php
index e2b93a9a4a3..d8be5bd1862 100644
--- a/htdocs/reception/stats/index.php
+++ b/htdocs/reception/stats/index.php
@@ -71,7 +71,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
-if (!$user->hasRight('societe', 'client', 'voir') || $user->socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$filenamenb = $dir.'/receptionsnbinyear-'.$user->id.'-'.$year.'.png';
} else {
$filenamenb = $dir.'/receptionsnbinyear-'.$year.'.png';
diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php
index 8bf79b2b7f7..e3583c439e0 100644
--- a/htdocs/societe/class/client.class.php
+++ b/htdocs/societe/class/client.class.php
@@ -64,7 +64,7 @@ class Client extends Societe
$sql = "SELECT count(s.rowid) as nb, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".((int) $user->id);
$clause = "AND";
diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php
index 854be79efc2..a954f0a0426 100644
--- a/htdocs/societe/index.php
+++ b/htdocs/societe/index.php
@@ -100,11 +100,11 @@ $total = 0;
$sql = "SELECT s.rowid, s.client, s.fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if (!$user->hasRight('fournisseur', 'lire')) {
@@ -294,11 +294,11 @@ $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
}
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if (!$user->hasRight('fournisseur', 'lire')) {
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index 85489b2a314..0de0a878ab0 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -521,10 +521,6 @@ $sql .= " staff.code as staff_code,";
$sql .= " country.code as country_code, country.label as country_label,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
$sql .= " region.code_region as region_code, region.nom as region_name";
-// We'll need these fields in order to filter by sale (including the case where the user can only see his prospects)
-if ($search_sale && $search_sale != '-1') {
- $sql .= ", sc.fk_soc, sc.fk_user";
-}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
@@ -552,32 +548,21 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_ef
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.code_region = state.fk_region)";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
-// We'll need this table joined to the select in order to filter by sale
-if ($search_sale == -2) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
- //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-} elseif (!empty($search_sale) && $search_sale != '-1' || (!$user->hasRight('societe', 'client', 'voir') && !$socid)) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-}
// Add table from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
-//if (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
-}
-if ($search_sale && $search_sale != '-1' && $search_sale != '-2') {
- $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
-}
if (!$user->hasRight('fournisseur', 'lire')) {
$sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
}
-if ($search_sale == -2) {
- $sql .= " AND sc.fk_user IS NULL";
-} elseif ($search_sale > 0) {
- $sql .= " AND sc.fk_user = ".((int) $search_sale);
+// Search on sale representative
+if ($search_sale && $search_sale != '-1') {
+ if ($search_sale == -2) {
+ $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid)";
+ } elseif ($search_sale > 0) {
+ $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid AND sc.fk_user = ".((int) $search_sale).")";
+ }
}
$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();
$searchCategoryCustomerOperator = 0;
diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php
index ffe975640e2..f877fddc2c2 100644
--- a/htdocs/supplier_proposal/class/supplier_proposal.class.php
+++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php
@@ -2223,7 +2223,7 @@ class SupplierProposal extends CommonObject
$sql = "SELECT p.rowid, p.ref, p.datec as datec, p.date_cloture as datefin";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p";
- if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".((int) $user->id);
$clause = " AND";
@@ -2380,7 +2380,7 @@ class SupplierProposal extends CommonObject
$sql = "SELECT count(p.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid";
- if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".((int) $user->id);
$clause = "AND";
diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php
index e69bad34b72..34bfb83eed3 100644
--- a/htdocs/supplier_proposal/index.php
+++ b/htdocs/supplier_proposal/index.php
@@ -67,7 +67,7 @@ print '
';
$sql = "SELECT count(p.rowid), p.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.fk_soc = s.rowid";
@@ -75,7 +75,7 @@ $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
if ($user->socid) {
$sql .= ' AND p.fk_soc = '.((int) $user->socid);
}
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " AND p.fk_statut IN (0,1,2,3,4)";
@@ -167,7 +167,7 @@ if (isModEnabled('supplier_proposal')) {
$sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
@@ -176,7 +176,7 @@ if (isModEnabled('supplier_proposal')) {
if ($socid) {
$sql .= " AND c.fk_soc = ".((int) $socid);
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
@@ -225,7 +225,7 @@ $sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid,
$sql .= " date_cloture as datec";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
@@ -234,7 +234,7 @@ $sql .= " AND c.entity = ".$conf->entity;
if ($socid) {
$sql .= " AND c.fk_soc = ".((int) $socid);
}
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= " ORDER BY c.tms DESC";
@@ -306,13 +306,13 @@ if (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'l
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as supplier_proposalid, p.total_ttc, p.total_tva, p.total_ht, p.ref, p.fk_statut, p.datec as dp";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
$sql .= " AND p.fk_statut = 1";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
if ($socid) {
diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php
index 9b6bcd90be8..75e106f0454 100644
--- a/htdocs/ticket/class/ticket.class.php
+++ b/htdocs/ticket/class/ticket.class.php
@@ -792,8 +792,8 @@ class Ticket extends CommonObject
$sql .= " t.date_read,";
$sql .= " t.date_last_msg_sent,";
$sql .= " t.date_close,";
- $sql .= " t.tms";
- $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label";
+ $sql .= " t.tms,";
+ $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label";
// Add fields for extrafields
if ($extrafields->attributes[$this->table_element]['count']> 0) {
foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) {
@@ -801,21 +801,17 @@ class Ticket extends CommonObject
}
}
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid=t.fk_user_create";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON ua.rowid=t.fk_user_assign";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code = t.type_code";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code = t.category_code";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code = t.severity_code";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid = t.fk_user_create";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON ua.rowid = t.fk_user_assign";
if ($extrafields->attributes[$this->table_element]['count']> 0) {
if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)";
}
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- }
-
$sql .= " WHERE t.entity IN (".getEntity('ticket').")";
// Manage filter
@@ -838,10 +834,25 @@ class Ticket extends CommonObject
}
}
}
- if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
- $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- } elseif ($user->socid) {
- $sql .= " AND t.fk_soc = ".((int) $user->socid);
+
+ // Case of external user
+ $socid = $user->socid ? $user->socid : 0;
+ // If the internal user must only see his customers, force searching by him
+ $search_sale = 0;
+ if (!$user->hasRight('societe', 'client', 'voir')) {
+ $search_sale = $user->id;
+ }
+ // Search on sale representative
+ if ($search_sale && $search_sale != '-1') {
+ if ($search_sale == -2) {
+ $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
+ } elseif ($search_sale > 0) {
+ $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
+ }
+ }
+ // Search on socid
+ if ($socid) {
+ $sql .= " AND t.fk_soc = ".((int) $socid);
}
$sql .= $this->db->order($sortfield, $sortorder);
@@ -3060,7 +3071,7 @@ class Ticket extends CommonObject
$sql = "SELECT count(p.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid";
- if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".((int) $user->id);
$clause = "AND";
diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php
index 011826f9095..79668bb3c8c 100644
--- a/htdocs/ticket/index.php
+++ b/htdocs/ticket/index.php
@@ -156,13 +156,13 @@ $tick = array(
$sql = "SELECT t.fk_statut, COUNT(t.fk_statut) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ' WHERE t.entity IN ('.getEntity('ticket').')';
$sql .= dolSqlDateFilter('datec', 0, 0, $endyear);
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
@@ -332,13 +332,13 @@ if ($user->hasRight('ticket', 'read')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ' WHERE t.entity IN ('.getEntity('ticket').')';
$sql .= " AND t.fk_statut = 0";
- if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
+ if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php
index bcc74cc0e0c..5bd47cff622 100644
--- a/htdocs/ticket/stats/index.php
+++ b/htdocs/ticket/stats/index.php
@@ -83,7 +83,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
-if (!$user->hasRight('societe', 'client', 'voir') || $user->socid) {
+if (!$user->hasRight('societe', 'client', 'voir')) {
$filenamenb = $dir.'/ticketsnbinyear-'.$user->id.'-'.$year.'.png';
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.'-'.$year.'.png';
} else {
diff --git a/htdocs/webhook/webhookindex.php b/htdocs/webhook/webhookindex.php
deleted file mode 100644
index 2886d3f5e1c..00000000000
--- a/htdocs/webhook/webhookindex.php
+++ /dev/null
@@ -1,208 +0,0 @@
-
- * Copyright (C) 2004-2015 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2015 Jean-François Ferry
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file webhook/webhookindex.php
- * \ingroup webhook
- * \brief Home page of webhook top menu
- */
-
-// Load Dolibarr environment
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-
-// Parameters
-$action = GETPOST('action', 'aZ09');
-
-// Security check
-// if (! $user->rights->webhook->myobject->read) {
-// accessforbidden();
-// }
-$socid = GETPOST('socid', 'int');
-if (isset($user->socid) && $user->socid > 0) {
- $action = '';
- $socid = $user->socid;
-}
-
-$max = 5;
-$now = dol_now();
-
-
-/*
- * Actions
- */
-
-// None
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-$formfile = new FormFile($db);
-
-llxHeader("", $langs->trans("WebhookArea"));
-
-print load_fiche_titre($langs->trans("WebhookArea"), '', 'webhook.png@webhook');
-
-print '';
-
-
-/* BEGIN MODULEBUILDER DRAFT MYOBJECT
-// Draft MyObject
-if (!empty($conf->webhook->enabled) && $user->rights->webhook->read) {
- $langs->load("orders");
-
- $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
- $sql.= ", s.code_client";
- $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
- $sql.= ", ".MAIN_DB_PREFIX."societe as s";
- if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE c.fk_soc = s.rowid";
- $sql.= " AND c.fk_statut = 0";
- $sql.= " AND c.entity IN (".getEntity('commande').")";
- if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
-
- $resql = $db->query($sql);
- if ($resql)
- {
- $total = 0;
- $num = $db->num_rows($resql);
-
- print '
';
- print '';
- print '| '.$langs->trans("DraftMyObjects").($num?''.$num.'':'').' |
';
-
- $var = true;
- if ($num > 0)
- {
- $i = 0;
- while ($i < $num)
- {
-
- $obj = $db->fetch_object($resql);
- print '| ';
-
- $myobjectstatic->id=$obj->rowid;
- $myobjectstatic->ref=$obj->ref;
- $myobjectstatic->ref_client=$obj->ref_client;
- $myobjectstatic->total_ht = $obj->total_ht;
- $myobjectstatic->total_tva = $obj->total_tva;
- $myobjectstatic->total_ttc = $obj->total_ttc;
-
- print $myobjectstatic->getNomUrl(1);
- print ' | ';
- print '';
- print ' | ';
- print ''.price($obj->total_ttc).' |
';
- $i++;
- $total += $obj->total_ttc;
- }
- if ($total>0)
- {
-
- print '| '.$langs->trans("Total").' | '.price($total)." |
";
- }
- }
- else
- {
-
- print '| '.$langs->trans("NoOrder").' |
';
- }
- print "
";
-
- $db->free($resql);
- }
- else
- {
- dol_print_error($db);
- }
-}
-END MODULEBUILDER DRAFT MYOBJECT */
-
-
-print '
';
-
-
-$NBMAX = getDolGlobalString('MAIN_SIZE_SHORTLIST_LIMIT');
-$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT');
-
-/* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
-// Last modified myobject
-if (!empty($conf->webhook->enabled) && $user->rights->webhook->read)
-{
- $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms";
- $sql.= " FROM ".MAIN_DB_PREFIX."webhook_myobject as s";
- //if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")";
- //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- //if ($socid) $sql.= " AND s.rowid = $socid";
- $sql .= " ORDER BY s.tms DESC";
- $sql .= $db->plimit($max, 0);
-
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
-
- print '
';
- print '';
- print '| ';
- print $langs->trans("BoxTitleLatestModifiedMyObjects", $max);
- print ' | ';
- print ''.$langs->trans("DateModificationShort").' | ';
- print '
';
- if ($num)
- {
- while ($i < $num)
- {
- $objp = $db->fetch_object($resql);
-
- $myobjectstatic->id=$objp->rowid;
- $myobjectstatic->ref=$objp->ref;
- $myobjectstatic->label=$objp->label;
- $myobjectstatic->status = $objp->status;
-
- print '';
- print '| '.$myobjectstatic->getNomUrl(1).' | ';
- print '';
- print " | ";
- print ''.dol_print_date($db->jdate($objp->tms), 'day')." | ";
- print '
';
- $i++;
- }
-
- $db->free($resql);
- } else {
- print '| '.$langs->trans("None").' |
';
- }
- print "
";
- }
-}
-*/
-
-print '
';
-
-// End of page
-llxFooter();
-$db->close();