From aefb0b7989a4004f87e46edde780a26b7a9be496 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 1 Aug 2013 11:49:14 +1200 Subject: [PATCH] CRM-13142 limited tidy up to extract js from tpl using new standards (I have completely tidied up & jslinted it into a new file but discarded after a tidy up was merged in from 4.3 --- CRM/Batch/Form/Entry.php | 2 ++ templates/CRM/Batch/Form/Entry.tpl | 37 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index 36586acd45..8c5efd085b 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -106,6 +106,8 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { // get the profile id associted with this batch type $this->_profileId = CRM_Batch_BAO_Batch::getProfileId($this->_batchInfo['type_id']); } + CRM_Core_Resources::singleton() + ->addSetting(array('batch' => array('type_id' => $this->_batchInfo['type_id']))); } /** diff --git a/templates/CRM/Batch/Form/Entry.tpl b/templates/CRM/Batch/Form/Entry.tpl index d3639aa107..29c8527e05 100644 --- a/templates/CRM/Batch/Form/Entry.tpl +++ b/templates/CRM/Batch/Form/Entry.tpl @@ -106,7 +106,7 @@ cj(function () { cj('.selector-rows').change(function () { var options = { - 'url': {/literal}"{crmURL p='civicrm/ajax/batch' h=0}"{literal} + 'url': CRM.url('civicrm/ajax/batch') }; cj("#Entry").ajaxSubmit(options); @@ -132,21 +132,22 @@ cj(function () { calculateActualTotal(); }); - {/literal}{if $batchType eq 1 }{literal} - // hide all dates if send receipt is checked - hideSendReceipt(); + if (CRM.batch.type_id == 1) { + // hide all dates if send receipt is checked + hideSendReceipt(); - // hide the receipt date if send receipt is checked - cj('input[id*="][send_receipt]"]').change(function () { - showHideReceipt(cj(this)); - }); + // hide the receipt date if send receipt is checked + cj('input[id*="][send_receipt]"]').change(function () { + showHideReceipt(cj(this)); + }); - {/literal}{else}{literal} - cj('select[id^="member_option_"]').each(function () { - if (cj(this).val() == 1) { - cj(this).attr('disabled', true); - } - }); + } + else{ + cj('select[id^="member_option_"]').each(function () { + if (cj(this).val() == 1) { + cj(this).attr('disabled', true); + } + }); // set payment info accord to membership type cj('select[id*="_membership_type_0"]').change(function () { @@ -157,7 +158,7 @@ cj(function () { setPaymentBlock(cj(this), cj(this).val()); }); - {/literal}{/if}{literal} + } // line breaks between radio buttons and checkboxes cj('input.form-radio').next().after('
'); @@ -170,7 +171,7 @@ cj(function () { function setPaymentBlock(form, memType) { var rowID = form.closest('div.crm-grid-row').attr('entity_id'); - var dataUrl = {/literal}"{crmURL p='civicrm/ajax/memType' h=0}"{literal}; + var dataUrl = CRM.url('civicrm/ajax/memType'); if (!memType) { memType = cj('select[id="field_' + rowID + '_membership_type_1"]').val(); @@ -321,7 +322,7 @@ function updateContactInfo(blockNo, prefix) { // for membership batch entry based on contact we need to enable / disable // add membership select - {/literal}{if $batchType eq 2}{literal} + if(CRM.batch.type_id == 2) { CRM.api('Membership', 'get', { 'sequential': '1', 'contact_id': contactId, @@ -346,7 +347,7 @@ function updateContactInfo(blockNo, prefix) { } } }); - {/literal}{/if}{literal} + } } }); } -- 2.25.1