<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">SubCategories</li>
              </ul>
              
 
            </div>
          </div>
          <!-- vd_head-section -->
          
          <div class="vd_title-section clearfix">
            <div class="vd_panel-header">
              <h1>Manage SubCategories</h1>
              <small class="subtitle">Add, Edit Delete SubCategories</small>
              
<!-- vd_panel-menu --> 
            </div>
            <!-- vd_panel-header --> 
          </div>
          <!-- vd_title-section -->
          
          <div class="vd_content-section clearfix">
            
         <div class="row">
                	
                   <div class="col-md-12">
                    <?php if($this->uri->segment(3)){$formats=explode(",",$pro->formats);?>
           
           <form action="<?php echo base_url();?>admin/add_product_submit" method="post" enctype="multipart/form-data">
           <input type="hidden" name="proid" value="<?php echo $this->uri->segment(3);?>" />
                    <div class="col-md-10 col-md-offset-1" style="background:#FFF; padding:5px;">
                    <?php if($this->session->flashdata("msg")!==""){echo $this->session->flashdata("msg"); }?>
                    <ul class="nav nav-tabs">
                      <li class="active"><a href="#tab21" data-toggle="tab"><strong>Product Info</strong></a></li>
                      <li><a href="#tab22" data-toggle="tab"><strong>Seo Details</strong></a></li>
                      <li class="pull-right">
                      <button class="btn btn-success" type="submit">Add Design</button></li>
                      
                    </ul>
                    <div class="tab-content  mgbt-xs-20">
                      <div class="tab-pane active col-md-10" id="tab21"><br/>
                      	<div class="row">
                          <div class="form-group col-md-8">
                            <label for="email">Select Category</label>
                            <select class="cat form-control" name="cat" id="cat">
                                                <option value="">Select Category</option>
                                                <?php foreach($cats as $cat){?>
                        <option <?php if($pro->cid==$cat->cid){echo 'selected';}?> value="<?php echo $cat->cid;?>"><?php echo $cat->cat_name;?></option>
                                                <?php }?>
                                            </select>
                            <label for="pwd">Select Subcategory</label>
                            <select class="subcat form-control" id="subcat" name="subcat">
                                                 <?php $subc=$this->db->get_where("subcategory",array("cid"=>$pro->cid))->result();
												 		foreach($subc as $sub){?>
                        <option value="<?php echo $sub->sid;?>" <?php if($pro->sid==$sub->sid){echo 'selected';}?>><?php echo $sub->subcat_name;?></option><?php }?>
                                            </select>
                              <label for="pwd">Title</label>
                              <input type="text" name="title" value="<?php echo $pro->title;?>"  class="form-control" required>
                              <label for="pwd">Color Codes</label><br/>
                              <input type="file" name="colorcode" style="width:60%;" class="form-control pull-left" required>
                              <input type="hidden" name="oldcolorcode" value="<?php echo $pro->colorcode;?>" />                              &nbsp;&nbsp;&nbsp;&nbsp;Featured: <input class="mgr-10"  name="feat" type="checkbox" data-rel="switch" data-size="small" data-wrapper-class="green" <?php if($pro->feat=="yes"){echo 'checked';}?>>      <br/><br/>
                           
                          <div class="vd_checkbox checkbox-danger">
    <input type="checkbox" value=".DST"  <?php if(in_array(".DST",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-1" checked="checked">
    <label for="checkbox-1"> .DST </label>
    <input type="checkbox" value=".EXP"  <?php if(in_array(".EXP",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-2" checked="checked">
    <label for="checkbox-2"> .EXP  </label>
    <input type="checkbox" value=".HUS"  <?php if(in_array(".HUS",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-3" checked="checked">
    <label for="checkbox-3"> .HUS  </label>
    <input type="checkbox" value=".JEF"  <?php if(in_array(".JEF",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-4" checked="checked">
    <label for="checkbox-4"> .JEF  </label>
    <input type="checkbox" value=".PCS"  <?php if(in_array(".PCS",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-5" checked="checked">
    <label for="checkbox-5"> .PCS  </label>
    <input type="checkbox" value=".PES"  <?php if(in_array(".PES",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-6" checked="checked">
    <label for="checkbox-6"> .PES  </label>
    <input type="checkbox" value=".SEW"  <?php if(in_array(".SEW",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-7" checked="checked">
    <label for="checkbox-7"> .SEW  </label>
    <input type="checkbox" value=".VIP"  <?php if(in_array(".VIP",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-8" checked="checked">
    <label for="checkbox-8"> .VIP   </label>
    <input type="checkbox" value=".VP3"  <?php if(in_array(".VP3",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-9" checked="checked">
    <label for="checkbox-9"> .VP3   </label>
    <input type="checkbox" value=".XXX"  <?php if(in_array(".XXX",$formats)){echo 'checked';}?> name="formats[]" id="checkbox-0" checked="checked">
    <label for="checkbox-0"> .XXX   </label>
                          </div>
                        
                          </div>
                          <div class="form-group col-md-4">
                            <div class="form-group">
                                <label for="image">Upload Preview Image</label>
                                <input type="file" class="form-control" id="fileUpload" name="profile_img"  />
                                <input type="hidden" name="oldimg" value="<?php echo $pro->img;?>" />
                                <div class="form-group" id="image-container">
                               <img class="img img-responsive" src="<?php echo base_url();?>assets/images/products/<?php echo $pro->img;?>" /> 
                                        </div>
                              
                               </div>
                               <label for="image">Product Tags</label>
                               <input id="input-autocomplete"  type="text" class="tags" value="<?php echo $pro->tags;?>" name="tags" placeholder="Add tags and hit Enter" /> 
                          </div>
                         </div>
                        
                        <div class="row">
                   
                        <h4 class="text-center">Existing Variants</h4>
                         <table class="table table-condensed">
                         <tr><th>S.No.</th><th>Size</th><th>Stitches</th><th>Price</th><th>Action</th></tr>
						<?php $i=1;foreach($vars as $v){?>
                        <tr><td><?php echo $i;?></td><td><?php echo $v->width;?> mm <i class="fa fa-times"></i> <?php echo $v->height;?> mm</td>
                        	<td><?php echo $v->stitch;?></td><td><?php echo $v->price;?></td>
                <td>
                <a href="<?php echo $v->zid;?>" class="btn btn-xs btn-warning" data-toggle="modal" data-target="#myModal"><i class="fa fa-edit"></i></a>
                <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>This is a small modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
                <a href="<?php echo $v->zid;?>" class="btn btn-xs btn-danger"><i class="fa fa-trash-o"></i></a></tr>
                        <?php $i++;}?></table>
                        
                        <h4 class="text-center">Add New Variants</h4>
                        <div id="field">
                        
                        
                        <div id="field0">
        <!-- Text input-->
        <div class="form-group col-md-3">
        	<label for="pwd">Size in MM</label><br/>
            <input type="number" class="form-control pull-left" style="width:50%;" name="width[]" />
            <input type="number" class="form-control" style="width:50%;" name="height[]" />
        </div>
        <div class="form-group col-md-2">
        	<label for="pwd">Stitch Count</label>
            <input type="number" class="form-control pull-left" name="stitch[]" />
        </div>
        <div class="form-group col-md-2">
        	<label for="pwd">Price</label>
            <input type="number" class="form-control pull-left" name="price[]" />
        </div>
        <div class="form-group col-md-4">
          <label for="pwd">Zip</label>
          <input type="file" name="test1[]" class="form-control" />
        </div>
      
        </div>
        <!-- Button -->
        <br/>
          
            <button id="add-more" name="add-more" class="btn btn-primary"><i class="fa fa-plus"></i></button>
         
        <br><br>
                      
                    </div>
                </div>
                          
                      </div>
                      <div class="tab-pane col-md-10" id="tab22"><br/>
                            <div class="form-group">
                                <label class="control-label">Meta Title</label>
                                <input type="text" required name="meta_title" value="<?php echo $pro->meta_title;?>" class="form-control">
                            </div>   
                            <div class="form-group">
                                <label class="control-label">Meta Keywords</label>
                                <textarea class="form-control" rows="2" value="<?php echo $pro->meta_key;?>" name="meta_key"></textarea>
                            </div>
                            <div class="form-group">
                                <label class="control-label">Meta Description</label>
                                <textarea class="form-control" rows="5" value="<?php echo $pro->meta_desc;?>" name="meta_desc"></textarea>
                            </div>
                            <div class="form-group">
                                <label class="control-label">Og:Title</label>
                                <input type="text" name="og_title" value="<?php echo $pro->og_title;?>" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">Og:Description</label>
                                <textarea class="form-control" rows="4" value="<?php echo $pro->og_desc;?>" name="og_desc"></textarea>
                            </div>
                      </div>
                      <div class="tab-pane" id="tab23"> Tab 3 </div>
                    </div>
                    </div></form>
           <?php }else{?>
          <form action="<?php echo base_url();?>admin/add_product_submit" method="post" enctype="multipart/form-data">
                    <div class="col-md-10 col-md-offset-1" style="background:#FFF; padding:5px;">
                    <?php if($this->session->flashdata("msg")!==""){echo $this->session->flashdata("msg"); }?>
                    <ul class="nav nav-tabs">
                      <li class="active"><a href="#tab21" data-toggle="tab"><strong>Product Info</strong></a></li>
                      <li><a href="#tab22" data-toggle="tab"><strong>Seo Details</strong></a></li>
                      <li class="pull-right">
                      <button class="btn btn-success" type="submit">Add Design</button></li>
                      
                    </ul>
                    <div class="tab-content  mgbt-xs-20">
                      <div class="tab-pane active col-md-10" id="tab21"><br/>
                      	<div class="row">
                          <div class="form-group col-md-8">
                            <label for="email">Select Category</label>
                            <select class="cat form-control" name="cat" id="cat" required>
                                <option value="">Select Category</option>
                                <?php foreach($cats as $cat){?>
                                <option value="<?php echo $cat->cid;?>"><?php echo $cat->cat_name;?></option>
                                <?php }?>
                            </select>
                            <label for="pwd">Select Subcategory</label>
                            <select class="subcat form-control" id="subcat" name="subcat" required>
                                <option value="">Select Subcategory</option>
                            </select> 
                              <label for="pwd">Title</label>
                              <input type="text" name="title" class="form-control" required>
                              <label for="pwd">Color Codes</label><br/>
                              <input type="file" name="colorcode" style="width:60%;" class="form-control pull-left" required>                              &nbsp;&nbsp;&nbsp;&nbsp;Featured: <input class="mgr-10"  name="feat" type="checkbox" data-rel="switch" data-size="small" data-wrapper-class="green">      <br/><br/>
                           
                          <div class="vd_checkbox checkbox-danger">
                            <input type="checkbox" value=".DST" name="formats[]" id="checkbox-1" checked="checked">
                            <label for="checkbox-1"> .DST </label>
                            <input type="checkbox" value=".EXP" name="formats[]" id="checkbox-2" checked="checked">
                            <label for="checkbox-2"> .EXP  </label>
                            <input type="checkbox" value=".HUS" name="formats[]" id="checkbox-3" checked="checked">
                            <label for="checkbox-3"> .HUS  </label>
                            <input type="checkbox" value=".JEF" name="formats[]" id="checkbox-4" checked="checked">
                            <label for="checkbox-4"> .JEF  </label>
                            <input type="checkbox" value=".PCS" name="formats[]" id="checkbox-5" checked="checked">
                            <label for="checkbox-5"> .PCS  </label>
                            <input type="checkbox" value=".PES" name="formats[]" id="checkbox-6" checked="checked">
                            <label for="checkbox-6"> .PES  </label>
                            <input type="checkbox" value=".SEW" name="formats[]" id="checkbox-7" checked="checked">
                            <label for="checkbox-7"> .SEW  </label>
                            <input type="checkbox" value=".VIP" name="formats[]" id="checkbox-8" checked="checked">
                            <label for="checkbox-8"> .VIP   </label>
                            <input type="checkbox" value=".VP3" name="formats[]" id="checkbox-9" checked="checked">
                            <label for="checkbox-9"> .VP3   </label>
                            <input type="checkbox" value=".XXX" name="formats[]" id="checkbox-0" checked="checked">
                            <label for="checkbox-0"> .XXX   </label>
                          </div>
                        
                          </div>
                          <div class="form-group col-md-4">
                            <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>
                               <label for="image">Product Tags</label>
                               <input id="input-autocomplete"  type="text" class="tags" name="tags" placeholder="Add tags and hit Enter" /> 
                          </div>
                         </div>
                        
                        <div class="row">
                   
                        <h4 class="text-center">Add Variants</h4>
                        <div id="field">
                        <div id="field0">
        <!-- Text input-->
        <div class="form-group col-md-3">
        	<label for="pwd">Size in MM</label><br/>
            <input type="number" class="form-control pull-left" style="width:50%;" name="width[]" />
            <input type="number" class="form-control" style="width:50%;" name="height[]" />
        </div>
        <div class="form-group col-md-2">
        	<label for="pwd">Stitch Count</label>
            <input type="number" class="form-control pull-left" name="stitch[]" />
        </div>
        <div class="form-group col-md-2">
        	<label for="pwd">Price</label>
            <input type="number" class="form-control pull-left" name="price[]" />
        </div>
        <div class="form-group col-md-4">
          <label for="pwd">Zip</label>
          <input type="file" name="test1[]" class="form-control" />
        </div>
      
        </div>
        <!-- Button -->
        <br/>
          
            <button id="add-more" name="add-more" class="btn btn-primary"><i class="fa fa-plus"></i></button>
         
        <br><br>
                      
                    </div>
                </div>
                          
                      </div>
                      <div class="tab-pane col-md-10" id="tab22"><br/>
                            <div class="form-group">
                                <label class="control-label">Meta Title</label>
                                <input type="text" required name="meta_title" class="form-control">
                            </div>   
                            <div class="form-group">
                                <label class="control-label">Meta Keywords</label>
                                <textarea class="form-control" rows="2" name="meta_key"></textarea>
                            </div>
                            <div class="form-group">
                                <label class="control-label">Meta Description</label>
                                <textarea class="form-control" rows="5" name="meta_desc"></textarea>
                            </div>
                            <div class="form-group">
                                <label class="control-label">Og:Title</label>
                                <input type="text" name="og_title" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">Og:Description</label>
                                <textarea class="form-control" rows="4" name="og_desc"></textarea>
                            </div>
                      </div>
                      <div class="tab-pane" id="tab23"> Tab 3 </div>
                    </div>
                    </div></form>
           <?php }?>
           
             
                   </div>
                </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/subcatenable',
							 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/in_trend',
							 data: {v:v,id:id},
							 success: function(response){
								// alert(response);
							 }
							 });
						});
		
		$(".subcatdelete").click(function(e){e.preventDefault();
		if (!confirm("Sure you want to delete?")){
				  return false;
				}
			var id=$(this).attr("href");
			var img=$(this).attr("id");
		//alert(img);return false;
			$(this).closest("tr").remove();
			$.ajax({
							 type: "POST",
							 
							 url: '<?php echo base_url();?>admin/subcatdelete',
							 data: {id:id,img:img},
							 success: function(response){
								 //alert(response);
							 }
							 });
		});
		$(".editform").click(function(){
			var id=$(this).attr("id");
			$.ajax({
							 type: "POST",
							 dataType:"json",
							 url: '<?php echo base_url();?>admin/ajax_showsubcat',
							 data: {id:id},
							 success: function(response){
								 //alert(response);
								$("#subcat").val(response.subcat_name);
								$("#metakey").val(response.metakey);
								$("#metatitle").val(response.metatitle);
								$("#metadesc").val(response.metadesc);
							 	$("#oldimg").val(response.subcat_image);
								$("#img").attr("src","<?php echo base_url();?>assets/images/category/"+response.subcat_image);
								$("#sid").val(response.sid);
								$("#cat").val(response.cid).prop("selected",true);
							 }
							 });
		});
		$("form#updateform").submit(function(e){
								var sid=$("#sid").val();
								//alert(sid);
								e.preventDefault();
								$.ajax({
								url: "<?php echo base_url();?>admin/update_subcategory", // Url to which the request is send
								type: "POST",             // Type of request to be send, called as method
								data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
								contentType: false,       // The content type used when sending data to the server.
								cache: false,             // To unable request pages to be cached
								processData:false,        // To send DOMDocument or non processed data file it is set to false
								success: function(data)   // A function to be called if request succeeds
								{
									window.location.href = '<?php echo base_url();?>admin/subcategory';
								//$("#tr"+sid+":first-child").text(data.subcat_name);
								//$("#respond").html(data);
								//$("#myModal").modal('toggle'); 
								//$("#cancelmodal").trigger("click");
								}
								});
		});
	});
</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>

<script type="text/javascript">
		$(document).ready(function() {
				"use strict";
				
				$('#data-tables').dataTable();
		} );
</script>

</body>
</html>