<link href="<?php echo $base?>plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/iCheck/all.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet"/>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/iCheck/icheck.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $base?>plugins/autocomplete/shieldui-all.css" />
<link href="<?php echo $base?>bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/locales/bootstrap-datetimepicker.id.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>plugins/autocomplete/shieldui-all.min.js"></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>
<script type="text/javascript">
 function hourChange(selectObj) {
   var selectIndex=selectObj.selectedIndex;
   var selectValue=selectObj.options[selectIndex].text;
   if (selectIndex == 0){
	   document.getElementById("cbpenumpang").selectedIndex = "0";
		$('#penumpang').show();
		$('#kendaraan').hide();
		$('#dewasa').show();
		$('#anak').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
   } else if (selectIndex == 1){
	   document.getElementById("cbkendaraan").selectedIndex = "0";
		$('#penumpang').hide();
		$('#kendaraan').show();
		$('#dewasa').hide();
		$('#anak').hide();
		$('#gol_1').show();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
   }	
 }
</script>
<script type="text/javascript">
 function hourChange2(selectObj) {
   var selectIndex=selectObj.selectedIndex;
   var selectValue=selectObj.options[selectIndex].text;
   if (selectIndex == 0){
		$('#dewasa').show();
		$('#anak').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
	
   } else if (selectIndex == 1){
		$('#anak').show();
		$('#dewasa').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
   }	
 }
</script>
<script type="text/javascript">
 function hourChange3(selectObj) {
   var selectIndex=selectObj.selectedIndex;
   var selectValue=selectObj.options[selectIndex].text;
   if (selectIndex == 0){
		$('#dewasa').hide();
		$('#anak').hide();
		$('#gol_1').show();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
	
   } else if (selectIndex == 1){
		$('#anak').hide();
		$('#dewasa').hide();
		$('#gol_1').hide();
		$('#gol_2').show();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
   }else if (selectIndex == 2){
		$('#anak').hide();
		$('#dewasa').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').show();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
   }else if (selectIndex == 3){
		$('#anak').hide();
		$('#dewasa').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').show();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
   }else if (selectIndex == 4){
		$('#anak').hide();
		$('#dewasa').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').show();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
   }else if (selectIndex == 5){
		$('#anak').hide();
		$('#dewasa').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').show();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
   }else if (selectIndex == 6){
		$('#anak').hide();
		$('#dewasa').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').show();
		$('#gol_6a').hide();
		$('#gol_6b').hide();
   }else if (selectIndex == 7){
		$('#anak').hide();
		$('#dewasa').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').show();
		$('#gol_6b').hide();
   }else if (selectIndex == 8){
		$('#anak').hide();
		$('#dewasa').hide();
		$('#gol_1').hide();
		$('#gol_2').hide();
		$('#gol_3').hide();
		$('#gol_4a').hide();
		$('#gol_4b').hide();
		$('#gol_5a').hide();
		$('#gol_5b').hide();
		$('#gol_6a').hide();
		$('#gol_6b').show();
   }	
 }
</script>
<aside class="right-side">                
                <section class="content-header">
                    <h1>
                        Pemesanan Tiket
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="home"><i class="fa fa-dashboard"></i> Home</a></li>
                        <li><a href="#">Tiket</a></li>
                        <li class="active">Transaksi Pemesanan Tiket</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                    <a href="<?php echo $base?>daftar-jadwal" class="btn btn-primary" style="color:#FFF; float:right; margin-right:40px;"><i class="fa fa-bars"></i> Daftar Jadwal</a>
                                </div><!-- /.box-header -->
                               <?php
								$idjadwal = $xcode;

							    	if($idjadwal==""){
	
								?> 
									<script>window.location = "<?php echo $base?>daftar-jadwal"</script>
                                <?php
                                }
				    include("config/connection.php");
              		$sql ="select tb_jadwal.*, DATE_FORMAT(tb_jadwal.tanggal,'%d-%m-%Y') as tgl, tb_kapal.Nama as namakapal, tb_nahkoda.Nahkoda, pDari.Nama as dari, pTujuan.Nama as tujuan, tb_jenis_kapal.Jenis
							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)
							inner join tb_jenis_kapal on tb_kapal.Id_Jenis = tb_jenis_kapal.Id
							where tb_jadwal.Status = '1' and tb_jadwal.Id_Jadwal = '".$idjadwal."'";
					$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;
						$tanggal = $row->tgl;
						$Waktu = $row->Waktu;
						$Jenis = $row->Jenis;
						
						$dewasa = $row->dewasa;
						$anak = $row->anak;
						$gol_1 = $row->gol_1;
						$gol_2 = $row->gol_2;
						$gol_3 = $row->gol_3;
						$gol_4a = $row->gol_4a;
						$gol_4b = $row->gol_4b;
						$gol_5a = $row->gol_5a;
						$gol_5b = $row->gol_5b;
						$gol_6a = $row->gol_6a;
						$gol_6b = $row->gol_6b;

			?>
        <div class="box-body">
        	<div class="col-sm-8">
                <form class="form-horizontal" role="form" method="POST" enctype="multipart/form-data" action="<?php echo $base?>pemesanan-tiket-proses">
                    <input type="hidden" name="id_jadwal" value="<?php echo $idjadwal?>">
                    <input type="hidden" name="act" value="1">
                    <div  style="min-height:30px;">
                        <h2 class="modal-title" id="myModalLabel" style="float:right">
                        	
                            <div id="dewasa">Rp.<?php echo number_format($dewasa)?></div>
                            <div id="anak" style="display:none">Rp.<?php echo number_format($anak)?></div>
                            <div id="gol_1" style="display:none">Rp.<?php echo number_format($gol_1)?></div>
                            <div id="gol_2" style="display:none">Rp.<?php echo number_format($gol_2) ?></div>
                            <div id="gol_3" style="display:none">Rp.<?php echo number_format($gol_3) ?></div>
                            <div id="gol_4a" style="display:none">Rp.<?php echo number_format($gol_4a) ?></div>
                            <div id="gol_4b" style="display:none">Rp.<?php echo number_format($gol_4b) ?></div>
                            <div id="gol_5a" style="display:none">Rp.<?php echo number_format($gol_5a) ?></div>
                            <div id="gol_5b" style="display:none">Rp.<?php echo number_format($gol_5b) ?></div>
                            <div id="gol_6a" style="display:none">Rp.<?php echo number_format($gol_6a) ?></div>
                            <div id="gol_6b" style="display:none">Rp.<?php echo number_format($gol_6b) ?></div>
                        </h2>
                    </div>
                    <div class="modal-body" >
                        <div class="form-group">
                            <label for="Operator" class="control-label" >Jenis Angkutan</label>
                            <select name="jenisangkutan" class="form-control" onchange="hourChange(this);">
								<?php  
                                    include("config/connection.php");
                                    $sql ="select * from tb_jenis_angkutan ";
                                    $hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
                                    mysql_close($test);
                                    
                                    while($row = mysql_fetch_object($hasil)){
                                        $id_jenis_angkutan = $row->id_jenis_angkutan;
                                        $namajenis = $row->nama;
                                ?>
                                <option value="<?php echo $id_jenis_angkutan?>"><?php echo $namajenis?></option>
                                <?php } ?>
                            </select>
                         </div>
                        <div class="form-group" id="penumpang">
                            <label for="Operator" class="control-label" >Penumpang</label>
                            <select name="penumpang" class="form-control" onChange="hourChange2(this);" id="cbpenumpang">
								<?php  
                                    include("config/connection.php");
                                    $sql ="select * from tb_angkutan where id_jenis_angkutan = 1";
                                    $hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
                                    mysql_close($test);
                                    
                                    while($row = mysql_fetch_object($hasil)){
                                        $id_angkutan = $row->id_angkutan;
                                        $namaangkutan = $row->nama;
                                ?>
                                <option value="<?php echo $id_angkutan?>"><?php echo $namaangkutan?></option>
                                <?php } ?>
                            </select>
                         </div>
                        <div class="form-group" id="kendaraan" style="display:none;">
                            <label for="Operator" class="control-label">Kendaraan</label>
                            <select name="kendaraan" class="form-control" onChange="hourChange3(this);" id="cbkendaraan">
								<?php  
                                    include("config/connection.php");
                                    $sql ="select * from tb_angkutan where id_jenis_angkutan = 2";
                                    $hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
                                    mysql_close($test);
                                    
                                    while($row = mysql_fetch_object($hasil)){
                                        $id_angkutan = $row->id_angkutan;
                                        $namaangkutan = $row->nama;
                                ?>
                                <option value="<?php echo $id_angkutan?>"><?php echo $namaangkutan?></option>
                                <?php } ?>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="Operator" class="control-label">No. Identitas (KTP/SIM/Lainnya)</label>
                            <input type="text" name="no_identitas" required="required" class="form-control" >
                         </div>
                        <div class="form-group">
                            <label for="Operator" class="control-label">Nama</label>
                            <input type="text" name="nama" required="required" class="form-control" >
                         </div>
                    </div> 
                    <div class="modal-footer">
                        <div class="form-group">  
                            <label class="col-sm-2" for="aksi"></label>      
                                <div class="col-sm-10">
                                	<button class="btn btn-warning" style="width:80px"><i class='fa fa-level-up'></i> Reset</button>
                                    <button type="submit" class="btn btn-success" style="width:80px"><i class='glyphicon glyphicon-ok'></i> Beli</button>
                                </div>
                        </div>
                    </div>
                </form>
                </div>
        	<div class="col-sm-4" style="border-radius: 7px ; padding-top:20px; padding-bottom:20px; ">
                <div style="background-color:#3c8dbc; border-radius: 7px 7px 0px 0px; ">
                    <div style="padding:5px;color:#FFF; text-align:center">
                        <h3><?php echo $namakapal?></h3>
                        <h4><?php echo $dari." - ".$tujuan?></h2>
                     </div>
                </div> 
                <div class="callout callout-info">
                    <h4>Kuota : <?php echo $Kuota_Order?></h4>
                    <h4>Sisa : <?php echo $Sisa?></h4>
                </div> 
                <div clas="modal-body" style="padding:10px;">
                    <ul class="list-group">
                        <li class="list-group-item">Tipe Kapal : <?php echo $Jenis?></li>
                        <li class="list-group-item">Tanggal : <?php echo $tanggal?></li>
                        <li class="list-group-item">Waktu : <?php echo $Waktu?> Wita</li>
                    </ul>
                </div> 
                <div class="callout callout-info" style="margin-bottom:0px; padding-bottom: 25px">  
                    <label  for="aksi"></label>      
                    <a data-toggle="modal" href="#modalInsert"><button type="submit" class="btn btn-info" style="float:right; width:80px"><i class='glyphicon glyphicon-search'></i> Info</button></a>
                </div>
                <div style="background-color:#3c8dbc; border-radius: 0px 0px 7px 7px; min-height:10px; ">
                </div> 
            </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">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalLabel">Informasi Jadwal</h4>
                                        </div>
                                        <div class="modal-body" style="padding-left:50px; padding-right:50px;">
                                            <div class="form-group">
                                            	<div class="list-group-item active" style="color: #fff; background-color: #0275d8;border-color: #0275d8;">					 													Nahkoda
                                                </div>
                                                <div class="list-group-item"><?php echo $Nahkoda?></div>
                                            </div>
                                            <div class="form-group">
                                            	<div class="list-group-item" style="color: #fff; background-color: #0275d8;border-color: #0275d8;">Anak Buah Kapal</div>
                                                <ul class="list-group">
												<?php  
													include("config/connection.php");
													$sql ="select tb_abk.* from tb_jadwal_detil inner join tb_abk on tb_jadwal_detil.id_abk = tb_abk.id_abk where tb_jadwal_detil.id_jadwal = '".$idjadwal."'";
													$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
													mysql_close($test);
													
													while($row = mysql_fetch_object($hasil)){
														$namaabk = $row->nama;
												?>
                                                    <li class="list-group-item"><?php echo $namaabk?></li>
                                                <?php } ?>
                                                </ul>
                                             </div>
                                             <div class="form-group">
                                            	<div class="list-group-item" style="color: #fff; background-color: #0275d8;border-color: #0275d8;">Harga Tiket Penumpang</div>
                                                <div class="list-group-item">Dewasa : Rp. <?php echo number_format($dewasa) ?></div>
                                                <div class="list-group-item">Anak - anak : Rp. <?php echo number_format($dewasa)?></div>
											</div>
                                             <div class="form-group">
	                                            <div class="list-group-item" style="color: #fff; background-color: #0275d8;border-color: #0275d8;">Harga Tiket Kendaraaan</div>
                                                <div class="list-group-item">Gol I - Sepeda : Rp. <?php echo number_format($gol_1) ?></div>
                                                <div class="list-group-item">Gol II - Sepeda Motor : Rp. <?php echo number_format($gol_2) ?></div> 
                                                <div class="list-group-item">Gol III - Sepeda Motor > 500 cc : Rp. <?php echo number_format($gol_3) ?></div> 
                                                <div class="list-group-item">Gol IV A - Mobil / Sedan : Rp. <?php echo number_format($gol_4a) ?></div> 
                                                <div class="list-group-item">Gol IV B - Mobil Barang Sedang : Rp. <?php echo number_format($gol_4b) ?></div> 
                                                <div class="list-group-item">Gol V A - Bus Sedang : Rp. <?php echo number_format($gol_5a) ?></div> 
                                                <div class="list-group-item">Gol V B - Truk Sedang : Rp. <?php echo number_format($gol_5b) ?></div> 
                                                <div class="list-group-item">Gol VI A - Bus Besar : Rp. <?php echo number_format($gol_6a) ?></div> 
                                                <div class="list-group-item">Gol VI B - Truk Besar : Rp. <?php echo number_format($gol_6b) ?></div> 
                                         	</div>
                                        </div> 
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-warning" data-dismiss="modal">Tutup</button>
                                        </div>
                                    </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-jadwal-proses.php?actget=1",
                data: "id="+Id,
                success: function(data){
					        
                    var jdata = jQuery.parseJSON(data);
                    $('#id').val(jdata.Id_Jadwal);
					$('#Waktu').val(jdata.Waktu);
					$('#Kuota_Order').val(jdata.Kuota_Order);
					$('#Harga').val(jdata.Harga);
					$('#tanggal').val(jdata.tgl);
					$('#tgl').val(jdata.tanggal);
					
					$('#Id_Kapal').val(jdata.Id_Kapal).attr('selected',true);
                    var option = document.createElement("option");
                    option.value = jdata.Id_Kapal;
                    option.text = jdata.namakapal;
                    var select = document.getElementById("Id_Kapal");

					$('#Id_Nahkoda').val(jdata.Id_Nahkoda).attr('selected',true);
                    var option2 = document.createElement("option");
                    option2.value = jdata.Id_Nahkoda;
                    option2.text = jdata.Nahkoda;
                    var select = document.getElementById("Id_Nahkoda");

					$('#Dari').val(jdata.Dari).attr('selected',true);
                    var option3 = document.createElement("option");
                    option3.value = jdata.Dari;
                    option3.text = jdata.peldari;
                    var select = document.getElementById("Dari");

					$('#Tujuan').val(jdata.Dari).attr('selected',true);
                    var option3 = document.createElement("option");
                    option4.value = jdata.Tujuan;
                    option4.text = jdata.peltujuan;
                    var select = document.getElementById("Tujuan");
					
                    $("#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>
<script type="text/javascript">
            $('#timepicker2').timepicker({
                minuteStep: 1,
                template: 'modal',
                appendWidgetTo: 'body',
                showSeconds: true,
                showMeridian: false,
                defaultTime: false
            });
        </script>