<link rel="stylesheet" href="themes/base/jquery.ui.all.css">
<link rel="stylesheet" href="css/chosen.css">
<link rel="stylesheet" type="text/css" href="plugins/datatables/jquery.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="plugins/datatables/dataTables.bootstrap.css"/>
<script src="plugins/datepicker/js/jquery-1.7.2.js"></script>
<script src="plugins/datepicker/ui/jquery.ui.core.js"></script>
<script src="plugins/datepicker/ui/jquery.ui.widget.js"></script>
<script src="plugins/datepicker/ui/jquery.ui.datepicker.js"></script>
<script>
	$(function() {
		$( "#datepicker" ).datepicker({
            format : ('yyyy-mm-dd')
		});
	});
</script>
<script>
    
</script>
<div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            SURAT PENGANTAR BARU
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
           
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
        <!-- TAB INDUK PENDUDUK --------------------------------------------------------------------->
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">Pengantar UKS</h3>
                            <div class="box-tools pull-right">
                                <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                                <button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                            </div>
                    </div><!-- /.box-header -->
                    <div class="box-body">
                        <?php         
                        require 'plugins/bulan.php';
                        include 'koneksi.php';
                        $stringbulan=date("m");
                        $bulan=bulanindonesia($stringbulan);
                        $sql ="SELECT max(ID) as terakhir from surat ";
                        $hasil = mysql_query($sql);
                        $data = mysql_fetch_array($hasil);
                        $lastID = $data['terakhir'];
                        $lastNoUrut = substr($lastID, 3, 9);
                        $nextNoUrut = $lastNoUrut + 1;
                        $nextID = sprintf("%03s",$nextNoUrut)."/UKS/";
                         ?>
                        <form action="indexadmin.php?p=PriviewSKCK" name="" target="_blank" method="POST">
                        <div class="row">   
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label for="inputName" class="col-sm-5 control-label">No Surat</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control" id="NoSurat" name="NoSurat" required value="<?php echo $nextID; ?><?php echo $bulan; ?>/<?php echo date('Y'); ?>" readonly>
                                        <input type="hidden" class="form-control" id="idnama" name="idnama" required>
										<input type="hidden" class="form-control" id="Tipe" name="Tipe" value="Surat Pengantar SKCK" required>
                                    </div>
                                </div>
                                <br><br> 
                                <div class="form-group">
                                    <label for="" class="col-sm-5 control-label">Tanggal</label>
                                    <div class="col-sm-6">
                                        <input type="text" class="form-control" id="datepicker" name="TanggalSurat" value="<?php echo date('Y-m-d'); ?>" required>
                                    </div>
                                </div>
                                <br><br> 
                                <div class="form-group">
                                    <label for="" class="col-sm-5 control-label">Nama</label>
                                    <div class="col-lg-7">
                                        <div class="input-group">
                                            <input type="text" class="form-control" placeholder="Cari Nama" id="Nama" name="Nama" readonly>
                                            <span class="input-group-btn">
                                                <button class="btn btn-default" type="button" data-toggle="modal" data-target="#carinama">Cari</button>
                                            </span>
                                        </div>
                                    </div>
                                </div> 
                                <br><br>
                                <div class="form-group">
                                    <label for="" class="col-sm-5 control-label">No Peserta</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control" id="NoKTP" readonly name="NoKTP">
                                    </div>
                                </div>
                                <br><br>
                                <div class="form-group">
                                    <label for="" class="col-sm-5 control-label">No Registrasi</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control" id="NoKK" readonly name="NoKK">
                                    </div>
                                </div>
                                <br><br>
                                <div class="form-group">
                                    <label for="inputName" class="col-sm-5 control-label">Tempat Lahir</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control" id="TempatLahir" readonly name="TempatLahir">
                                    </div>
                                </div>
                                <br><br>
                                <div>
                                    <label for="inputName" class="col-sm-5 control-label">Tanggal Lahir</label>
                                    <div class="col-sm-7">
                                        <input type="date" class="form-control" id="TglLahir" readonly name="TglLahir">
                                    </div>
                                </div>
                            </div>
                            
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label for="inputName" class="col-sm-5 control-label">Rekam Medis</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control" id="Jalan" readonly name="Jalan">
                                    </div>
                                </div>
                                <br><br>
                                <div class="form-group">
                                    <label for="inputName" class="col-sm-5 control-label">Tindakan</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control" id="RT" readonly name="RT">
                                    </div>
									 <br><br>
                                    <label for="inputName" class="col-sm-5 control-label">Obat</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control" id="RW" readonly name="RW">
                                    </div>
                                </div>
                                <br><br>
                                <?php 
                                include 'koneksi.php';
                                $query1 = mysql_query("SELECT * FROM contact");
                                    while ($data1 = mysql_fetch_array($query1)) {
                                    ?>
                                
                               
                                <?php } ?>
                                <div class="form-group">
                                    <label for="inputName" class="col-sm-5 control-label">Agama</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control" id="Agama" readonly name="Agama">
                                    </div>
                                </div>
                                  </div>
                                <br><br>
                            </div>
                        </div> 
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <label for="inputName" class="col-sm-2 control-label">Keperluan</label>
                                    <div class="col-sm-10">
                                        <textarea class="form-control" name="Keperluan"></textarea>
                                    <br><br>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputName" class="col-sm-2 control-label">Keterangan</label>
                                    <div class="col-sm-10">
                                        <textarea class="form-control" name="Keterangan"></textarea> <br> 
                                    </div>
                                </div>
                            </div>
                        </div> 
                                <div class="box-footer">
                                    <div style="float:right;">
                                        <button type="Submit"  name="Cetak1" class="btn btn-primary" id="Cetak1" data-toggle="modal" data-target="#Cetak"><i class="fa fa-print"> Priview </i></button>
                                    </div>
                                </div>
                           
                        </form>                
                    </div><!-- ./box-body -->
                </div><!-- /.box -->
            </div><!-- /.col -->
        </div><!-- /.row -->
        <!-- TAB END INDUK PENDUDUK -->    
    </section>
</div>

<div class="modal fade" id="carinama" tabindex="-1" role="dialog" aria-labelledby="carinama" aria-hidden="true">
  	<div class="modal-dialog modal-lg">
    	<div class="modal-content">
            
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="cariibu">Form Pencarian</h4>
      		</div>
      		<div class="modal-body">            
                <form name="form" method="post" action="">
                <div class="table-responsive">
                <table id="table" class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th style="width:px;">Nama</th>
                                            <th style="width:px;">No KTP</th>
                                            <th style="width:px;">No KK</th>
                                            <th style="width:px;">Tempat Lahir</th>
                                            <th style="width:px;">Tanggal Lahir</th>
                                            <th style="width:px;">Jalan</th>
                                            <th style="">RT</th>
                                            <th style="width:px;">RW</th>
                                            <td style="width:px; display:none;"></td>
											<td style="width:px; display:none;"></td>
											<td style="width:px; display:none;"></td>
											<td style="width:px; display:none;"></td>
											<td style="width:px; display:none;"></td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php
                                    $query = mysql_query("SELECT * FROM penduduk where Keterangan <> 'Mutasi Keluar' ");
                                    while ($data = mysql_fetch_array($query)) {
                                    ?>
                                        <tr>
                                            <td><?php echo $data['Nama']; ?></td>         
                                            <td><a href="#"><?php echo $data['NoKTP']; ?></a></td>
                                            <td><?php echo $data['NoKK']; ?></td>
                                            <td><?php echo $data['TempatLahir']; ?></td>
                                            <td><?php echo $data['TglLahir']; ?></td>
                                            <td><?php echo $data['Jalan']; ?></td>
                                            <td><?php echo $data['RT']; ?></td>
                                            <td><?php echo $data['RW']; ?></td>
                                            <td style="width:px; display:none;"><?php echo $data['Agama']; ?></td>
                                            <td style="width:px; display:none;"><?php echo $data['Kewarganegaraan']; ?></td>
                                            <td style="width:px; display:none;"><?php echo $data['JenKel']; ?></td>
                                            <td style="width:px; display:none;"><?php echo $data['Pekerjaan']; ?></td>
                                            <td style="width:px; display:none;"><?php echo $data['id']; ?></td>
                                        </tr>
                                      <?php
                                      }
                                      ?>
                                    </tbody>
                                </table>
                </div>
            </div>
      		<div class="modal-footer">
                <button type="close" class="btn btn-default" data-dismiss="modal"><i class="fa fa-close"></i> Close</button>
                </form>
      		</div>
    	
        </div>
  	</div>
</div>

<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script type="text/javascript" charset="utf8" src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.js"></script>
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script>
  $(function(){
    $("#table").dataTable();
  });
</script>

<script type="text/javascript"> 
$(document).ready(function ()  
{  
   
$("#table td:nth-child(2)").click(function(event){  
  
//Prevent the hyperlink to perform default behavior  
//event.preventDefault();  
//alert($(event.target).text())  
  
var $td= $(this).closest('tr').children('td');   
var Nama= $td.eq(0).text();  
var NoKTP= $td.eq(1).text();
var NoKK= $td.eq(2).text();  
var TempatLahir= $td.eq(3).text();
var TglLahir= $td.eq(4).text();
var Jalan= $td.eq(5).text();  
var RT= $td.eq(6).text();
var RW= $td.eq(7).text();
var Agama= $td.eq(8).text();
var Kewarganegaraan= $td.eq(9).text();
var JenKel= $td.eq(10).text();
var Pekerjaan= $td.eq(11).text();
var id= $td.eq(12).text();
document.getElementById("Nama").value = Nama;
document.getElementById("NoKTP").value = NoKTP;
document.getElementById("NoKK").value = NoKK;
document.getElementById("TempatLahir").value = TempatLahir;
document.getElementById("TglLahir").value = TglLahir;
document.getElementById("Jalan").value = Jalan;
document.getElementById("RT").value = RT;
document.getElementById("RW").value = RW;
document.getElementById("Agama").value = Agama;
document.getElementById("Kewarganegaraan").value = Kewarganegaraan;
document.getElementById("JenKel").value = JenKel;
document.getElementById("Pekerjaan").value = Pekerjaan;
document.getElementById("idnama").value = id;
     $('#carinama').modal('hide');}  
  
);  
  
});  
  
</script>
  
<script>
function printDiv(divName) {
     var originalContents = document.body.innerHTML;
     var printContents = document.getElementById(divName).innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}
</script>  