        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3>Product</h3>
                </div>
            </div>
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Add Product</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">

             <form class="form-horizontal form-label-left" action="<?php echo base_url() ?>Inventory/update_product/<?php echo $edit_id;?>" method="post">
                <p style="color:green;font-weight: bold;padding:10px;text-align: center"><?php echo $this->session->flashdata('msg');?></p>
 
 
            <div class="item form-group">
              <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Product Name <span class="required">*</span>
              </label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                <input id="name" class="form-control col-md-7 col-xs-12"  name="name"  value="<?php echo $products["name"]  ?>"  required="required" type="text">
              <input id="name" class="form-control col-md-7 col-xs-12"name="id" value="<?php echo $products["id"]  ?>"  type="hidden">
              </div>
            </div>
               <div class="item form-group">
              <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Price <span class="required">*</span>
              </label>
              <div class="col-md-6 col-sm-6 col-xs-12"> 
                <input id="name" class="form-control col-md-7 col-xs-12" name="price" value="<?php echo $products["price"]  ?>" type="number"   required="required" >

                  
              </div>
            </div>
          
             <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name"> Category <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select class="form-control select2_single" name="category_id"  required>  


                 <?php  
  $this->db->select('*');
  $this->db->from('categories');
  $this->db->where('is_delete',0);
        $query= $this->db->get();
       $cat=$query->result_array();

       ?>
                            <?php if(!empty($products)){ ?>
                            <option value="" > Select Options</option> 
                            <?php   foreach ($cat as $v){ ?> 
                            <option <?php if ($products['category_id']==$v['id']) echo "selected='selected'"; ?> value="<?php echo $v['id']?>"> <?php echo $v['category_name'];?></option>  
                                <?php } } ?>             
                          </select>

                        </div>
                      </div>
              

                <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Sub_Category <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select class="form-control select2_single" name="sub_cat_id"  required>  


                 <?php  
  $this->db->select('*');
  $this->db->from('sub_category');
  $this->db->where('is_delete',0);
        $query= $this->db->get();
       $sub=$query->result_array();
       ?>
                            <?php if(!empty($products)){ ?>
                            <option value="" > Select Options</option> 
                            <?php   foreach ($sub as $v){ ?> 
                            <option <?php if ($products['sub_cat_id']==$v['id']) echo "selected='selected'"; ?> value="<?php echo $v['id']?>"> <?php echo $v['name'];?></option>  
                                <?php } } ?>             
                          </select>

                        </div>
                      </div>

                   <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Brands <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select class="form-control select2_single" name="brand_id"  required>  


                 <?php  
  $this->db->select('*');
  $this->db->from('brands');
  $this->db->where('is_delete',0);
        $query= $this->db->get();
       $brands=$query->result_array();
      // var_dump($brands);
       //die();
       ?>
                            <?php if(!empty($products)){ ?>
                            <option value="" > Select Options</option> 
                            <?php   foreach ($brands as $v){ ?> 
                            <option <?php if ($products['brand_id']==$v['id']) echo "selected='selected'"; ?> value="<?php echo $v['id']?>"> <?php echo $v['name'];?></option>  
                                <?php } } ?>             
                          </select >

                        </div>
                      </div>

              

             
            <div class="item form-group">
              <label class="control-label col-md-3 col-sm-3 col-xs-12" for="address">Description<span class="required">*</span>
              </label>
              <div class="col-md-6 col-sm-6 col-xs-12">
                <textarea id="desc" class="form-control col-md-7 col-xs-12" name="description" required="required" placeholder="Description"> <?php echo $products["description"]  ?></textarea>
              </div>
            </div>
              
              
            
            <div class="ln_solid"></div>
            <div class="form-group">
              <div class="col-md-6 col-md-offset-6">
                <button id="send" type="submit" class="btn btn-custom">Update</button>
              </div>
            </div>
          </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

     

    <!-- jQuery -->
     <link href="<?php echo base_url(); ?>assets/vendors/select2/dist/css/select2.min.css" rel="stylesheet">
    <!-- jQuery -->
    <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/select2/dist/js/select2.full.min.js"></script>
    <!-- Datatables -->
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-scroller/js/datatables.scroller.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/jszip/dist/jszip.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/vfs_fonts.js"></script>

  </body>
</html>

<script>
     $(".select2_single").select2({
            placeholder: "Select Option",
            allowClear: true
         });
</script>

<script>
$(function(){
    $('#catogires').change(function() {
      
   var c=$('#catogires').val();
   //console.log(c);
   $.ajax({
          url: "<?php echo base_url();?>Inventory/get_sub_cat/"+c, 
        success: function(result){
          //console.log(result);
              $("#subcat").html(result);
          }});

    })
});

  </script> 


<script>
$(function(){
    $('#subcat').change(function() {
      
   var c=$('#subcat').val();
   console.log(c);
   $.ajax({
          url: "<?php echo base_url();?>Inventory/get_brand/"+c, 
        success: function(result){
          console.log(result);
              $("#brand").html(result);
          }});

    })
});

  </script>