
<?php $PageSecurity = 11;
include('includes/session.inc');
 


include('includes/SQL_CommonFunctions.inc');
	
	if($_REQUEST['insertdata'])
	{
		 
		$x = $_REQUEST['insertdata'];
		 
			$query = "Update purchorders
				  set bank_name = '".$x[1][2]."',
				   check_no = '".$x[1][0]."',
				   check_date = '".ConvertSQLDate($x[1][1])."',
				   check_amt = '".$x[1][3]."'
				  where id = '".$x[1][4]."';
				";
				 
		 
				 
		$update = DB_query($query,$db);
		if($update){
			echo "1";
		}
		else{
			echo "2";
		}
		exit;
	}
	


	if($_REQUEST['checkno']){
		$query = "Update purchorders
				  set bank_name = '".$_REQUEST['bank_name']."',
				   check_no = '".$_REQUEST['checkno']."',
				   check_date = '".ConvertSQLDate($_REQUEST['checkdate'])."',
				   check_amt='".$_REQUEST['amount']."'
				  where id = '".$_REQUEST['poid']."';
				";
		$update = DB_query($query,$db);
		if($update){
			echo "1";
		}
		else{
			echo "2";
		}
		exit;
	}

	 if($_REQUEST['checkdetails']){ 
	 	$result = DB_query("Select bank_name,check_no,check_date,check_amt from purchorders where id ='".$_REQUEST['po_id']."' ",$db);
	 	if(DB_num_rows($result)>0){
	 		$data = DB_fetch_array($result);
	 		echo $data['bank_name']."__".$data['check_no']."__".ConvertSQLDate($data['check_date'])."__".$data['check_amt'];
	 	}
	 	exit;
	 }

$data1=' <option value="0">Select</option>'; 
$vendor="Select * from suppliers where CompanyId='".$_SESSION['ACGCompanyId']."'";		
				// $vendor="Select * from suppliers where CompanyId='".$_SESSION['ACGCompanyId']."' and site in('".$_REQUEST['site']."') and assigned_items is not null and assigned_items!=''";
				$vendor_sql=DB_query($vendor,$db);
				while($vendor_res=DB_fetch_array($vendor_sql))
				{
                $data1.='<option value="'.$vendor_res['id'].'" >'.$vendor_res['vendor_name'].'</option>';
                } 
echo $data1;
                ?>
<script>
 $('.datepicker').removeClass('hasDatepicker').datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true, changeYear: true,yearRange: '-80:+20'});	
 </script>                
