<?php session_start();
      include('open_connection.php');
      include('header.php');  ?>

<html>
<link href='blue/style.css' rel='stylesheet' type='text/css' />

<style>
.myButton {
	-moz-box-shadow:inset 0px 1px 3px 0px #91b8b3;
	-webkit-box-shadow:inset 0px 1px 3px 0px #91b8b3;
	box-shadow:inset 0px 1px 3px 0px #91b8b3;
	background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #768d87), color-stop(1, #6c7c7c));
	background:-moz-linear-gradient(top, #768d87 5%, #6c7c7c 100%);
	background:-webkit-linear-gradient(top, #768d87 5%, #6c7c7c 100%);
	background:-o-linear-gradient(top, #768d87 5%, #6c7c7c 100%);
	background:-ms-linear-gradient(top, #768d87 5%, #6c7c7c 100%);
	background:linear-gradient(to bottom, #768d87 5%, #6c7c7c 100%);
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#768d87', endColorstr='#6c7c7c',GradientType=0);
	background-color:#768d87;
	-moz-border-radius:5px;
	-webkit-border-radius:5px;
	border-radius:5px;
	border:1px solid #566963;
	display:inline-block;
	cursor:pointer;
	color:#ffffff;
	font-family:arial;
	font-size:12px;
	font-weight:bold;
	padding:4px 20px;
	text-decoration:none;
	text-shadow:0px -1px 0px #2b665e;
}
.myButton:hover {
	background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #6c7c7c), color-stop(1, #768d87));
	background:-moz-linear-gradient(top, #6c7c7c 5%, #768d87 100%);
	background:-webkit-linear-gradient(top, #6c7c7c 5%, #768d87 100%);
	background:-o-linear-gradient(top, #6c7c7c 5%, #768d87 100%);
	background:-ms-linear-gradient(top, #6c7c7c 5%, #768d87 100%);
	background:linear-gradient(to bottom, #6c7c7c 5%, #768d87 100%);
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#6c7c7c', endColorstr='#768d87',GradientType=0);
	background-color:#6c7c7c;
}
.myButton:active {
	position:relative;
	top:1px;
}
table.imagetable {
	font-family: verdana,arial,sans-serif;
	font-size:11px;
	color:#333333;
	border-width: 1px;
	border-color: #999999;
	border-collapse: collapse;
}
table.imagetable th {
	background:#b5cfd2 url('cell-blue.jpg');
	border-width: 1px;
	padding: 5px;
	border-style: solid;
	border-color: #999999;
}
table.imagetable td {
	background:#dcddc0 url('cell-grey.jpg');
	border-width: 1px;
	padding:5px;
	border-style: solid;
	border-color: #999999;
}

</style>
<body>

<table width="100%">
<tr>
<td align="left">
<?php
echo 'Welcome: ' . $_SESSION['username'];
?>
</td>
<td align="right">
<a href="vendor_AdminSection_login.php"><img src="images/logout3.gif"></a>
</td>
</tr>
</table>

<h2 align="center">VENDOR ADMIN PAGE</h2>

<form  method="post">
<table border=0 align=center  class="imagetable" >
<tr><td>INFO SEARCH</td>
<td><input type="text" name="directory" />
<input type="submit" class="myButton"  value="SEARCH"/>&nbsp;
<input type="button" class="myButton"  value="INSERT"  onClick="window.location.href='vendor_FinanceAdmin_insert.php'">&nbsp;
<input type="button" class="myButton"  value="HOME"    onClick="window.location.href='index.php'">
<input type="button" value="BACK" class="myButton" onClick="history.back();">
<input type="hidden" name="vendor_id" value="<!--?php echo $vendor_id; ?>">
 </td>
</tr>
</table>
</form>
<br>
<div align="right">
  <?php
$rowsPerPage =20; 
				$pageNum = $_REQUEST['page']; 
				if(empty($pageNum))
						{
					$offset =0;
					$pageNum=1;
						}
				else
						{
					$offset = ($pageNum - 1) * $rowsPerPage;
						}	
					$result=mysql_query(" select tbl_dir_evendor.vendor_id, tbl_dir_evendor.vendor_name,tbl_dir_evendor.vendor_address1,tbl_dir_evendor.vendor_address2,
										  tbl_dir_evendor.vendor_contact,tbl_dir_evendor.vendor_hp1,tbl_dir_evendor.vendor_hp2,tbl_dir_evendor.vendor_fax,
					 					  tbl_dir_evendor.vendor_email,tbl_dir_evendor.category_name,tbl_dir_evendor.subCategory_name,tbl_ref_ecategory.category_id,tbl_ref_ecategory.category_name,tbl_ref_esubcategory.SubCategory_id,
										  tbl_ref_esubcategory.subCategory_name
       									  from tbl_dir_evendor
										  Left join  tbl_ref_ecategory ON tbl_dir_evendor.category_name=tbl_ref_ecategory.category_name
										  Left Join  tbl_ref_esubcategory ON tbl_dir_evendor.subCategory_name=tbl_ref_esubcategory.subCategory_name
										  where 
										  tbl_dir_evendor.category_name LIKE '%".$_POST[directory]. "%' OR vendor_name LIKE '%".$_POST[directory]."%'  
										  OR vendor_email LIKE '%".$_POST[directory]."%' OR vendor_hp1 LIKE '%".$_POST[directory]."%'
		   								  ORDER BY tbl_dir_evendor.vendor_id ASC LIMIT $offset, $rowsPerPage");
		
		  			$i=$offset;
		  
echo "<center><span class=style16><table class=tablesorter id=user>";
echo "<thead>";
echo"<tr align='center'><th>NO</th><th>COMPANY NAME</th><th>COMPANY ADDRESS</th><th>CONTACT PERSON</th><th>TELEPHONE 1</th><th>TELEPHONE 2</th><th>FAX</th><th>EMAIL</th><th>CATEGORY</th><th>SUB CATEGORY</th><!--th colspan=2>ACTION</th--></tr>";
echo "</thead>";
echo "<tbody>";	 
while($row=mysql_fetch_array($result))
{
				 $vendor_id = $row['vendor_id'];
	     $vendor_salutation = $row['vendor_salutation']; 
		 	   $vendor_name = $row['vendor_name'];
		   $vendor_address1 = $row['vendor_address1'];
		   $vendor_address2 = $row['vendor_address2'];
		   $vendor_address3 = $row['vendor_address3'];
		   $vendor_address4 = $row['vendor_address4'];
			$vendor_contact = $row['vendor_contact'];
			   $vendor_city = $row['vendor_city'];
		   $vendor_postcode = $row['vendor_postcode'];
			  $vendor_state = $row['vendor_state'];
			$vendor_country = $row['vendor_country'];
			    $vendor_hp1 = $row['vendor_hp1'];
				$vendor_hp2 = $row['vendor_hp2'];
			    $vendor_fax = $row['vendor_fax'];
			  $vendor_email = $row['vendor_email'];
			//$vendor_section = $row['vendor_section'];
			 $category_id = $row['category_name'];
			 $subCategory_id = $row['subCategory_name'];
			$i++;
					echo"<tr>";
						echo "<td align=center>".$i."</td>";
						echo "<td align=left >".$row['vendor_name']."</td>";
						echo "<td align=center >".$row['vendor_address1']."<br>.".$row['vendor_address2']."<br>".$row['vendor_address3']."<br>".$row['vendor_address4']."<br>".$row['vendor_city'].",".$row['vendor_postcode']."<br>".$row['vendor_state']."<br>".$row['vendor_country']."</td>";
						echo "<td align=center >".$row['vendor_contact']."</td>";
						echo "<td align=center >".$row['vendor_hp1']."</td>";
						echo "<td align=center >".$row['vendor_hp2']."</td>";
						echo "<td align=center >".$row['vendor_fax']."</td>";
						echo "<td align=center >".$row['vendor_email']."</td>";
						//echo "<td align=center >".$row['vendor_section']."</td>";
						echo "<td align=center >".$row['category_name']."</td>";
						echo "<td align=center >".$row['subCategory_name']."</td>";
						//echo "<td align=center >"."<a href='vendor_FinanceAdmin_update.php?vendor_id=$vendor_id'>Update</a>"."</td>";
						//echo "<td align=center >"."<a href='vendor_FinanceAdmin_delete.php?vendor_id=$vendor_id'>Delete</a>"."</td>";
					echo"</tr>";
					}
					
					echo "</span></table>";
echo "</tbody>";
//mysql_close($con);

?>

  <div align="right"> <span class="style16"  >
    <?php
				$query1 = "SELECT COUNT(vendor_id) AS numrows FROM tbl_dir_evendor";
				$result1 = mysql_query($query1) or die('Error, query failed');
				$row1 = mysql_fetch_array($result1, MYSQL_ASSOC);
				$numrows = $row1['numrows'];
				$maxPage = ceil($numrows/$rowsPerPage);
				// print the link to access each page
				$self = $_SERVER['PHP_SELF'];
				$nav = '';
				for($page = 1; $page <= $maxPage; $page++){
				if ($page == $pageNum){
				$nav .= " $page ";}
				else{
				$nav .= " <a href=\"$self?page=$page\">$page</a> ";
					}
				}
				if ($pageNum > 1)
				{
					$page = $pageNum - 1;
					$color="#FFFFFF";
					$prev = " <a href=\"$self?page=$page\">[Previous]</a> ";
					$first = " <a href=\"$self?page=1\">[First]</a> ";
				}
					else{
					$prev = ' ';
					$first = ' ';
				}
					if ($pageNum < $maxPage)
				{
						$page = $pageNum + 1;
						$next = " <a href=\"$self?page=$page\">[Next]</a> ";
						$last = " <a href=\"$self?page=$maxPage\">[Last]</a> ";
				}
					else{
					$next = ' ';
					$last = ' ';
				}
		echo  $first . $prev . $nav . $next . $last;?>
  </span></div>
  </td>
  </tr>
      </table>
</div>
</body>
<script type='text/javascript' src='tablesorter/jquery-latest.js'>
</script>
<script type='text/javascript' src='tablesorter/jquery.tablesorter.min.js'>
</script>


<script type='text/javascript'>
	$(document).ready(function() { 
		$("#user").tablesorter({ 
			//for example we want to disable the 
			//password column (5th column) from sorting
			//we will specify '4' since it was indexed
			//(count starts at '0')
			//and set its property to 'false'
			headers: { 
				8: {    
					sorter: false 
				}
			}
		}); 
	});
	
</script>
<input type="button" value="BACK" class="myButton" onClick="history.back();">
<p id="back-top">
<a href="#top"><span></span>Back to Top</a>
</p>

</html>
<?php include('footer.php'); ?>
