 <script src="//cdn.ckeditor.com/4.7.3/standard/ckeditor.js"></script>
 <div class="clearfix"></div>
  <div class="content-wrapper">

    <div class="container-fluid">

      <!-- Breadcrumb-->

     <div class="row pt-2 pb-2">

        <div class="col-sm-9">

		    <h4 class="page-title">Add/Edit Products</h4>

	   </div>

     

     </div>

    <!-- End Breadcrumb-->

      <div class="row">

			<div class="col-lg-12">

			   <?php echo $this->session->flashdata("msg");?>

               <div class="card">

                    	  <div class="card-header">Enter Product Details</div>

                    <div class="card-body">

                          <?php if($_GET['prod_id']){
							  $edit=$this->db->get_where("products",array("pid"=>$_GET['prod_id']))->row();
							  //echo "<pre>";print_r($edit);?>
                            <form  action="<?php echo base_url();?>admin/update_product_submit" method="post" enctype="multipart/form-data">
                            <input type="hidden" name="pid" value="<?php echo $edit->pid;?>" />
                                  <div class="row">
                                  <div class="col-md-5">
								  <div class="form-group">

                                    <label for="email">Choose Category</label>

                                    <select class="form-control" name="cid"  id="mcat">

                                        <option value="">Choose Category</option>

                                        <?php $mcat=$this->db->get("mcategory")->result();

                                            foreach($mcat as $cat){?>

                                        <option value="<?php echo $cat->mid;?>" <?php if($cat->mid==$edit->cid){echo "selected";}?>><?php echo $cat->mcat_name;?></option>

                                        <?php }?>

                                    </select>

                                  </div>
                                  <div class="form-group">

                                    <label for="email">Choose SubCategory</label>

                                    <select class="form-control" name="cid2" id="mcat2">

                                    <option value="">Choose</option>

<?php $subcat=$this->db->get_where("category",array("mid"=>$edit->cid))->result();

    foreach($subcat as $cat){?>

<option value="<?php echo $cat->cid;?>" <?php if($cat->cid==$edit->sid){echo "selected";}?>><?php echo $cat->cat_name;?></option>

<?php }?>
                                    </select>

                                  </div>
                                  <div class="form-group ">

                                    <label for="email">Product Name</label>

                                    <input type="text" required class="form-control" value="<?php echo $edit->title;?>" name="title">

                                  </div>
                                  <div class="form-group ">

                                    <label for="email">Product Slug/URL</label>

                                    <input type="text" required class="form-control" value="<?php echo $edit->prod_slug;?>" name="prod_slug">

                                  </div>
                                  <div class="row">
                                  <div class="form-group col-md-4">

                                    <label for="email">Price</label>

                                    <input type="text"  class="form-control" name="price" value="<?php echo $edit->price;?>" required>

                                  </div>
                                  <div class="form-group col-md-4">

                                    <label for="email">Offer Price</label>

                                    <input type="text"  class="form-control" name="oprice" value="<?php echo $edit->oprice;?>" required>

                                  </div>
                                    <input type="hidden"  class="form-control" name="wr_month">

                                 
                                    <input type="hidden"  class="form-control" name="book_amt">


                                    <input type="hidden"  class="form-control" name="book_last_date" value="<?php echo $edit->book_last_date;?>">

                                  <div class="form-group col-md-4">

                                    <label for="email">Available Qtys</label>

                                    <input type="number"  class="form-control" required name="qtys" value="<?php echo $edit->qtys;?>">

                                  </div>
                                  <div class="form-group col-md-6">

                                    <label for="email">Color</label>


<select class="form-control" name="color" required>

    <option value="red" <?php if($edit->color=='red'){echo "selected";}?>>Red</option>
    <option value="pink" <?php if($edit->color=='pink'){echo "selected";}?>>Pink</option>
    <option value="green" <?php if($edit->color=='green'){echo "selected";}?>>Green</option>
    <option value="blue" <?php if($edit->color=='blue'){echo "selected";}?>>Blue</option>
    <option value="black" <?php if($edit->color=='black'){echo "selected";}?>>Black</option>
    <option value="orange" <?php if($edit->color=='orange'){echo "selected";}?>>Orange</option>
    <option value="white" <?php if($edit->color=='white'){echo "selected";}?>>White</option>
    <option value="brown" <?php if($edit->color=='brown'){echo "selected";}?>>Brown</option>
    <option value="yellow" <?php if($edit->color=='yellow'){echo "selected";}?>>Yellow</option>
    <option value="purple" <?php if($edit->color=='purple'){echo "selected";}?>>Purple</option>


</select>
                                  </div>
                                  <div class="form-group col-md-6">

                                    <label for="email">Fabric</label>


<select class="form-control" name="fabric" >

<option value="">Select</option>
    <option value="Nylon" <?php if($edit->fabric=='Nylon'){echo "selected";}?>>Nylon</option>
    <option value="Rayon" <?php if($edit->fabric=='Rayon'){echo "selected";}?>>Rayon</option>
    <option value="Satin" <?php if($edit->fabric=='Satin'){echo "selected";}?>>Satin</option>
    <option value="Cotton" <?php if($edit->fabric=='Cotton'){echo "selected";}?>>Cotton</option>
    <option value="Viscose" <?php if($edit->fabric=='Viscose'){echo "selected";}?>>Viscose</option>
    <option value="Organza" <?php if($edit->fabric=='Organza'){echo "selected";}?>>Organza</option>
    <option value="Other" <?php if($edit->fabric=='Other'){echo "selected";}?>>Other</option>


</select>
<style>
.sizes{font-size:16px; font-weight:700; color:'blue';}
</style>
                                  </div>
                                  <div class="form-group col-md-12">
<?php $sizes=explode(",",$edit->psizes);?>
                                    <label for="email">Choose Sizes</label><br/>
<span class="sizes"><input type="checkbox" <?php if (in_array("XS", $sizes)){echo "checked";}?> name="sizes[]" value="XS"/> XS</span> 
<span class="sizes"><input type="checkbox" <?php if (in_array("S", $sizes)){echo "checked";}?> name="sizes[]" value="S"/> S</span> 
<span class="sizes"><input type="checkbox" <?php if (in_array("M", $sizes)){echo "checked";}?> name="sizes[]" value="M"/> M</span> 
<span class="sizes"><input type="checkbox" <?php if (in_array("L", $sizes)){echo "checked";}?> name="sizes[]" value="L"/> L</span> 
<span class="sizes"><input type="checkbox" <?php if (in_array("XL", $sizes)){echo "checked";}?> name="sizes[]" value="XL"/> XL</span> 
<span class="sizes"><input type="checkbox" <?php if (in_array("XXL", $sizes)){echo "checked";}?> name="sizes[]" value="XXL"/> XXL</span> 
<span class="sizes"><input type="checkbox" <?php if (in_array("NA", $sizes)){echo "checked";}?> name="sizes[]" value="NA"/> NA</span> 
                                            </div>
                                  </div>

                                  <div class="form-group">

                                    <label for="email">Product Short Description</label>

                                    <textarea class="form-control" rows="3" name="sdesc"><?php echo $edit->sdesc;?></textarea>

                                  </div>
                                  <div class="form-group ">

                                  <label for="email">Product Image</label>

                                  <input type="file" name="profile_img" class="form-control"/>
                                  <input type="hidden" name="oldprofile_img" class="form-control" value="<?php echo $edit->img;?>"/>
                                  <img class="img img-responsive" width="100px" src="<?php echo base_url().'assets/images/products/'.$edit->img;?>" />
                                  <br/>

                                  <button type="submit" class="btn btn-success" name="submit">Update Product</button>
								  </div>
                                  </div>
                                  <div class="col-md-7">
                                      <div class="form-group">
                                        <label>Product Description Details</label>
                                        <textarea class="form-control" rows="5" name="pdesc" required><?php echo $edit->pdesc;?></textarea>
                                      </div>
                                  </div>
                                  </div>
                                </form>

                              <?php }else{?>

                                <form  action="<?php echo base_url();?>admin/add_product_submit" method="post" enctype="multipart/form-data">
                                  <div class="row">
                                  <div class="col-md-5">
								  <div class="form-group">

                                    <label for="email">Choose Category</label>

                                    <select class="form-control" name="cid" id="mcat">

                                        <option value="">Choose Category</option>

                                        <?php $mcat=$this->db->get("mcategory")->result();

                                            foreach($mcat as $cat){?>

                                        <option value="<?php echo $cat->mid;?>"><?php echo $cat->mcat_name;?></option>

                                        <?php }?>

                                    </select>

                                  </div>
                                  <div class="form-group">

                                    <label for="email">Choose SubCategory</label>

                                    <select class="form-control" name="cid2" id="mcat2">

                                        <option value="">Select</option>
                                    </select>

                                  </div>
                                  <div class="form-group ">

                                    <label for="email">Product Name</label>

                                    <input type="text" required class="form-control" name="title">

                                  </div>
                                  <div class="form-group ">

                                    <label for="email">Product Slug/URL</label>

                                    <input type="text" required class="form-control" name="prod_slug">

                                  </div>
                                  <div class="row">
                                  <div class="form-group col-md-4">

                                    <label for="email">Price</label>

                                    <input type="text"  class="form-control" name="price" required>

                                  </div>
                                  <div class="form-group col-md-4">

                                    <label for="email">Offer Price</label>

                                    <input type="text"  class="form-control" name="oprice" required>

                                  </div>
                                 
                                    <input type="hidden"  class="form-control" name="wr_month">

                                  
                                 
                                    <input type="hidden"  class="form-control" name="book_amt">

                                    <input type="hidden"  class="form-control" name="book_last_date">

                                  <div class="form-group col-md-4">

                                    <label for="email">Available Qtys</label>

                                    <input type="number"  class="form-control" name="qtys" required>

                                  </div>
                                  <div class="form-group col-md-6">

                                    <label for="email">Color</label>


<select class="form-control" name="color" required>

    <option value="red">Red</option>
    <option value="pink">Pink</option>
    <option value="green">Green</option>
    <option value="blue">Blue</option>
    <option value="black" <?php //if($edit->color=='black'){echo "selected";}?>>Black</option>
    <option value="orange" <?php //if($edit->color=='orange'){echo "selected";}?>>Orange</option>
    <option value="white" <?php //if($edit->color=='white'){echo "selected";}?>>White</option>
    <option value="brown" <?php //if($edit->color=='brown'){echo "selected";}?>>Brown</option>
    <option value="yellow" <?php //f($edit->color=='yellow'){echo "selected";}?>>Yellow</option>
    <option value="purple" <?php //if($edit->color=='purple'){echo "selected";}?>>Purple</option>


</select>
                                  </div>
                                  <div class="form-group col-md-6">

                                    <label for="email">Fabric</label>


<select class="form-control" name="fabric">

<option value="">Select</option>
    <option value="Nylon">Nylon</option>
    <option value="Rayon">Rayon</option>
    <option value="Satin">Satin</option>
    <option value="Cotton">Cotton</option>
    <option value="Viscose">Viscose</option>
    <option value="Organza">Organza</option>
    <option value="Other">Other</option>


</select>
                                  </div>
                                  <div class="form-group col-md-12">

                                    <label for="email">Choose Sizes</label><br/>
<span class="sizes"><input type="checkbox" name="sizes[]" value="XS"/> XS</span> 
<span class="sizes"><input type="checkbox" name="sizes[]" value="S"/> S</span> 
<span class="sizes"><input type="checkbox" name="sizes[]" value="M"/> M</span> 
<span class="sizes"><input type="checkbox" name="sizes[]" value="L"/> L</span> 
<span class="sizes"><input type="checkbox" name="sizes[]" value="XL"/> XL</span> 
<span class="sizes"><input type="checkbox" name="sizes[]" value="XXL"/> XXL</span> 
<span class="sizes"><input type="checkbox" name="sizes[]" value="NA"/> NA</span> 
                                            </div>
                                  </div>

                                  <div class="form-group">

                                    <label for="email">Product Short Description</label>

                                    <textarea class="form-control" rows="3" name="sdesc"></textarea>

                                  </div>
                                  <div class="form-group ">

                                  <label for="email">Product Image</label>

                                  <input type="file" name="profile_img" class="form-control"/>
                                  <br/>

                                  <button type="submit" class="btn btn-success" name="submit">Add Product</button>
								  </div>
                                  </div>
                                  <div class="col-md-7">
                                  	
                                      <div class="form-group">
                                        <label>Product Description Details</label>
                                        <textarea class="form-control" rows="5" name="pdesc" required></textarea>
                                      </div>
                                  </div>
                                  </div>
                                </form>

                                <?php }?>

                          

                    </div>

                    

               </div>                  

            </div>

            

            

        </div><!--End Row-->

	  

	  <!--End Row-->



    </div>

    <!-- End container-fluid-->

    

    </div><!--End content-wrapper-->

   <!--Start Back To Top Button-->

    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>

    <!--End Back To Top Button-->

	

	<!--Start footer-->

	<footer class="footer">

      <div class="container">

        <div class="text-center">

          Copyright © 2022
        </div>

      </div>

    </footer>

	<!--End footer-->

   

  </div><!--End wrapper-->





  <!-- Bootstrap core JavaScript-->

	<script>
	CKEDITOR.replace('pdesc');

	$(document).ready(function(){
    $("#mcat").change(function(){
      var cat=$(this).val();
      $.ajax({

type: "POST",

url: '<?php echo base_url();?>admin/ajax_showsubcat1',

data: {cid:cat},

success: function(res){

  $("#mcat2").html(res);

}

});

    });
		$(".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/prod_enable',

							 data: {id:id,st:st},

							 success: function(response){

								 //alert(response);

							 }

							 });

		});
		$(".prod_delete").click(function(e){e.preventDefault();

				if(!confirm("Sure you want to delete?")){

					  return false;

				}

				var id=$(this).attr("id");$(this).closest("tr").remove();

				$.ajax({

					 type: "POST",

					 url: '<?php echo base_url();?>admin/ajax_prod_delete',

					 data: {id:id},

					 success: function(response){

						 //alert(response);

					 }

				});

			});

		});

</script>

	<!-- simplebar js -->

  <script src="<?php echo base_url();?>adminassets/js/sidebar-menu.js"></script>

  <!-- Custom scripts -->

  <script src="<?php echo base_url();?>adminassets/js/app-script.js"></script>

  

  <!-- Vector map JavaScript -->

  <!-- Index js -->

  <script src="<?php echo base_url();?>adminassets/js/index.js"></script>



    

	

</body>

</html>

