<?php session_start();?>
<?php include("Header.php"); ?>
<?php require_once('open_connection.php');?>

<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>

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

<h2 align="center">UPDATE VENDOR RECORD</h2>

<?php
       $vendor_id = $_REQUEST['vendor_id'];

echo $vendor_id;

       $sql = "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  vendor_id= '$vendor_id'";
																		
				$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
				// $row = mysql_fetch_array($result, MYSQL_ASSOC);
				
				$row=mysql_fetch_array($result);
			    $vendor_id=$row['vendor_id'];
			
		?>
				<?php // echo $staff_id;?>
				
				<form  method="post">
						<table border=0 align=center  class="imagetable" >
							<tr><td>Vendor Name</td><td> : </td><td><input type="text" size="100" name="vendor_name" value="<?php echo "$row[vendor_name]"?>"></td></tr>
							<tr><td>Address</td><td> : </td><td><input type="text" size="100" name="vendor_address1" value="<?php echo "$row[vendor_address1]"?>">
							<br><input type="text" size="100" name="vendor_address2" value="<?php echo "$row[vendor_address2]"?>">
							<br><input type="text" size="100" name="vendor_address3" value="<?php echo "$row[vendor_address3]"?>">
							<br><input type="text" size="100" name="vendor_address4" value="<?php echo "$row[vendor_address4]"?>"></td></tr>
							<tr><td>Contact</td><td> : </td><td><input type="text" size="50" name="vendor_contact" value="<?php echo "$row[vendor_contact]"?>"></td></tr>
							<tr><td>Tel</td><td> : </td><td><input type="text" size="11" name="vendor_hp1" value="<?php echo "$row[vendor_hp1]"?>"></td></tr>
							<tr><td>Tel</td><td> : </td><td><input type="text" size="11" name="vendor_hp2" value="<?php echo "$row[vendor_hp2]"?>"></td></tr>
							<tr><td>Fax</td><td> : </td><td><input type="text" size="20" name="vendor_fax" value="<?php echo "$row[vendor_fax]"?>"></td></tr>
							<tr><td>Email</td><td> : </td><td><input type="text" size="30" name="vendor_email" value="<?php echo "$row[vendor_email]"?>"></td></tr>
													  
							  <!--tr><td>Category</td><td> : </td><td><select name="category_id" >
                                <option ><!--?php echo  $row['category_name']; ?></option>
                                <!--?php $category_query=mysql_query("select * from tbl_ref_ecategory order by category_id")or die(mysql_error());
                                       while($row_category=mysql_fetch_array($category_query)){?>
                                <option> <!--?php echo $row_category['category_name']; ?>
                                <!--?php } ?>
                                </option>
                              </select></td></tr-->
							  <form method="post">
							  <tr><td>Category</td><td> : </td><td><select name="category_id" >
							
							   <!--?php $category_name=$row.['category_id'];?-->
                                   <option value="<?php echo $row['category_id']; ?>" ><?php echo $row['category_name']; ?></option>
								    
                                 <?php $category_query=mysql_query("select * from tbl_ref_ecategory  order by category_id")or die(mysql_error());
                                       while($row_category=mysql_fetch_array($category_query)){?>
                                   <option> <?php echo $row_category['category_name']; ?>
                                <?php } ?>
                                </option>
                            </select></td></tr>
							  
							  <tr><td>Sub Category</td><td> : </td><td><select name="subCategory_id" >
                                <option value="<?php echo  $row['subCategory_id']; ?>" ><?php echo  $row['subCategory_name']; ?></option>
                                <?php $subcategory_query=mysql_query("select * from tbl_ref_esubcategory order by subCategory_id")or die(mysql_error());
                                       while($row_subcategory=mysql_fetch_array($subcategory_query)){?>
                                <option> <?php echo $row_subcategory['subCategory_name']; ?>
                                <?php } ?>
                                </option>
                              </select></td></tr>
							  
							  
							<tr><td colspan="3" align="center">
						<input type="submit" class="myButton" value="UPDATE"  name="save" id="save">
						<input type="button" class="myButton" value="VENDOR LIST" onClick="window.location.href='vendor_FinanceAdmin_view.php'">
						</td></tr>
					</table>
						<input type="hidden" name="id" value="<?php echo "$row[vendor_id]" ?>">
			</form>

<?php
// escape variables for security

if (isset($_POST['save'])){
       $vendor_name = $_POST['vendor_name'];
    $vendor_address1 =$_POST['vendor_address1'];
	$vendor_address2 =$_POST['vendor_address2'];
	$vendor_address3 =$_POST['vendor_address3'];
	$vendor_address4 =$_POST['vendor_address4'];
$vendor_contact = $_POST['vendor_contact'];
        $vendor_hp1 = $_POST['vendor_hp1'];
		$vendor_hp2 = $_POST['vendor_hp2'];
         $vendor_fax =$_POST['vendor_fax'];
       $vendor_email = $_POST['vendor_email'];
     //$vendor_section = $_POST['vendor_section'];
	 $category_name = $_POST['category_name'];
	$subCategory_name = $_POST['subCategory_name'];
// insert record into database
$sql="update tbl_dir_evendor set vendor_name='$vendor_name',vendor_address1='$vendor_address1',vendor_address2='$vendor_address2',vendor_address3='$vendor_address3',vendor_address4='$vendor_address4',vendor_contact='$vendor_contact',
	  vendor_hp1='$vendor_hp1',vendor_hp2='$vendor_hp2',vendor_fax='$vendor_fax', vendor_email='$vendor_email' , category_name='$category_name', subCategory_name='$subCategory_name' where vendor_id='$vendor_id'";

$result=mysql_query($sql);
if($result)
echo "<script language='javascript'>window.location='vendor_FinanceAdmin_view.php'</script>";

else
   
   echo 'Unsuccessfull update';
   }
?>

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