<div class="modal" tabindex="-1" role="dialog" id="<?= $id_modal ?>">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<form id="tambah">
				<div class="modal-header bg-primary text-light">
					<h5 class="modal-title">Tambah Pelayanan</h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<div class="modal-body">
					<div class="row">
						<div class="form-group col-md-12">
							<label for="exampleInputEmail1">Nama Pelayanan</label>
							<input type="text" class="form-control" id="nama" name="nama" required>
						</div>
						<div class="form-group col-md-12">
							<label for="jenis_pelayanan_id">Jenis Pelayanan</label>
							<select class="form-control" id="jenis_pelayanan_id" name="jenis_pelayanan_id" required>
								<option value="">Pilih Jenis Pelayanan</option>
								<?php foreach ($jenis_pelayanan as $jp): ?>
									<option value="<?= $jp->id_jenis_pelayanan ?>"><?= $jp->nama ?></option>
								<?php endforeach; ?>
							</select>
						</div>
						<div class="form-group col-md-12">
							<label for="stipendium">Stipendium</label>
							<input type="number" class="form-control" id="stipendium" name="stipendium" step="0.01" placeholder="Masukkan stipendium" required>
						</div>
						<div class="form-group col-md-12">
							<label for="stipendium_daring">Stipendium Daring</label>
							<input type="number" class="form-control" id="stipendium_daring" name="stipendium_daring" step="0.01" placeholder="Masukkan stipendium daring" required>
						</div>
						<div class="form-group col-md-12">
							<label for="keterangan">Keterangan</label>
							<textarea class="form-control" id="keterangan" name="keterangan" rows="3" placeholder="Masukkan keterangan"></textarea>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>
					<button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> Simpan</button>
				</div>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	$(document).ready(function() {
		var base_url = "<?= base_url() ?>";
		var id_modal = "<?= $id_modal ?>";

		$("#tambah").submit(function() {
			var form_data = new FormData($('#tambah')[0]);
			bootbox.confirm("Apakah Anda Yakin Akan Menyimpan Data?", function(result) {
				if (result == true) {
					$.ajax({
						url: base_url + 'pelayanan/simpan_pelayanan',
						type: "POST",
						dataType: 'json',
						mimeType: 'multipart/form-data',
						data: form_data,
						contentType: false,
						cache: false,
						processData: false,
						success: function(response) {
							// alert(response)
							if (response == true) {
								$('#' + id_modal).modal('hide');
								Command: toastr["success"]("Data Pelayanan Berhasil Disimpan", "Berhasil");
								getcontens('page/data_pelayanan');
							} else {
								Command: toastr["error"]("Simpan error, data tidak berhasil disimpan", "Error");
							}
						},
						error: function(jqXHR, textStatus, errorThrown) {
							$('#loading').modal('hide');
							Command: toastr["error"](errorThrown, "Error");
						},
						beforeSend: function() {
							$('#loading').modal('show');
						},
						complete: function() {
							$('#loading').modal('hide');
						}
					});
				}
			});
			return false;
		})
	})
</script>