CRM_Utils_System::civiExit();
}
- /**
- * Function to obtain list of permissioned employer for the given contact-id.
- */
- static function getPermissionedEmployer() {
- $cid = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
- $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String'));
- $name = str_replace('*', '%', $name);
-
- $elements = CRM_Contact_BAO_Relationship::getPermissionedEmployer($cid, $name);
-
- if (!empty($elements)) {
- foreach ($elements as $cid => $name) {
- echo $element = $name['name'] . "|$cid\n";
- }
- }
- CRM_Utils_System::civiExit();
- }
-
-
static function groupTree() {
$gids = CRM_Utils_Type::escape($_GET['gids'], 'String');
echo CRM_Contact_BAO_GroupNestingCache::json($gids);
if ($form->_relatedOrganizationFound) {
$locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', 'cid=', FALSE, NULL, FALSE);
$form->assign('locDataURL', $locDataURL);
-
- $dataURL = CRM_Utils_System::url('civicrm/ajax/employer', 'cid=' . $contactID, FALSE, NULL, FALSE);
- $form->assign('employerDataURL', $dataURL);
}
if ($form->_values['is_for_organization'] != 2) {
if ($contactID && count($form->_employers) >= 1) {
$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'));
+ $employers = array();
+ foreach ($form->_employers as $id => $vals) {
+ $employers[$id] = $vals['name'];
+ }
+ $form->add('select', 'onbehalfof_id', 'onbehalfof_id', $employers);
$orgOptions = array(0 => ts('Select an existing organization'),
1 => ts('Enter a new organization'),
<page_callback>CRM_Core_Page_AJAX_Location::getPermissionedLocation</page_callback>
<access_arguments>make online contributions</access_arguments>
</item>
- <item>
- <path>civicrm/ajax/employer</path>
- <page_callback>CRM_Contact_Page_AJAX::getPermissionedEmployer</page_callback>
- <access_arguments>make online contributions</access_arguments>
- </item>
<item>
<path>civicrm/contribute/unsubscribe</path>
<title>Cancel Subscription</title>
{else}
<div class="label">{$form.onbehalf.$fieldName.label}</div>
<div class="content">
- {$form.onbehalf.$fieldName.html}
- {if $fieldName eq 'organization_name'}
- <div id="id-onbehalf-orgname-help" class="description">{ts}Start typing the name of an organization that you have saved previously to use it again. Otherwise click "Enter a new organization" above.{/ts}</div>
+ {if $fieldName eq 'organization_name' and !empty($form.onbehalfof_id)}
+ {$form.onbehalfof_id.html}
{/if}
+ {$form.onbehalf.$fieldName.html}
{if !empty($onBehalfOfFields.$fieldName.html_type) && $onBehalfOfFields.$fieldName.html_type eq 'Autocomplete-Select'}
{assign var=elementName value=onbehalf[$fieldName]}
{include file="CRM/Custom/Form/AutoComplete.tpl" element_name=$elementName}
{if empty($snippet)}
{literal}
<script type="text/javascript">
- cj( "div#id-onbehalf-orgname-help").hide( );
showOnBehalf({/literal}"{$onBehalfRequired}"{literal});
});
}
-var orgOption = '';
cj("input:radio[name='org_option']").click( function( ) {
- orgOption = cj("input:radio[name='org_option']:checked").val( );
+ var orgOption = cj(this).val();
selectCreateOrg(orgOption, true);
});
+cj('#onbehalfof_id').change(function() {
+ setLocationDetails(cj(this).val());
+}).change();
+
function selectCreateOrg( orgOption, reset ) {
if (orgOption == 0) {
- cj("div#id-onbehalf-orgname-help").show( );
- var dataUrl = {/literal}"{$employerDataURL}"{literal};
- cj('#onbehalf_organization_name').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('#onbehalf_organization_name').val( data[0] );
- cj('#onbehalfof_id').val( data[1] );
- setLocationDetails( data[1] );
- });
+ cj("#onbehalfof_id").show().change();
+ cj("input#onbehalf_organization_name").hide()
}
else if ( orgOption == 1 ) {
- cj("input#onbehalf_organization_name").removeClass( 'ac_input' ).unautocomplete( );
- cj("div#id-onbehalf-orgname-help").hide( );
+ cj("input#onbehalf_organization_name").show();
+ cj("#onbehalfof_id").hide();
}
if ( reset ) {