<?php 
include('authentication.php');
include('includes/header.php');
include('includes/topbar.php');
include('includes/sidebar.php');
?>

<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0"> Mattress</h1>
                </div><!-- /.col -->
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="#">Home</a></li>
                        <li class="breadcrumb-item active">Mattress</li>
                    </ol>
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <?php 
            if(isset($_GET['id'])){
                $id = $_GET['id'];
            }
            ?>


            <div class="card">
                <div class="card-header">
                    <h4>
                         Mattress
                        <a href="mattress.php" class="btn btn-danger float-sm-right">BACK</a>
                    </h4>
                </div>
                <div class="card-body">
                    <form action="code.php" method="POST" id="catform" enctype="multipart/form-data">
                        
                        
                        <div class="form-group mb-3">
                            <select name="mattress" id="mattress" required class="form-control">
                                <?php 
                                $ref = "Mattress/";
                        $fetchdata = $database->getReference($ref)->getValue();
                                foreach($fetchdata as $key => $row){
                                    ?>
                                    <option value="<?=$key?>"><?=$row['name']?></option>
                                    
                                    <?php
                                }
                                ?>
                                <option></option>
                            </select>
                        </div>
                        <div class="form-group mb-3">
                             <select name="thickness" id="thickness" required class="form-control">
                                 <option>100</option>
                                 <option>125</option>
                                 <option>150</option>
                                 <option>175</option>
                                 <option>200</option>
                                 </select>
                        </div>
                        
                        <div class="form-group mb-3">
                             <select name="size" id="size" required class="form-control">
                                 <option>72*35</option>
                                 <option>72*36</option>
                                 <option>72*48</option>
                                 <option>72*60</option>
                                 <option>72*70</option>
                                 <option>72*72</option>
                                 
                                  <option>75*35</option>
                                 <option>75*36</option>
                                 <option>75*48</option>
                                 <option>75*60</option>
                                 <option>75*70</option>
                                 <option>75*72</option>
                                 
                                  <option>78*35</option>
                                 <option>78*36</option>
                                 <option>78*48</option>
                                 <option>78*60</option>
                                 <option>78*70</option>
                                 <option>78*72</option>
                                 </select>
                        </div>
                        
                        
                       
                        
                          <div class="form-group mb-3">
                            <input type="number" name="warrenty" placeholder="Warrenty" value="<?php if(isset($id)){echo($fetchdata['warrenty']);}?>"  class="form-control" required>
                        </div>
                        
                         <div class="form-group mb-3">
                            <input type="number" name="price" id="price" placeholder="Price" value="<?php if(isset($id)){echo($fetchdata['price']);}?>"  class="form-control" required>
                        </div>
                       
                        <div class="form-group mt-3">
                            <button type="submit" name="<?php if(isset($id)){echo('update_mattress_pricing_btn');}else{echo('add_mattress_pricing_btn');}?>"
                                value="<?php if(isset($id)){echo($id);}?>" class="btn btn-primary float-sm-right">Submit</button>
                        </div>
                    </form>
                </div>

            </div>
        </div>


    </section>
</div><!-- /.container-fluid -->

<?php
include('includes/script.php');
?>
<script>
   
   
   
   
   function removeOptions(selectElement) {
       var i, L = selectElement.options.length - 1;
       for(i = L; i >= 0; i--) {
          selectElement.remove(i);
       }
    }
   
   
  
</script>
<?php
include('includes/footer.php');
?>