Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. $(document).ready(function(){
  2. var id;
  3. $('.cal_demonstration').on('change', 'input.cal_demonstration_change',function(){
  4. id = $(this).attr("id").split("__");
  5. $(this).attr("id");
  6. $(this).attr("value");
  7. if(id[1] =='base'){
  8. var ans = parseFloat($("#"+id[0]+"__base").val()) * parseFloat($("#"+id[0]+"__multiplier").val())
  9. if(!isNaN(ans)) {
  10. $("#"+id[0]+"__ans").val(ans.toFixed(2));
  11. } else {
  12. $("#"+id[0]+"__ans").val('0.00');
  13. $("#"+id[0]+"__multiplier").val('0.00');
  14. }
  15. }else if(id[1] =='otbase'){
  16. var ans = parseFloat($("#"+id[0]+"__otbase").val()) * parseFloat($("#"+id[0]+"__otmultiplier").val())
  17. if(!isNaN(ans)) {
  18. $("#"+id[0]+"__otans").val(ans.toFixed(2));
  19. } else {
  20. $("#"+id[0]+"__otans").val('0.00');
  21. $("#"+id[0]+"__otmultiplier").val('0.00');
  22. }
  23. }else if(id[1] == 'multiplier'){
  24. var ans = parseFloat($("#"+id[0]+"__base").val()) * parseFloat($("#"+id[0]+"__multiplier").val())
  25. if(!isNaN(ans)) {
  26. $("#"+id[0]+"__ans").val(ans.toFixed(2));
  27. } else {
  28. $("#"+id[0]+"__ans").val('0.00');
  29. }
  30.  
  31. }else if(id[1] == 'otmultiplier'){
  32. var ans = parseFloat($("#"+id[0]+"__otbase").val()) * parseFloat($("#"+id[0]+"__otmultiplier").val())
  33. if(!isNaN(ans)) {
  34. $("#"+id[0]+"__otans").val(ans.toFixed(2));
  35. } else {
  36. $("#"+id[0]+"__otans").val('0.00');
  37. }
  38.  
  39. }else if(id[1] =='ans') {
  40. var multiplier = parseFloat($("#"+id[0]+"__ans").val()) / parseFloat($("#"+id[0]+"__base").val())
  41. if(!isNaN(multiplier)) {
  42. $("#"+id[0]+"__multiplier").val(multiplier.toFixed(2));
  43. } else {
  44. $("#"+id[0]+"__multiplier").val('0.00');
  45. }
  46. }else if(id[1] =='otans') {
  47. var multiplier = parseFloat($("#"+id[0]+"__otans").val()) / parseFloat($("#"+id[0]+"__otbase").val())
  48. if(!isNaN(multiplier)) {
  49. $("#"+id[0]+"__otmultiplier").val(multiplier.toFixed(2));
  50. } else {
  51. $("#"+id[0]+"__otmultiplier").val('0.00');
  52. }
  53. }
  54.  
  55. });
  56.  
  57. $('#default_value_save-admin').on('click',function(){
  58. var $inputs = $('#full_data_get_id_form_this_page :input');
  59. // An array of just the ids...
  60. var ids = {};
  61. var count=0;
  62. var jsonVariable ='';
  63. $inputs.each(function (index){
  64. ids[count] = $(this).attr('id');
  65.  
  66. //if($('#'+$(this).attr('id')).val() != '' && !isNaN($('#'+$(this).attr('id')).val())) {
  67. if($('#'+$(this).attr('id')).val() != '') {
  68. jsonVariable += '"'+$(this).attr('id')+'":"'+$('#'+$(this).attr('id')).val()+'",'
  69. }
  70. count++;
  71. });
  72.  
  73. jsonVariable = jsonVariable.slice(0, -1);
  74. jsonVariable = "{"+jsonVariable+"}";
  75. console.log(jsonVariable);
  76. // alert(window.location.origin);
  77. $.ajax({
  78. url: window.location.origin+'/FE2/index.php/dashboard/defaultValueStore',
  79. type: 'POST',
  80. dataType: 'json',
  81. data:{"default_value":jsonVariable},
  82. success:function(res){
  83. console.log('success');
  84. },error : function(e) {
  85. console.log(e);
  86. console.log('an error occured');
  87. }, complete : function() {
  88. console.log('Defaut value saved successfully')
  89. }
  90. });
  91.  
  92.  
  93. });
  94.  
  95. $('#standard_hrs_rate').on('change',function(){
  96. //$("input[id$=__base]").val($('#standard_hrs_rate').val());
  97. $("input[id$=__base]")
  98. .val($('#standard_hrs_rate').val())
  99. .trigger('change');
  100. });
  101.  
  102. $('#overtime_rate').on('change',function(){
  103. //$("input[id$=__otbase]").val($('#overtime_rate').val());
  104. $("input[id$=__otbase]")
  105. .val($('#overtime_rate').val())
  106. .trigger('change');
  107. });
  108.  
  109.  
  110. $("#inflation_percent_year").change(function(){
  111. if(event.keyCode == 8 || event.keyCode == 46) {
  112. return false;
  113. } else {
  114. $(this).val(function(index, old) { return old.replace(/[^0-9\.]/g, '') + '%'; });
  115. }
  116. });
  117.  
  118.  
  119.  
  120. //
  121. $('#quoates_status_pending_approval,#quoates_status_approved,#quoates_status_sent_to_customer,#quoates_status_agreed_by_customer,#quoates_status_agreed_by_customer_after_date,#quoates_status_agreed_by_customer,#quoates_status_archived').on('click', function(){
  122. var id_to_status;
  123. var id = $(this).attr('id');
  124. id_to_status = id_to_status_fun(id);
  125.  
  126. $.ajax({
  127. url: window.location.origin+'/FE2/index.php/dashboard/approval_pending',
  128. type: 'POST',
  129. dataType: 'json',
  130. data:{"filter_key": id_to_status },
  131. success:function(res){
  132. console.log('success');
  133. },error : function(e) {
  134. console.log(e);
  135. console.log('an error occured');
  136. }, complete : function() {
  137. console.log('Defaut value saved successfully')
  138. }
  139. });
  140.  
  141. });
  142.  
  143. function id_to_status_fun(id){
  144.  
  145. switch(id) {
  146.  
  147. case 'quoates_status_pending_approval':
  148. return 'pending_approval';
  149. break;
  150.  
  151. case 'quoates_status_approved':
  152. return 'status_approved';
  153. break;
  154.  
  155. case 'quoates_status_sent_to_customer':
  156. return 'sent_to_customer';
  157. break;
  158.  
  159. case 'quoates_status_agreed_by_customer':
  160. return 'agreed_by_customer';
  161. break;
  162.  
  163. case 'quoates_status_agreed_by_customer_after_date':
  164. return 'agreed_by_customer_after_date';
  165. break;
  166.  
  167. case 'quoates_status_agreed_by_customer':
  168. return 'agreed_by_customer';
  169. break;
  170.  
  171. case 'quoates_status_archived':
  172. return 'archived';
  173. break;
  174.  
  175. default:
  176. return false;
  177. }
  178. }
  179.  
  180. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement