Guest User

Untitled

a guest
Oct 12th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. <script type="text/javascript">
  2. function calculate_amt(count,price)
  3. {
  4.  
  5. var ref_amt = document.getElementById("ref_amt").value;
  6. var total_ref = document.getElementById('total_ref').innerHTML;
  7. var total = parseInt(Math.round(count * price * 100)/100); //two decimal value
  8. var balance = 0;
  9.  
  10. ref_amt = parseInt(ref_amt);
  11.  
  12. if(isNaN(ref_amt))
  13. {
  14. ref_amt = 0;
  15. balance = Math.round(total * 100)/100;
  16. }
  17. else
  18. {
  19. balance = Math.round((total - ref_amt)* 100)/100;
  20. }
  21. if(balance < 0)
  22. {
  23. balance = 0;
  24. }
  25. if(isNaN(count))
  26. {
  27. document.getElementById("quantity").value = '1';
  28. return;
  29. }
  30.  
  31. if(count == 0)
  32. {
  33. document.getElementById("quantity").value = '1';
  34. return;
  35. }
  36.  
  37. if(ref_amt <= total_ref)
  38. {
  39. if(ref_amt > total)
  40. {
  41. document.getElementById('ref_amt').value = 0;
  42. }
  43. }
  44. else
  45. {
  46. document.getElementById('ref_amt').value = 0;
  47. }
  48.  
  49. document.getElementById("total_amt1").innerHTML=balance;
  50. document.getElementById("payable_total_amt").innerHTML=balance;
  51. document.getElementById("AMT").value = balance;
  52.  
  53. var data = document.getElementById("CUSTOM").value;
  54. var cid = data.split(",",1);
  55. if(count=='') count = 1;
  56. var cumm = cid+","+count
  57. document.getElementById("CUSTOM").value='';
  58. document.getElementById("CUSTOM").value=cumm;
  59. }
  60.  
  61. function calculate_referral(ref_amt,price)
  62. {
  63. ref_amt = parseInt(ref_amt);
  64. var count = document.getElementById('quantity').value;
  65. var purchase_price;
  66. var total_ref = document.getElementById('total_ref').innerHTML;
  67. var total;
  68. var balance = 0;
  69. var ref_amt_bal = parseInt(document.getElementById('ref_amt_bal').value);
  70.  
  71. if(ref_amt_bal >= ref_amt && parseInt(document.getElementById("total_amt1").innerHTML) >= ref_amt ){
  72. // Condition to check whether entered amount is with in Original balance & total order
  73. //alert("success");
  74. }else{
  75. alert("Enter applicable refferal amount!"); document.getElementById('ref_amt').value = '';
  76. document.getElementById('ref_amt').value = 0;
  77. balance = Math.round(count * price * 100)/100; //two decimal value
  78.  
  79. document.getElementById("total_amt1").innerHTML=balance;
  80. document.getElementById("payable_total_amt").innerHTML=balance;
  81. document.getElementById("AMT").value = balance;
  82. var data = document.getElementById("CUSTOM").value;
  83. var cid = data.split(",",1);
  84. if(count=='') count = 1;
  85. var cumm = cid+","+count
  86. document.getElementById("CUSTOM").value='';
  87. document.getElementById("CUSTOM").value=cumm;
  88. return;
  89. }
  90.  
  91. if(isNaN(count))
  92. {
  93. document.getElementById("quantity").value = '1';
  94. return;
  95. }
  96.  
  97. if(count == 0)
  98. {
  99. document.getElementById("quantity").value = '1';
  100. return;
  101. }
  102. total = Math.round(count * price * 100)/100; //two decimal value
  103. if(isNaN(ref_amt))
  104. {
  105. ref_amt = 0;
  106. balance = Math.round(total* 100)/100;
  107. }
  108. else
  109. {
  110. balance = Math.round((total - ref_amt)* 100)/100;
  111. }
  112. if(balance < 0)
  113. {
  114. balance = 0;
  115. }
  116. if(ref_amt <= total)
  117. {
  118.  
  119. if(ref_amt > total_ref)
  120. {
  121. document.getElementById('ref_amt').value = ref_amt;
  122. }
  123. }
  124. else
  125. {
  126. document.getElementById('ref_amt').value = 0;
  127. }
  128.  
  129. document.getElementById("total_amt1").innerHTML=balance;
  130. document.getElementById("payable_total_amt").innerHTML=balance;
  131. document.getElementById("AMT").value = balance;
  132.  
  133. var data = document.getElementById("CUSTOM").value;
  134. var cid = data.split(",",1);
  135. if(count=='') count = 1;
  136. var cumm = cid+","+count
  137. document.getElementById("CUSTOM").value='';
  138. document.getElementById("CUSTOM").value=cumm;
  139.  
  140. }
  141. </script>
Add Comment
Please, Sign In to add comment