	<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 
if($_REQUEST['QID']!='' &&  $_REQUEST['SID']=='')
{ 
	$sql1=DB_query("Select * from quotation where id='".$_REQUEST['QID']."'",$db);
	$result1=DB_fetch_array($sql1);
	$site= $result1['site']; 
	$quotationNo=$result1['quotationNo'];  
	$quotationDate=ConvertSqlDate($result1['quotationDate']);  
	$party=$result1['party'];   
	$quotationType=$result1['quotationType'];
	$quotation_subject=$result1['quotation_subject'];
	$quotation_funnel  =$result1['quotation_funnel'];
	$PPC  =$result1['PPC'];
	$orderReceived   =$result1['orderReceived'];
	$PORefNo=$result1['PORefNo'];  
	$partyContact=$result1['partyContact'];  
	$validTill=ConvertSqlDate($result1['validTill']);  
	$pack_forward=$result1['pack_forward'];  
	$freight=$result1['freight']; 
	$payTerms=$result1['payTerms'];  
	$salesTax=$result1['salesTax'];  
	$Excise=$result1['Excise'];  
	$insurance=$result1['insurance'];  
	$basicAmount=$result1['basicAmount'];  
	$totalDiscountedPrice=$result1['totalDiscountedPrice'];  
	$exciseDuty=$result1['exciseDuty'];  
	$exciseValue=$result1['exciseValue'];  
	$ECessValue=$result1['ECessValue'];  
	$SAHCessValue=$result1['SAHCessValue'];  
	$taxableAmount=$result1['taxableAmount'];
	$VatCst=$result1['VatCst'];  
	$VatCstValue=$result1['VatCstValue'];  
	$freightValue=$result1['freightValue'];  
	$packagingCharges=$result1['packagingCharges'];  
	$additionalCharges=$result1['additionalCharges'];  
	$roundOff=$result1['roundOff'];  
	$grandTotal=$result1['grandTotal'];  
	$createdBy=$_SESSION['UserID'];  
}


if($_REQUEST['SID']!='' && $_REQUEST['QID']!='')
{
	$sql1=DB_query("Select * from salesorder where id='".$_REQUEST['SID']."'",$db);
	$result1=DB_fetch_array($sql1);
	extract($result1);
}?>
<div class="body_contain">
<h1>Process Sales Order</h1>

<div class="insideclass">


	<?php  
if($_REQUEST['action']=='Edit'){
	?>
	 <a href="CRM/tcpdf/PDFSalesOrder.php?record=<?php echo $_REQUEST['QID'].'&Sid='.$_REQUEST['SID'].$rurl;?>">
	 <input type="button" name=" Export to PDF" value=" Export to PDF" style=" background-image:
	 url(images/PDF.gif)background-color:#d1d4be; color:#006699; font-weight:800; padding-top:3px; padding-bottom:3px; " />
</a><?php } ?>


<div style="z-index:-1000em;">
	<div class="demo">
<?php
   $appstatus=$s->GetFieldValue('salesorder_details',"masterId='".$_REQUEST['SID']."' ",'ApprovalStatus');
		if($appstatus=='3' || $appstatus=='2')
		{
	?>
	
	 <a href="index.php?route=CRM/ConvertSaleOrder_Into_Dispatch&SID=<?php  echo $_REQUEST['SID'].$rurl;?>">
<input type="button" name="Create" value="Convert into Dispatch " class="search" />
</a><?php  }else{
echo "Approval Pending";
}?> 
<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">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr class="row1">
    <td class="tabledata1">Branch</td>
    <td><?php echo $s->GetFieldValue('locations',"loccode='".$branch."'",'locationname'); ?></td>
    <td class="tabledata1">Order No.</td>
    <td id="CODE"><?php echo $orderNo;?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">Cost Center No</td>
    <td nowrap="nowrap"><?php echo $cost_center; ?></td>
    <td class="tabledata1">Date</td>
    <td nowrap="nowrap"><?php echo ConvertSQLDate($orderDate); ?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">Account Name</td>
    <td nowrap="nowrap"><?php echo $s->GetFieldValue('clientmaster',"id='".$client."'",'c_name'); ?></td>
   <td class="tabledata1">Against   Quotation </td>
    <td><?php echo $s->GetFieldValue('quotation',"id='".$_REQUEST['QID']."'",'quotationNo'); ?></td>
    </tr>
  <tr class="row1">
   <td class="tabledata1">Address</td>
    <td><?php echo $s->GetFieldValue('clientmaster',"id='".$client."'",'pre_address1'); ?></td>
    <td class="tabledata1">Contact Person</td>
    <td nowrap="nowrap"><?php echo $s->GetFieldValue('contact_information_master',"id='".$ContactPerson."'",'person'); ?></td>
  </tr>
  
  
  <tr class="row1">
    <td class="tabledata1">&nbsp;</td>
    <td nowrap="nowrap"><?php $City=$s->GetFieldValue('clientmaster',"id='".$client."'",'pre_city'); ?>
						<?php echo $City1=$s->GetFieldValue('city_master',"id='".$City."'",'city'); ?>
	</td>
    <td class="tabledata1">Phone No</td>
	<td><?php echo $s->GetFieldValue('contact_information_master',"id='".$ContactPerson."'",'phone'); ?></td>
</tr>

  <tr class="row1">
    <td class="tabledata1">&nbsp;</td>
    <td nowrap="nowrap"><?php $State=$s->GetFieldValue('clientmaster',"id='".$client."'",'pre_state'); ?>
						<?php echo $State1=$s->GetFieldValue('state_master',"id='".$State."'",'state'); ?>
	</td>
    <td class="tabledata1">&nbsp;</td>
	<td></td>
</tr>

  <tr class="row1">
    <td class="tabledata1">Client PO No</td>
    <td nowrap="nowrap"><?php echo $PORefNo; ?></td>
    <td class="tabledata1">PO Date</td>
    <td><?php echo ConvertSQLDate($customerPODate); ?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">Delivery Date</td>
    <td nowrap="nowrap"><?php echo ConvertSQLDate($DeliveryDate); ?></td>
    <td class="tabledata1">Road Permit</td>
    <td><?php echo $RoadPermit; ?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">Transport</td>
    <td><?php echo $s->GetFieldValue('transport_master',"id='".$Transport."'",'TransportName'); ?></td>
	<td class="tabledata1">Freight Type</td>
    <td><?php if($freight=='Paid'){echo 'Paid';}
			  if($freight=='topay'){echo 'To Pay';}
			  if($freight=='Nill'){echo 'Nill';} ?></td>
  </tr>
  
    <tr class="row1">
    <td class="tabledata1">Status</td>
    <td><?php echo $TelStatus; ?></td>
	<td class="tabledata1">Sales Key Executive</td>
    <td><?php echo $s->GetFieldValue('www_users',"id='".$Sale_Key_Exec."'",'userid'); ?></td>
  </tr>
  
   <tr class="row1">
    <td class="tabledata1">Category</td>
    <td><?php echo $cate; ?></td>
	<td class="tabledata1"> Order Type</td>
    <td><?php if($order_type=='Consolidate'){echo 'TBI';}
			  if($order_type=='MRP_Item'){echo 'MRP Item Wise';} ?></td>
  </tr>
<tr class="row1">
	<td colspan="4">
	 <h3>Item Details</h3>
	</td>
</tr>
</table>

<?php  if($_REQUEST['QID']!='' && $_REQUEST['SID']!=''){?>
<table width="100%" cellpadding="3" cellspacing="0" border="1">
<tr class="row1">
<td class="tabledata">Sr.No.</td>
<td class="tabledata">Item Code</td>
<td class="tabledata">Item Name</td>
<td class="tabledata">Item Desc</td>
<td class="tabledata">Qty</td>
<td class="tabledata">Approved Qty</td>
<td class="tabledata">Price</td>
<!--<td class="tabledata">Per Unit(s)</td>-->
<td class="tabledata">Total Amt</td>
<td class="tabledata">Excise Duty Rate</td>
<td class="tabledata">ED Amt</td>
 <td class="tabledata">Remark</td>
</tr>
<?php $total=0;$i=0;$after_discount=0;
$getitem=DB_query("select * from salesorder_details where masterId='".$_REQUEST['SID']."' ",$db); 
while($row=DB_fetch_array($getitem)){
$itemquery=DB_query("select * from item_master where id='".$row['ItemCode']."'" , $db);
$item_row=DB_fetch_array($itemquery);
if($i%2==0)
{$bg="#CCCCCC";}
else
$bg="#C8BECB";?>

<?php 
if($row['pendingQty']=='')
{
$approvedQTY=$row['Approved_qty'];
}
else
{
$approvedQTY=$row['Approved_qty']-$row['pendingQty'];
}

?>
<tr class="row1">
	<td><?php echo $i+1; ?></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 $row['Quantity'];?></td>
	<td><?php echo $row['Approved_qty'];?></td>
	<td><?php echo $row['Rate'];?></td>
	<!-- <td><?php echo $row['pricePer'];?></td>-->
	<td><?php echo $row['Amount'];?></td>
	<td><?php echo $s->GetFieldValue('excise_tax',"id='".$row['EDRate']."'",'caption');?></td>
	<td><?php echo $row['EDAmt']; ?></td>
	<td><?php echo $row['remarks']; ?></td>
</tr>
<?php $i++;} }?>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="3" >
<tr class="row1">
	<td style="width:50%" align="left">&nbsp;</td>
	<td style="width:50%" align="right">
		<table width="100%" border="0" cellspacing="0" cellpadding="3" >
		<tr class="row1">
		<td class="tabledata1">Basic Amount</td>
		<td><?php echo $basicAmount;?></td>
		</tr>
		<tr class="row1">
		<td class="tabledata1">Excise</td>
		<td><?php echo $s->GetFieldValue('excise_tax',"id='".$exciseDuty."'",'caption')." | ".$TotalExciseValue;?></td>
		</tr>
		
		<tr class="row1">
		<td class="tabledata1">E-Cess</td>
		<td><?php echo $ECessPercentage." | ".$ECessValue; ?></td>
		</tr>
		<tr class="row1">
		<td class="tabledata1">SAH-E Cess </td>
		<td><?php echo $SAHCessPercentage." | ".$SAHCessValue; ?></td>
		</tr>
		
		
		<tr class="row1">
		<td class="tabledata1">Taxable Amount</td>
		<td><?php echo $taxableAmount; ?></td>
		</tr>
		
		<tr class="row1">
		<td class="tabledata1">VAT/CST</td>
		<td><?php echo $s->GetFieldValue('sales_tax_master',"salestax_id='".$VatCst."'",'tax_code')." | ".$VatCstValue;; ?></td>
		</tr>
		
		
		<tr class="row1">
		<td class="tabledata1"><strong>Grand Total</strong></td>
		<td><?php echo $grandTotal; ?></td>
		</tr>
		</table>
	</td>
</tr>
</table>
		</div>
</div><!-- Tab 1 Close -->
<?php $commSQL=DB_query("select * from salesorder_comments where sopno='".$id."'",$db);
	  if(DB_num_rows($commSQL)>0){
	  $Comments=DB_fetch_array($commSQL);
	  extract($Comments);
	  }
	  $username=$s->GetFieldValue('www_users',"id='".$user."'",'userid');
	  ?>
	<div id="tabs-2">
			<div style="width:auto;">
				<p style="margin:0px; padding:0px; text-align:left;"><textarea readonly="readonly" style="width:700px;" ><?php echo $comment; ?></textarea></p>				
			<p style="margin:0px; padding:0px; text-align:left; color:#003366">By <?php echo $username; ?> <?php echo ConvertSQLDate($posted_date);?></p>
			</div>
	</div><!-- Tab 2 Close -->
</div>
</div>
</div>
</div><!-- inside div close -->
</div><!-- Main div close -->
