<!-- 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 News</h6>
               </div>
               <div class="clearfix"></div>
            </div>
            <div class="panel-wrapper collapse in">
               <div class="panel-body">
                  <div class="form-wrap">
                     <form id="addPostFrom" class="form-horizontal" action="<?php echo base_url(A."/addPost"); ?>" enctype="multipart/form-data" method='post'>
                        <div class="row">
                           <div class="col-md-12">
                              <div class="form-group">
                                 <label class="col-sm-12">Title:</label>
                                 <div class="col-sm-12">
                                    <input type="text" name="post_title" class="form-control" placeholder="Enter Post Title" required>
                                 </div>
                              </div>
                           </div>
                           <div class="col-md-6">
                              <div class="form-group">
                                 <label class="col-sm-12">Date:</label>
                                 <div class="col-sm-12">
                                    <input type="date" name="publish_date" class="form-control" placeholder="Enter Date" value="<?php echo date('Y-m-d'); ?>" style="line-height: 18px;">
                                 </div>
                              </div>
                           </div>
                           <div class="col-md-6">
                              <div class="form-group">
                                 <label class="col-sm-12">Image (Image Size -890x596px)</label>
                                 <div class="col-sm-12">
                                    <input type="file" name="image" class="form-control">
                                 </div>
                              </div>
                           </div>
                           <!-- <div class="col-md-6">
                              <div class="form-group">
                                 <label class="col-sm-12">Icon (Image Size - 50x50px)</label>
                                 <div class="col-sm-12">
                                    <input type="file" name="icon" class="form-control">
                                 </div>
                              </div>
                           </div> -->
                              <!-- <div class="form-group col-sm-12">
                                 <label class="">Category</label>
                                 <select class="form-control" name="post_category" required>
                                    <option value="">Select Category</option>
                                    <?php //if(isset($cat) && !empty($cat)){ foreach($cat as $key=>$value) : ?>
                                       <option value="<?php //echo $value['id']; ?>"><?php //echo $value['category']; ?></option>
                                    <?php //endforeach; } ?>
                                 </select>
                              </div> -->
                              <!-- <div class="form-group">
                                 <label class="col-sm-12">Meta Title:</label>
                                 <div class="col-sm-12">
                                    <input type="text" name="seo_title" class="form-control" placeholder="Enter title for SEO">
                                 </div>
                              </div>
                              <div class="form-group">
                                 <label class="col-sm-12">Meta Keywords:</label>
                                 <div class="col-sm-12">
                                    <input type="text" name="seo_keyword" class="form-control" placeholder="Enter keywords for SEO">
                                 </div>
                              </div>
                              <div class="form-group">
                                 <label class="col-sm-12">Meta Description:</label>
                                 <div class="col-sm-12">
                                    <textarea name="seo_description" class="form-control" placeholder="Enter description for SEO"></textarea>
                                 </div>
                              </div> -->
                           </div>
                           <div class="col-md-12">
                              <div class="form-group">
                                 <label class="col-sm-12">Description:</label>
                                 <div class="col-sm-12">
                                    <!-- <div class="fileUpload btn btn-default">
                                       <span>Add Media</span>
                                       <input id="file_2" type="file" name="" class="upload" />
                                    </div> -->
                                    <textarea name="post_description" class="ckeditor_full" id="ckeditor_full_2" placeholder="Enter Post Description"></textarea>
                                 </div>
                              </div>
                           </div>
                           <div class="col-md-12">
                              <div class="form-group mb-0">
                                 <div class="col-sm-12">
                                    <button 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 -->
<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);
   	        }
   	    });
   	});
   	$("#file_2").on("change",function(){
   	    var file_data = $("#file_2").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_2'].insertHtml(html);
   	        }
   	    });
   	});
   	$("#file_3").on("change",function(){
   	    var file_data = $("#file_3").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_3'].insertHtml(html);
   	        }
   	    });
   	});

</script>
<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>