<?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');
		
	// Create our database connection
	$db = mysql_select_db('arlstats', $arlConn) or die ("Unable to select arlstats database.");
	
/*-------------------------------------------------------------
Purpose: Create queries, and variables for all returned values.  Computation of final variable below queries.
-------------------------------------------------------------*/
	
	//Volumes held statistic
	

	$sql_volumes_held = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE ((MID = 1 OR MID = 2 OR MID = 3) AND (CID = 4 or CID=3 or CID=2 or CID=1) AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$volumes_held_result = @mysql_query($sql_volumes_held, $arlConn) or die ("Unable to query: $sql_volumes_held");
	$held_total = @mysql_result($volumes_held_result,0);

	$sql_volumes_widthdrawn = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE ((MID = 1 OR MID = 2 OR MID = 3) AND (CID = 7) AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$volumes_widthdrawn_result = @mysql_query($sql_volumes_widthdrawn, $arlConn) or die ("Unable to query: $sql_volumes_widthdrawn");
	$widthdrawn_total = @mysql_result($volumes_widthdrawn_result,0);
	
	$vol_net = $held_total - $widthdrawn_total;
	//$vol_held_curr_add = 2481085 + $vol_net;
	
	//Microform Result
	$sql_microforms = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 4 AND CID = 4 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$microforms_result = @mysql_query($sql_microforms, $arlConn) or die ("Unable to query: $sql_microforms");
	$microforms_total = @mysql_result($microforms_result,0);
	
	$sql_microforms_widthdrawn = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 4 AND CID = 7 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$microforms_widthdrawn_result = @mysql_query($sql_microforms_widthdrawn, $arlConn) or die ("Unable to query: $sql_microforms_widthdrawn");
	$volume_widthdrawn_total = @mysql_result($volumes_widthdrawn_result,0);
	
	$mi_total = $microforms_total - $volume_widthdrawn_total;
	
	//Computer File Result
	$sql_cfile = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 5 AND CID = 4 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$cfile_result = @mysql_query($sql_cfile, $arlConn) or die ("Unable to query: $sql_cfile");
	$cfile_total = @mysql_result($cfile_result,0);
	
	$sql_cfile_widthdrawn = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 5 AND CID = 7 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$cfile_widthdrawn_result = @mysql_query($sql_cfile_widthdrawn, $arlConn) or die ("Unable to query: $sql_cfile_widthdrawn");
	$cfile_widthdrawn_total = @mysql_result($cfile_widthdrawn_result,0);
	
	$c_total = $cfile_total - $cfile_widthdrawn_total;
	
	//Map Result
	$sql_map = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 6 AND CID = 4 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46)AND SID = 1)";
	$map_result = @mysql_query($sql_map, $arlConn) or die ("Unable to query: $sql_map");
	$map_total = @mysql_result($map_result,0);
	
	$sql_map_widthdrawn = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 6 AND CID = 7 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46)AND SID = 1)";
	$map_widthdrawn_result = @mysql_query($sql_map_widthdrawn, $arlConn) or die ("Unable to query: $sql_map_widthdrawn");
	$map_widthdrawn_total = @mysql_result($map_widthdrawn_result,0);
	
	$ma_total = $map_total - $map_widthdrawn_total;
	
	//2-D Object Result
	$sql_object = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 7 AND CID = 4 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$object_result = @mysql_query($sql_object, $arlConn) or die ("Unable to query: $sql_object");
	$object_total = @mysql_result($volumes_result,0);
	
	$sql_object_widthdrawn = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 7 AND CID = 7 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46)AND SID = 1)";
	$object_widthdrawn_result = @mysql_query($sql_object_widthdrawn, $arlConn) or die ("Unable to query: $sql_object_widthdrawn");
	$object_widthdrawn_total = @mysql_result($object_widthdrawn_result,0);
	
	$o_total = $object_total - $object_widthdrawn_total;
	
	//Sound Recordings Result
	$sql_sound = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 8 AND CID = 4 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$sound_result = @mysql_query($sql_sound, $arlConn) or die ("Unable to query: $sql_sound");
	$sound_total = @mysql_result($sound_result,0);
	
	$sql_sound_widthdrawn = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 8 AND CID = 7 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$sound_widthdrawn_result = @mysql_query($sql_sound_widthdrawn, $arlConn) or die ("Unable to query: $sql_sound_widthdrawn");
	$sound_widthdrawn_total = @mysql_result($sound_widthdrawn_result,0);
	
	$s_total = $sound_total - $sound_widthdrawn_total;
	
	//Projected Medium Result
	$sql_pmedium = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 4 AND CID = 9 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$pmedium_result = @mysql_query($sql_microforms, $arlConn) or die ("Unable to query: $sql_microforms");
	$pmedium_total = @mysql_result($pmedium_result,0);
	
	$sql_pmedium_widthdrawn = "SELECT SUM(Value) AS Total FROM Archive_Stats WHERE (MID = 9 AND CID = 7 AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46) AND SID = 1)";
	$pmedium_widthdrawn_result = @mysql_query($sql_pmedium_widthdrawn, $arlConn) or die ("Unable to query: $sql_pmedium_widthdrawn");
	$pmedium_widthdrawn_total = @mysql_result($pmedium_widthdrawn_result,0);
	
	$p_total = $pmedium_total - $pmedium_widthdrawn_total;
	

	//Adjustments *** (MID1,2,3)(CID1,2,3,4)	
	$sql_govdoc = "SELECT SUM(Value) FROM Archive_Stats WHERE (SID = 3)AND (MID=1 or MID=2 or MID=3) AND (CID = 4 or CID=3 OR CID=2 OR CID=1) AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46)";
	$govdoc_result = @mysql_query($sql_govdoc, $arlConn) or die ("Unable to query: $sql_govdoc");
	$govdoc_total = @mysql_result($govdoc_result,0);
	
	$g_total = 34353 - $govdoc_total;
	$vol_held_curr = $vol_held_curr_add + $g_total;

	
	//get info for last year govdocs retro count
	$sql_lastyearadded = "SELECT SUM(Value) FROM Archive_Stats WHERE (SID = 3) AND (CID = 4 or CID=3 or CID=2 or CID=1) AND (MID = 1 OR MID = 2 OR MID = 3) AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46)";
	$lastyearadded_result = @mysql_query($sql_lastyearadded, $arlConn) or die ("Unable to query: $sql_lastyearadded");
	$lastyearadded_total = @mysql_result($lastyearadded_result,0);

	//get info for adjustments
	$sql_adj = "Select Sum(Archive_Stats.value)From Archive_Stats Where ((Archive_Stats.MID = 1 OR Archive_Stats.MID = 2 OR Archive_Stats.MID = 3) AND(Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '1' OR Archive_Stats.CID = '2' OR Archive_Stats.CID = '3' OR Archive_Stats.CID = '4') AND (Archive_Stats.SID = '4'))";
	$man_result = @mysql_query($sql_adj, $arlConn) or die ("Unable to query: $sql_adj");
	
	$man_add = @mysql_result($man_result,0);
	
	$sql_adj_withdraw = "Select Sum(Archive_Stats.value)From Archive_Stats Where ((Archive_Stats.MID = 1 OR Archive_Stats.MID = 2 OR Archive_Stats.MID = 3) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '7') AND (Archive_Stats.SID = '4'))";
	$man_result_withdraw = @mysql_query($sql_adj_withdraw, $arlConn) or die ("Unable to query: $sql_adj");
	
	$man_withdraw = @mysql_result($man_result_withdraw,0);
	
	$man_total = $man_add - $man_withdraw;
	
	$sql_mi = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 4) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '1' OR Archive_Stats.CID = '2' OR Archive_Stats.CID = '3' OR Archive_Stats.CID = '4') AND (Archive_Stats.SID = '4'))";
	$mi_result = @mysql_query($sql_mi, $arlConn) or die ("Unable to query: $sql_adj");
	
	$mi_add = @mysql_result($mi_result,0);
	
	$sql_mi_withdraw = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 4) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '7') AND (Archive_Stats.SID = '4'))";
	$mi_result_withdraw = @mysql_query($sql_mi_withdraw, $arlConn) or die ("Unable to query: $sql_adj");
	
	$mi_withdraw = @mysql_result($mi_result_withdraw,0);
	
	$mi_adj = $mi_add - $mi_withdraw;
	
	$sql_c = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 5) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '1' OR Archive_Stats.CID = '2' OR Archive_Stats.CID = '3' OR Archive_Stats.CID = '4') AND (Archive_Stats.SID = '4'))";
	$c_result = @mysql_query($sql_c, $arlConn) or die ("Unable to query: $sql_adj");
	$c_add = @mysql_result($c_result,0);
	
	$sql_c_withdraw = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 5) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '7') AND (Archive_Stats.SID = '4'))";
	$c_result_withdraw = @mysql_query($sql_c_withdraw, $arlConn) or die ("Unable to query: $sql_adj");
	$c_withdraw = @mysql_result($c_result_withdraw,0);
	
	$c_adj = $c_add - $c_withdraw;
	
	$sql_ma = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 6) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '1' OR Archive_Stats.CID = '2' OR Archive_Stats.CID = '3' OR Archive_Stats.CID = '4') AND (Archive_Stats.SID = '4'))";
	$ma_result = @mysql_query($sql_ma, $arlConn) or die ("Unable to query: $sql_adj");
	$ma_add = @mysql_result($ma_result,0);
	
	$sql_ma_withdraw = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 6) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '7') AND (Archive_Stats.SID = '4'))";
	$ma_result_withdraw = @mysql_query($sql_ma_withdraw, $arlConn) or die ("Unable to query: $sql_adj");
	$ma_withdraw = @mysql_result($ma_result_withdraw,0);
	
	$ma_adj = $ma_add - $ma_withdraw;
	
	
	$sql_o = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 7) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '1' OR Archive_Stats.CID = '2' OR Archive_Stats.CID = '3' OR Archive_Stats.CID = '4') AND (Archive_Stats.SID = '4'))";
	$o_result = @mysql_query($sql_o, $arlConn) or die ("Unable to query: $sql_adj");
	$o_add = @mysql_result($o_result,0);
	
	$sql_o_withdraw = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 7) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '7') AND (Archive_Stats.SID = '4'))";
	$o_result_withdraw = @mysql_query($sql_o_withdraw, $arlConn) or die ("Unable to query: $sql_adj");
	$o_withdraw = @mysql_result($o_result_withdraw,0);
	
	$o_adj = $o_add - $o_withdraw;
	
	$sql_s = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 8) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '1' OR Archive_Stats.CID = '2' OR Archive_Stats.CID = '3' OR Archive_Stats.CID = '4') AND (Archive_Stats.SID = '4'))";
	$s_result = @mysql_query($sql_s, $arlConn) or die ("Unable to query: $sql_adj");
	$s_add = @mysql_result($s_result,0);
	
	$sql_s_withdraw = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 8) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '7') AND (Archive_Stats.SID = '4'))";
	$s_result_withdraw = @mysql_query($sql_s_withdraw, $arlConn) or die ("Unable to query: $sql_adj");
	$s_withdraw = @mysql_result($s_result_withdraw,0);
	
	$s_adj = $s_add - $s_withdraw;
	
	$sql_p = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 9) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '1' OR Archive_Stats.CID = '2' OR Archive_Stats.CID = '3' OR Archive_Stats.CID = '4') AND (Archive_Stats.SID = '4'))";
	$p_result = @mysql_query($sql_p, $arlConn) or die ("Unable to query: $sql_adj");
	$p_add = @mysql_result($p_result,0);
	
	$sql_p_withdraw = "Select Sum(Archive_Stats.Value)From Archive_Stats Where ((Archive_Stats.MID = 9) AND (Archive_Stats.QID = '34'  OR Archive_Stats.QID = '35' OR Archive_Stats.QID = '36' OR Archive_Stats.QID = '37' OR Archive_Stats.QID = '38' OR Archive_Stats.QID = '39' OR Archive_Stats.QID = '40' OR Archive_Stats.QID = '41' OR Archive_Stats.QID = '42' OR Archive_Stats.QID = '43' OR Archive_Stats.QID = '44' OR Archive_Stats.QID = '45') AND (Archive_Stats.CID = '7') AND (Archive_Stats.SID = '4'))";
	$p_result_withdraw = @mysql_query($sql_p_withdraw, $arlConn) or die ("Unable to query: $sql_adj");
	$p_withdraw = @mysql_result($p_result_withdraw,0);
	
	$p_adj = $p_add - $p_withdraw;	
		
		
	
	//get info for last year govdocs retro withdrawn
	$sql_lastyearwithdrawn = "SELECT SUM(Value) FROM Archive_Stats WHERE (SID = 3) AND (CID = 7) AND (MID = 1 OR MID = 2 OR MID = 3) AND (QID = 35 OR QID = 36 OR QID = 37 OR QID = 38 OR QID = 39 OR QID = 40 OR QID = 41 OR QID = 42 OR QID = 43 OR QID = 44 OR QID = 45 OR QID = 46)";
	$lastyearwithdrawn_result = @mysql_query($sql_lastyearwithdrawn, $arlConn) or die ("Unable to query: $sql_lastyearwithdrawn");
	$lastyearwithdrawn_total = @mysql_result($lastyearwithdrawn_result,0);
	if($lastyearwithdrawn_total == "")
		$lastyearwithdrawn_total = 0;
	if($lastyearadded_total == "")
		$lastyearadded_total = 0;
	$net = $lastyearadded_total - $lastyearwithdrawn_total;
	$net_thisYear = 34353-$lastyearadded_total;
	$thisyear = date("F")." - ".date("Y");
	$yearAlone = date("Y");
	$adj_total = 2623434+$net+$man_total;
	$vol_held_curr_add = $adj_total + $vol_net;
	$net_adj=$net;

/*-----------------------------------
Purpose: Display on page
-----------------------------------*/	

$lastyearadded_total=number_format($lastyearadded_total);
$lastyearwithdrawn_total=number_format($lastyearwithdrawn_total);
$net=number_format($net);
$net_adj=number_format($net_adj);
$adj_total=number_format($adj_total);
$man_total=number_format($man_total);
	
echo "

<table width='100%' cellspacing ='10' >
	<tr>
	<td>
	<FORM ACTION='http://ul.uc.edu/uclit/protected/assocdean/collstats/arl_report_ytd_2007.php' METHOD=GET>
	<INPUT TYPE=submit VALUE='ARL Collection Report 2007'>
	</FORM></td>
	<td>
	<FORM ACTION='http://ul.uc.edu/uclit/protected/assocdean/collstats/arl_report_adj_2007.php' METHOD=GET>
	<INPUT TYPE=submit VALUE='ARL Collection Adjustments 2007'>
	</FORM></td>
	<td>
	<FORM ACTION='http://ul.uc.edu/uclit/protected/assocdean/collstats/arl_report_summary_2007.php' METHOD=GET>
	<INPUT TYPE=submit VALUE='ARL Yearly Summaries 2007'>
	</FORM></td>
	</tr>
	</table>

	<font size='+2'>ARL Collection Report Adjustments (2006 - 2007)</font>
	<table border='1' cellspacing='10' width='100%'>
				<tr>
					<td colspan='4' align='center'><strong><br />Government Documents Adjustments</strong></td>
				</tr>
				<tr>
					<td >Retro GovDocs Vols. Added</td>
					<td >$lastyearadded_total</td>
										
				</tr>
				<tr>
					<td >Gov Docs Retro Clean Up</td>
					<td >-$lastyearwithdrawn_total</td>
				</tr>
				<tr>
					<td >Net Gov Docs Adjustment</td>
					<td >$net</td>
					
				</tr>
				<tr>
					<td ></td>
					<td ></td>
				</tr><tr></tr>
				<tr><td><strong>Adjustment Actions:</strong></td><td align='center'>
	<FORM ACTION='http://ul.uc.edu/uclit/protected/assocdean/collstats/add_arl_adj_2007.php' METHOD=GET>
	<INPUT TYPE=submit VALUE='Add'>
	</FORM></td><td align='center'>
	<FORM ACTION='http://ul.uc.edu/uclit/protected/assocdean/collstats/view_arl_adj_2007.php' METHOD=GET>
	<INPUT TYPE=submit VALUE='View'>
	</FORM></td></tr>
				<tr>
					<td colspan='4' align='center'><strong><br /><br />Previous Reporting Year Adjusted Total (Volumes)</strong></td>
				</tr>
				<tr>
					<td >Previous Year Reported Total</td>
					<td >2,623,434</td>
				</tr>
				<tr>
					<td >Net Gov Docs Adjustment</td>
					<td >$net</td>
				</tr>
				<tr>
					<td >Net Volumes Adjustment</td>
					<td >$man_total</td>
					
				</tr>

				<tr>
					<td >Previous Year Adjusted Total (2006)</td>
					<td ><strong>$adj_total</strong></td>
				</tr>
			<tr>
						    
					<td colspan='4'align='center'><strong><br />Previous Reporting Year Adjusted Totals (Other Library Materials)</strong><br/></td> 
				</tr>
				<tr>
					
					<td align='left'>Microforms Adjustments:</td>
					<td>$mi_adj</td>
				</tr>
				<tr>
					
					<td align='left'>Computer Files Adjustments:</td>
					<td>$c_adj</td>
				</tr>
				<tr>	 
					<td colspan='4'align='center'><strong><br />Previous Reporting Year Adjusted Totals (Audiovisual Materials)</strong><br/></td> 
				</tr>
				<tr>
					
					<td align='left'>Cartographic(Maps) Adjustments:</td>
					<td>$ma_adj</td>
				</tr>	
				<tr>
					
					<td align='left'>Graphic (2D)Adjustments:</td>
					<td>$o_adj</td>
				</tr>		
				<tr>
					
					<td align='left'>Audio (sound recordings)Adjustments:</td>
					<td>$s_adj</td>
				</tr>		
				<tr>
					
					<td align='left'>Film & Video (Projected Medium) Adjustments:</td>
					<td>$p_adj</td>
			    </tr>
			  </table>
		
	  ";

require ("/var/www/html/uclit/protected/common/css_login/css_foot.php"); ?>