<?php
  require_once("../../session_check.php");
	require_once("../../../classes/main_classes.php");

	//OBJECTS
	$retrieveObj=new RETRIEVE();

	
	$get_user=$retrieveObj->retriever("users","*","user_id",$user_id,"fetch");
	if($get_user=="1020"){
		die("<p class='alert alert-warning'> Sorry something went wrong, try again later</p>");
	}

  //get user profile picture
  $profile_img=$retrieveObj->retriever("users","photo","user_id",$user_id,"fetch");

?>

<div class="profile-head">
    <div class="d-flex justify-content-between">
        <h5>User Information</h5>
        <a href="#" id="edit_profile_view_btn" onclick="profile_readonly_mode_view()">View Profile</a>
    </div>
    <form class="container-fluid" id="edit_profile_form">
      <div class="row my-2">
          <div class="col-12 col-sm-4 col-md-3 col-lg-2">
              <label class="text-black">Firstname</label>
          </div>
          <div class="col-12 col-sm-8 col-md-9 col-lg-10">
              <input class="form-control" type="text" name="firstname" value="<?php echo $get_user->firstname ;?>"/>
          </div>
      </div>
      <div class="row my-2">
          <div class="col-12 col-sm-4 col-md-3 col-lg-2">
              <label class="text-black">Lastname</label>
          </div>
          <div class="col-12 col-sm-8 col-md-9 col-lg-10">
             <input class="form-control" type="text" name="lastname" value="<?php echo $get_user->lastname ;?>"/>
          </div>
      </div>
      <div class="row my-2">
          <div class="col-12 col-sm-4 col-md-3 col-lg-2">
              <label class="text-black">Username</label>
          </div>
          <div class="col-12 col-sm-8 col-md-9 col-lg-10">
               <input class="form-control" type="text" name="username" value="<?php echo $get_user->username ;?>"/>
          </div>
      </div>
      <div class="row my-2">
          <div class="col-12 col-sm-4 col-md-3 col-lg-2">
              <label class="text-black">Email</label>
          </div>
          <div class="col-12 col-sm-8 col-md-9 col-lg-10">
              <input class="form-control" type="email" name="email" value="<?php echo $get_user->email ;?>"/>
          </div>
      </div>
      <div id="edit_profile_response"></div>
      <div class="row mt-3 mb-2">
          <div class="col-md-12">
              <input type="hidden" name="update_profile_note">
              <button class="btn btn-primary btn-block" onclick="update_profile()" type="submit"><span class="fas fa-edit"></span> Update</button>
          </div>
      </div>
    </form>
</div>