}
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'templates/CRM/Batch/Form/Entry.js', 1, 'html-header')
- ->addScriptFile('civicrm', 'templates/CRM/Contribute/Form/PCP.js.tpl', 1, 'html-header')
->addSetting(array('batch' => array('type_id' => $this->_batchInfo['type_id'])))
->addSetting(array('setting' => array('monetaryThousandSeparator' => CRM_Core_Config::singleton()->monetaryThousandSeparator)))
->addSetting(array('setting' => array('monetaryDecimalPoint' => CRM_Core_Config::singleton()->monetaryDecimalPoint)));
$errors["soft_credit_amount[$key]"] = ts('Soft credit amount should not be greater than the total amount');
}
+ // TODO: validate for PCP
+
//membership type is required for membership batch entry
if ($self->_batchInfo['type_id'] == $batchTypes['Membership']) {
if (empty($value['membership_type'][1])) {
}
}
+ // Build PCP params
+ if (!empty($params['pcp_made_through_id'][$key])) {
+ $value['pcp']['pcp_made_through_id'] = $params['pcp_made_through_id'][$key];
+ $value['pcp']['pcp_display_in_roll'] = !empty($params['pcp_display_in_roll'][$key]);
+ if (!empty($params['pcp_roll_nickname'][$key])) {
+ $value['pcp']['pcp_roll_nickname'] = $params['pcp_roll_nickname'][$key];
+ }
+ if (!empty($params['pcp_personal_note'][$key])) {
+ $value['pcp']['pcp_personal_note'] = $params['pcp_personal_note'][$key];
+ }
+ }
+
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($value,
NULL,
'Contribution'
$('#soft_credit_type_'+ rowNum).val($('#sct_default_id').val());
});
+ var pcpURL = CRM.url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1');
+ $('input[name^="pcp_made_through_id"]').each(function() {
+ // Figure out the name of the corresponding pcp_made_through[X] field
+ var thisMadeThroughName = $(this).attr('name').replace('through_id', 'through');
+ $(this).crmSelect2({
+ minimumInputLength: 1,
+ ajax: {
+ url: pcpURL,
+ data: function(term, page) {
+ return {term: term, page_num: page};
+ },
+ results: function(response) {
+ return response;
+ }
+ },
+ initSelection: function(el, callback) {
+ callback({id: $(el).val(), text: $('[name="'+thisMadeThroughName+'"]').val()});
+ }
+ })
+ // This is just a cheap trick to store the name when the form reloads
+ .on('change', function() {
+ var fieldNameVal = $(this).select2('data');
+ if (!fieldNameVal) {
+ fieldNameVal = '';
+ }
+ $('[name="'+thisMadeThroughName+'"]').val(fieldNameVal.text);
+ });
+ })
+
+ $('input[name^="pcp_display_in_roll"]').each(function() {
+ showHidePCPRoll(this);
+ $(this).change(function() {
+ showHidePCPRoll(this);
+ });
+ });
+
+
// validate rows
validateRow();
//set the focus on first element
$('#primary_contact_1').focus();
-
});
-
+function showHidePCPRoll(elem) {
+ CRM.$(function($) {
+ if ($(elem).prop('checked')) {
+ $(elem).parents('.crm-grid-cell').children('.pcp_roll_display').show();
+ }
+ else {
+ $(elem).parents('.crm-grid-cell').children('.pcp_roll_display').hide();
+ }
+ });
+}
function setPaymentBlock(form, memType) {
var rowID = form.closest('div.crm-grid-row').attr('entity_id');
{$form.soft_credit_type.$rowNumber.html}
</div>
{elseif $n eq 'contribution_soft_credit_pcp_id'}
- <div>{$form.pcp_made_through_id.$rowNumber.html}{$form.pcp_made_through.$rowNumber.html}</div>
- <div>{$form.pcp_display_in_roll.$rowNumber.label} {$form.pcp_display_in_roll.$rowNumber.html}</div>
- <div>{$form.pcp_roll_nickname.$rowNumber.label} {$form.pcp_roll_nickname.$rowNumber.html}</div>
- <div>{$form.pcp_personal_note.$rowNumber.label} {$form.pcp_personal_note.$rowNumber.html}</div>
+ <div class="compressed crm-grid-cell">
+ <div>{$form.pcp_made_through_id.$rowNumber.html}{$form.pcp_made_through.$rowNumber.html}</div>
+ <div>{$form.pcp_display_in_roll.$rowNumber.label} {$form.pcp_display_in_roll.$rowNumber.html}</div>
+ <div class="pcp_roll_display">{$form.pcp_roll_nickname.$rowNumber.label} {$form.pcp_roll_nickname.$rowNumber.html}</div>
+ <div class="pcp_roll_display">{$form.pcp_personal_note.$rowNumber.label} {$form.pcp_personal_note.$rowNumber.html}</div>
+ </div>
{elseif in_array( $fields.$n.html_type, array('Radio', 'CheckBox'))}
<div class="compressed crm-grid-cell"> {$form.field.$rowNumber.$n.html}</div>
{elseif $n eq 'total_amount'}