Commit 27f44980 authored by jaapjansma's avatar jaapjansma

fixed issue with create/update relationship

parent a56a19aa
......@@ -54,7 +54,7 @@ class FindIndividualByNameAndEmail extends AbstractAction {
WHERE contact.is_deleted = 0 AND contact.is_deceased = 0 AND contact.contact_type = 'Individual'
AND contact.first_name = %2 AND contact.last_name = %3
ORDER BY weight
ORDER BY weight ASC
";
$sqlParams[1] = array($parameters->getParameter('email'), 'String');
......
......@@ -76,19 +76,21 @@ class CreateOrUpdateRelationship extends CreateRelationship {
* @throws \Exception
*/
protected function doAction(ParameterBagInterface $parameters, ParameterBagInterface $output) {
$relationship_type_id = $this->relationshipTypeIds[$this->configuration->getParameter('relationship_type_id')];
$relationship_id = false;
$alsoUpdateInactiveOne = false;
if ($this->configuration->doesParameterExists('also_update_inactive') && $this->configuration->getParameter('also_update_inactive')) {
$alsoUpdateInactiveOne = true;
}
$relationship_id = $this->findExistingRelationshipId($parameters->getParameter('contact_id_a'), $parameters->getParameter('contact_id_b'), $this->relationshipTypes[$parameters->getParameter('relationship_type_id')], $alsoUpdateInactiveOne);
$relationship_id = $this->findExistingRelationshipId($parameters->getParameter('contact_id_a'), $parameters->getParameter('contact_id_b'), $relationship_type_id, $alsoUpdateInactiveOne);
if ($relationship_id) {
$relationshipParams['id'] = $relationship_id;
}
// Get the contact and the event.
$relationshipParams['contact_id_a'] = $parameters->getParameter('contact_id_a');
$relationshipParams['contact_id_b'] = $parameters->getParameter('contact_id_b');
$relationshipParams['relationship_type_id'] = $this->relationshipTypeIds[$this->configuration->getParameter('relationship_type_id')];
$relationshipParams['relationship_type_id'] = $relationship_type_id;
$relationshipParams['is_active'] = '1';
if ($this->configuration->getParameter('set_start_date') && !$relationship_id) {
$today = new \DateTime();
......@@ -97,7 +99,6 @@ class CreateOrUpdateRelationship extends CreateRelationship {
if ($relationship_id) {
$relationshipParams['end_date'] = 'null';
}
$relationshipParams['custom'] = array();
foreach($this->getParameterSpecification() as $spec) {
if (stripos($spec->getName(), 'custom_')!==0) {
......@@ -119,6 +120,7 @@ class CreateOrUpdateRelationship extends CreateRelationship {
$output->setParameter('id', $relationship->id);
} catch (\Exception $e) {
// Do nothing.
echo $e;
}
}
......
......@@ -163,7 +163,7 @@ class GetRelationship extends AbstractAction {
$relationshipFindParams['is_active'] = '0';
try {
$relationship = civicrm_api3('Relationship', 'getsingle', $relationshipFindParams);
$relationship;
return $relationship;
} catch (\Exception $e) {
// Do nothing
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment