-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmasterr.php
More file actions
275 lines (221 loc) · 7.68 KB
/
Copy pathmasterr.php
File metadata and controls
275 lines (221 loc) · 7.68 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$koneksi = new mysqli("localhost", "root", "", "wgs");
// Periksa apakah koneksi berhasil atau tidak
if ($koneksi->connect_error) {
die("Koneksi gagal: " . $koneksi->connect_error);
}
$query = "SELECT * FROM masterbarang";
$result = mysqli_query($koneksi, $query);
if (mysqli_num_rows($result) > 0) {
echo "<table class='table'>
<tr>
<th class='text-white'>Action</th>
<th class='text-white'>Id</th>
<th class ='text-white'>Nama Barang</th>
</tr>";
// ... (Your existing PHP code)
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>
<td>
<a href='#' class='infoButton' data-kodebarang='" . $row["kodebarang"] . "'><i class='fa fa-info-circle text-white' aria-hidden='true' title='Info'></i></a>
<a href='#' class='editButton' data-kodebarang='" . $row["kodebarang"] . "'><i class='fa fa-pencil-square text-white' aria-hidden='true' title='Edit'></i></a>
</td>
<td class='text-white'>" . $row["kodebarang"] . "</td>
<td class='text-white'>" . $row["namabarang"] . "</td>
</tr>";
}
echo "</table>";
} else {
echo "Belum Ada Data";
}
mysqli_close($koneksi);
?>
<style>
/* CSS */
/* CSS */
#editModal,
#myModal {
overflow: auto; /* Tambahkan overflow: auto; untuk membuat efek scroll jika kontennya melebihi ukuran modal */
}
.modal-wrapper {
margin-top: 50px; /* Posisikan tepat di tengah vertikal */
margin-left: 50px; /* Posisikan tepat di tengah horizontal */
}
/* Warna teks dalam modal */
.modal-content,
.modal-content * {
color: black; /* Mengatur warna teks menjadi hitam */
}
.rincianquotes{
text-align: left;
margin-left: 26px;
}
.rincianharga {
margin-top: 20px; /* Sesuaikan nilai ini sesuai kebutuhan Anda */
}
#invoiceDetails {
margin-left: 400px;
}
#subtotalDisplay,
#ppnDisplay,
#totalallDisplay {
/* Jika Anda ingin mengatur jarak kiri pada elemen-elemen span secara khusus */
margin-left: 10px; /* Sesuaikan nilai ini sesuai kebutuhan Anda */
}
.modal-content {
width: 78%; /* You can adjust the percentage based on your preference */
margin-left: 265px;
margin-top: 66px;
}
.close {
color: black; /* Mengatur warna teks tombol close menjadi hitam */
font-weight: bold;
/* Properti CSS lainnya sesuai kebutuhan */
}
/* Increase the height of the modal content */
.modal-dialog {
max-width: 80%; /* Adjust the maximum width of the modal */
height: 80vh; /* Set the height to 90% of the viewport height */
margin-left: 0px; /* Add some margin for better appearance */
}
}
#barangTableDetail {
margin: 20px auto; /* Menempatkan tabel di tengah konten modul */
width: 90%; /* Lebar tabel */
}
#barangTableDetail th,
#barangTableDetail td {
border: 1px solid #dddddd;
padding: 20px;
text-align: left;
}
#barangTableDetail th {
background-color: #f2f2f2;
}
.rincianharga{
margin-left: 20px;
text-align: left;
}
.tablequotes{
margin-left: 180px;
}
</style>
<div id="editModal" class="modal">
<div class="modal-content" role="document">
<button class="close" style="text-align: left;">×</button>
<h5 style="text-align: center;">Edit Barang</h5>
<div>
<label for="editNamaBarang">Nama Barang:</label>
<input type="text" id="editNamaBarang" class="form-control">
</div>
<div>
<label for="editSatuan">Satuan:</label>
<input type="text" id="editSatuan" class="form-control">
</div>
<button id="saveEditButton" class="btn btn-primary">Save</button>
</div>
</div>
<div id="myModal" class="modal">
<div class="modal-content" role="document">
<button class="close" style="text-align:left;">×</button>
<h5 style="text-align: center;"> Master Barang</h5>
<div class="rincianquotes" style="text-align:left">
<p><strong>Nama Barang : </strong><span id="namabarangDisplay"></span></p>
<br>
<table class="table" id="nopoTable">
<thead>
<tr>
<th>No. PO</th>
</tr>
</thead>
<tbody id="nopoTableBody"></tbody>
</table>
<br>
<table class="table" id="ocTable">
<thead>
<tr>
<th>No. OC</th>
</tr>
</thead>
<tbody id="ocTableBody"></tbody>
</table>
<br>
<table class="table" id="inTable">
<thead>
<tr>
<th>Stock (In)</th>
</tr>
</thead>
<tbody id="inTableBody"></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
var modal = document.getElementById("myModal");
var editModal = document.getElementById("editModal");
var infoButtons = document.querySelectorAll('.infoButton');
var editButtons = document.querySelectorAll('.editButton');
var closeButton = document.querySelector('.close');
var saveEditButton = document.getElementById("saveEditButton");
infoButtons.forEach(function (button) {
button.addEventListener('click', function (event) {
event.preventDefault();
var kodebarang = this.dataset.kodebarang;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
showDetails(data.barang);
} else {
alert("Gagal mengambil data dari server.");
}
}
};
xhr.open('GET', 'get_barangmaster.php?kodebarang=' + encodeURIComponent(kodebarang), true);
xhr.send();
});
});
editButtons.forEach(function (button) {
button.addEventListener('click', function (event) {
event.preventDefault();
var kodebarang = this.dataset.kodebarang;
fetchDataAndDisplayEditModal(kodebarang);
});
});
closeButton.addEventListener('click', function () {
modal.style.display = 'none';
});
function fetchDataAndDisplayEditModal(kodebarang) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
displayEditModal(data.barang);
} else {
alert("Gagal mengambil data dari server.");
}
}
};
xhr.open('GET', 'get_barangmaster.php?kodebarang=' + encodeURIComponent(kodebarang), true);
xhr.send();
}
function displayEditModal(barang) {
document.getElementById("editNamaBarang").value = barang[0].namabarang;
document.getElementById("editSatuan").value = barang[0].satuan;
editModal.style.display = 'block';
}
function showDetails(barang) {
document.getElementById("namabarangDisplay").textContent = barang[0].namabarang;
modal.style.display = 'block';
}
});
</script>