<?php 
	include "includes/operations.php";
	if(!isset($_SESSION['admin_id'])){
		echo '<script> window.location.href = "login.php"; </script>';
		header("location:login.php"); exit();
	}
	
	
	function CheckAccess() {
		
    $result = (isset($_SESSION['role']) &&  $_SESSION['role'] != 'Super Admin');
		return $result;
	}
	
	if (CheckAccess()) {
		header("location:login.php");
			echo '<script> window.location.href = "login.php"; </script>';
			exit();
	}
	
	$res = mysqli_query($con, "SELECT * FROM system_configuration");
	$lang = mysqli_fetch_array($res);
	
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <?php include "includes/headerlinks.php";?>
	<style>
		b {
			font-weight:600 !important;
		}
	</style>
</head>

<body class="fix-header card-no-border">
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <?php include "includes/loader.php";?>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <div id="main-wrapper">
        <!-- ============================================================== -->
        <!-- Topbar header - style you can find in pages.scss -->
        <!-- ============================================================== -->
        <?php include "includes/header.php";?>
        <!-- ============================================================== -->
        <!-- End Topbar header -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <?php include "includes/sidebar.php";?>
        <!-- ============================================================== -->
        <!-- End Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Page wrapper  -->
        <!-- ============================================================== -->
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <div class="row page-titles">
                <div class="col-md-5 align-self-center">
                    <h3 class="text-themecolor">Manage System Settings</h3>
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- End Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container">
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
                <!-- Row -->
				<div class="row">
                    <div class="col-lg-7">
                        <div class="card card-outline-info">
                            <div class="card-body">
                                <form method="post">
                                    <div class="form-body">
                                        <div class="">
											<div class="form-group">
												<label class="control-label"><b>System Name</b></label>
												<input type="text" id="sys_name" name="system_name" value="<?php echo $lang['system_name'];?>" class="form-control" placeholder="John doe">
											 </div>
                                        </div>
										<div class="">
											<div class="form-group">
												<label class="control-label"><b>Email</b></label>
												<input type="text" id="sys_email" name="system_email" value="<?php echo $lang['system_email'];?>" class="form-control" placeholder="John doe">
											</div>
										</div>
                                        <!--/row-->
                                        <div class="">
											<div class="">
                                                <div class="form-group">
                                                    <label class="control-label"><b>Phone</b></label>
                                                    <input type="text" id="sys_phone" name="system_phone" value="<?php echo $lang['system_phone'];?>" class="form-control" placeholder="John doe">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="">
											<div class="">
                                                <div class="form-group">
                                                    <label class="control-label"><b>Address</b></label>
                                                    <input type="text" id="sys_phone" name="system_address" value="<?php echo $lang['system_address'];?>" class="form-control" placeholder="John doe">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="">
											<div class="">
                                                <div class="form-group">
                                                    <label class="control-label"><b>Facebook</b></label>
                                                    <input type="text" id="sys_phone" name="system_facebook" value="<?php echo $lang['system_facebook'];?>" class="form-control" placeholder="Facebook Profile Link">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="">
											<div class="">
                                                <div class="form-group">
                                                    <label class="control-label"><b>Instagram</b></label>
                                                    <input type="text" id="sys_phone" name="system_instagram" value="<?php echo $lang['system_instagram'];?>" class="form-control" placeholder="Instagram Profile Link">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="">
											<div class="">
                                                <div class="form-group">
                                                    <label class="control-label"><b>Youtube</b></label>
                                                    <input type="text" id="sys_phone" name="system_youtube" value="<?php echo $lang['system_youtube'];?>" class="form-control" placeholder="Youtube Profile Link">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="">
											<div class="">
                                                <div class="form-group">
                                                    <label class="control-label"><b>Twitter</b></label>
                                                    <input type="text" id="sys_phone" name="system_twitter" value="<?php echo $lang['system_twitter'];?>" class="form-control" placeholder="Twitter Profile Link">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-actions">
                                        <button type="submit" class="btn btn-success" name="save_config">Save</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
					<div class="col-lg-5 col-xlg-3 col-md-5">
						<div class="card card-outline-info">
                            <div class="card-body">
								<h4><b>SETUP STRIPE KEYS</b></h4>
								<p>Please watch the video how to get <b>Live Keys</b> from your stripe account and then copy & paste the keys into the text box. <br><a href="https://youtu.be/vpvy24WRzGY?si=S9sSngLyQv-LMkrA" target="_blank">Click here to watch the Stripe video </a>
								</p>
								<hr>
                                <form method="post">
                                    <div class="form-body">
                                        <div class="">
											<div class="form-group">
												<label class="control-label"><b>Public Key*</b></label>
												<input type="text" id="sys_name" name="public_key" value="<?php echo $lang['public_key'];?>" class="form-control" placeholder="Enter Public Key" required>
											 </div>
                                        </div>
                                        <div class="">
											<div class="form-group">
												<label class="control-label"><b>Secret Key*</b></label>
												<input type="text" id="sys_name" name="secret_key" value="<?php echo $lang['secret_key'];?>" class="form-control" placeholder="Enter Secret Key" required>
											 </div>
                                        </div>
                                    </div>
                                    <div class="form-actions">
                                        <button type="submit" class="btn btn-success" name="save_stripe_config">Save</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-body">
                                <center class="m-t-30"> <img src="uploads/logo/<?php echo $lang['system_image']?>" onerror="this.onerror=null;this.src='assets/images/default.png';" class="img-responsive" width="150" />
                                    <br><br><a href="#" class="btn btn-success" data-toggle="modal" data-target="#myModal"> Change Logo</a>
									<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<h4 class="modal-title" id="myModalLabel">Change Logo</h4>
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
												</div>
												<form method="POST" enctype="multipart/form-data">
													<div class="modal-body">
														<img src="uploads/logo/<?php echo $lang['system_image']?>" onerror="this.onerror=null;this.src='assets/images/default.png';" alt="Detail Picture" style="width:40% !important" class="img-responsive radius" /><br>
													</div>
													<div class="custom-file">
													  <input type="file" name="system_image" class="custom-file-input" id="customFile" accept="image/*" required>
													  <label class="custom-file-label form-control" for="customFile">Choose file</label>
													</div>
													<div class="modal-footer">
														<button type="submit" name="update_system_image" class="btn btn-success waves-effect">Save</button>
														<button type="button" class="btn btn-secondary"
															data-dismiss="modal">Close</button>
													</div>
												</form>
											</div>
											<!-- /.modal-content -->
										</div>
										<!-- /.modal-dialog -->
									</div>
                                </center>
                            </div>
                            <div>
                            </div>
                        </div>
                    </div>
                </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <?php include "includes/footer.php";?>
            <?php include "includes/theme.php";?>
            <!-- ============================================================== -->
            <!-- 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/popper.min.js"></script>

    <script src="assets/plugins/bootstrap/js/bootstrap.min.js"></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>
    <script src="assets/plugins/sparkline/jquery.sparkline.min.js"></script>
    <!--Custom JavaScript -->
    <script src="js/custom.min.js"></script>
    <!-- ============================================================== -->
    <!-- Style switcher -->
    <!-- ============================================================== -->
    <script src="assets/plugins/styleswitcher/jQuery.style.switcher.js"></script>
</body>
   <script>
		// Add the following code if you want the name of the file appear on select
		$(".custom-file-input").on("change", function() {
		  var fileName = $(this).val().split("\\").pop();
		  $(this).siblings(".custom-file-label").addClass("selected").html(fileName);
		});
	</script>
</html>
