<? include("../settings.php"); ?>
<? include("session.php"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SP Admin Panel</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Include all CSS/JS -->
        <!-- Bootstrap -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/jquery.dataTables.css" rel="stylesheet">
    <link href="http://cdn.datatables.net/responsive/1.0.1/css/dataTables.responsive.css" 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/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="js/jquery-2.1.1.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.dataTables.min.js"></script>
    <script src="http://cdn.datatables.net/responsive/1.0.1/js/dataTables.responsive.js"></script>

    <!-- End of all CSS/JS -->

   </head>
<body>


<? include("nav_menu.php"); ?>
      <div class="well">
<div class="content" bgcolor="#FFFFD0">
<div class="col-12 feature">
<div class="panelCheck">
    <div class="panel-heading">
        <h3 class "panel-title"><strong>Table Setup</strong></h3>
    </div>

    <form name="edittable" method='GET' action="tablesetup_edit.php" enctype="multipart/form-data" class="form-horizontal" role="form">
    <center>

      <div class="panel-body">
        <?
            if (isset($_REQUEST['confirm']) && $_REQUEST['confirm']!=""){
                $bind = array(":search1"=>$_REQUEST['tbl_id']);
                $update = array(
                    "tbl_name"=>$_REQUEST['tbl_name'],
                    "tbl_max"=>$_REQUEST['tbl_max'],
                    "tbl_active"=>$_REQUEST['tbl_active'],
                    "tbl_order"=>$_REQUEST['tbl_order'],
                    "tbl_lock"=>$_REQUEST['tbl_lock']
                );
                $db->update("tbl_table", $update, "tbl_id = :search1", $bind);
                echo "<script>alert('Table Updated');window.location='tablesetup.php';</script>";
            }else{
                $bind = array(":search1"=>$_REQUEST['tbl_id']);
                $results = $db->select("tbl_table","tbl_id = :search1",$bind);
                $result = $results[0];
            }

        ?>
        <div class='form-group'>
            <label for='tbl_name' class='col-lg-4 control-label'>Table Name</label>
            <div class='col-lg-6 text-left'>
                <input type="text" class="form-control" name="tbl_name" id="tbl_name" required value="<?=$result['tbl_name'];?>">
            </div>
        </div>
        <div class='form-group'>
            <label for='tbl_max' class='col-lg-4 control-label'>Maximum Seating Capacity</label>
            <div class='col-lg-6 text-left'>
                <input type="text" class="form-control" name="tbl_max" id="tbl_max" required value="<?=$result['tbl_max'];?>">
            </div>
        </div>
        <div class='form-group'>
            <label for='tbl_active' class='col-lg-4 control-label'>Table Active</label>
            <div class='col-lg-6 text-left'>
                <select name="tbl_active" class="form-control">
                    <?
                        if ($result['tbl_active']==1)
                            echo "<option value='1' selected>Yes</option><option value='0'>No</option>";
                        else
                            echo "<option value='1'>Yes</option><option value='0' selected>No</option>";
                    ?>
                </select>
            </div>
        </div>
        <div class='form-group'>
            <label for='tbl_lock' class='col-lg-4 control-label'>Table Lock</label>
            <div class='col-lg-6 text-left'>
                <select name="tbl_order" class="form-control">
                    <?
                        if ($result['tbl_lock']==1)
                            echo "<option value='1' selected>Yes</option><option value='0'>No</option>";
                        else
                            echo "<option value='1'>Yes</option><option value='0' selected>No</option>";
                    ?>
                </select>
            </div>
        </div>  
          <div class='form-group'>
            <label for='tbl_max' class='col-lg-4 control-label'>Table Order</label>
            <div class='col-lg-6 text-left'>
                <input type="text" class="form-control" name="tbl_order" id="tbl_order" required value="<?=$result['tbl_order'];?>">
            </div>
        </div>
          <input type="hidden" name="tbl_id" value="<?=$_REQUEST['tbl_id'];?>">
<input type="submit" name="confirm" value="Update" class="btn btn-default">
    <input type="button" value="Close" class="btn btn-default" onclick="window.location='tablesetup.php';">
        
        
    </center>
    </form>
</div>
</div>
</div>
</div>
</body>
</html>
