Merge pull request #1450 from davecivicrm/CRM-13218
authorKurund Jalmi <kurund@civicrm.org>
Fri, 16 Aug 2013 18:52:17 +0000 (11:52 -0700)
committerKurund Jalmi <kurund@civicrm.org>
Fri, 16 Aug 2013 18:52:17 +0000 (11:52 -0700)
CRM-13218 Total Fee on first page adjusts based on number of participant...

templates/CRM/Price/Form/Calculate.tpl

index 6ab5bca39608a30f42098989da8957def2fd8ec5..62f0d9a888a67284136ab0b0111e2ebb14b8b0e9 100644 (file)
@@ -74,6 +74,10 @@ cj("input,#priceset select,#priceset").each(function () {
       }
       display( totalfee );
     });
+    cj('#additional_participants').change( function( ) {
+      display( totalfee );
+    });
+
     display( totalfee );
     break;
 
@@ -100,6 +104,11 @@ cj("input,#priceset select,#priceset").each(function () {
 
       display( totalfee );
     });
+
+    cj('#additional_participants').change( function( ) {
+      display( totalfee );
+    });
+
     display( totalfee );
     break;
 
@@ -126,6 +135,11 @@ cj("input,#priceset select,#priceset").each(function () {
     cj(this).bind( 'keyup', function() { calculateText( this );
     }).bind( 'blur' , function() { calculateText( this );
     });
+
+    cj('#additional_participants').change( function( ) {
+      display( totalfee );
+    });
+
     display( totalfee );
     break;
 
@@ -171,6 +185,11 @@ cj("input,#priceset select,#priceset").each(function () {
       }
       display( totalfee );
     });
+
+    cj('#additional_participants').change( function( ) {
+      display( totalfee );
+    });
+
     display( totalfee );
     break;
     }
@@ -200,7 +219,18 @@ function calculateText( object ) {
 
 //display calculated amount
 function display( totalfee ) {
-    var totalEventFee  = formatMoney( totalfee, 2, seperator, thousandMarker);
+    num_participants = cj('#additional_participants').val()
+
+    if(!num_participants) {
+      num_participants = 0
+    }
+    // The value of this field is the number of *additional* participants
+    // What is displayed to the user is 1 + the value, because it is including
+    // the "yourself". Since we want to give a total, including "yourself" we have
+    // to add one to the value of #additional_participants.
+    num_participants++;
+
+    var totalEventFee  = formatMoney( totalfee * num_participants, 2, seperator, thousandMarker);
     document.getElementById('pricevalue').innerHTML = "<b>"+symbol+"</b> "+totalEventFee;
     scriptfee   = totalfee;
     scriptarray = price;