Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //dodawanie/ usuwanie wiersza w tabeli
- <script>
- jQuery(document).ready(function() {
- jQuery('#add').click(function(e){
- var ca=jQuery('#dpchc').val();
- var selectedf = jQuery('#types_ft').val();
- e.preventDefault();
- if (selectedf == " VAT ")
- {
- ca++;
- jQuery('#dpchc').val(ca);
- 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>');
- }
- if (selectedf == " Podatnika zwolnionego z VAT "){
- ca++;
- jQuery('#dpchc').val(ca);
- 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>');
- }
- });
- jQuery("body").on("click", ".delete2", function (e) {
- e.preventDefault();
- var No5 = jQuery('#dpchc').val();
- jQuery('#d'+No5).remove();
- var No6 = parseInt(No5)-1;
- jQuery('#dpchc').val(No6);
- });
- //wczytywanie danych z tabeli i wpisywanie do niej i innych pól wyników
- jQuery('.preview').on('input', function(){
- Licz();
- });
- var Licz = function () {
- co = jQuery('#dpchc').val();
- var arrayil = [];
- var arraycjn = [];
- var arrayvat=[];
- var arraywvat=[];
- var arraywb =[];
- var arraywn =[];
- var ilosc = "";
- var wnetto = "";
- var vat = "";
- var wvat = "";
- var wbrutto = "";
- var rzm = 0;
- var wtp = 0;
- for(count=1;count<=co;count++){
- arraycjn[count] = jQuery('#cjnt'+count).val();
- arrayil[count] = jQuery('#ilosc'+count).val();
- arrayvat[count] = jQuery('#vat'+count).val();
- }
- for(counttp=1;counttp<=co;counttp++){
- arraywn[counttp]=parseFloat(arraycjn[counttp])*parseFloat(arrayil[counttp]);
- }
- for(coun=1;coun<=co;coun++){
- arraywvat[coun]=parseFloat((arraywn[coun]*arrayvat[coun]))/100;
- }
- for(cnt=1;cnt<=co;cnt++){
- arraywb[cnt]=parseFloat(arraywn[cnt])+parseFloat(arraywvat[cnt]);
- }
- var crzm = parseInt(arraywb.length)-1;
- for(cnnt=1;cnnt<=crzm;cnnt++){
- rzm+=parseFloat(arraywb[cnnt]);
- }
- jQuery('#dzp').val(rzm);
- var cwtp = parseInt(arraywvat.length)-1;
- for(cnntt=1;cnntt<=crzm;cnntt++){
- wtp+=parseFloat(arraywvat[cnntt]);
- }
- jQuery('#wtp').val(wtp);
- for(cntt=1;cntt<=co;cntt++){
- jQuery('#wrtn'+cntt).val(arraywn[cntt]);
- jQuery('#wavat'+cntt).val(arraywvat[cntt]);
- jQuery('#wabr'+cntt).val(arraywb[cntt]);
- }
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement