<!DOCTYPE html>

<?php 
	session_start();
	@ob_start();
	include "../../config/koneksi.php";
	include "../../config/fungsi_rupiah.php";
	include "../head.php";

	
	if ($_SESSION['nama'] == ''){
		header('Location:index.php');
	}
	else{
?>
<html>

  <body class="hold-transition skin-blue sidebar-mini layout-boxed">
    <div class="wrapper">
		<?php include "../header.php";?>
      
		<?php include "../menu.php";?>
      

      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            DETAIL PIUTANG CUSTOMER
            <small>Data Piutang</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Customer</a></li>
            <li class="active">Data Piutang Detail</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12">
              
              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">List Piutang Customer</h3><br><br>

					<?php
						$id = $_GET['id'];
						$jenis = $_GET['jenis'];
						if($jenis == "semen"){
							$cat ="1.SMN'  or jenis = '6.SMP";
						}elseif($jenis == "pvc"){
							$cat = "3.PVC";
						}elseif($jenis == "slc"){
							$cat = "4.SLC";
						}elseif($jenis== "acp"){
							$cat = "2.ACP";
						}
						echo "<h3>Cust : $id<br>Stock Name : $jenis </h3>";
					?>
				</div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th>No Faktur</th>
                        <th>Tgl Faktur</th>
                        <th>Qty</th>
                        <th>Jumlah</th>
						<th>Bayar</th>
						<th>JTO</th>
                      </tr>
                    </thead>
                    <tbody>
					<?php
						
						
						$salesman = $_SESSION['nama'];
						$idd = $_SESSION['idm'];
						$super = mysql_result(mysql_query("select super from admins where pk = $idd"),0);
						if ($super == "Y"){
								$cek = mysql_query("Select * from  piutang where  jenis = '$cat' and custname = '$id' order by custname asc");
						}else{
							$cek = mysql_query("Select * from  piutang where salesman = '$salesman' and jenis = '$cat' and custname = '$id' order by custname asc");
						}
						while ($r=mysql_fetch_array($cek)){	
							$jumlah = format_rupiah($r['jumlah']);
							echo "<tr>
									<td>$r[nofaktur]</td>
									<td>$r[tglfaktur]</td>
									<td>$r[qty]</td>
									<td>$jumlah</td>
									<th>0</th>
									<td>$r[jto]</td>
								  </tr>";
						}
					?>
                        
                     
                    </tbody>
                    <tfoot>
                      <tr>
                        <th>No Faktur</th>
                        <th>Tgl Faktur</th>
                        <th>Qty</th>
                        <th>Jumlah</th>
						<th>Bayar</th>
						<th>JTO</th>
                      </tr>
                    </tfoot>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
		<?php include "../footer.php";?>
		

      <!-- Control Sidebar -->
      <aside class="control-sidebar control-sidebar-dark">

        <!-- Tab panes -->
        <div class="tab-content">
          <!-- Home tab content -->
          <div class="tab-pane" id="control-sidebar-home-tab">

          </div><!-- /.tab-pane -->

        </div>
      </aside><!-- /.control-sidebar -->
      <!-- Add the sidebar's background. This div must be placed
           immediately after the control sidebar -->
      <div class="control-sidebar-bg"></div>
    </div><!-- ./wrapper -->

    <!-- jQuery 2.1.4 -->
    <script src="../../plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="../../bootstrap/js/bootstrap.min.js"></script>
    <!-- DataTables -->
    <script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="../../plugins/datatables/dataTables.bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="../../plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="../../plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="../../dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="../../dist/js/demo.js"></script>
    <!-- page script -->
    <script>
      $(function () {
        $("#example1").DataTable();
        $('#example2').DataTable({
          "paging": true,
          "lengthChange": false,
          "searching": false,
          "ordering": true,
          "info": true,
          "autoWidth": false
        });
      });
    </script>
  </body>
</html>
<?php 
	}
?>