-
Notifications
You must be signed in to change notification settings - Fork 37
/
tambah_disposisi.php
216 lines (196 loc) · 11.7 KB
/
tambah_disposisi.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
<?php
//cek session
if(empty($_SESSION['admin'])){
$_SESSION['err'] = '<center>Anda harus login terlebih dahulu!</center>';
header("Location: ./");
die();
} else {
if(isset($_REQUEST['submit'])){
$id_surat = $_REQUEST['id_surat'];
$query = mysqli_query($config, "SELECT * FROM tbl_surat_masuk WHERE id_surat='$id_surat'");
$no = 1;
list($id_surat) = mysqli_fetch_array($query);
//validasi form kosong
if($_REQUEST['tujuan'] == "" || $_REQUEST['isi_disposisi'] == "" || $_REQUEST['sifat'] == "" || $_REQUEST['batas_waktu'] == ""
|| $_REQUEST['catatan'] == ""){
$_SESSION['errEmpty'] = 'ERROR! Semua form wajib diisi';
echo '<script language="javascript">window.history.back();</script>';
} else {
$tujuan = $_REQUEST['tujuan'];
$isi_disposisi = $_REQUEST['isi_disposisi'];
$sifat = $_REQUEST['sifat'];
$batas_waktu = $_REQUEST['batas_waktu'];
$catatan = $_REQUEST['catatan'];
$id_user = $_SESSION['id_user'];
//validasi input data
if(!preg_match("/^[a-zA-Z0-9.,()\/ -]*$/", $tujuan)){
$_SESSION['tujuan'] = 'Form Tujuan Disposisi hanya boleh mengandung karakter huruf, angka, spasi, titik(.), koma(,) minus(-). kurung() dan garis miring(/)';
echo '<script language="javascript">window.history.back();</script>';
} else {
if(!preg_match("/^[a-zA-Z0-9.,_()%&@\/\r\n -]*$/", $isi_disposisi)){
$_SESSION['isi_disposisi'] = 'Form Isi Disposisi hanya boleh mengandung karakter huruf, angka, spasi, titik(.), koma(,), minus(-), garis miring(/), dan(&), underscore(_), kurung(), persen(%) dan at(@)';
echo '<script language="javascript">window.history.back();</script>';
} else {
if(!preg_match("/^[0-9 -]*$/", $batas_waktu)){
$_SESSION['batas_waktu'] = 'Form Batas Waktu hanya boleh mengandung karakter huruf dan minus(-)<br/>';
echo '<script language="javascript">window.history.back();</script>';
} else {
if(!preg_match("/^[a-zA-Z0-9.,()%@\/ -]*$/", $catatan)){
$_SESSION['catatan'] = 'Form catatan hanya boleh mengandung karakter huruf, angka, spasi, titik(.), koma(,), minus(-) garis miring(/), dan kurung()';
echo '<script language="javascript">window.history.back();</script>';
} else {
if(!preg_match("/^[a-zA-Z0 ]*$/", $sifat)){
$_SESSION['sifat'] = 'Form SIFAT hanya boleh mengandung karakter huruf dan spasi';
echo '<script language="javascript">window.history.back();</script>';
} else {
$query = mysqli_query($config, "INSERT INTO tbl_disposisi(tujuan,isi_disposisi,sifat,batas_waktu,catatan,id_surat,id_user)
VALUES('$tujuan','$isi_disposisi','$sifat','$batas_waktu','$catatan','$id_surat','$id_user')");
if($query == true){
$_SESSION['succAdd'] = 'SUKSES! Data berhasil ditambahkan';
echo '<script language="javascript">
window.location.href="./admin.php?page=tsm&act=disp&id_surat='.$id_surat.'";
</script>';
} else {
$_SESSION['errQ'] = 'ERROR! Ada masalah dengan query';
echo '<script language="javascript">window.history.back();</script>';
}
}
}
}
}
}
}
} else {?>
<!-- Row Start -->
<div class="row">
<!-- Secondary Nav START -->
<div class="col s12">
<nav class="secondary-nav">
<div class="nav-wrapper blue-grey darken-1">
<ul class="left">
<li class="waves-effect waves-light"><a href="#" class="judul"><i class="material-icons">description</i> Tambah Disposisi Surat</a></li>
</ul>
</div>
</nav>
</div>
<!-- Secondary Nav END -->
</div>
<!-- Row END -->
<?php
if(isset($_SESSION['errQ'])){
$errQ = $_SESSION['errQ'];
echo '<div id="alert-message" class="row">
<div class="col m12">
<div class="card red lighten-5">
<div class="card-content notif">
<span class="card-title red-text"><i class="material-icons md-36">clear</i> '.$errQ.'</span>
</div>
</div>
</div>
</div>';
unset($_SESSION['errQ']);
}
if(isset($_SESSION['errEmpty'])){
$errEmpty = $_SESSION['errEmpty'];
echo '<div id="alert-message" class="row">
<div class="col m12">
<div class="card red lighten-5">
<div class="card-content notif">
<span class="card-title red-text"><i class="material-icons md-36">clear</i> '.$errEmpty.'</span>
</div>
</div>
</div>
</div>';
unset($_SESSION['errEmpty']);
}
?>
<!-- Row form Start -->
<div class="row jarak-form">
<!-- Form START -->
<form class="col s12" method="post" action="">
<!-- Row in form START -->
<div class="row">
<div class="input-field col s6">
<i class="material-icons prefix md-prefix">place</i>
<input id="tujuan" type="text" class="validate" name="tujuan" required>
<?php
if(isset($_SESSION['tujuan'])){
$tujuan = $_SESSION['tujuan'];
echo '<div id="alert-message" class="callout bottom z-depth-1 red lighten-4 red-text">'.$tujuan.'</div>';
unset($_SESSION['tujuan']);
}
?>
<label for="tujuan">Tujuan Disposisi</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix md-prefix">alarm</i>
<input id="batas_waktu" type="text" name="batas_waktu" class="datepicker" required>
<?php
if(isset($_SESSION['batas_waktu'])){
$batas_waktu = $_SESSION['batas_waktu'];
echo '<div id="alert-message" class="callout bottom z-depth-1 red lighten-4 red-text">'.$batas_waktu.'</div>';
unset($_SESSION['batas_waktu']);
}
?>
<label for="batas_waktu">Batas Waktu</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix md-prefix">description</i>
<textarea id="isi_disposisi" class="materialize-textarea validate" name="isi_disposisi" required></textarea>
<?php
if(isset($_SESSION['isi_disposisi'])){
$isi_disposisi = $_SESSION['isi_disposisi'];
echo '<div id="alert-message" class="callout bottom z-depth-1 red lighten-4 red-text">'.$isi_disposisi.'</div>';
unset($_SESSION['isi_disposisi']);
}
?>
<label for="isi_disposisi">Isi Disposisi</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix md-prefix">featured_play_list </i>
<input id="catatan" type="text" class="validate" name="catatan" required>
<?php
if(isset($_SESSION['catatan'])){
$catatan = $_SESSION['catatan'];
echo '<div id="alert-message" class="callout bottom z-depth-1 red lighten-4 red-text">'.$catatan.'</div>';
unset($_SESSION['catatan']);
}
?>
<label for="catatan">Catatan</label>
</div>
<div class="input-field col s6">
<i class="material-icons prefix md-prefix">low_priority</i><label>Pilih Sifat Disposisi</label><br/>
<div class="input-field col s11 right">
<select class="browser-default validate" name="sifat" id="sifat" required>
<option value="Biasa">Biasa</option>
<option value="Penting">Penting</option>
<option value="Segera">Segera</option>
<option value="Rahasia">Rahasia</option>
</select>
</div>
<?php
if(isset($_SESSION['sifat'])){
$sifat = $_SESSION['sifat'];
echo '<div id="alert-message" class="callout bottom z-depth-1 red lighten-4 red-text">'.$sifat.'</div>';
unset($_SESSION['sifat']);
}
?>
</div>
</div>
<!-- Row in form END -->
<div class="row">
<div class="col 6">
<button type="submit" name ="submit" class="btn-large blue waves-effect waves-light">SIMPAN <i class="material-icons">done</i></button>
</div>
<div class="col 6">
<button type="reset" onclick="window.history.back();" class="btn-large deep-orange waves-effect waves-light">BATAL <i class="material-icons">clear</i></button>
</div>
</div>
</form>
<!-- Form END -->
</div>
<!-- Row form END -->
<?php
}
}
?>