<!DOCTYPE html>

<?php 
	session_start();
	@ob_start();
	include "../../config/koneksi.php";
	include "../../config/fungsi_rupiah.php";
	include "../../config/fungsi_indotgl.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>
            MUTASI
            <small>Data Mutasi</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="data.php">Transaksi</a></li>
            <li class="active"><a href="data.php"><u>Mutasi</u></a></li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12">
			<?php		
				$dt = strtotime('today GMT');
				$tglawal = $_GET['tglawal'];
				$tglakhir = $_GET['tglakhir'];
					
				if ($tglawal == ""){
					$tglawal = date('Y-m-d');
				}
				
				if ($tglakhir == ""){
					$tglakhir = date('Y-m-d'); 
				}						
			?>
              
              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">List Mutasi</h3><br><br>
				  
				  <?php
						
						echo"
						<form method=POST action='aksisales.php?module=view&act=penjualancs'>
								<table>
									<tr>
										<td>
												<div class='input-group'>
													<i class='fa fa-calendar'> From </i> <input value = '$tglawal' name ='awal' type = 'date'>
												</div>
										</td>
										<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										</td>
										<td>
												<div class='input-group'>
													<i class='fa fa-calendar'> To</i> <input value = '$tglakhir' name='akhir' type = 'date'>
												</div>
										</td>
										<td>
												<div class='input-group'>
													<button type='submit'> GO </button></form>
												</div>
										</td>
									</tr>
								</table><br>";

			
			
				?>
				  <a href="add.php" class="btn btn-sm btn-info btn-flat pull-left">Mutasi Baru</a>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th>No Ord</th>
                        <th>Tanggal </th>
						<th>From </th>
                        <th>To</th>
						<th>Kasir</th>
						<th></th>
                      </tr>
                    </thead>
                    <tbody>
					<?php
						$user = $_SESSION['nama'];
						$idd = $_SESSION['idm'];
						$leader = mysql_result(mysql_query("select leader from admins where pk = $idd"),0);
						//if($leader == "N"){
						//	$cek = mysql_query("Select * from jualcs where (billdate >= '$tglawal' and billdate <= '$tglakhir') and kasir = '$user' order by billno desc");
						//}else{
							$cek = mysql_query("Select * from mutasim where (billdate >= '$tglawal' and billdate <= '$tglakhir') order by billno desc");
						//}
						while ($r=mysql_fetch_array($cek)){	
							$ord = $r['billno'];
							$tgl = tgl_ind($r['billdate']);

							$noord = str_pad($ord, 4, "0", STR_PAD_LEFT);

							$gd1 = mysql_result(mysql_query("select gudang from gudang where id = $r[gudang]"),0);
							$gd2 = mysql_result(mysql_query("select gudang from gudang where id = $r[gudang2]"),0);

							
							
							
							if($r['status'] == 'N'){
								$warna = "class='label label-danger'";
								$warnakolom = "class = 'danger'";
							}else{
								$warna = "class='label label-success'";
								$warnakolom = "";
							}
							
							
							echo "<tr>
									<td $warnakolom ><a href='view.php?id=$ord'><span $warna><span class='fa fa-eye'> </span></span>&nbsp;&nbsp;$noord  <br>$r[web] </a></td>
									<td $warnakolom>$tgl</td>
									<td $warnakolom>$gd1</td>
									<td $warnakolom>$gd2</td>
									<td $warnakolom>$r[kasir]</td>	
									<td  $warnakolom>
										<div class='btn-group'>
										  <button type='button' class='btn btn-info'>Action</button>
										  <button type='button' class='btn btn-info dropdown-toggle' data-toggle='dropdown'>
											<span class='caret'></span>
											<span class='sr-only'>Toggle Dropdown</span>
										  </button>
										  <ul class='dropdown-menu' role='menu'>
											<li><a href='view.php?id=$ord'>View</a></li>
											<li><a href='aksisales.php?module=sales&act=delinv&id=$ord'>Cancel</a></li>
											<li><a href='print.php?id=$ord'>Print</a></li>
	
										  </ul>
										</div>
									</td>
								  </tr>";
						}
					?>
                        
                     
                    </tbody>
                    <tfoot>
                      <tr>
                        <th>No Ord</th>
                        <th>Tanggal </th>
						<th>From </th>
                        <th>To</th>
						<th>Kasir</th>
						<th></th>
                      </tr>
                    </tfoot>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
		
		<!-- Modal form-->
                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                  <div class="modal-dialog ">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h4 class="modal-title" id="myModalLabel"></h4>
                      </div>
                      <div class="modal-body" id="modal-bodyku">
                      </div>
                      <div class="modal-footer" id="modal-footerq">
                      </div>
                    </div>
                  </div>
                </div>
                <!-- end of modal ------------------------------>
		
		
      </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 () {
        $("#example2").DataTable();
        $('#example1').DataTable({
          "paging": true,
          "lengthChange": true,
          "searching": true,
          "ordering": true,
		  "order": [[ 0, "desc" ]],
          "info": true,
          "autoWidth": false
        });
      });
    </script>
	
	
  </body>
</html>
<?php 
	}
?>