<?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">



            <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="dealer" id="dealer" required class="form-control">
                                <?php 
                                $ref = "Dealers/";
                        $fetchdata = $database->getReference($ref)->getValue();
                                foreach($fetchdata as $key => $row){
                                    ?>
                                    <option value="<?=$key?>"><?=$row['name']?></option>
                                    
                                    <?php
                                }
                                ?>
                                <option></option>
                            </select>
                        </div>
                        <?php 
                        $ref1 = "Mattress/";
                        $fetchdata1 = $database->getReference($ref1)->getValue();
                        
                        
                        
                        
                        ?>
                        
                        <div class="form-group mb-3">
                            <select name="mattress_pricing" id="mattress_pricing" required class="form-control">
                                <?php 
                                $ref = "MattressPricing/";
                        $fetchdata = $database->getReference($ref)->getValue();
                                foreach($fetchdata as $key => $row){
                                    $ma = $row['mattress'];
                                    ?>
                                    
                                    <option value="<?=$key?>"><?=$fetchdata1[$ma]['name'].' '.$row['size'].' '.$row['thickness']?></option>
                                    
                                    <?php
                                }
                                ?>
                            </select>
                        </div>
                      
                        
                          <div class="form-group mb-3">
                            <input type="number" name="quantity" placeholder="Quantity" value="<?php if(isset($id)){echo($fetchdata['quantity']);}?>"  class="form-control" required>
                        </div>
                        
                       
                       
                        <div class="form-group mt-3">
                            <button type="submit" name="add_mrp_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 getval(e){
       
       if(e.value == "ORTHO ECO"){
           removeOptions(document.getElementById('type'));
           var option = document.createElement("option");
            option.text = "4";
            document.getElementById('type').add(option);
            
             var option1 = document.createElement("option");
            option1.text = "5";
            document.getElementById('type').add(option1);
       }else if(e.value == "ORTHO NURSE" || e.value == "ORTHO EXPERT" ){
           removeOptions(document.getElementById('type'));
           var option = document.createElement("option");
            option.text = "5";
            document.getElementById('type').add(option);
            
             var option1 = document.createElement("option");
            option1.text = "6";
            document.getElementById('type').add(option1);
       }
   }
   
   function removeOptions(selectElement) {
       var i, L = selectElement.options.length - 1;
       for(i = L; i >= 0; i--) {
          selectElement.remove(i);
       }
    }
   
   function onclickhandler(e) {
      var quantity = e.value;
      var product_code =  document.getElementById("product_code").value;
      var mattress_type =  document.getElementById("mattress_type").value;
      var type =  document.getElementById("type").value;
      if(product_code == "72*35" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "9225";
          document.getElementById("price").value = price;
      } else if(product_code == "72*35" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "11242";
          document.getElementById("price").value = price;
      } else if(product_code == "72*35" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "11550";
          document.getElementById("price").value = price;
      }else if(product_code == "72*35" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "13706";
          document.getElementById("price").value = price;
      }else if(product_code == "72*35" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "12320";
          document.getElementById("price").value = price;
      }else if(product_code == "72*35" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "14168";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "72*36" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "9225";
          document.getElementById("price").value = price;
      } else if(product_code == "72*36" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "11242";
          document.getElementById("price").value = price;
      } else if(product_code == "72*36" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "11550";
          document.getElementById("price").value = price;
      }else if(product_code == "72*36" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "13706";
          document.getElementById("price").value = price;
      }else if(product_code == "72*36" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "12320";
          document.getElementById("price").value = price;
      }else if(product_code == "72*36" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "14168";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "72*48" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "12651";
          document.getElementById("price").value = price;
      } else if(product_code == "72*48" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "15418";
          document.getElementById("price").value = price;
      } else if(product_code == "72*48" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "15840";
          document.getElementById("price").value = price;
      }else if(product_code == "72*48" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "18797";
          document.getElementById("price").value = price;
      }else if(product_code == "72*48" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "16896";
          document.getElementById("price").value = price;
      }else if(product_code == "72*48" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "19430";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "72*60" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "15814";
          document.getElementById("price").value = price;
      } else if(product_code == "72*60" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "19272";
          document.getElementById("price").value = price;
      } else if(product_code == "72*60" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "19800";
          document.getElementById("price").value = price;
      }else if(product_code == "72*60" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "23496";
          document.getElementById("price").value = price;
      }else if(product_code == "72*60" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "21120";
          document.getElementById("price").value = price;
      }else if(product_code == "72*60" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "24288";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "72*70" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "18450";
          document.getElementById("price").value = price;
      } else if(product_code == "72*70" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "22484";
          document.getElementById("price").value = price;
      } else if(product_code == "72*70" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "23100";
          document.getElementById("price").value = price;
      }else if(product_code == "72*70" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "27412";
          document.getElementById("price").value = price;
      }else if(product_code == "72*70" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "24640";
          document.getElementById("price").value = price;
      }else if(product_code == "72*70" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "28336";
          document.getElementById("price").value = price;
      }
      
       else if(product_code == "72*72" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "18450";
          document.getElementById("price").value = price;
      } else if(product_code == "72*72" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "22484";
          document.getElementById("price").value = price;
      } else if(product_code == "72*72" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "23100";
          document.getElementById("price").value = price;
      }else if(product_code == "72*72" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "27412";
          document.getElementById("price").value = price;
      }else if(product_code == "72*72" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "24640";
          document.getElementById("price").value = price;
      }else if(product_code == "72*72" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "28336";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "75*35" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "9609";
          document.getElementById("price").value = price;
      } else if(product_code == "75*35" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "11710";
          document.getElementById("price").value = price;
      } else if(product_code == "75*35" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "12031";
          document.getElementById("price").value = price;
      }else if(product_code == "75*35" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "14277";
          document.getElementById("price").value = price;
      }else if(product_code == "75*35" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "12833";
          document.getElementById("price").value = price;
      }else if(product_code == "75*35" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "14758";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "75*36" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "9609";
          document.getElementById("price").value = price;
      } else if(product_code == "75*36" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "11710";
          document.getElementById("price").value = price;
      } else if(product_code == "75*36" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "12031";
          document.getElementById("price").value = price;
      }else if(product_code == "75*36" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "14277";
          document.getElementById("price").value = price;
      }else if(product_code == "75*36" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "12833";
          document.getElementById("price").value = price;
      }else if(product_code == "75*36" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "14758";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "75*48" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "13719";
          document.getElementById("price").value = price;
      } else if(product_code == "75*48" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "16060";
          document.getElementById("price").value = price;
      } else if(product_code == "75*48" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "16500";
          document.getElementById("price").value = price;
      }else if(product_code == "75*48" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "19580";
          document.getElementById("price").value = price;
      }else if(product_code == "75*48" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "17600";
          document.getElementById("price").value = price;
      }else if(product_code == "75*48" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "20240";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "75*60" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "16473";
          document.getElementById("price").value = price;
      } else if(product_code == "75*60" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "20075";
          document.getElementById("price").value = price;
      } else if(product_code == "75*60" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "20625";
          document.getElementById("price").value = price;
      }else if(product_code == "75*60" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "24475";
          document.getElementById("price").value = price;
      }else if(product_code == "75*60" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "22000";
          document.getElementById("price").value = price;
      }else if(product_code == "75*60" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "25300";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "75*70" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "19219";
          document.getElementById("price").value = price;
      } else if(product_code == "75*70" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "23421";
          document.getElementById("price").value = price;
      } else if(product_code == "75*70" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "24063";
          document.getElementById("price").value = price;
      }else if(product_code == "75*70" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "28554";
          document.getElementById("price").value = price;
      }else if(product_code == "75*70" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "25667";
          document.getElementById("price").value = price;
      }else if(product_code == "75*70" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "29517";
          document.getElementById("price").value = price;
      }
      
       else if(product_code == "75*72" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "19219";
          document.getElementById("price").value = price;
      } else if(product_code == "75*72" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "23421";
          document.getElementById("price").value = price;
      } else if(product_code == "75*72" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "24063";
          document.getElementById("price").value = price;
      }else if(product_code == "75*72" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "28554";
          document.getElementById("price").value = price;
      }else if(product_code == "75*72" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "25667";
          document.getElementById("price").value = price;
      }else if(product_code == "75*72" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "29517";
          document.getElementById("price").value = price;
      }
      
       else if(product_code == "78*35" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "9994";
          document.getElementById("price").value = price;
      } else if(product_code == "78*35" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "12719";
          document.getElementById("price").value = price;
      } else if(product_code == "78*35" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "12513";
          document.getElementById("price").value = price;
      }else if(product_code == "78*35" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "14828";
          document.getElementById("price").value = price;
      }else if(product_code == "78*35" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "13347";
          document.getElementById("price").value = price;
      }else if(product_code == "78*35" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "15349";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "78*36" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "9994";
          document.getElementById("price").value = price;
      } else if(product_code == "78*36" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "12719";
          document.getElementById("price").value = price;
      } else if(product_code == "78*36" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "12513";
          document.getElementById("price").value = price;
      }else if(product_code == "78*36" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "14828";
          document.getElementById("price").value = price;
      }else if(product_code == "78*36" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "13347";
          document.getElementById("price").value = price;
      }else if(product_code == "78*36" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "15349";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "78*48" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "13706";
          document.getElementById("price").value = price;
      } else if(product_code == "78*48" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "16702";
          document.getElementById("price").value = price;
      } else if(product_code == "78*48" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "17160";
          document.getElementById("price").value = price;
      }else if(product_code == "78*48" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "20363";
          document.getElementById("price").value = price;
      }else if(product_code == "78*48" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "18304";
          document.getElementById("price").value = price;
      }else if(product_code == "78*48" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "21050";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "78*60" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "17132";
          document.getElementById("price").value = price;
      } else if(product_code == "78*60" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "20878";
          document.getElementById("price").value = price;
      } else if(product_code == "78*60" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "21450";
          document.getElementById("price").value = price;
      }else if(product_code == "78*60" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "25454";
          document.getElementById("price").value = price;
      }else if(product_code == "78*60" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "22880";
          document.getElementById("price").value = price;
      }else if(product_code == "78*60" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "26312";
          document.getElementById("price").value = price;
      }
      
      else if(product_code == "78*70" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "19988";
          document.getElementById("price").value = price;
      } else if(product_code == "78*70" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "24358";
          document.getElementById("price").value = price;
      } else if(product_code == "78*70" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "25025";
          document.getElementById("price").value = price;
      }else if(product_code == "78*70" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "29696";
          document.getElementById("price").value = price;
      }else if(product_code == "78*70" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "26693";
          document.getElementById("price").value = price;
      }else if(product_code == "78*70" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "30497";
          document.getElementById("price").value = price;
      }
      
       else if(product_code == "78*72" && mattress_type == "ORTHO ECO" && type == "4"){
          var price = quantity * "19988";
          document.getElementById("price").value = price;
      } else if(product_code == "78*72" && mattress_type == "ORTHO ECO" && type == "5"){
          var price = quantity * "24358";
          document.getElementById("price").value = price;
      } else if(product_code == "78*72" && mattress_type == "ORTHO NURSE" && type == "5"){
          var price = quantity * "25025";
          document.getElementById("price").value = price;
      }else if(product_code == "78*72" && mattress_type == "ORTHO NURSE" && type == "6"){
          var price = quantity * "29696";
          document.getElementById("price").value = price;
      }else if(product_code == "78*72" && mattress_type == "ORTHO EXPERT" && type == "5"){
          var price = quantity * "26693";
          document.getElementById("price").value = price;
      }else if(product_code == "78*72" && mattress_type == "ORTHO EXPERT" && type == "6"){
          var price = quantity * "30497";
          document.getElementById("price").value = price;
      }
    }
  
</script>
<?php
include('includes/footer.php');
?>