<!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";?>
		
		<?php		
			$dt = strtotime('today GMT');
			$tglawal = $_GET['tglawal'];
			$tglakhir = $_GET['tglakhir'];
				
			if ($tglawal == ""){
				$tglawal = date('Y-m-d', strtotime('first day of this month', $dt));
			}
			
			if ($tglakhir == ""){
				$tglakhir = date('Y-m-d', strtotime('last day of this month', $dt)); 
			}						
		?>
      

      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            History Penjualan Tax
            <small>Data History Penjualan Tax</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="data.php">Customer</a></li>
            <li class="active"><a href="#"><u>History Penjualan</u></a></li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12">
              
              <div class="box">
                <div class="box-header">
				
				
				
			<!--	
				<div class="row">
				<div class="col-lg-12">    
				
					<div class="col-lg-12">
					  <div class="small-box bg-blue">
						<div class="inner">
						<p>Total Jual</p>
						  <h3 align = 'right'><?php
												//$totaljual = mysql_result(mysql_query("select sum(grandtotal) from qpenjualan where (billdate >= '$tglawal' and billdate <= '$tglakhir')"),0);
												//$totaljual2 = format_rupiah($totaljual); echo"$totaljual2"; 
											 ?><sup style="font-size: 20px">IDR</sup></h3>
				
						</div>
					   
						<a class="small-box-footer">Total Penjualan<i class="fa fa-arrow-circle-right"></i></a>
					  </div>
					</div>
					
				   
					
					
					
					
					
					
				</div>
			</div><!-- /.row -->
                  
				  
		<script src="highcharts.js"></script>
		<script src="exporting.js"></script>
		  
			
		
				  
				  
				  <?php
						echo"<h3 class='box-title'><br><br>List PENJUALAN Tax per PRODUK</h3><br>";
						echo"<br><br>
						<form method=POST action='aksicust.php?module=lap&act=penjualanproduktax&id=$_GET[id]'>
								<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> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										</td>
										<td>
												<div class='input-group'>
													<i class='fa fa-dropbox'> Produk </i> 
													<select name='produk'  class='select2'>";
													
															$cek = mysql_query("Select * from produk where del = 'N'  order by produk asc");
															while ($r=mysql_fetch_array($cek)){	
																if ($r['id'] == $_GET['produk']){
																	echo"<option value = $r[id] selected='selected'>$r[sku] $r[produk]</option>";
																}else{
																echo"<option value = $r[id] >$r[sku] $r[produk]</option>";
																}
															}	
													echo"	
													</select>
												</div>
										</td>
										<td>
												<div class='input-group'>
													<button type='submit'> GO </button></form>
												</div>
										</td>
									</tr>
								</table>";

			
			
				?>
				 
                </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>Customer </th>
						<th>Produk </th>
						<th>Qty </th>
						<th>Harga </th>
						<th>Disc </th>
                        <th>Total (Rp)</th>
						<th>Kasir</th>
                      </tr>
                    </thead>
                    <tbody>
					<?php
						$user = $_SESSION['nama'];
						$idd = $_SESSION['idm'];
						$today = date("Y-m-d");
						$custid = $_GET['id'];
						$cek = mysql_query("Select jualcstax.billdate, jualcstax.cust,jualcstaxdetail.* , produk.produk as namaproduk from jualcstax
										inner join jualcstaxdetail on jualcstaxdetail.billno = jualcstax.billno and jualcstaxdetail.ucode = jualcstax.ucode
										inner join produk on produk.id = jualcstaxdetail.produk
										where cust = $custid and  (billdate >= '$tglawal' and billdate <= '$tglakhir') 
											and jualcstaxdetail.produk = $_GET[produk] and jualcstax.status <> 'D'
											order by billno desc");
						
						
						while ($r=mysql_fetch_array($cek)){	
							$ord = $r['billno'];
							$ucode = $r['ucode'];
							$tgl = tgl_ind($r['billdate']);

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

							$supp = mysql_result(mysql_query("select nama from customer where id = $r[cust]"),0);
							$kurir = mysql_result(mysql_query("select kurir from kurir where id = $r[kurir]"),0);
							$bank = mysql_result(mysql_query("select bank from bank where id = $r[bank]"),0);
							$tot0 = mysql_result(mysql_query("select sum(qty * (harga - (harga * disc /100))) from jualcsdetail where billno = $ord and ucode=$ucode"),0);
							$diskon = mysql_result(mysql_query("select diskon from jualcs where billno = $ord  and ucode=$ucode"),0);
							$total = format_rupiah($tot0 - $diskon);
							
							$qty = number_format($r['qty'],2);
							$harga = number_format($r['harga'],0);
							$disc = number_format($r['disc'],2);
							$totprod = number_format((100 - $r['disc']) * $r['qty'] * $r['harga'] / 100,0);
							
							if($r['status'] == 'D'){
								$warna = "class='label label-danger'";
								$warnakolom = "class = 'danger'";
							}else{
								$warna = "class='label label-success'";
								$warnakolom = "";
							}
							
							if($r['status'] == 'V'){
								$valid = "<span class='fa fa-thumbs-o-up'></span>";
							}else{
								$valid = "";
							}
							
							
							echo "<tr>
									<td $warnakolom ><a href='../salescs/view.php?id=$ord&ucode=$ucode'><span $warna><span class='fa fa-eye'> </span></span>&nbsp;&nbsp;$noord  <br>$r[web] </a></td>
									<td $warnakolom>$tgl</td>
									<td $warnakolom>$supp</td>
									<td $warnakolom>$r[namaproduk]</td>
									<td $warnakolom>$qty</td>
									<td $warnakolom>$harga</td>
									<td $warnakolom>$disc</td>
									<td $warnakolom>$totprod</td>
									<td $warnakolom>$r[kasir]</td>
									<td $warnakolom>$r[byrby]<br>$tglbyr</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='../salescs/view.php?id=$ord&ucode=$ucode'>View</a></li>
											
	
										  </ul>
										</div>
									</td>
								  </tr>";
						}
					?>
                        
                     
                    </tbody>

                  </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 -->
	

	<script language="javascript">
	 function open_container(id)
	 {
	 var size='standart';
	 var content = '<form role="form" method=POST action="aksisales.php?module=sales&act=validasibyr&id='+id+'" ><div class="form-group"><label for="exampleInputFile">Yakin Validasi Pembayaran untuk Nota '+id+'</label></div><button type="submit" class="btn btn-default">Submit</button></form>';
	 var title = 'Validasi Penerimaan Pembayaran';
	 var footer = '<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>';
	 setModalBox(title,content,footer,size);
	 $('#myModal').modal('show');
	 }
	 function setModalBox(title,content,footer,$size)
	 {
	 document.getElementById('modal-bodyku').innerHTML=content;
	 document.getElementById('myModalLabel').innerHTML=title;
	 document.getElementById('modal-footerq').innerHTML=footer;
	 if($size == 'large')
	 {
	 $('#myModal').attr('class', 'modal fade bs-example-modal-lg')
		  .attr('aria-labelledby','myLargeModalLabel');
	 $('.modal-dialog').attr('class','modal-dialog modal-lg');
	 }
	 if($size == 'standart')
	 {
	 $('#myModal').attr('class', 'modal fade')
		  .attr('aria-labelledby','myModalLabel');
	 $('.modal-dialog').attr('class','modal-dialog');
	 }
	 if($size == 'small')
	 {
	 $('#myModal').attr('class', 'modal fade bs-example-modal-sm')
		  .attr('aria-labelledby','mySmallModalLabel');
	 $('.modal-dialog').attr('class','modal-dialog modal-sm');
	 }
	 }
	 
	 
	 
	 function open_container2(id)
	 {
	 var size='standart';
	 var content = '<form role="form" method=POST action="aksisales.php?module=sales&act=validasikrm&id='+id+'" ><div class="form-group"><label for="exampleInputFile">Yakin Validasi Pengiriman untuk Nota '+id+'</label></div><button type="submit" class="btn btn-default">Submit</button></form>';
	 var title = 'Validasi Barang Dikirim';
	 var footer = '<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>';
	 setModalBox(title,content,footer,size);
	 $('#myModal').modal('show');
	 }
	 function setModalBox(title,content,footer,$size)
	 {
	 document.getElementById('modal-bodyku').innerHTML=content;
	 document.getElementById('myModalLabel').innerHTML=title;
	 document.getElementById('modal-footerq').innerHTML=footer;
	 if($size == 'large')
	 {
	 $('#myModal').attr('class', 'modal fade bs-example-modal-lg')
		  .attr('aria-labelledby','myLargeModalLabel');
	 $('.modal-dialog').attr('class','modal-dialog modal-lg');
	 }
	 if($size == 'standart')
	 {
	 $('#myModal').attr('class', 'modal fade')
		  .attr('aria-labelledby','myModalLabel');
	 $('.modal-dialog').attr('class','modal-dialog');
	 }
	 if($size == 'small')
	 {
	 $('#myModal').attr('class', 'modal fade bs-example-modal-sm')
		  .attr('aria-labelledby','mySmallModalLabel');
	 $('.modal-dialog').attr('class','modal-dialog modal-sm');
	 }
	 }
 </script>
 
<script>
	var chart = Highcharts.chart('container', {

		title: {
			text: <?php echo "$title1" ; ?>
		},

		subtitle: {
			text: ''
		},

		xAxis: {
			categories: [<?php echo "$kasir" ; ?>]
		},

		series: <?php echo "$isi" ; ?>

	});

</script>
<script>
	var chart = Highcharts.chart('container22', {

		title: {
			text: <?php echo "$title22" ; ?>
		},

		subtitle: {
			text: ''
		},

		xAxis: {
			categories: [<?php echo "$kasir22" ; ?>]
		},

		series: <?php echo "$isi22" ; ?>

	});

</script>

    <!-- 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": false,
          "lengthChange": true,
          "searching": true,
          "ordering": true,
		  "order": [[ 0, "asc" ]],
          "info": true,
          "autoWidth": false
        });
      });
    </script>
	
	
	
  </body>
</html>
<?php 
	}
?>