This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tambah_izin.php
146 lines (145 loc) · 7.83 KB
/
tambah_izin.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
<?php
$page = "Data Izin";
require_once("./header.php");
?>
<div id="layoutSidenav_content">
<main>
<div class="container-fluid">
<h1 class="mt-4">Tambah Data Izin</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="./data_izin.php">Data Izin</a></li>
<li class="breadcrumb-item active">Tambah Data Izin</li>
</ol>
<!-- START MESSAGE -->
<div id="response">
<?php
if (isset($_GET['msg']) && isset($_SERVER['HTTP_REFERER'])) {
if ($_GET['msg'] == 1 && $_SERVER['HTTP_REFERER']) {
?>
<div class="alert alert-success alert-dismissible fade show text-center h4" role="alert">
<strong>Berhasil update data!</strong>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<?php
}
}
?>
</div>
<!-- END MESSAGE -->
<div class="card mb-4">
<div class="card-header">
<i class="fas fa-plus-square mr-1"></i>
Tambah Data Izin
</div>
<div class="card-body">
<form class="mb-5" action="./tambah_izin_post.php" method="POST" id="appsform"
enctype="multipart/form-data">
<div class="form-group row">
<label class="col-sm-4 col-form-label" for="karyawanId">Karyawan Nama</label>
<div class="col-sm-8">
<select class="custom-select" id="karyawanId" name="karyawanId"
autocomplete="off" required>
<?php
$sql = "SELECT `karyawan`.`karyawan_id`, `karyawan`.`karyawan_nama`, `karyawan`.`karyawan_nik` FROM `karyawan`";
$result = $koneksi->query($sql);
if ($result->num_rows > 0) {
echo '<option value="">- Pilih Karyawan -</option>';
while ($row = $result->fetch_assoc()) {
$karyawanID = $row['karyawan_id'];
$karyawanNama = $row['karyawan_nama'];
$karyawanNIK = $row['karyawan_nik'];
echo '<option value="' . $karyawanID . '">' . $karyawanNama . ' - ' . $karyawanNIK . '</option>';
}
} else {
echo '<option value="">- Karyawan Tidak Ditemukan -</option>';
}
?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label" for="keteranganIzin">Keterangan Izin</label>
<div class="col-sm-8">
<select class="custom-select" id="keteranganIzin" name="keteranganIzin" autocomplete="off"
required>
<option value="">- Pilih Keterangan Izin -</option>
<option value="Sakit">Cuti Sakit</option>
<option value="Cuti Hamil">Cuti Hamil</option>
<option value="Cuti Tahunan">Cuti Tahunan</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label" for="izinDari">Dari Tanggal</label>
<div class="col-sm-8">
<input type="date" class="form-control" id="izinDari" name="izinDari"
placeholder="Masukkan Nama Jabatan" autocomplete="off" minlength="2" maxlength="50"
required>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label" for="izinSampai">Sampai Tanggal</label>
<div class="col-sm-8">
<input type="date" class="form-control" id="izinSampai" name="izinSampai"
placeholder="Masukkan Nama Jabatan" autocomplete="off" minlength="2" maxlength="50"
required>
</div>
</div>
<div class="form-group row">
<div class="col-sm-8 ml-auto">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn btn-danger">Reset</button>
</div>
</div>
</form>
</div>
</div>
</div>
</main>
<?php
require_once("./footer.php");
?>
<script>
$(document).ready(function() {
$("form#appsform").submit(function() {
// Karena ada file tidak bisa pakai serialize
// var postdata = $(this).serialize();
var postdata = new FormData(this);
var postaction = $(this).attr('action');
$.ajax({
type: "POST",
url: postaction,
timeout: false,
data: postdata,
contentType: false,
processData: false,
dataType: 'JSON',
success: function(response) {
if (response.status) {
$("#response").html(
'<div class="alert alert-success alert-dismissible fade show text-center h4" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>' +
response.message + '</div>');
$("#appsform")[0].reset();
} else {
$("#response").html(
'<div class="alert alert-danger alert-dismissible fade show text-center h4" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>' +
response.message + '</div>');
}
},
error: function(_, _, errorMessage) {
$("#response").html(
'<div class="alert alert-danger alert-dismissible fade show text-center h4" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>' +
errorMessage + '</div>');
},
beforeSend: function() {
$("#response").html(
'<div class="alert alert-warning alert-dismissible fade show text-center h4" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>Loading...</div>'
);
}
});
return false;
});
});
</script>