Fix: wrong entity with multicompany thirdparty sharing

This commit is contained in:
Regis Houssin 2018-01-10 12:38:12 +01:00
parent e5c26f89e7
commit bd1acca2cd
2 changed files with 69 additions and 65 deletions

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
@ -174,6 +174,7 @@ if (empty($reshook))
if ($canvas) $object->canvas=$canvas; if ($canvas) $object->canvas=$canvas;
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
$object->socid = GETPOST("socid",'int'); $object->socid = GETPOST("socid",'int');
$object->lastname = GETPOST("lastname"); $object->lastname = GETPOST("lastname");
$object->firstname = GETPOST("firstname"); $object->firstname = GETPOST("firstname");
@ -531,12 +532,14 @@ else
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if (! empty($objsoc)) {
print '<input type="hidden" name="entity" value="'.$objsoc->entity.'">';
}
dol_fiche_head($head, 'card', '', 0, ''); dol_fiche_head($head, 'card', '', 0, '');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Name // Name
print '<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</label></td>'; print '<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</label></td>';
print '<td><input name="lastname" id="lastname" type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(GETPOST("lastname")?GETPOST("lastname"):$object->lastname).'" autofocus="autofocus"></td>'; print '<td><input name="lastname" id="lastname" type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(GETPOST("lastname")?GETPOST("lastname"):$object->lastname).'" autofocus="autofocus"></td>';
@ -673,7 +676,7 @@ else
} }
// Other attributes // Other attributes
$parameters=array('colspan' => ' colspan="3"','cols'=>3); $parameters=array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) if (empty($reshook) && ! empty($extrafields->attribute_label))

View File

@ -187,7 +187,7 @@ class Contact extends CommonObject
$sql.= ", statut"; $sql.= ", statut";
$sql.= ", canvas"; $sql.= ", canvas";
$sql.= ", entity"; $sql.= ", entity";
$sql.= ",ref_ext"; $sql.= ", ref_ext";
$sql.= ", import_key"; $sql.= ", import_key";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'".$this->db->idate($now)."',"; $sql.= "'".$this->db->idate($now)."',";
@ -199,7 +199,7 @@ class Contact extends CommonObject
$sql.= " ".$this->priv.","; $sql.= " ".$this->priv.",";
$sql.= " ".$this->statut.","; $sql.= " ".$this->statut.",";
$sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").",";
$sql.= " ".$conf->entity.","; $sql.= " ".$this->entity.",";
$sql.= "'".$this->db->escape($this->ref_ext)."',"; $sql.= "'".$this->db->escape($this->ref_ext)."',";
$sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null");
$sql.= ")"; $sql.= ")";
@ -642,7 +642,7 @@ class Contact extends CommonObject
$langs->load("companies"); $langs->load("companies");
$sql = "SELECT c.rowid, c.fk_soc, c.ref_ext, c.civility as civility_id, c.lastname, c.firstname,"; $sql = "SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_id, c.lastname, c.firstname,";
$sql.= " c.address, c.statut, c.zip, c.town,"; $sql.= " c.address, c.statut, c.zip, c.town,";
$sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_pays as country_id,";
$sql.= " c.fk_departement,"; $sql.= " c.fk_departement,";
@ -671,6 +671,7 @@ class Contact extends CommonObject
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->entity = $obj->entity;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->ref_ext = $obj->ref_ext; $this->ref_ext = $obj->ref_ext;
$this->civility_id = $obj->civility_id; $this->civility_id = $obj->civility_id;