<script src="<?php echo base_url();?>ckeditor/ckeditor.js"></script>
   <section class="content-header">
      <h1>

        Articles 

      </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');?>">Articles</a></li>

        <li class="active"> Edit</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>

          <!-- Horizontal Form -->

          <div class="box box-info">

            <div class="box-header with-border">

              <h3 class="box-title">Edit </h3>

            </div>

            <!-- /.box-header -->

            <!-- form start -->

            <form id="add_frm" name="add_frm" class="form-horizontal" method="post" action="" enctype="multipart/form-data">

              <div class="box-body">
                <div class="form-group">

                  <label class="col-sm-2 control-label">Language</label>

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

                    <select class="form-control" name="language" id="language">
                      <?php if(!empty($languages))
                            {
                            foreach ($languages as $value) { ?>
                              <option value="<?php echo $value['id']; ?>" <?php if($articleDetails['lang_id']==$value['id']){ echo 'selected'; }?>><?php echo $value['name']; ?></option>
                      <?php }
                          }
                      ?>
                    </select>

                  </div>

                </div>

                <div class="form-group">

                  <label class="col-sm-2 control-label">Title</label>

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

                    <input type="text" class="form-control" id="title" name="title" value="<?php if(!empty($articleDetails)){ echo $articleDetails['title']; } ?>" placeholder="Please enter title">

                  </div>

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

                  <label class="col-sm-2 control-label">Sub Title</label>

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

                    <input type="text" class="form-control" id="subtitle" name="subtitle" value="<?php if(!empty($articleDetails)){ echo $articleDetails['teasertext']; } ?>" placeholder="Please enter subtitle">

                  </div>

                </div>

                <div class="form-group">

                  <label class="col-sm-2 control-label">Sort Order</label>

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

                    <input type="text" class="form-control" id="sort" name="sort" value="<?php if(!empty($articleDetails)){ echo $articleDetails['sort']; } ?>" placeholder="Please enter sort order">

                  </div>

                </div>

                
                <div class="form-group">

                  <label class="col-sm-2 control-label">Content</label>

                  <div class="col-sm-10">
                    <textarea name="content" class="form-control"><?php if(!empty($articleDetails)) { echo $articleDetails['content']; } ?></textarea>
                  <script>
                           CKEDITOR.replace( 'content',{
                                    filebrowserBrowseUrl : '/castle/fileman/index.html',
                                    filebrowserImageBrowseUrl : '/castle/fileman/index.html?type=image',
                                    removeDialogTabs: 'link:upload;image:upload'
                            });
                        </script> 
                  </div>

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

                  <label class="col-sm-2 control-label">Preview Image</label>

                  <div class="col-sm-6">
                    <?php if(!empty($previewImage)){
                    ?>
                      <div class="col-md-6"><img src="<?php echo base_url(); ?>assets/userfiles/<?php echo $previewImage['path']; ?>/<?php echo $previewImage['filename']; ?>.<?php echo $previewImage['extension']; ?>" class="img-responsive"></div>
                    <?php
                          }
                      ?>
                    
                      <input type="file" name="previewfile" value="Upload" class="form-control">
                     
                  </div>

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

                  <label class="col-sm-2 control-label">Logo</label>

                  <div class="col-sm-6">
                    <?php if(!empty($logoImage)){
                    ?>
                      <div class="col-md-6"><img src="<?php echo base_url(); ?>assets/userfiles/<?php echo $logoImage['path']; ?>/<?php echo $logoImage['filename']; ?>.<?php echo $logoImage['extension']; ?>" class="img-responsive"></div>
                    <?php
                          }
                      ?>
                      <input type="file" name="logofile" value="Upload" class="form-control">
                      
                  </div>

                </div>       

              </div>
             
              <!-- /.box-body -->

              <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="Update" id="add">

              </div>

              <input type="hidden" name="frmSecurity" value="<?php echo $this->utility->getSecurity();?>"/>

              <!-- /.box-footer -->

            </form>

          </div>

          <!-- /.box -->

         

          <!-- /.box -->

        </div>

        <!--/.col (right) -->

      </div>

      <!-- /.row -->

    </section>

    <style type="text/css">

    .loader{

      position: fixed;

      left: 0;

      top: 0;

      right: 0;

      bottom: 0;

      width: 100%;

      height: 100%;

      background-color: rgba(0, 0, 0, 0.60);

      z-index: 9999;

      text-align: center;

    }

    .loader img{

      z-index: 99999;

      margin-top: 10%;

    }

    </style>

   <script type='text/javascript'>
      $("#add_frm").validate({
        rules: {
          title: {
            required: true,
          },
          subtitle:{
            required: true,
          },
          sort:{
            required:true
          }
        }
      });
    </script>

   <script type="text/javascript">
    function return_back()
    {
      var back_url='<?php echo base_url()?>admin/blog/article';
      window.location=back_url;
    }
    
   </script>