-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathitem.php
More file actions
256 lines (194 loc) · 9.35 KB
/
item.php
File metadata and controls
256 lines (194 loc) · 9.35 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
require 'functions.php';
if (empty($_SESSION['code_client'])) {
header("location: index.php");
} else {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INPUT ITEM INVOICE</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body style="background-color: white !important;">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">INVOICE LESMANA DESIGN</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Tambah Invoice <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="lihat/index.php">Lihat Data Invoice</a>
</li>
</ul>
</div>
</nav>
<div class="container-fluid">
<div class="row mt-3">
<div class="col-sm">
<div class="jumbotron">
<h2>Input Invoice</h2>
<hr>
<h4>Item</h4>
<form action="" method="POST" class="formitem">
<input type="hidden" name="codes" value="<?php echo $_SESSION['code_client'] ?>">
<div class="field_wrapper">
<div class="card mt-5 hitungs">
<div class="card-body">
<div>
<div class="form-group">
<label for="">Item Deskripsi</label>
<input type="text" name="item_desk" class="form-control item_desk" value="" /><br>
</div>
<div class="form-group">
<label for="">Revisi</label>
<input type="text" name="rev" class="form-control rev" value="" /><br>
</div>
<div class="form-group">
<label for="">Harga</label>
<input type="text" name="harga" class="form-control harga" value="" /><br>
</div>
<div class="form-group">
<label for="">Total</label>
<input type="text" name="total" class="form-control total" readonly value="" /><br>
</div>
<a href="javascript:void(0);" class="float-right add_button btn btn-success" title="Add field">Tambah Item</a>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="col-sm">
<div class="jumbotron">
<h2>History Inputan</h2>
<hr>
<h4>Data</h4>
<div class="itemlist"></div>
</div>
<button class="btn btn-primary" id="lanjut">Lanjut</button>
</div>
</div>
<script src="css/jquery-3.5.1.min.js"></script>
<script>
$('.itemlist').load('loaditem.php');
$('.add_button').click(function() {
var data = $('.formitem').serialize();
$.ajax({
type: 'POST',
url: 'uploaditem.php',
data: data,
success: function() {
$('.itemlist').load('loaditem.php');
$('.rev').val("");
$('.harga').val("");
$('.item_desk').val("");
$('.total').val("");
}
})
});
$('#lanjut').click(function() {
var data = '<?php echo $_SESSION['code_client'] ?>';
$.ajax({
type: 'GET',
url: 'total.php',
data: {
"data": data
},
success: function(data) {
document.location.href = 'discount.php';
}
})
})
$('.harga').keyup(function() {
$(this).val(formatRupiah(this.value));
var harga = $(this).val();
var revtotal;
harganew = harga.split('.').join("");
var rev = $('.rev').val();
if (rev == 1) {
revtotal = parseInt(rev) * 0;
} else {
revtotal = (parseInt(rev) - 1) * 150000;
}
var total = revtotal + parseInt(harganew);
$('.total').val(total);
})
function formatRupiah(angka, prefix) {
var number_string = angka.replace(/[^,\d]/g, '').toString(),
split = number_string.split(','),
sisa = split[0].length % 3,
rupiah = split[0].substr(0, sisa),
ribuan = split[0].substr(sisa).match(/\d{3}/gi);
if (ribuan) {
separator = sisa ? '.' : '';
rupiah += separator + ribuan.join('.');
}
rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
return prefix == undefined ? rupiah : (rupiah ? 'Rp. ' + rupiah : '');
}
</script>
<!-- <script type="text/javascript">
$(document).ready(function(){
var maxField = 10; //Input fields increment limitation
var addButton = $('.add_button'); //Add button selector
var wrapper = $('.field_wrapper'); //Input field wrapper
var fieldHTML = '<div class="card mt-5 hitungs"><div class="card-body"><div><div class="form-group"><label for="">Item Deskripsi</label><input type="text" name="item_desk" class="form-control" value=""/><br></div><div class="form-group"><label for="">Harga</label><input type="text" name="harga" class="form-control harga" value=""/><br></div><div class="form-group"><label for="">Revisi</label><input type="text" name="rev" class="form-control rev" value=""/><br></div><div class="form-group"><label for="">Total</label><input type="text" id="total" name="total" class="form-control total" value=""/><br></div><a href="javascript:void(0);" class="float-right remove_button btn btn-danger" title="Add field">-</a></div>'; //New input field html
var x = 1; //Initial field counter is 1
//Once add button is clicked
$(addButton).click(function(){
//Check maximum number of input fields
if(x < maxField){
var s = x++; //Increment field counter
$(wrapper).append(fieldHTML); //Add field html
}
});
//Once remove button is clicked
$(wrapper).on('click', '.remove_button', function(e){
e.preventDefault();
$(this).parent('div').remove(); //Remove field html
x--; //Decrement field counter
console.log(x);
});
});
</script> -->
<!--
<script>
$(document).ready(function(){
$(document).on("keyup", ".harga", function() {
var harga;
$('.harga').each(function(){
harga = $(this).val()
})
var rev;
$('.rev').each(function(){
if ($(this).val() == null){
rev = 0;
} else {
rev = $(this).val()
}
})
var revharga;
var revtotal;
var total1;
$('.total').each(function(){
revharga = 150000;
revtotal = parseInt(rev) * revharga;
total1 = revtotal + parseInt(harga);
$(this).val(total1)
})
console.log(total1)
})
})
</script> -->
</body>
</html>
<?php } ?>