 <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 text-dark">Gallery</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item"><a href="#">Front Setting</a></li>
              <li class="breadcrumb-item active">Gallery</li>

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
         <div class="row">
            <div class="col-sm-6">
               <div class="row">
                  <div class="col-sm-12">
                     <div class="card card-default">
                       <div class="card-header">
                         <h3 class="card-title">Add Gallery Category</h3>
                       </div>
                       <!-- /.card-header -->
                        <?php echo form_open(base_url().'admin/front_setting/add_gallery_category');?>
                       <div class="card-body">
                         <div class="row">

                           <div class="col-md-12">
                              <div class="item form-group">
                                 <label class="col-md-12 col-sm-12 col-xs-12">Category Name<span>*</span></label>
                                 <div class="col-md-12 col-sm-12 col-xs-12">
                                    <input type="text" class="form-control"  name="gc_name" placeholder="Enter Gallery Category Name" required>
                                 </div>
                              </div>
                           </div>
                            
                           <div class="col-md-12">
                             <div class="form-group">
                                <button name="form1" style="float: right" type="submit" class="btn btn-success">Add</button>
                             </div>
                           </div>
                           <?php echo form_close() ?>
                         </div>
                       </div>
                     </div>
                  </div>
                  <div class="col-sm-12">
                     <div class="card card-default">
                        <div class="card-header">
                           <h3 class="card-title">Viwe All Gallery Category</h3>
                        </div>
                       <!-- /.card-header -->
                        <div class="card-body">
                           <table id="example1" class="table table-bordered table-striped">
                               <thead>
                               <tr>
                                 <th>ID</th>
                                 <th>Name</th>
                                 <th></th>
                               </tr>
                               </thead>
                               <tbody>
                               <?php $i=1; foreach ($all_category as $category):?>
                                  <tr>
                                    <td><?php echo $i ?></td>
                                    <td><?php echo $category->gc_name ?></td>
                                    <td>
                                      <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                          <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                          Action
                                          </button>
                                          <div class="dropdown-menu">
                                            <a data-toggle="modal" data-target="#category_modal<?php echo $category->gc_id ?>" class="dropdown-item" href="#"><i class="fas fa-edit"></i>&nbsp;&nbsp;Edit</a>
                                            <div class="dropdown-divider"></div>
                                            <a class="dropdown-item" onclick="return confirm('Are you sure?')" href="<?php echo base_url(); ?>/admin/front_setting/delete_gallery_category/<?php echo $category->gc_id ?>"><i class="fas fa-trash"></i>&nbsp;&nbsp;Delete</a>
                                          </div>
                                        </div>
                                      </div>
                                    </td>
                                 </tr>
                                 <div class="modal fade" id="category_modal<?php echo $category->gc_id ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                       <div class="modal-content">
                                          <div class="modal-header">
                                             <h5 class="modal-title" id="exampleModalLabel">Update Category</h5>
                                             <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">&times;</span>
                                             </button>
                                          </div>
                                          <?php echo form_open(base_url().'admin/front_setting/update_gallery_category/'.$category->gc_id);?>
                                             <div class="modal-body">
                                                <div class="form-group">
                                                   <label for="recipient-name" class="col-form-label">Category Name <span class="text-danger">*</span></label>
                                                   <input type="text" class="form-control" placeholder="Enter Category Name" required value="<?php echo $category->gc_name; ?>" name="gc_name">
                                                </div>
                                             </div>
                                             <div class="modal-footer">
                                               <button type="submit" class="btn btn-primary">Update</button>
                                             </div>
                                          <?php echo form_close();?>
                                       </div>
                                    </div>
                                 </div>
                               <?php $i++; ?>
                               <?php endforeach; ?>
                               </tbody>
                           </table>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
            <div class="col-sm-6">
               <div class="row">
                  <div class="col-sm-12">
                     <div class="card card-default">
                        <div class="card-header">
                           <h3 class="card-title">Add Gallery</h3>
                        </div>
                          <!-- /.card-header -->
                           <?php echo form_open_multipart(base_url().'admin/front_setting/add_gallery_image');?>
                          <div class="card-body">
                            <div class="row">

                              <div class="col-md-8">
                                 <div class="item form-group">
                                    <label class="col-md-12 col-sm-12 col-xs-12">Select Category<span>*</span></label>
                                    <div class="col-md-12 col-sm-12 col-xs-12">
                                       <select type="text" class="form-control"  name="gallery_category" placeholder="Enter Gallery Category Name" required>
                                          <option value="">Select A Category</option>
                                          <?php foreach ($all_category as $category):?>
                                             <option value="<?php echo $category->gc_id; ?>"><?php echo $category->gc_name; ?></option>
                                          <?php endforeach; ?>
                                       </select>
                                    </div>
                                 </div>
                              </div>
                              <div class="col-md-4">
                                 <div class="item form-group">
                                    <label class="col-md-12 col-sm-12 col-xs-12">Select Mode<span>*</span></label>
                                    <div class="col-md-12 col-sm-12 col-xs-12">
                                       <select onchange="mode(this.value)" type="text" class="form-control"  name="gallery_video_or_image" placeholder="Enter Gallery Category Name" required>
                                          <option value="">Select</option>
                                          <option value="1">Image</option>
                                          <option value="2">Video</option>
                                       </select>
                                    </div>
                                 </div>
                              </div>
                              <div class="col-md-12" id="image_div">
                                 <div class="item form-group">
                                    <label class="col-md-12 col-sm-12 col-xs-12">Upload Image<span>*</span></label>
                                    <div class="col-md-12 col-sm-12 col-xs-12">
                                       <input type="file" class="form-control"  name="gallery_image" placeholder="Enter Gallery Category Name" id="image_filed">
                                    </div>
                                 </div>
                              </div>
                              <div class="col-md-12" id="video_div">
                                 <div class="item form-group">
                                    <label class="col-md-12 col-sm-12 col-xs-12">Youtube Video URL<span>*</span></label>
                                    <div class="col-md-12 col-sm-12 col-xs-12">
                                       <textarea  class="form-control"  name="gallery_video_iframe" placeholder="Enter Video URL" id="video_filed"></textarea>
                                    </div>
                                 </div>
                              </div>
                              <div class="col-md-12">
                                <div class="form-group">
                                   <button name="form1" style="float: right" type="submit" class="btn btn-success">Add</button>
                                </div>
                              </div>
                              <?php echo form_close() ?>
                           </div>
                       </div>
                     </div>   
                  </div>
                  <div class="col-sm-12">
                     <div class="card card-default">
                        <div class="card-header">
                           <h3 class="card-title">Viwe All Gallery</h3>
                        </div>
                       <!-- /.card-header -->
                        <div class="card-body">
                           <table id="example2" class="table table-bordered table-striped">
                               <thead>
                               <tr>
                                 <th>ID</th>
                                 <th>Video / Image</th>
                                 <th>Mode</th>
                                 <th>Category</th>
                                 <th></th>
                               </tr>
                               </thead>
                               <tbody>
                               <?php $i=1; foreach ($all_gallery as $gallery):?>
                                  <tr>
                                    <td><?php echo $i ?></td>
                                    <td>
                                       <?php if($gallery->gallery_video_or_image == 1): ?>
                                          <img src="<?php echo base_url(); ?><?php echo $gallery->gallery_image; ?>" width="70px">
                                       <?php else: ?>
                                       <?php endif; ?>
                                    </td>
                                    <td>
                                       <?php if($gallery->gallery_video_or_image == 1): ?>
                                          Image
                                       <?php else: ?>
                                          Video
                                       <?php endif; ?>
                                    </td>
                                    <td>
                                       <?php echo $gallery->gc_name; ?>
                                    </td>
                                    <td>
                                      <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                          <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                          Action
                                          </button>
                                          <div class="dropdown-menu">
                                            <a href="<?php echo base_url(); ?>admin/front_setting/edit_gallery/<?php echo $gallery->gallery_id ?>" class="dropdown-item" href="#"><i class="fas fa-edit"></i>&nbsp;&nbsp;Edit</a>
                                            <div class="dropdown-divider"></div>
                                            <a class="dropdown-item" onclick="return confirm('Are you sure?')" href="<?php echo base_url(); ?>/admin/front_setting/delete_gallery/<?php echo $gallery->gallery_id ?>"><i class="fas fa-trash"></i>&nbsp;&nbsp;Delete</a>
                                          </div>
                                        </div>
                                      </div>
                                    </td>
                                 </tr>
                               <?php $i++; ?>
                               <?php endforeach; ?>
                               </tbody>
                           </table>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
    </section>
  </div>
<style type="text/css">
#image_div, #video_div
{
   display: none;
}
</style>
<script type="text/javascript">
function mode(e) 
{
   if(e == 1)
   {
      $('#image_div').show();
      $('#image_filed').attr('required', true);
      $('#video_div').hide();
      $('#video_filed').attr('required', false);

   }
   else if(e == 2)
   {
      $('#image_div').hide();
      $('#image_filed').attr('required', false);
      $('#video_div').show();
      $('#video_filed').attr('required', true);
   }
   else
   {
      $('#image_div').hide();
      $('#video_div').hide();
   }
}
</script>