-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path044 Fatura.html
141 lines (119 loc) · 5.46 KB
/
044 Fatura.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sipariş Toplam</title>
<script>
function yeniSatir(){
var tabloGovde = document.getElementById('siparisTablosu').getElementsByTagName('tbody')[0];
var table = document.getElementById("siparisTablosu");
var satirSayisi = table.rows.length-5; //7 toplam satır, 5 tanesi sabit, 2 kalan olacak
var num = satirSayisi+1;
var yeniSatir = tabloGovde.insertRow(num);
var yeniHucre = yeniSatir.insertCell();
var eleman = document.createElement("INPUT");
eleman.setAttribute("type", "text");
eleman.setAttribute("placeholder", "urun adı");
eleman.setAttribute("id", "urun"+num);
yeniHucre.appendChild(eleman);
var yeniHucre = yeniSatir.insertCell();
var eleman = document.createElement("INPUT");
eleman.setAttribute("type", "number");
eleman.setAttribute("placeholder", "adet");
eleman.setAttribute("id", "adet"+num);
yeniHucre.appendChild(eleman);
var yeniHucre = yeniSatir.insertCell();
var eleman = document.createElement("INPUT");
eleman.setAttribute("type", "number");
eleman.setAttribute("placeholder", "fiyat");
eleman.setAttribute("id", "fiyat"+num);
yeniHucre.appendChild(eleman);
var yeniHucre = yeniSatir.insertCell();
var eleman = document.createElement("INPUT");
eleman.setAttribute("type", "number");
eleman.setAttribute("placeholder", "KDV(%)");
eleman.setAttribute("id", "kdv"+num);
eleman.setAttribute("value", "20");
eleman.setAttribute("min",1);
eleman.setAttribute("max",100);
eleman.setAttribute("size",3);
yeniHucre.appendChild(eleman);
var yeniHucre = yeniSatir.insertCell();
var eleman = document.createElement("INPUT");
eleman.setAttribute("type", "number");
eleman.setAttribute("placeholder", "Tutar");
eleman.setAttribute("id", "tutar"+num);
yeniHucre.appendChild(eleman);
}
function hesapla(){
var table = document.getElementById("siparisTablosu");
var satirSayisi = table.rows.length-5;
//alert(satirSayisi);
var toplam=0;
var kdvtoplam=0;
for(i=1; i<=satirSayisi; i++)
{
tutar=0;
adet= document.getElementById("adet"+i).value;
fiyat=document.getElementById("fiyat"+i).value;
kdv=document.getElementById("kdv"+i).value;
if(adet.length!==0 && fiyat.length!==0 && kdv.length!==0){
tutar= parseFloat(adet)*parseFloat(fiyat);
//console.log("Tutar:"+tutar);
document.getElementById("tutar"+i).value=tutar;
kdvtoplam+= tutar*kdv/100;
toplam+=tutar;
}
}
document.getElementById("alttoplam").value=toplam;
document.getElementById("kdvtoplam").value=kdvtoplam;
document.getElementById("geneltoplam").value=toplam+kdvtoplam;
}
</script>
</head>
<body>
<form>
Fatura No:<input type="text" name="faturaID">
<table border="1" align="center" id="siparisTablosu">
<tr>
<th>Ürün Adı</th>
<th>Adet</th>
<th>Birim Fiyat</th>
<th>KDV(%)</th>
<th>Tutar</th>
</tr>
<tr>
<td><input type="text" id="urun1"></td><!-- Ürün Adı -->
<td><input type="number" id="adet1"></td> <!-- Adet-->
<td><input type="number" id="fiyat1"></td><!-- Birim Fiyat-->
<td><input type="number" id="kdv1" value="20" min="1" max="100" size="3"></td><!--KDV-->
<td><input type="number" id="tutar1" readonly></td><!-- Tutar-->
</tr>
<tr>
<td><input type="text" id="urun2"></td><!-- Ürün Adı -->
<td><input type="number" id="adet2"></td> <!-- Adet-->
<td><input type="number" id="fiyat2"></td><!-- Birim Fiyat-->
<td><input type="number" id="kdv2" value="20" min="1" max="100" size="3"></td><!--KDV-->
<td><input type="number" id="tutar2" readonly></td><!-- Tutar-->
</tr>
<tr>
<td><button onclick="yeniSatir()">Yeni Satır Ekle(+)</button></td>
<td colspan="4" align="right"><button onclick="hesapla()">Hesapla</button></td>
</tr>
<tr>
<td colspan="4" align="right"><b>Toplam:</b></td>
<td align="right"><input type="text" id="alttoplam" readonly></td>
</tr>
<tr>
<td colspan="4" align="right"><b>KDV Toplam:</b></td>
<td align="right"><input type="text" id="kdvtoplam" readonly></td>
</tr>
<tr>
<td colspan="4" align="right"><b>Genel Toplam:</b></td>
<td align="right"><input type="text" id="geneltoplam" readonly></td>
</tr>
</table>
</body>
</html>