<?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');
	$loggedinuser = $_SESSION['username'];
?>
	<H1> Previous Yearl ARL Adjustment (2006 - 2007) </H1>			
	<form method="post" action="add_adj_2007.php" name="ticket_form" onSubmit="return validator();">
		<table border="0" width="90%">
        
        <tr>
	<td align='right'><strong>Cataloger: </strong></td>
	<td>   <select name='Personnel'>
<?php
	//sart work
	$db = mysql_select_db('login', $loginConn) or die ("Unable to select login database.");
	$sql_login = "SELECT username, personnel_id FROM users WHERE username = '$loggedinuser' ";
	$login_result = @mysql_query($sql_login, $loginConn) or die ("Unable to query: $sql_login");
	
	while($log_row = @mysql_fetch_array($login_result))
	{	
		$pid = $log_row['personnel_id'];				

		$db = mysql_select_db('uclit_db', $uclit_dbConn) or die ("Unable to select uclit_db database.");
		
		$sql_logindept = "SELECT personnel_id, last_name, first_name, middle_name, dept_id FROM personnel ORDER BY last_name";
		$logindept_result = @mysql_query($sql_logindept, $uclit_dbConn) or die ("Unable to query: $sql_logindept");
		$dept_string = "";		
		while($emp_row = @mysql_fetch_array($logindept_result))
		{	
			$pid = $emp_row['personnel_id'];
			$lname = $emp_row['last_name'];
			$fname = $emp_row['first_name'];
			$mname = $emp_row['middle_name'];
			echo "\\n<option value='$pid'>$lname, $fname $mname</option>";
		}	
	}
?>
	</td>
  </tr>
				<tr>
					<td align="right" valign="top" width="25%">
						<P><strong>&nbsp;&nbsp; Value:</strong><BR>
					</td>
					<td valign="top">
					<input type="text" name="adj_value" size="25" maxlength="25">
					</td>
					                    
                    <tr>
					<td align='right'><strong>Location: </strong></td>
					<td>    <select name='Location'>
				<?php
				$dbloc = mysql_select_db("arlstats", $arlConn) or die("Couldn't select arlstats dababase");
	$sql_location = "SELECT LID, Name, Description, UID FROM Location ORDER BY Name";
	$location_result = @mysql_query($sql_location, $arlConn) or die ("Unable to query: $sql_location");
		
		
	while($loc_row= @mysql_fetch_array($location_result))
	{
		$lid = $loc_row['LID'];
		$loc = $loc_row['Name'];
		$lde = $loc_row['Description'];
		$luserstring = $loc_row['UID'];
		$luserarray = split("\+", $luserstring);
	
		if (in_array($loggedinuser, $luserarray))
			echo "\\n<option value='$lid'>$loc ($lde)</option>";
	}		
?>
			</select>
	</td>
  </tr>
  
   <tr>
	<td align='right'><strong>Format:</strong> </td>
	<td>    <select name='Material'>
<?php
	$sql_material = "SELECT MID, Name FROM Material_Types ORDER BY Name";
	$material_result = @mysql_query($sql_material, $arlConn) or die ("Unable to query: $sql_material");

	
	while($mat_row = @mysql_fetch_array($material_result))
	{	
		$mid = $mat_row['MID'];
		$mname = $mat_row['Name'];
		echo "\\n<option value='$mid'>$mname</option>";
	}
?>
		</select>
	</td>
  </tr>
  
  <tr>
	<td align='right'><strong>Cataloging Types:</strong></td>
	<td>     
	  <select name='Catalog'>
<?php
	$sql_catalog = "SELECT CID, Name FROM Catalog_Types ORDER BY Name";
	$catalog_result = @mysql_query($sql_catalog, $arlConn) or die("Unable to query: $sql_catalog");

	
	while($cat_row = @mysql_fetch_array($catalog_result))
	{
		$cid = $cat_row['CID'];
		$cat = $cat_row['Name'];
		echo "\\n<option value='$cid'>$cat</option>";
	}
?>
      </select>
    </td>
  </tr>
  
  <tr>
	<td align='right'><strong>Month: </strong></td>
	<td>   
	  <select name='Month'>
<?php
	$sql_calendar = "SELECT QID, Month FROM Calendar WHERE (QID=40 OR QID=46) ORDER BY QID Asc";
	$calendar_result = @mysql_query($sql_calendar, $arlConn) or die ("Unable to query: $sql_material");
	
	
	while($cal_row = @mysql_fetch_array($calendar_result))
	{	
		$qid = $cal_row['QID'];
		$qname = $cal_row['Month'];
		echo "\\n<option value='$qid'>$qname</option>";
	}
?>
      </select>
	</td>
  </tr>
  
  <tr>
					<td align="right" valign="top" width="25%">
						<P><strong>&nbsp;&nbsp; Description:</strong><BR>
					</td>
					<td valign="top">
                    <textarea cols="50" rows="4" name="adj_desc"></textarea>
										</td>
					</tr>
                    
                    
					<tr>
					<input type="hidden" name="username" value="$loggedinuser">
					</td>
								</tr>	<tr></tr>		
				<tr><td></td>
						<td><input type="button" value="Submit Adjustment" onClick="CheckBeforeSumbit()"></td>
						
				</tr>
			</table>
		</form>

<script type="text/javascript">
function CheckBeforeSumbit()
{
	var x = document.ticket_form;
	if(x.adj_value.value == "" || x.adj_desc.value == "")
	{
		window.alert("Please fill in all of the fields");
	}
	else
	{
		x.submit();
	}
}	
</script>

<?php
	include('/var/www/html/uclit/protected/common/css_login/css_foot2.php');
?>
