CRM-13964 : JQUERY part and new status creation
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Fri, 20 Dec 2013 12:30:36 +0000 (18:00 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Thu, 16 Jan 2014 01:43:15 +0000 (07:13 +0530)
CRM/Event/Form/Participant.php
CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl
templates/CRM/Event/Form/Participant.tpl
xml/templates/civicrm_data.tpl

index 51b2359f664f6d6c154f3b999db8bce9da395a0e..4b9eb2184fbd40dbaae448bfad504087dc7bf3ca 100644 (file)
@@ -255,6 +255,10 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task {
     $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
     $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
 
+    $partiallyPaidStatusId = CRM_Event_PseudoConstant::participantStatus();
+    $partiallyPaidStatusId = array_search('Partially paid', $partiallyPaidStatusId);
+    $this->assign('partiallyPaidStatusId', $partiallyPaidStatusId);
+
     if ($this->_mode) {
       $this->assign('participantMode', $this->_mode);
 
index 1faa6c99557c6618ade5ec8159e2c9b513fa2ea1..db9fe0acfdc6ab68bd37d79e8310cc69b43af6be 100644 (file)
@@ -97,4 +97,21 @@ SELECT @caseCompId := id FROM `civicrm_component` where `name` like 'CiviCase';
 
 UPDATE `civicrm_option_value`
 SET is_reserved = 1
-WHERE is_reserved = 0 AND option_group_id = @option_group_id_activity_type AND component_id = @caseCompId;
\ No newline at end of file
+WHERE is_reserved = 0 AND option_group_id = @option_group_id_activity_type AND component_id = @caseCompId;
+
+-- CRM-13964
+SELECT @option_group_id_cs   := max(id) from civicrm_option_group where name = 'contribution_status';
+SELECT @option_val_id_cs_wt  := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cs;
+SELECT @option_val_id_cs_val := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cs;
+
+INSERT INTO
+   `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
+VALUES
+  (@option_group_id_cs, '{ts escape="sql"}Partially paid{/ts}', @option_val_id_cs_val+1, 'Partially paid', NULL, 0, NULL, @option_val_id_cs_wt+1, 0, 1, 1, NULL, NULL);
+
+-- participant status adding
+SELECT @participant_status_wt  := max(id) from civicrm_participant_status_type;
+
+INSERT INTO civicrm_participant_status_type (id, name,  {localize field='label'}label{/localize}, class, is_reserved, is_active, is_counted, weight, visibility_id)
+VALUES
+  (1,  'Partially paid', '{ts escape="sql"}Partially paid{/ts}', 'Positive', 1, 1, 1, @participant_status_wt+1, 2);
\ No newline at end of file
index 5a37446fda1f3a0be4822586b2a6e964297a80da..2f5973dd640ce9989f2eeb559784de448415de18 100644 (file)
         }
       }
     }
+
+  // change the status to default 'partially paid' for partial payments
+  var feeAmount;
+  var userModifiedAmount;
+  var partiallyPaidStatusId = {/literal}{$partiallyPaidStatusId}{literal};
+
+  cj('#total_amount')
+   .focus(
+     function() {
+       feeAmount = cj(this).val();
+       feeAmount = parseInt(feeAmount);
+     }
+   )
+   .change(
+    function() {
+      userModifiedAmount = cj(this).val();
+      userModifiedAmount = parseInt(userModifiedAmount);
+      if (userModifiedAmount < feeAmount) {
+        cj('#status_id').val(partiallyPaidStatusId);
+      }
+    }
+  );
+
+  cj('#Participant').submit(
+    function(e) {
+      var userSubmittedStatus = cj('#status_id').val();
+      var statusLabel = cj('#status_id option:selected').text();
+      if (userModifiedAmount < feeAmount && userSubmittedStatus != 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 (result == false) {
+          e.preventDefault();
+        }
+      }
+    }
+  );
   </script>
   {/literal}
   {/if}
index 560ac8681434a3b04db93225f78cc2b919c31572..80a775945dfa5f9c4c2c20cb5061e8ca11777cb0 100644 (file)
@@ -413,6 +413,7 @@ VALUES
   (@option_group_id_cs, '{ts escape="sql"}In Progress{/ts}', 5, 'In Progress', NULL, 0, NULL, 5, NULL, 0, 1, 1, NULL, NULL),
   (@option_group_id_cs, '{ts escape="sql"}Overdue{/ts}'    , 6, 'Overdue'    , NULL, 0, NULL, 6, NULL, 0, 1, 1, NULL, NULL),
   (@option_group_id_cs, '{ts escape="sql"}Refunded{/ts}'   , 7, 'Refunded'   , NULL, 0, NULL, 7, NULL, 0, 1, 1, NULL, NULL),
+  (@option_group_id_cs, '{ts escape="sql"}Partially paid{/ts}', 8, 'Partially paid', NULL, 0, NULL, 8, NULL, 0, 1, 1, NULL, NULL),
 
   (@option_group_id_pcp, '{ts escape="sql"}Waiting Review{/ts}', 1, 'Waiting Review', NULL, 0, NULL, 1, NULL, 0, 1, 1, NULL, NULL),
   (@option_group_id_pcp, '{ts escape="sql"}Approved{/ts}'      , 2, 'Approved'      , NULL, 0, NULL, 2, NULL, 0, 1, 1, NULL, NULL),
@@ -1446,7 +1447,9 @@ INSERT INTO civicrm_participant_status_type
   (10, 'Pending from approval',               '{ts escape="sql"}Pending from approval{/ts}',               'Pending',  1,           0,         1,          10,     2            ),
   (11, 'Rejected',                            '{ts escape="sql"}Rejected{/ts}',                            'Negative', 1,           0,         0,          11,     2            ),
   (12, 'Expired',                             '{ts escape="sql"}Expired{/ts}',                             'Negative', 1,           1,         0,          12,     2            ),
-  (13, 'Pending in cart',                     '{ts escape="sql"}Pending in cart{/ts}',                     'Pending',  1,           1,         0,          13,     2            );
+  (13, 'Pending in cart',                     '{ts escape="sql"}Pending in cart{/ts}',                     'Pending',  1,           1,         0,          13,     2            ),
+  (14,  'Partially paid',                      '{ts escape="sql"}Partially paid{/ts}',                      'Positive', 1,           1,         1,          14,     2           );
+
 
 
 -- CRM-8150