<!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>
            Customer Data
            <small>Data Customer</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">Customer Data</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 Customer</h3><br><br>
				  
				  <?php
					$oto = mysql_result(mysql_query("select count(pk) from admindetail where user = $idd and xadd = 'Y' and modul ='24'"),0);
					if ($oto > 0 ){
						echo"<a href='add.php' class='btn btn-sm btn-info btn-flat pull-left'>Customer Baru</a> <br><br>";
					}
				  ?>
				  
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example2" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th>Nama</th>
						<th>Aktif</th>
						<th>NPWP</th>
						<th>NIK</th>
						<th>Alamat</th>	
                        <th>HP</th>
                        <th>Limit</th>
						<th>Keterangan</th>
						<th></th>
                      </tr>
                    </thead>
                    <tbody>
					<?php
						$cek = mysql_query("Select * from  customer where nama <> '' order by nama asc");
						while ($r=mysql_fetch_array($cek)){	
							$cust = $r['id'];
							if($r['status'] == 'N'){
								$warnakolom = "class='danger'";
								$link = ""; $kata = "";
								if (strtoupper($_SESSION['nama']) == "ADMIN") {
									$link = "'aksicust.php?id=$cust&module=cust&act=aktif'";
									$kata = "Aktifkan";
									$wbut = "btn-danger";
								}
							}else{
								$warnakolom = "";
								$link = ""; $kata = "";
								if (strtoupper($_SESSION['nama']) == "ADMIN") {
									$link = "'aksicust.php?id=$cust&module=cust&act=delete'";
									$kata = "Non Aktifkan";
									$wbut = "btn-success";
								}
							}
							
							$limit = format_rupiah($r['lim']);
							echo "<tr>
									<td $warnakolom >$r[nama]</td>
									<td $warnakolom style='font-size:20px;text-align:center;font-weight:bolder;'><a href=$link  onclick=\"return confirm('Anda yakin ingin $kata customer ini ?')\"><button class = 'btn btn-lg $wbut'>$r[status]</button></a></td>
									<td $warnakolom >$r[npwp]</td>
									<td $warnakolom >$r[nik]</td>
									<td $warnakolom >$r[alamat]</td>
									<td $warnakolom >$r[telp]</td>
									<td $warnakolom >$limit</td>
									<td $warnakolom >$r[keterangan]</td>
									<td $warnakolom >";
									$oto = mysql_result(mysql_query("select count(pk) from admindetail where user = $idd and xedit = 'Y' and modul ='24'"),0);
									if ($oto > 0 ){
										echo"
										<a href='edit.php?id=$cust'><span class='label label-success'>Edit</span></a>";
									}
									$oto = mysql_result(mysql_query("select count(pk) from admindetail where user = $idd and xdelete = 'Y' and modul ='24'"),0);
									if ($oto > 0 ){
										echo"
										<a href='aksicust.php?id=$cust&module=cust&act=delete' onclick=\"return confirm('Anda yakin ingin delete customer ini ?')\"><span class='label label-danger'>Delete</span></a> ";
									}
									echo"
									<a href='history.php?id=$cust'><span class='label label-info'>History Penjualan</span></a> <br>
									<a href='historytax.php?id=$cust'><span class='label label-info'>History Sales Order</span></a>
									
									</td>
								  </tr>";
						}
					?>
                        
                     
                    </tbody>
                    <tfoot>
                      <tr>
                        <th>Nama</th>
						<th>NPWP</th>
						<th>Alamat</th>
                        <th>HP</th>
                        <th>Limit</th>
						<th>Keterangan</th>
                      </tr>
                    </tfoot>
                  </table>
				  
						
				  </form>
                </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": true,
          "searching": true,
          "ordering": true,
          "info": true,
		  "scrollX": true,
          "autoWidth": false
        });
      });
    </script>
  </body>
</html>
<?php 
	}
?>