<div class="modal" tabindex="-1" role="dialog" id="<?= $id_modal ?>">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<form id="update">
				<div class="modal-header bg-info text-light">
					<h5 class="modal-title">Edit Jenis 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">
					<input type="hidden" name="id_jenis_pelayanan" value="<?= $id_row ?>">
					<div class="row">
						<div class="form-group col-md-12">
							<label for="exampleInputEmail1">Nama Jenis Pelayanan</label>
							<input type="text" class="form-control" id="nama" name="nama" required>
							<!-- <small id="emailHelp" class="form-text text-muted">Data Akan terisi Otomatis.</small> -->
						</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-info"><i class="fas fa-upload"></i> Update</button>
				</div>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	$(document).ready(function() {
		var base_url = "<?= base_url() ?>";
		var id_modal = "<?= $id_modal ?>";
		var id_jenis_pelayanan = "<?= $id_row ?>";

		data_jenis_pelayanan = function() {
			$.ajax({
				url: base_url + 'jenis_pelayanan/ambil_jenis_pelayanan',
				type: "POST",
				dataType: 'json',
				data: {
					id_jenis_pelayanan: id_jenis_pelayanan
				},
				success: function(row) {
					// alert(JSON.stringify(row))
					$("#nama").val(row['nama']);
				}
			})
		}
		data_jenis_pelayanan();
		$("#update").submit(function() {
			var form_data = new FormData($('#update')[0]);
			bootbox.confirm("Apakah Anda Yakin Akan Menyimpan Data?", function(result) {
				if (result == true) {
					$.ajax({
						url: base_url + 'jenis_pelayanan/update_jenis_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"]("Jenis Pelayanan Berhasil Disimpan", "Berhasil");
								getcontens('page/data_jenis_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>