allow the webservice to create a private individual

This commit is contained in:
Cédric Salvador 2013-12-20 17:03:24 +01:00
parent 168412a2d6
commit 18b163c6db
3 changed files with 27 additions and 20 deletions

View File

@ -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, ...)
*

View File

@ -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;
}
}

View File

@ -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++;