<div class="mt2cms2-c-l">
    <div class="page-hd" style="background-image: url(<?php print $site_url; ?>images/user.png)">
        <div class="bd-c">
            <div id='page_title'><?php print $lang['my-account']; ?></div>
			<?php $account_name = getAccountName($_SESSION['id']); ?>
        </div>
    </div>
	<div id="page_content">
		<?php
			if(isset($_POST['delete-code']))
			{
				$alt_message = $lang['delete-chars'];
				$subject = $lang['delete-chars'];
				$sendName = $account_name;
				$sendEmail = $myEmail;
				$code = getAccountSocialID($_SESSION['id']);
				
				$html_mail = sendCode($account_name, $code);
				include 'include/functions/sendEmail.php';
				
				print '<div class="alert alert-success alert-dismissible fade in" role="alert">
							<button type="button" class="close" data-dismiss="alert" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>';
				print $lang['sended-code'];
				print '</div>';
			} else if(isset($_POST['storekeeper-code']))
			{
				$code = getPlayerSafeBoxPassword($_SESSION['id']);
				
				if($code!='' && $code!='000000')
				{
					$alt_message = $lang['storekeeper'];
					$subject = $lang['storekeeper'];
					$sendName = $account_name;
					$sendEmail = $myEmail;
					$html_mail = sendCode($account_name, $code, 2);
					include 'include/functions/sendEmail.php';
					
					print '<div class="alert alert-success alert-dismissible fade in" role="alert">
								<button type="button" class="close" data-dismiss="alert" aria-label="Close">
									<span aria-hidden="true">&times;</span>
								</button>';
					print $lang['sended-code'];
					print '</div>';
				} else
				{
					print '<div class="alert alert-danger alert-dismissible fade in" role="alert">
								<button type="button" class="close" data-dismiss="alert" aria-label="Close">
									<span aria-hidden="true">&times;</span>
								</button>';
					print $lang['no-storekeeper'];
					print '</div>';
				}
			} else if(!$delete_account && isset($_POST['delete-account']))
			{
				$code = generateSocialID(32);
				update_deletion_token($_SESSION['id'], $code);
				
				$code = '<br><br><a href="'.$site_url.'user/delete/'.$code.'" target="_blank" style="display: inline-block; color: #ffffff; background-color: #3498db; border: solid 1px #3498db; border-radius: 5px; box-sizing: border-box; cursor: pointer; text-decoration: none; font-size: 14px; font-weight: bold; margin: 0; padding: 12px 25px; text-transform: capitalize; border-color: #3498db;">'.$lang['delete-account'].'</a>';
				
				$alt_message = $lang['delete-account'];
				$subject = $lang['delete-account'];
				$sendName = $account_name;
				$sendEmail = $myEmail;
				$html_mail = sendCode($account_name, $code, 3);
				include 'include/functions/sendEmail.php';
					
				print '<div class="alert alert-success alert-dismissible fade in" role="alert">
							<button type="button" class="close" data-dismiss="alert" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>';
				print $lang['sended-code'];
				print '</div>';
			} else if(isset($_POST['change-password']))
			{
				$code = generateSocialID(32);
				update_passlost_token_by_email($myEmail, $code);
				
				$code = '<br><br><a href="'.$site_url.'user/password/'.$code.'" target="_blank" style="display: inline-block; color: #ffffff; background-color: #3498db; border: solid 1px #3498db; border-radius: 5px; box-sizing: border-box; cursor: pointer; text-decoration: none; font-size: 14px; font-weight: bold; margin: 0; padding: 12px 25px; text-transform: capitalize; border-color: #3498db;">'.$lang['change-password'].'</a>';
				
				$alt_message = $lang['password'];
				$subject = $lang['password'];
				$sendName = $account_name;
				$sendEmail = $myEmail;
				$html_mail = sendCode($account_name, $code, 4);
				include 'include/functions/sendEmail.php';
					
				print '<div class="alert alert-success alert-dismissible fade in" role="alert">
							<button type="button" class="close" data-dismiss="alert" aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>';
				print $lang['sended-code'];
				print '</div>';
			}
		?>

				<table class="table table-striped table-hover">
					<tbody><tr>
						<td colspan="2"><img src="<?php print $site_url; ?>images/interfata/default-avatar.jpg" width="150" class="user-avatar" style="float: none !important;"></td>
					</tr>
					<tr style="height:51px;">
						<td style="color:#f6fba7;width: 50%;text-align:left;"><p><?php print $lang['user-name']; ?>: </p></td><td style="text-align:left;"><?php print $account_name; ?><p></p></td>
					</tr>
					<tr style="height:51px;">
						<td style="color:#f6fba7;width: 50%;text-align:left;"><p><?php print $lang['email-address']; ?>: </p></td><td style="text-align:left;"><?php print $myEmail; ?><p></p></td>
					</tr>
					<tr style="height:51px;">
						<td style="color:#f6fba7;width: 50%;text-align:left;"><p><img src="<?php print $site_url; ?>images/md.png"> <?php print $lang['md']; ?>: </p></td><td style="text-align:left;"><?php print getAccountMD($_SESSION['id']); ?><p></p></td>
					</tr>
					<tr style="height:51px;">
						<td style="color:#f6fba7;width: 50%;text-align:left;"> <p><img src="<?php print $site_url; ?>images/jd.png"> <?php print $lang['jd']; ?>: </p></td><td style="text-align:left;"><?php print getAccountJD($_SESSION['id']); ?><p></p></td>
					</tr>
				</tbody></table>

				<table class="table table-striped table-hover">
					<thead class="thead-inverse">
						<tr>
							<th colspan="2">Manage your account.</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td><?php print $lang['change-email']; ?></td>
							<td><form action="<?php print $site_url; ?>user/email">
							<input class="btn btn-primary btn-lg special-btn" type="submit" value="&raquo; <?php print $lang['change-email']; ?>">
							</form></td>
						</tr>

						<tr>
							<td><?php print $lang['chars-list']; ?></td>
							<td><form action="<?php print $site_url; ?>user/characters">
								<input class="btn btn-primary btn-lg special-btn" type="submit" value="&raquo; <?php print $lang['chars']; ?>">
							</form></td>
						</tr>

						<tr>
							<td><?php print $lang['change-password']; ?></td>
							<td><form action="" method="post">
								<input type="submit" name="change-password" class="btn btn-primary btn-lg special-btn" onclick="return confirm('<?php print $lang['sure_send?']; ?>')" value="&raquo; <?php print $lang['password']; ?>" />
							</form></td>
						</tr>

						
							<tr><td><?php print $lang['request-storekeeper']; ?></td>
							<td><form action="" method="post">
								<input type="submit" name="storekeeper-code" class="btn btn-primary btn-lg special-btn" onclick="return confirm('<?php print $lang['sure_send?']; ?>')" value="&raquo; <?php print $lang['storekeeper']; ?>" />
							</form></td>
						</tr>
						<tr>
							<td><?php print $lang['delete-chars']; ?></td>
							<td><form action="" method="post">
								<input type="submit" name="delete-code" class="btn btn-primary btn-lg special-btn" onclick="return confirm('<?php print $lang['sure_send?']; ?>')" value="&raquo; <?php print $lang['send']; ?>" />
							</form></td>
						</tr>
						<?php if(!$delete_account) { ?>
						<tr>
							<td><?php print $lang['delete-account']; ?></td>
							<td><form action="" method="post">
								<input type="submit" name="delete-account" class="btn btn-danger btn-lg special-btn" onclick="return confirm('<?php print $lang['sure_send?']; ?>')" value="&raquo; <?php print $lang['delete-account']; ?>" />
							</form></td>
						</tr>
						<?php } else { ?>
						<tr>
							<?php
								$date1=date_create($delete_account['date']);
								$date2=date_create(date('Y-m-d'));
								$diff=date_diff($date1,$date2);
								$time_delete = intval($diff->format("%R%a"));
							?>
							<td><?php if($time_delete < 0) print $lang['time-until-deletion'].' '.($time_delete*(-1)).' '.$lang['days']; else print $lang['time-to-deletion']; ?></td>
							<td><form action="" method="post">
								<input type="submit" name="cancel-delete-account" class="btn btn-warning btn-lg special-btn" value="<?php print $lang['cancel-delete-account']; ?> &raquo;" />
								<input type="submit" name="delete-account" class="btn btn-danger btn-lg special-btn" onclick="return confirm('<?php print $lang['sure_send?']; ?>')" value="&raquo; <?php print $lang['delete-account']; ?>" />
							</form></td>
						</tr>
						<?php } ?>
					</tbody>
				 </table>
	</div>
</div>