allow the webservice to create a private individual
This commit is contained in:
parent
168412a2d6
commit
18b163c6db
@ -297,6 +297,25 @@ class Societe extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
function create_individual($user) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
$contact=new Contact($this->db);
|
||||
|
||||
$contact->name = $this->name_bis;
|
||||
$contact->firstname = $this->firstname;
|
||||
$contact->socid = $this->id; // fk_soc
|
||||
$contact->statut = 1;
|
||||
$contact->priv = 0;
|
||||
$result = $contact->create($user);
|
||||
if ($result < 0) {
|
||||
$this->error = $contact->error;
|
||||
$this->errors = $contact->errors;
|
||||
dol_syslog("Societe::create_individual ERROR:" . $this->error, LOG_ERR);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check properties of third party are ok (like name, third party codes, ...)
|
||||
*
|
||||
|
||||
@ -255,28 +255,10 @@ if (empty($reshook))
|
||||
if ($object->particulier)
|
||||
{
|
||||
dol_syslog("This thirdparty is a personal people",LOG_DEBUG);
|
||||
$contact=new Contact($db);
|
||||
|
||||
$contact->civilite_id = $object->civilite_id;
|
||||
$contact->name = $object->name_bis;
|
||||
$contact->firstname = $object->firstname;
|
||||
$contact->address = $object->address;
|
||||
$contact->zip = $object->zip;
|
||||
$contact->town = $object->town;
|
||||
$contact->state_id = $object->state_id;
|
||||
$contact->country_id = $object->country_id;
|
||||
$contact->socid = $object->id; // fk_soc
|
||||
$contact->statut = 1;
|
||||
$contact->email = $object->email;
|
||||
$contact->skype = $object->skype;
|
||||
$contact->phone_pro = $object->phone;
|
||||
$contact->fax = $object->fax;
|
||||
$contact->priv = 0;
|
||||
|
||||
$result=$contact->create($user);
|
||||
$result=$object->create_individual($user);
|
||||
if (! $result >= 0)
|
||||
{
|
||||
$error=$contact->error; $errors=$contact->errors;
|
||||
$error=$object->error; $errors=$object->errors;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -443,6 +443,7 @@ function createThirdParty($authentication,$thirdparty)
|
||||
$newobject->tva_intra=$thirdparty['vat_number'];
|
||||
|
||||
$newobject->canvas=$thirdparty['canvas'];
|
||||
$newobject->particulier=$thirdparty['individual'];
|
||||
|
||||
//Retreive all extrafield for thirdsparty
|
||||
// fetch optionals attributes and labels
|
||||
@ -457,6 +458,11 @@ function createThirdParty($authentication,$thirdparty)
|
||||
$db->begin();
|
||||
|
||||
$result=$newobject->create($fuser);
|
||||
if ($newobject->particulier && $result > 0) {
|
||||
$newobject->firstname = $thirdparty['firstname'];
|
||||
$newobject->name_bis = $thirdparty['ref'];
|
||||
$result = $newobject->create_individual($fuser);
|
||||
}
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user