<?

require_once("../dasar/session.php");
require_once("conn.php");
include '../dasar/ubahtgl.php';
$menu2='active';

$kode = $_SESSION['kode'];

$limit=$_GET['limit'];

if(isset($_POST['cari']))
{
    $cari = $_POST['cari'];
    
}
else
{
	 $cari='';
}

$tanggalawal = date("Y-m-d", strtotime($_GET['tglawal']));
$tanggalakhir = date("Y-m-d", strtotime($_GET['tglakhir']));

$offset = $_GET['offset']
?>
<!DOCTYPE html>
<html lang="en">
    <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>Transaksi - Web Report</title>

        <!-- Bootstrap Core CSS -->
        <link href="../css/bootstrap.min.css" rel="stylesheet">

        <!-- MetisMenu CSS -->
        <link href="../css/metisMenu.min.css" rel="stylesheet">

        <!-- DataTables CSS -->
        <link href="../css/dataTables/dataTables.bootstrap.css" rel="stylesheet">

        <!-- DataTables Responsive CSS -->
        <link href="../css/dataTables/dataTables.responsive.css" rel="stylesheet">
 <link rel="icon" href="../favicon.ico" type="image/icon"/>
        <!-- Custom CSS -->
        <link href="../css/startmin.css" rel="stylesheet">

        <!-- Custom Fonts -->
        <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css">

        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->

		<style>
.pagination {
    display: inline-block;
}

.pagination a {
    color: black;
    float: left;
    padding: 8px 16px;
    text-decoration: none;
    transition: background-color .3s;
}

.pagination a.active {
    background-color: #4CAF50;
    color: white;
}

.pagination a:hover:not(.active) {background-color: #ddd;}
</style>

    </head>
    <body>
        <div id="wrapper">
                
                <!-- /.row -->
                <div class="row">
                    
                
                        <div class="panel panel-green">
                            <div class="panel-heading">
                                <i class="fa fa-edit fa-fw"></i>&nbsp;&nbsp;Data Transaksi
                            </div>
                            <!-- /.panel-heading -->
                            <div class="panel-body">
                                <div class="dataTable_wrapper" style="overflow-x:auto;">
									
                                    <table class="table table-bordered table-hover">
                                        <thead>
                                            <tr>
                                                <th><center>No</center></th>
                                                <th><center>Tanggal</center></th>
                                                <th><center>Produk</center></th>
                                                <th><center>Tujuan</center></th>
                                                
												<th><center>Harga Rp</center></th>
												<th><center>Status</center></th>
												<th><center>Serial</center></th>
                                            </tr>
                                        </thead>
										<?
										$exe = mysqli_query($conn,"SELECT * FROM transaksi where kode_reseller ='$kode' and (tujuan LIKE '%$cari%' or sn LIKE '%$cari%' or kode_produk LIKE '%$cari%') and tanggal BETWEEN '$tanggalawal' AND '".$tanggalakhir." 23:59:59' order by kode desc limit $offset,$limit");

										$jml = mysqli_query($conn,"SELECT * FROM transaksi where kode_reseller ='$kode' and (tujuan LIKE '%$cari%' or sn like '%$cari%' or kode_produk LIKE '%$cari%') and tanggal BETWEEN '$tanggalawal' AND '".$tanggalakhir." 23:59:59'");	
					
										$jumlah=mysqli_num_rows($jml);

				       					$no = 1+$offset;
										while($record = mysqli_fetch_array($exe)){
                       

										$kode = $record['kode'];
										$tanggal = tampildate($record['tanggal']);
										$produk = $record['kode_produk'];
										$tujuan = $record['tujuan'];
										//$tujuan = substr($tujuan,0,strlen($tujuan) -3).'xxx';
										$reseler = $record['kode_reseller'];
										$harga = $record['harga'];
										$awal = $record['saldo_awal'];
										$saldo = $awal-$harga;
										$serial = $record['sn'];
										$status = $record['status'];
										$harga2=number_format($harga,0,',','.');
										$saldo2=number_format($saldo,0,',','.');
										
										if ($status == 20)
										{
											$status1 = 'Sukses';
											$bgstatus='#ffffff';
										}
										else if ($status == 2 || $status == 3)
										{
											$status1 = 'Menunggu Jawaban';
											$bgstatus='#ccffff';
										}
										else if ($status == 50)
										{
											$status1 = 'Dibatalkan';
											$bgstatus='#ffcccc';
											}
										else if ($status == 0)
										{
											$status1 = 'Belum Diproses';
											$bgstatus='#ffff99';
											}
										else if ($status == 45)
										{
											$status1 = 'Stok Kosong';
											$bgstatus='#ffcccc';
											}
										else if ($status == 52)
										{
											$status1 = 'Tujuan Salah';
											$bgstatus='#ffcccc';
											}
										else if ($status == 53)
										{
											$status1 = 'Outer';
											$bgstatus='#ffcccc';
											}
										else if ($status == 47)
										{
											$status1 = 'Produk Gangguan';
											$bgstatus='#ffcccc';
											}
										else
										{
											$status1 = 'Gagal';
											$bgstatus='#ffcccc';
											}

                                        ?><tbody>
                                            <tr bgcolor='<? echo $bgstatus ;?>' >
                                                <td><center><? echo $no ;?></center></td>
                                                <td><center><? echo $tanggal ;?></center></td>
                                                <td><center><? echo $produk ;?></center></td>
                                                <td><center><? echo $tujuan ;?></center></td>
                                                
                                                <td><center><? echo $harga2 ;?></center></td>
                                                <td><center><? echo $status1 ;?></center></td>
                                                <td><center><? echo $serial ;?></center></td>
                                                
                                            </tr>
                                        </tbody>

											<?$no++;}?>
                                    </table>
								
                                </div>
                                <!-- /.table-responsive
                                <div class="well">
                                    <h4>DataTables Usage Information</h4>
                                    <p>DataTables is a very flexible, advanced tables plugin for jQuery. In SB Admin, we are using a specialized version of DataTables built for Bootstrap 3. We have also customized the table headings to use Font Awesome icons in place of images. For complete documentation on DataTables, visit their website at <a target="_blank" href="https://datatables.net/">https://datatables.net/</a>.</p>
                                    <a class="btn btn-default btn-lg btn-block" target="_blank" href="https://datatables.net/">View DataTables Documentation</a>
                                </div>-->
                            </div>
                            <!-- /.panel-body -->
                        </div>
                        <!-- /.panel -->
                 
                    <!-- /.col-lg-12 -->
              
                
                <!-- /.row -->
            </div>
            <!-- /#page-wrapper -->

        </div>
        <!-- /#wrapper -->

        <!-- jQuery -->
        <script src="../js/jquery.min.js"></script>

        <!-- Bootstrap Core JavaScript -->
        <script src="../js/bootstrap.min.js"></script>

        <!-- Metis Menu Plugin JavaScript -->
        <script src="../js/metisMenu.min.js"></script>

        <!-- DataTables JavaScript -->
        <script src="../js/dataTables/jquery.dataTables.min.js"></script>
        <script src="../js/dataTables/dataTables.bootstrap.min.js"></script>

        <!-- Custom Theme JavaScript -->
        <script src="../js/startmin.js"></script>

        <!-- Page-Level Demo Scripts - Tables - Use for reference -->
        <script>
            $(document).ready(function() {
                $('#dataTables-example').DataTable({
                        responsive: true
                });
            });
        </script>
    </body>
</html>
<body onload="window.print()">
