	<link rel="stylesheet" href="css/new_mxerp.css">

	<link rel="stylesheet" href="/css/jquery.ui.all.css">
	<script src="js1/jquery-1.7.2.js"></script>
	<script src="js1/jquery.ui.widget.js"></script>
	<script src="js1/jquery.ui.tabs.js"></script>

<script>
	$(function() {
		$( "#tabs" ).tabs();
	});
	</script>
 
<?php  include("CRM/Class_Party.php");

if($_REQUEST['Proceed']!='' )
{
  $adviceNo=$_REQUEST['adviceNo'];
	$party=$_REQUEST['party'];
	$dispatchDate=$_REQUEST['dispatchDate'];
	$cst_vatno=$_REQUEST['cst_vatno'];
	$da_refno=$_REQUEST['da_refno'];
	$ecc_no=$_REQUEST['ecc_no'];
	//$po_date=$_REQUEST['po_date'];
	$our_ref_no=$_REQUEST['our_refno'];
	$form_status=$_REQUEST['form_status'];
	$form_no=$_REQUEST['form_no'];
	//$po_orderno=$_REQUEST['po_orderno'];
	$excisableComm=$_REQUEST['excisableComm'];
	$dispatch_mode=$_REQUEST['dispatch_mode'];
	$tarrif_heading=$_REQUEST['tarrifHeading'];
	$ex_cust_group=$_REQUEST['ex_cust_group'];
	$payment_term=$_REQUEST['payment_term'];					  
	$desitination=$_REQUEST['desitination'];
	
	  $AccountSQL=DB_query("select * from accountledger where AccountsId='".$party."'",$db);
		$AccountSQLRow=DB_fetch_array($AccountSQL);
		if($AccountSQLRow['ledgertype']=='client')
		{
	   $clientid=$AccountSQLRow['vender_client'];
		}
		else
		{
		$clientid=$AccountSQLRow['AccountName'];
		}
	
					  
  
}
//$sql_client=mysql_query("select * from clientmaster");
//$$sql_fetch_array=mysql_fetch_array()
?>
<?php
if($_REQUEST['Save']!='')
{
   $insert1="Insert into dispatch set
					 site='".$_REQUEST['site1']."',    
					 adviceNo='".$_REQUEST['adviceNo1']."', 
					 party='".$_REQUEST['party1']."',   
					 dispatchDate='".FormatDateForSQL($_REQUEST['dispatchDate1'])."',  
					 againstSOP='".$_REQUEST['againstSOP1']."',  
  					 totalDispatch='".$_REQUEST['totalDispatch']."',
					 remarks='".$_REQUEST['remarks']."', 
					da_refno='".$_REQUEST['da_refno']."',
					our_refno ='".$_REQUEST['our_refno']."',
					form_status='".$_REQUEST['form_status']."',
					form_no='".$_REQUEST['form_no']."',
					dispatch_mode='".$_REQUEST['dispatch_mode']."',
					ecc_no='".$_REQUEST['ecc_no']."',
					ex_cust_group='".$_REQUEST['ex_cust_group']."',
					name_of_commodity='".$_REQUEST['excisableComm']."',
 					tarrif_heading='".$_REQUEST['tarrifHeading']."',
					payment_term='".$_REQUEST['payment_term']."',
					desitination='".$_REQUEST['desitination']."',
				  	basicAmount='".$_REQUEST['basicAmount']."',
					totalDiscountedPrice='".$_REQUEST['totalDiscountedPrice']."',
					ECessID='".$_REQUEST['ECessID']."',
					ECessValue='".$_REQUEST['ECessValue']."',
					ECessPercentage='".$_REQUEST['ECessPercentage']."',
					SAHCessPercentage='".$_REQUEST['SAHCessPercentage']."',
					SHECessId='".$_REQUEST['SHECessId']."',
					SAHCessValue='".$_REQUEST['SAHCessValue']."',
					taxableAmount='".$_REQUEST['SAHCessValue']."',
					VatCst='".$_REQUEST['VatCst']."',
					VatCstValue='".$_REQUEST['VatCstValue']."',
					grandTotal='".$_REQUEST['grandTotal']."',
					
 					  CompanyId='".$_SESSION['ACGCompanyId']."',
					 createdBy='".$_SESSION['UserID']."',
					 createdDate='".date('Y-m-d')."'  ";
					 
					  
	$result1=DB_query($insert1,$db);
	
	$masterId=DB_Last_Insert_ID($db,'dispatch','id');
	
	if($masterId!='')
	{
			$totalDispatch=0;
		for($y=0;$y<$_REQUEST['count'];$y++)
		{
			 $insert2="Insert into dispatch_details set 
							 parentId='".$masterId."',
							 SOPNo='".$_REQUEST['SOPNo'][$y]."',  
							 item='".$_REQUEST['item'][$y]."',    
							 orderQty='".$_REQUEST['orderQty'][$y]."',  
							 dispatchQty='".$_REQUEST['dispatchQty'][$y]."',  
							 boxDetails='".$_REQUEST['boxDetails'][$y]."', 
							 Price='".$_REQUEST['Rate'][$y]."',
							 AssValue='".$_REQUEST['assable_value'][$y]."', 
							  weight='".$_REQUEST['weight'][$y]."',  
							  EdRate='".$_REQUEST['HidRate'][$y]."',  
							  EDamount='".$_REQUEST['EDamount'][$y]."',  
							 piecePerBox='".$_REQUEST['piecePerBox'][$y]."'";
						 
			$result2=DB_query($insert2,$db);
			
			
			 $totalDispatch=$totalDispatch+$_REQUEST['dispatchQty'][$y];
			
			$p=$_REQUEST['pendingQty'][$y];
			$dispatchQty=$_REQUEST['dispatchQty'][$y];
			$pendindQty=$p-$dispatchQty;

			if($dispatchQty==$p)
			{
				$update1="Update salesorder_details set pendingForDispatch='0',pendingQty='0' where id='".$_REQUEST['rowId'][$y]."'";
			}
			else if($dispatchQty!=$p)
			{
				$update1="Update salesorder_details set pendingQty='".$pendindQty."' where id='".$_REQUEST['rowId'][$y]."'";
			}
			$updateResult1=DB_query($update1,$db);
		}
		$updateDispatchQty=DB_query("Update dispatch set totalDispatch='".$totalDispatch."' where id='".$masterId."'",$db);
	}

	 $salesDetailsArray=explode(',',$_REQUEST['againstSOP1']);
	for($d=0;$d<count($salesDetailsArray);$d++)
	{
		$check_pending=DB_query("Select pendingForDispatch from salesorder_details where masterId='".$salesDetailsArray[$d]."'",$db);
		$pending='0';
		while($pendingResult=DB_fetch_array($check_pending))
		{
			$pending=$pending+$pendingResult['pendingForDispatch'];
		}	
		if($pending=='0')
		{
			$updatesql2=DB_query("Update salesorder set status='dispatched' where id='".$salesDetailsArray[$d]."'",$db);
		}	
	
}	
prnMsg( _('Record Inserted Successfully'),'success');
echo "<script>location.href='index.php?route=CRM/dispatch_list&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";	
}
?>
 <script language="javascript" type="text/javascript">
function calqty(k)
{
 	var dispatchQty=document.getElementById("dispatchQty_"+k).value;
	var Qty=document.getElementById("orderQty_"+k).value;
	var Rate=document.getElementById("Rate_"+k).value;
 	var total=parseFloat(dispatchQty)*parseFloat(Qty);
 	var HRate=document.getElementById("HidRate_"+k).value;
   //document.getElementById("EDamount_"+k).value=dispatchQty*Rate*.01;

		document.getElementById("assable_value_"+k).value=dispatchQty*Rate ;


}
 
function calculateBasic()
{

	var count1=document.getElementById("count").value;
	total=0;
	
	for(var k=0;k<count1;k++)
	{
	 	var dispatchQty=document.getElementById("dispatchQty_"+k).value;
		if(dispatchQty!=''){
 		var Qty=document.getElementById("assable_value_"+k).value; 
 		total+=parseFloat(Qty);}
		
 	}
	if(total!=0)
	  document.getElementById("basicAmount").value=total ;
 }


function calculateDiscounted()
{
	var totalDiscounted=0;
	var cnt=document.getElementById("count").value;
       for(var i=0;i<cnt;i++)
      {
 	    var totalDiscounted1=document.getElementById("EDAmt_"+i).value;
 	    
 	    var totalDiscounted=(parseFloat(totalDiscounted)+parseFloat(totalDiscounted1)).toFixed(2);
  	 }
	 if(totalDiscounted1!=='0.00')
	 {
 	document.getElementById("totalDiscountedPrice").value=totalDiscounted;
	}
	else{
		var total=document.getElementById("basicAmount").value;
		var Edrate=document.getElementById("EDRate_"+i).value;
		var discountEdrate=((parseFloat(Edrate)*parseFloat(total) )/100);
		document.getElementById("totalDiscountedPrice").value=discountEdrate.toFixed(2);
	}
	
}

function calculateECess()
{
	var exciseValue=document.getElementById("totalDiscountedPrice").value;
	var ECessPercentage=document.getElementById("ECessPercentage").value;
	var total=exciseValue*(ECessPercentage/100);
	document.getElementById("ECessValue").value=total.toFixed(2);
}

function calculateSAHCess()
{
	var exciseValue=document.getElementById("totalDiscountedPrice").value;
	var SAHCessPercentage=document.getElementById("SAHCessPercentage").value;
	var total=exciseValue*(SAHCessPercentage/100);
	document.getElementById("SAHCessValue").value=total.toFixed(2);
}
function calculateTaxable()

{
	var Basic=document.getElementById("basicAmount").value;
	var totalDiscountedPrice=document.getElementById("totalDiscountedPrice").value;
	
	
	var ECessValue=document.getElementById("ECessValue").value;
	var SAHCessValue=document.getElementById("SAHCessValue").value;
	
	
	
	if(totalDiscountedPrice==''){totalDiscountedPrice=0;}
	
	if(ECessValue==''){ECessValue=0;}
	if(SAHCessValue==''){SAHCessValue=0;}
	
	var TOTAL=parseFloat(totalDiscountedPrice)+parseFloat(ECessValue)+parseFloat(SAHCessValue)+parseFloat(Basic);
	document.getElementById("taxableAmount").value=TOTAL.toFixed(2);
}

function calculateVATCST(str)
{
	var taxableAmount=document.getElementById("taxableAmount").value;
	if (str.length==0)
  		{
  			document.getElementById("VATId").innerHTML="";
  			return;
  		}
		if (window.XMLHttpRequest)
  		{// code for IE7+, Firefox, Chrome, Opera, Safari
  			xmlhttp=new XMLHttpRequest();
  		}
		else
  		{// code for IE6, IE5
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
  			if (xmlhttp.readyState==4 && xmlhttp.status==200)
    		{
    			document.getElementById("VATId").innerHTML=xmlhttp.responseText;
    		}
  		}
		xmlhttp.open("GET","calculateExcise.php?salesId="+str+"&taxable="+taxableAmount,true);
		xmlhttp.send();
}

function calculateGrand()
{
	
	
	var a=document.getElementById("totalDiscountedPrice").value;
	var b=document.getElementById("taxableAmount").value;
	var c=document.getElementById("VatCstValue").value;
	
	
	
	
	if(b==''){b=0;}
	if(c==''){c=0;}
	
	var GRAND=parseFloat(b)+parseFloat(c);
	document.getElementById("grandTotal").value=GRAND.toFixed(2);
	
}

function calculateEDAmt(j)
{

    
 		
	var EDRate = document.getElementById("EDRate_"+j).value;
	
	if(EDRate=='0')
	{
		
		document.getElementById("EDAmt_"+j).value='0.00';
		
	}
	else{
		
	
	 
 	var assable_value = document.getElementById("assable_value_"+j).value;
 
	var EDAmt=((parseFloat(EDRate)*parseFloat(assable_value) )/100);
 	 document.getElementById("EDAmt_"+j).value=EDAmt.toFixed(2);
 	}
	 
 
}

function CalculateVatCstValue(str)
{
 
 	var taxableammount12=document.getElementById("taxableAmount").value;
 	 
		 
		var VAtCst1= parseFloat(str)*parseFloat(taxableammount12) *.01;
	 	 
		document.getElementById("VatCstValue").value=VAtCst1.toFixed(2);
	 
}

function getTarrifHeading(str)
{
	if (str.length==0)
  		{
  			document.getElementById("commID").innerHTML="";
  			return;
  		}
		if (window.XMLHttpRequest)
  		{// code for IE7+, Firefox, Chrome, Opera, Safari
  			xmlhttp=new XMLHttpRequest();
  		}
		else
  		{// code for IE6, IE5
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
  			if (xmlhttp.readyState==4 && xmlhttp.status==200)
    		{
    			document.getElementById("commID").innerHTML=xmlhttp.responseText;
    		}
  		}
		xmlhttp.open("GET","get_category.php?comm="+str,true);
		xmlhttp.send();
}
</script>

<div class="body_contain">
<h1>Dispatch Slip</h1>

<div class="insideclass">

	
<div style="z-index:-1000em;">
	<div class="demo">

<div id="tabs">
	<ul>
		<li><a href="#tabs-1">Order Detials</a></li>
		<li><a href="#tabs-2">More Information</a></li>


	</ul>
	<div id="tabs-1">
		<div class="tab_div">
			
			<form name="DispatchSlip" action="" method="post" onsubmit="">

 <div>
 <table width="100%" border="0" cellspacing="1" cellpadding="1" align="center">
	<tr class="row1">
	<td class="tabledata1">Branch<span style="color:#FF0000">*</span></td> 
	<td>
	<?php 
	$site_sql=DB_query("Select loccode, locationname from locations  where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')",$db);?>
<select name="site" id="site" style="width:107px;"  onchange="ShowDiv(this.value,'adviceId','codeGenerator.php?type=dispatchSite')" >
	<option value="0">Select</option>
	<?php 
	while($site_row=DB_fetch_array($site_sql))
	{?>
	<option value="<?php echo $site_row['loccode']?>"<?php echo($_REQUEST['site']==$site_row['loccode']?'selected':'')?>><?php echo   $site_row['locationname']?></option>
	<?php 	
	}
	?>
	</select></td>
	<td class="tabledata1">Advice No.<span style="color:#FF0000">*</span></td>
	<td id="adviceId"><input name="adviceNo" id="adviceNo" type="text" value="<?php echo $_REQUEST['adviceNo'];?>" style="width:107px;" /></td>
	</tr>
	<tr class="row1">
	<td class="tabledata1">Party<span style="color:#FF0000">*</span></td>
	<td>
	
	<?php /*
	$arr_con_acc=array();
	$con_accountSql=DB_query("Select Convert_AccountId from crm_leads where deleted_status='N' and Convert_IntoAccountStatus='Y'",$db);
	while($row_Conacc=DB_fetch_array($con_accountSql))
	{
	$arr_con_acc[]=$row_Conacc['Convert_AccountId'];
	}
	$x="";
	if(count($arr_con_acc)>0)
	{
	$x.="'".implode("', '",$arr_con_acc)."'";
	$AccountCompany= "SELECT vender_client,AccountsID,AccountName,ledgertype FROM accountledger WHERE  ledgertype IN('client','leads') or AccountsID IN ($x) and CompanyId='".$_SESSION['ACGCompanyId']."'";
	}else{
	$AccountCompany= "SELECT vender_client,AccountsID,AccountName ,ledgertype FROM accountledger WHERE  ledgertype IN('client','leads') and CompanyId='".$_SESSION['ACGCompanyId']."'";
	}
	$Account_sql=DB_query($AccountCompany,$db);
*/	?>
	<!--<select name="party" id="party" style="width:107px;" onchange="ShowDiv(this.value,'SOPId','showSalesOrders.php?client=tel&branch='+document.getElementById('site').value)" >
	<option value="0">Select</option>
	<?php
 	while($Account_row=DB_fetch_array($Account_sql))
	{
 	if($Account_row['ledgertype']=='client'){
	  	 $ClientSQL="Select Site,Zone from clientmaster where CompanyId='".$_SESSION['ACGCompanyId']."' and  Site='".$_SESSION['AssignedBranch']."' 
		 and id='".$Account_row['vender_client']."' and  Zone in(".$_SESSION['AssignedSites'].") ";
		 }
		 else  if($Account_row['ledgertype']=='leads')
		 {
		 $ClientSQL="Select Site,Zone from clientmaster where CompanyId='".$_SESSION['ACGCompanyId']."' and  Site='".$_SESSION['AssignedBranch']."' 
		 and id='".$Account_row['AccountName']."' and  Zone in(".$_SESSION['AssignedSites'].") ";
 		 }
 	//$ClientSQL="Select Site,Zone from clientmaster where CompanyId='".$_SESSION['ACGCompanyId']."' and  Site='".$_SESSION['AssignedBranch']."' 
	//and id='".$Account_row['vender_client']."' and  Zone in(".$_SESSION['AssignedSites'].") ";
	$ClientRes=DB_query($ClientSQL,$db);
	if(DB_num_rows($ClientRes)>0)
	{
	
	?>
	<option value="<?php  echo $Account_row['AccountsID']?>"<?php echo($_REQUEST['party']==$Account_row['AccountsID'] ? 'selected':'');?>><?php 
	if($Account_row['ledgertype']=='leads')
		echo $s->GetFieldValue('clientmaster',"id='".$Account_row['AccountName']."'",'c_name');
		else 
	  echo $Account_row['AccountName'];
	 ?></option>
	
	<?php 	 }
	}
	?>
	</select>-->	
	
	<select name="party" id="party" style="width:107px;" 
	onchange="ShowDiv(this.value,'SOPId','showSalesOrders.php?client=tel&branch='+document.getElementById('site').value)" >
	<option value="0">Select</option>
	<?php 
	echo 	$ClassParty->ClientList($_SESSION['UserID'],$result1['party']);?>
	 </select>
	 
	 
	 </td>
	<td class="tabledata1">Dispatch Date<span style="color:#FF0000">*</span></td>
	<td><input name="dispatchDate" type="text" value="<?php if(isset($_REQUEST['dispatchDate'])){echo $_REQUEST['dispatchDate'];}else{echo date('d/m/Y');}?>" class="datepicker"  style="width:107px;"/></td>
	</tr>
	 
 	

	
	
	<!--<tr class="row1">
	<td>&nbsp; </td>
	<td >&nbsp; </td>-->
	<!--<td>Date </td>-->
	<!--<td ><input name="po_date" type="text" value="<?php //echo $po_date;?>"  class="datepicker"/>&nbsp;</td>
	</tr>-->
	<tr class="row1">
	<td class="tabledata1">Name of commodity </td>
	<td ><!--<input name="name_of_commodity" type="text" value="<?php echo $name_of_commodity;?>" />-->
	<select name="excisableComm" style="width:107px;" onchange="getTarrifHeading(this.value)" >
		<option value="">Select</option>
		<?php 
		$excisableSql=DB_query("Select * from excisable_commodity_master",$db);
		while($excisableRow=DB_fetch_array($excisableSql))
		{?>
			<option value="<?php echo $excisableRow['id']?>"<?php echo ($excisableComm==$excisableRow['id']?'selected':'')?>><?php echo $excisableRow['commodityName']?></option>
		<?php 	
		}
		?>
	</select>
	</td>
	<td class="tabledata1">Dispatch Mode <span style="color:#FF0000">*</span></td>
	<td ><input name="dispatch_mode" type="text" value="<?php echo $dispatch_mode;?>" style="width:107px;" />&nbsp;</td>
	</tr>
	<tr class="row1">
	<td class="tabledata1">Tarrif Heading  </td>
			<?php 
	$tariffSql=DB_query("Select tarrifHeading from excisable_commodity_master where id='".$excisableComm."'",$db);
	$tariffRow=DB_fetch_array($tariffSql);
		?>
	<td id="commID"><input type="text" name="tarrifHeading" value="<?php echo $tariffRow['tarrifHeading']?>" style="width:107px;"/></td>
	<td class="tabledata1">DA Ref No</td>
	<td><input name="da_refno" type="text" value="<?php echo $da_refno;?>" style="width:107px;" /></td>	
	  </td>		
	</tr>
	<tr class="row1">
	<td class="tabledata1">Payment Terms </td>
	<td ><input name="payment_term" type="text" value="<?php echo $payment_term;?>" style="width:107px;" /> </td>	
	
	<td class="tabledata1">Destination<span style="color:#FF0000">*</span></td>
	<td ><input name="desitination" type="text" value="<?php echo $desitination;?>" style="width:107px;" /> </td>	
	</tr>
  </table>

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

 <div>

	<div id="SOPId">
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<!--<tr class="row1">
	<td>PO No. </td>
	<td ><input name="po_orderno" type="text" value="<?php //echo $po_orderno;?>" />&nbsp;</td>
	<td></td><td></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" type="text" value="<?php echo $cst_vatno;?>" style="width:107px;" /></td>
	
	<td class="tabledata1">Customer Group </td>
	<td>
	<?php 

	$sql_zonedata=DB_query("Select id,ZoneTitle from zone_master where site='".$_REQUEST['site']."'  and CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
$row_zone=DB_fetch_array($sql_zonedata)
?>
<input type="text" name="ex_cust_group" id="ex_cust_group" value="<?php echo $ex_cust_group; ?>" style="width:107px;" />
	  </td>		
	
		
	</tr>
	<tr class="row1">
	<td class="tabledata1">ECC No </td>
	<td ><input name="ecc_no" type="text" value="<?php echo $ecc_no;?>" style="width:107px;" /></td>
	<td class="tabledata1">Our Ref No</td>
	<td><input type="text" name="our_refno" value="<?php echo $our_ref_no; ?>" style="width:107px;" /></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>
	<tr class="row1">
	<td colspan="4">
	<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
	<td class="tabledata1">Against Single/Multiple S. O. P.</td>
	<?php 
	//echo $_REQUEST['againstSOP'];
	if($_REQUEST['Proceed']!='' && $_REQUEST['againstSOP']!='')
	{
	$finalArray=explode(',',implode(',',$_REQUEST['againstSOP']));
	//print_r($finalArray);
	}
	?>
	<td nowrap="nowrap">
	<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['site']."' 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['site']."' and client='".$clientid."' and status='pending'",$db);
	$i=0;	
	while($myrow2=DB_fetch_array($sql2))
	{
	$c='';
	for($x=0;$x<count($finalArray);$x++)
	{
		if($_REQUEST['againstSOP'][$i]==$finalArray[$x])
		$c="checked";
	}
	?>
	<input type="checkbox" name="againstSOP[<?php echo $i;?>]" value="<?php echo $myrow2['id']?>" <?php echo $c;?>/><?php echo $myrow2['orderNo']?><?php echo '--'.'&nbsp;&nbsp;'.$myrow2['PORefNo']; ?><br/>
	<?php 	$i++;
	}
	?>			
	</div>    </td>
	</tr>
	</table>	    </td>
	</tr>
</table>
	</div>
 
  </div>

<div style="clear:both;"></div>
 <p align="center"><input type="submit" name="Proceed" value="Proceed" onclick="return Dispatch_Slip()" /><input type="submit" name="Cancel" value="Cancel" /></p>
</form>
	<div style="overflow:scroll; width:730px;float:left;">		
 <?php
if($_REQUEST['Proceed']!='' && $_REQUEST['againstSOP']!='')
{
	$SOParray=array();
	$SOParray=$_REQUEST['againstSOP'];
    $SOstring=implode(',',$SOParray); 
	//echo $SOstring;

?><form action="" method="post">
 <input type="hidden" name="site1" value="<?php echo $_REQUEST['site'];?>" />
<input type="hidden" name="adviceNo1" value="<?php echo $_REQUEST['adviceNo'];?>" />
<input type="hidden" name="party1" value="<?php echo $_REQUEST['party'];?>" />
<input type="hidden" name="dispatchDate1" value="<?php echo $_REQUEST['dispatchDate'];?>" />
<input type="hidden" name="againstSOP1" value="<?php echo $SOstring;?>" />
<input type="hidden" name="site1" value="<?php echo $_REQUEST['site'];?>" />

 <input type="hidden" name="party" value="<?php echo $_REQUEST['party'];?>" />
<input type="hidden" name="dispatchDate" value="<?php echo $_REQUEST['dispatchDate'];?>" />
<input type="hidden" name="cst_vatno" value="<?php echo $_REQUEST['cst_vatno'];?>" />
<input type="hidden" name="da_refno" value="<?php echo $_REQUEST['da_refno'];?>" />
<input type="hidden" name="ecc_no" value="<?php echo $_REQUEST['ecc_no'];?>" />

<input type="hidden" name="our_refno" value="<?php echo $_REQUEST['our_refno']; ?>" />

<input type="hidden" name="form_status" value="<?php echo $_REQUEST['form_status'];?>" />

<input type="hidden" name="form_no" value="<?php echo $_REQUEST['form_no'];?>" />

<input type="hidden" name="excisableComm" value="<?php echo $_REQUEST['excisableComm'];?>" />
<input type="hidden" name="dispatch_mode" value="<?php echo $_REQUEST['dispatch_mode'];?>" />
<input type="hidden" name="tarrifHeading" value="<?php echo $_REQUEST['tarrifHeading'];?>" />
<input type="hidden" name="ex_cust_group" value="<?php echo $_REQUEST['ex_cust_group'];?>" />
<input type="hidden" name="payment_term" value="<?php echo $_REQUEST['payment_term'];?>" />
<input type="hidden" name="desitination" value="<?php echo $_REQUEST['desitination'];?>" />

	<table width="100%" cellpadding="1" cellspacing="1">
		<tr class="row1">
			<td>Sno.</td>
			<td>Code</td>
			<td>Item/Shade Name </td>
			<td>Item Desc</td>
			<td>Unit</td>
			<td>S.O.P No.</td>
			
			<td> Order Qty</td>
			<td>Dispatch Qty </td>
			<td> Price</td>	<td> Ass. Value</td>
			<td>Pending Qty</td>
			<td>EDRate</td><td>EDAmount</td>
			<td>Box Details</td>
			<td>Weight</td>
			<td>Piece Per Box</td>
		</tr>
		<?php 

if($_REQUEST['Proceed']!='')
		{
			if($_REQUEST['againstSOP']!='')
			{
				//echo "Select * from salesorder where id in (".$SOstring.")  ";
				$details_data=DB_query("Select * from salesorder where id in (".$SOstring.") and CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
				$row=DB_fetch_array($details_data);
				 $test_amit=$row['Sale_Key_Exec']; 
			// echo"Select * from salesorder_details where masterId in (".$SOstring.") and pendingForDispatch!='0' and ApprovalStatus='Approved'";				
				$details_sql=DB_query("Select * from salesorder_details where masterId in (".$SOstring.") and pendingForDispatch!='0' and ApprovalStatus='Approved'",$db);
			}
				if(DB_num_rows($details_sql)>0)	
			{

		$j=0; 

		while($details_row=DB_fetch_array($details_sql))
		{	
		
		//echo "Select item_name,unit from item_master where StockID='".$details_row['ItemCode']."'";
			$item_sql=DB_query("Select item_name,unit,StockID,item_desc from item_master where  id='".$details_row['ItemCode']."'",$db);
			$item_row=DB_fetch_array($item_sql);
		?>
		<tr bgcolor="#FFFFF" valign="top">
		<td><?php echo $details_row['ItemCode']?><input type="hidden" name="rowId[<?php echo $j;?>]" value="<?php echo $details_row['id']?>" /><input type="hidden" name="item[<?php echo $j;?>]" value="<?php echo $details_row['ItemCode']?>"   size="10"  /></td>
		<td><?php echo $item_row['StockID']?></td>
		<td><?php echo $item_row['item_name']?></td>
		<td><?php echo $item_row['item_desc']?></td>
		<td><?php echo	$unitName=$s->getField('unitsofmeasure','unitid',$item_row['unit'],'unitname');	 ?></td>
		<td><?php $SOPNo=$s->getField('salesorder_details','id',$details_row['id'],'masterId');
			   echo $SOPCode=$s->getField('salesorder','id',$SOPNo,'orderNo');
		?><input type="hidden" name="SOPNo[<?php echo $j;?>]" id="SOPNo_<?php echo $j;?>" value="<?php echo $SOPNo;?>" /></td>
		<td><?php echo $details_row['Quantity']?></td>
		<td><input type="text" name="dispatchQty[<?php echo $j;?>]"  id="dispatchQty_<?php echo $j;?>"    size="10"  onblur="calqty(<?php echo $j;?>)"  /></td>
		
		<td><input type="text" name="Rate[<?php echo $j;?>]" id="Rate_<?php echo $j;?>" value="<?php  echo $details_row['Rate']?>"  size="10"/>
		<input type="hidden" name="orderQty[<?php echo $j;?>]" id="orderQty_<?php echo $j;?>" value="<?php echo $details_row['Quantity']?>"  size="10"  />&nbsp;
		</td>
		<td>
		<input  type="text"   size="10" name="assable_value[<?php echo $j;?>]" id="assable_value_<?php echo $j;?>" readonly />
		</td>
		<td><?php if($details_row['pendingQty']!='' && $details_row['pendingQty']!='0'){echo $details_row['pendingQty'];}else{echo $details_row['Quantity'];}?><input type="hidden" name="pendingQty[<?php echo $j;?>]" value="<?php if($details_row['pendingQty']!='' && $details_row['pendingQty']!='0'){echo $details_row['pendingQty'];}else{echo $details_row['Quantity'];}?>"  /></td>
		
		<td>
			<select name="EDRate[<?php echo $j;?>]" id="EDRate_<?php echo $j?>" style="width:107px" 
		onchange="ShowDiv(this.value,'hid_ED_div_<?php echo $j?>','calculateExcise.php?type=TELORD&i=<?php echo $j;?>&amount='+document.getElementById('assable_value_<?php echo $j;?>').value)">
    		<option value="0">--Select--</option>
    		<?php
    		$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
			$ServiceRes=DB_query($ServiceSql,$db);
			while($ServiceRow=DB_fetch_array($ServiceRes))
			{
			?>
		  <option value="<?php echo $ServiceRow['id']?>" <?php echo $details_row['EDRate']==$ServiceRow['id']?'selected':''?>><?php echo $ServiceRow['caption']?>
		  </option>
			<?php	
			}
    		
    		?>
    		</select>
		 
 		 <input type="hidden" name="HidRate[<?php echo $j;?>]" id="HidRate_<?php echo $j;?>" value="<?php  echo $s->getField('excise_tax','id',$details_row['EDRate'],'id');?>"   />
		 </td>
		 <td>
		 <div id='hid_ED_div_<?php echo $j?>'>  
 		<input type="text" name="EDamount[<?php echo $j;?>]" id="EDAmt_<?php echo $j;?>" value="<?php echo $details_row['EDAmt']; ?>" />
		</div>
		</td>
		<td><input type="text" name="boxDetails[<?php echo $j;?>]" value=""   size="10"  /></td>
		<td><input type="text" name="weight[<?php echo $j;?>]" value=""   size="10"  /></td>
		<td><input type="text" name="piecePerBox[<?php echo $j;?>]" value=""   size="10"  /></td>	
		</tr>
		<?php $j++;} ?>
		<input type="hidden" name="count"  id='count' value="<?php echo $j;?>"/>
	</table>
			</div>
	<div style="width:200px; float: right;">
		<table width="100%" border="0" cellspacing="1" cellpadding="0" align="right" bgcolor="#FFFFFF" style="border:1px solid #ccc;">
					<tr class="row1">
				<td style="text-align:center;" colspan="2">Amount And Taxes</td>
			</tr>
			<tr class="row1">
		  <tr class="row1">
					<td>Value Of Goods<label><font color="#FF0000">*</font></label></td>
					<td><input name="basicAmount" type="text"  style="width:107px;" onfocus="calculateBasic()" id="basicAmount" value="<?php  echo $row['basicAmount']?>"/></td>
					
		  </tr>
				  <tr class="row1">
					<td nowrap="nowrap">Excise Duty<label><font color="#FF0000">*</font></label></td>
					<td>
					<select name="EDRate[<?php echo $j;?>]" id="EDRate_<?php echo
		 $j?>" style="width:107px">
    		<option value="0">--Select--</option>
    		<?php
    		$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
			$ServiceRes=DB_query($ServiceSql,$db);
			while($ServiceRow=DB_fetch_array($ServiceRes))
			{
			?>
			<option value="<?php echo $ServiceRow['def_rate']?>"><?php echo $ServiceRow['caption']?></option>
			<?php	
			}
    		
    		?>
    		</select>
					<input name="totalDiscountedPrice" id="totalDiscountedPrice" type="text"  style="width:107px;" onfocus ="calculateDiscounted()" value="<?php  echo $row['TotalExciseValue']?>"/>
					
					
					</td>
					
				</tr>
				 
					 
					
					 <tr class="row1">
					<td>E-Cess</td>
					<td>
						<?php  $SQl=DB_query("SELECT * FROM excise_tax WHERE caption LIKE '%Edu Cess%'",$db);
						$RESULT=DB_fetch_array($SQl);
						
						
						  ?>
						<input type="hidden" name="ECessID" value="<?php echo $RESULT['id']?>">
						
						<input name="ECessPercentage" id="ECessPercentage" type="text" value="<?php echo $RESULT['def_rate'];?>"  readonly size="6" />
						<input name="ECessValue" id="ECessValue" type="text"   readonly onFocus="calculateECess()" value="<?php echo $row['ECessValue'];?>" size="6" /></td>
					</tr>
					<tr class="row1">
					<td nowrap="nowrap">SHE-E Cess </td>
					<?php  $SQl=DB_query("SELECT * FROM excise_tax WHERE caption LIKE '%SHE Cess%'",$db);
						$RESULT=DB_fetch_array($SQl);
						
						
						  ?>
					
					
					
					<td>
						<input type="hidden" name="SHECessId" value="<?php echo $RESULT['id']?>">
						
						<input name="SAHCessPercentage" id="SAHCessPercentage" type="text" value="<?php echo $RESULT['def_rate'];?>" size="6"readonly/>
						<input name="SAHCessValue" id="SAHCessValue" type="text" size="6" readonly onFocus="calculateSAHCess()" value="<?php echo $row['SAHCessValue'];?>"/></td>
					</tr>
				  
				  
		   <tr class="row1">
			<td>Taxable Amount<label><font color="#FF0000">*</font></label></td>
			<td><input name="taxableAmount" id="taxableAmount" type="text" style="width:107px;" onFocus="calculateTaxable()" value="<?php echo $row['taxableAmount'];?>"/></td>
		   </tr>
				  
				  
				  
				  <tr class="row1">
					<td>VAT/CST</td>
					<td><?php  
				$editsalid= 	$s->GetFieldValue('sales_tax_master',"salestax_id='".$row['VatCst']."'" ,'taxrate');
					 ?>
					<select name="VatCst" id="value3" style="width:107px;" onChange="calculateVATCST(this.value)">
					<option value="0" >Select</option>
					<?php 
					$salesSql=DB_query("Select * from sales_tax_master",$db);
					while($salesRow=DB_fetch_array($salesSql))
					{?>
						<option value="<?php echo $salesRow['salestax_id'];?>" <?php echo  $row['VatCst']==$salesRow['salestax_id']?'selected':''?>><?php echo $salesRow['tax_code'];?></option>
					<?php 	
					}
					?>
				  </select>
					  <div id="VATId"><input name="VatCstValue" id="VatCstValue" type="text"  style="width:107px;"
					    value="<?php    echo  $row['VatCstValue'];  ?>" onfocus="CalculateVatCstValue(<?php echo $editsalid ?>)"/>
					 
						</div></td>
 				</tr>
 				<tr class="row1">
					<td>Grand Total<label><font color="#FF0000">*</font></label></td>
					<td><input name="grandTotal" id="grandTotal" type="text"  style="width:107px;" onFocus="calculateGrand()" readonly="readonly"  value="<?php    echo $row['grandTotal'];  ?>" /></td>
					
				</tr>
	  </table>
  </div>
  
 
<div style="width:760px; float:left;">
	<table width="100%">
		<tr class="row1">
			<td>Remarks</td>
			<td><textarea name="remarks" cols="50" rows="5"></textarea></td>
		</tr>
	</table>
</div>	
<div style="clear:both;"></div>
	<p align="center"><input type="submit" name="Save" value="Save" /></p>
	
</form>
<?php }
else { ?>
	<tr bgcolor="#FFFFFF">
<td colspan="12" style="color:#FF0000;">No Records Find</td>
</tr> <?php } 
} }?>			
			
	
		</div>
	</div><!-- Tab 1 Close -->
	
	<div id="tabs-2">
		

			<div style="width:auto;">
				<p style="margin:0px; padding:0px; text-align:left; font-weight:bold">Comment 1</p>
				<p style="margin:0px; padding:0px; text-align:left;"><textarea style="width:700px;" ></textarea></p>				
			<p style="margin:0px; padding:0px; text-align:left; color:#003366">User Name 1</p>
			
			</div>
			<br />
			<div style="width:auto;">
				<p style="margin:0px; padding:0px; text-align:left; font-weight:bold">Comment 2</p>
				<p style="margin:0px; padding:0px; text-align:left;"><textarea style="width:700px;" ></textarea></p>				
			<p style="margin:0px; padding:0px; text-align:left; color:#003366">User Name 2</p>
			
			</div>
			<br />
			<div style="width:auto;">
				<p style="margin:0px; padding:0px; text-align:left; font-weight:bold">Comment 3</p>
				<p style="margin:0px; padding:0px; text-align:left;"><textarea style="width:700px;" ></textarea></p>				
			<p style="margin:0px; padding:0px; text-align:left; color:#003366">User Name 3</p>
			
			</div>
			<br />
			<div style="width:auto;">
				<p style="margin:0px; padding:0px; text-align:left; font-weight:bold">Comment 4</p>
				<p style="margin:0px; padding:0px; text-align:left;"><textarea style="width:700px;" ></textarea></p>				
			<p style="margin:0px; padding:0px; text-align:left; color:#003366">User Name 4</p>
			
			</div>


	<p style="text-align:right;"><input type="button" value="Save" name="save" /></p>

	</div><!-- Tab 2 Close -->



</div></div></div>

</div><!-- inside div close -->
</div><!-- Main div close -->
  

<script language="javascript" type="text/javascript">
	function Dispatch_Slip()
		{
			if(document.DispatchSlip.site.value=='0')
				{
					alert("Please Select The Branch Name First");
					return false;
				}
				else if(document.DispatchSlip.party.value=='0')
				{
					alert("Please Select Party First");
					return false;
				}
				else if(document.DispatchSlip.adviceNo.value=='')
				{
					alert("Please Enter The Advoice No First");
					return false;
				}
				else if(document.DispatchSlip.dispatchDate.value=='')
				{
					alert("Please Select The Dispatch date");
					return false;
				}
				else if(document.DispatchSlip.dispatch_mode.value=='')
				{
					alert("Please Enter The Dispatch Mode");
					return false;
				}
				else if(document.DispatchSlip.desitination.value=='')
				{
					alert("Please Enter The Desitination");
					return false;
				}
				return true;
				
		}
</script>

