<?php 
session_start();
include('koneksi.php');
$nm=$mr=$dok="";
$telpon=$penjamin=$penjaminN=$pol=$polN=$dok=$dokN="";
	$mr=$_SESSION["MRNo"];
$nm=$_SESSION["Patname"];
$telpon=$_POST['telp'];
$penjamin=$_POST['debt'];
$pol=$_POST['poli'];
$dok=$_POST['dokter'];

$strSQL1="select * from ar_custmaster where kode='$penjamin'";
//$result =  $koneksi->query($strSQL1);
$result = sqlsrv_query($koneksi, $strSQL1);
while($data=sqlsrv_fetch_array($result)){
    $penjaminN=$data['nama'];
}
$strSQL1="select * from poly where Polycode='$pol'";
$result = sqlsrv_query($koneksi, $strSQL1);
while($data=sqlsrv_fetch_array($result)){
    $polN=$data['Polyname'];
}
$strSQL1="select * from doctor where DoctCode='$dok'";
$result = sqlsrv_query($koneksi, $strSQL1);
while($data=sqlsrv_fetch_array($result)){
    $dokN=$data['Name'];
}
$_SESSION["telp"]=$telpon;
$_SESSION["debt"]=$penjamin;
$_SESSION["debtN"]=$penjaminN;
$_SESSION["poli"]=$pol;
$_SESSION["poliN"]=$polN;
$_SESSION["dokter"]=$dok;
$_SESSION["dokterN"]=$dokN;
//$dok=$_SESSION["pol"];
//echo($al);
//echo($nm);
//include("cekVerif.php")
include('koneksi.php');
 ?>
<html>
<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="style.css">

<title>Langkah 3</title>
	<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php include 'style.php' ?>
	<style>
table {
    border-collapse: collapse;
    border: 1px solid black;
}
</style>
<!-- Kode menampilkan peringatan untuk mengaktifkan javascript-->
<div align="center"><noscript>
   <div style="position:fixed; top:0px; left:0px; z-index:3000; height:100%; width:100%; background-color:#FFFFFF">
   <div style="font-family: Arial; font-size: 17px; background-color:#00bbf9; padding: 11pt;">Mohon aktifkan javascript pada browser untuk mengakses halaman ini!</div></div>
</noscript></div>
 
<!--Kode untuk mencegah seleksi teks, block teks dll.-->
<script type="text/javascript">
function disableSelection(e){if(typeof e.onselectstart!="undefined")e.onselectstart=function(){return false};else if(typeof e.style.MozUserSelect!="undefined")e.style.MozUserSelect="none";else e.onmousedown=function(){return false};e.style.cursor="default"}window.onload=function(){disableSelection(document.body)}
</script>
 
<!--Kode untuk mematikan fungsi klik kanan di blog-->
<script type="text/javascript">
function mousedwn(e){try{if(event.button==2||event.button==3)return false}catch(e){if(e.which==3)return false}}document.oncontextmenu=function(){return false};document.ondragstart=function(){return false};document.onmousedown=mousedwn
</script>
 
<style type="text/css">
* : (input, textarea) {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
 
}
</style>
<style type="text/css">
img {
     -webkit-touch-callout: none;
     -webkit-user-select: none;
    }
</style>
 
<!--Kode untuk mencegah shorcut keyboard, view source dll.-->
<script type="text/javascript">
window.addEventListener("keydown",function(e){if(e.ctrlKey&&(e.which==65||e.which==66||e.which==67||e.which==73||e.which==80||e.which==83||e.which==85||e.which==86)){e.preventDefault()}});document.keypress=function(e){if(e.ctrlKey&&(e.which==65||e.which==66||e.which==67||e.which==73||e.which==80||e.which==83||e.which==85||e.which==86)){}return false}
</script>
<script type="text/javascript">
document.onkeydown=function(e){e=e||window.event;if(e.keyCode==123||e.keyCode==18){return false}}
</script>
	
</head>
<div class="container">
<div class="middle"  align=left >
<img src="kopnu.jpg" alt="RSI Purwodadi">
<br>
<body>

	<form id="form1" name="form1" method="post" action="InsData.php">
<div class="box-header with-border">
              <h3 class="box-title">Nomor Rekam Medik : <?php echo($mr) ?></h3>
			  <br>
			  <h3 class="box-title">Nama Pasien&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo($nm) ?></h3>
            <br>
			  <h3 class="box-title">Nomor Telp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo($telpon) ?></h3>
			  <br>
			  <h3 class="box-title">Penjamin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo($penjaminN) ?></h3>
			  <br>
			  <h3 class="box-title">Poli&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo($polN) ?></h3>
			  <br>
			  <h3 class="box-title">Dokter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo($dokN) ?></h3>
			</div>


<script src="jquery-3.3.1.js" type="text/javascript"></script>
<script src="jquery-ui.js" type="text/javascript"></script>
<link href="jquery-ui.css" rel="stylesheet" type="text/css">
<!--
<br>
Tanggal Praktek Dokter : 

<input name="myLocalDate" type="text" id="myLocalDate" readonly>

<script>
$(function() {
	$("#myLocalDate").datepicker({
		dateFormat : "yy-mm-dd",
		minDate : 1,
		maxDate : 3,
	});
});

</script>
-->
<!--<input name="myLocalDate" class="form-control" type="date" id="myLocalDate" step=".1" required/>-->
<div class="row">
        <div class="col-xs-12">
          <div class="box">
			<div class="box-header">
              <h3 class="box-title">Jadwal Dokter,</h3>
            </div>
			
			<div class="box-body">
              <table id="example2" class="table table-bordered table-hover">
                <thead>
				<tr>
<th>TANGGAL (Tahun-Bulan-Hari)</th>
<th>HARI</th>
<th>JAM</th>
<th></th>
</tr>
</thead>
                <tbody>
<?php
/*
$strSQL1="select doctor_cuti.keterangan,
DATE(CURDATE() + 1) as tgl,
case
when date_format(now(),'%w') = 0 THEN 'Senin'
when date_format(now(),'%w') = 1 THEN 'Selasa'
when date_format(now(),'%w') = 2 THEN 'Rabu'
when date_format(now(),'%w') = 3 THEN 'Kamis'
when date_format(now(),'%w') = 4 THEN 'Jumat'
when date_format(now(),'%w') = 5 THEN 'Sabtu'
when date_format(now(),'%w') = 6 THEN 'Minggu'
end as hari,
case
when date_format(now(),'%w') = 0 THEN senin
when date_format(now(),'%w') = 1 THEN selasa
when date_format(now(),'%w') = 2 THEN rabu
when date_format(now(),'%w') = 3 THEN kamis
when date_format(now(),'%w') = 4 THEN jumat
when date_format(now(),'%w') = 5 THEN sabtu
when date_format(now(),'%w') = 6 THEN minggu
end as jam
from jadwaldokter
left outer join doctor on doctor.name = jadwaldokter.dokter
left outer join doctor_cuti on doctor_cuti.doctcode = doctor.DoctCode and doctor_cuti.TglCuti = DATE(CURDATE() + 1)
where dokter ='$dokN'
union all
select doctor_cuti.keterangan,
DATE(CURDATE() + 2) as tgl,
case
when date_format(now(),'%w') = 0 THEN 'Selasa'
when date_format(now(),'%w') = 1 THEN 'Rabu'
when date_format(now(),'%w') = 2 THEN 'Kamis'
when date_format(now(),'%w') = 3 THEN 'Jumat'
when date_format(now(),'%w') = 4 THEN 'Sabtu'
when date_format(now(),'%w') = 5 THEN 'Minggu'
when date_format(now(),'%w') = 6 THEN 'Senin'
end as hari,
case
when date_format(now(),'%w') = 0 THEN selasa
when date_format(now(),'%w') = 1 THEN rabu
when date_format(now(),'%w') = 2 THEN kamis
when date_format(now(),'%w') = 3 THEN jumat
when date_format(now(),'%w') = 4 THEN sabtu
when date_format(now(),'%w') = 5 THEN minggu
when date_format(now(),'%w') = 6 THEN senin
end as jam
from jadwaldokter
left outer join doctor on doctor.name = jadwaldokter.dokter
left outer join doctor_cuti on doctor_cuti.doctcode = doctor.DoctCode and doctor_cuti.TglCuti = DATE(CURDATE() + 2)
where dokter ='$dokN'
UNION all
select doctor_cuti.keterangan,
DATE(CURDATE() + 3) as tgl,
case
when date_format(now(),'%w') = 0 THEN 'Rabu'
when date_format(now(),'%w') = 1 THEN 'Kamis'
when date_format(now(),'%w') = 2 THEN 'Jumat'
when date_format(now(),'%w') = 3 THEN 'Sabtu'
when date_format(now(),'%w') = 4 THEN 'Minggu'
when date_format(now(),'%w') = 5 THEN 'Senin'
when date_format(now(),'%w') = 6 THEN 'Selasa'
end as hari,
case
when date_format(now(),'%w') = 0 THEN rabu
when date_format(now(),'%w') = 1 THEN kamis
when date_format(now(),'%w') = 2 THEN jumat
when date_format(now(),'%w') = 3 THEN sabtu
when date_format(now(),'%w') = 4 THEN minggu
when date_format(now(),'%w') = 5 THEN senin
when date_format(now(),'%w') = 6 THEN selasa
end as jam
from jadwaldokter
left outer join doctor on doctor.name = jadwaldokter.dokter
left outer join doctor_cuti on doctor_cuti.doctcode = doctor.DoctCode and doctor_cuti.TglCuti = DATE(CURDATE() + 3)
where dokter ='$dokN'";
*/
$strSQL1="select isnull(doctor_cuti.keterangan, 
case 
when dbo.condate(getdate()) + 1 in (select tgl from liburnasional ) then 'LIBUR NASIONAL'
else doctor_cuti.keterangan
end)
as keterangan,
FORMAT(getdate() + 1, 'dd MMM yyyy') as tgl,
case
when DATENAME(weekday, getdate() + 1) = 'Monday' THEN 'Senin'
when DATENAME(weekday, getdate() + 1) = 'Tuesday' THEN 'Selasa'
when DATENAME(weekday, getdate() + 1) = 'Wednesday' THEN 'Rabu'
when DATENAME(weekday, getdate() + 1) = 'Thursday' THEN 'Kamis'
when DATENAME(weekday, getdate() + 1) = 'Friday' THEN 'Jumat'
when DATENAME(weekday, getdate() + 1) = 'Saturday' THEN 'Sabtu'
when DATENAME(weekday, getdate() + 1) = 'Sunday' THEN 'Minggu'
end as hari,
case
when DATENAME(weekday, getdate() + 1) = 'Monday' THEN senin
when DATENAME(weekday, getdate() + 1) = 'Tuesday' THEN selasa
when DATENAME(weekday, getdate() + 1) = 'Wednesday' THEN rabu
when DATENAME(weekday, getdate() + 1) = 'Thursday' THEN kamis
when DATENAME(weekday, getdate() + 1) = 'Friday' THEN jumat
when DATENAME(weekday, getdate() + 1) = 'Saturday' THEN sabtu
when DATENAME(weekday, getdate() + 1) = 'Sunday' THEN minggu
end as jam
from jadwaldokter
left outer join doctor on doctor.name = jadwaldokter.dokter
left outer join doctor_cuti on doctor_cuti.doctcode = doctor.DoctCode and dbo.condate(doctor_cuti.TglCuti) = dbo.condate(getdate()) + 1 
where dokter ='$dokN'
union all
select isnull(doctor_cuti.keterangan, 
case 
when dbo.condate(getdate()) + 2 in (select tgl from liburnasional ) then 'LIBUR NASIONAL'
else doctor_cuti.keterangan
end)
as keterangan,
FORMAT(getdate() + 2, 'dd MMM yyyy') as tgl,
case
when DATENAME(weekday, getdate() + 2) = 'Monday' THEN 'Senin'
when DATENAME(weekday, getdate() + 2) = 'Tuesday' THEN 'Selasa'
when DATENAME(weekday, getdate() + 2) = 'Wednesday' THEN 'Rabu'
when DATENAME(weekday, getdate() + 2) = 'Thursday' THEN 'Kamis'
when DATENAME(weekday, getdate() + 2) = 'Friday' THEN 'Jumat'
when DATENAME(weekday, getdate() + 2) = 'Saturday' THEN 'Sabtu'
when DATENAME(weekday, getdate() + 2) = 'Sunday' THEN 'Minggu'
end as hari,
case
when DATENAME(weekday, getdate() + 2) = 'Monday' THEN senin
when DATENAME(weekday, getdate() + 2) = 'Tuesday' THEN selasa
when DATENAME(weekday, getdate() + 2) = 'Wednesday' THEN rabu
when DATENAME(weekday, getdate() + 2) = 'Thursday' THEN kamis
when DATENAME(weekday, getdate() + 2) = 'Friday' THEN jumat
when DATENAME(weekday, getdate() + 2) = 'Saturday' THEN sabtu
when DATENAME(weekday, getdate() + 2) = 'Sunday' THEN minggu
end as jam
from jadwaldokter
left outer join doctor on doctor.name = jadwaldokter.dokter
left outer join doctor_cuti on doctor_cuti.doctcode = doctor.DoctCode and dbo.condate(doctor_cuti.TglCuti) = dbo.condate(getdate()) + 2
where dokter ='$dokN'
UNION all
select isnull(doctor_cuti.keterangan, 
case 
when dbo.condate(getdate()) + 3 in (select tgl from liburnasional ) then 'LIBUR NASIONAL'
else doctor_cuti.keterangan
end)
as keterangan,
FORMAT(getdate() + 3, 'dd MMM yyyy') as tgl,
case
when DATENAME(weekday, getdate() + 3) = 'Monday' THEN 'Senin'
when DATENAME(weekday, getdate() + 3) = 'Tuesday' THEN 'Selasa'
when DATENAME(weekday, getdate() + 3) = 'Wednesday' THEN 'Rabu'
when DATENAME(weekday, getdate() + 3) = 'Thursday' THEN 'Kamis'
when DATENAME(weekday, getdate() + 3) = 'Friday' THEN 'Jumat'
when DATENAME(weekday, getdate() + 3) = 'Saturday' THEN 'Sabtu'
when DATENAME(weekday, getdate() + 3) = 'Sunday' THEN 'Minggu'
end as hari,
case
when DATENAME(weekday, getdate() + 3) = 'Monday' THEN senin
when DATENAME(weekday, getdate() + 3) = 'Tuesday' THEN selasa
when DATENAME(weekday, getdate() + 3) = 'Wednesday' THEN rabu
when DATENAME(weekday, getdate() + 3) = 'Thursday' THEN kamis
when DATENAME(weekday, getdate() + 3) = 'Friday' THEN jumat
when DATENAME(weekday, getdate() + 3) = 'Saturday' THEN sabtu
when DATENAME(weekday, getdate() + 3) = 'Sunday' THEN minggu
end as jam
from jadwaldokter
left outer join doctor on doctor.name = jadwaldokter.dokter
left outer join doctor_cuti on doctor_cuti.doctcode = doctor.DoctCode and dbo.condate(doctor_cuti.TglCuti) = dbo.condate(getdate()) + 3
where dokter ='$dokN'
";
$result = sqlsrv_query($koneksi, $strSQL1);
while($row=sqlsrv_fetch_array($result)){
	echo "<tr>";
	echo "<td>" . $row["tgl"] . "</td>";
	echo "<td>" . $row["hari"] . "</td>";
	if ($row["keterangan"] != "") {
				echo "<td></td>";
			}
			else {
					echo "<td>" . $row["jam"] . "</td>";
			}
	if ($row["keterangan"] == "") {
		if ($row["jam"] == "") {
			echo "<td>Tidak Ada Jadwal..</td>";
		}
		else {
	//echo "<td><a href='insdata.php?id=$row[tgl]'>PILIH</a></td>";	
				echo "<td><a href='insdata.php?id=$row[tgl]&jam=$row[jam]'>PILIH</a></td>";		
			}
		
	
	}
	else {
		
		echo "<td>" . $row["keterangan"] . "</td>";
	}
}

?>
</tbody>
 </table>
	</div>
	</div>
	</div>
	</div>
<br>
<br>
	<div class="btn-group">
                      <button type="button" name="Submit2" onClick="location='admisi.php'" class="btn btn-info">&lt;&lt; Kembali</button>
       
                    </div>
	<!--<script src="jquery-1.10.2.min.js"></script> -->
        <script src="jquery.chained.min.js"></script>
        <script>
            $("#dokter").chained("#poli");
            //$("#kecamatan").chained("#kota");
        </script>
</form>
</body>
</div>
<br>
	<div class="middle" align=center >
<a class="gb_ne gb_qc gb_le" href="https://play.google.com/store/apps/details?id=app.bpjs.mobile&pcampaignid=web_share" title="Aplikasi JKN Mobile"><img class="gb_oa" src="playstorelogo.png" style="width:30px;height:30px" data-atf="true"></a>
  <strong><a title="Aplikasi JKN Mobile" href="https://play.google.com/store/apps/details?id=app.bpjs.mobile&pcampaignid=web_share" target="_blank" rel="noopener">Download Aplikasi JKN Mobile</a></strong>
  <br>
<footer>
<p></p>
                <p align=center>&copy; 2020 - RSI PURWODADI</p>
            </footer>
	
</html>