Location: PHPKode > projects > Personal Finance Manager > index.php
<?
/*
	Scryed Labs Financial Manager
	Copyright (c) 2005-2007, Scryed Labs
	http://www.scryedlabs.com
	
	Financial Manager is copyrighted free software by Waheed Ayubi <hide@address.com>.
	You can redistribute it and/or modify it under either the terms of the GPL
	(see COPYING.txt), or the terms of the Artistic License (see README.txt).
	
	http://sourceforge.net/projects/financemonitor/
*/
?>
<?
	# If the user wants to log out then clear the UserID cookie and return him to the index page.
	if ( $_GET['logout'] ) 
	{ 
		setcookie("UserID", ""); 
		header("Location: index.php"); 
		exit;
	}
	
	# If the user hits the index page without a UserID cookie, return him to the login page.
	if ( !$_COOKIE['UserID'] ) 
	{ 
		header("Location: login.php"); 
		exit;
	}

	$debug = 0;
	
	## Script Execution Time
	if ($debug) {
		$mtime = microtime();
		$mtime = explode(" ", $mtime);
		$mtime = $mtime[1] + $mtime[0];
		$starttime = $mtime;
	}
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>Financial Monitor</title>
		
		<?
			# Include the settings file. Contains globals settings.
			include_once ("settings.php");
		
			# Include the adodb connection files. 'adodb_connect.php' contains the settings.
			#include_once ("adodb/adodb.inc.php");
			include_once ("adodb_connect.php");
			
			# Include the php function file.  All php functions are contained within.
			include_once ("functions.php");
			
			# Include the calendar popup javascript toolset
			include_once ("lib/calendarpopup/CalendarPopup.inc.php");
			
			# Set the current screen display month and year.  If no date info has been selected,
			# then set the info from the current date.
			if ($_GET['month']) { $month = $_GET['month']; } else { $month = date("n", time()); }
			if ($_GET['year']) { $year = $_GET['year']; } else { $year = date("Y", time()); }
			$date = returnDate ($month, $year);
			$eom = returnDate ($month, $year, 99);
			$today = date("Y-m-d", time());
			
			# Include the php parsed javascript file.
			include_once('functions.js.php');
		?>
		
		<script type="text/javascript" src="lib/MochiKit-1.3.1/lib/MochiKit/MochiKit.js"></script>
		<script type="text/javascript" src="lib/plotkit-0.9.1/PlotKit/Base.js"></script>
		<script type="text/javascript" src="lib/plotkit-0.9.1/PlotKit/Layout.js"></script>
		<script type="text/javascript" src="lib/plotkit-0.9.1/PlotKit/Canvas.js"></script>
		<script type="text/javascript" src="lib/plotkit-0.9.1/PlotKit/SweetCanvas.js"></script>
		<script type="text/javascript" src="lib/plotkit-0.9.1/PlotKit/excanvas.js"></script>
		
		<style type="text/css" title="currentStyle" media="screen">
			@import "css/default/stylesheet.css";
		</style>
	
		<link rel="shortcut icon" href="img/favicon.ico" />
		
	</head>
	
	<body>
		
		<div id="LogoutLayer">
			<a href="index.php?logout=1">Log Out</a>
		</div>
			
		<?
			# Include the header layer. Includes title and navigation bar.
			include_once( 'layer_header.php' );
			
			# Include the income layer.
			include_once( 'layer_income.php' );
			
			# Include the expenses layer.
			include_once( 'layer_expenses.php' );
		?>
		
		<?
			$sql = "select * from savings_items where userid = '".$_COOKIE['UserID']."' and date = \"".$date."\"";
			$r1 = $conn->Execute ($sql);
			$savings_rate = $r1->fields['rate'];
			$savings_total = number_format(($IncomeTotal * number_format($savings_rate, 2, '.', '') / 100), 2, '.', '');
			if ($r1->fields['deposited']) {
				$deposited = "d";
			} else {
				$deposited = "nd";
			}
		?>
		<div class="ns_parent_title">Savings Rate</div>
		
		<div class="ns_parent"><table cellspacing="0" border="1">
			<tr class="head">
				<td colspan="2" id="<?=$deposited?>"><?
					if ($deposited == "d") {
						print "Deposited";
					} else {
						print "Not Deposited";
					}
				?></td>
			</tr>
			<tr class="buttons">
				<td colspan="2">
					<input type="text" name="savingsrate" id="savingsrate"><input type="button" onclick="setSavingsRate(document.getElementById('savingsrate').value)" id="setsavingsrate" value="Set Savings Rate"><input type="button" id="depositsavings" onclick="depositSavings()" value="Deposit Savings">
				</td>
			</tr>
			<tr class="foot">
				<td class="account">Savings (<?=number_format($savings_rate, 2, '.', '')?>%)</td>
				<td class="amount"><?=$savings_total?></td>
			</tr>
		</table></div>
		<?
			if ($r1->fields['deposited']) {
				print "<script>";
				print "document.getElementById('savingsrate').disabled = true;";
				print "document.getElementById('setsavingsrate').disabled = true;";
				print "document.getElementById('depositsavings').disabled = true;";
				print "</script>";
			}
			$r1->Close();
		?>
		
		<?
			# Include the luxuries layer.
			include_once( 'layer_luxuries.php' );
		?>
		
		<script>
		if (document.getElementById('depositluxuries').disabled == true) {
			document.getElementById('savingsrate').disabled = true;
			document.getElementById('setsavingsrate').disabled = true;
		}
		</script>
		
		<DIV ID="caldiv" STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"></DIV>
		
	</body>
	
	
	<form name="masterform" method="post" action="submit.php" style="margin: 0px;">
	
		<input type="hidden" name="masterlock" value="">
		<input type="hidden" name="date" value="<?=$date?>">
		
		<input type="hidden" name="year" value="<?=$year?>">
		<input type="hidden" name="month" value="<?=$month?>">
		<input type="hidden" name="day" value="1">
		
		<input type="hidden" name="incometotal" value="<?=$IncomeTotal?>">
		<input type="hidden" name="expensestotal" value="<?=$estimated_total?>">
		<input type="hidden" name="expensename" value="">
		<input type="hidden" name="incomename" value="">
		<input type="hidden" name="expenseitemid" value="">
		<input type="hidden" name="expenseitemname" value="">
		<input type="hidden" name="expenseitemestimated" value="">
		<input type="hidden" name="expenseitemactual" value="">
		<input type="hidden" name="incomeitemid" value="">
		<input type="hidden" name="incomeitemname" value="">
		<input type="hidden" name="incomeitemamount" value="">
		<input type="hidden" name="catId" value="">
		<input type="hidden" name="savingsrate" value="<?=$savings_rate?>">
		
		<input type="hidden" name="luxuriestransactionschecked" value="">
		<input type="hidden" name="luxuriestransactionslabel" value="">
		
		<input type="hidden" name="luxuriesfilterschecked" value="" />
		<input type="hidden" name="luxuriesfiltersfilter" value="">
		<input type="hidden" name="luxuriesfilterslabel" value="">
		<input type="hidden" name="luxuriesfiltersuserid" value="">
		
	</form>
	
	
	<?
		include_once ("adodb_disconnect.php");
	?>

</html>

<?

	## Script Execution Time
	if ($debug) {
		$mtime = microtime();
		$mtime = explode(" ", $mtime);
		$mtime = $mtime[1] + $mtime[0];
		$endtime = $mtime;
		$totaltime = ($endtime - $starttime);
		echo "This page was created in ".$totaltime." seconds";
		
		$handle = fopen("execute_time.txt", 'a');
		fwrite($handle, $totaltime."\r\n");
		fclose($handle);
	}

?>
Return current item: Personal Finance Manager