<!-- Main Content -->

<div class="page-wrapper">

    <div class="container-fluid pt-25">

    	 <div class="row">

            <div class="alert alert-success alert-dismissible" role="alert" <?php if($this->session->flashdata('message')==''){ ?> style="display:none" <?php } ?> >

                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>

                <?php echo $this->session->flashdata('message'); ?>

            </div>

            <div class="alert alert-warning alert-dismissible" role="alert" <?php if($this->session->flashdata('emessage')==''){ ?> style="display:none" <?php } ?> >

                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>

                <?php echo $this->session->flashdata('emessage'); ?>

            </div>

        </div>

		<!-- Row -->

		<div class="row">

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

				<div class="panel panel-default card-view">

					<div class="panel-heading">

						<div class="pull-left">

							<h6 class="panel-title txt-dark">Add Product</h6>

						</div>

						<div class="clearfix"></div>

					</div>

					<div class="panel-wrapper collapse in">

						<div class="panel-body">

							<div class="form-wrap">

								<form id="addProductFrom" class="form-horizontal" action="<?php echo base_url(A."/addProduct"); ?>" enctype="multipart/form-data" method='post'>

									<div class="row">

										<div class="col-md-7">
											<div class="form-group">
				                                <label class="col-sm-12">Product Title:</label>
				                                <div class="col-sm-12">
				                                    <input type="text" name="product_name" class="form-control" placeholder="Enter Product Title">
				                                </div>
				                            </div>
				                            <!-- <div class="form-group">
				                                <label class="col-sm-12">Product Slug:</label>
				                                <div class="col-sm-12">
				                                    <input type="text" name="product_slug" class="form-control" placeholder="Enter Product Slug">
				                                </div>
				                            </div> -->

				                            <div class="form-group">
				                                <label class="col-sm-12">Serial No:</label>
				                                <div class="col-sm-12">
				                                    <input type="text" name="product_sku" class="form-control" placeholder="Enter Serial No.">
				                                </div>
				                            </div>
				                            <div class="form-group">
				                                <label class="col-sm-12">Product Price:</label>
				                                <div class="col-sm-12">
				                                    <input type="text" name="product_price" class="form-control" placeholder="Enter Regular Price">
				                                </div>
				                            </div>
				                            <div class="form-group">
				                                <label class="col-sm-12">Product Sale Price:</label>
				                                <div class="col-sm-12">
				                                    <input type="text" name="product_sale_price" class="form-control" placeholder="Enter Sale Price">
				                                </div>
				                            </div>
				                            <!-- <div class="form-group">
				                                <label class="col-sm-12">Unit Label:</label>
				                                <div class="col-sm-12">
				                                    <input type="text" name="unit_label" class="form-control" placeholder="Ex. - PK5">
				                                </div>
				                            </div> -->

				                            <div class="form-group">
				                                <label class="col-sm-12">Product Description:</label>
				                                <!-- <div class="col-sm-12">
				                                    <div class="fileUpload btn btn-default ml-0">
				                                       <span>Add Media</span>
				                                       <input id="file_1" type="file" name="" class="upload" />
				                                    </div>
				                                    <textarea name="product_description" class="ckeditor_full" id="ckeditor_full_1" placeholder="Enter Description"></textarea>
				                                </div> -->
				                                <div class="col-sm-12">
				                                    <textarea name="product_description" class="tinymce" placeholder="Enter Product Description"></textarea>
				                                </div>
				                            </div>

				                            <div class="form-group">
				                                <label class="col-sm-12">Additional Information:</label>
				                                <div class="col-sm-12">
				                                    <textarea name="product_specification" class="tinymce" placeholder="Enter Product Specification"></textarea>
				                                </div>
				                            </div>

				                            <!-- <div class="form-group">
				                                <label class="col-sm-12">DIMENSIONS:</label>
				                                <div class="col-sm-12">
				                                    <textarea name="product_dimensions" class="tinymce" placeholder="Enter DIMENSIONS"></textarea>
				                                </div>
				                            </div> -->

										</div>

										<div class="col-md-5">

				                            <div class="form-group">
				                                <label class="col-sm-12">Product Stock:</label>
				                                <div class="col-sm-12">
				                                    <input type="text" name="product_stock" class="form-control" placeholder="Enter Product Stock">
				                                </div>
				                            </div>

				                            <div class="form-group">

				                                <label class="col-sm-12">Featured Image (Size : 500x500 px) : </label>

				                                <div class="col-sm-12 mb-15">

				                                    <input type="file" class="form-control" name="product_photos_thumb" required>
				                                    

				                                </div>

				                                <label class="col-sm-12">Product Images (multiple) : </label>

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

				                                    <input id="pimages" type="file" class="form-control" name="product_photos[]" multiple>
				                                    <p id="imageError"></p>

				                                </div>

				                            </div>
				                            <?php /* $brand = $this->common->getData('brand'); ?>
				                            <div class="form-group">
				                                <label class="col-sm-12">Brand:</label>
				                                <div class="col-sm-12">
				                                    <select class="form-control" name="brandid">
				                                    	<option value="">Select Brand</option>
				                                    	<?php if(isset($brand) && !empty($brand)){ foreach($brand as $key=>$value) : ?>
				                                    		<option value="<?php echo $value['brandid']; ?>"><?php echo $value['brand_name']; ?></option>
				                                    	<?php endforeach; } ?>
				                                    </select>
				                                </div>
				                            </div>
				                            <?php */ ?>

				                            <div class="form-group pl-15">
				                            	<label class="col-sm-12 pl-0">Select Category</label>
				                            	<div class="col-sm-12" style="overflow:scroll; height:400px;border: 1px solid #ddd; width: calc(100% - 15px);"><br>
					                            	<ul class="tristate" style="list-style-type:disc;margin-left:20px;line-height: 35px;">
							                            <?php if(!empty($category)){ 
							                            	echo postMenu($category);
							                            } ?>
							                        </ul>
							                    </div>
				                            </div>
				                            <!-- <div class="form-group col-sm-12">
				                            	<div class="col-sm-12">
					                            	<p><input type="checkbox" name="new_arrival" value="1"> New</p>
					                            	<p><input type="checkbox" name="shop_rewards" value="1"> Top</p>
					                            	<p><input type="checkbox" name="best_selling" value="1"> Sale</p>
					                            </div>
				                            </div> -->

				                            <!-- <div class="form-group">
				                                <label class="col-sm-12">Front:</label>
				                                <div class="col-sm-12">
				                                    <textarea name="key_features" class="tinymce" placeholder="Enter DIMENSIONS"></textarea>
				                                </div>
				                            </div> -->

				                            <div class="form-group mb-0"> 

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

												  <button id="validBtn" type="submit" name="addcategory" class="btn btn-success btn-anim pull-right"><i class="icon-rocket"></i><span class="btn-text">Submit</span></button>

												</div>

											</div>

										</div>

									</div>									

								</form>

							</div>

						</div>

					</div>

				</div>

			</div>

		</div>	

		<!-- /Row -->

	</div>

	<style type="text/css">

		label{color:#000;}

		div.mce-edit-area{height:230px;}

	</style>
	<script type="text/javascript">
	   $(".add_fields").on("click", function(){
	      var html = $(this).closest('.comments_html').clone();
	      html.find("input").val("");
	      html.find(".add_fields").removeClass("add_fields btn-success").addClass("remove_fields btn-danger");
	      html.find(".fa-plus").removeClass("fa-plus").addClass("fa-trash").closest('.comments_html');
	      $(this).closest('.row').append(html);
	   });
	   $("body").on("click", ".remove_fields", function(){
	      $(this).closest('.comments_html').remove();
	   });
	</script>

	<script>
	    $("#pimages").on("change", function() {
	        var $fileUpload = $("input[type='file']");
        	if (paPKReInt($fileUpload.get(0).files.length)>8){
        		alert('You can select only 10 images');
	            $('#imageError').html('<span style="color:red;">You can select only 10 images</span>');
	            $('#validBtn').prop('disabled',true);
	         }else{
	         	$('#imageError').html('');
	         	$('#validBtn').prop('disabled',false);
	         }
	    });
	</script>

<script>
	$('.bget1').on('keyup', function () {
		var val = $(this).val();
		if(val){
			$('.bd').attr('disabled',true);
		}else{
			$('.bd').attr('disabled',false);
		}
	});
	$('.bd1').on('keyup', function () {
		var val = $(this).val();
		if(val){
			$('.bget').attr('disabled',true);
		}else{
			$('.bget').attr('disabled',false);
		}
	});
</script>
<style>
	input[type=number]::-webkit-inner-spin-button, 
	input[type=number]::-webkit-outer-spin-button { 
	  -webkit-appearance: none; 
	}

	input[type=number] {
	  -moz-appearance: textfield;
	}
</style>

<script src="<?php echo base_url("assets/admin/vendors/ckeditor/ckeditor.js"); ?>"></script>
<script src="<?php echo base_url("assets/admin/vendors/ckeditor/adapters/jquery.js"); ?>"></script>
<style type="text/css">
   #cke_1_contents{height:300px !important;}
   label{color:#000;}
   .fileUpload {
   position: relative;
   overflow: hidden;
   margin: 10px;
   }
   .fileUpload input.upload {
   position: absolute;
   top: 0;
   right: 0;
   margin: 0;
   padding: 0;
   font-size: 20px;
   cursor: pointer;
   opacity: 0;
   filter: alpha(opacity=0);
   }
</style>
<script type="text/javascript">
   $(function() {
        $('textarea.ckeditor_full' ).ckeditor({
            toolbarGroups: [
                     /*{ name: "document",    groups: [ "mode", "document" ] },            // Displays document group with its two subgroups.
                     { name: "basicstyles", groups: [ "basicstyles", "cleanup" ] },
                     { name: 'insert', groups: [ 'insert' ] },
                     { name: "links" },
                     { name: 'colors' },
                     { name: 'tools' },*/

              // { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },

              // { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },

              { name: 'links' },

              { name: 'insert' },

              // { name: 'forms' },

              // { name: 'tools' },

              // { name: 'document',       groups: [ 'mode', 'document', 'doctools' ] },

              { name: 'others' },

              // '/',

              { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },

              { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },

              { name: 'styles' },

              { name: 'colors' },

              { name: 'about' }
            ]
        });
    });
  	var site_url = "<?php echo base_url(); ?>";
  	var urlLink = "<?php echo A; ?>";
   	$("#file_1").on("change",function(){
   	    var file_data = $("#file_1").prop('files')[0];
   	    var form_data = new FormData();
   	    form_data.append('file', file_data);
   	    $.ajax({
   	        url: site_url+urlLink+"/uploadPostImage",
   	        dataType: 'text',
   	        cache: false,
   	        contentType: false,
   	        processData: false,
   	        data: form_data,
   	        type: 'post',
   	        success: function(result){
   	            var html='<img src="'+site_url+'assets/post-image/'+result+'" style="width:200px;">';
   	            CKEDITOR.instances['ckeditor_full_1'].insertHtml(html);
   	        }
   	    });
   	});
</script>
<script>
	$('body').on('click','.checkone', function () {
		var parent = $(this).attr('data-parent');
		$('#check'+parent).attr('checked',true);
	});
</script>
<style type="text/css">
	 li 
	{
		list-style-type: none!important;
	}
</style>