Merge remote-tracking branch 'upstream/4.4' into 4.4-4.5-2014-09-08-20-42-29
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution / OnBehalfOf.tpl
index 1ea2da371214f178b01781d54ba80999d8ded00e..b9181ecc6d37559725c9431269fd469cd81ba837 100644 (file)
               {if $form.onbehalf.$phone_ext_field.html}
                  {$form.onbehalf.$phone_ext_field.html}
               {/if}
+            {/if} 
+           {if $onBehalfOfFields.$fieldName.data_type eq 'Date'}
+            {assign var=elementName value=onbehalf[$fieldName]}
+              {include file="CRM/common/jcalendar.tpl" elementName=$elementName elementId=onbehalf_$fieldName}
             {/if}
             {if $onBehalfOfFields.$fieldName.help_post}
               <br /><span class='description'>{$onBehalfOfFields.$fieldName.help_post}</span>
@@ -194,7 +198,17 @@ function setOrgName( ) {
 }
 
 
-function setLocationDetails(contactID) {
+function setLocationDetails(contactID , reset) {
+  var submittedCID = {/literal}"{$submittedOnBehalf}"{literal};
+  var submittedOnBehalfInfo = {/literal}'{$submittedOnBehalfInfo}'{literal};
+  submittedOnBehalfInfo = cj.parseJSON(submittedOnBehalfInfo);
+  if (submittedCID == contactID) {
+    cj.each(submittedOnBehalfInfo, function(key, value) {
+      cj('#onbehalf_' + key ).val(value);
+    });
+    return;
+  }
+
   resetValues();
   var locationUrl = {/literal}"{$locDataURL}"{literal} + contactID + "&ufId=" + {/literal}"{$profileId}"{literal};
   cj.ajax({
@@ -257,7 +271,7 @@ cj('#onbehalfof_id').change(function() {
 function selectCreateOrg( orgOption, reset ) {
   if (orgOption == 0) {
     cj("#onbehalfof_id").show().change();
-    cj("input#onbehalf_organization_name").hide()
+    cj("input#onbehalf_organization_name").hide();
   }
   else if ( orgOption == 1 ) {
     cj("input#onbehalf_organization_name").show();
@@ -282,9 +296,9 @@ function selectCreateOrg( orgOption, reset ) {
 {if $membershipContactID}
 {literal}
   CRM.$(function($) {
-    cj('#organization_id').val("{/literal}{$membershipContactName}{literal}");
-    cj('#organization_name').val("{/literal}{$membershipContactName}{literal}");
-    cj('#onbehalfof_id').val("{/literal}{$membershipContactID}{literal}");
+    $('#organization_id').val("{/literal}{$membershipContactName}{literal}");
+    $('#organization_name').val("{/literal}{$membershipContactName}{literal}");
+    $('#onbehalfof_id').val("{/literal}{$membershipContactID}{literal}");
     setLocationDetails( "{/literal}{$membershipContactID}{literal}" );
   });
 {/literal}