<?php
$PageSecurity = 1;
include('config.php');
include('includes/ConnectDB.inc');
include('includes/function_lib.php');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
  
?>
<link rel="stylesheet" href="css/professional/default.css">
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain" style="margin:10px; width:94%;">
<div class="tab_div">
<h1>Reason</h1>
<form action="" method="post">
<table width="100%" border="0"  bordercolor="#999999" cellpadding="3" cellspacing="0">
  <tr>
    <td>
	<?php
	$selectreason=DB_query("SELECT reason_id FROM log_reason where doc_id='".$_REQUEST['id']."' order by id DESC",$db);
		$secarr=DB_fetch_array($selectreason); ?>
	<textarea name="otherReason" readonly id="otherReason" style="width:90%;"><?php echo $s->getField('reason_master','id',$secarr['reason_id'],'reason'); ?></textarea></td>
  </tr>
 
</table>
</form> 
</div>
</div>
<?php 
	 if(isset($_POST['Cancel']))
			 {
					 $venderid=$s->getField('purchorders','orderno',$_REQUEST['id'],'mst_vendor_quotesid');
					$comid=$s->getField('purchorders','orderno',$_REQUEST['id'],'mst_comperitive');
					 $updatevender=DB_query("update venderquotations set po_cancel_vender='Y' where id='".$venderid."'",$db); 
					 $update=DB_query("update purchorders set cancel_status=1,cancel_reason='".$_REQUEST['reason']."' 
					 where orderno='".$_REQUEST['id']."'",$db);
					 $update_com=DB_query("update comprative_detail set status_active=1 where comprative_id ='".$comid."'",$db);
							
					

echo "<script>parent.window.close();
parent.window.opener.location.href='index.php?route=POModule/direct_po_index2&modid=".$_REQUEST['modid'].                      "&frmid=".$_REQUEST['frmid']."'</script>";			
		}
?>