<!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>Paket</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="dashboard.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="dashboard.php">Beranda</a></li>
                        <li><a class="active" href="paket.php">Paket</a></li>
                        <li><a href="tiket.php">Tiket</a></li>
                    
                        <li><a href="contact.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">
        <?php

include('add_modal.php');
include('edit_modal.php');

                // pagination
            // konfigurasi
            $jumlahDataPerHalaman =4;
            $jumlahData = count(query("SELECT * FROM paket")); // jumlah halaman = total data/ data per halaman
            $jumlahHalaman = ceil($jumlahData / $jumlahDataPerHalaman);
            $halamanAktif = (isset($_GET["halaman"] ) ) ? $_GET["halaman"] : 1; // ? = if, :=else

            $awalData = ($jumlahDataPerHalaman * $halamanAktif) - $jumlahDataPerHalaman;
            $datapaket = query("SELECT * FROM paket LIMIT $awalData, $jumlahDataPerHalaman");

            // tombol cari di klik
            if(isset($_POST["cari"]) ){
                $datapaket = caripaket($_POST["keyword"]);
            }             
             
            ?>
			<h1>Paket<span class="m_1">Beberapa pilihan paket yang tersedia.</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 mb-3">
                <div class="col-lg-12">
                    <center><form class="checkdomain form-inline" action="" method="post">
                        <div class="checkdomain-wrapper">
                            <div class="form-group">
                                <label class="sr-only">Paket</label>
                                <input type="text" class="form-control" id="keyword" name="keyword" placeholder="Cari paket...">
                                <button type="submit" class="btn btn-primary grd1" name="cari"><i class="fa fa-search"></i></button>
                            </div>
                            <hr>
                        </div><!-- end checkdomain-wrapper -->
                    </form><center>
                </div>
            </div>
        <?php
				if(!isset($_POST['cari'])){
				?>
					<?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; } ?>
                        
			<div class="row">
				<tr ></tr>
				<!-- course item -->
					<?php
 						// $datapaket = getPaket();
 													
                    foreach($datapaket as $paket) : {}
								echo('<div class="col-lg-6 col-md-6">');
									echo('<table width="100%" >');
                                        echo('<tr class="thead"><td  colspan="2">Rp.' . $paket['harga'] . '</td><td align="right" class"icon">
                                        <a data-toggle="modal" class="btn btn-success btn-sm" href="detailpaket.php?id='.$paket['id_paket'].'" style="background-color:#5778d41;"><i class="fa fa-eye">&nbsp Lihat</i></a> &nbsp &nbsp
                                        <a data-toggle="modal" class="btn btn-success btn-sm" href="#edit_' . $paket['id_paket'] . '" style="background-color:#6f6fff;"><i class="fa fa-edit">&nbsp Sunting</i></a>&nbsp &nbsp
                                        <a data-toggle="modal" class="btn btn-danger btn-sm" href="#delete_' . $paket['id_paket'] . '"><i class="fa fa-trash">&nbsp Hapus</i></a>&nbsp&nbsp</td></tr>'); 
										echo('<tr class="timg" ><td class="timg"  colspan="3"><center><img src="uploads/' . $paket['gambar'] . '"></center></td></tr>');   
                                         echo('<tr class="tligt" style="background-color:#f3f7d4;"><td colspan = "3"><center><h1><strong><i>Paket ' . $paket['nama_paket'] . '</i></strong></h1></center></td></tr>');
                                    echo('</table>');
                                    echo('<br>');
                                echo('</div>');
                                include('edit_modal.php');
        endforeach;
        
					?>			
		</div>
	</section>

        

 
    <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="dashboard.php">Beranda</a></li>
 
                        <li><a href="paket.php">Paket</a></li>
                        <li><a href="tiket.php">Tiket</a></li>

                        <li><a href="contact.php">Kontak</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>