<?php include 'includes/config.php'; 
date_default_timezone_set('Asia/Calcutta');
// $date = date("Y/m/d");

if (!isset($_SESSION['useradmin']) ) {
  echo '<script>alert("You are not logged in");window.location = "../admin/index.php";</script>';
}

$usertype = $_SESSION['useradmin'];

$msg = "";
$error = "";


if (isset($_POST['updateadminone']))
{

    $Market_name_one = $_POST['Market_name_one'];
    $Market_name_two = $_POST['Market_name_two'];
    $Market_name_three = $_POST['Market_name_three'];
    
    $min_starlinebetting_one = $_POST['min_starlinebetting_one'];
    $min_starlinebetting_two = $_POST['min_starlinebetting_two'];
    $min_starlinebetting_three = $_POST['min_starlinebetting_three'];


    
     $sql="UPDATE admin SET Market_name_one = '$Market_name_one' , Market_name_two = '$Market_name_two' , Market_name_three = '$Market_name_three' , min_starlinebetting_one = '$min_starlinebetting_one' , min_starlinebetting_two = '$min_starlinebetting_two' , min_starlinebetting_three = '$min_starlinebetting_three'  WHERE id='1'"; 
    
        if (!mysqli_query($conn,$sql)) {
            $error = "Fail to Update Settings";
        }else{
            $msg = "Settings Updated Successfully";
        }
}


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

<head>
    <meta charset="utf-8" />
    <title>Market Settings</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="adminassets/images/favicon.ico">

    <!-- Bootstrap Css -->
    <link href="adminassets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
    <!-- Icons Css -->
    <link href="adminassets/css/icons.min.css" rel="stylesheet" type="text/css" />

    <link href="adminassets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />
    <link href="adminassets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" />
    <link href="adminassets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" />
    <link href="adminassets/libs/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
    <!-- App Css-->
    <link href="adminassets/css/app.min.css?v=2" id="app-style" rel="stylesheet" type="text/css" />

    <link href="adminassets/css/custom.css?v=11" rel="stylesheet" type="text/css" />

    <!-- ckeditor  -->  
     <script type="text/javascript" src="assest/ckeditor/ckeditor.js"></script>
    <!-- ckeditor -->

</head>

<body data-sidebar="dark">

    <div id="layout-wrapper">

         <?php include 'includes/header.php';  ?>

        <div class="main-content">
            <div class="page-content"> 
                   <div class="col-md-12">
                        <?php if($msg){?>
                        <div class="alert alert-success left-icon-alert" role="alert">
                         <strong>Well done! </strong><?php echo htmlentities($msg); ?>
                         </div><?php } 
                         else if($error){?>
                            <div class="alert alert-danger left-icon-alert" role="alert">
                                <strong>Oh snap!</strong> <?php echo htmlentities($error); ?>
                            </div>
                        <?php } ?>
                    </div>

                <div class="container-fluid"> 
                    <div class="row clearfix">
                        <div class="col-lg-12 col-md-12 col-sm-12">
                            <div class="card p-4">
                                <div class="header">
                                    <h2><strong>Market </strong> <small>Update Settings</small> </h2>
                                </div>
                                <div class="body">
                                    <?php 

                                    $sql = "SELECT * FROM admin";
                                    $getqry = mysqli_query($conn, $sql);
                                    if (mysqli_num_rows($getqry) > 0) {
                                        while ($row = mysqli_fetch_assoc($getqry)) {
                                            $Market_name_one = $row['Market_name_one'];
                                            $Market_name_two = $row['Market_name_two'];
                                            $Market_name_three = $row['Market_name_three'];
                                            
                                            $min_starlinebetting_one = $row['min_starlinebetting_one'];
                                            $min_starlinebetting_two = $row['min_starlinebetting_two'];
                                            $min_starlinebetting_three = $row['min_starlinebetting_three'];

                                            
                                        }
                                    }
                                    ?>
                                    <form method="POST" action="">
                                        <div class="row clearfix">
                                            <div class="col-sm-4">
                                                <label for="market_name"> <?echo $Market_name_one;?> </label>
                                                <div class="form-group">
                                                    <div class="form-group">
                                                        <input type="text" id="Market_name_one" name="Market_name_one" class="form-control" value="<?php echo $Market_name_one; ?>" placeholder="Market One">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-sm-4">
                                                <label for="market_close"> <?echo $Market_name_two;?> </label>
                                                <div class="form-group">
                                                    <div class="form-group">
                                                        <input type="text" id="Market_name_two" name="Market_name_two" class="form-control" value="<?php echo $Market_name_two; ?>" placeholder="Market Two">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-sm-4">
                                                <label for="market_close"> <?echo $Market_name_three;?> </label>
                                                <div class="form-group">
                                                    <div class="form-group">
                                                        <input type="text" id="Market_name_three" name="Market_name_three" class="form-control" value="<?php echo $Market_name_three; ?>" placeholder="Market Three">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-sm-4">
                                                <label for="market_close"> <?echo $Market_name_one;?> Bet Rate </label>
                                                <div class="form-group">
                                                    <div class="form-group">
                                                        <input type="text" id="min_starlinebetting_one" name="min_starlinebetting_one" class="form-control" value="<?php echo $min_starlinebetting_one; ?>" placeholder="Min Betting Rate">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-sm-4">
                                                <label for="market_close"> <?echo $Market_name_two;?> Bet Rate </label>
                                                <div class="form-group">
                                                    <div class="form-group">
                                                        <input type="text" id="min_starlinebetting_two" name="min_starlinebetting_two" class="form-control" value="<?php echo $min_starlinebetting_two; ?>" placeholder="Min Betting Rate">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-sm-4">
                                                <label for="market_close"> <?echo $Market_name_three;?> Bet Rate </label>
                                                <div class="form-group">
                                                    <div class="form-group">
                                                        <input type="text" id="min_starlinebetting_three" name="min_starlinebetting_three" class="form-control" value="<?php echo $min_starlinebetting_three; ?>" placeholder="Min Betting Rate">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group m-4 text-sm-right">
                                                <button type="submit" style="text-align:right;" name="updateadminone" class="btn btn-raised btn-primary btn-round waves-effect">Update</button>
                                            </div>
                                        </div>
                                    </form> 
                                </div>
                            </div>
                        </div>
                        
                    </div>
                </div>

            </div>            
        </div>


        <footer class="footer">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-6">
                        <script>
                            document.write(new Date().getFullYear())
                        </script> ©Matka.
                    </div>
                    <div class="col-sm-6">
                        <div class="text-sm-right d-none d-sm-block">

                        </div>
                    </div>
                </div>
            </div>
        </footer>
    </div>
</div>

<script src="adminassets/libs/jquery/jquery.min.js"></script>
<script src="adminassets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="adminassets/libs/metismenu/metisMenu.min.js"></script>
<script src="adminassets/libs/simplebar/simplebar.min.js"></script>
<script src="adminassets/libs/node-waves/waves.min.js"></script>
<script src="adminassets/libs/select2/js/select2.min.js"></script>
<script src="adminassets/js/pages/form-advanced.init.js"></script>
<!-- Required datatable js -->
<script src="adminassets/libs/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="adminassets/libs/datatables.net-bs4/js/dataTables.bootstrap4.min.js"></script>
<!-- Buttons examples -->
<script src="adminassets/libs/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
<script src="adminassets/libs/datatables.net-buttons-bs4/js/buttons.bootstrap4.min.js"></script>
<script src="adminassets/libs/jszip/jszip.min.js"></script>
<script src="adminassets/libs/pdfmake/build/pdfmake.min.js"></script>
<script src="adminassets/libs/pdfmake/build/vfs_fonts.js"></script>
<script src="adminassets/libs/datatables.net-buttons/js/buttons.html5.min.js"></script>
<script src="adminassets/libs/datatables.net-buttons/js/buttons.print.min.js"></script>
<script src="adminassets/libs/datatables.net-buttons/js/buttons.colVis.min.js"></script>

<!-- Responsive examples -->
<script src="adminassets/libs/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
<script src="adminassets/libs/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script>

<!-- Datatable init js -->
<script src="adminassets/js/pages/datatables.init.js"></script>
<!-- App js -->
<script src="adminassets/js/app.js"></script>
<script src="adminassets/js/customjs.js?v=9212"></script>


</body>

</html>