<script type="text/javascript">
  function showMessage(status, client_id) {
    if (status == 1) {
        $title = 'Great !!';
        $message = 'USER UPDATED SUCCESSFUL';
        $type = 'success';
    } else {
        $title = 'Opps...';
        $message = 'Error in adding user. Please try again';
        $type = 'error';
    }
    swal({
        title: $title,
        text: $message,
        type: $type,
        showCancelButton: false,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "OK"
    },
    function() {
        if (status == 1) {
            window.location.href = http_host + '?page=user_management/user-profile.php';
        } else {
            window.location.href = http_host + '?page=user_management/user-profile.php';
        }
    });
  }
</script>
<?php 
  $sqlcon="SELECT * FROM users WHERE id='".$_SESSION['user_detail']['id']."'";
  $cat_que=mysqli_query($conn,$sqlcon);
  $cat_row=mysqli_fetch_array($cat_que,MYSQLI_BOTH);

  if (isset($_REQUEST['update'])){
    $name               = $_REQUEST['name'];
    $email              = $_REQUEST['email'];
    $mobile             = $_REQUEST['mobile'];
    $updated_datetime   = date('Y-m-d H:i:s');
    $updated_id         =$_SESSION['user_detail']['id'];
    
    $update_mail = "UPDATE users SET name='$name',email='$email',mobile='$mobile',updated_id='$updated_id',updated_datetime='$updated_datetime' WHERE id='".$_SESSION['user_detail']['id']."'";
    $update_mail=mysqli_query($conn,$update_mail);
     
    if($update_mail){ 
      echo "<script type='text/javascript'> showMessage(1, 1); </script>";
    } else {
      echo "<script type='text/javascript'> showMessage(0, 0); </script>";
    }
  }
?>
<section class="content-header hitz-braed-crumb">
    <h1 class="hitz-border">user profile</h1>
    <ol class="breadcrumb">
      <a class="btn btn-sm btn-primary btn-create btn hitz-bread-btn" href="index.php?page=user_management/user-profile.php">&nbsp; BACK</a>
    </ol>
</section>
<section style="margin-top: 30px;">
   <div class="row">
      <div class="col-xs-12">
         <div class="box box-success">
            <div class="box-body table-responsive no-padding">
                <form role="form" method="post">
                  <table class="table table-hover">
                    <tbody>
                       <tr>
                          <th>NAME</th>
                          <td><input class="form-control" placeholder="Please enter the name" type="text" name="name" value="<?php echo $cat_row['name'];?>"</td>
                       </tr>
                       <tr>
                          <th>E-MAIL</th>
                          <td><input class="form-control" placeholder="Please enter the name" type="text" name="email" value="<?php echo $cat_row['email'];?>"></td>
                       </tr>
                       <tr>
                          <th>PHONE</th>
                          <td><input class="form-control" placeholder="Please enter the name" type="text" name="mobile" value="<?php echo $cat_row['mobile'];?>"></td>
                       </tr>
                       <tr>
                          <td colspan="2" align="center">
                             <button name="update" class="btn btn-primary capital"> Update Profile</button>
                          </td>
                       </tr>
                    </tbody>
                  </table>
                </form>
            </div>
         </div>
      </div>
   </div>
</section>
<script type="text/javascript">
  $(document).ready(function() {
    $('input').iCheck({
        checkboxClass: 'icheckbox_flat',
        radioClass: 'iradio_flat'
    });
    $('#role_id').select2();
    $("#checkAll").click(function() {
        $('input:checkbox').not(this).prop('checked', this.checked);
    });
  });
</script>

   
