<?php   include_once('../config/db.php');   include_once('../config/check.php');  



if (filter_has_var(INPUT_POST, "submit")) 
    try{
            $date =            htmlspecialchars (strtoupper($_POST['date']));
            $date =            date("Y-m-d", strtotime($date));

            $branch =                   htmlspecialchars ( $_POST['branch']);
            $store =                    htmlspecialchars ( $_POST['store']);
            $name =                     htmlspecialchars ( $_POST['name']);
            $desc =                     htmlspecialchars ( $_POST['description']);
            $location =                  htmlspecialchars ( $_POST['location']);
          
            $sql = 'INSERT INTO admbtill(date,branch,store,name,description,location,uid) VALUES (:date,:branch,:store,:name,:desc,:location,:uid )';
            $conn->prepare($sql)->execute([ 'date'=>$date,'branch'=> $branch,'store'=>$store,'name'=>$name,'desc'=>$desc ,'location'=>$location,'uid'=>$uid ]);
            header("location:admbstill.php");

        } catch(Exception $e) { echo 'Message: ' .$e->getMessage();}

?>

<!DOCTYPE html>
<html>
<head>
<?php include_once('inc/link.php');   ?>  
</head>
<body <?php include_once('inc/nav.php');  ?>>
<div class="wrapper">

  <!-- Main Header -->
    <header class="main-header">

    <!-- Logo -->
       <?php include_once('inc/brand.php');   ?>

    <!-- Header Navbar -->
    <?php include_once('inc/navbar.php');   ?>

  </header>
 
  <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">

    <!-- sidebar: style can be found in sidebar.less -->
     <?php include_once('inc/menu.php');   ?>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">

    <section class="content-header">
      <h1>  <i class="fa fa-plus-circle" >  </i> Add Tills  </h1>
        <ol class="breadcrumb">
               </ol>
    </section>

    <section class="content container-fluid"> 
        <div class="box box-success box-xs">
            <div class="box-body">
                <div class="row">
                <form class="form-horizontal add_form "  action="" method="post"  >
                                                           
                                        <div class="col-sm-2"> 
                                            <label > Date  </label>  
                                            <input type="text"   autocomplete="off" class="form-control datepicker" name="date"   required=""   > 
                                        </div> 
                                        <div class="col-sm-3">
                                            <label>  Select Branch  </label>                               
                                            <select class="form-control  js-example-basic-single "  required="" name="branch" style="width:100%" >
                                                <?php $stmt = $conn->prepare("SELECT * FROM admbranch  ");
                                                $stmt->execute(); foreach ($stmt as $row) {?>
                                                        <option></option>
                                                        <option value="<?php echo $row['id']; ?>"><?php
                                                        echo $row['name']; ?></option> <?php } ?>
                                            </select>
                                        </div>    
                                        <div class="col-sm-3">
                                            <label>  Retails/Store Shops  </label>                               
                                            <select class="form-control  js-example-basic-single "  required="" name="store" style="width:100%" >
                                                <?php $stmt = $conn->prepare("SELECT * FROM admbstore  ");
                                                $stmt->execute(); foreach ($stmt as $row) {?>
                                                        <option></option>
                                                        <option value="<?php echo $row['id']; ?>"><?php
                                                        echo $row['name']; ?></option> <?php } ?>
                                            </select>
                                        </div>                                         
                                                                                                                                        
                                        <div class="col-md-4">
                                            <label > Tills  Name  </label>                          
                                            <input type="text" class="form-control" name="name" required="" autocomplete="off" >
                                        </div> 
                                        <div class="col-md-6">
                                            <label > Tills Description  </label>                          
                                            <input type="text" class="form-control" name="description" required="" autocomplete="off" >
                                        </div> 
                                      
                                       
                                        <div class="col-sm-6">   
                                            <label class=""> Location  </label>              
                                                <input type="text" class="form-control " name="location"  required="" autocomplete="off">
                                        </div>
                                     
                                     

                            <!-- submit button -->
                            <div class="form-group">                              
                                <div class="col-sm-offset-4 col-sm-10" style="padding:0.5rem;">
                                        <button type="submit"  name="submit" class="btn btn-success col-md-3">  <i class="fa fa-plus"></i>  Add Tills  </button> </div>
                            </div> 
                    </form>               
                </div>
            </div>
        </div>
                                
    </section>

</div>
  <!-- /.content-wrapper -->
  
  <!-- Main Footer -->
  <footer class="main-footer">
    <?php  include_once('inc/footer.php'); ?>
  </footer>
  
</div>
                         
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->
<?php include_once('inc/linkjs.php') ?>

</body>
</html>