<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Add New Product</h1>
          </div>
          <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">Add New Product</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
 <?php
              $success = $this->session->flashdata('success');
               if(isset($success)){  ?>
            <div class="alert alert-success">
              <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <?php echo $this->session->flashdata('success');?>
          </div>
          <?php } ?>

          <?php
              $same = $this->session->flashdata('same');
               if(isset($same)){  ?>
            <div class="alert alert-warning">
              <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <?php echo $this->session->flashdata('same');?>
          </div>
          <?php } ?>
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <!-- /.col -->
          <div class="col-md-9">
            <div class="card card-primary card-outline">
              <div class="card-header">
                <h3 class="card-title">Add Your Product Data in This Form !</h3>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
                
                   <form action="<?php if(!isset($data)){ echo base_url('admin/Add_product/insert'); }else{ echo base_url('admin/Add_product/update');}?>" method="POST" enctype="multipart/form-data">
                    <div class="form-example-wrap">
                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Product Category </label>
                                <div class="nk-int-st">
                                    <select name="cat_slug" id="" class="form-control">
                                      <option value="">Select Product Category</option>
                                      <?php 
                                            $qu = $this->db->get('category');
                                            $n = $qu->result();
                                            if($qu->num_rows() > 0){
                                              foreach ($n as $cat) {
                                                
                                          ?>
                                       <option value="<?php echo $cat->slug; ?>" <?php if(isset($data)){if($cat->slug == $data[0]->cat_slug){echo "selected"; }  } ?> ><?php echo $cat->category_name; ?></option>
                                     <?php } }else{ ?>
                                      <option value="">NO CATEGORY IN YOUR WEBSITE</option>
                                    <?php } ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Product Name <small>(Your Product Name Convert into your Product URL/SLUG)</small></label>
                                <div class="nk-int-st">
                                    <input type="text" value="<?php if(isset($data)){echo $data[0]->name;}else{ echo "";} ?>" name="name" required="" class="form-control input-sm" placeholder="Enter Name">
                                </div>
                            </div>
                        </div>
                           <div class="form-example-int">
                            <div class="form-group">
                                <label>Product Slug </label>
                                <div class="nk-int-st">
                                    <input type="text" value="<?php if(isset($data)){echo $data[0]->slug;}else{ echo "";} ?>" name="slug" required="" class="form-control input-sm" placeholder="Enter Product slug">
                                </div>
                            </div>
                        </div>
                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Short description</label>
                                <div class="nk-int-st ">
                                    <textarea name="short_description" class="form-control input-sm ckeditor" id="compose-textarea" placeholder="Short description" rows="12"><?php if(isset($data)){echo $data[0]->short_description;}else{ echo "";} ?></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Product Image </label>
                                <div class="nk-int-st">
                                    <input type="file" multiple  name="img[]" <?php if(!isset($data)){ echo "required ";} ?>
                                           class="form-control input-sm">
                                    <?php 
                                        if(isset($data)){
                                     ?>
                                     <img src="<?php echo base_url('uploads/thumbs/').$data[0]->img; ?>" alt="">
                                 <?php } ?>
                                </div>
                            </div>
                        </div>
                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Product Price</label>
                                <div class="nk-int-st">
                                    <input type="text" name="price" value="<?php if(isset($data)){echo $data[0]->price;}else{ echo "";} ?>" required="" class="form-control input-sm" placeholder="Product Price">
                                    <input type="hidden" name="id" value="<?php if(isset($data)){echo $data[0]->id;}else{ echo "";} ?>">
                                </div>
                            </div>
                        </div>
                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Product Sale Price</label>
                                <div class="nk-int-st">
                                    <input type="text" name="sail_price" value="<?php if(isset($data)){echo
                                    $data[0]->sail_price;}else{ echo "";} ?>" required="" class="form-control
                                    input-sm" placeholder="Sale Price">
                                 
                                </div>
                            </div>
                        </div>
						  <div class="form-example-int">
                            <div class="form-group">
                                <label>Product size</label>
                                <div class="nk-int-st">
                                    <input type="text" name="size" value="<?php if(isset($data)){echo $data[0]->size;}else{ echo "";} ?>" required="" class="form-control input-sm" placeholder="Product size">
                                
                                </div>
                            </div>
                        </div>
						  <div class="form-example-int">
                            <div class="form-group">
                                <label>imported from</label>
                                <div class="nk-int-st">
                                    <input type="text" name="imported_from" value="<?php if(isset($data)){echo $data[0]->imported_from;}else{ echo "";} ?>" required="" class="form-control input-sm" placeholder="imported from">
                                
                                </div>
                            </div>
                        </div>
                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Product Meta Title</label>
                                <div class="nk-int-st">
                                    <input type="text" name="m_title" value="<?php if(isset($data)){echo $data[0]->m_title;}else{ echo "";} ?>" required="" class="form-control input-sm" placeholder="Meta Title">
                                
                                </div>
                            </div>
                        </div>
                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Product Meta description</label>
                                <div class="nk-int-st">
                                    <input type="text" name="m_des" value="<?php if(isset($data)){echo $data[0]->m_des;}else{ echo "";} ?>" required="" class="form-control input-sm" placeholder="Meta Description">
                                  
                                </div>
                            </div>
                        </div>
                       <div class="form-example-int">
                            <div class="form-group">
                                <label>Tags</label>
                                <div class="nk-int-st"><input type="text" value="<?php if(isset($data)){echo $data[0]->tags;}else{ echo "";} ?>" name="tags[]" data-role="tagsinput">
                                </div>
                            </div>
                        </div>
                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Delivery Charges</label>
                                <div class="nk-int-st"><input type="text" class="form-control" required value="<?php if
                                    (isset($data))
                                {echo
                                    $data[0]->dliveryfee;}else{ echo "";} ?>" name="dliveryfee">
                                </div>
                            </div>
                        </div>

                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Stock Status</label>
                                <div class="nk-int-st">
                                    <select name="stock" class="form-control" id="">
                                        <option
                                        <?php
                                        if(isset($data))
                                        {
                                            if($data[0]->stock == 'yes')
                                        { 
                                            echo "selected";
                                        
                                        } } ?>
                                                value="yes">Yes</option>
                                        <option <?php if(isset($data)){ if($data[0]->stock == 'no'){ echo "selected"; } } ?>
                                                value="no">No</option>
                                    </select>
                                    <!-- /# -->
                                </div>
                            </div>
                        </div>

                        <div class="form-example-int">
                            <div class="form-group">
                                <label>Product Description</label>
                                <div class="nk-int-st ">
                                    <textarea name="des" class="form-control input-sm ckeditor" id="editor" placeholder="Full Description" rows="12"><?php if(isset($data)){echo $data[0]->des;}else{ echo "";} ?></textarea>
                                </div>
                            </div>
                        </div>
                        
                        
                        <div class="form-example-int mg-t-15">
                            <button class="btn btn-success notika-btn-success" type="submit"><?php if(isset($data)){ ?> UPDATE PRODUCT <?php }else{ ?>ADD PRODUCT <?php } ?></button>
                        </div>
                    </div>
                    </form>
                
              </div>
              <!-- /.card-body -->
              <!-- /.card-footer -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>