Advertisement
Amakesh

Untitled

Jan 13th, 2017
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 6.23 KB | None | 0 0
  1. //dodawanie/ usuwanie wiersza w tabeli
  2. <script>
  3.  
  4. jQuery(document).ready(function() {
  5.  
  6.       jQuery('#add').click(function(e){  
  7.             var ca=jQuery('#dpchc').val();
  8.           var selectedf = jQuery('#types_ft').val();
  9.  
  10.            e.preventDefault();
  11.  
  12.             if (selectedf == " VAT ")
  13.     {
  14.           ca++;  
  15.         jQuery('#dpchc').val(ca);
  16.            jQuery('#table_rach').append('<tr id="d'+ca+'" class ="tr" onMouseOver="this.style.background='+bf+'" onMouseOut="this.style.background='+tr+'";><td class="container_res" width = "40px;"><center><input id="lp" type="hidden" value="'+ca+'" >'+ca+'</input></td><td class="container_res"><center><div><input type="text" class="preview" id="name'+ca+'" name="name" size="40;" line-height="0px" value=""></input></div></td><td class="container_res"><center><div class="td_div"><input type="text" class="preview" id="pkwiu'+ca+'" name="pkwiu" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><center><div><input type="number" class="preview" id="ilosc'+ca+'" name="ilosc" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><center><div><input type="text" class="preview" id="jdn'+ca+'" name="jdn" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><center><div><input type="number" class="preview" id="cjnt'+ca+'" name="cjnt" size="40" line-height="0px" value=" "></input></div></td><td class="container_res"><center><div><input style = "width: 170px !important" type="number" class="preview" id="wrtn'+ca+'" name="wrtn" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><center><div id="vt'+ca+'"><input style = "width: 170px !important" type="number" class="preview" id="vat'+ca+'" name="vat" size="40" line-height="0px" value="23"></input></div></td><td class="container_res"><center><div id="wvt'+ca+'"><input style = "width: 170px !important" type="number" class="preview" id="wavat'+ca+'" name="wavat" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><center><div><input style = "width: 170px !important" type="number" class="preview" id="wabr'+ca+'" name="wabr" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><div><button type="button" name="remove" id="'+ca+'" class="delete2">X</button></div></td></tr>');  
  17.     }
  18.     if (selectedf == " Podatnika zwolnionego z VAT "){
  19.           ca++;  
  20.         jQuery('#dpchc').val(ca);
  21.            jQuery('#table_rach').append('<tr id="d'+ca+'" class ="tr" onMouseOver="this.style.background='+bf+'" onMouseOut="this.style.background='+tr+'";><td class="container_res" width = "40px;"><center><input id="lp" type="hidden" value="'+ca+'" >'+ca+'</input></td><td class="container_res"><center><div><input type="text" class="preview" id="name'+ca+'" name="name" size="40;" line-height="0px" value=""></input></div></td><td class="container_res"><center><div class="td_div"><input type="text" class="preview" id="pkwiu'+ca+'" name="pkwiu" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><center><div><input type="number" class="preview" id="ilosc'+ca+'" name="ilosc" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><center><div><input type="text" class="preview" id="jdn'+ca+'" name="jdn" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><center><div><input type="number" class="preview" id="cjnt'+ca+'" name="cjnt" size="40" line-height="0px" value=" "></input></div></td><td class="container_res"><center><div><input style = "width: 170px !important" type="number" class="preview" id="wrtn'+ca+'" name="wrtn" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><center><div id="vt'+ca+'"><input style = "width: 170px !important" type="number" class="preview" id="vat'+ca+'" name="vat" size="40" line-height="0px" value="0" readonly></input></div></td><td class="container_res"><center><div id="wvt'+ca+'"><input style = "width: 170px !important" type="number" class="preview" id="wavat'+ca+'" name="wavat" size="40" line-height="0px" value="" readonly></input></div></td><td class="container_res"><center><div><input style = "width: 170px !important" type="number" class="preview" id="wabr'+ca+'" name="wabr" size="40" line-height="0px" value=""></input></div></td><td class="container_res"><div><button type="button" name="remove" id="'+ca+'" class="delete2">X</button></div></td></tr>');        
  22.  
  23.     }
  24.       });
  25.  
  26.     jQuery("body").on("click", ".delete2", function (e) {
  27.     e.preventDefault();
  28.  
  29.         var No5 = jQuery('#dpchc').val();
  30.     jQuery('#d'+No5).remove();
  31.  
  32.     var No6 = parseInt(No5)-1;
  33.  
  34.     jQuery('#dpchc').val(No6);
  35.  
  36. });
  37.  
  38.  
  39.  
  40. //wczytywanie danych z tabeli i wpisywanie do niej i innych pól wyników
  41.  
  42.  
  43. jQuery('.preview').on('input', function(){  
  44.             Licz();
  45.  });
  46.  
  47.     var Licz = function () {
  48.  
  49.     co = jQuery('#dpchc').val();    
  50.     var arrayil = [];
  51.     var arraycjn = [];
  52.     var arrayvat=[];
  53.     var arraywvat=[];
  54.     var arraywb =[];
  55.     var arraywn =[];
  56.     var ilosc = "";
  57.     var wnetto = "";
  58.     var vat = "";
  59.     var wvat = "";
  60.     var wbrutto = "";
  61.     var rzm = 0;
  62.     var wtp = 0;
  63.  
  64. for(count=1;count<=co;count++){
  65.  
  66.     arraycjn[count] = jQuery('#cjnt'+count).val();
  67.     arrayil[count] = jQuery('#ilosc'+count).val();
  68.     arrayvat[count] = jQuery('#vat'+count).val();
  69. }
  70.  
  71. for(counttp=1;counttp<=co;counttp++){
  72. arraywn[counttp]=parseFloat(arraycjn[counttp])*parseFloat(arrayil[counttp]);
  73.  
  74. }
  75. for(coun=1;coun<=co;coun++){
  76. arraywvat[coun]=parseFloat((arraywn[coun]*arrayvat[coun]))/100;
  77.  
  78. }
  79. for(cnt=1;cnt<=co;cnt++){
  80. arraywb[cnt]=parseFloat(arraywn[cnt])+parseFloat(arraywvat[cnt]);
  81.  
  82. }
  83. var crzm = parseInt(arraywb.length)-1;      
  84. for(cnnt=1;cnnt<=crzm;cnnt++){
  85. rzm+=parseFloat(arraywb[cnnt]);
  86.  
  87. }
  88. jQuery('#dzp').val(rzm);    
  89.  
  90. var cwtp = parseInt(arraywvat.length)-1;        
  91. for(cnntt=1;cnntt<=crzm;cnntt++){
  92. wtp+=parseFloat(arraywvat[cnntt]);
  93.  
  94. }
  95. jQuery('#wtp').val(wtp);        
  96.  
  97. for(cntt=1;cntt<=co;cntt++){
  98. jQuery('#wrtn'+cntt).val(arraywn[cntt]);    
  99. jQuery('#wavat'+cntt).val(arraywvat[cntt]);    
  100. jQuery('#wabr'+cntt).val(arraywb[cntt]);        
  101. }
  102.  
  103.     }  
  104.     });    
  105. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement