<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
             <?php
               echo isset($title) ? $title : NULL;
             ?>
          </h1>
        </section>
        <!-- Main content -->
        <section class="content">
            <div class="row">
            <form method="post" role="form">
                <div class="col-lg-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                          <h3 class="box-title">Edit Aboutus Page</h3>
                        </div>
                        <!-- /.box-header -->
                        <div class="adminform">
                        <!-- form start -->

                        <?php
                        if(isset($message))
                        {
                            echo $message;
                        }
                        ?>


                            <div class="form-group">
                                <label for="Company-description"> About us</label>
                                <textarea name="description"  rows="8" class="form-control"><?php echo $abouts['description'] ?></textarea>
                                <p class="help-block">Add Description About US.</p>

                            </div>
                            <script>
                                CKEDITOR.replace( 'description' );
                                function CKupdate(){
                                    for ( instance in CKEDITOR.instances )
                                        CKEDITOR.instances[instance].updateElement();
                                }
                            </script>
                            <div class="form-group">
                                <label for="website-logo">Image</label>
                                <img src="<?php echo UPLOAD_LINK.$abouts['image'] ?>" data-toggle="modal" data-target="#update-img" class="img-responsive change-logo" />
                                <p class="help-block">Change Image</p>
                            </div>
                            <div class="form-group">
                              <label for="availability" class="set-block">Status</label>
                              <div class="radio radio-info  radio-inline">
                                 <input type="radio" id="inlineRadio1" value="1" name="status" <?php if($abouts['status'] == 1) echo 'checked'; ?> >
                                 <label for="inlineRadio1"> Active </label>
                              </div>
                              <div class="radio radio-info  radio-inline">
                                 <input type="radio" id="inlineRadio2" value="2" name="status" <?php if($abouts['status'] == 2) echo 'checked'; ?>>
                                 <label for="inlineRadio2"> Not Active </label>
                              </div>
                           </div>
                            <input type="submit" class="btn btn-primary" name="edit" value="Edit Page" />
                        </div>
                      </div>
                      <!-- /.box -->
                </div>
                </form>

            </div>
      </section><!-- /.content -->
</div><!-- /.content-wrapper -->


<!-- Start edit Wwbsite Logo Modal -->
<div class="modal fade" id="update-img" role="dialog">
    <div class="modal-dialog modal-md">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Edit WebSite Logo</h4>
            </div>
            <div class="modal-body">
                <div id="updateImageResult"></div>
                <div class="row">
                    <div class="col-lg-10 pull-left">
                        <form id="updateImage" method="post" enctype="multipart/form-data">
                            <div class="form-group">
                                <label for="category-image"> Image</label>
                                <input type="file" name="image_name" id="image_name">
                                <p class="help-block">Change  Image.</p>
                            </div>
                            <input type="submit" class="btn btn-primary updatebtn" name="editImage" value="Save" />
                            <span class="loadingImage">
                                <img src="customize\backend\images\Preloader_61.gif" />
                             </span>
                        </form>
                    </div>
                    <div class="col-lg-2 pull-right">
                        <img src="" alt="" title="Edit Image" class="img-responsive old-image" />
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>
<!--End Edit Website Logo Modal-->


<script>
$(document).ready(function(){
    // start edit website logo
           $(".change-logo").click(function(){
             $("#updateImageResult").html("");
             // get image
             var image = $(this).attr("src");
             // set image into model
             $(".old-image").attr("src",image);
             $("#updateImage").submit(function(){
                $.ajax({
                    url: "<?php echo BASE_URL."About/update_image"; ?>",
                    type:"POST",
                    data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
                    contentType: false,       // The content type used when sending data to the server.
                    processData:false,
                    beforeSend:function(){
						$(".loadingImage").show();
                    },
                    statusCode: {
                     404: function() {
                       alert( "page not found" );
                      },
                      },
                      success:function(valdata) {
						  $(".loadingImage").hide();
                         var da = jQuery.parseJSON(valdata);
                        if(da['status'] == "success")
                        {
							$(".loadingImage").hide();
                          $("#updateImageResult").html('<div class="alert alert-success" role="alert"><strong>Success </strong> Image Updated Successfuly </div>');
                          $('#update-img').modal('hide');
                          $('.change-logo').attr("src","<?php echo UPLOAD_LINK; ?>"+da['newImage']);

                        }else{
                          $("#updateImageResult").html('<div class="alert alert-danger" role="alert"><strong> Error ! </strong> Error Update Your Image (Not Allowed Image Extension Or You Did Not Choose Image)</div>');
                        }
                      }
                });
                return false;
             });
           });
         // end edit website logo
});
</script>
