-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathedit.php
213 lines (161 loc) · 7.82 KB
/
edit.php
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
<?php
session_start();
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>EDIT INVOICE ITEM</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>
<?php
require 'functions.php';
$id = $_GET['id'];
$k = mysqli_query($koneksi, "SELECT * FROM item WHERE id=$id");
$kl = mysqli_fetch_array($k);
if (isset($_POST['edits'])) {
edititem($_POST);
}
?>
<div class="container-fluid">
<div class="row mt-3">
<div class="col-sm">
<div class="jumbotron">
<h2>Edit Invoice Item</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="<?php echo $kl['item_desk'] ?>" /><br>
</div>
<div class="form-group">
<label for="">Revisi</label>
<input type="text" name="rev" class="form-control rev" value="<?php echo $kl['rev'] ?>" /><br>
</div>
<div class="form-group">
<label for="">Harga</label>
<input type="text" name="harga" class="form-control harga" value="<?php echo $kl['price'] ?>" /><br>
</div>
<div class="form-group">
<label for="">Total</label>
<input type="text" name="total" class="form-control total" readonly value="" /><br>
</div>
<input type="submit" class="float-right add_button btn btn-success" name="edits" value="Edit Item">
</div>
</div>
</div>
</div>
</form>
</div>
</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("");
// }
// })
// });
$('.harga').keyup(function() {
var harga = $(this).val();
var rev = $('.rev').val();
var revtotal = parseInt(rev) * 150000;
var total = revtotal + parseInt(harga);
$('.total').val(total);
})
</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 } ?>