Merge pull request #1046 from colemanw/showHide
[civicrm-core.git] / CRM / Contact / BAO / Contact / Utils.php
index 26b03dc2b207e8a5e8c909ef99fae70c61746c21..0dcbb173652c39086e7ceac23e8c33bc4130d854 100644 (file)
@@ -296,7 +296,8 @@ UNION
       }
     }
 
-    if ($organizationId) {
+    $previousEmployerID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'employer_id');
+    if ($organizationId && $organizationId != $previousEmployerID) {
       $cid = array('contact' => $contactID);
 
       // get the relationship type id of "Employee of"
@@ -317,7 +318,6 @@ UNION
 
 
       // In case we change employer, clean prveovious employer related records.
-      $previousEmployerID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'employer_id');
       if ($previousEmployerID &&
         $previousEmployerID != $organizationId
       ) {
@@ -510,11 +510,7 @@ WHERE id={$contactId}; ";
           $form->assign('relatedOrganizationFound', TRUE);
         }
 
-        $isRequired = FALSE;
-        if (CRM_Utils_Array::value('is_for_organization', $form->_values) == 2) {
-          $isRequired = TRUE;
-        }
-        $form->add('text', 'organization_name', ts('Organization Name'), $attributes['organization_name'], $isRequired);
+        $form->add('text', 'organization_name', ts('Organization Name'), $attributes['organization_name'], TRUE);
         break;
 
       case 'Household':
@@ -526,7 +522,7 @@ WHERE id={$contactId}; ";
       default:
         // individual
         $form->addElement('select', 'prefix_id', ts('Prefix'),
-          array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::individualPrefix()
+          array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id')
         );
         $form->addElement('text', 'first_name', ts('First Name'),
           $attributes['first_name']
@@ -538,7 +534,7 @@ WHERE id={$contactId}; ";
           $attributes['last_name']
         );
         $form->addElement('select', 'suffix_id', ts('Suffix'),
-          array('' => ts('- suffix -')) + CRM_Core_PseudoConstant::individualSuffix()
+          array('' => ts('- suffix -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id')
         );
     }