-
Notifications
You must be signed in to change notification settings - Fork 2
/
transaksi_surat_masuk.php
344 lines (318 loc) · 21.6 KB
/
transaksi_surat_masuk.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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<?php
//cek session
if(empty($_SESSION['admin'])){
$_SESSION['err'] = '<center>Anda harus login terlebih dahulu!</center>';
header("Location: ./");
die();
} else {
if($_SESSION['admin'] != 1 AND $_SESSION['admin'] != 3){
echo '<script language="javascript">
window.alert("ERROR! Anda tidak memiliki hak akses untuk membuka halaman ini");
window.location.href="./logout.php";
</script>';
} else {
if(isset($_REQUEST['act'])){
$act = $_REQUEST['act'];
switch ($act) {
case 'add':
include "tambah_surat_masuk.php";
break;
case 'edit':
include "edit_surat_masuk.php";
break;
case 'disp':
include "disposisi.php";
break;
case 'print':
include "cetak_disposisi.php";
break;
case 'del':
include "hapus_surat_masuk.php";
break;
}
} else {
$query = mysqli_query($config, "SELECT surat_masuk FROM tbl_sett");
list($surat_masuk) = mysqli_fetch_array($query);
//pagging
$limit = $surat_masuk;
$pg = @$_GET['pg'];
if(empty($pg)){
$curr = 0;
$pg = 1;
} else {
$curr = ($pg - 1) * $limit;
}?>
<!-- Row Start -->
<div class="row">
<!-- Secondary Nav START -->
<div class="col s12">
<div class="z-depth-1">
<nav class="secondary-nav">
<div class="nav-wrapper blue-grey darken-1">
<div class="col m7">
<ul class="left">
<li class="waves-effect waves-light hide-on-small-only"><a href="?page=tsm" class="judul"><i class="material-icons">mail</i> Surat Masuk</a></li>
<li class="waves-effect waves-light">
<a href="?page=tsm&act=add"><i class="material-icons md-24">add_circle</i> Tambah Data</a>
</li>
</ul>
</div>
<div class="col m5 hide-on-med-and-down">
<form method="post" action="?page=tsm">
<div class="input-field round-in-box">
<input id="search" type="search" name="cari" placeholder="Ketik dan tekan enter mencari data..." required>
<label for="search"><i class="material-icons md-dark">search</i></label>
<input type="submit" name="submit" class="hidden">
</div>
</form>
</div>
</div>
</nav>
</div>
</div>
<!-- Secondary Nav END -->
</div>
<!-- Row END -->
<?php
if(isset($_SESSION['succAdd'])){
$succAdd = $_SESSION['succAdd'];
echo '<div id="alert-message" class="row">
<div class="col m12">
<div class="card green lighten-5">
<div class="card-content notif">
<span class="card-title green-text"><i class="material-icons md-36">done</i> '.$succAdd.'</span>
</div>
</div>
</div>
</div>';
unset($_SESSION['succAdd']);
}
if(isset($_SESSION['succEdit'])){
$succEdit = $_SESSION['succEdit'];
echo '<div id="alert-message" class="row">
<div class="col m12">
<div class="card green lighten-5">
<div class="card-content notif">
<span class="card-title green-text"><i class="material-icons md-36">done</i> '.$succEdit.'</span>
</div>
</div>
</div>
</div>';
unset($_SESSION['succEdit']);
}
if(isset($_SESSION['succDel'])){
$succDel = $_SESSION['succDel'];
echo '<div id="alert-message" class="row">
<div class="col m12">
<div class="card green lighten-5">
<div class="card-content notif">
<span class="card-title green-text"><i class="material-icons md-36">done</i> '.$succDel.'</span>
</div>
</div>
</div>
</div>';
unset($_SESSION['succDel']);
}
?>
<!-- Row form Start -->
<div class="row jarak-form">
<?php
if(isset($_REQUEST['submit'])){
$cari = mysqli_real_escape_string($config, $_REQUEST['cari']);
echo '
<div class="col s12" style="margin-top: -18px;">
<div class="card blue lighten-5">
<div class="card-content">
<p class="description">Hasil pencarian untuk kata kunci <strong>"'.stripslashes($cari).'"</strong><span class="right"><a href="?page=tsm"><i class="material-icons md-36" style="color: #333;">clear</i></a></span></p>
</div>
</div>
</div>
<div class="col m12" id="colres">
<table class="bordered" id="tbl">
<thead class="blue lighten-4" id="head">
<tr>
<th width="10%">No. Agenda<br/>Kode</th>
<th width="30%">Isi Ringkas<br/> File</th>
<th width="24%">Asal Surat</th>
<th width="18%">No. Surat<br/>Tgl Surat</th>
<th width="18%">Tindakan <span class="right"><i class="material-icons" style="color: #333;">settings</i></span></th>
</tr>
</thead>
<tbody>';
//script untuk mencari data
$query = mysqli_query($config, "SELECT * FROM tbl_surat_masuk WHERE isi LIKE '%$cari%' ORDER by id_surat DESC LIMIT 15");
if(mysqli_num_rows($query) > 0){
$no = 1;
while($row = mysqli_fetch_array($query)){
echo '
<tr>
<td>'.$row['no_agenda'].'<br/><hr/>'.$row['kode'].'</td>
<td>'.substr($row['isi'],0,200).'<br/><br/><strong>File :</strong>';
if(!empty($row['file'])){
echo ' <strong><a href="?page=gsm&act=fsm&id_surat='.$row['id_surat'].'">'.$row['file'].'</a></strong>';
} else {
echo '<em>Tidak ada file yang di upload</em>';
} echo '</td>
<td>'.$row['asal_surat'].'</td>
<td>'.$row['no_surat'].'<br/><hr/>'.indoDate($row['tgl_surat']).'</td>
<td>';
if($_SESSION['id_user'] != $row['id_user'] AND $_SESSION['id_user'] != 1){
echo '<a class="btn small yellow darken-3 waves-effect waves-light" href="?page=ctk&id_surat='.$row['id_surat'].'" target="_blank">
<i class="material-icons">print</i> PRINT</a>';
} else {
echo '<a class="btn small blue waves-effect waves-light" href="?page=tsm&act=edit&id_surat='.$row['id_surat'].'">
<i class="material-icons">edit</i> EDIT</a>
<a class="btn small light-green waves-effect waves-light tooltipped" data-position="left" data-tooltip="Pilih Disp untuk menambahkan Disposisi Surat" href="?page=tsm&act=disp&id_surat='.$row['id_surat'].'">
<i class="material-icons">description</i> DISP</a>
<a class="btn small yellow darken-3 waves-effect waves-light" href="?page=ctk&id_surat='.$row['id_surat'].'" target="_blank">
<i class="material-icons">print</i> PRINT</a>
<a class="btn small deep-orange waves-effect waves-light" href="?page=tsm&act=del&id_surat='.$row['id_surat'].'">
<i class="material-icons">delete</i> DEL</a>';
} echo '
</td>
</tr>';
}
} else {
echo '<tr><td colspan="5"><center><p class="add">Tidak ada data yang ditemukan</p></center></td></tr>';
}
echo '</tbody></table><br/><br/>
</div>
</div>
<!-- Row form END -->';
} else {
echo '
<div class="col m12" id="colres">
<table class="bordered" id="tbl">
<thead class="blue lighten-4" id="head">
<tr>
<th width="10%">No. Agenda<br/>Kode</th>
<th width="30%">Isi Ringkas<br/> File</th>
<th width="24%">Asal Surat</th>
<th width="18%">No. Surat<br/>Tgl Surat</th>
<th width="18%">Tindakan <span class="right tooltipped" data-position="left" data-tooltip="Atur jumlah data yang ditampilkan"><a class="modal-trigger" href="#modal"><i class="material-icons" style="color: #333;">settings</i></a></span></th>
<div id="modal" class="modal">
<div class="modal-content white">
<h5>Jumlah data yang ditampilkan per halaman</h5>';
$query = mysqli_query($config, "SELECT id_sett,surat_masuk FROM tbl_sett");
list($id_sett,$surat_masuk) = mysqli_fetch_array($query);
echo '
<div class="row">
<form method="post" action="">
<div class="input-field col s12">
<input type="hidden" value="'.$id_sett.'" name="id_sett">
<div class="input-field col s1" style="float: left;">
<i class="material-icons prefix md-prefix">looks_one</i>
</div>
<div class="input-field col s11 right" style="margin: -5px 0 20px;">
<select class="browser-default validate" name="surat_masuk" required>
<option value="'.$surat_masuk.'">'.$surat_masuk.'</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
<div class="modal-footer white">
<button type="submit" class="modal-action waves-effect waves-green btn-flat" name="simpan">Simpan</button>';
if(isset($_REQUEST['simpan'])){
$id_sett = "1";
$surat_masuk = $_REQUEST['surat_masuk'];
$id_user = $_SESSION['id_user'];
$query = mysqli_query($config, "UPDATE tbl_sett SET surat_masuk='$surat_masuk',id_user='$id_user' WHERE id_sett='$id_sett'");
if($query == true){
header("Location: ./admin.php?page=tsm");
die();
}
} echo '
<a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Batal</a>
</div>
</div>
</form>
</div>
</div>
</div>
</tr>
</thead>
<tbody>';
//script untuk menampilkan data
$query = mysqli_query($config, "SELECT * FROM tbl_surat_masuk ORDER by id_surat DESC LIMIT $curr, $limit");
if(mysqli_num_rows($query) > 0){
$no = 1;
while($row = mysqli_fetch_array($query)){
echo '
<tr>
<td>'.$row['no_agenda'].'<br/><hr/>'.$row['kode'].'</td>
<td>'.substr($row['isi'],0,200).'<br/><br/><strong>File :</strong>';
if(!empty($row['file'])){
echo ' <strong><a href="?page=gsm&act=fsm&id_surat='.$row['id_surat'].'">'.$row['file'].'</a></strong>';
} else {
echo '<em>Tidak ada file yang di upload</em>';
} echo '</td>
<td>'.$row['asal_surat'].'</td>
<td>'.$row['no_surat'].'<br/><hr/>'.indoDate($row['tgl_surat']).'</td>
<td>';
if($_SESSION['id_user'] != $row['id_user'] AND $_SESSION['id_user'] != 1){
echo '<a class="btn small yellow darken-3 waves-effect waves-light" href="?page=ctk&id_surat='.$row['id_surat'].'" target="_blank">
<i class="material-icons">print</i> PRINT</a>';
} else {
echo '<a class="btn small blue waves-effect waves-light" href="?page=tsm&act=edit&id_surat='.$row['id_surat'].'">
<i class="material-icons">edit</i> EDIT</a>
<a class="btn small light-green waves-effect waves-light tooltipped" data-position="left" data-tooltip="Pilih Disp untuk menambahkan Disposisi Surat" href="?page=tsm&act=disp&id_surat='.$row['id_surat'].'">
<i class="material-icons">description</i> DISP</a>
<a class="btn small yellow darken-3 waves-effect waves-light" href="?page=ctk&id_surat='.$row['id_surat'].'" target="_blank">
<i class="material-icons">print</i> PRINT</a>
<a class="btn small deep-orange waves-effect waves-light" href="?page=tsm&act=del&id_surat='.$row['id_surat'].'">
<i class="material-icons">delete</i> DEL</a>';
} echo '
</td>
</tr>';
}
} else {
echo '<tr><td colspan="5"><center><p class="add">Tidak ada data untuk ditampilkan. <u><a href="?page=tsm&act=add">Tambah data baru</a></u></p></center></td></tr>';
}
echo '</tbody></table>
</div>
</div>
<!-- Row form END -->';
$query = mysqli_query($config, "SELECT * FROM tbl_surat_masuk");
$cdata = mysqli_num_rows($query);
$cpg = ceil($cdata/$limit);
echo '<br/><!-- Pagination START -->
<ul class="pagination">';
if($cdata > $limit ){
//first and previous pagging
if($pg > 1){
$prev = $pg - 1;
echo '<li><a href="?page=tsm&pg=1"><i class="material-icons md-48">first_page</i></a></li>
<li><a href="?page=tsm&pg='.$prev.'"><i class="material-icons md-48">chevron_left</i></a></li>';
} else {
echo '<li class="disabled"><a href="#"><i class="material-icons md-48">first_page</i></a></li>
<li class="disabled"><a href="#"><i class="material-icons md-48">chevron_left</i></a></li>';
}
//perulangan pagging
for ($i = 1; $i <= $cpg; $i++) {
if ((($i >= $pg - 3) && ($i <= $pg + 3)) || ($i == 1) || ($i == $cpg)) {
if ($i == $pg) echo '<li class="active waves-effect waves-dark"><a href="?page=tsm&pg='.$i.'"> '.$i.' </a></li>';
else echo '<li class="waves-effect waves-dark"><a href="?page=tsm&pg='.$i.'"> '.$i.' </a></li>';
}
}
//last and next pagging
if($pg < $cpg){
$next = $pg + 1;
echo '<li><a href="?page=tsm&pg='.$next.'"><i class="material-icons md-48">chevron_right</i></a></li>
<li><a href="?page=tsm&pg='.$cpg.'"><i class="material-icons md-48">last_page</i></a></li>';
} else {
echo '<li class="disabled"><a href="#"><i class="material-icons md-48">chevron_right</i></a></li>
<li class="disabled"><a href="#"><i class="material-icons md-48">last_page</i></a></li>';
}
echo '
</ul>';
} else {
echo '';
}
}
}
}
}
?>