From 9fa00ed176043c6cbed0e4875eb6a0407ed54ca4 Mon Sep 17 00:00:00 2001 From: moremanish Date: Wed, 3 Dec 2014 12:32:32 +0530 Subject: [PATCH] QA fixes --- CRM/Batch/BAO/Batch.php | 6 +- CRM/Batch/Form/Batch.php | 3 - CRM/Pledge/BAO/PledgePayment.php | 3 +- CRM/Pledge/Page/AJAX.php | 23 +----- .../Incremental/sql/4.6.alpha1.mysql.tpl | 5 +- templates/CRM/Batch/Form/Entry.js | 71 ---------------- templates/CRM/Batch/Form/Entry.tpl | 80 ++++++++++++++----- 7 files changed, 71 insertions(+), 120 deletions(-) mode change 100644 => 100755 CRM/Batch/BAO/Batch.php mode change 100644 => 100755 CRM/Batch/Form/Batch.php mode change 100644 => 100755 CRM/Pledge/Page/AJAX.php mode change 100644 => 100755 CRM/Upgrade/Incremental/sql/4.6.alpha1.mysql.tpl mode change 100644 => 100755 templates/CRM/Batch/Form/Entry.js mode change 100644 => 100755 templates/CRM/Batch/Form/Entry.tpl diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php old mode 100644 new mode 100755 index a84b889026..59a0ed3beb --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -106,7 +106,8 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { //retrieve the profile specific to batch type switch ($batchTypeId) { case 1: - //batch profile used for contribution + case 3: + //batch profile used for pledges $profileName = "contribution_batch_entry"; break; @@ -114,9 +115,6 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { //batch profile used for memberships $profileName = "membership_batch_entry"; break; - default: - //batch profile used for pledges - $profileName = "contribution_batch_entry"; } // get and return the profile id diff --git a/CRM/Batch/Form/Batch.php b/CRM/Batch/Form/Batch.php old mode 100644 new mode 100755 index 035c472f66..1ba9b10bcb --- a/CRM/Batch/Form/Batch.php +++ b/CRM/Batch/Form/Batch.php @@ -65,9 +65,6 @@ class CRM_Batch_Form_Batch extends CRM_Admin_Form { $batchTypes = CRM_Batch_BAO_Batch::buildOptions('type_id'); - // unset non-related types - //unset($batchTypes[3]); - //unset($batchTypes[4]); $type = $this->add('select', 'type_id', ts('Type'), $batchTypes); if ($this->_action & CRM_Core_Action::UPDATE) { diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index 53a8064313..77a9c88294 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -694,7 +694,7 @@ WHERE civicrm_pledge_payment.id = {$paymentId} $statusClause = " IN (" . implode(',', $status) . ")"; $query = " -SELECT civicrm_pledge_payment.id id, civicrm_pledge_payment.scheduled_amount amount, civicrm_pledge_payment.currency +SELECT civicrm_pledge_payment.id id, civicrm_pledge_payment.scheduled_amount amount, civicrm_pledge_payment.currency, civicrm_pledge_payment.scheduled_date FROM civicrm_pledge, civicrm_pledge_payment WHERE civicrm_pledge.id = civicrm_pledge_payment.pledge_id AND civicrm_pledge_payment.status_id {$statusClause} @@ -713,6 +713,7 @@ LIMIT 0, %2 'id' => $payment->id, 'amount' => $payment->amount, 'currency' => $payment->currency, + 'schedule_date' => $payment->scheduled_date, 'count' => $count, ); $count++; diff --git a/CRM/Pledge/Page/AJAX.php b/CRM/Pledge/Page/AJAX.php old mode 100644 new mode 100755 index cb8ae8906e..59de5ef66c --- a/CRM/Pledge/Page/AJAX.php +++ b/CRM/Pledge/Page/AJAX.php @@ -90,26 +90,9 @@ WHERE {$whereClause} * Function to setDefaults according to Pledge Id * for batch entry pledges */ - function getPledgeDefaults($config) { - if (!$_POST['mtype']) { - $details['scheduled_amount'] = ''; - echo json_encode($details); - CRM_Utils_System::civiExit(); - } - $memType = CRM_Utils_Type::escape($_POST['mtype'], 'Integer'); - $query = "SELECT min(id),scheduled_amount - FROM civicrm_pledge_payment - WHERE pledge_id = %1 and status_id != 1"; - $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($memType, 'Positive'))); - $properties = array( 'scheduled_amount'); - while ($dao->fetch()) { - foreach ($properties as $property) { - $details[$property] = $dao->$property; - } - } - $details['total_amount_numeric'] = $details['total_amount']; - // fix the display of the monetary value, CRM-4038 - $details['scheduled_amount'] = CRM_Utils_Money::format($details['scheduled_amount'], NULL, '%a'); + function getPledgeDefaults() { + $pledgeID = CRM_Utils_Type::escape($_POST['pid'], 'Integer'); + $details = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID); echo json_encode($details); CRM_Utils_System::civiExit(); } diff --git a/CRM/Upgrade/Incremental/sql/4.6.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.6.alpha1.mysql.tpl old mode 100644 new mode 100755 index f474c5af2f..61c3a09cfe --- a/CRM/Upgrade/Incremental/sql/4.6.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.6.alpha1.mysql.tpl @@ -74,5 +74,6 @@ SELECT @option_group_id := id FROM civicrm_option_group WHERE name = 'batch_type SELECT @max_option_value:= max(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id; -INSERT INTO civicrm_option_value(option_group_id, {localize field='label'}`label`{/localize}, value, name) -VALUES (@option_group_id, {localize}'{ts escape="sql"}Pledge{/ts}'{/localize}, @max_option_value+1, 'Pledge'); \ No newline at end of file +INSERT INTO civicrm_option_value(option_group_id, {localize field='label'}`label`{/localize}, value, name,weight) +VALUES (@option_group_id, {localize}'{ts escape="sql"}Pledge{/ts}'{/localize}, @max_option_value+1, 'Pledge','3'); + diff --git a/templates/CRM/Batch/Form/Entry.js b/templates/CRM/Batch/Form/Entry.js old mode 100644 new mode 100755 index 149b448e5e..f75467c97e --- a/templates/CRM/Batch/Form/Entry.js +++ b/templates/CRM/Batch/Form/Entry.js @@ -57,7 +57,6 @@ CRM.$(function($) { $('select[id*="_membership_type_0"]').change(function () { setPaymentBlock($(this), null); }); - $('select[id*="_membership_type_1"]').change(function () { setPaymentBlock($(this), $(this).val()); }); @@ -74,76 +73,6 @@ CRM.$(function($) { }); -function updateContactInfo(blockNo, prefix) { - var contactHiddenElement = 'input[name="' + prefix + 'contact_select_id[' + blockNo + ']"]'; - var contactId = cj(contactHiddenElement).val(); - - var profileFields = CRM.contact.fieldmap; - - CRM.api('Contact', 'get', { - 'sequential': '1', - 'contact_id': contactId, - 'return': CRM.contact.return }, - { success: function (data) { - cj.each(data.values[0], function (key, value) { - // set the values - var actualFldName = profileFields[key]; - if (key == 'country' || key == 'state_province') { - idFldName = key + '_id'; - value = data.values[0][idFldName]; - } - setFieldValue(actualFldName, value, blockNo) - }); - - // for membership batch entry based on contact we need to enable / disable - // add membership select - if(CRM.batch.type_id == 2) { - CRM.api('Membership', 'get', { - 'sequential': '1', - 'contact_id': contactId - }, - { success: function (data) { - if (data.count > 0) { - //get the information on membership type - var membershipTypeId = data.values[0].membership_type_id; - var membershipJoinDate = data.values[0].join_date; - CRM.api('MembershipType', 'get', { - 'sequential': '1', - 'id': membershipTypeId - }, - { success: function (data) { - var memTypeContactId = data.values[0].member_of_contact_id; - cj('select[id="member_option_' + blockNo + '"]').prop('disabled', false).val(2); - cj('select[id="field_' + blockNo + '_membership_type_0"]').val(memTypeContactId).change(); - cj('select[id="field_' + blockNo + '_membership_type_1"]').val(membershipTypeId).change(); - setDateFieldValue('join_date', membershipJoinDate, blockNo) - } - }); - } - } - }); - } - if (CRM.batch.type_id == 3) { - CRM.api('Pledge', 'get', { - 'q': 'civicrm/ajax/rest', - 'sequential': 1, - 'contact_id': contactId - }, - {success: function(data) { - cj.each(data['values'], function(key, value) { - if (value['pledge_status']!='Completed'){ - cj('#open_pledges_'+ blockNo).append(cj('