@extends('base.layout')

@section('content')
<div class="wrapper">
	<div class="container-fluid">
		<div class="row">
			<div class="col-lg-7">
				<div class="card-box ribbon-box">
					<div class="ribbon ribbon-primary">Request List</div>
					<p class="m-b-0"></p>
					<button type="button" class="btn btn-custom waves-light waves-effect" data-toggle="modal" data-target="#addModalPoli">Add New</button>
					<br><br>
					<div id="gridpoli"></div>
				</div>
			</div>
			<div class="col-lg-5">
				<div class="card-box ribbon-box">
					<div class="ribbon ribbon-danger">Rooms List</div>
					<p class="m-b-0"></p>
					<button type="button" class="btn btn-custom waves-light waves-effect" data-toggle="modal" data-target="#addModalRuangan">Add New</button>
					<br><br>
					<div id="gridruangan"></div>
				</div>
			</div>
			<div class="col-lg-5">
				<div class="card-box ribbon-box">
					<div class="ribbon ribbon-danger">Specimen List</div>
					<p class="m-b-0"></p>
					<button type="button" class="btn btn-custom waves-light waves-effect" id="btnaddModalSpecimen">Add New</button>
					<br><br>
					<div id="gridbakteri"></div>
				</div>
			</div>
		</div>
		<!-- end row -->
	</div> <!-- end container -->
</div>
<!-- Add Modal Poli -->
<div id="addModalPoli" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h4 class="modal-title" id="myModalLabel">Add New Services</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal">
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Category</label>
							<input class="form-control" type="text" name="add_poli" id="add_poli" value="Mikrobiologi">
						</div>
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Request Name</label>
							<input class="form-control" type="text" name="add_subpoli" id="add_subpoli" required="">
						</div>
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Header</label>
							<input class="form-control" type="text" id="add_modaliti" name="add_modaliti">
						</div>
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Footer</label>
							<input class="form-control" type="text" id="add_subsubpoli" name="add_subsubpoli">
						</div>
					</div>
					<div class="form-group account-btn text-center m-t-10">
						<div class="col-12">
							<button class="btn w-lg btn-custom waves-effect waves-light" id="btnAddPoli" type="button">Save</button>
						</div>
					</div>
				</form>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>
<!-- Update Modal Poli -->
<div id="updateModalPoli" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h4 class="modal-title" id="myModalLabel">Update Services Name</h4>
			</div>
			<div class="modal-body">
			<form class="form-horizontal">
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Category</label>
							<input class="form-control" type="text" name="poli" id="poli" required="">
						</div>
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Request Name</label>
							<input class="form-control" type="text" id="subpoli" name="subpoli" required="">
						</div>
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Header</label>
							<input class="form-control" type="text" id="modaliti" name="modaliti">
						</div>
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Footer</label>
							<input class="form-control" type="text" id="subsubpoli" name="subsubpoli">
						</div>
					</div>
					<input type="hidden" id="id_poli" name="id_poli">
					<div class="form-group account-btn text-center m-t-10">
						<div class="col-12">
							<button class="btn w-lg btn-custom waves-effect waves-light" id="btnUpdatePoli" type="button">Update</button>
						</div>
					</div>
				</form>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>
<!-- Add Modal Ruangan -->
<div id="addModalRuangan" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h4 class="modal-title" id="myModalLabel">Form Add New Rooms</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal">
					<div class="col-12">
						<label>Clinic</label>
						<input class="form-control" type="text" name="poli" id="add_idruangan" required="">
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Rooms Name</label>
							<input class="form-control" type="text" id="add_ruangan" name="ruangan" required="">
						</div>
					</div>
					<div class="form-group account-btn text-center m-t-10">
						<div class="col-12">
							<button class="btn w-lg btn-custom waves-effect waves-light" id="btnAddRuangan" type="button">Save</button>
						</div>
					</div>
				</form>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>
<!-- Update Modal Ruangan -->
<div id="updateModalRuangan" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h4 class="modal-title" id="myModalLabel">Update Rooms</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal">
					<div class="col-12">
						<label>Clinic</label>
						<input class="form-control" type="text" name="poli" id="poli_ruangan" required="">
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Rooms Name</label>
							<input class="form-control" type="text" id="ruangan" name="ruangan" required="">
						</div>
					</div>
					<input type="hidden" id="id_ruangan" name="id_ruangan">
					<div class="form-group account-btn text-center m-t-10">
						<div class="col-12">
							<button class="btn w-lg btn-custom waves-effect waves-light" id="btnUpdateRuangan" type="button">Update</button>
						</div>
					</div>
				</form>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>
<div id="ModalMikroandBakteri" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h4 class="modal-title" id="myModalLabel">Editor Data</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal">
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Name</label>
							<input type="text" class="form-control" id="mb_name">
						</div>
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Category Name</label>
							<input type="text" class="form-control" id="mb_kategori">
						</div>
					</div>
					<div class="form-group account-btn text-center m-t-10">
						<div class="col-12">
							<input type="hidden" class="form-control" id="mb_id">
							<input type="hidden" class="form-control" id="mb_kelompok">
							<button class="btn w-lg btn-custom waves-effect waves-light" id="btnAddMB" type="button">Save</button>
						</div>
					</div>
				</form>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>
<div id="ModalSpecimen" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h4 class="modal-title" id="myModalLabel">Editor Data Specimen</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal">
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Name</label>
							<input type="text" class="form-control" id="sp_name">
						</div>
					</div>
					<div class="form-group m-b-25">
						<div class="col-12">
							<label>Category Name</label>
							<input type="text" class="form-control" id="sp_kategori">
						</div>
					</div>
					<div class="form-group">
						<label>Target Selesai</label>
						<div class="form-group m-b-25">
							<div class="col-6">
								<label>Satuan</label>
								<select class="form-control" id="sp_satuan" name="sp_satuan">
									<option value="Jam">Jam</option>
									<option value="Hari">Hari</option>
									<option value="Minggu">Minggu</option>
									<option value="Bulan">Bulan</option>
								</select>
							</div>
							<div class="col-6">
								<label>Nilai</label>
								<input type="number" class="form-control" id="sp_nilai" placeholder="Hanya Angka">
							</div>
						</div>
					</div>
					<div class="form-group account-btn text-center m-t-10">
						<div class="col-12">
							<input type="hidden" class="form-control" id="sp_id">
							<input type="hidden" class="form-control" id="sp_kelompok">
							<button class="btn w-lg btn-custom waves-effect waves-light" id="btnAddSP" type="button">Save</button>
						</div>
					</div>
				</form>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>
<input type="hidden" name="_token" id="token" value="{{ csrf_token() }}">
<div style="overflow: hidden; display: none;">
	
	<div class="form-group m-b-25">
		<div class="col-12">
			<label>Secondary Mapping</label>
			<select class="form-control" id="add_modaliti2" name="add_modaliti2">
				<option value="OT">OT - Other</option>
				<option value="CR">CR - Computed Radiography</option>
				<option value="CT">CT - Computed Tomography</option>
				<option value="DX">DX - Digital Radiography</option>
				<option value="MG">MG - Mammography</option>
				<option value="MR">MR - Magnetic Resonance</option>
				<option value="PX">PX - Panoramic X-Ray</option>
				<option value="AR">AR - Autorefraction</option>
				<option value="RF">RF - Radio Fluoroscopy</option>
				<option value="RG">RG - Radiographic imaging (conventional film/screen)</option>
				<option value="TG">TG - Thermography</option>
				<option value="US">US - Ultrasound</option>
				<option value="VA">VA - Visual Acuity</option>
				<option value="XA">XA - X-Ray Angiography</option>
				<option value="XC">XC - External-camera Photography</option>
				<option value="ASMT">ASMT - Content Assessment Results</option>
				<option value="AU">AU - Audio</option>
				<option value="BDUS">BDUS - Bone Densitometry (ultrasound)</option>
				<option value="BI">BI - Biomagnetic imaging</option>
				<option value="BMD">BMD - Bone Densitometry (X-Ray)</option>
				<option value="DG">DG - Diaphanography</option>
				<option value="DOC">DOC - Document</option>
				<option value="ECG">ECG - Electrocardiography</option>
				<option value="EPS">EPS - Cardiac Electrophysiology</option>
				<option value="ES">ES - Endoscopy</option>
				<option value="FID">FID - Fiducials</option>
				<option value="GM">GM - General Microscopy</option>
				<option value="HC">HC - Hard Copy</option>
				<option value="HD">HD - Hemodynamic Waveform</option>
				<option value="IO">IO - Intra-Oral Radiography</option>
				<option value="IOL">IOL - Intraocular Lens Data</option>
				<option value="IVOCT">IVOCT - Intravascular Optical Coherence Tomography</option>
				<option value="IVUS">IVUS - Intravascular Ultrasound</option>
				<option value="KER">KER - Keratometry</option>
				<option value="KO">KO - Key Object Selection</option>
				<option value="LEN">LEN - Lensometry</option>
				<option value="LS">LS - Laser surface scan</option>
				<option value="NM">NR - Nuclear Medicine</option>
				<option value="OAM">OAM - Ophthalmic Axial Measurements</option>
				<option value="OCT">OCT - Optical Coherence Tomography (non-Ophthalmic)</option>
				<option value="OP">OP - Ophthalmic Photography</option>
				<option value="OPM">OPM - Ophthalmic Mapping</option>
				<option value="OPT">OPT - Ophthalmic Tomography</option>
				<option value="OPV">OPV - Ophthalmic Visual Field</option>
				<option value="OSS">OSS - Optical Surface Scan</option>
				<option value="PLAN">PLAN - Plan</option>
				<option value="PR">PR - Presentation State</option>
				<option value="PT">PT - Positron emission tomography (PET)</option>
				<option value="REG">REG - Registration</option>
				<option value="RESP">RESP - Respiratory Waveform</option>
				<option value="RTDOSE">RTDOSE - Radiotherapy Dose</option>
				<option value="RTIMAGE">RTIMAGE - Radiotherapy Image</option>
				<option value="RTPLAN">RTPLAN - Radiotherapy Plan</option>
				<option value="RTRECORD">RTRECORD - RT Treatment Record</option>
				<option value="RTSTRUCT">RTSTRUCT - Radiotherapy Structure Set</option>
				<option value="RWV">RWV - Real World Value Map</option>
				<option value="SEG">SEG - Segmentation</option>
				<option value="SM">SM - Slide Microscopy</option>
				<option value="SMR">SMR - Stereometric Relationship</option>
				<option value="SR">SR - SR Document</option>
				<option value="SRF">SRF - Subjective Refraction</option>
				<option value="STAIN">STAIN - Automated Slide Stainer</option>
			</select>
		</div>
	</div>
	
	<div class="form-group m-b-25">
		<div class="col-12">
			<label>Secondary Mapping</label>
			<select class="form-control" id="modaliti2" name="modaliti2">
				<option value="OT">OT - Other</option>
				<option value="CR">CR - Computed Radiography</option>
				<option value="CT">CT - Computed Tomography</option>
				<option value="DX">DX - Digital Radiography</option>
				<option value="MG">MG - Mammography</option>
				<option value="MR">MR - Magnetic Resonance</option>
				<option value="PX">PX - Panoramic X-Ray</option>
				<option value="AR">AR - Autorefraction</option>
				<option value="RF">RF - Radio Fluoroscopy</option>
				<option value="RG">RG - Radiographic imaging (conventional film/screen)</option>
				<option value="TG">TG - Thermography</option>
				<option value="US">US - Ultrasound</option>
				<option value="VA">VA - Visual Acuity</option>
				<option value="XA">XA - X-Ray Angiography</option>
				<option value="XC">XC - External-camera Photography</option>
				<option value="ASMT">ASMT - Content Assessment Results</option>
				<option value="AU">AU - Audio</option>
				<option value="BDUS">BDUS - Bone Densitometry (ultrasound)</option>
				<option value="BI">BI - Biomagnetic imaging</option>
				<option value="BMD">BMD - Bone Densitometry (X-Ray)</option>
				<option value="DG">DG - Diaphanography</option>
				<option value="DOC">DOC - Document</option>
				<option value="ECG">ECG - Electrocardiography</option>
				<option value="EPS">EPS - Cardiac Electrophysiology</option>
				<option value="ES">ES - Endoscopy</option>
				<option value="FID">FID - Fiducials</option>
				<option value="GM">GM - General Microscopy</option>
				<option value="HC">HC - Hard Copy</option>
				<option value="HD">HD - Hemodynamic Waveform</option>
				<option value="IO">IO - Intra-Oral Radiography</option>
				<option value="IOL">IOL - Intraocular Lens Data</option>
				<option value="IVOCT">IVOCT - Intravascular Optical Coherence Tomography</option>
				<option value="IVUS">IVUS - Intravascular Ultrasound</option>
				<option value="KER">KER - Keratometry</option>
				<option value="KO">KO - Key Object Selection</option>
				<option value="LEN">LEN - Lensometry</option>
				<option value="LS">LS - Laser surface scan</option>
				<option value="NM">NR - Nuclear Medicine</option>
				<option value="OAM">OAM - Ophthalmic Axial Measurements</option>
				<option value="OCT">OCT - Optical Coherence Tomography (non-Ophthalmic)</option>
				<option value="OP">OP - Ophthalmic Photography</option>
				<option value="OPM">OPM - Ophthalmic Mapping</option>
				<option value="OPT">OPT - Ophthalmic Tomography</option>
				<option value="OPV">OPV - Ophthalmic Visual Field</option>
				<option value="OSS">OSS - Optical Surface Scan</option>
				<option value="PLAN">PLAN - Plan</option>
				<option value="PR">PR - Presentation State</option>
				<option value="PT">PT - Positron emission tomography (PET)</option>
				<option value="REG">REG - Registration</option>
				<option value="RESP">RESP - Respiratory Waveform</option>
				<option value="RTDOSE">RTDOSE - Radiotherapy Dose</option>
				<option value="RTIMAGE">RTIMAGE - Radiotherapy Image</option>
				<option value="RTPLAN">RTPLAN - Radiotherapy Plan</option>
				<option value="RTRECORD">RTRECORD - RT Treatment Record</option>
				<option value="RTSTRUCT">RTSTRUCT - Radiotherapy Structure Set</option>
				<option value="RWV">RWV - Real World Value Map</option>
				<option value="SEG">SEG - Segmentation</option>
				<option value="SM">SM - Slide Microscopy</option>
				<option value="SMR">SMR - Stereometric Relationship</option>
				<option value="SR">SR - SR Document</option>
				<option value="SRF">SRF - Subjective Refraction</option>
				<option value="STAIN">STAIN - Automated Slide Stainer</option>
			</select>
		</div>
	</div>
</div>
@endsection

@push('script')
<script type="text/javascript">
	function openedpage( jQuery ){
		var token					= document.getElementById('token').value;
		var sourcebakteri 			= {
			datatype	: "json",
			datafields	: [
				{ name: 'id',type: 'text'},
				{ name: 'name',type: 'text'},
				{ name: 'category',type: 'text'},
				{ name: 'kelompok',type: 'text'},
				{ name: 'nilai',type: 'text'},
				{ name: 'satuan',type: 'text'},
			],
			type: 'POST',
			data: {	val01:'listkodespesimen', _token: token },
			url	: '{{ route("getriwayat") }}',
		};
		var jsonBakteri 			= new $.jqx.dataAdapter(sourcebakteri);
		$("#gridbakteri").jqxGrid({
			width					: '100%',
			showfilterrow			: true,
			filterable				: true,
			source					: jsonBakteri,
			columnsresize			: true,
			theme					: "energyblue",
			autoheight				: true,
			pageable				: true,
			altrows					: true,
			selectionmode			: 'multiplecellsextended',
			columns					: [
				{ text: 'Edit', filterable: false, columntype: 'button', cellsalign: 'center', align: 'center', width: '10%', cellsrenderer: function () {
					return "Edit";
					}, buttonclick: function (row) {
						editrowpoli 	= row;
						var offset      = $("#gridbakteri").offset();       
						var dataRecord  = $("#gridbakteri").jqxGrid('getrowdata', editrowpoli);
						$("#sp_id").val(dataRecord.id);
						$("#sp_kelompok").val(dataRecord.kelompok);
						$("#sp_kategori").val(dataRecord.category);
						$("#sp_name").val(dataRecord.name);
						$("#sp_nilai").val(dataRecord.nilai);
						$("#sp_satuan").val(dataRecord.satuan);
						$('#ModalSpecimen').modal('show');
					}
				},
				{ text: 'Name', datafield: 'name', width: '40%', cellsalign: 'left', align: 'center' },
				{ text: 'Category', datafield: 'category', width: '20%', cellsalign: 'left', align: 'center' },
				{ text: 'Satuan', datafield: 'satuan', width: '10%', cellsalign: 'left', align: 'center' },
				{ text: 'Nilai', datafield: 'nilai', width: '10%', cellsalign: 'center', align: 'center' },
				{ text: 'Delete', editable: false, sortable: false, filterable: false, columntype: 'button', width: '10%', cellsrenderer: function () {
					return "Delete";
					}, buttonclick: function (row) {	
						editrow = row;	
						var offset 		= $("#gridbakteri").offset();		
						var dataRecord 	= $("#gridbakteri").jqxGrid('getrowdata', editrow);
						swal({
							title				: 'Are you sure?',
							text				: "Do you realy want to delete this data!",
							type				: 'warning',
							showCancelButton	: true,
							confirmButtonClass	: 'btn btn-confirm mt-2',
							cancelButtonClass	: 'btn btn-cancel ml-2 mt-2',
							confirmButtonText	: 'Yes, confirm it!'
						}).then(function () {
							var token   	= document.getElementById('token').value;		
							$.post('{{ route("deleteJawaban") }}', { id: 'mikroorganisme', idsirab: dataRecord.id, _token: token },	function(data){					
								var status  = data.status;
								var message = data.message;
								var warna 	= data.warna;
								var icon 	= data.icon;
								$.toast({
									heading: status,
									text: message,
									position: 'top-right',
									loaderBg: warna,
									icon: icon,
									hideAfter: 5000,
									stack: 1
								});
								$("#gridbakteri").jqxGrid('updatebounddata', 'filter');
								return false;
							});
						});
					}
				},
			]
		});
	}
	$(window).on('load', function () {
		openedpage();
	});
    $(document).ready(function() {
        $('form').parsley();
    });
    var sourcepoli = {
        datatype: "json",
        datafields: [
        	{ name: 'id'},
        	{ name: 'poli', type: 'text'},
       	 	{ name: 'subpoli', type: 'text'},
        	{ name: 'subsubpoli', type: 'text'},
			{ name: 'modaliti', type: 'text'},
			{ name: 'modaliti2', type: 'text'}
        ],
        updaterow: function (rowid, rowdata, commit) {
        commit(true);
        },
        url: '{{ route("getListPoli") }}',
        cache: false
    };
    var dataAdapterpoli = new $.jqx.dataAdapter(sourcepoli);
    $("#gridpoli").jqxGrid({
        width					: '100%',
		enablebrowserselection	: true,
        filterable				: true,
        showfilterrow			: true,
        pageable				: true,
        autoheight				: true,
        source					: dataAdapterpoli,
        theme					: "energyblue",
        selectionmode			: 'multiplecellsextended',
        columns					: [
			{ text: 'Category', filtertype: 'checkedlist', datafield: 'poli', width: '15%', align: 'center', cellsalign: 'left'},                   
			{ text: 'Request Name', datafield: 'subpoli', width: '35%', cellsalign: 'left', align: 'center' },
			{ text: 'Header', datafield: 'modaliti', width: '15%', cellsalign: 'left', align: 'center'  },
			{ text: 'Footer', datafield: 'subsubpoli', width: '15%', cellsalign: 'left', align: 'center'  },
			{ text: 'Update', sortable: false, filterable: false, columntype: 'button', align: 'center', width: '10%', cellsrenderer: function () {
				return "Update";
				}, buttonclick: function (row) {
					editrowpoli = row;
					var offset      = $("#gridpoli").offset();       
					var dataRecord  = $("#gridpoli").jqxGrid('getrowdata', editrowpoli);
					$("#id_poli").val(dataRecord.id);
					$("#poli").val(dataRecord.poli);
					$("#subpoli").val(dataRecord.subpoli);
					$("#subsubpoli").val(dataRecord.subsubpoli);
					$("#modaliti").val(dataRecord.modaliti);
					$("#modaliti2").val(dataRecord.modaliti2);
					$('#updateModalPoli').modal('show');
				}
			},   
			{ text: 'Delete', sortable: false, filterable: false, columntype: 'button', align: 'center', width: '10%', cellsrenderer: function () {
				return "Delete";
				}, buttonclick: function (row) {        
					editrow         = row;   
					var offset      = $("#gridpoli").offset();       
					var dataRecord  = $("#gridpoli").jqxGrid('getrowdata', editrow);                      
					var goook       = dataRecord.id;
					var token       = document.getElementById('token').value;
					swal({
						title: 'Are you sure?',
						text: "Do you realy want to delete this data!",
						type: 'warning',
						showCancelButton: true,
						confirmButtonClass: 'btn btn-confirm mt-2',
						cancelButtonClass: 'btn btn-cancel ml-2 mt-2',
						confirmButtonText: 'Yes, delete it!'
					}).then(function () {
						swal({
							title: 'Deleted !',
							text: "Your Data has been deleted",
							type: 'success',
							confirmButtonClass: 'btn btn-confirm mt-2'
						})
						$.post('{{ route("deletePoli") }}', { id: goook, _token: token },
						function(data){
							$("#gridpoli").jqxGrid('updatebounddata'); 
							return false;
						}); 
					})                
				}
			},
		]
    });
    var sourceruangan = {
        datatype: "json",
        datafields: [
			{ name: 'id'},
			{ name: 'poli', type: 'text'},
			{ name: 'ruangan', type: 'text'}
        ],
        updaterow: function (rowid, rowdata, commit) {
        commit(true);
        },
        url: '{{ route("getListRuangan") }}',
        cache: false
    };      
    var dataAdapterruangan = new $.jqx.dataAdapter(sourceruangan);
    $("#gridruangan").jqxGrid({
        width					: '100%',
		enablebrowserselection	: true,
        filterable				: true,
        showfilterrow			: true,
        pageable				: true,
        autoheight				: true,
        source					: dataAdapterruangan,
        theme					: "energyblue",
        selectionmode			: 'multiplecellsextended',
        columns					: [
			{ text: 'Group', filtertype: 'checkedlist', datafield: 'poli', width: '38%', align: 'center', cellsalign: 'left'},                   
			{ text: 'Rooms Name', datafield: 'ruangan', width: '38%', cellsalign: 'left', align: 'center' },
			{ text: 'Update', sortable: false, filterable: false, columntype: 'button', align: 'center', width: '12%', cellsrenderer: function () {
				return "Update";
				}, buttonclick: function (row) {
					editrowruangan = row;
					var offset      = $("#gridruangan").offset();
					var dataRecord  = $("#gridruangan").jqxGrid('getrowdata', editrowruangan);
					$("#id_ruangan").val(dataRecord.id);
					$("#poli_ruangan").val(dataRecord.poli);
					$("#ruangan").val(dataRecord.ruangan);
					$('#updateModalRuangan').modal('show');
				}
			},   
			{ text: 'Delete', sortable: false, filterable: false, columntype: 'button', align: 'center', width: '12%', cellsrenderer: function () {
				return "Delete";
				}, buttonclick: function (row) {        
					editrow         = row;   
					var offset      = $("#gridruangan").offset();       
					var dataRecord  = $("#gridruangan").jqxGrid('getrowdata', editrow);                      
					var goook       = dataRecord.id;
					var token       = document.getElementById('token').value;
					swal({
						title: 'Are you sure?',
						text: "Do you realy want to delete this data!",
						type: 'warning',
						showCancelButton: true,
						confirmButtonClass: 'btn btn-confirm mt-2',
						cancelButtonClass: 'btn btn-cancel ml-2 mt-2',
						confirmButtonText: 'Yes, delete it!'
					}).then(function () {
						swal({
							title: 'Deleted !',
							text: "Your Data has been deleted",
							type: 'success',
							confirmButtonClass: 'btn btn-confirm mt-2'
						})
						$.post('{{ route("deleteRuangan") }}', { id: goook, _token: token },
						function(data){ 
							$("#gridruangan").jqxGrid('updatebounddata');
							return false;
						}); 
					})
				}
			},
		]
	});
	$("#btnaddModalSpecimen").click(function() {
		$("#sp_id").val('new');
		$("#sp_kelompok").val('listkodespesimen');
		$('#ModalSpecimen').modal('show');
	});
	$("#btnAddMB").click(function(){
		var set01 = document.getElementById('mb_name').value;
		var set02 = document.getElementById('mb_kategori').value;
		var set03 = document.getElementById('mb_kelompok').value;
		var set04 = document.getElementById('mb_id').value;
		if (set01 == '' || set02 == '' || set03 == ''){
			swal({
				title	: 'Mohon diLengkapi',
				text	: 'Data Dasar Wajib di Isi',
				type	: 'warning',
			});
		} else {
			$('#ModalMikroandBakteri').modal('hide');
			var form_data 	= 	new FormData();
				form_data.append('name', set01);
				form_data.append('category', set02);
				form_data.append('kelompok', set03);
				form_data.append('id', set04);
				form_data.append('tabel', 'Organisme');
				form_data.append('_token', '{{csrf_token()}}');
			$.ajax({
				url			: '{{ route("exSIRAb") }}',
				data		: form_data,
				type		: 'POST',
				contentType	: false,
				processData	: false,
				success		: function (data) {
					var status  = data.status;
					var message = data.message;
					var icon 	= data.icon;
					var warna 	= data.warna;
					$("html, body").animate({ scrollTop: 0 }, "slow");
					$.toast({
						heading		: status,
						text		: message,
						position	: 'top-right',
						loaderBg	: warna,
						icon		: icon,
						hideAfter	: 3000,
						stack		: 1
					});
					$("#gridbakteri").jqxGrid('updatebounddata', 'filter');
					$("#gridmikroorganisme").jqxGrid('updatebounddata', 'filter');
					return false;
				},
				error		: function (xhr, status, error) {
					var response 	= xhr.responseJSON || {};
					var traceText 	= response.trace ? JSON.stringify(response.trace) : null;
					swal({
						title	: response,
						text	: traceText,
						type	: 'error',
					})
				}
			});
		}
	});
	$("#btnAddSP").click(function(){
		var set01 = document.getElementById('sp_name').value;
		var set02 = document.getElementById('sp_kategori').value;
		var set03 = document.getElementById('sp_kelompok').value;
		var set04 = document.getElementById('sp_id').value;
		var set05 = document.getElementById('sp_satuan').value;
		var set06 = document.getElementById('sp_nilai').value;

		if (set01 == '' || set02 == '' || set03 == '' || set04 == '' || set05 == '' || set06 == ''){
			swal({
				title	: 'Mohon diLengkapi',
				text	: 'Data Dasar Wajib di Isi',
				type	: 'warning',
			});
		} else {
			$('#ModalSpecimen').modal('hide');
			var form_data 	= 	new FormData();
				form_data.append('name', set01);
				form_data.append('category', set02);
				form_data.append('kelompok', set03);
				form_data.append('id', set04);
				form_data.append('satuan', set05);
				form_data.append('nilai', set06);
				form_data.append('tabel', 'Speciment');
				form_data.append('_token', '{{csrf_token()}}');
			$.ajax({
				url			: '{{ route("exSIRAb") }}',
				data		: form_data,
				type		: 'POST',
				contentType	: false,
				processData	: false,
				success		: function (data) {
					var status  = data.status;
					var message = data.message;
					var icon 	= data.icon;
					var warna 	= data.warna;
					$("html, body").animate({ scrollTop: 0 }, "slow");
					$.toast({
						heading		: status,
						text		: message,
						position	: 'top-right',
						loaderBg	: warna,
						icon		: icon,
						hideAfter	: 3000,
						stack		: 1
					});
					$("#gridbakteri").jqxGrid('updatebounddata', 'filter');
					$("#gridmikroorganisme").jqxGrid('updatebounddata', 'filter');
					return false;
				},
				error		: function (xhr, status, error) {
					var response 	= xhr.responseJSON || {};
					var traceText 	= response.trace ? JSON.stringify(response.trace) : null;
					swal({
						title	: response,
						text	: traceText,
						type	: 'error',
					})
				}
			});
		}
	});
    $("#btnAddPoli").click(function(){
        var poli            =   document.getElementById('add_poli').value;
        var subpoli         =   document.getElementById('add_subpoli').value;
        var subsubpoli      =   document.getElementById('add_subsubpoli').value;
		var modaliti   		=   document.getElementById('add_modaliti').value;
		var modaliti2  		=   document.getElementById('add_modaliti2').value;
        var token           =   document.getElementById('token').value;
        $.post('{{ route("storePoli") }}', { poli: poli, subpoli: subpoli, subsubpoli: subsubpoli, modaliti: modaliti, modaliti2: modaliti2, _token: token },
        function(data){
			var message = data.message;
			var status 	= data.status;
            $.toast({
                heading: status,
                text: message,
                position: 'top-right',
                loaderBg: '#bf441d',
                icon: 'info',
                hideAfter: 5000,
                stack: 1
            });
            $('#addModalPoli').modal('hide');
            $("#gridpoli").jqxGrid('updatebounddata');
            return false;
        });
    });
    $("#btnAddRuangan").click(function(){
        var poli            =   document.getElementById('add_idruangan').value;
        var ruangan         =   document.getElementById('add_ruangan').value;
        var token           =   document.getElementById('token').value;
        $.post('{{ route("storeRuangan") }}', { poli: poli, ruangan: ruangan, _token: token },
        function(data){
            $.toast({
                heading: 'Status Info',
                text: 'Data Berhasil diupdate',
                position: 'top-right',
                loaderBg: '#bf441d',
                icon: 'info',
                hideAfter: 5000,
                stack: 1
            });
            $('#addModalRuangan').modal('hide');
            $("#gridruangan").jqxGrid('updatebounddata');
            return false;
        });
    });
    $("#btnUpdatePoli").click(function(){
        var poli         =   document.getElementById('poli').value;
        var subpoli      =   document.getElementById('subpoli').value;
        var subsubpoli   =   document.getElementById('subsubpoli').value;
        var poli_id      =   document.getElementById('id_poli').value;
		var modaliti     =   document.getElementById('modaliti').value;
		var modaliti2    =   document.getElementById('modaliti2').value;
        var token        =   document.getElementById('token').value;
        $.post('{{ route("updatePoli") }}', { id: poli_id, poli: poli, subpoli: subpoli, subsubpoli: subsubpoli, modaliti: modaliti, modaliti2: modaliti2, _token: token },
        function(data){
            var message = data.message;
			var status 	= data.status;
            $.toast({
                heading: status,
                text: message,
                position: 'top-right',
                loaderBg: '#bf441d',
                icon: 'info',
                hideAfter: 5000,
                stack: 1
            });
            $('#updateModalPoli').modal('hide');
            $("#gridpoli").jqxGrid('updatebounddata');
            return false;
        });
    });
    $("#btnUpdateRuangan").click(function(){
        var poli            =   document.getElementById('poli_ruangan').value;
        var ruangan         =   document.getElementById('ruangan').value;
        var id_ruangan      =   document.getElementById('id_ruangan').value;
        var token           =   document.getElementById('token').value;
        $.post('{{ route("updateRuangan") }}', { id: id_ruangan, poli: poli, ruangan: ruangan, _token: token },
        function(data){
            $.toast({
                heading: 'Status Info',
                text: 'Data Berhasil diupdate',
                position: 'top-right',
                loaderBg: '#bf441d',
                icon: 'info',
                hideAfter: 5000,
                stack: 1
            });
            $('#updateModalRuangan').modal('hide');
            $("#gridruangan").jqxGrid('updatebounddata');
            return false;
        });
    });
</script>
@endpush
