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

$kode = $_SESSION['kode'];
$tanggal0z=date("Y-m-d");
if (isset($_GET['idpel']))
{
	$iidpel=$_GET['idpel'];
	$tanggal0=$_GET['tanggal'];
	$tanggal0z=date("Y-m-d", strtotime($tanggal0));
	//$ijenis=$_GET['jenis'];
	$kertas=(float)$_GET['kertas'];
	$admin=$_GET['admin'];

	$tanggal1=date("d", strtotime($tanggal0));
	$tanggal2=date("m", strtotime($tanggal0));
	$tanggal3=date("Y", strtotime($tanggal0));
	$tanggalcari=date("Y-m-d H:i:s", strtotime($tanggal0));

	if (empty($iidpel))
		{
		 $nodata='ID Pel tidak boleh kosong...!';
		}
	else
		{
		$conn=mysqli_connect("$host","$user","$pass") or die("koneksi gagal");
		mysqli_select_db($conn,"$db");
		$exe = mysqli_query($conn,"SELECT * FROM transaksi where tujuan= '$iidpel' and tanggal>= '$tanggalcari' and harga>0 and sn<>'' order by kode asc");
		//$exe = mysqli_query($conn,"SELECT * FROM t_struk where idpel= '$iidpel' and tanggal= '$tanggalcari' order by kode asc");
		$jumlah=mysqli_num_rows($exe);
		
		while($record = mysqli_fetch_array($exe)){
            $ijenis = $record['kode_produk'];
            $tanggaltrx=$record['tanggal'];
		}
		if ($jumlah == 0)
			{
			$nodata='Tidak Ada Data...!';
			}
		else
			{
			$nodata='';
			if ($kertas == 1 and substr_count($ijenis,'BAYARPLN') == 1)
				{
				echo "<script type='text/javascript'>window.open('layout/pasca1.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 2 and substr_count($ijenis,'BAYARPLN') == 1)
				{
				echo "<script type='text/javascript'>window.open('layout/pasca2.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 1 and (substr_count($ijenis,'ZPLN') == 1 or substr_count($ijenis,'PLN') == 1 or substr_count($ijenis,'QPLN') == 1))
				{
				echo "<script type='text/javascript'>window.open('layout/token1.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
	    	else if ($kertas == 2 and (substr_count($ijenis,'ZPLN') == 1 or substr_count($ijenis,'PLN') == 1 or substr_count($ijenis,'QPLN') == 1))
				{
				echo "<script type='text/javascript'>window.open('layout/token2.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
		    else if ($kertas == 1 and substr_count($ijenis,'BYRBPJS') == 1)
				{
				echo "<script type='text/javascript'>window.open('layout/bpjs1.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 2 and substr_count($ijenis,'BYRBPJS') == 1)
				{
				echo "<script type='text/javascript'>window.open('layout/bpjs2.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 1 and substr_count($ijenis,'BYRTELKOM') == 1)
				{
				echo "<script type='text/javascript'>window.open('layout/telkom1.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 2 and substr_count($ijenis,'BYRTELKOM') == 1)
				{
				echo "<script type='text/javascript'>window.open('layout/telkom2.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 1 and substr_count($ijenis,'BYRAIRKEB') == 1)
				{
				echo "<script type='text/javascript'>window.open('layout/pdam1.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 2 and substr_count($ijenis,'BYRAIRKEB') == 1)
				{
				echo "<script type='text/javascript'>window.open('layout/pdam2.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 1 and $ijenis == 17)
				{
				echo "<script type='text/javascript'>window.open('layout/halo1.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 2 and $ijenis == 17)
				{
				echo "<script type='text/javascript'>window.open('layout/halo2.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 1 and $ijenis >= 6)
				{
				echo "<script type='text/javascript'>window.open('layout/tv1.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			else if ($kertas == 2 and $ijenis >= 6)
				{
				echo "<script type='text/javascript'>window.open('layout/tv2.php?jenis=$ijenis&tanggal=$tanggaltrx&idpel=$iidpel&admin=$admin', '_blank')</script>";
				}
			}
		}
}

else
{
	$nodata='';
	$iidpel='';
	$tanggal0=$tanggal;
	$kertas=1;
	$ijenis=1;
	$admin=2000;
}


if ($ijenis==1)
{
	$jenis1='selected';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==2)
{
	$jenis1='';
	$jenis2='selected';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==3)
{
	$jenis1='';
	$jenis2='';
	$jenis3='selected';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==4)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='selected';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==5)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='selected';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==6)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='selected';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==7)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='selected';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==8)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='selected';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==9)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='selected';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==10)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='selected';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==11)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='selected';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==12)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='selected';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==13)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='selected';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==14)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='selected';
	$jenis15='';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==15)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='selected';
	$jenis16='';
	$jenis17='';
}
else if ($ijenis==16)
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='selected';
	$jenis17='';
}
else
{
	$jenis1='';
	$jenis2='';
	$jenis3='';
	$jenis4='';
	$jenis5='';
	$jenis6='';
	$jenis7='';
	$jenis8='';
	$jenis9='';
	$jenis10='';
	$jenis11='';
	$jenis12='';
	$jenis13='';
	$jenis14='';
	$jenis15='';
	$jenis16='';
	$jenis17='selected';
}

if ($kertas==1)
{
	$kertas1='selected';
	$kertas2='';
}
else 
{
	$kertas1='';
	$kertas2='selected';
}

if ($admin==1600)
{
	$admin1='selected';
	$admin2='';
	$admin3='';
	$admin4='';
	$admin5='';
	$admin6='';
}
else if ($admin==1800)
{
	$admin1='';
	$admin2='selected';
	$admin3='';
	$admin4='';
	$admin5='';
	$admin6='';
}
else if ($admin==2000)
{
	$admin1='';
	$admin2='';
	$admin3='selected';
	$admin4='';
	$admin5='';
	$admin6='';
}
else if ($admin==2500)
{
	$admin1='';
	$admin2='';
	$admin3='';
	$admin4='selected';
	$admin5='';
	$admin6='';
}
else if ($admin==3000)
{
	$admin1='';
	$admin2='';
	$admin3='';
	$admin4='';
	$admin5='selected';
	$admin6='';
}
else 
{
	$admin1='';
	$admin2='';
	$admin3='';
	$admin4='';
	$admin5='';
	$admin6='selected';
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta 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>Cetak Struk - 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]-->

	</head>
    <body>

        <div id="wrapper">

            <?
			require_once("nav.php");
			?>

            <div id="page-wrapper">
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">Struk</h1>
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
				
                <!-- /.row -->
                <div class="row">
                    <div class="col-lg-4">
                        <div class="panel panel-green">
                            <div class="panel-heading">
                                <i class="fa fa-print fa-fw"></i>&nbsp;&nbsp;Cetak Struk
                            </div>
                            <!-- /.panel-heading -->
                            <div class="panel-body">
                                <div class="dataTable_wrapper" style="overflow-x:auto;width:100%">
									<form name='loginform' method='get' action='struk.php'>
									<!--<div class="form-group">
                                        <label>Jenis Struk</label>
                                        <select class="form-control" name="jenis">
                                            <option <?php echo $jenis1 ?> value="1">Token PLN</option>
                                            <option <?php echo $jenis2 ?> value="2">PLN Pasca Bayar</option>
                                            <option <?php echo $jenis3 ?> value="3">BPJS</option>
                                            <option <?php echo $jenis4 ?> value="4">Telkom / Speedy</option>
                                            <option <?php echo $jenis5 ?> value="5">PDAM</option>
                                            <option <?php echo $jenis17 ?> value="17">HALO</option>
                                            	<optgroup label="TV Berlangganan">
                                            	  <option <?php echo $jenis6 ?> value="6">Indovision TV</option>
                                            	  <option <?php echo $jenis7 ?> value="7">Top TV</option>
                                            	  <option <?php echo $jenis8 ?> value="8">Oke vision TV</option>
                                            	  <option <?php echo $jenis9 ?> value="9">Big TV</option>
                                            	  <option <?php echo $jenis10 ?> value="10">Orange TV</option>
                                            	  <option <?php echo $jenis11 ?> value="11">Aora TV</option>
                                            	  <option <?php echo $jenis12 ?> value="12">First Media TV</option>
                                            	  <option <?php echo $jenis13 ?> value="13">Nextmedia</option>
                                            	  <option <?php echo $jenis14 ?> value="14">Centrin TV</option>
                                            	  <option <?php echo $jenis15 ?> value="15">K-Vision</option>
                                            	  <option <?php echo $jenis16 ?> value="16">Transvision</option>
                                                </optgroup>
                                            <select>
                                        </select>
                                    </div>-->
                                    <div class="form-group">
                                        <label>ID PEL</label>
                                        <input class="form-control" name="idpel" value="<? echo $iidpel ?>">
                                        
                                    </div>
                                    <label>Tanggal Beli</label><br><input type="date" style="width: 100%;" name='tanggal' value="<? echo $tanggal0z ?>"><br><br>
                                    <div class="form-group">
                                        <label>Admin Bank</label>
                                        <select class="form-control" name="admin">
                                            <option <?php echo $admin1 ?> value="1600">1600</option>
                                            <option <?php echo $admin2 ?> value="1800">1800</option>
                                            <option <?php echo $admin3 ?> value="2000">2000</option>
                                            <option <?php echo $admin4 ?> value="2500">2500</option>
                                            <option <?php echo $admin5 ?> value="3000">3000</option>
                                            <option <?php echo $admin6 ?> value="5000">5000</option>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label>Ukuran Kertas</label>
                                        <select class="form-control" name="kertas">
                                            <option <?php echo $kertas1 ?> value="1">Horizontal</option>
                                            <option <?php echo $kertas2 ?> value="2">Vertikal</option>
                                           
                                        </select>
                                    </div><br>
                                    <center><font style="color:red"><label><? echo $nodata ?></label></font></center><br>
                                    <button type="submit" class="btn btn-outline btn-primary btn-lg btn-block" name='tampilkan' value='Tampilkan'>Proses</button>
                                    </form>
                                    
									
                                </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 -->
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                
                <!-- /.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>
    <?
        include 'chat.php';
    ?>
    </body>
</html>
