<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>
<aside class="right-side">                
    <section class="content-header">
        <h1>
            Dashboard 
        </h1>
        <ol class="breadcrumb">
            <li><a href="home"><i class="fa fa-dashboard"></i> Home</a></li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-teal">
                    <div class="inner">
                        <h3>
           <?php
					include("config/connection.php");
					$today = date('Y-m-d');
              		$sql ="select  count(Id_Jadwal) as jml from tb_jadwal where tanggal = '".$today."'";
					$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
					mysql_close($test);
					
					$row = mysql_fetch_object($hasil);
					    
						$jml = $row->jml;
						echo $jml;
		?>
                        </h3>
                        <p>
                            Jadwal penyeberangan hari ini
                        </p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-ios7-alarm-outline"></i>
                    </div>
                    <a data-toggle="modal" data-target="#modaljadwal" class="small-box-footer" href="#">
                        More info <i class="fa fa-arrow-circle-right"></i>
                    </a>
                </div>
            </div><!-- ./col -->
            <div id="modaljadwal" class="modal fade" role="dialog">
              <div class="modal-dialog" style="width:70%">
            
                <!-- Modal content-->
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Jadwal Hari ini</h4>
                  </div>
                  <div class="modal-body">
						<?php  
                                include("config/connection.php");
                                $today = date('Y-m-d');
                                $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.tanggal = '".$today."'";
                                $hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
                                mysql_close($test);
                                
                                while($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;
                                    
                        ?>
                        <div class="col-sm-6" 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>
                                 </div>
                            </div> 
                            <div class="callout callout-info" style="margin-bottom:0px">
                                <h4>Tipe Kapal : <?php echo $Jenis?></h4>
                                <h4>Kuota : <?php echo $Kuota_Order?></h4>
                                <h4>Sisa : <?php echo $Sisa?></h4>
                                
                            </div> 
                            <div clas="modal-body" style="padding:10px; margin-bottom:-20px;">
                                <ul class="list-group">
                                    <li class="list-group-item">DARI : <?php echo $dari?></li>
                                    <li class="list-group-item">TUJUAN : <?php echo $tujuan?></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; min-height:60px;">  
                            </div>
                            <div style="background-color:#3c8dbc; border-radius: 0px 0px 7px 7px; min-height:10px; ">
                            </div> 
                        </div>
                    <?PHP } ?>     
                  </div>
                  <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                  </div>
                </div>
            
              </div>
            </div>
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-green">
                    <div class="inner">
                        <h3>
           <?php
					include("config/connection.php");
              		$sql ="select sum(sisa) as sisa from tb_jadwal group by tanggal order by tanggal desc limit 0,1";
					$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
					mysql_close($test);
					
					$row = mysql_fetch_object($hasil);
					    
						$sisa = $row->sisa;
						$sisa = 400 - $sisa;
					$pers = $sisa/400*100;
					echo $pers;
		?>
                            <sup style="font-size: 20px">%</sup>
                        </h3>
                        <p>
                            Presentase Isi Kapal
                        </p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-stats-bars"></i>
                    </div>
                    <a data-toggle="modal" data-target="#modalpresentase" class="small-box-footer" href="#">
                        More info <i class="fa fa-arrow-circle-right"></i>
                    </a>
                </div>
            </div><!-- ./col -->
            <div id="modalpresentase" class="modal fade" role="dialog">
              <div class="modal-dialog">
            
                <!-- Modal content-->
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Presentase Isi Kapal</h4>
                  </div>
                  <div class="modal-body">
					   <?php
                                include("config/connection.php");
                                $sql ="select sum(sisa) as sisa from tb_jadwal group by tanggal order by tanggal desc limit 0,1";
                                $hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
                                mysql_close($test);
                                
                                $row = mysql_fetch_object($hasil);
                                    
                                    $sisa = $row->sisa;
                                    $sisa = 400 - $sisa;
                                	$pers = $sisa/400*100;
                                echo "Terisi ".$sisa." dari 400 Kursi yang tersedia hari ini";
                    ?>
                    
                  </div>
                  <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                  </div>
                </div>
            
              </div>
            </div>            
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-yellow">
                    <div class="inner">
                        <h3>
           <?php
					include("config/connection.php");
              		$sql ="select sum(sisa) as sisa from tb_jadwal where date(tanggal) = CURDATE() group by tanggal ";
					
					$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
					mysql_close($test);
					
					$row = mysql_fetch_object($hasil);
					    
						$sisa = $row->sisa;
						$penumpang = 400 - $sisa;
						echo $penumpang;
		?>
                        </h3>
                        <p>
                            Jumlah Penumpang hari ini
                        </p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-person-add"></i>
                    </div>
                    <a data-toggle="modal" data-target="#modaljumlah" class="small-box-footer" href="#">
                        More info <i class="fa fa-arrow-circle-right"></i>
                    </a>
                </div>
            </div><!-- ./col -->
            <div id="modaljumlah" class="modal fade" role="dialog">
              <div class="modal-dialog">
            
                <!-- Modal content-->
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Jumlah Penumpang hari ini</h4>
                  </div>
                  <div class="modal-body">
                        <table id="example2" class="table table-bordered table-hover">
                          <tr>
                            <td><div align="center">No</div></td>
                            <td>Jenis Penumpang / Angkutan</td>
                            <td><div align="center" style="text-align:center">Jumlah</div></td>
                          </tr>

					   <?php
                                include("config/connection.php");
                                $sql ="select  tb_angkutan.nama as angkutan, count(*) as jumlah from tb_tiket
								inner join tb_angkutan on tb_tiket.id_angkutan = tb_angkutan.id_angkutan
								where date(tanggal) = CURDATE()
								 group by tb_tiket.id_angkutan";
                                $hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
                                mysql_close($test);
                                $a = 0;
                                while($row = mysql_fetch_object($hasil)){
                                    
                                    $angkutan = $row->angkutan;
									$jumlah = $row->jumlah;
									$a = $a + 1;
                    ?>
                          <tr>
                            <td><div align="center"><?php echo $a?></div></td>
                            <td><?php echo $angkutan?></td>
                            <td><div align="center"><?php echo $jumlah?></div></td>
                          </tr>
                     <?php } ?>     
                        </table>
                  </div>
                  <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                  </div>
                </div>
            
              </div>
            </div>            
            
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-red">
                    <div class="inner">
                        <h3>
           <?php
					include("config/connection.php");
					$bulan = date('m');
					$tahun = date('Y');
              		$sql ="select count(id) as jumlah from tb_tiket where month(tanggal) = '".$bulan."' and year(tanggal) = '".$tahun."'";
					$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
					mysql_close($test);
					
					$row = mysql_fetch_object($hasil);
					    
						$jumlah = $row->jumlah;
						echo $jumlah;
		?>
                        </h3>
                        <p>
                            Tiket Terjual Bulan Ini
                        </p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-ios7-pricetag-outline"></i>
                    </div>
                    <a data-toggle="modal" data-target="#modalterjual" class="small-box-footer" href="#">
                        More info <i class="fa fa-arrow-circle-right"></i>
                    </a>
                </div>
            </div><!-- ./col -->
        </div><!-- /.row -->
	</section>
        <div id="modalterjual" class="modal fade" role="dialog">
          <div class="modal-dialog">
        
            <!-- Modal content-->
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Jumlah Penumpang hari ini</h4>
              </div>
              <div class="modal-body">
                    <table id="example2" class="table table-bordered table-hover">
                      <tr>
                        <td><div align="center">No</div></td>
                        <td>Tanggal</td>
                        <td><div align="center" style="text-align:center">Jumlah</div></td>
                      </tr>

                   <?php
                            include("config/connection.php");
                            $sql ="select date(tanggal) as tanggal, count(*) as jumlah from tb_tiket where month(tanggal) = month(curdate()) group by date(tanggal)";
                            $hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
                            mysql_close($test);
                            $a = 0;
                            while($row = mysql_fetch_object($hasil)){
                                
                                $tanggal = $row->tanggal;
                                $jumlah = $row->jumlah;
                                $a = $a + 1;
                ?>
                      <tr>
                        <td><div align="center"><?php echo $a?></div></td>
                        <td><?php echo $tanggal?></td>
                        <td><div align="center"><?php echo $jumlah?></div></td>
                      </tr>
                 <?php } ?>     
                    </table>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              </div>
            </div>
        
          </div>
        </div>            
    <section class="content">
        <div class="row">
            <div class="box col-md-12">
                <div class="box-header">
                    <i class="fa fa-th"></i>
                    <h3 class="box-title">Riwayat Keberangkatan</h3>                                    
                </div><!-- /.box-header -->
                <?php 
					$dari = $_POST['dari'];
					//$dari = substr(0, 10, $dari);
					$sampai = $_POST['sampai'];
					
					if($dari == ''){
						$dari = date('Y-m-d');	
					}
					 
					if($sampai == ''){
						$sampai = date('Y-m-d');	
					}
				?>
                <form action="<?php echo $base ?>dashboard" method="post">
                <div class="col-sm-5">
                     <div class="form-group">
                        <label class="control-label">Dari Tanggal</label>
                        <div class="input-group date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="tgl">
                            <input required="required" class="form-control" type="text" value="<?php echo $dari?>" readonly id="tgl">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                            <input type="hidden" id="tgl" name="dari" value="" />
                            <script type="text/javascript">
                                $('.form_date').datetimepicker({
                                    language:  'id',
                                    weekStart: 1,
                                    todayBtn:  1,
                                    autoclose: 1,
                                    todayHighlight: 1,
                                    startView: 2,
                                    minView: 2,
                                    forceParse: 0
                                });
                            </script>  
                        </div>
                     </div>
				</div>
                <div class="col-sm-5">
                     <div class="form-group">
                        <label class="control-label">Sampai Tanggal</label>
                        <div class="input-group date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="tgl2">
                            <input required="required" class="form-control" type="text" value="<?php echo $sampai?>" readonly id="tgl2">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                            <input type="hidden" id="tgl2" name="sampai" value="" />
                            <script type="text/javascript">
                                $('.form_date').datetimepicker({
                                    language:  'id',
                                    weekStart: 1,
                                    todayBtn:  1,
                                    autoclose: 1,
                                    todayHighlight: 1,
                                    startView: 2,
                                    minView: 2,
                                    forceParse: 0
                                });
                            </script>  
                        </div>
                     </div>
				</div>
                <div class="col-sm-2">
					<button type="submit" class="btn btn-success" style="margin-top:25px; width:100%"><i class='glyphicon glyphicon-search'></i> Cari</button>
                </div>
                </form>
                <div class="box-body table-responsive" style="padding-top:100px">
                    <table id="example1" class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th>No Tiket</th>
                                <th>Nama</th>
                                <th>No Identitas</th>
                                <th>Jenis Angkutan</th>
                                <th>Kategori</th>
                                <th>Kapal</th>
                                <th>Tanggal</th>
                                <th>Waktu</th>
                            </tr>
                        </thead>
                        <tbody>
           <?php
					include("config/connection.php");
              		$sql ="	select tb_tiket.*, tb_angkutan.nama as angkutan, tb_jadwal.Waktu, tb_jadwal.tanggal, tb_kapal.Nama as kapal
							from tb_tiket inner join 
							tb_angkutan on tb_angkutan.id_angkutan = tb_tiket.id_angkutan
							inner join tb_jadwal on tb_jadwal.Id_Jadwal = tb_tiket.id_jadwal
							inner join tb_kapal on tb_jadwal.Id_Kapal = tb_kapal.Id_Kapal
							where tb_jadwal.tanggal >= '".$dari."' and tb_jadwal.tanggal <= '".$sampai."'
							order by tb_jadwal.tanggal desc";
							//echo $sql;
					$hasil = mysql_query($sql) or die("Kesalahan Pada SQL");
					mysql_close($test);
					
					while($row = mysql_fetch_object($hasil)){
					    
						$idtiket = $row->id;
						$id_jadwal = $row->id_jadwal;
						$harga = $row->harga;
						$namapenumpang = $row->nama;
						$no_identitas = $row->no_identitas;
						$tanggal = $row->tanggal;
						$no_tiket = $row->no_tiket;
						$id_angkutan = $row->id_angkutan;
						$angkutan = $row->angkutan;
						$Waktu = $row->Waktu;
						$tanggal = $row->tanggal;
						$kapal = $row->kapal;
						
						if($id_angkutan == 1 or $id_angkutan == 2){
							$jenisangkutan = 'Penumpang';	
						}else{
							$jenisangkutan = 'Kendaraan';	
						}
			?>
                            <tr>
                                <td><?php echo $no_tiket?></td>
                                <td><?php echo $namapenumpang?></td>
                                <td><?php echo $no_identitas?></td>
                                <td><?php echo $jenisangkutan?></td>
                                <td><?php echo $angkutan?></td>
                                <td><?php echo $kapal?></td>
                                <td><?php echo $tanggal?></td>
                                <td><?php echo $Waktu?></td>
                            </tr>
						<?php } ?>
                        </tbody>
                    </table>
                </div><!-- /.box-body -->
            </div><!-- /.box -->
       </div>
                            
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
        <!-- Bootstrap -->
        <script src="js/bootstrap.min.js" type="text/javascript"></script>
        <script src="js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
        <script src="js/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
        <!-- AdminLTE App -->
        <script src="js/AdminLTE/app.js" type="text/javascript"></script>
		<script type="text/javascript">
            $(function() {
                $("#example1").dataTable();
                $('#example2').dataTable({
                    "bPaginate": true,
                    "bLengthChange": false,
                    "bFilter": false,
                    "bSort": true,
                    "bInfo": true,
                    "bAutoWidth": false
                });
            });
        </script>

