<link href="<?php echo $base?>plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<script src="<?php echo $base?>plugins/datatables/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(document).ready(function(){
	var base = <?php echo json_encode($base);?>;
	
	$("#example1").dataTable();
	
	$('.context').click(function(e){
		var kode = $(this).attr('id');
		$('#kodekunci').val(kode);
   		$("#menuklik").modal('show');
	});
	
	/*$('.context').bind('contextmenu', function(e){
		e.preventDefault();
    	var kode = $(this).attr('id');
		$('#kodekunci').val(kode);
   		$("#menuklik").modal('show');
	});*/
	
	$('#editdata').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'edit-dosen/'+ kode +'';
	});
	
	$('#nonaktif').click(function(){
		var kode = $('#kodekunci').val();
		if (confirm("Anda yakin me-nonaktifkan data dengan kode " + kode+"?")){
			window.location=''+base+'query-delete-dosen/'+ kode +'';	
		}
	});
	
	$('#newdata').click(function(){
		window.location=''+base+'add-dosen';
	});

  });
   
</script>
<script type="text/javascript">
    var detik = <?php echo date('s'); ?>;
    var menit = <?php echo date('i'); ?>;
    var jam   = <?php echo date('H'); ?>;
    
    function clock()
    {
        if (detik!=0 && detik%60==0) {
            menit++;
            detik=0;
        }
        second = detik;
        
        if (menit!=0 && menit%60==0) {
            jam++;
            menit=0;
        }
        minute = menit;
        
        if (jam!=0 && jam%24==0) {
            jam=0;
        }
        hour = jam;
        
        if (detik<10){
            second='0'+detik;
        }
        if (menit<10){
            minute='0'+menit;
        }
        
        if (jam<10){
            hour='0'+jam;
        }
        waktu = hour+':'+minute+':'+second;
        
        document.getElementById("clock").innerHTML = waktu;
        detik++;
    }

    setInterval(clock,1000);
</script>
<aside class="right-side">                
                <section class="content-header">
                    <h1>
                        Data Jadwal 
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="home"><i class="fa fa-dashboard"></i> Home</a></li>
                        <li><a href="#">Kelola Data</a></li>
                        <li><a href="data-jadwal">Data Jadwal</a></li>
                        <li class="active">Detail Jadwal</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
        <div class="box-body">
            <div class="row">
			<?php  
					$idjawal = $xcode;
				    include("config/connection.php");
              		$sql ="select tb_jadwal.*, tb_kapal.Nama as namakapal, tb_nahkoda.Nahkoda, pDari.Nama as dari, pTujuan.Nama as tujuan
							from tb_jadwal inner join tb_kapal on tb_jadwal.Id_Kapal = tb_kapal.Id_Kapal
							inner join tb_nahkoda on tb_jadwal.Id_Nahkoda = tb_nahkoda.Id_Nahkoda
							inner join tb_pelabuhan pDari on (pDari.Id_Pelabuhan = tb_jadwal.Dari)
							inner join tb_pelabuhan pTujuan on (pTujuan.Id_Pelabuhan = tb_jadwal.Tujuan) 
							where tb_jadwal.Status = '1' and tb_jadwal.Id_Jadwal = '".$idjawal."'";
					$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
					mysql_close($test);
					
					$row = mysql_fetch_object($hasil);
						$id = $row->Id_Jadwal;
						$namakapal = $row->namakapal;
						$Nahkoda = $row->Nahkoda;
						$dari = $row->dari;
						$tujuan = $row->tujuan;
						$Kuota_Order = $row->Kuota_Order;
						$Sisa = $row->Sisa;
						
			?>
                <div class="col-sm-6">
                	<h5>Id Jadwal : <?php echo $id?></h5>
                    <h5>Nama Kapal :<?php echo $namakapal?></h5>
                    <h5>Nahkoda : <?php echo $Nahkoda?></h5>
                </div>
                <div class="col-sm-6">
                	<h5>Dari : <?php echo $dari?></h5>
                    <h5>Tujuan : <?php echo $tujuan?></h5>
                    <h5>Kuota Order :<?php echo $Kuota_Order?></h5>
                </div>
         	</div>
        <div class="table-responsive" style="margin-top:10px;">
          <table id="example1" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>Jenis Angkutan /Penumpang</th>
                    <th>Harga</th>
                </tr>
            </thead>
            <tbody>
			<?php  
				    include("config/connection.php");
              		$sql ="select tb_detil_angkutan_def.harga, tb_detil_angkutan_def.id, tb_angkutan.nama as angkutan 
							from tb_jadwal
							inner join tb_detil_angkutan_def on tb_jadwal.Id_Jadwal = tb_detil_angkutan_def.id_jadwal
							inner join tb_angkutan on tb_detil_angkutan_def.id_angkutan = tb_angkutan.id_angkutan 
							 order by tb_detil_angkutan_def.id_angkutan asc";
					$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
					mysql_close($test);
					
					while($row = mysql_fetch_object($hasil)){
						$id = $row->id;
						$harga = $row->harga;
						$angkutan = $row->angkutan;
						
			?>
            		<tr>
                        <td><?php echo $angkutan ?></td>
                        <td><?php echo number_format($harga) ?></td>
                    </tr>
            <?php		
					}
			?>         
        	</tbody>
          </table>
          </div>
        </div><!-- /.box-body -->
      </div><!-- /.box -->
    </div><!-- /.col -->
  </div><!-- /.row -->
  
                            <div class="modal fade" id="modalInsert" tabindex="-1" role="dialog">
                                <div class="modal-dialog modal-lg">
                                    <div class="modal-content">
                                    <form class="form-horizontal" role="form" method="POST" enctype="multipart/form-data" action="<?php echo $base?>data-jadwal-detil-proses">
                                    	<input type="hidden" name="act" value="2">
                                        <input type="hidden" name="idjadwal" value="<?php echo $idjawal?>">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalLabel">Tambah Angkutan Jadwal</h4>
                                        </div>
                                        <div class="modal-body" style="padding-left:50px; padding-right:50px;">
                                            <div class="form-group">
                                                <label for="Operator" class="control-label">Nama Angkutan</label>
                                                <select name="idangkutan" class="form-control">
											<?php  
												include("config/connection.php");
												$sql ="select * from tb_angkutan where id_angkutan not in (select id_angkutan from tb_detil_angkutan_def)";
												$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
												mysql_close($test);
												
												while($row = mysql_fetch_object($hasil)){
													$id = $row->id_angkutan;
													$nama = $row->nama;
																																				
											?>
												<option value="<?php echo $id ?>" ><?php echo $nama?></option>
                                             <?php } ?> 
                                             	</select>  
                                             </div>
                                            <div class="form-group">
                                                <label for="Operator" class="control-label">Harga</label>
												<input type="text" class="form-control" name="harga">
                                             </div>
                                        </div> 
                                        <div class="modal-footer">
                                            <div class="form-group">  
                                                <label class="col-sm-2" for="aksi"></label>      
                                                    <div class="col-sm-10">
                                                        <button type="submit" class="btn btn-success"><i class='glyphicon glyphicon-save'></i> Simpan</button>
                                                    </div>
                                            </div>
                                        </div>
                                    </form>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>


                            <div class="modal fade" id="modalEdit" tabindex="-1" role="dialog">
                                <div class="modal-dialog modal-lg">
                                    <div class="modal-content">
                                    <form class="form-horizontal" role="form" method="POST" enctype="multipart/form-data" action="data-abk-proses">
                                       <input type="hidden" name="act" value="2">
                                       <input type="hidden" name="id" id="id">
                                        <div class="modal-header">

                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalLabel">Ubah Data ABK</h4>
                                        </div>
                                        <div class="modal-body" style="padding-left:50px; padding-right:50px;">
                                            <div class="form-group">
                                                <label for="Operator" class="control-label">Nama ABK</label>
                                                <input type="text" name="nama" required="required" class="form-control" id="nama">
                                             </div>
                                            <div class="form-group">
                                                <label for="Operator" class="control-label">Alamat</label>
                                                <input type="text" name="alamat" class="form-control" id="alamat">
                                             </div>
                                            <div class="form-group">
                                                <label for="Operator" class="control-label">Telepon</label>
                                                <input type="text" name="telepon"  class="form-control" id="telp">
                                             </div>
                                        </div> 
                                        <div class="modal-footer">
                                            <div class="form-group">  
                                                <label class="col-sm-2" for="aksi"></label>      
                                                    <div class="col-sm-10">
                                                        <button type="submit" class="btn btn-success"><i class='glyphicon glyphicon-save'></i> Simpan</button>
                                                    </div>
                                            </div>
                                        </div>
                                    </form>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>
                            <div class="modal fade" id="modalDelete" tabindex="-1" role="dialog">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalLabel">Non Aktif Data Angkutan</h4>
                                        </div>
                                        <div class="modal-body">
                                            <form class="form-horizontal" role="form" name="form_kepala_delete" method="POST" enctype="multipart/form-data" id="form_kepala_delete" action="<?php echo $base?>data-jadwal-detil-proses">
                                                <input type="hidden" id="idd" name="id">
                                                <input type="hidden" name="act" value="4">
                                                <input type="hidden" name="idjadwal" value="<?php echo $idjawal?>">
                                            <p>Apakah Anda Yakin Akan Menghapus data ini?</p>
                                        </div>
                                        <div class="modal-footer"> 
                                            <button type="button" class="btn btn-warning" data-dismiss="modal">Tidak</button>
                                            <button type="submit" class="editflag btn btn-success" >Yakin</button>    
                                        </div>
                                            </form>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>
    <script>
        $(document).on("click", ".open-Edit", function () {
            var Id = $(this).data('id');
            //event.preventDefault();
            $.ajax({
                type: "get",
                url: "data-abk-proses.php?actget=1",
                data: "id="+Id,
                success: function(data){
                    var jdata = jQuery.parseJSON(data);
                    $('#id').val(jdata.id_abk);
					$('#nama').val(jdata.nama);
                    $('#alamat').val(jdata.alamat);
                    $('#telp').val(jdata.telp);
                    $("#modalEdit").modal('show');
                },
                error: function(){
                    alert("failure");
                }
            });
        });
        $(document).on("click", ".open-Delete", function () {
            var Id = $(this).data('id');
            //event.preventDefault();
            $('#idd').val(Id);
            $('#modalDelete').modal('show');
        });

    </script>
