<?



### TRIGGERS:
//$action_links = "OFF"; // if it's not 'OFF'... then it's ON
//$member_only = "ON"; // if it's not 'ON' then it's OFF

$activeaccount_colspan = "2";


### GET ACCOUNT BALANCE/VALUE:
$_SESSION['balance'] = $balance = balance($_SESSION['account']['accountid']);

//test("_SESSION['balance']",$_SESSION['balance']);
//logger3("account['accountid']",$_SESSION['account']['accountid']);



### NO ACCOUNT SET YET:
if(strtoupper($members_only) == "ON") {

	echo "
	<tr>
		<td class='TABLE_IX_i_activeaccount_td_1'>
			
			<nobr>
				<span class='TABLE_IX_i_activeaccount_text_1'>
    				Active&nbsp;Member:&nbsp;&nbsp;<span style='color:#008800;'>" . $_SESSION['member']['firstname'] . " " . $_SESSION['member']['lastname'] . "</span>
    			</span>
    		</nobr>
    	
  		</td>
		<td class='TABLE_IX_i_activeaccount_td_2'>
		
			<nobr>
				<span class='TABLE_IX_i_activeaccount_text_5'>
			
		   		</span>
			</nobr>
		
		</td>
	</tr>

	<tr>
		<td colspan='" . $activeaccount_colspan . "' class='TABLE_IX_i_activeaccount_td_3'>
";


} else if($active_account_display == "payme_receipt") {

	echo "
	<tr>
	
		<td class='TABLE_IX_i_activeaccount_td_1'>
			<nobr>
				<span class='TABLE_IX_i_activeaccount_text_1'>";
				
					if($_SESSION['payme']["customer"] == "New") {
    					echo "Your <span style='color:#8536E4; text-decoration:underline;'>NEW</span> " . $_SESSION['template']['company']['domain'] . " Account:";
    				} else {
    					echo "Your Account:";
    				}
    				echo "
    				</span>
     				<span class='TABLE_IX_i_activeaccount_text_2'>
    					" . $_SESSION['account']["accountname"] . "&nbsp;   	
		    		</span>
						<span class='TABLE_IX_i_activeaccount_text_4'>
		   				&nbsp;(" . $_SESSION['account']['emailaddress'] . ")
		   			</span>
		    	</nobr>
		  	</td>
		  	
		  	<td class='TABLE_IX_i_activeaccount_td_2'>
		  		<nobr>";
		
		  	
		  		echo "
			
			    <span class='TABLE_IX_i_activeaccount_text_5'>
		   	    	Your Balance:&nbsp;
			    </span>";
		
			    if($_SESSION['account']["currency_translation"] == "On") {
		
		
		
			    	if($active_account_display == "payme_receipt") {
			
			    		echo "
			    		<span class='TABLE_IX_i_activeaccount_text_8'>
		   	    		(" . $_SESSION['account']['currency_code_1'] . "&nbsp;" . currency_format(get_fx($_SESSION['template']['company']['currency1'], $_SESSION['account']['currency_code_1'], $_SESSION['balance']['balance']['account']),",") . ")&nbsp;
			    		</span>
			    		<span class='TABLE_IX_i_activeaccount_text_6'>
			    			" . $_SESSION['template']['company']['currency1'] . "&nbsp;" . currency_format($_SESSION['balance']['balance']['account'],",") . "
		   	    		</span>";
			
			    	} else {
			
			    		echo "
			    		<span class='TABLE_IX_i_activeaccount_text_8'>
			    		(";
			    		if(strtoupper($action_links) != "OFF") {
		   	    			echo "<a href='" . $http . $_SESSION['template']['company']['host_www'] . "/edit_currency_translation_1.b!'>";
		   	    			// echo "<img src='" . image($http,"links_8px_v6_ani.gif") . "' border=0>&nbsp;";
		   	    			//echo "<img src='" . image($http,"icon_pencil_b+w_2_12px.png") . "' border=0>&nbsp;";
		   	     
		   	    		}
		   	    		echo $_SESSION['account']['currency_code_1'] . "&nbsp;" . currency_format(get_fx($_SESSION['template']['company']['currency1'], $_SESSION['account']['currency_code_1'], $_SESSION['balance']['balance']['account']),",");
		   	    
		   	    	if(strtoupper($action_links) != "OFF") {
		   	    		echo "</a>";
		   	    	}
		   	    
		   	    	echo ")&nbsp;
			    	</span>
			    	<span class='TABLE_IX_i_activeaccount_text_6'>
			    		" . $_SESSION['template']['company']['currency1'] . "&nbsp;" . currency_format($_SESSION['balance']['balance']['account'],",") . "
		   	    	</span>";
			
				}
			
			} else {
		
		
				if($active_account_display == "payme_receipt") {
			
					echo "
				
		   			<span class='TABLE_IX_i_activeaccount_text_6'>
		   				&nbsp;" . $_SESSION['template']['company']['currency1'] . "&nbsp;" . currency_format($_SESSION['balance']['balance']['account']) . "
		   			</span>";
			
				} else {
			
					echo "<span class='TABLE_IX_i_activeaccount_text_6'>";
		   		
					if(strtoupper($action_links) != "OFF") {
		   			echo "<a href='" . $http . $_SESSION['template']['company']['host_www'] . "/edit_currency_translation_1.b!'>";
		   			//echo "<img src='" . image($http,"links_8px_v6_ani.gif") . "' border=0>&nbsp;";
		   			//echo "<img src='" . image($http,"icon_pencil_b+w_2_12px.png") . "' border=0>&nbsp;";
		   			echo $_SESSION['template']['company']['currency1'] . "&nbsp;";
		   		}
		   		
		   		echo currency_format($_SESSION['balance']['balance']['account']);
		   		
		   		if(strtoupper($action_links) != "OFF") {
		   			echo "</a>";
		   		}
		   	
		   		echo "</span>";
			
			}
			
		}

		echo "
		</nobr>
	</td>

</tr>
	
<tr>
	
	<td colspan='" . $activeaccount_colspan . "' class='TABLE_IX_i_activeaccount_td_3'>";



### NORMAL/DEFAULT:
} else if($_SESSION['account']['accountid']) {



	

	echo "

<style>
.edit_payme {
	text-decoration:none;
	font-family:verdana;
	font-size:11px;
	font-weight:normal;
	color:#888888;
}

.edit_payme A {
	text-decoration:none;
	font-family:verdana;
	font-size:11px;
	font-weight:normal;
	color:#888888;
}

.edit_payme A:HOVER {
	text-decoration:underline;
	font-family:verdana;
	font-size:11px;
	font-weight:normal;
	color:#888888;
}
</style>


<tr>

	<td class='TABLE_IX_i_activeaccount_td_1'>
		
		<nobr>
		
			<span class='TABLE_IX_i_activeaccount_text_1' style='font-size:11px;'>";
				
				//logger3("_SESSION['session']['permissions']['accounttype']",$_SESSION['session']['permissions']['accounttype']);
				
				if($_SESSION['session']['permissions']['accounttype'] == "Shared") {
					echo "Active&nbsp;Account&nbsp;(SHARED):&nbsp;";
				} else {
					echo "Active&nbsp;Account:&nbsp;";
				}
				
			echo "
    	</span>";
    	
    	$display_account_name = $_SESSION['account']['accountname'];
    	if(stristr($_SESSION['account']['accounttype'],"BUSINESS")) $display_account_name .= "&nbsp;" . $_SESSION['account']['business_type'];
     	
     	
     	echo "<span class='TABLE_IX_i_activeaccount_text_2' style='font-size:11px;'>" . $display_account_name . "</span>";

	 	
	 	$active_account_emailaddress = ""; // $_SESSION['account']['emailaddress']
	 	if(!empty($active_account_emailaddress)) {
	 		echo "<span class='TABLE_IX_i_activeaccount_text_8' style='font-size:11px;'>&nbsp;(<a href='/view_business_identity_1.b!'>" . $_SESSION['account']['emailaddress'] . "</a>)</span>";
	 	} else {
		 		
		 	echo "<span class='TABLE_IX_i_activeaccount_text_8' style='font-size:11px;'>&nbsp;(<a href='/view_business_identity_1.b!'>Click to Edit</a>)</span>";
	 	}
	 	



echo "&nbsp;&nbsp;</nobr>
  </td>
  
<style>
.available_balance {
	text-decoration:none;
	font-family:verdana;
	font-size:10px;
	font-weight:bold;
	color:#4F1F7A;
}

.available_balance A {
	text-decoration:none;
	font-family:verdana;
	font-size:10px;
	font-weight:bold;
	color:#4F1F7A;
}

.available_balance A:HOVER {
	text-decoration:underline;
	font-family:verdana;
	font-size:10px;
	font-weight:bold;
	color:#4F1F7A;
}
</style>

<style>
.account_balance {
	text-decoration:none;
	font-family:verdana;
	font-size:11px;
	font-weight:bold;
	color:#000000;
}

.account_balance A {
	text-decoration:none;
	font-family:verdana;
	font-size:11px;
	font-weight:bold;
	color:#000000;
}

.account_balance A:HOVER {
	text-decoration:underline;
	font-family:verdana;
	font-size:11px;
	font-weight:bold;
	color:#000000; 
}
</style>

<style>
.available_translation {
	text-decoration:none;
	font-family:verdana;
	font-size:11px;
	font-weight:bold;
	color:#444444;
}

.available_translation A {
	text-decoration:none;
	font-family:verdana;
	font-size:11px;
	font-weight:bold;
	color:#444444;
}

.available_translation A:HOVER {
	text-decoration:underline;
	font-family:verdana;
	font-size:11px;
	font-weight:bold;
	color:#444444; 
}
</style>

<style>
.account_balance_total {
	font-family:verdana,arial,helvetica,sans-serif;
	font-size:13px;
	font-weight:bold;
	text-decoration:none;
	color:#008800;
}
</style>
	<td class='TABLE_IX_i_activeaccount_td_2' align='right'>";
	


#################################################################################
###### START BALANCE TABLE ######################################################

//test("1__SESSION['account']['emailaddress']",$_SESSION['account']['emailaddress']);

/// START permision to view balance
if(
(in_array("view_balance",$_SESSION['session']['permissions']['permissions'])) ||
(strtoupper($_SESSION['session']['permissions']['permissions']) == "MASTER")
) {
	
	//test("2__SESSION['account']['emailaddress']",$_SESSION['account']['emailaddress']);


	### MULTI-CURRENCY TRANSLATION "ON" ###########################################
	if(multicurrency()) {
		
		echo "
		<table cellpadding='0' cellspacing='0' border='0' style='text-align:right;'>
			<tr>
				<td>
					<span class='account_balance'>";
								
						//echo "<nobr><a href='javascript:openSUPPORT(" . $blank_id . ");'>" . display_image('popup.png',$vertical_align) . "&nbsp;Available Balance:</a>&nbsp;&nbsp;</nobr>";
									
						echo "<nobr>";
						
						//test("_SESSION['template']['company']['name']",$_SESSION['template']['company']['name']);
						//test("_SESSION['account']['business_subcategory']",$_SESSION['account']['business_subcategory']);
						
						if(
						(stristr($_SESSION['account']['business_subcategory'],"GATEWAY"))
						) {
						
						
							$tmp_balance_description = "Balance Due:";
						
						
						} else if(
						(stristr($_SESSION['account']['accounttype'],"BUSINESS"))
						) {
							$tmp_balance_description = "ACCOUNT Balance:";
						} else {
							$tmp_balance_description = "LOADED Balance:";
						}
						echo $tmp_balance_description;
						
						echo "</nobr>";
								
					echo "
					</span>
				</td>";
				
				### FX TRANSLATION:
				echo "
				
				<td>
					<nobr>
						<span class='available_translation'  style='padding-right:3px; padding-left:5px;'>&nbsp;&nbsp;(";
			
			  				if(strtoupper($action_links) != "OFF") {
			   					echo "<a href='" . $http . $_SESSION['template']['company']['host_www'] . "/edit_currency_translation_1.b!'>";
			   					//echo "<img src='" . image($http,"links_8px_v6_ani.gif") . "' border=0>&nbsp;";
			   					//echo "<img src='" . image($http,"icon_pencil_b+w_2_12px.png") . "' border=0>&nbsp;";
			   				}
			   				//test("_SESSION['balance']",$_SESSION['balance']);
							echo $_SESSION['account']['currency_code_1'] . "&nbsp;" . currency_format(get_fx($_SESSION['template']['company']['currency1'], $_SESSION['account']['currency_code_1'], $_SESSION['balance']['account_balance']),",");
				
							if(strtoupper($action_links) != "OFF") {
								echo "</a>";
			   				}
			   				
			   				echo ")&nbsp;&nbsp;
			   			</span>
					</nobr>
				</td>";
				
				
				
				
				### BALANCE:
				echo "
				<td style='padding-right:3px;'>
					<nobr>
						<span class='account_balance_total'>
							" . $_SESSION['template']['company']['currency1'] . "&nbsp;" . currency_format($_SESSION['balance']['account_balance'],",") . "
			   			</span>
					</nobr>
				</td>
			</tr>";



		//$display_available_balance = FALSE;

		
		if($display_available_balance) {
			include($_SESSION['template']['company']['file_path'] . "shared/display_available_balance.shared");
		}
			
		echo "
		</table>";
	
	
	
	### MULTI-CURRENCY TRANSLATION "OFF" ###########################################
	} else {
	
		echo "
		<table cellpadding='0' cellspacing='0' border='0' style='text-align:right;'>";
				
				
		
		### AVAILABLE BALANCE:			
							
			echo "
			<tr>
				<td>
					<span class='account_balance'>";
					
						//echo "<nobr><a href='javascript:openSUPPORT(" . $blank_id . ");'>" . display_image('popup.png',$vertical_align) . "&nbsp;Available Balance:</a>&nbsp;&nbsp;</nobr>";
								
						echo "<nobr>";

						//test("_SESSION['template']['company']['name']",$_SESSION['template']['company']['name']);
						//test("_SESSION['account']['business_subcategory']",$_SESSION['account']['business_subcategory']);
						
						if(
						(stristr($_SESSION['account']['business_subcategory'],"GATEWAY"))
						) {
						
						
							$tmp_balance_description = "Balance Due:";
						
						
						} else if(
						(stristr($_SESSION['account']['accounttype'],"BUSINESS"))
						) {
							$tmp_balance_description = "ACCOUNT Balance:";
						} else {
							$tmp_balance_description = "LOADED Balance:";
						}
						
						echo $tmp_balance_description;
						
						echo "</nobr>";
						
					//test("_SESSION['balance']",$_SESSION['balance']);
					
						
					echo "
					</span>
				</td>
				<td colspan=2 align='right' style='padding-right:3px; padding-left:5px;'>
					<nobr>
						<span class='account_balance_total'>
							" . $_SESSION['template']['company']['currency1'] . "&nbsp;" . currency_format($_SESSION['balance']['account_balance'],",") . "
		   				</span>
					</nobr>
				</td>
			</tr>";

		if($display_available_balance) {
			include($_SESSION['template']['company']['file_path'] . "shared/display_available_balance.shared");
		}
		
		
		echo "
		</table>";
	}

}
/// END permision to view balance

echo "
	</td>
</tr>
";



}

?>