<?php $PageSecurity = 11;
include('includes/session.inc');
//include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
//echo $_REQUEST['q'];
  if($_REQUEST['client']!='')
{
	    $AccountSQL=DB_query("select * from accountledger where AccountsId='".$_REQUEST['q']."'",$db);
		$AccountSQLRow=DB_fetch_array($AccountSQL);
		if($AccountSQLRow['ledgertype']=='client')
		{
	   $clientid=$AccountSQLRow['vender_client'];
		}
		else
		{
		$clientid=$AccountSQLRow['AccountName'];
		}
		$cst_vatno=$s->GetFieldValue('clientmaster'," id='".$clientid."'  " ,'cst_no');
		$cst_exciseno=$s->GetFieldValue('clientmaster'," id='".$clientid."'  " ,'excies_no');
	    $assign_zone=$s->GetFieldValue('clientmaster'," id='".$clientid."'  " ,'Zone');
  //   echo "Select id,orderNo, PORefNo from salesorder where branch='".$_REQUEST['branch']."' and client='".$clientid."'  and status='pending'";
	//  echo "Select id,orderNo, PORefNo from salesorder where (createdBy IN(".$_SESSION['ACG_DashBoard_User'].")) and branch='".$_REQUEST['branch']."' and client='".$clientid."' and status='pending' and CompanyId='".$_SESSION['ACGCompanyId']."'";
	$sql=DB_query("Select id,orderNo, PORefNo from salesorder where (createdBy IN(".$_SESSION['ACG_DashBoard_User'].")) and branch='".$_REQUEST['branch']."' and client='".$clientid."' and status='pending' and CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
	

?>

<div>


<table width="100%" cellpadding="0" cellspacing="0" border="0">

	<!--<tr>
	<td>PO No. </td>
	<td >
	<?php 
$rowdata=DB_fetch_array($sql)
	?>
	<input type="text" name="po_orderno" id="po_orderno" value="<?php //echo $rowdata['PORefNo']; ?>" />
	<input name="po_orderno" type="text" value="<?php //echo $po_orderno;?>" />&nbsp;</td>
	</tr>-->
	<tr style="background-color:#e7e7e7; border-left: #666666 solid 1px;border-right: #666666 solid 1px;">
	<td class="tabledata1">CST Vat No </td>
	<td><input name="cst_vatno" style="width:107px;" type="text" value="<?php echo $cst_vatno;?>" /></td>
	
	<td class="tabledata1">Customer Group </td>
	<td>
	<?php  
	//echo "Select id,ZoneTitle from zone_master where site='".$_REQUEST['branch']."'  and CompanyId='".$_SESSION['ACGCompanyId']."'";?>
	<?php 
	$sql_zonedata=DB_query("Select id,ZoneTitle from zone_master where site='".$_REQUEST['branch']."'  and CompanyId='".$_SESSION['ACGCompanyId']."' and id='".$assign_zone."'",$db);
$row_zone=DB_fetch_array($sql_zonedata)
 ?>
 <input type="text" style="width:107px;" name="ex_cust_group" id="ex_cust_group" value="<?php echo $row_zone['ZoneTitle']; ?>" />
</td>		
	</tr>
	
	<tr class="row1">
	<td class="tabledata1">ECC No </td>
	<td ><input name="ecc_no" style="width:107px;" type="text" value="<?php echo $cst_exciseno;?>" /></td>
	<td class="tabledata1">Our Ref No</td>
	<td><input type="text" style="width:107px;" name="our_refno" value="<?php echo $our_ref_no; ?>" /></td>		
	</tr>
	<tr class="row1">
	<td class="tabledata1">Form</td>
	<td >
	<select name="form_status" style="width:107px;">
	<option value="Yes" <?php  echo  $form_status=='Yes'?'selected':'' ?>>Yes</option>
	<option value="No" <?php  echo $form_status=='No'?'selected':'' ?> >No</option>
	</select>
	 </td>	
	<td class="tabledata1">Form No</td>
	 <td><input type="text" name="form_no" value="<?php echo $form_no; ?>" style="width:107px;"  /></td>
	</tr>
	</table>

</div>
<div style="clear:both;"></div>

<div style="margin:0px;">
<table width="100%" cellpadding="0" cellspacing="0">
    	<tr style="background-color:#e7e7e7; border-left: #666666 solid 1px;border-right: #666666 solid 1px;border-bottom: #666666 solid 1px;">
	<td class="tabledata1">Against Single/Multiple S. O. P.</td>
    <td>
 
    	<div style="overflow:auto; height:100px; width:600px;border:#666666 1px solid; " >
    	<?php 
//echo "Select id,orderNo from salesorder where (createdBy IN(".$_SESSION['ACG_DashBoard_User'].")) and branch='".$_REQUEST['branch']."' and client='".$clientid."' and status='pending'";
    	$sql2=DB_query("Select id,orderNo,PORefNo from salesorder where (createdBy IN(".$_SESSION['ACG_DashBoard_User'].")) and branch='".$_REQUEST['branch']."' and client='".$clientid."' and status='pending'",$db);
    	$i=0;	
    		while($myrow2=DB_fetch_array($sql2))
			{?>
				<input type="checkbox" name="againstSOP[<?php echo $i;?>]" value="<?php echo $myrow2['id']?>" /><?php echo $myrow2['orderNo']?><?php echo '--'.'&nbsp;&nbsp;'.$myrow2['PORefNo']; ?> <br/> 
			<?php 	$i++;
			}
    	?>	
    	</div>	
    </td>
    </tr>
</table>
</div>
<div style="clear:both;"></div>
<?php 
}
else if($_REQUEST['q']!='')
{
	$sql="Select id,EONumber from export_sales_order where consignee='".$_REQUEST['q']."'";
	$result=DB_query($sql,$db);
?>
	<select name="EONumber" style="width: 100%" onchange="exportOrdersDetails(this.value)" >
              <option value="0">Select</option>
              <?php
                while($row=DB_fetch_array($result))
                {?>
              <option value="<?php echo $row['id'];?>"><?php echo $row['EONumber'];?></option>
              <?php 	
                }
                ?>
</select>
<?php 
}
?>