<link href="<?php echo base_url();?>adminassets/plugins/dataTables/css/jquery.dataTables.html" rel="stylesheet" type="text/css">
<link href="<?php echo base_url();?>adminassets/plugins/dataTables/css/dataTables.bootstrap.css" rel="stylesheet" type="text/css"> 	
<div class="vd_content-wrapper">
      <div class="vd_container">
        <div class="vd_content clearfix">
          <div class="vd_head-section clearfix">
            <div class="vd_panel-header">
              <ul class="breadcrumb">
                <li><a href="<?php echo base_url();?>admin">Home</a> </li>
                <li class="active">Design Packs</li>
              </ul>
            </div>
          </div>
          <!-- vd_head-section -->
          
          <div class="vd_title-section clearfix">
            <div class="vd_panel-header">
              <h1>Design Packs</h1>
              <small class="subtitle">Search for Designs and Create Packs</small>
            </div>
            <!-- vd_panel-header --> 
          </div>
          <!-- vd_title-section -->
          
          <div class="vd_content-section clearfix">
            
         <div class="row">
                	
                    
                    <!-- User Activity -->
                    <div class="col-md-5">
                        <div class="panel panel-success">
							
      <div class="panel-heading">Design Packs</div>
      <div class="panel-body">
      <form action="<?php echo base_url();?>admin/add_pack" method="post" enctype="multipart/form-data">
          <div class="form-group "> <label for="email">Design Pack Title</label>
            <input type="text" required class="form-control" name="title">
          </div>
          <div class="row"><div class="col-md-6">
          
          <div class="form-group">
            <label for="email"> Category</label>
          	<select class="form-control cat" name="cat">
            	<option value=""> Category</option>
                <?php foreach($cats as $cat){?>
                <option value="<?php echo $cat->cid;?>"><?php echo $cat->cat_name;?></option>
                <?php }?>
            </select>
          </div>
           <div class="form-group">
            <label for="email"> Subcategory</label>
          	<select class="subcat form-control" id="subcat" name="subcat">
                                <option value=""> Subcategory</option>
                            </select> 
         	 </div>
             <div class="form-group">
            <label for="email">Price</label>
          	 <input type="text" required class="form-control" name="price">
          	</div>
          	</div>
            
            <div class="col-md-6">
            <div class="form-group">
                                <label for="image">Upload Preview Image</label>
                                <input type="file" class="form-control" id="fileUpload" name="profile_img"  />
                                <div class="form-group" id="image-container">
                               <img class="img img-responsive" src="<?php echo base_url();?>assets/images/products/default.jpg" /> 
                                        </div>
                              
                               </div>
            </div>
            
          </div>
          <div class="form-group">
          <table class="table table-condensed">
          	<tr id="added"></tr>
          </table>
          </div>
          <div class="form-group"> <label for="email">Search for a Design and Add</label>
            <input type="text" class="form-control" name="design" id="search">
          </div>
          <div class="form-group" id="results">
          
          </div>
          <br/>
          <button type="submit" class="btn btn-success" name="submit">Add Design Pack</button>
        </form>
      </div>
    </div>
                    </div>
                    
                    <div class="col-md-7">
                     <div class="panel panel-success">
							
      <div class="panel-heading">Listing All Design Pack</div>
      <div class="panel-body">
                    
        <table class="table table-striped table-responsive table-bordered dataTable" id="data-tables">
        	<thead><tr><th>S.No.</th><th>Design Pack</th><th>Pack Includes</th><th>Action</th></tr></thead>
            <tbody>
            	<?php $i=1;foreach($packs as $pack){?>
                <tr><td><?php echo $i;?></td>
                <td width="100px"><img src="<?php echo base_url();?>assets/images/products/<?php echo $pack->pthumb;?>" class="img img-responsive">
				<?php echo $pack->ptitle;?><br/>
                <input type="checkbox" name="in_trend" <?php if($pack->ptrend!=""){echo "checked";}?> value="<?php echo $pack->packid;?>" class="in_trend" /> In Trend</td>
                <td><?php $p=explode(",",$pack->pimgs);
				foreach($p as $pp){
				$sc=$this->db->get_where("products",array("pid"=>$pp))->row();
	?><img width="80px" src="<?php echo base_url();?>assets/images/products/<?php echo $sc->img;?>" class="img img-responsive pull-left"><?php 
				}?></td>
                <td>
                 <?php if($pack->pack_status==""){$st="Disable";}else{$st="Enable";}?>
                <a href="<?php echo $pack->packid;?>" class="btn btn-xs btn-default enable"><?php echo $st;?></a>
<a href="<?php echo $pack->packid;?>" id="<?php echo $pack->packid;?>" class="btn btn-xs btn-warning"><i class="fa fa-edit"></i></a>
<a href="<?php echo $pack->packid;?>" id="<?php echo $pack->packid;?>" class="btn btn-xs btn-danger packdelete"><i class="fa fa-trash-o"></i></a></td>
                <?php $i++;}?>
            </tbody>
        </table>
        </div></div>
                    </div>
                    
                    
                    <!-- End Chat Room -->
                </div>
          </div>
          <!-- .vd_content-section --> 
          
        </div>
        <!-- .vd_content --> 
      </div>
      <!-- .vd_container --> 
    </div>
    <!-- .vd_content-wrapper --> 
    
    <!-- Middle Content End --> 
    
  </div>
  <!-- .container --> 
</div>
<!-- .content -->

<!-- Footer Start -->
  <footer class="footer-1"  id="footer">      
    <div class="vd_bottom ">
        <div class="container">
            <div class="row">
              <div class=" col-xs-12">
                <div class="copyright">
                  	Copyright &copy;2018 HadesIndia. All Rights Reserved 
                </div>
              </div>
            </div><!-- row -->
        </div><!-- container -->
    </div>
  </footer>
<!-- Footer END -->
  

</div>

<!-- .vd_body END  -->
<a id="back-top" href="#" data-action="backtop" class="vd_back-top visible"> <i class="fa  fa-angle-up"> </i> </a>

<!--
<a class="back-top" href="#" id="back-top"> <i class="icon-chevron-up icon-white"> </i> </a> -->

<!-- Javascript =============================================== --> 
<!-- Placed at the end of the document so the pages load faster --> 
<script>
		$(document).ready(function(){
			
			$(".enable").click(function(e){e.preventDefault();
			var st=$(this).text();
			var id=$(this).attr("href");
			if(st=="Enable"){
			$(this).text("Disable");
			}else{
			$(this).text("Enable");	
			}
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/packenable',
							 data: {id:id,st:st},
							 success: function(response){
								 //alert(response);
							 }
							 });
		});
			
			
			$(".in_trend").click(function(){
							var id=$(this).val();
							//alert(id);
							var v="";
							if ($(this).is(':checked')) {
								var v=$(this).val();
							}
							//alert(v);
							$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/pack_trend',
							 data: {v:v,id:id},
							 success: function(response){
								// alert(response);
							 }
							 });
						});
			$("#search").keyup(function(){
				var key=$(this).val();
				if(key!=""){
				$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>admin/pack_search',
				 data: {key:key},
				 success: function(res){
					$("#results").html(res);
					}
				 }); }else{
					 $("#results").html("");
				 }
			});
			
			$(".cat").change(function(){
				var cid=$(this).val();
				$.ajax({
				 type: "POST",
				 url: '<?php echo base_url();?>home/ajax_showsubcat',
				 data: {cid:cid},
				 success: function(res){
				//alert(res);
				$(".subcat").html(res);
				}
				 }); 
			});
			$("#fileUpload").on('change', function() {

  if (typeof(FileReader) == "undefined") {
    alert("Your browser doesn't support HTML5, Please upgrade your browser");
  } else {

    var container = $("#image-container");

    //remove all previous selected files
    container.empty();

    //create instance of FileReader
    var reader = new FileReader();
    reader.onload = function(e) {
      $("<img />", {
        "src": e.target.result,"style": 'width:200px;'
      }).appendTo(container);
    }
    
    reader.readAsDataURL($(this)[0].files[0]);
  }});
		
		$(".packdelete").click(function(e){e.preventDefault();
		if (!confirm("Sure you want to delete?")){
				  return false;
				}
			var id=$(this).attr("href");$(this).closest("tr").remove();
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/packdelete',
							 data: {id:id},
							 success: function(response){
								 //alert(response);
							 }
							 });
		});
		
		});
		
		
	</script>
<script type="text/javascript" src='<?php echo base_url();?>adminassets/plugins/jquery-ui/jquery-ui.custom.min.js'></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/js/caroufredsel.js"></script> 
<script type="text/javascript" src="<?php echo base_url();?>adminassets/js/plugins.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/breakpoints/breakpoints.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/dataTables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/prettyPhoto-plugin/js/jquery.prettyPhoto.js"></script> 

<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/tagsInput/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/bootstrap-switch/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/blockUI/jquery.blockUI.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/pnotify/js/jquery.pnotify.min.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/js/theme.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/custom/custom.js"></script>
 <script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/dataTables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/dataTables/dataTables.bootstrap.js"></script>


</body>
</html>