<?php session_start();?>
<?php require_once('open_connection.php');?>
<!--link href='blue/style.css' rel='stylesheet' type='text/css' /-->
<link href='css/imagetable.css' rel='stylesheet' type='text/css' />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css"></style>
<script type="text/javascript" src="http://cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
    $('#myTable').dataTable();
});
</script>
<style type="text/css">
.buttonnew {
    background-color: #CC9900; /* Green */
    border: none;
    color: white;
    padding: 10px 25px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    -webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    cursor: pointer;
}
.buttonnew:hover {
    background-color: #CC9900;
    color: white;
}
.buttonsubnew {
    background-color: white; 
    color: black; 
    border: 2px solid #CC9900;
}
</style>
<!DOCTYPE html>
<html>
<head>
      <title>PICCSB e-Directory System</title>

</head>
<body bgcolor="#333333"> 
<table width="100%" border="0" align="center">
<tr>
<td width="15%" bgcolor="#333333">&nbsp;</td>
<td width="70%" align="center" bgcolor="#FFFFFF" > 

<table width="100%" border="0" align="center">

<!-- row for header picc 1 -->
<tr>  
     <th width="100%" colspan="4"><img src="images/header-cox.jpg" width="100%" height="auto"></th>
</tr>

<!-- row for header picc 2 -->
<tr>
     <th width="100%" colspan="4"><img src="images/eoffice-cox.jpg" width="100%"  height="auto"></th>
</tr>
<!-- calling frame -->	
<tr>
    <td colspan="1" width="10%" align="center"><?php include("header.php");?></td>
	
</tr>
<tr>

<td colspan="3" width="90%" align="center" >
<tr><td>&nbsp;</td></tr>
<tr><td align="left">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<?php
								echo 'Welcome: ' . $_SESSION['username'];
								?>
							<a href="cust_FnB_Login.php"><img src="images/logout3.gif" align="right"></a>
							</td>
</tr>
<tr><td>
<h2 align="center">CUSTOMER ADMIN PAGE</h2>

<form action="cust_FnB_view.php" 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='cust_FnB_createCust.php'">&nbsp;
<!--<input type="button" class="myButton"  value="HOME"    onClick="window.location.href='index.php'">-->
<input type="hidden" name="cust_id" value="<?php echo $cust_id; ?>">
 </td>
</tr>
</table>
</form>
<br>

<!--hr /-->
<form action="exportCust.php" method="post" name="export_excel">
			<div class="control-group">
				<div class="controls">
					<button type="submit" id="export" name="export" class="buttonnew buttonsubnew" data-loading-text="Loading...">Export Customer File</button>
				</div>
			</div>
			 
		</form>	
		
		<form action="exportquotation.php" method="post" name="export_excel">
			<div class="control-group">
				<div class="controls">
					<button type="submit" id="export" name="export" class="buttonnew buttonsubnew" data-loading-text="Loading...">Export Quotation File</button>
				</div>
			</div>
			 
		</form>	
		<div class=table-responsive>
<div align="right">
<?php

					$result=mysql_query("select tbl_dir_fnb_customer.cust_id,tbl_dir_fnb_customer.cust_salutation, tbl_dir_fnb_customer.cust_name,
					                     tbl_dir_fnb_customer.cust_address1,tbl_dir_fnb_customer.cust_address2,tbl_dir_fnb_customer.cust_postcode,tbl_dir_fnb_customer.cust_city,
					                     tbl_dir_fnb_customer.state_name,tbl_dir_fnb_customer.cust_contact,tbl_dir_fnb_customer.cust_company,
		                                 tbl_dir_fnb_customer.cust_position,tbl_dir_fnb_customer.cust_email,tbl_ref_state.state_code,tbl_ref_state.state_name
										 from tbl_dir_fnb_customer
									     Left join  tbl_ref_state ON tbl_dir_fnb_customer.state_name=tbl_ref_state.state_name
										 where 
										 tbl_dir_fnb_customer.state_name LIKE '%".$_POST[directory]. "%' OR cust_name LIKE '%".$_POST[directory]."%'  
										 OR cust_email LIKE '%".$_POST[directory]."%' OR cust_contact LIKE '%".$_POST[directory]."%' OR cust_company LIKE '%".$_POST[directory]."%'                                         ORDER BY tbl_dir_fnb_customer.cust_id DESC ");
		
		
		  			$i=0;
		  
echo "<center><table id=myTable  class=imagetable style=background-color:003333; font:Arial, Helvetica, sans-serif border=1 style=table-layout:fixed;overflow:auto>"; 
echo "<thead>";
echo"<tr align='center' style=color:FFFFFF;><th>NO</th><th width=200>NAME</th><th>COMPANY</th><th>POSITION</th><th>CONTACT</th><th>EMAIL</th><th>ADDRESS</th><th>UPDATE</th><th>DELETE</th><th>QUOTATION</th></tr>";
echo "</thead>";
echo "<tbody>";	 
while($row=mysql_fetch_array($result))
{
					 $cust_id = $row['cust_id']; 
					  $cust_salutation = $row['cust_salutation'];
		 		   $cust_name = $row['cust_name'];
			    $cust_company = $row['cust_company'];
		       $cust_position = $row['cust_position'];
				$cust_contact = $row['cust_contact'];
			      $cust_email = $row['cust_email'];
			   $cust_address1 = $row['cust_address1'];
			   $cust_address2 = $row['cust_address2'];
				$cust_address3 = $row['cust_address3'];
				$cust_address4 = $row['cust_address4'];
				$cust_postcode = $row['cust_postcode'];
				    $cust_city = $row['cust_city'];
				$state_name = $row['state_name'];
				//$staff_assign = $row['staff_assign'];
			$i++;
					echo"<tr>";
						echo "<td align=center>".$i."</td>";
						//echo "<td align=left >".$row['cust_id']."</td>";
						echo "<td align=left >".$row['cust_salutation']. "." .$row['cust_name']."</td>";
						//echo "<td align=left >".$row['cust_name']."</td>";
						echo "<td align=left >".$row['cust_company']."</td>";
						echo "<td align=left >".$row['cust_position']."</td>";
						echo "<td align=left style= word-break: nowrap;>".$row['cust_contact']."</td>";
						echo "<td align=left >".$row['cust_email']."</td>";
						echo "<td align=center >".$row['cust_address1']."," . $row['cust_address2']. "," .$row['cust_address3']."," . $row['cust_address4']. "," .$row['cust_postcode']."," .$row['cust_city']. "," .$row['state_name']."</td>";
						//echo "<td align=center >".$row['staff_assign']."</td>";
						echo "<td align=center >"."<a href=cust_FnB_update.php?cust_id=$cust_id>Update</a>"."</td>";
						echo "<td align=center >"."<a href=cust_FnB_delete.php?cust_id=$cust_id>Delete</a>"."</td>";
						echo "<td align=center >"."<a href=quotation_mainpage.php?cust_id=$cust_id>Quotation</a>"."</td>";
					echo"</tr>";
					}
					
					echo "</span></table>";
echo "</tbody>";
//mysql_close($con);

?>
  
  </td>
  </tr>
  
</div>

  </td></tr>
  
  </div></div>
  </td></tr>
<!-- row for footer -->	
<tr>
	<th align="center" colspan="4">
	<?php include ('footer.php'); ?>
		
	</th>
</tr>

<!--- end for ruang kerja 80% -->
</table>

</td>

<td width="100%" bgcolor="#333333">&nbsp;</td>

</tr>

<!--- end for ruang kerja 100% -->
</table>

</body>
</html>