CRM-13964-qa : includes 1st QA cycle fixes mentioned in issue comment
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Mon, 3 Mar 2014 21:08:35 +0000 (02:38 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Mon, 3 Mar 2014 21:08:35 +0000 (02:38 +0530)
CRM/Contribute/Form/AdditionalPayment.php
CRM/Contribute/Page/PaymentInfo.php
CRM/Contribute/xml/Menu/Contribute.xml
CRM/Event/Form/Participant.php
CRM/Event/Selector/Search.php
CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl
templates/CRM/Contribute/Form/AdditionalPayment.tpl
templates/CRM/Contribute/Page/PaymentInfo.tpl
templates/CRM/Event/Form/Participant.tpl
xml/templates/message_templates/event_offline_receipt_html.tpl
xml/templates/message_templates/event_offline_receipt_text.tpl

index 6fb22dfee176b3c5f9d81f01ac16b1f8074aa6af..99cd84998127fbcf4e26651659e3ffcfd19460c6 100644 (file)
@@ -74,11 +74,26 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
 
   protected $_fromEmails = NULL;
 
+  protected $_view = NULL;
+
+  public $_action = NULL;
+
   public function preProcess() {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
+    $this->_view = CRM_Utils_Request::retrieve('view', 'String', $this, FALSE);
+    $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
+    $this->assign('component', $this->_component);
+    $this->assign('id', $this->_id);
 
+    if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) {
+      $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, TRUE);
+      $transactionRows = $paymentInfo['transaction'];
+      $this->assign('transaction', TRUE);
+      $this->assign('rows', $transactionRows);
+      return;
+    }
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
 
@@ -126,8 +141,6 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
 
     $this->assign('contributionMode', $this->_mode);
     $this->assign('contactId', $this->_contactId);
-    $this->assign('component', $this->_component);
-    $this->assign('id', $this->_id);
     $this->assign('paymentType', $this->_paymentType);
     $this->assign('paymentAmt', abs($paymentAmt));
 
@@ -140,6 +153,9 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
   }
 
   public function setDefaultValues() {
+    if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) {
+      return;
+    }
     if ($this->_mode) {
       $defaults = $this->_values;
 
@@ -165,6 +181,18 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
   }
 
   public function buildQuickForm() {
+    if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) {
+      $this->addButtons(array(
+          array(
+            'type' => 'cancel',
+            'name' => ts('Done'),
+            'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
+            'isDefault' => TRUE,
+          ),
+        )
+      );
+      return;
+    }
     $ccPane = NULL;
     if ($this->_mode) {
       if (CRM_Utils_Array::value('payment_type', $this->_processors) & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT
index ccf502e332f32a0400c3b7bdf810c72ef10d09c6..fe8ce148aaf32427ad32cf88c5c1ee45e7133884 100644 (file)
@@ -52,10 +52,6 @@ class CRM_Contribute_Page_PaymentInfo extends CRM_Core_Page {
     if ($this->_context == 'payment_info') {
       $this->assign('paymentInfo', $paymentInfo);
     }
-    else {
-      $rows = CRM_Utils_Array::value('transaction', $paymentInfo);
-      $this->assign('rows', $rows);
-    }
   }
 
   function run() {
index d95d5ad9b43d0daa8646b7225f82ffaa55994594..522f6ca56b3e02d3a3cbbc537524a364119751a9 100644 (file)
     <weight>580</weight>
   </item>
   <item>
-    <path>civicrm/payment/add</path>
+    <path>civicrm/payment</path>
     <title>New Payment</title>
     <page_callback>CRM_Contribute_Form_AdditionalPayment</page_callback>
     <path_arguments>action=add</path_arguments>
index d7424165a91968233c6542669345c9af68beede7..0d474fad715e172b5884ee8f725bf4cb77111953 100644 (file)
@@ -452,7 +452,6 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task {
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
     $roleIds = CRM_Event_PseudoConstant::participantRole();
-
     if (!empty($roleIds)) {
       $query = "
 SELECT civicrm_custom_group.name as name,
@@ -669,7 +668,7 @@ SELECT civicrm_custom_group.name as name,
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
     $participantStatuses = CRM_Event_PseudoConstant::participantStatus();
     $partiallyPaidStatusId = array_search('Partially paid', $participantStatuses);
-    CRM_Core_Resources::singleton()->addSetting(array('partiallyPaidStatusId' => $partiallyPaidStatusId));
+    $this->assign('partiallyPaidStatusId', $partiallyPaidStatusId);
 
     if ($this->_showFeeBlock) {
       return CRM_Event_Form_EventFees::buildQuickForm($this);
@@ -842,7 +841,20 @@ SELECT civicrm_custom_group.name as name,
     $this->assign('notificationStatusIds', $notificationStatusIds);
 
     $this->_participantStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
-    $this->addSelect('status_id', $checkCancelledJs, TRUE);
+    $participantStatuses = $this->addSelect('status_id', $checkCancelledJs, TRUE);
+    $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME,
+      'enable_cart'
+    );
+    $pendingInCartStatusId  = CRM_Utils_Array::key( "Pending in cart" , $this->_participantStatuses );
+    if (!$enableCart) {
+      $statusOptions = & $participantStatuses->_options;
+      foreach($statusOptions as $key =>$option){
+        $status_id = $option['attr']['value'];
+        if ($status_id == $pendingInCartStatusId) {
+          unset($statusOptions[$key]);
+        }
+      }
+    }
 
     $this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL);
 
@@ -1538,7 +1550,11 @@ SELECT civicrm_custom_group.name as name,
         }
 
         $this->assign('totalAmount', $contributionParams['total_amount']);
-
+        if (isset($contributionParams['partial_payment_total'])) {
+          // balance amount
+          $balanceAmount = $contributionParams['partial_payment_total'] - $contributionParams['partial_amount_pay'];
+          $this->assign('balanceAmount', $balanceAmount );
+        }
         $this->assign('isPrimary', 1);
         $this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
       }
index 5358eec110503cdb35eb10abe6cf9962b4285661..b72be682fa346154b479aeb397cca966c0cf05e8 100644 (file)
@@ -365,7 +365,7 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
       if ($statusTypes[$row['participant_status_id']] == 'Partially paid') {
         $links[CRM_Core_Action::ADD] = array(
           'name' => ts('Record Payment'),
-          'url' => 'civicrm/payment/add',
+          'url' => 'civicrm/payment',
           'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event',
           'title' => ts('Record Payment'),
         );
@@ -374,7 +374,7 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
       if ($statusTypes[$row['participant_status_id']] == 'Pending refund') {
         $links[CRM_Core_Action::ADD] = array(
           'name' => ts('Record Refund'),
-          'url' => 'civicrm/payment/add',
+          'url' => 'civicrm/payment',
           'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event',
           'title' => ts('Record Refund'),
         );
index d46a279aa477f50ac6cd154a5eb230698e0b3f95..07553db60b979da789ea147c272e5e0b506355a5 100644 (file)
@@ -15,6 +15,7 @@
   UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
 {/foreach}
 
+{php}
   $ovNames = array(
     'contribution' => array(
       'payment_or_refund_notification' => ts('Additional Payment Receipt or Refund Notification',             array('escape' => 'sql')),
index d141b9512aa4e1d8f5bb1aabee96fbf56a38674c..fc97db16c6b25c5183c8728e305c5d9837e06637 100644 (file)
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-{if $formType}
+{if $transaction}
+ <div class="crm-submit-buttons">
+    {include file="CRM/common/formButtons.tpl"}
+ </div>
+  {if !empty($rows)}
+   <table id='info'>
+     <tr class="columnheader">
+       <th>{ts}Amount{/ts}</th>
+       <th>{ts}Type{/ts}</th>
+       <th>{ts}Paid By{/ts}</th>
+       <th>{ts}Received{/ts}</th>
+       <th>{ts}Transaction ID{/ts}</th>
+       <th>{ts}Status{/ts}</th>
+     </tr>
+     {foreach from=$rows item=row}
+     <tr>
+       <td>{$row.total_amount|crmMoney}</td>
+       <td>{$row.financial_type}</td>
+       <td>{$row.payment_instrument}</td>
+       <td>{$row.receive_date|crmDate}</td>
+       <td>{$row.trxn_id}</td>
+       <td>{$row.status}</td>
+     </tr>
+     {/foreach}
+    <table>
+  {else}
+     {if $component eq 'event'}
+       {assign var='entity' value='participant'}
+     {else}
+       {assign var='entity' value=$component}
+     {/if}
+    {ts 1=$entity}No additional payments found for this %1 record{/ts}
+  {/if}
+{elseif $formType}
   {include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"}
 {else}
 
index d770cfe7ce9632f632278f4ed208bc9d2950b357..c388efeab121d1e0564ebdf5ee94ef2efca80122 100644 (file)
@@ -54,7 +54,7 @@ cj(function($){
     <td>{$paymentInfo.total|crmMoney}</td>
     <td class='right'>
       {if $paymentInfo.paid > 0}
-        <a class='action-item' href='{crmURL p="civicrm/payment/view" q="action=browse&cid=`$cid`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&context=transaction"}'>{$paymentInfo.paid|crmMoney}<br/>>> view payments</a>
+        <a class='action-item' href='{crmURL p="civicrm/payment" q="view=transaction&cid=`$cid`&id=`$paymentInfo.id`&component=`$paymentInfo.component`&action=browse"}'>{$paymentInfo.paid|crmMoney}<br/>>> view payments</a>
       {/if}
     </td>
     <td class='right'>{$paymentInfo.balance|crmMoney}</td>
@@ -66,36 +66,6 @@ cj(function($){
   {elseif $paymentInfo.balance < 0}
      {assign var=paymentButtonName value='Record Refund'}
   {/if}
-  <a class="button" href='{crmURL p="civicrm/payment/add" q="reset=1&component=`$component`&id=`$id`&cid=`$cid`"}' title="{ts}{$paymentButtonName}{/ts}"><span><div class="icon add-icon"></div> {ts}{$paymentButtonName}{/ts}</span></a>
+  <a class="button" href='{crmURL p="civicrm/payment" q="action=add&reset=1&component=`$component`&id=`$id`&cid=`$cid`"}' title="{ts}{$paymentButtonName}{/ts}"><span><div class="icon add-icon"></div> {ts}{$paymentButtonName}{/ts}</span></a>
 {/if}
-{elseif $context eq 'transaction'}
-  {if !empty($rows)}
-   <table id='info'>
-     <tr class="columnheader">
-       <th>{ts}Amount{/ts}</th>
-       <th>{ts}Type{/ts}</th>
-       <th>{ts}Paid By{/ts}</th>
-       <th>{ts}Received{/ts}</th>
-       <th>{ts}Transaction ID{/ts}</th>
-       <th>{ts}Status{/ts}</th>
-     </tr>
-     {foreach from=$rows item=row}
-     <tr>
-       <td>{$row.total_amount|crmMoney}</td>
-       <td>{$row.financial_type}</td>
-       <td>{$row.payment_instrument}</td>
-       <td>{$row.receive_date|crmDate}</td>
-       <td>{$row.trxn_id}</td>
-       <td>{$row.status}</td>
-     </tr>
-     {/foreach}
-    <table>
-  {else}
-     {if $component eq 'event'}
-       {assign var='entity' value='participant'}
-     {else}
-       {assign var='entity' value=$component}
-     {/if}
-    {ts 1=$entity}No additional payments found for this %1 record{/ts}
-  {/if}
 {/if}
\ No newline at end of file
index 743c67c4554aaa465b3a2115389cdcbb69858b71..0068c32b09f923f0123247fe56c922417d105139 100644 (file)
 
   // change the status to default 'partially paid' for partial payments
   var feeAmount, userModifiedAmount;
+  var partiallyPaidStatusId = {/literal}{$partiallyPaidStatusId}{literal};
 
   cj('#total_amount')
    .focus(
       userModifiedAmount = cj(this).val();
       userModifiedAmount = parseInt(userModifiedAmount);
       if (userModifiedAmount < feeAmount) {
-        cj('#status_id').val(CRM.partiallyPaidStatusId);
+        cj('#status_id').select2('val', partiallyPaidStatusId);
       }
     }
   );
 
-  cj('#Participant').submit(
+  cj('#Participant').on("click",'.validate',
     function(e) {
       var userSubmittedStatus = cj('#status_id').val();
       var statusLabel = cj('#status_id option:selected').text();
-      if (userModifiedAmount < feeAmount && userSubmittedStatus != CRM.partiallyPaidStatusId) {
-        var result = confirm('Payment amount is less than the amount owed. Expected participant status is \'Partially paid\'. Are you sure you want to set the participant status to ' + statusLabel + '? Click OK to continue, Cancel to change your entries.');
+      if (userModifiedAmount < feeAmount && userSubmittedStatus != partiallyPaidStatusId) {
+        var msg = "{/literal}{ts escape="js" 1="%1"}Payment amount is less than the amount owed. Expected participant status is 'Partially paid'. Are you sure you want to set the participant status to %1? Click OK to continue, Cancel to change your entries.{/ts}{literal}";
+        var result = confirm(ts(msg, {1: statusLabel}));
         if (result == false) {
-          e.preventDefault();
+          return false;
         }
       }
     }
         }
 
         var roleGroupMapper = {/literal}{$participantRoleIds|@json_encode}{literal};
-
         function showCustomData( type, subType, subName ) {
           var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q='snippet=4&type='}"{literal} + type;
           var roleid = "role_id_"+subType;
           var loadData = false;
 
           if ( document.getElementById( roleid ).checked == true ) {
-            if ( roleGroupMapper[subType] ) {
+            if ( typeof roleGroupMapper !== 'undefined' && roleGroupMapper[subType] ) {
               var splitGroup = roleGroupMapper[subType].split(",");
               for ( i = 0; i < splitGroup.length; i++ ) {
                 var roleCustomGroupId = splitGroup[i];
index d26a95bf4c24a6d8a8df1b42e544585c3f463c85..5dc686c2f4233af90ae7c35ca8f0d30ddbf37ab7 100644 (file)
@@ -220,12 +220,26 @@ registration process.{/ts}</p>
       {if $isPrimary}
        <tr>
         <td {$labelStyle}>
-         {ts}Total Amount{/ts}
+        {if $balanceAmount}
+           {ts}Total Paid{/ts}
+        {else}
+           {ts}Total Amount{/ts}
+         {/if}
         </td>
         <td {$valueStyle}>
          {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
         </td>
        </tr>
+      {if $balanceAmount}
+       <tr>
+        <td {$labelStyle}>
+         {ts}Balance{/ts}
+        </td>
+        <td {$valueStyle}>
+         {$balanceAmount|crmMoney}
+        </td>
+       </tr>
+      {/if}
        {if $pricesetFieldsCount }
      <tr>
        <td {$labelStyle}>
index 02985ca010ddb1349e68a8bddccebb194c9dec87..8a51a9e85f4e3300e4826c756947bb81ff52661c 100644 (file)
@@ -131,9 +131,13 @@ registration process.{/ts}
 {foreach from=$amount item=amnt key=level}{$amnt.amount|crmMoney} {$amnt.label}
 {/foreach}
 {/if}
-{if $isPrimary }
+{if $isPrimary}
+
+{if $balanceAmount}{ts}Total Paid{/ts}{else}{ts}Total Amount{/ts}{/if}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
 
-{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
+{if $balanceAmount}
+{ts}Balance{/ts}: {$balanceAmount|crmMoney}
+{/if}
 
 {if $pricesetFieldsCount }
       {assign var="count" value= 0}