';
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 0fedb83d524..d967d94e9e1 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -680,7 +680,7 @@ if ($showbirthday)
$sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
$sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
$sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))';
- $sql.= " AND sp.entity IN (".getEntity('societe').")";
+ $sql.= " AND sp.entity IN (".getEntity('socpeople').")";
if ($action == 'show_day')
{
$sql.= ' AND MONTH(birthday) = '.$month;
diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php
index 1460abe9823..fe2e3027dcf 100644
--- a/htdocs/comm/contact.php
+++ b/htdocs/comm/contact.php
@@ -78,7 +78,7 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql .= " ".MAIN_DB_PREF
$sql.= " ".MAIN_DB_PREFIX."socpeople as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql.= " WHERE s.fk_stcomm = st.id";
-$sql.= " AND p.entity IN (".getEntity('societe').")";
+$sql.= " AND p.entity IN (".getEntity('socpeople').")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($type == "c") $sql.= " AND s.client IN (1, 3)";
if ($type == "p") $sql.= " AND s.client IN (2, 3)";
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index e63cfa3da99..5053e07212f 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -687,7 +687,10 @@ class Contact extends CommonObject
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
if ($id) $sql.= " WHERE c.rowid = ". $id;
- elseif ($ref_ext) $sql .= " WHERE c.ref_ext = '".$this->db->escape($ref_ext)."'";
+ elseif ($ref_ext) {
+ $sql .= " WHERE c.entity IN (".getEntity($this->element).")";
+ $sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'";
+ }
$resql=$this->db->query($sql);
if ($resql)
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 0660b394f1b..8719c77f1b4 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -260,7 +260,7 @@ if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_conta
if (! empty($search_categ_thirdparty)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
if (! empty($search_categ_supplier)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
-$sql.= ' WHERE p.entity IN ('.getEntity('societe').')';
+$sql.= ' WHERE p.entity IN ('.getEntity('socpeople').')';
if (!$user->rights->societe->client->voir && !$socid) //restriction
{
$sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)";
diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php
index d74d45598a7..394680f4d8e 100644
--- a/htdocs/core/actions_addupdatedelete.inc.php
+++ b/htdocs/core/actions_addupdatedelete.inc.php
@@ -76,7 +76,7 @@ if ($action == 'add' && ! empty($permissiontoadd))
if ($result > 0)
{
// Creation OK
- $urltogo=$backtopage?$backtopage:$backurlforlist;
+ $urltogo=$backtopage?str_replace('__ID__', $result, $backtopage):$backurlforlist;
header("Location: ".$urltogo);
exit;
}
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index 936d269f82a..a8dc7f1231d 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -85,7 +85,7 @@ class box_contacts extends ModeleBoxes
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE sp.entity IN (".getEntity('societe').")";
+ $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")";
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id;
$sql.= " ORDER BY sp.tms DESC";
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 4b70f5d424c..0fbd5b05949 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1116,7 +1116,7 @@ abstract class CommonObject
$sql.= " WHERE ec.element_id = ".$id;
$sql.= " AND ec.fk_socpeople = c.rowid";
if ($source == 'internal') $sql.= " AND c.entity IN (0,".$conf->entity.")";
- if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")";
+ if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('socpeople').")";
$sql.= " AND ec.fk_c_type_contact = tc.rowid";
$sql.= " AND tc.element = '".$element."'";
$sql.= " AND tc.source = '".$source."'";
@@ -5582,7 +5582,7 @@ abstract class CommonObject
$("a#'.dol_escape_js($keyprefix.$key.$keysuffix).'_add").click(function() {
$("'.dol_escape_js($newInput).'").insertBefore(this);
});
-
+
$(document).on("click", "a.'.dol_escape_js($keyprefix.$key.$keysuffix).'_del", function() {
$(this).parent().remove();
});
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index ccd873ece8a..c02ada175fd 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1332,7 +1332,7 @@ class Form
if ($showsoc > 0) $sql.= " , s.nom as company";
$sql.= " FROM ".MAIN_DB_PREFIX ."socpeople as sp";
if ($showsoc > 0) $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX ."societe as s ON s.rowid=sp.fk_soc";
- $sql.= " WHERE sp.entity IN (".getEntity('societe').")";
+ $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")";
if ($socid > 0) $sql.= " AND sp.fk_soc=".$socid;
if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut <> 0";
$sql.= " ORDER BY sp.lastname ASC";
diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php
index e6f0255b9d9..38636396da5 100644
--- a/htdocs/core/modules/mailings/advthirdparties.modules.php
+++ b/htdocs/core/modules/mailings/advthirdparties.modules.php
@@ -122,7 +122,7 @@ class mailing_advthirdparties extends MailingTargets
{
$sql= "SELECT socp.rowid as id, socp.email as email, socp.lastname as lastname, socp.firstname as firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as socp";
- $sql.= " WHERE socp.entity IN (".getEntity('societe').")";
+ $sql.= " WHERE socp.entity IN (".getEntity('socpeople').")";
if (count($contactid)>0) {
$sql.= " AND socp.rowid IN (".implode(',',$contactid).")";
}
diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php
index 8aae15b9cc8..90d81dca4a5 100644
--- a/htdocs/core/modules/mailings/contacts1.modules.php
+++ b/htdocs/core/modules/mailings/contacts1.modules.php
@@ -71,7 +71,7 @@ class mailing_contacts1 extends MailingTargets
$statssql[0] = "SELECT '".$langs->trans("NbOfCompaniesContacts")."' as label,";
$statssql[0].= " count(distinct(c.email)) as nb";
$statssql[0].= " FROM ".MAIN_DB_PREFIX."socpeople as c";
- $statssql[0].= " WHERE c.entity IN (".getEntity('societe').")";
+ $statssql[0].= " WHERE c.entity IN (".getEntity('socpeople').")";
$statssql[0].= " AND c.email != ''"; // Note that null != '' is false
$statssql[0].= " AND c.no_email = 0";
$statssql[0].= " AND c.statut = 1";
@@ -95,7 +95,7 @@ class mailing_contacts1 extends MailingTargets
$sql = "SELECT count(distinct(c.email)) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc";
- $sql.= " WHERE c.entity IN (".getEntity('societe').")";
+ $sql.= " WHERE c.entity IN (".getEntity('socpeople').")";
$sql.= " AND c.email != ''"; // Note that null != '' is false
$sql.= " AND c.no_email = 0";
$sql.= " AND c.statut = 1";
@@ -123,7 +123,7 @@ class mailing_contacts1 extends MailingTargets
// Add filter on job position
$sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
- $sql.= " WHERE sp.entity IN (".getEntity('societe').")";
+ $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")";
/*$sql.= " AND sp.email != ''"; // Note that null != '' is false
$sql.= " AND sp.no_email = 0";
$sql.= " AND sp.statut = 1";*/
@@ -161,7 +161,7 @@ class mailing_contacts1 extends MailingTargets
$sql.= " WHERE sp.statut = 1"; // Note that null != '' is false
//$sql.= " AND sp.no_email = 0";
//$sql.= " AND sp.email != ''";
- //$sql.= " AND sp.entity IN (".getEntity('societe').")";
+ //$sql.= " AND sp.entity IN (".getEntity('socpeople').")";
$sql.= " AND cs.fk_categorie = c.rowid";
$sql.= " AND cs.fk_socpeople = sp.rowid";
$sql.= " GROUP BY c.label";
@@ -236,7 +236,7 @@ class mailing_contacts1 extends MailingTargets
$sql.= " WHERE sp.statut = 1"; // Note that null != '' is false
//$sql.= " AND sp.no_email = 0";
//$sql.= " AND sp.email != ''";
- //$sql.= " AND sp.entity IN (".getEntity('societe').")";
+ //$sql.= " AND sp.entity IN (".getEntity('socpeople').")";
$sql.= " AND cs.fk_categorie = c.rowid";
$sql.= " AND cs.fk_soc = sp.fk_soc";
$sql.= " GROUP BY c.label";
@@ -278,7 +278,7 @@ class mailing_contacts1 extends MailingTargets
$sql.= " WHERE sp.statut = 1"; // Note that null != '' is false
//$sql.= " AND sp.no_email = 0";
//$sql.= " AND sp.email != ''";
- //$sql.= " AND sp.entity IN (".getEntity('societe').")";
+ //$sql.= " AND sp.entity IN (".getEntity('socpeople').")";
$sql.= " AND cs.fk_categorie = c.rowid";
$sql.= " AND cs.fk_soc = sp.fk_soc";
$sql.= " GROUP BY c.label";
@@ -374,7 +374,7 @@ class mailing_contacts1 extends MailingTargets
if ($filter_category_customer <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as c2s";
if ($filter_category_supplier <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie as c3";
if ($filter_category_supplier <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie_fournisseur as c3s";
- $sql.= " WHERE sp.entity IN (".getEntity('societe').")";
+ $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")";
$sql.= " AND sp.email <> ''";
$sql.= " AND sp.no_email = 0";
$sql.= " AND sp.statut = 1";
diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php
index 711e2ead71c..8df1bb4a8bb 100644
--- a/htdocs/core/modules/modSociete.class.php
+++ b/htdocs/core/modules/modSociete.class.php
@@ -322,7 +322,7 @@ class modSociete extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
- $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('societe').')';
+ $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('socpeople').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) {
$this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' ';
if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 0ae72b8f96d..b7ee4ee7232 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1704,7 +1704,7 @@ class CommandeFournisseur extends CommonOrder
$this->error='ErrorBadValueForParameterWarehouse';
return -1;
}
- if ($qty <= 0)
+ if ($qty == 0)
{
$this->error='ErrorBadValueForParameterQty';
return -1;
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index dba45be1bc5..c55183921f2 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -243,7 +243,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
$fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2];
// We ask to move a qty
- if (GETPOST($qty) > 0) {
+ if (GETPOST($qty) != 0) {
if (! (GETPOST($ent, 'int') > 0)) {
dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed');
$text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline);
diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php
index 49a7a2a4a5f..9a7fda388d2 100644
--- a/htdocs/modulebuilder/template/myobject_card.php
+++ b/htdocs/modulebuilder/template/myobject_card.php
@@ -120,6 +120,7 @@ if (empty($reshook))
$permissiontoadd = $user->rights->mymodule->write;
$permissiontodelete = $user->rights->mymodule->delete;
+ if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id=__ID__';
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1);
$triggermodname = 'MYMODULE_MODIFY';
diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php
index d8922a94b24..a8b8e7f5479 100644
--- a/htdocs/ticketsup/class/ticketsup.class.php
+++ b/htdocs/ticketsup/class/ticketsup.class.php
@@ -1934,7 +1934,7 @@ class Ticketsup extends CommonObject
// Generation requete recherche
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "socpeople";
- $sql .= " WHERE entity IN (" . getEntity('ticketsup', 1) . ")";
+ $sql .= " WHERE entity IN (" . getEntity('socpeople') . ")";
if (!empty($socid)) {
$sql .= " AND fk_soc='" . $this->db->escape($socid) . "'";
}