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

  });
   
</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 Jenis Barang </li>
  </ol>
</section>
<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box">
                <?php
          	$idruangan = $xcode;
			$ruangan = $dataInventaris2->get_ruangan('ruangan', $idruangan);
			$lantai = $dataInventaris2->get_ruangan('lantai', $idruangan);
			$gedung = $dataInventaris2->get_ruangan('gedung', $idruangan);
		  ?>

        <div class="box-header">
          <a style="float:right"  href="<?php echo $base?>add-jenis-barang/<?php echo $idruangan?>" class="btn btn-primary">
            <i class="glyphicon glyphicon-plus-sign"></i>
            Tambah Data
          </a>
          <a style="float:right; margin-right:10px;"  href="<?php echo $base?>data-ruangan" class="btn btn-success">
            <i class="glyphicon glyphicon-list"></i>
            Data Ruangan
          </a>
          <h4>Ruangan : <?php echo $ruangan?></h4>
          <h4>Lantai : <?php echo $lantai?></h4>
          <h4>Gedung : <?php echo $gedung?></h4>
        </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>Jenis/Nama Barang</th>
                    <th>Merk/Model</th>
                    <th>No Seri Pabrik</th>
                    <th>Tahun Penerimaan</th>
                    <th>No Kode Barang</th>
                    <th>Jumlah Barang</th>
                    <th>Keadaan Baik</th>
                    <th>Keadaan Kurang Baik</th>
                    <th>Keadaan Rusak</th>
                    <th>Keterangan</th>
                </tr>
            </thead>
            <tbody>
            <?php
				
            	$JumlahData = $dataInventaris->get_data_barang('',$a,'jumlah', $idruangan);
				if ($JumlahData<=0){
					echo "<tr class='odd gradeX'>";
					echo "<td>No Data</td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "<td></td>";
					echo "</tr>";	
				}else{
					for ($a=1;$a<=$JumlahData;$a++){
						$id = $dataInventaris->get_data_barang('id',$a,'', $idruangan);
						$barang = $dataInventaris->get_data_barang('barang',$a,'', $idruangan);
						$merk = $dataInventaris->get_data_barang('merk', $a, '', $idruangan);
						$noseri = $dataInventaris->get_data_barang('noseri',$a,'', $idruangan);
						$tahun = $dataInventaris->get_data_barang('tahun',$a,'', $idruangan);
						$kodebarang = $dataInventaris->get_data_barang('kodebarang',$a,'', $idruangan);
						$jumlah = $dataInventaris->get_data_barang('jumlah', $a, '', $idruangan);
						$baik = $dataInventaris->get_data_barang('baik',$a,'', $idruangan);
						$kurang = $dataInventaris->get_data_barang('kurang',$a,'', $idruangan);
						$rusak = $dataInventaris->get_data_barang('rusak',$a,'', $idruangan);
						$keterangan = $dataInventaris->get_data_barang('keterangan',$a,'', $idruangan);
						
						echo "<tr class='odd gradeX context' id='".$id."' idruangan = '".$idruangan."'>";
						echo "<td >".$a."</td>";
						echo "<td >".$barang."</td>";
						echo "<td >".$merk."</td>";
						echo "<td >".$noseri."</td>";
						echo "<td >".$tahun."</td>";
						echo "<td >".$kodebarang."</td>";
						echo "<td>".$jumlah."</td>";
						echo "<td>".$baik."</td>";
						echo "<td>".$kurang."</td>";
						echo "<td>".$rusak."</td>";
						echo "<td>".$keterangan."</td>";
						echo "</tr>";
					}
				}
			?>
        	</tbody>
          </table>
          </div>
          <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="idruangan">
                        <div align="center">
                        <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>
 
