<?php if(!loggedIn())header('Location: '.$CONFIG['webAddress']); ?>
<?php require 'header.tpl.php';?>
<?php
#TODO 1: Email-Change
#TODO 2: PW-Change
#TODO 3: Charge Points
#TODO 4: Refer a friend
#TODO 5: Redeem
?>
<!-- SUBNAV -->
<div id="subNav">
  <div class="placeholder"><span class="account-title">My Account » Refer A Friend</span></div>
</div>
<!-- end SUBNAV -->
<!-- DONATE BODYAREA -->
<div id="bodyArea">
    <?php require 'account_menu.tpl.php'; ?>
    <div class="right">
      <div class="tab-content">
        <div class="tab-pane active" id="accountSettings">
          <div class="account-placeholder">
            <div class="account-settings">Refer A Friend</div>
				<div class="maincontent">
				  <div class="row">
					<p class="subtitle">My Refer Link:</p>
					<input name="" readonly="" value="<?=$CONFIG['webAddress'].'?RaF='.$USER['sReferCode']?>" type="text" class="redeemcode" style="background-color:#fff;cursor:default;" onclick="this.select();"></input>
					<div class="clear"></div>    
				</div>
				
				<div class="row">
					<p class="title2">What is Refer A Friend?</p>
					<p>Refer-A-Friend program is an easy way to earn rewards. All you have to do is give your friends the link above. You will get RaF Points when someone who registers an account from your link shows activity. The more actively your friend plays, the more points you earn. And it doesn't even stop there. You will also get a percentage of the RaF points your referred friend earns. Sounds awesome, doesn't it?</p>
					
					<p>With RaF points you'll have access to limited offers in our store and special events. Don't want to miss anything? Follow us on twitter, like our Facebook fanpage and subscribe to our Youtube channel!</p>
					<div class="clear"></div>    
				</div>
				
					<div class="row">
						<p class="subtitle">My Referred Members:</p>
					
						<table class="table">
						  <thead>
							<tr>
							  <th>#</th>
							  <th>User</th>
							  <th>Date</th>
							  <th>Activity Points</th>
							</tr>
							<?php
							
							sqlChooseDB($CONFIG['db_accountDB']);
							$rs = sqlsrv_query($CONFIG['db_conn'], 'SELECT * FROM tAccounts WHERE nReferedByEMID = \''.$USER['nEMID'].'\' ORDER BY dDate');
							if(sqlsrv_has_rows($rs))
							{
								$count = 0;
								while($rs2 = sqlsrv_fetch_array($rs, SQLSRV_FETCH_ASSOC))
								{
									$ReferredUser = array();
									foreach($rs2 as $key => $value)
									{
										$ReferredUser[$key] = $value;
									}
									?>
									
									<tr>
									  <th><?=++$count?></th>
									  <th><?=$ReferredUser['sUsername']?></th>
									  <th><?=$ReferredUser['dDate']->format('Y-m-d H:i:s')?></th>
									  <th>0</th>
									</tr>
									
									<?php
									//$count++;
								}
							}
							?>
						  </thead>
						  <tbody>
											
						  </tbody>
						</table>
						<div class="clear"></div>    
					</div>
				</div>
            </div>
		
          </div>
        </div>

      </div>
</div>
<!-- END DONATE BODYAREA -->
<div class="clearfix"></div>
<?php require 'footer.tpl.php';?>