<script src="https://cdn.ckeditor.com/4.7.1/standard/ckeditor.js"></script>
<section class="content-header">
  <h1>Blog Article</h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo base_url().'admin';?>"><i class="fa fa-dashboard"></i> Home</a></li>
    <li><a href="<?php echo base_url('admin/blog_article');?>">Blog Article</a></li>
    <li class="active">Add</li>
  </ol>
</section>
<section class="content">
  <div class="row">
    <?php echo $this->utility->showMsg();?>
    <div class="col-md-12">
      <div class="loader" style="display:none;"><img src='<?php echo base_url();?>assets/images/loading.gif' alt='loading' /></div>
      <div class="box box-info">
        <div class="box-header with-border">
          <h3 class="box-title">Add </h3>
        </div>
        <form id="add_cat_add" name="add_cat_add" class="form-horizontal" method="post" action="" enctype="multipart/form-data" onsubmit="return formValidate();">
           <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Meta Tag [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <input type="text" class="form-control required" required id="meta_title_<?php echo $lang['id']; ?>" name="meta_title_<?php echo $lang['id']; ?>" value="" placeholder="Please enter meta title">
                <p style="color:#b3975b !important">Please enter details with comma seperators</p>
              </div>
            </div>
          </div>
          <?php } } ?> 
          <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Meta Keywords [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <?php $title = getValue('b_article_lang_values',array('lang_id'=>$lang['id'],'blog_id'=>$blogDetails['blog_id']));?>
                <input type="text" class="form-control required" required id="meta_keywords_<?php echo $lang['id']; ?>" name="meta_keywords_<?php echo $lang['id']; ?>" value="" placeholder="Please enter meta keywords">
                <p style="color:#b3975b !important">Please enter details with comma seperators</p>
              </div>
            </div>
          </div>
          <?php } } ?>
          <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Meta Description [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
             <textarea name="meta_description_<?php echo $lang['id']; ?>" id="meta_description_<?php echo $lang['id']; ?>" class="form-control required" required style="width:680px;height:175px;"></textarea>
              </div>
            </div>
          </div>
          <?php } } ?>
          <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?> 
      <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Intro Text [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <textarea name="intro_text_<?php echo $lang['id']; ?>" id="intro_text_<?php echo $lang['id']; ?>" class="form-control required" required style="width:680px;height:175px;"></textarea>
              </div>
            </div>
          </div>
          <?php } } ?>
          <div class="box-body" style="display:none">
            <div class="form-group">
              <label class="col-sm-2 control-label">Blog Category </label>
              <div class="col-sm-6">
                <select name="cat_id" id="cat_id" class="form-control required" required>
                  <?php 
                  if(!empty($category_list)){
                    foreach($category_list as $row){
                      if($row['cat_id']==$blogDetails['cat_id']){
                        $selected_catgory = "selected";
                      }else{
                        $selected_catgory = "";
                      }
                  ?>
                  <option value="<?php echo $row['cat_id']; ?>" <?php echo $selected_catgory;?>><?php echo $row['cat_name']; ?></option>
                  <?php 
                    } 
                  } 
                  ?>   
                </select>
              </div>
            </div>
          </div>

          <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Blog Title [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-6">
              <input type="text" class="form-control required" required id="blog_title_<?php echo $lang['id']; ?>" name="blog_title_<?php echo $lang['id']; ?>" value="" placeholder="Please enter blog title">
              </div>
            </div>
          </div>
      <?php } } ?>
          <?php if(!empty($language)){ 
                  foreach ($language as $lang) { ?>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Blog Descriotion [<?php echo $lang['name']; ?>]</label>
              <div class="col-sm-10">
              <textarea name="blog_desc_<?php echo $lang['id']; ?>" id="blog_desc_<?php echo $lang['id']; ?>" class="form-control"></textarea>
                <script>
               CKEDITOR.replace( 'blog_desc_<?php echo $lang['id']; ?>',{
                        filebrowserBrowseUrl : '/fileman/index.html',
                        filebrowserImageBrowseUrl : '/fileman/index.html?type=image',
                        removeDialogTabs: 'link:upload;image:upload',
                        extraPlugins: 'youtube',
                });
                CKEDITOR.plugins.addExternal('youtube', '/ckeditor/plugins/youtube/plugin.js');
                </script> 
                <label id="blog_desc_error" style="color:red;"></label>
              </div>

            </div>
          </div>
          <?php } } ?>
		      <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Logo</label>
              <div class="col-sm-6">
                <input type="file" class="form-control" id="logofile" name="logofile" value="">
              </div>
            </div>
          </div>
          <div class="box-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">Banner Image</label>
              <div class="col-sm-6">
                <input type="file" class="form-control required" id="banner_image" name="banner_image" value="">
              </div>
            </div>
          </div>
          <div class="box-footer">
            <button type="button" onclick="return_back()"class="btn btn-default  margin-left  " >Cancel</button>
            <input type="submit" class="btn btn-info " value="Add" id="add">
          </div>
        </form>
      </div>
    </div>
  </div>
</section>
 <script type='text/javascript'>
  $("#add_cat_add").validate();
  function formValidate() {
      
      if (CKEDITOR.instances['blog_desc'].getData() == '') {
          $('#blog_desc_error').html("This field is required.");
          return false;
      }else{
          $('#blog_desc_error').html("");
          return true;
      }
  }
</script>
 <script type="text/javascript">
  function return_back(){
    var back_url='<?php echo base_url()?>admin/blog_article';
    window.location=back_url;
  }
 </script>