<?php
	include "php_class/class_mysql.php";
	include "php_class/class_inventaris.php";
	$dataInventaris = new dataInventaris;
?>
<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>
<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-ruangan/'+ kode +'';
	});
	
	$('#nonaktif').click(function(){
		var kode = $('#kodekunci').val();
		if (confirm("Anda yakin menghapus data dengan kode " + kode+"?")){
			window.location=''+base+'query-delete-ruangan/'+ kode;	
		}
	});
	
	$('#databarang').click(function(){
		var kode = $('#kodekunci').val();
		window.location=''+base+'data-barang/'+ kode ;
	});

  });
   
</script>
<section class="content-header">
  <h1>
    Data Inventaris Barang
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>index"><i class="fa fa-dashboard"></i> Home</a></li>
    <li class="active">Data Ruangan</li>
  </ol>
</section>
<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box">
        <div class="box-header">
          <h3 class="box-title">Data Ruangan</h3>
          <a style="float:right"  href="<?php echo $base?>add-ruangan" class="btn btn-primary">
            <i class="glyphicon glyphicon-plus-sign"></i>
            Tambah Data
          </a>
        </div><!-- /.box-header -->
        <div class="box-body">
        <div class="table-responsive" style="margin-top:30px;">
          <table id="example1" class="table table-bordered table-striped table-hover">
             <thead>
                <tr>
                    <th>No</th>
                    <th>Ruangan</th>
                    <th>Lantai</th>
                    <th>Gedung</th>
                </tr>
            </thead>
            <tbody>
            <?php
				
            	$JumlahData = $dataInventaris->get_data_ruangan('',$a,'jumlah');
				if ($JumlahData<=0){
					echo "<tr class='odd gradeX'>";
					echo "<td>No Data</td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$idruangan = $dataInventaris->get_data_ruangan('idruangan',$a,'');
						$ruangan = $dataInventaris->get_data_ruangan('ruangan', $a, '');
						$lantai = $dataInventaris->get_data_ruangan('lantai',$a,'');
						$gedung = $dataInventaris->get_data_ruangan('gedung',$a,'');
						
						echo "<tr class='odd gradeX context' id='".$idruangan."'>";
						echo "<td>".$a."</td>";
						echo "<td>".$ruangan."</td>";
						echo "<td>".$lantai."</td>";
						echo "<td>".$gedung."</td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
          </div>
             <form action="<?php echo $base?>tabel-agenda-surat.php" method="post" style="float:right; margin-right:10px;" target="_blank">
                <input type="hidden" name="beranda" value="<?php echo $beranda?>" />
                <input type="hidden" name="status" value="2" />
                <input type="hidden" name="tglAwal" value="<?php echo $tglAwal?>" />
                <input type="hidden" name="tglAkhir" value="<?php echo $tglAkhir?>">
            	<button type="submit" class="btn btn-success" id="OK" style="margin-top:20px;"> <i class="glyphicon glyphicon-print"></i> Export Data</button>
             </form>
              <form action="<?php echo $base?>laporan-agenda-surat.php" method="post" style="float:right; margin-right:10px;" target="_blank">
                <input type="hidden" name="beranda" value="<?php echo $beranda?>" />
                <input type="hidden" name="status" value="1" />
                <input type="hidden" name="tglAwal" value="<?php echo $tglAwal?>" />
                <input type="hidden" name="tglAkhir" value="<?php echo $tglAkhir?>">
            	<button type="submit" class="btn btn-default" id="OK" style="margin-top:20px;"> <i class="glyphicon glyphicon-print"></i> Cetak Data</button>
             </form>
          <div id="menuklik" class="modal fade" role="dialog">
          	<div class="modal-dialog modal-sm">
                <div class="modal-content">
                	<div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h5 class="modal-title">Aksi</h5>
                    </div>
                  	<div class="modal-body">
                        <input type="hidden" value="" id="kodekunci">
                        <input type="hidden" value="" id="beranda">
                        <div align="center">
                        <p><button type="button" class="btn btn-success" id="databarang"><i class='fa fa-list-ol'></i> List Barang</button></p>
                        <p><button type="button" class="btn btn-default" id="editdata">Edit Data</button></p>
                        <p><button type="button" class="btn btn-default" id="nonaktif">Non Aktif</button></p>
                        </div>
                     </div>
                </div>
            </div>
          </div>
          
          
        </div><!-- /.box-body -->
      </div><!-- /.box -->
    </div><!-- /.col -->
  </div><!-- /.row -->
  
</section>
 
