<!DOCTYPE html>
<html lang="en">

<?php
    require_once 'common/database.php';
        if(!isset($_SESSION['logged_in'])){
            header('location: index.php');
        }
    ?>

    <!-- Basic -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">   
   
    <!-- Mobile Metas -->
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
 
     <!-- Site Metas -->
    <title>Tiket</title>  
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Site Icons -->
    <link rel="shortcut icon" href="images/logos/mikhol-logo.jpg" type="image/x-icon" />
    <link rel="apple-touch-icon" href="images/apple-touch-icon.png">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- Site CSS -->
    <link rel="stylesheet" href="style.css">
    <!-- Colors CSS -->
    <link rel="stylesheet" href="css/colors.css">
    <!-- ALL VERSION CSS -->
    <link rel="stylesheet" href="css/versions.css">
    <!-- Responsive CSS -->
    <link rel="stylesheet" href="css/responsive.css">
    <!-- Custom CSS -->
    <link rel="stylesheet" href="css/custom.css">
    <link rel="stylesheet" href="css/paket.css">
    <!-- Modernizer for Portfolio -->
    <script src="js/modernizer.js"></script>

    <!--[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 class="host_version"> 

	<!-- Modal -->


    <!-- LOADER -->
	<div id="preloader">
		<div class="loading">
			<div class="finger finger-1">
				<div class="finger-item">
				<span></span><i></i>
				</div>
			</div>
  			<div class="finger finger-2">
				<div class="finger-item">
				<span></span><i></i>
				</div>
			</div>
  			<div class="finger finger-3">
				<div class="finger-item">
				  <span></span><i></i>
				</div>
			</div>
  			<div class="finger finger-4">
				<div class="finger-item">
				<span></span><i></i>
				</div>
			</div>
  			<div class="last-finger">
				<div class="last-finger-item"><i></i></div>
			</div>
		</div>
	</div>
	<!-- END LOADER -->

    <header class="header header_style_01">
        <nav class="megamenu navbar navbar-default">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="dashboard1.php"><img src="images/logos/logo1.png" alt="image"></a>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li><a href="dashboard1.php">Beranda</a></li>
                        <li><a href="paket1.php">Paket</a></li>
                        <li><a class="active" href="tiket1.php">Tiket</a></li>
                        <!-- <li><a href="testimonial1.php">Testimonial</a></li> -->
                        <li><a href="contact1.php">Kontak</a></li>
                    </ul>
                    <ul class="nav navbar-nav navbar-right">
                        <li><a class="btn-light btn-radius btn-brd log" href="logout.php"><i class="flaticon-padlock"></i> Keluar</a></li>
                    </ul>
                </div>
            </div>
        </nav>
    </header>
	<?php
        // $AllPaket = GetAllPaket();
    ?>
	<div class="all-title-box">
		<div class="container text-center">
			<h1>Tiket<span class="m_1">Lihat daftar tiket dari paket yang sudah anda pesan.</span></h1>
            <!-- <a href="#addnew" class="btn btn-light btn-radius btn-brd grd1 effect-1 fa fa-plus" data-toggle="modal">&nbsp Tambah Paket</a> -->
            
		</div>
	</div>
    <hr>

        <section class="courses-section spad">
		<div class="container">
			<div class="row">
				<tr ></tr>
				<!-- course item -->
					<?php
                            $id_akun = $_SESSION['id_akun'];
 						    $jumlahDataPerHalaman =3;
                             $jumlahData = count(query("SELECT * FROM paket INNER JOIN tiket ON paket.id_paket
                             = tiket.kode_paket WHERE id_akun = '$id_akun'")); // jumlah halaman = total data/ data per halaman
                             $jumlahHalaman = ceil($jumlahData / $jumlahDataPerHalaman);
                             $halamanAktif = (isset($_GET["halaman"] ) ) ? $_GET["halaman"] : 1; // ? = if, :=else
                          
                             $awalData = ($jumlahDataPerHalaman * $halamanAktif) - $jumlahDataPerHalaman;
                             $AllTiket = query("SELECT * FROM paket INNER JOIN tiket ON paket.id_paket
                             = tiket.kode_paket WHERE id_akun = '$id_akun' LIMIT $awalData, $jumlahDataPerHalaman");                        

 						// $AllTiket = GetAllTiketUser($_SESSION['id_akun']);
 					?>
                     	<?php if($halamanAktif > 1) : ?>
						<a href="?halaman=<?= $halamanAktif - 1; ?>">Previous</a>
					<?php endif; ?>

					<?php for($i = 1; $i <= $jumlahHalaman; $i++) : ?>
						<?php if($i == $halamanAktif ) : ?>
							<a href="?halaman=<?= $i; ?>" style="font-weight: bold; color: red;"><?= $i; ?></a>
						<?php else : ?>
							<a href="?halaman=<?= $i; ?>"><?= $i; ?></a>
						<?php endif; ?>
					<?php endfor; ?>

					<?php if($halamanAktif < $jumlahHalaman) : ?>
						<a href="?halaman=<?= $halamanAktif + 1; ?>">Next</a>
					<?php endif;  ?>
                     <center>				
				    <table style="width:90%;margin-top:25px;" border="5">
                        <tr style="color:black;">
                            <th><strong>No Tiket</strong></th>
                            <th><strong>ID Pembeli</strong></th>    
                            <th><strong>Kode Paket</strong></th>
                            <th><strong>No Kursi</strong></th>
                            <th  style="border-bottom:none"></th>
                        </tr>
                        <?php 
                            $id = 1;
                            foreach($AllTiket as $tiket){ 
                                if($id%2==0){
                                    $color = '#add8e6';
                                }
                                else{
                                    $color = '#ffffe0';
                                }?>
                            <tr style="color:black;">
                                <td id="<?= $id; ?>" style="background-color:<?= $color; ?>"><?= $tiket['id_tiket']; ?></td>
                                <td id="<?= $id; ?>" style="background-color:<?= $color; ?>"><?= $tiket['id_akun']; ?></td>
                                <td id="<?= $id; ?>" style="background-color:<?= $color; ?>"><?= $tiket['kode_paket']; ?></td>
                                <td id="<?= $id; ?>" style="background-color:<?= $color; ?>"><?= $tiket['no_kursi']; ?></td>
                                <td>
                                    <a href="tiketMahasiswa.php?kode=<?= $tiket['kode_paket']; ?>" target="_blank"">
                                    <center><div class="fa fa-print btn btn-info">&nbspPrint Tiket</div></center>
                                    </a>
                                </td>
                            </tr>
                        <?php 
                            ++$id;
                            } 
                        ?>
                    </table>
                    </center>				
		</div>
	</section><br>

        

 
    <footer class="footer">
        <div class="container">
            <div class="row">
                <div class="col-md-4 col-sm-4 col-xs-12">
                    <div class="widget clearfix">
                        <div class="widget-title">
                            <img src="images/logos/logo1.png" alt="">
                            <small>Mickie Funland</small>
                        </div>
                        <p>Taman bermain nomor 1 di Sumatera Utara.</p>
                    </div><!-- end clearfix -->
                </div><!-- end col -->

				<div class="col-md-3 col-sm-3 col-xs-12">
                    <div class="widget clearfix">
                        <div class="widget-title">
                            <h3>Information Link</h3>
                        </div>
                        <ul class="footer-links">
                        <li><a  href="dashboard1.php">Home</a></li>
                        <!-- <li><a href="wahana.php">Wahana</a></li> -->
                        <li><a href="paket1.php">Paket</a></li>
                        <li><a href="tiket1.php">Tiket</a></li>
                        <!-- <li><a href="testimonial.php">Testimonials</a></li> -->
                        <li><a href="contact1.php">Contact</a></li>
                        </ul><!-- end links -->
                    </div><!-- end clearfix -->
                </div><!-- end col -->
				

                <div class="col-md-2 col-sm-2 col-xs-12">
                    <div class="widget clearfix">
                        <div class="widget-title">
                            <h3>Social</h3>
                        </div>
                        <ul class="footer-links">
                            <li><a href="#"><i class="fa fa-facebook"></i> 22.543 Likes</a></li>
                            <li><a href="#"><i class="fa fa-github"></i> 128 Projects</a></li>
                            <li><a href="#"><i class="fa fa-twitter"></i> 12.860 Followers</a></li>
                            <li><a href="#"><i class="fa fa-dribbble"></i> 3312 Shots</a></li>
                            <li><a href="#"><i class="fa fa-pinterest"></i>3331 Pins</a></li>
                        </ul><!-- end links -->
                    </div><!-- end clearfix -->
                </div><!-- end col -->
            </div><!-- end row -->
        </div><!-- end container -->
    </footer><!-- end footer -->

    <div class="copyrights">
        <div class="container">
            <div class="footer-distributed">
                <div class="footer-left">                   
                    <p class="footer-company-name">&copy; 2020 <a href="#">Funland</a> Design By : PSW-01 </p>
                </div>

                <!-- <div class="footer-right"> -->
                    <!-- <form method="get" action="#"> -->
                        <!-- <input placeholder="Subscribe our newsletter.." name="search"> -->
                        <!-- <i class="fa fa-envelope-o"></i> -->
                    <!-- </form> -->
                <!-- </div> -->
            </div>
        </div><!-- end container -->
    </div><!-- end copyrights -->

    <a href="#" id="scroll-to-top" class="dmtop global-radius"><i class="fa fa-angle-up"></i></a>

    <!-- ALL JS FILES -->
    <script src="js/all.js"></script>
    <!-- ALL PLUGINS -->
    <script src="js/custom.js"></script>

</body>
</html>