{ $obj = $db->fetch_object($resql); if ($obj && $obj->rowid > 0) { $othermember=new Adherent($db); $othermember->fetch($obj->rowid); $thirdparty=new Societe($db); $thirdparty->fetch($_POST["socid"]); $error++; $errmsg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->nom).'</div>'; } } if (! $error) { $result=$adh->setThirdPartyId($_POST["socid"]); if ($result < 0) dol_print_error($adh->db,$adh->error); $_POST['action']=''; $action=''; } } } } // Create user from a member if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer) { if ($result > 0) { // Creation user $nuser = new User($db);
/** * testAdherentSetThirdPartyId * * @param Adherent $localobject Member instance * @return Adherent * * @depends testAdherentSetUserId * The depends says test is run only if previous is ok */ public function testAdherentSetThirdPartyId(Adherent $localobject) { global $conf, $user, $langs, $db; $conf = $this->savconf; $user = $this->savuser; $langs = $this->savlangs; $db = $this->savdb; //Create a Third Party $thirdparty = new Societe($db); $thirdparty->initAsSpecimen(); $result = $thirdparty->create($user); print __METHOD__ . " id=" . $localobject->id . " third party id=" . $thirdparty->id . " result=" . $result . "\n"; $this->assertTrue($result > 0); //Set Third Party ID $result = $localobject->setThirdPartyId($thirdparty->id); $this->assertEquals($result, 1); print __METHOD__ . " id=" . $localobject->id . " result=" . $result . "\n"; //Adherent is updated with new data $localobject->fetch($localobject->id); $this->assertEquals($localobject->fk_soc, $thirdparty->id); print __METHOD__ . " id=" . $localobject->id . " result=" . $result . "\n"; //We remove the third party association $result = $localobject->setThirdPartyId(0); $this->assertEquals($result, 1); //And check if it has been updated $localobject->fetch($localobject->id); $this->assertNull($localobject->fk_soc); //Now we remove the third party $result = $thirdparty->delete($thirdparty->id, $user); $this->assertEquals($result, 1); return $localobject; }