-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransaksi_edit.php
264 lines (234 loc) · 10.2 KB
/
transaksi_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
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
<?php
//cek session
session_start();
require_once 'config/config.php';
if (empty($_SESSION['loggedin'])) {
header("Location: ./");
die();
} else {
if (!isset($_GET['id_transaksi'])) {
header('Location: transaksi.php');
}
$id_transaksi = $_GET['id_transaksi'];
$sql = "SELECT * FROM view_transaksi WHERE id_transaksi=$id_transaksi";
$query = mysqli_query($db, $sql);
$sql2 = "SELECT * FROM view_transaksi_detail WHERE id_transaksi=$id_transaksi";
$query2 = mysqli_query($db, $sql2);
$query3 = mysqli_query($db, "SELECT sum(harga_paket) as harga_paket FROM view_transaksi_detail WHERE id_transaksi = $id_transaksi");
$query4 = mysqli_query($db, "SELECT count(harga_paket) as c_hargapaket FROM view_transaksi_detail WHERE id_transaksi = $id_transaksi");
$transaksi = mysqli_fetch_assoc($query);
$transaksi2 = mysqli_fetch_assoc($query2);
$data3 = mysqli_fetch_array($query3);
$data4 = mysqli_fetch_array($query4);
if (mysqli_num_rows($query) < 1){
header("Location: transaksi.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<?php include('_partials/head.php'); ?>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<?php include('_partials/navbar.php'); ?>
<?php include('_partials/sidebar.php'); ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Transaksi Cucian
</h1>
<ol class="breadcrumb">
<li><a href="dashboard.php"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li><a href="transaksi.php">Transaksi Cucian</a></li>
<li class="active">Edit Data Transaksi Cucian</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<?php if (isset($_SESSION['error'])) : ?>
<p>
<?php
$error = $_SESSION['error'];
if ($error) {
?>
<div id="errorMessage" class="alert alert-danger" role="alert">
<i class="fa fa-exclamation-circle"></i> <?=$error;?>
</div>
<?php
}
?>
</p>
<?php
unset($_SESSION['error']);
endif;
?>
<div class="row">
<!-- left column -->
<div class="col-md-12">
<!-- general form elements -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Edit Data Transaksi Cucian</h3>
</div>
<!-- /.box-header -->
<!-- form start -->
<form method="post" action="transaksi_edit_process.php" role="form">
<input type="hidden" name="id_transaksi" value="<?=$transaksi['id_transaksi'];?>" />
<?php
mysqli_data_seek($query2, 0);
$row = mysqli_fetch_array($query2);
?>
<input type="hidden" name="id_transaksidetail" value="<?=$row['id_transaksi_detail'];?>" />
<?php
mysqli_data_seek($query2, 1);
$row = mysqli_fetch_array($query2);
?>
<input type="hidden" name="id_transaksidetail2" value="<?=$row['id_transaksi_detail'];?>" />
<div class="box-body">
<div class="form-group">
<div class="row">
<div class="col-md-4">
<label>Nama Pelanggan</label>
<input type="text" class="form-control" name="nama_pelanggan" value="<?=$transaksi['nama_pelanggan'];?>" readonly="">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>Tipe Mobil</label>
<input type="text" class="form-control" placeholder="Tipe Mobil" name="tipe_mobil" value="<?=$transaksi['tipe_mobil'];?>" readonly="">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>NOPOL</label>
<input type="text" class="form-control" placeholder="NOPOL" name="nopol" value="<?=$transaksi['nopol'];?>" readonly="">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-4">
<label>Paket</label>
<select class="form-control" id="paket" name="paket" required="">
<?php
mysqli_data_seek($query2, 0);
$row = mysqli_fetch_array($query2);
?>
<option value="<?=$row['id_paket'];?>"><?=$row['nama_paket'];?></option>
<?php
$q = mysqli_query($db, "SELECT * FROM tb_paket ORDER BY paket ASC");
while($data = mysqli_fetch_array($q)){
echo '<option value="'.$data['id_paket'].'">'.$data['paket'].'</option>';
}
?>
</select>
</div>
</div>
</div>
<?php if ($data4['c_hargapaket'] == 1) { ?>
<div class="form-group hint">
<div class="row">
<div class="col-md-4">
<select class="form-control" id="paket2" name="paket2">
<option value="">Pilih Paket</option>
<?php
$q = mysqli_query($db, "SELECT * FROM tb_paket ORDER BY paket ASC");
while($data = mysqli_fetch_array($q)){
echo '<option value="'.$data['id_paket'].'">'.$data['paket'].'</option>';
}
?>
</select>
</div>
</div>
</div>
<!-- <div class="form-group">
<div class="row">
<div class="col-md-4">
<button id="button" type="button" class="btn btn-warning">Ada Paket Lainnya?</button>
</div>
</div>
</div> -->
<?php } else { ?>
<div class="form-group">
<div class="row">
<div class="col-md-4">
<select class="form-control" id="paket2" name="paket2">
<?php
mysqli_data_seek($query2, 1);
$row = mysqli_fetch_array($query2);
?>
<option value="<?=$row['id_paket'];?>"><?=$row['nama_paket'];?></option>
<?php
$q = mysqli_query($db, "SELECT * FROM tb_paket ORDER BY paket ASC");
while($data = mysqli_fetch_array($q)){
echo '<option value="'.$data['id_paket'].'">'.$data['paket'].'</option>';
}
?>
</select>
</div>
</div>
</div>
<?php } ?>
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>Biaya</label>
<input type="text" class="form-control biaya" id="biaya" name="biaya" value="<?='Rp ' . number_format($data3['harga_paket'], 0, ",", ".");?>" readonly="">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>Bayar</label>
<input type="text" class="form-control mata-uang" id="bayar" placeholder="Bayar" name="bayar" value="<?=number_format($transaksi2['bayar'], 0, ",", ".");?>" required="">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>Kembalian</label>
<input type="text" class="form-control kembali" id="kembali" name="kembali" value="<?=number_format($transaksi2['bayar'] - $data3['harga_paket'], 0, ",", ".");?>" readonly="">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-5">
<label>Total Bayar</label>
<input type="text" class="form-control total" id="total" name="total" value="<?='Rp ' . number_format($data3['harga_paket'], 0, ",", ".");?>" readonly="">
</div>
</div>
</div>
<input type="submit" value="Simpan Data" class="btn btn-success" name="simpan" />
<a class="btn btn-default" href="transaksi.php">Kembali</a>
</div>
<!-- /.box-body -->
</form>
</div>
<!-- /.box -->
</div>
<!-- /.col-lg-6 -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php include('_partials/footer.php'); ?>
</div>
<!-- ./wrapper -->
<?php include('_partials/modal.php'); ?>
<?php include('_partials/js.php'); ?>
<?php include('_partials/ajax.php'); ?>
</body>
</html>
<?php
}
?>