<!-- 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">

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

                    <div class="box box-primary">

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

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

                        </div>

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

                        <!-- form start -->

                        

                        <?php

                        if(isset($message))

                        {

                            echo $message;

                        }

                        ?>

                        <form role="form" method="post" enctype="multipart/form-data">

                          <div class="box-body">

                            <div class="form-group">

                              <label for="exampleInputEmail1">Full Name</label>

                              <input type="text" name="fullName" value="<?php echo $user['name']; ?>" class="form-control" id="exampleInputEmail1" placeholder="Enter Driver Full Name">

                            </div>

                            <div class="form-group">

                              <label for="exampleInputEmail1">Mobile Number</label>

                              <input type="text" name="phone" value="<?php echo $user['phone']; ?>" class="form-control" id="exampleInputEmail1" placeholder="Enter Driver Mobile Number">

                            </div> 

                            <div class="form-group">

                              <label for="exampleInputEmail1">Email Address</label>

                              <input type="email" name="email" value="<?php echo $user['mail']; ?>" class="form-control" id="exampleInputEmail1" placeholder="Enter Driver Email Address">

                            </div>

                            <div class="form-group">

                              <label for="exampleInputEmail1">Address</label>

                              <input type="text" name="address" value="<?php echo $user['address']; ?>" class="form-control" id="exampleInputEmail1" placeholder="Enter Driver Address">

                            </div>  

                            <div class="form-group">

                                <label for="website-logo">Profile Picture</label>

                                <img src="<?php echo UPLOAD_LINK.$user['photo'] ?>" data-toggle="modal" data-target="#profile_img" class="img-responsive change-logo profile_img" />

                                <p class="help-block">Update Profile Picture</p>

                            </div> 

                            <div class="form-group">

                                  <label for="password" class="set-block">Password </label>

                                    <a href="" data-toggle="modal" data-target="#changepassword" class="">Edit Your Password</a>

                               </div>  

                          </div>

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

                          <div class="box-footer">

                            <button type="submit" name="edit" class="btn btn-primary">Edit</button>

                          </div>

                        </form>

                      </div>

                      <!-- /.box -->

                </div>

            </div>

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

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



<!-- Start edit profile pic Modal -->

<div class="modal fade" id="profile_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 Profile Image</h4>

         </div>

         <div class="modal-body">

         <div id="updateImageResult"></div>

            <div class="row">

               <div class="col-lg-9 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-file">

                        <p class="help-block">Choose Image.</p>

                     </div>

                     <input type="hidden" value=""  class="field_id" name="field_id" />

                     <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-3 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 profile image Modal-->



<!-- Start change Password  Modal -->

<div class="modal fade" id="changepassword" 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 User Password</h4>

         </div>

         <div class="modal-body">

            <div class="row">

               <div class="col-lg-12 pull-left">

                   <div id="updatePasswordResult"></div>

                  <form id="EditPassword">

                    <div class="form-group">

                        <label for="old_password">Old Password</label>

                        <input type="password" class="form-control"  id="old_password" name="old_password">

                        <p class="help-block">Insert Your Current Password.</p>

                     </div>  

                     <div class="form-group">

                        <label for="category-image">New Password</label>

                        <input type="password" class="form-control"  id="password" name="password">

                        <p class="help-block">Insert Your New Password.</p>

                     </div>

                      <div class="form-group">

                        <label for="category-image">Confirm New Password</label>

                        <input type="password" class="form-control" id="repassword" name="repassword">

                        <p class="help-block">Re-Type Your New Password.</p>

                     </div>

                     <input type="submit" class="btn btn-primary" name="editPass" value="Save" />

                  </form>

               </div>

            </div>

         </div>

         <div class="modal-footer">

            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

         </div>

      </div>

   </div>

</div>

<!--End change password Modal-->



<script>

$(document).ready(function(){

    // start edit profile image

	 $(".profile_img").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."admin/update_profile_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")

                        {

                          $("#updateImageResult").html('<div class="alert alert-success" role="alert"><strong>Success </strong> Image Updated Successfuly </div>');

                          $('#profile_img').modal('hide');

                          // get image row id to change image when success

                          $('.profile_img').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 profile image

     //start edit password

    $("#EditPassword").submit(function(){

         var formData = $(this).serialize();

         var allData  = formData + "&action=editPass";

                $.ajax({

                    url: "<?php echo BASE_URL."admin/update_password"; ?>",

                    type:"POST",

                    data: allData, // Data sent to server, a set of key/value pairs (i.e. form fields and values)

                    beforeSend:function(){

                    },

                    statusCode: {

                     404: function() {

                       alert( "page not found" );

                      },

                      },

                      success:function(valdata) {

                          //alert(valdata);

                         var da = jQuery.parseJSON(valdata);

                          //alert("")

						  if(da['status'] == "success")

						  {

							$("#updatePasswordResult").html(da['message']);

							setTimeout(function(){$('#changepassword').modal('hide');}, 2000);

						  }else{

							 $("#updatePasswordResult").html(da['message']); 

						  }

                      }

                });

                return false;

             });

    //end edit password



});

</script>