@extends('base.layout')

@section('content')
<div class="wrapper">
	<div class="container-fluid">
		<div id="divawal">
			<div class="row">
				<div class="col-lg-7">
					<div class="card-box ribbon-box">
						<div class="ribbon ribbon-primary">List Yang Akan di Kirim</div>
						<p class="m-b-0"></p>
						<div id="gridlist"></div>
					</div>
				</div>
                <div class="col-lg-5">
					<div class="card-box ribbon-box">
						<div class="ribbon ribbon-primary">Lengkapi Data Kegiatan</div>
						<p class="m-b-0"></p>
                        <div class="box-body">
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="id_kodjenis">Jenis Penugasan/Kegiatan <font color="red">*</font></label>
                                    <select id="id_kodjenis" size="1" class="form-control">
                                        <option value="">Pilih Salah Satu</option>
                                        <optgroup label="PELAKSANAAN PENDIDIKAN">
                                            <option value="201306">Kuliah Pakar/Kuliah Klarifikasi</option>
                                            <option value="202101">Tutorial Fasilitator PBL/Modul</option>
                                            <option value="202102">Bimbingan Lab. Skill</option>
                                            <option value="202103">Bimbingan PANUM</option>
                                            <option value="202104">Bimbingan Tugas Ilmiah / Penelitian / Tesis</option>
                                            <option value="204302">Bimbingan Penulisan Resep</option>
                                            <option value="204303">Otopsi Bimbingan / Mandiri</option>
                                            <option value="204304">Bimbingan Bed-Side (Bed-Side Teaching)</option>
                                            <option value="204305">Bimbingan Poliklinik</option>
                                            <option value="204306">Bimbingan Morning Report</option>
                                            <option value="204308">Bimbingan Jaga</option>
                                            <option value="204309">Operasi Bimbingan / Mandiri</option>
                                            <option value="204310">Bimbingan tindakan medis invasif</option>
                                            <option value="204311">Ujian OSCE Lokal atau sejenis</option>
                                            <option value="204312">Ujian OSCE nasional atau sejenis</option>
                                            <option value="204313">Ujian Akhir Lokal / Board</option>
                                            <option value="204314">Ujian Akhir nasional / Board</option>
                                            <option value="204315">Bimbingan dan Ujian Referat Akhir (Tinjauan Kepustakaan)</option>
                                            <option value="204316">Bimbingan dan Ujian Referat Kecil (Tinjauan Kepustakaan)</option>
                                            <option value="204317">Ujian Referat Akhir</option>
                                            <option value="204318">Ujian Referat Kecil</option>
                                            <option value="204319">Bimbingan Tugas ilmiah nasional</option>
                                            <option value="204320">Tugas ilmiah internasional</option>
                                            <option value="204321">Bimbingan Case report</option>
                                            <option value="204322">Texbook reading</option>
                                            <option value="204323">Jurnal reading</option>
                                            <option value="204324">Ujian akhir stase</option>
                                            <option value="204325">Ujian Semester</option>
                                        </optgroup>
                                    </select>
                                </div>
                                <div class="form-group" id="tampilankhususoperasi">
                                    <label for="id_role">Role</label>
                                    <select id="id_role" size="1" class="form-control">
                                        <option value="Observer">Observer</option>
                                        <option value="Asisten">Asisten</option>
                                        <option value="Operator">Operator</option>
                                    </select>
                                </div>
                                <div class="form-group" id="tampilankhususbiasa">
                                    <label for="id_role2">Role</label>
                                    <select id="id_role2" size="1" class="form-control">
                                        <option value="PPDS JUNIOR">PPDS JUNIOR</option>
                                        <option value="PPDS MIDLLE">PPDS MIDLLE</option>
                                        <option value="PPDS SENIOR">PPDS SENIOR</option>
                                    </select>
                                </div>
                                <div class="form-group">
									<div class="row">
										<div class="col-lg-6">
                                            <div class="form-group">
                                                <label>Tanggal <font color="red">*</font></label>
                                                <div>
                                                    <div class="input-group">
                                                        <input type="text" id="id_tanggal" class="form-control" placeholder="Pick Date">
                                                        <div class="input-group-append">
                                                            <span class="input-group-text"><i class="fa fa-calendar"></i></span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
										</div>
										<div class="col-lg-6">
                                            <div class="form-group">
                                                <label>Waktu <font color="red">*</font></label>
                                                <div>
                                                    <div class="input-group">
                                                        <input type="text" id="id_waktu" class="form-control" placeholder="Pick Time">
                                                        <div class="input-group-append">
                                                            <span class="input-group-text"><i class="fa fa-hourglass-1"></i></span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
										</div>
                                        <div class="col-lg-3">
                                            <label for="id_durasi">Durasi</label>
                                            <select id="id_durasi" size="1" class="form-control">
                                                <option value="1"> 1 Jam</option>
                                                <option value="2"> 2 Jam</option>
                                                <option value="3"> 3 Jam</option>
                                                <option value="4-8 Jam"> 4 - 8 Jam</option>
                                                <option value="9-12 Jam"> 9 - 12 Jam</option>
                                            </select>
										</div>
                                        <div class="col-lg-3">
                                            <label for="id_jumlah">Jml MHS</label>
                                            <input type="text" id="id_jumlah" class="form-control" value="1">
                                        </div>
                                        <div class="col-lg-3">
                                            <label for="id_topik">Semester</label>
                                            <select id="id_topik" size="1" class="form-control">
                                                <option value="1">1</option>
                                                <option value="2">2</option>
                                                <option value="3">3</option>
                                                <option value="4">4</option>
                                                <option value="5">5</option>
                                                <option value="6">6</option>
                                                <option value="7">7</option>
                                                <option value="8">>7</option>
                                            </select>
                                        </div>
                                        <div class="col-lg-3">
                                            <label for="id_semester">TA.Akademik</label>
                                            <select id="id_semester" size="1" class="form-control">
                                            @php 
                                                $i      =   0;
                                                $now    =   date('Y');
                                                for($i = 0; $i < 10; $i++) {
                                                    $tahun  =   (int)$now - ($i);
                                                    echo '<option value="'.$tahun.'.1">'.$tahun.'.1</option>';
                                                    echo '<option value="'.$tahun.'.2">'.$tahun.'.2</option>';
                                                }
                                            @endphp
                                            </select>
                                            <p class="help-block">1 Ganjil, 2 Genap</p>
										</div>
									</div>
								</div>
                                
                                <div class="form-group">
                                    <label for="id_stase">Stase <font color="red">*</font></label>
                                    <select id="id_stase" size="1" class="form-control">
                                        <option value="Emergency Radiology"> Emergency Radiology</option>
                                        <option value="Baca Foto"> Baca Foto</option>
                                        <option value="Contrast Study / Fluoroscopy"> Contrast Study / Fluoroscopy</option>
                                        <option value="Ultrasonografi"> Ultrasonografi</option>
                                        <option value="CT Scan"> CT Scan</option>
                                        <option value="MRI"> MRI</option>
                                        <option value="Interventional Radiologi"> Interventional Radiologi</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="id_rumahsakit">Nama Rumah Sakit / Klinik <font color="red">*</font></label>
                                    <select id="id_rumahsakit" size="1" class="form-control">
                                        <option value="RSSA Malang"> RSSA Malang</option>
                                        <option value="RSUB"> RSUB</option>
                                        <option value="Puskesmas"> Puskesmas</option>
                                        <option value="RS lainnya"> RS Lainnya</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="id_rumahsakitnama">Bila Puskesmas / RS Lainnya Mohon di Lengkapi Nama Puskesmas / RS Lainnya Tersebut</label>
                                    <input type="text" id="id_rumahsakitnama" name="id_rumahsakitnama" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>Supervisor 1<font color="red">*</font></label>
                                    <div class="row">
                                        <div class="col-lg-10">
                                            <select id="id_spv" size="1" class="form-control select2" style="width: 100%;">
                                                <option value="">Pilih Salah Satu</option>
                                                @if(!empty($dosens))
                                                    @foreach($dosens as $rdosen)
                                                        <option value="{{ $rdosen->no }}">{!! $rdosen->nama_lengkap !!}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                        </div>
                                        <div class="col-lg-2">
                                            <a href="#" id="tombolview2" class="btn btn-danger btn-block"><i class="fa fa-plus"></i></a>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group" id="tampilanspv2">
                                    <label>Supervisor 2<font color="red">*</font></label>
                                    <div class="row">
                                        <div class="col-lg-2">
                                            <a href="#" id="tombolclose2" class="btn btn-info btn-block"><i class="fa fa-minus"></i></a>
                                        </div>
                                        <div class="col-lg-8">
                                            <select id="id_spv2" size="1" class="form-control select2" style="width: 100%;">
                                                <option value="">Pilih Salah Satu</option>
                                                @if(!empty($dosens))
                                                    @foreach($dosens as $rdosen)
                                                        <option value="{{ $rdosen->no }}">{!! $rdosen->nama_lengkap !!}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                        </div>
                                        <div class="col-lg-2">
                                            <a href="#" id="tombolview3" class="btn btn-danger btn-block"><i class="fa fa-plus"></i></a>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group" id="tampilanspv3">
                                    <label>Supervisor 3<font color="red">*</font></label>
                                    <div class="row">
                                        <div class="col-lg-2">
                                            <a href="#" id="tombolclose3" class="btn btn-info btn-block"><i class="fa fa-minus"></i></a>
                                        </div>
                                        <div class="col-lg-8">
                                            <select id="id_spv3" size="1" class="form-control select2" style="width: 100%;">
                                                <option value="">Pilih Salah Satu</option>
                                                @if(!empty($dosens))
                                                    @foreach($dosens as $rdosen)
                                                        <option value="{{ $rdosen->no }}">{!! $rdosen->nama_lengkap !!}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                        </div>
                                        <div class="col-lg-2">
                                            <a href="#" id="tombolview4" class="btn btn-danger btn-block"><i class="fa fa-plus"></i></a>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group" id="tampilanspv4">
                                    <label for="id_spvnama">Bila Nama Dosen Tidak Masuk dalam List Mohon Menginputkan di bawah ini nama lengkap SPV yang dimaksud</label>
                                    <input type="text" id="id_spvnama" name="id_spvnama" class="form-control">
                                </div>
                                <div class="form-group">  
                                    <label for="id_deskripsi">Deskripsi / Keterangan Tambahan <font color="red">*</font></label>
                                    <textarea id="id_deskripsi" name="id_deskripsi"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <label>Username INSITU<font color="red">*</font></label>
                                        <input type="text" id="id_username" name="id_username" class="form-control">
                                    </div>
                                    <div class="col-lg-6">
                                        <label>Password INSITU<font color="red">*</font></label>
                                        <input type="password" id="id_password" name="id_password" class="form-control">
                                    </div>
                                </div>
                            </div>
                            <div class="box-footer">
                                <div class="form-group">
                                    <input type="hidden" id="id_idne" name="id_idne" class="form-control">
                                    <button type="button" class="btn btn-success pull-left" id="btnsimpandata">SIMPAN</button>
                                </div>
                            </div>
                        </div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<div id="tempatctk" style="overflow: hidden; display: none;">
	<div id="tabel_cetak"></div>
    <div class="form-group">
        <label for="filesk">File Pendukung 1</label>
        <input type="file" id="filesk" name="filesk">
    </div>
    <div class="form-group">
        <label for="filesk2">File Pendukung 2</label>
        <input type="file" id="filesk2" name="filesk2">
    </div>
    <div class="form-group">
        <label for="id_nama">Nama <font color="red">*</font></label>
        <input type="text" id="id_nama" name="id_nama" class="form-control" value="{!! Session('nama') !!}">
    </div>				
    <div class="form-group">
        <label for="id_nim">NIM <font color="red">*</font></label>
        <input type="text" id="id_nim" name="id_nim" class="form-control" value="{!! Session('id') !!}">
    </div> 
</div>
<input type="hidden" name="_token" id="token" value="{{ csrf_token() }}">
<input type="hidden" id="master_set01" name="master_set01" value="ThisSync">
<input type="hidden" id="master_set02" name="master_set02" value="new">
<input type="hidden" id="master_set03" name="master_set03" value="{{Session('username')}}">
<input type="hidden" id="master_set04" name="master_set04" value=""> 
@endsection

@push('script')
<script type="text/javascript">
    $(function () {
		$('.select2').select2()
		CKEDITOR.env.isCompatible = true;
		CKEDITOR.replace( 'id_deskripsi' );
		$("#id_tanggal").datepicker({format: 'yyyy-mm-dd', autoclose: true});
        $("#id_waktu").timepicker({format: 'HH:mm:ss'});
	});
    function openedpage( jQuery ){
		var token=document.getElementById('token').value;
		var set01=document.getElementById('master_set01').value;
		var set02=document.getElementById('master_set02').value;
		var set03=document.getElementById('master_set03').value;
		var set04=document.getElementById('master_set04').value;
		var token=document.getElementById('token').value;
		var sourcepasiencari = {
			datatype: "json",
			datafields: [
				{ name: 'id',type: 'text'},
				{ name: 'nofoto',type: 'text'},
				{ name: 'tlsdaftar',type: 'text'},
				{ name: 'tlsnofoto',type: 'text'},
				{ name: 'tlsnoregister',type: 'text'},
				{ name: 'noloket',type: 'text'},
				{ name: 'tlsnama',type: 'text'},
				{ name: 'tlsusia',type: 'text'},
				{ name: 'tlsreques',type: 'text'},
				{ name: 'ruangan',type: 'text'},
				{ name: 'kesimpulan', type: 'text'},
				{ name: 'poli', type: 'text'},
				{ name: 'jkn', type: 'text'},
				{ name: 'umm', type: 'text'},
				{ name: 'swasta', type: 'text'},
				{ name: 'billing', type: 'text'},
				{ name: 'ele', type: 'text'},
				{ name: 'cito', type: 'text'},
				{ name: 'daftar', type: 'text'},
				{ name: 'foto',type: 'text'},
				{ name: 'baca',type: 'text'},
				{ name: 'cetak',type: 'text'},
				{ name: 'tanggal',type: 'text'},
				{ name: 'dokter',type: 'text'},
				{ name: 'ppds1',type: 'text'},
				{ name: 'ppds2',type: 'text'},
				{ name: 'ppds3',type: 'text'},
				{ name: 'diagnosa',type: 'text'},
				{ name: 'modality',type: 'text'},
				{ name: 'kd_spesimen',type: 'text'},
				{ name: 'nm_spesimen',type: 'text'},
				{ name: 'asalpasien',type: 'text'},
				{ name: 'status',type: 'text'},
				{ name: 'nmrs',type: 'text'},
				{ name: 'berat',type: 'text'},
				{ name: 'klinisi',type: 'text'},
				{ name: 'klinis',type: 'text'},
				{ name: 'telpon',type: 'text'},
				{ name: 'tlstelpon',type: 'text'},
				{ name: 'analis',type: 'text'},
				{ name: 'verifikasi',type: 'text'},
				{ name: 'tlsjk',type: 'text'},
				{ name: 'dokter',type: 'text'},
				{ name: 'filefoto',type: 'text'}
			],
			type: 'POST',
			data: {val01:set01, val02:set02, val03:set03, val04:set04, _token: token},
			url: '{{ route("getListdoneonly") }}',
		};
		var dataAdapter = new $.jqx.dataAdapter(sourcepasiencari);
		$("#gridlist").jqxGrid({
            width: '100%',
            enablebrowserselection: true,
            filterable: true,
            autoheight: true,
            autorowheight: true,
            showfilterrow: true,
            source: dataAdapter,
            pageable: true,
            theme: "energyblue",
            columnsresize: true,
            pagesizeoptions: ['10', '20', '30', '50', '100'],
            columns: [
                { text: 'Result', sortable: false, filterable: false, columntype: 'button', align: 'center', width: '8%', cellsrenderer: function () {
                    return "View";
                    }, buttonclick: function (row) {
                        editrowjabatan = row;
                        var offset      = $("#gridlist").offset();
                        var dataRecord  = $("#gridlist").jqxGrid('getrowdata', editrowjabatan);
                        var url 		= "{{URL::to("/")}}/hasil/"+dataRecord.nofoto;
                        var windowName 	= dataRecord.nofoto;
                        var windowSize 	= "width=800,height=800";
                        window.open(url, windowName, windowSize);
                        event.preventDefault();
                        return false;
                    }
                },
                { text: 'SPV', datafield: 'dokter', width: '30%', cellsalign: 'left', align: 'center'  },
                { text: 'Nama', datafield: 'tlsnama', width: '30%', cellsalign: 'left', align: 'center' },
                { text: 'Order', datafield: 'tlsreques', width: '25%', cellsalign: 'left', align: 'center'  },
                { text: 'Del', editable: false, sortable: false, filterable: false, columntype: 'button', width: '7%', cellsrenderer: function () {
                    return "Del";
                    }, buttonclick: function (row) {
                        editrow = row;	
                        var offset 		= $("#gridlist").offset();		
                        var dataRecord 	= $("#gridlist").jqxGrid('getrowdata', editrow);
                        var cek         = dataRecord.verifikator;
                        swal({
                            title: 'Apakah anda yakin ?',
                            text: "Perhatian, data yang sudah di hapus tidak bisa di Undo, apakah anda yakin ingin menghapus",
                            type: 'warning',
                            showCancelButton: true,
                            confirmButtonClass: 'btn btn-confirm mt-2',
                            cancelButtonClass: 'btn btn-cancel ml-2 mt-2',
                            confirmButtonText: 'Yes'
                        }).then(function () {
                            $.post('simba/destroyer', { set01: dataRecord.id, set02: 'delsynclist', _token: "{{ csrf_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
                                    });
                                    $("#gridlist").jqxGrid('updatebounddata', 'filter');
                                    return false;
                            });
                        });
                    }
                },
            ],
        });
	}
	$(window).on('load', function () {
		openedpage();
	});
$(document).ready(function () {
	$('#bodystatistik').hide();	
	$('#bodyreport').hide();	
	$('#divelogbook').hide();	
	$('#divcontrol').hide();	
	$('#grpbtnfeedback').hide();	
	$('#loading').hide();	
	$('#tampilankhususoperasi').hide();	
	$('#tampilanspv2').hide();
	$('#tampilanspv3').hide();
	$('#tampilanspv4').hide();
    $('#grpbtntambah').hide();
    $('#btnawal').hide();
    $("#id_kodjenis").on('change', function () {
        var val01	= $(this).find('option:selected').attr('value');
        if (val01 == '204309'){
            $('#tampilankhususoperasi').show();
            $('#tampilankhususbiasa').hide();
        } else {
            $('#tampilankhususbiasa').show();
            $('#tampilankhususoperasi').hide();
        }
    });	
	$('.btnkembali').click(function(){
		$('#divcontrol').hide();
        $('#divutama').removeClass('col-lg-7').addClass('col-lg-12');
	});
    $('#tombolclose2').click(function(){
		$('#tampilanspv2').hide();	
        $('#tampilanspv3').hide();
        $('#tampilanspv4').hide();
	});
    $('#tombolclose3').click(function(){
		$('#tampilanspv2').show();	
        $('#tampilanspv3').hide();
        $('#tampilanspv4').hide();
	});
    $('#tombolclose4').click(function(){
		$('#tampilanspv2').show();	
        $('#tampilanspv3').show();
        $('#tampilanspv4').hide();
	});
    $('#tombolview2').click(function(){
		$('#tampilanspv2').show();	
        $('#tampilanspv3').hide();
        $('#tampilanspv4').hide();
	});
    $('#tombolview3').click(function(){
		$('#tampilanspv2').show();	
        $('#tampilanspv3').show();
        $('#tampilanspv4').hide();
	});
    $('#tombolview4').click(function(){
		$('#tampilanspv2').show();	
        $('#tampilanspv3').show();
        $('#tampilanspv4').show();
	});
    $("#btnsimpandata").click(function(){
        var file1=document.getElementById('id_username').value;
        var file2=document.getElementById('id_password').value;
        var set01=document.getElementById('id_nim').value;
        var set02='28';
        var set03=document.getElementById('id_tanggal').value;
        var set04=document.getElementById('id_waktu').value;
        var set05=document.getElementById('id_topik').value;
        var set06=document.getElementById('id_spv').value;
        var set07=CKEDITOR.instances['id_deskripsi'].getData()
        var set08=document.getElementById('id_kodjenis').value;
        var set09=document.getElementById('id_durasi').value;
        var set10=document.getElementById('id_rumahsakit').value;
        var set11=document.getElementById('id_rumahsakitnama').value;
        var set12=document.getElementById('id_idne').value;
        var set13='DEPARTEMEN RADIOLOGI';
        var set14=document.getElementById('id_spvnama').value;
        var set15=document.getElementById('id_jumlah').value;
        var set16=document.getElementById('id_spv2').value;
        var set17=document.getElementById('id_spv3').value;
        var set18=document.getElementById('id_role').value;
        var set19=document.getElementById('id_role2').value;
        var set20=document.getElementById('id_semester').value;
        var set21=document.getElementById('id_stase').value;
        $('#loading').show();	
        $('#divcontrol').hide();
        $('#divutama').removeClass('col-lg-7').addClass('col-lg-12');
        $("html, body").animate({ scrollTop: 0 }, "slow");
	    var form_data = new FormData();
            form_data.append('file', file1);
            form_data.append('file2', file2);
            form_data.append('val01', set01);
            form_data.append('val02', set02);
            form_data.append('val03', set03);
            form_data.append('val04', set04);
            form_data.append('val05', set05);
            form_data.append('val06', set06);
            form_data.append('val07', set07);
            form_data.append('val08', set08);
            form_data.append('val09', set09);
            form_data.append('val10', set10);
            form_data.append('val11', set11);
            form_data.append('val12', set12);
            form_data.append('val13', set13);
            form_data.append('val14', set14);
            form_data.append('val15', set15);
            form_data.append('val16', set16);
            form_data.append('val17', set17);
            form_data.append('val18', set18);
            form_data.append('val19', set19);
            form_data.append('val20', set20);
            form_data.append('val21', set21);
            form_data.append('_token', '{{csrf_token()}}');
        $.ajax({
            url: '{{route("exDatapenugasan")}}',
            data: form_data,
            type: 'POST',
            contentType: false,
            processData: false,
            success: function (data) {
                var status  = data.status;
                var message = data.message;
                var warna 	= data.warna;
                var icon 	= data.icon;
                $('#loading').hide();
                $.toast({
                    heading: status,
                    text: message,
                    position: 'top-right',
                    loaderBg: warna,
                    icon: icon,
                    hideAfter: 5000,
                    stack: 1
                });
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $("#gridlist").jqxGrid('updatebounddata');
                return false;
            },
            error: function (xhr, status, error) {
                $('#loading').hide();
                swal({
                    title: 'Stop',
                    text: xhr.responseText,
                    type: 'warning',
                })
            }
        });			
    });
});
</script>
@endpush
