<?php
include 'koneksi/koneksi.php';
session_start();
$app = mysql_fetch_array(mysql_query("SELECT * from aplikasi where id_user = $_SESSION[id]"));

$skr = date('Y-m-d');
/**
 * Jika Tidak login atau sudah login tapi bukan sebagai admin
 * maka akan dibawa kembali kehalaman login atau menuju halaman yang seharusnya.
 */
if ( !isset($_SESSION['username'])) {

	header('location:../admin/login.php');
	exit();
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="../assets/images/favicon.png">
    <title><?= $app['nama_aplikasi'];?> - <?= $app['nama_perusahaan'];?> - admin</title>
    <!-- Bootstrap Core CSS -->
    <link href="../assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<!-- Bootstrap datetime picker-->
    <link href="datepicker/css/bootstrap-datepicker3.css" rel="stylesheet">
    
    <!-- chartist CSS -->
    <link href="../assets/plugins/chartist-js/dist/chartist.min.css" rel="stylesheet">
    <link href="../assets/plugins/chartist-js/dist/chartist-init.css" rel="stylesheet">
    <link href="../assets/plugins/chartist-plugin-tooltip-master/dist/chartist-plugin-tooltip.css" rel="stylesheet">
    <!--This page css - Morris CSS -->
    <link href="../assets/plugins/c3-master/c3.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="css/style.css" rel="stylesheet">
    <!-- You can change the theme colors from here -->
    <link href="css/colors/blue.css" id="theme" rel="stylesheet">
    <!-- 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 class="fix-header fix-sidebar card-no-border">
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
    </div>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <div id="main-wrapper">
        <!-- ============================================================== -->
        <!-- Topbar header - style you can find in pages.scss -->
        <!-- ============================================================== -->
                <?php include"controller/topbar.php";?>

        <!-- ============================================================== -->
        <!-- End Topbar header -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <aside class="left-sidebar">
            <!-- Sidebar scroll-->
            <div class="scroll-sidebar">
                <!-- Sidebar navigation-->
                <nav class="sidebar-nav">
                    <ul id="sidebarnav">
                        <li > <a class="waves-effect waves-dark" href="index.php" aria-expanded="false"><i class="mdi mdi-gauge"></i><span class="hide-menu">Dashboard</span></a>
                        </li>
                        <li> <a class="waves-effect waves-dark" href="laporan.php?start=&end=" aria-expanded="false"><i class="mdi mdi-file-document"></i><span class="hide-menu">Laporan</span></a>
                        </li>
						<li> <a class="waves-effect waves-dark" href="pertanyaan.php" aria-expanded="false"><i class="mdi mdi-help"></i><span class="hide-menu">Pertanyaan</span></a>
                        </li>
                        <li> <a class="waves-effect waves-dark" href="feed.php" aria-expanded="false"><i class="mdi mdi-rss-box"></i><span class="hide-menu">Feed</span></a>
                        </li>
						  <li> <a class="waves-effect waves-dark" href="jenis_kelamin.php" aria-expanded="false"><i class="mdi mdi-account"></i><span class="hide-menu">Kategori</span></a>
                        </li>
                        <li> <a class="waves-effect waves-dark" href="setting.php" aria-expanded="false"><i class="mdi mdi-settings"></i><span class="hide-menu">Setting</span></a>
                        </li>
						<li> <a class="waves-effect waves-dark" href="profil.php" aria-expanded="false"><i class="mdi mdi-account-check"></i><span class="hide-menu">Profil</span></a>
                        </li>
						<li><hr></li>
						<li> <a class="waves-effect waves-dark" href="../index.php" target="_blank" aria-expanded="false"><i class="mdi mdi-arrow-expand-all"></i><span class="hide-menu">Front End</span></a>
                        </li>
						<li> <a class="waves-effect waves-dark text-danger" href="controller/logout.php" aria-expanded="false"><i class="mdi mdi-power text-danger"></i><span class="hide-menu">Logout</span></a>
                        </li>
                    </ul>
                </nav>
                <!-- End Sidebar navigation -->
            </div>
            <!-- End Sidebar scroll-->
            <!-- Bottom points-->
            <div class="sidebar-footer">
                <!-- item--><a href="setting.php" class="link" data-toggle="tooltip" title="Settings"><i class="ti-settings"></i></a>
                <!-- item--><a href="../index.php" class="link" data-toggle="tooltip" title="Front End"><i class="mdi mdi-arrow-expand-all"></i></a>
                <!-- item--><a href="controller/logout.php" class="link text-danger" data-toggle="tooltip" title="Logout"><i class="mdi mdi-power"></i></a> </div>
            <!-- End Bottom points-->
        </aside>
        <!-- ============================================================== -->
        <!-- End Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Page wrapper  -->
        <!-- ============================================================== -->
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container-fluid">
                <!-- ============================================================== -->
                <!-- Bread crumb and right sidebar toggle -->
                <!-- ============================================================== -->
                <div class="row page-titles">
                    <div class="col-md-5 col-8 align-self-center">
                        <h3 class="text-themecolor"><?= $app['nama_aplikasi'];?></h3>
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="index">Home</a></li>
                            <li class="breadcrumb-item active">Pertanyaan</li>
                        </ol>
                    </div>
                    <div class="col-md-7 col-4 align-self-center">
                        <a data-toggle="modal" role="button" href="#add_feed" class="btn waves-effect waves-light btn-info pull-right hidden-sm-down"><i class="mdi mdi-plus"></i>Tambah Pertanyaan</a>
                    </div>
                </div>
                <!-- ============================================================== -->
                <!-- End Bread crumb and right sidebar toggle -->
                <!-- ============================================================== -->
                <div class="modal" id="add_feed" tabindex="-1" role="dialog" aria-hidden="true">
									<div class="modal-dialog">
										<div class="card">
											<div class="modal-header">
										  		<h4 class="modal-title">Tambah Pertanyaan</h4>
												<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
										  		
											</div>
											<div class="modal-body">
												<form action="controller/pertanyaan_simpan.php" method="POST" class="form-horizontal form-material" enctype="multipart/form-data">
														<div class="form-group">
															<label class="col-md-12">Pertanyaan</label>
															<div class="col-md-12">
																<textarea name="pertanyaan" class="form-control"></textarea>
															</div>
														</div>
														<div class="form-group">
															<label class="col-sm-12">Status</label>
															<div class="col-sm-12">
																<input name="status" value="0" type="hidden" />
															</div>
														</div>
													
											</div>
											<div class="modal-footer">
												<button type="submit" class="btn btn-right btn-success">Tambah</button>
										  	</div>
											</form>
										</div>
									</div>
								</div>
				<!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
                <!-- Row -->
                <div class="row">
                    <!-- column -->
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-block">
                                <h4 class="card-title">Pertanyaan</h4>
                                <div class="table-responsive">
                                    <table class="table">
                                        <thead>
                                            <tr>
                                                <th>#</th>
                                                <th>Pertanyaan</th>
                                                <th>Status</th>
												<th></th>
                                            </tr>
                                        </thead>
                                        <tbody>
											<?php
											$s_feed=mysql_query("SELECT * from pertanyaan where id_user='$_SESSION[id]'");
											$i=1;
											while ($d_feed=mysql_fetch_array($s_feed)){
												
											?>
                                            <tr>
                                                <td><?= $i++;?></td>
                                                <td><?= $d_feed['pertanyaan'];?></td>
                                                <td><?php if($d_feed['status']==0){echo 'tidak aktif';}else{echo'aktif';}?></td>
												<td> <a href="controller/pertanyaan_hapus.php?id=<?= $d_feed['id'];?>" class="btn btn-sm btn-warning" onclick="return confirm('Apakah pertanyaan ini akan dihapus ?')"><i class="mdi mdi-delete"></i> hapus</a>
												<?php if($d_feed['status']==1){?>
												<a href="controller/pertanyaan_off.php?id=<?= $d_feed['id'];?>" class="btn btn-sm btn-danger"  onclick="return confirm('Apakah pertanyaan ini akan dinonaktifkan ?')"><i class="mdi mdi-power"></i> off</a></td>
											<?php ;} else if($d_feed['status']==0){?>
												<a href="controller/pertanyaan_on.php?id=<?= $d_feed['id'];?>" class="btn btn-sm btn-success" onclick="return confirm('Apakah pertanyaan ini akan diaktifkan ?')"><i class="mdi mdi-power"></i> on</a></td>
											<?php ;} ?>
											</tr>
                                            <?php ;} ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- Row -->
               
                <!-- ============================================================== -->
                <!-- End PAge Content -->
                <!-- ============================================================== -->
            </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <footer class="footer"> © 2019 <?= $app['nama_aplikasi'];?> - <?= $app['nama_perusahaan'];?> by besurvey.id</footer>
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="../assets/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="../assets/plugins/bootstrap/js/tether.min.js"></script>
    <script src="../assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <!-- Bootstrap datetime picker-->
    <script src="js/daterangepicker.js"></script>
    <script src="datepicker/js/bootstrap-datepicker.js"></script>
    <script type="text/javascript">
            $(document).ready(function () {
                $('.tanggal').datepicker({
                    todayHighlight: true,
					format: "yyyy-mm-dd",
                    autoclose:true
                });
            });
        </script>
	<!-- slimscrollbar scrollbar JavaScript -->
    <script src="js/jquery.slimscroll.js"></script>
    <!--Wave Effects -->
    <script src="js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="js/sidebarmenu.js"></script>
    <!--stickey kit -->
    <script src="../assets/plugins/sticky-kit-master/dist/sticky-kit.min.js"></script>
    <!--Custom JavaScript -->
    <script src="js/custom.min.js"></script>
    <!-- ============================================================== -->
    <!-- This page plugins -->
    <!-- ============================================================== -->
    <!-- chartist chart -->
    <script src="../assets/plugins/chartist-js/dist/chartist.min.js"></script>
    <script src="../assets/plugins/chartist-plugin-tooltip-master/dist/chartist-plugin-tooltip.min.js"></script>
    <!--c3 JavaScript -->
    <script src="../assets/plugins/d3/d3.min.js"></script>
    <script src="../assets/plugins/c3-master/c3.min.js"></script>
    <!-- Chart JS -->
    <script src="js/dashboard1.js"></script>
	<script src="../js/bootstrap-notify/bootstrap-notify.min.js"></script>
		<?php
		if (isset($_GET['sukses'])) : ?>
		<script type="text/javascript">
		$(document).ready(function(){
				$.notify({
					icon: 'font-icon font-icon-lock',
					title: '<strong>Berhasil.</strong>',
					message: '<?=base64_decode($_GET['sukses']);?>'
				},{
					type: 'success',
					placement: {
						align: "center"
					}
				});
		});
		</script>
		<?php endif;?>
		<?php
		if (isset($_GET['hapus'])) : ?>
		<script type="text/javascript">
		$(document).ready(function(){
				$.notify({
					icon: 'font-icon font-icon-lock',
					title: '<strong>Berhasil.</strong>',
					message: '<?=base64_decode($_GET['hapus']);?>'
				},{
					type: 'danger',
					placement: {
						align: "center"
					}
				});
		});
		</script>
		<?php endif;?>
		<?php
		if (isset($_GET['update'])) : ?>
		<script type="text/javascript">
		$(document).ready(function(){
				$.notify({
					icon: 'font-icon font-icon-lock',
					title: '<strong>Berhasil.</strong>',
					message: '<?=base64_decode($_GET['update']);?>'
				},{
					type: 'info',
					placement: {
						align: "center"
					}
				});
		});
		</script>
		<?php endif;?>
</body>

</html>
