* @static
*
*/
- static function buildOnBehalfForm(&$form,
- $contactType = 'Individual',
- $countryID = NULL,
- $stateID = NULL,
- $title = 'Contact Information',
- $contactEditMode = FALSE,
- $maxLocationBlocks = 1
- ) {
- if ($title == 'Contact Information') {
- $title = ts('Contact Information');
- }
+ static function buildOnBehalfForm(&$form, $contactType, $countryID, $stateID, $title) {
$config = CRM_Core_Config::singleton();
$form->assign('contact_type', $contactType);
$form->assign('fieldSetTitle', $title);
- $form->assign('contactEditMode', $contactEditMode);
+ $form->assign('contactEditMode', TRUE);
$attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
if ($form->_contactId) {
switch ($contactType) {
case 'Organization':
- $session = CRM_Core_Session::singleton();
- $contactID = $session->get('userID');
-
- if ($contactID) {
- $employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID);
- }
-
- $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', 'cid=', FALSE, NULL, FALSE);
- $form->assign('locDataURL', $locDataURL);
-
- if (!$contactEditMode && $contactID && (count($employers) >= 1)) {
-
- $dataURL = CRM_Utils_System::url('civicrm/ajax/employer',
- 'cid=' . $contactID,
- FALSE, NULL, FALSE
- );
- $form->assign('employerDataURL', $dataURL);
-
- $form->add('text', 'organization_id', ts('Select an existing related Organization OR Enter a new one'));
- $form->add('hidden', 'onbehalfof_id', '', array('id' => 'onbehalfof_id'));
- $orgOptions = array('0' => ts('Create new organization'),
- '1' => ts('Select existing organization'),
- );
- $orgOptionExtra = array('onclick' => "showHideByValue('org_option','true','select_org','table-row','radio',true);showHideByValue('org_option','true','create_org','table-row','radio',false);");
- $form->addRadio('org_option', ts('options'), $orgOptions, $orgOptionExtra);
- $form->assign('relatedOrganizationFound', TRUE);
- }
-
$form->add('text', 'organization_name', ts('Organization Name'), $attributes['organization_name'], TRUE);
break;
case 'Household':
- $form->add('text', 'household_name', ts('Household Name'),
- $attributes['household_name']
- );
+ $form->add('text', 'household_name', ts('Household Name'), $attributes['household_name']);
break;
default:
<fieldset><legend></legend>
{/if}
<div class="crm-section organizationName-section">
- {if $relatedOrganizationFound}
- <div class="section crm-section">
- <div class="content">{$form.org_option.html}</div>
- </div>
- <div id="select_org" class="crm-section select_org-section">
- <div class="label">{$form.organization_name.label}</div>
- <div class="content">{$form.organization_id.html|crmAddClass:big}</div>
- </div>
- {/if}
<div id="create_org" class="crm-section create_org-section">
<div class="label">{$form.organization_name.label}</div>
<div class="content">{$form.organization_name.html|crmAddClass:big}</div>
invert = "false"
}
{/if}
-
-{literal}
-<script type="text/javascript">
-{/literal}
-{* If mid present in the url, take the required action (poping up related existing contact ..etc) *}
-{if $membershipContactID}
- {literal}
- cj( function( ) {
- cj( '#organization_id' ).val("{/literal}{$membershipContactName}{literal}");
- cj( '#organization_name' ).val("{/literal}{$membershipContactName}{literal}");
- cj( '#onbehalfof_id' ).val("{/literal}{$membershipContactID}{literal}");
- setLocationDetails( "{/literal}{$membershipContactID}{literal}" );
- });
- {/literal}
-{/if}
-{* Javascript method to populate the location fields when a different existing related contact is selected *}
-{literal}
- var dataUrl = "{/literal}{$employerDataURL}{literal}";
- cj('#organization_id').autocomplete( dataUrl, { width : 180, selectFirst : false, matchContains: true, max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal}
- }).result( function(event, data, formatted) {
- cj('#organization_name').val( data[0] );
- cj('#onbehalfof_id').val( data[1] );
- setLocationDetails( data[1] );
- });
-
- var orgId = {/literal}"{$orgId}"{literal};
- if ( orgId ) {
- setLocationDetails( orgId );
- }
-
- function setLocationDetails( contactID ) {
- var locationUrl = {/literal}"{$locDataURL}"{literal}+ contactID + "&relContact=1";
-
- cj.ajax({
- url : locationUrl,
- dataType : "json",
- timeout : 5000, //Time in milliseconds
- success : function( data, status ) {
- for (var ele in data) {
- cj( "#"+ele ).val( data[ele] );
- }
- },
- error : function( XMLHttpRequest, textStatus, errorThrown ) {
- console.error("HTTP error status: ", textStatus);
- }
- });
- }
-</script>
-{/literal}