<?php
	include('/var/www/html/uclit/protected/common/login/check.php'); 
 	include('/var/www/html/uclit/protected/common/css_login/css_head2.php');
	include('/var/www/html/uclit/protected/connections/db_arlstats.php');

	@ob_start();

	echo"<h1>Display Adjustment Report</h1>";
	//process 1
		
	$atLeastOnce = "false";
	$atLeastOnce2 = "false";
	$total = 0;
	$where = "";
	
	
/*-----------------------------------------------------
Purpose: tally up total records and sum of values of the selected item from previous screen
-------------------------------------------------------*/
	$db = mysql_select_db('arlstats', $arlConn) or die ("Unable to select arlstats database.");
		
	$count_add = "Select Sum(Current_Adjustments.AdjVal)
From Current_Adjustments
Where Current_Adjustments.AdjYear = '2008'";
	$add_result = @mysql_query($count_add, $arlConn) or die ("Unable to query: $count_add");
	//echo "<br />Net Adjustment: ";
	$add_total = @mysql_result($add_result,0);
	//echo $add_total;

	//close cell and table
	

/*----------------------------------------------------
Purpose: querry and display in a table format for all recorded items that fit the cateria
-----------------------------------------------------*/
	$curr_status = "Select Current_Adjustments.AdjID, Current_Adjustments.AdjDesc, Current_Adjustments.AdjVal, Current_Adjustments.AdjPer, Current_Adjustments.AdjDate, Current_Adjustments.AdjYear
From Current_Adjustments
Where Current_Adjustments.AdjYear = '2008'";
		
	$curr_result = @mysql_query($curr_status, $arlConn) or die ("Unable to query: $curr_status");
	
	$export = "Select AdjID, AdjDesc, AdjVal, AdjPer, AdjDate, AdjYear From Current_Adjustments Where AdjYear = 2008";

	//display the heads of the table
?>
	 <table border = '0' width='100%' cellspacing ='10' >
            <tr>
            <?php
            echo"<td align = 'center' width='25%'> <br />Net Adjustment: $add_total </td><td align = 'center'></td></tr>";
            
            ?>
            <tr>
            <td align = 'center'>
            <FORM id='form2' name='form2' method='Post' ACTION='http://ul.uc.edu/uclit/protected/assocdean/collstats/export.php'>
			<INPUT name='Submit' type='submit' id='Submit' value='Export to Excel' />
            <INPUT name='saveWord' type='hidden' id='saveWord' value='2' />
			<INPUT name='current_status' type='hidden' id='current_status' value='<?php echo"$export"; ?>' />
            </FORM></td>
            </tr>
            </table>
	<form id='result' name='result' action='0' method='POST'>
		<table border='1' width='100%' class="sortable" id="maintable">
			<tr>
				<td width='20%' align='center'><strong>Desciption</strong></td>
				<td width='20%' align='center'><strong>Value</strong></td>
				<td width='20%' align='center'><strong>Username</strong></td>
				<td width='20%' align='center'><strong>Date Adjusted</strong></td>
				<td width='20%' align='center'><strong>Year</strong></td>
				<td width='20%' align='center'><strong>Delete</strong></td>
			</tr> 	
<?
	while($curr_row = @mysql_fetch_array($curr_result))
	{	
		$adjid = $curr_row['AdjID'];
		$adjdesc = $curr_row['AdjDesc'];
		$adjvalue = $curr_row['AdjVal'];
		$adjuser = $curr_row['AdjPer'];
		$adjdate = $curr_row['AdjDate'];
		$adjyear = $curr_row['AdjYear'];
		
		echo "<tr>";
		echo "<td width='20%' align='right'>$adjdesc</td>";
		echo "<td width='20%' align='right'>$adjvalue</td>";
		echo "<td width='20%' align='right'>$adjuser</td>";
		echo "<td width='20%' align='right'>$adjdate</td>";
		echo "<td width='20%' align='right'>$adjyear</td>";
		echo "<td align='center'><a href='http://ul.uc.edu/uclit/protected/assocdean/collstats/del_arl_adj_2008.php?statid=$adjid'><img src='delete.gif' border='0'></a></td>";

		}
		echo "</tr>";
	
		
	echo "</table></BR>";
 echo"<a href='http://ul.uc.edu/uclit/protected/assocdean/collstats/arl_report_adj_2008.php'>Return to ARL 2007 Adjustments</a>";
	require ("/var/www/html/uclit/protected/common/css_login/css_foot2.php"); 
?>