<?php
 /**
  * Edit account details
  */
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}

 global $fbbttm_helperobj;

 $fname = $lname = $email = $displayname ='';


 $currentuserid = get_current_user_id();


 $userdata = $fbbttm_helperobj->fbbttm_get_user_info($currentuserid);

 $displayname = $userdata->display_name;

 $userid = $userdata->ID;

 $email = $userdata->user_email;

 $fristname = get_user_meta( $currentuserid ,'first_name');
 $lastname =  get_user_meta( $currentuserid ,'last_name');
 $nickname =  get_user_meta( $currentuserid ,'nickname');

 $delivarydata = $fbbttm_helperobj->fbbttm_comman_single_tableinfo(FBBTTM_DELIVERY_ADDRESS,'fbbttm_user_id',$userid);



if(!empty($fristname))
	{
		$fname = $fristname[0];
	}

if(!empty($lastname))
	{
		$lname = $lastname[0];
	}

if(!empty($nickname))
	{
		$nname = $nickname[0];
	}

if(!empty($delivarydata))	
	{
		$fname = $delivarydata[0]->fbbttm_first_name;
		$lname = $delivarydata[0]->fbbttm_last_name;
	}
 
?>

<div class="editaccountcontent fbbttm-myaccountcontent" id="editaccountcontent">
<h3><?php echo esc_html__('Account details','foodboxbooker');?></h3>
<div id="result_editaccount">
	<div class="successcontent">
	</div>
 </div>
<form name="edit-account" id="edit-account" method="post">
	<?php
	 	// Noncename needed to verify where the data originated
    	wp_nonce_field( 'fbbttm_meta_box_nonce', 'fbbttm_meta_box_noncename' );
	?>
    <div class="row">
	    <div class="col-md-6">
			<label><?php echo esc_html__('First Name *','foodboxbooker');?></label>
			<input type="text" name="fbbttm-fname" value="<?php echo  esc_html(!empty($fname)? $fname: '');?>" class="input-text" required>
			<div class="fbbttm-error fbbttmacountfname"></div>
		</div>

		<div class="col-md-6">
			<label><?php echo esc_html__('Last Name *','foodboxbooker');?></label>
			<input type="text" name="fbbttm-lname" value="<?php echo  esc_html(!empty($lname)? $lname: '');?>" class="input-text" required>
			<div class="fbbttm-error fbbttmacountlname"></div>

		</div>
	</div>
	<div class="row">
		<div class="col-md-6">
			<label><?php echo esc_html__('Display Name *','foodboxbooker');?></label>
			<input type="text" name="fbbttm-dname" value="<?php echo  esc_html((!empty($displayname)? $displayname: ''));?>" class="input-text" required>
			<div class="fbbttm-error fbbttmacountdname"></div>
		</div>
		<div class="col-md-6">
			<label><?php echo esc_html__('email *','foodboxbooker');?></label>
			<input type="text" name="fbbttm-email" value="<?php echo  esc_html((!empty($email)? $email: ''));?>" class="input-text" required>
			<div class="fbbttm-error fbbttmacountemail"></div>
		</div>
	</div>

 <fieldset>
	<legend><?php echo esc_html__('Password Change','foodboxbooker');?></legend>
	<div class="fbbttm-password-box">
		<div class="row">
			<label><?php echo esc_html__('Current password','foodboxbooker');?></label>
			<input type="password" class="input-password input-text" name="password_current" id="password_current" autocomplete="off">
			<div class="fbbttm-error fbbttmacountpassword"></div>
		</div>
		<div class="row">
			<label><?php echo esc_html__('New password','foodboxbooker');?></label>
			<input type="password" class="input-password input-text" name="password_1" id="password_1" autocomplete="off">
			<div class="fbbttm-error fbbttmanewpassword"></div>
		</div>
		<div class="row">
			<label><?php echo esc_html__('Confirm new password','foodboxbooker');?></label>
			<input type="password" class="input-password input-text" name="password_2" id="password_2" autocomplete="off">
			<div class="fbbttm-error fbbttmanewpassword2"></div>
		</div>
	</div>
	 <div class="row fbbttm-password-btn">
		<input type="hidden" name="fbbttm-userid" id="fbbttm-userid-account" value="<?php echo esc_html($userid);?>">
		<input type="submit" name="fbbttm-editsubmit" id="fbbttm-editsubmit" value="<?php echo esc_html__('Submit','foodboxbooker');?>" class="input-submit">
		<div class="fbbttm-error php-error"></div>
		<div class="fbbttm-loader hide"></div> 
	 </div>
  </fieldset>
 </form>
</div> 