-
Notifications
You must be signed in to change notification settings - Fork 4
/
detail-pengguna.php
171 lines (170 loc) · 6.51 KB
/
detail-pengguna.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
<?php include 'koneksi.php'; ?>
<?php
if($_SESSION['role'] === 'Super Admin'){
$id = $_GET['id'];
$query = $conn->prepare("SELECT * FROM tb_user WHERE id_user = '$id'");
$query->execute();
$row = $query->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include 'menu/head.php'; ?>
</head>
<body>
<div id="app">
<div class="main-wrapper">
<div class="navbar-bg"></div>
<nav class="navbar navbar-expand-lg main-navbar">
<?php include 'menu/nav.php'; ?>
</nav>
<div class="main-sidebar">
<aside id="sidebar-wrapper">
<?php include 'menu/aside.php'; ?>
</aside>
</div>
<div class="main-content">
<section class="section">
<div class="section-header">
<h1>Update Pengguna</h1>
<div class="section-header-breadcrumb">
<div class="breadcrumb-item active"><a href="beranda">Beranda</a></div>
<div class="breadcrumb-item"><a href="pengguna">Pengguna</a></div>
<div class="breadcrumb-item">Update Pengguna</div>
</div>
</div>
<div class="section-body">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form role="form" action="#" method="POST" enctype="multipart/form-data" id="data-form">
<input type="hidden" name="id" value="<?= $row['id_user'] ?>">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="nama">Nama Lengkap</label>
<input type="text" class="form-control" name="nama" id="nama" required="" autocomplete="off" value="<?= $row['nama'] ?>" maxlength="100" autofocus="">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="nip">Nip</label>
<input type="text" class="form-control" name="nip" id="nip" required="" autocomplete="off" value="<?= $row['nip'] ?>" maxlength="100" autofocus="">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="kode">Kode Outlet</label>
<input type="text" class="form-control" name="kode" id="kode" required="" autocomplete="off" value="<?= $row['kode_outlet'] ?>" maxlength="100" autofocus="">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="posisi">Posisi</label>
<select class="form-control select2" name="posisi" id="posisi" required="">
<option value="<?= $row['posisi']?>"><?= $row['posisi'] ?></option>
<?php
$posisi = $conn->prepare("SELECT nama_posisi FROM tb_posisi");
$posisi->execute();
while($data = $posisi->fetch(PDO::FETCH_ASSOC)){
?>
<option value="<?= $data['nama_posisi'] ?>"><?= $data['nama_posisi'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="unit_kerja">Unit Kerja</label>
<select class="form-control select2" name="unit_kerja" id="unit_kerja" required="">
<option value="<?= $row['unit_kerja'] ?>"><?= $row['unit_kerja'] ?></option>
<?php
$posisi = $conn->prepare("SELECT nama_cabang FROM tb_cabang");
$posisi->execute();
while($data = $posisi->fetch(PDO::FETCH_ASSOC)){
?>
<option value="<?= $data['nama_cabang'] ?>"><?= $data['nama_cabang'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="username">Nama Pengguna</label>
<input type="text" class="form-control" name="username" id="username" required="" autocomplete="off" value="<?= $row['username'] ?>" minlength="5" maxlength="20" autofocus="">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="password">Kata Sandi</label>
<input type="text" class="form-control" name="password" id="password" required="" autocomplete="off" value="<?= $row['password'] ?>" minlength="5" maxlength="20" autofocus="">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="level">Role</label>
<select class="form-control select2" name="level" id="level" required="">
<option value="<?= $row['role'] ?>"><?= $row['role'] ?></option>
<option value="Staf/Non Staf">STAF/NON STAF</option>
<option value="Pimpinan Unit">Pimpinan Unit</option>
<option value="Pimpinan Unit">Pimpinan Cabang</option>
<option value="Pimpinan Final">Pimpinan Final</option>
<option value="admin">Administrator</option>
<option value="Super Admin">Super Administrator</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<a href="pengguna" class="btn btn-danger">Kembali</a>
<button type="submit" class="btn btn-primary float-right">Simpan</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<footer class="main-footer">
<?php include 'menu/footer.php'; ?>
</footer>
</div>
</div>
<?php include 'menu/script.php'; ?>
<script type="text/javascript">
$(document).ready(function() {
$("#data-form").submit(function(e) {
e.preventDefault();
var data = new FormData(this);
$.ajax({
type: "POST",
url: "proses/update-pengguna.php",
data: data,
processData: false,
contentType: false,
success: function(response) {
var dataresponse = JSON.parse(response);
console.log(dataresponse);
if(dataresponse.status == "1") {
window.location.href='pengguna'
}else {
swal('Peringatan', 'Kesalahan dalam sebuah query', 'error');
}
}
});
return false;
});
});
</script>
</body>
</html>
<?php
} else {
header("Location: beranda");
}
?>