<?php
	//Start session
	session_start();
	error_reporting(E_ALL ^ E_NOTICE ^E_WARNING);
	//Check whether the session variable SESS_MEMBER_ID is present or not
	if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
		header("location: index.html");
		exit();
	}
	if(isset($_SESSION['SESS_DEPT'])&&$_SESSION['SESS_DEPT']!='ACCOUNTS')
	{
		$styleHide = "display:none";
		$style= "style='display:none'"	;
	}
?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
<title>SALES ORDER ENTRY</title>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="../../javascript/jquery.js"></script>
<script type="text/javascript" src="../../javascript/sorder_entry_rel.js"></script>
<script type="text/javascript" src="../../javascript/jquery.autocomplete.js"></script>
<script type="text/javascript" src="../../javascript/numbertowords.js" ></script>
<script type="text/javascript" src="../../javascript/jquery.datepick.min.js"></script>
<script type="text/javascript" src="../../javascript/jNotify.jquery.min.js"></script>
<script type="text/javascript" src="../../javascript/jNotify.jquery.js"></script>

<link rel="stylesheet" href="../../css/jNotify.jquery.css">
<link rel="stylesheet" href="../../css/redmond.datepick.css">
<link rel="stylesheet" href="../../css/jquery.autocomplete.css" type="text/css" >
</link>
<link rel="stylesheet" href="../../css/style.css"  type="text/css">
</link>

<link rel="stylesheet" type="text/css" href="../../javascript/tooltip/css/tooltipster.bundle.min.css" />

    <script type="text/javascript" src="../../javascript/tooltip/js/tooltipster.bundle.min.js"></script>

<script type="text/javascript">
function myFunction()
{
jSuccess("Module not available in demo version");
}
</script>
<style type="text/css">

input[type=text],textarea{
	width:100%
}

</style>
</head>

<body >

<div id="pendingRawMatList" class="pendingRawMatList">
<div style=" background-color:white; height:0px;overflow-y: auto;" class="dataDiv dataTableContainer" > </div>

<div class="dragDown">Finish Product</div >

</div>

<input  id="inline_edit" type="hidden" value="0"  />
<div id="transperent" >
</div>
		
        
      <?php 
	    
		
  include '../../db_connect.php';

$orderid= $_GET['orderid'];
$table='';
if(($result = mysqli_query($con,"SELECT * FROM sorderreg  where orderid='$orderid'"))&&(!empty($orderid)))
{
	$totpcost=0;
	$totscost=0;
	
$row = mysqli_fetch_array($result);
if($result = mysqli_query($con,"SELECT * FROM commst  where compid='$row[buyercode]'"))
$client_detrow = mysqli_fetch_array($result);

if($agentcoderesult = mysqli_query($con,"SELECT * FROM commst  where compid='$row[agentcode]'   "))
$agentcoderow = mysqli_fetch_array($agentcoderesult);

if($distrresult = mysqli_query($con,"SELECT * FROM commst  where compid='$row[distr]'  "))
$distrcoderow = mysqli_fetch_array($distrresult);

if($billedtoresult = mysqli_query($con,"SELECT * FROM commst  where compid='$row[billedto]'  "))
$billedtorow = mysqli_fetch_array($billedtoresult);

if($shiptoresult = mysqli_query($con,"SELECT * FROM commst  where compid='$row[shipto]'"))
$shiptorow = mysqli_fetch_array($shiptoresult);

if(($result_det = mysqli_query($con,"SELECT * FROM sorderregdet  where orderid='$orderid' order by srno"))&&(!empty($orderid))){
	
		$pcdArray = $_SESSION['SESS_PCD'];
		$table="<div id='form_bookdetails'><table width='100%' id='msview'  cellpadding='0' cellspacing='0' style='table-layout: fixed;
width: 98.7%;'>
		<thead>
			<tr >
			
            <th  width='5%'>Sr No.</th>
			<th  width='10%'>$pcdArray[PRODNAME]</th>
			<th style='height: 32px;' width='10%'>$pcdArray[CAT]</th>
			<th style='height: 32px;' width='10%'>$pcdArray[COLOR]</th>
			<th style='height: 32px;' width='10%'>$pcdArray[DESC]</th>		
			<th style='' width='10%'>HSN</th>			
			<th style='height: 32px;' width='5%'>Qty</th>
			<th style='height: 32px;$styleHide' width='5%' >RATE</th>
			<th style='height: 32px;$styleHide' width='5%' >AMOUNT</th>
			<th style='height: 32px;$styleHide' width='5%' >DISC</th>
			<th style='' width='5%'>GST %</th>
			<th style='' width='5%'>CGST</th>
			<th style='' width='5%'>SGST</th>
			<th style='' width='5%'>IGST</th>
			<th style='$styleHide' width='5%'>GTOTAL</th>
			<th style='height: 32px;' width='5%'></th>
			<th style='height: 32px;' width='5%'></th>
			</tr>
			</thead><tbody>";
			
			/*<th style='height: 32px;' width='5%'>$pcdArray[SIZESETCODE]</th>			
			<th style='height: 32px;' width='5%'>$pcdArray[SETS]</th>*/
			
while($row_det = mysqli_fetch_array($result_det)){
			$totpcost+=$row_det['pcost'];
			$totscost+=$row_det['scost'];
			$totpamt+=$row_det['pamt'];
			$totdiscamt+=$row_det['discamt'];
			$totcgst+=$row_det['cgst'];
			$totsgst+=$row_det['sgst'];
			$totigst+=$row_det['igst'];
			$Grandtot+=$row_det['gtotal'];
			$qty+=$row_det['qty'];
			$sr_track=$row_det['srno'];
			
			
			$table.="<tr>
			<td style='display:none'><textarea name='entryid' class='entryid'>$row_det[entryid]</textarea></td>
			<td style='display:none'><textarea name='orderid' class='orderid'>$row_det[orderid]</textarea></td>
			<td width='5%'><textarea name='srno' class='srno'>$row_det[srno]</textarea></td>
			<td width='10%'><textarea name='prodcode' class='prodcode'>$row_det[prodcode]</textarea></td>
			<td width='10%'><textarea style='height: 32px; ' name='cat' class='cat'>$row_det[cat]</textarea></td>
			<td width='10%'><textarea style='height: 32px;' name='colorcode'>$row_det[colorcode]</textarea></td>
			<td width='10%'><textarea style='height: 32px;' name='shortdesc' class='shortdesc'>$row_det[shortdesc]</textarea></td>
			<td width='10%'><textarea style='' name='hsncode' class='hsncode'>$row_det[hsncode]</textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='qty' class='qty' >$row_det[qty]</textarea></td>
			<td width='5%' $style><textarea style='' name='rate' class='rate'>$row_det[pcost]</textarea></td>
			<td width='5%' $style><textarea style='height: 32px;' name='amount' class='amount'>$row_det[pamt]</textarea></td>
			<td width='5%' $style><textarea style='' name='discount' class='discount'>$row_det[discamt]</textarea></td>
			<td width='5%' $style><textarea style='' name='percgst' class='percgst'>$row_det[pergst]</textarea></td>
			<td width='5%' $style><textarea style='' name='cgst' class='cgst'>$row_det[cgst]</textarea></td>
			<td width='5%' $style><textarea style='' name='sgst' class='sgst'>$row_det[sgst]</textarea></td>
			<td width='5%' $style><textarea style='' name='igst' class='igst'>$row_det[igst]</textarea></td>
			<td width='5%' $style><textarea style='' name='gtotal' class='gtotal'>$row_det[gtotal]</textarea></td>
			<td width='5%' style='display:none'><textarea   name='set' class='set' >$row_det[set]</textarea></td>
			<td width='5%' $style><textarea style='height: 32px;' name='sordmrp' class='sordmrp'>$row_det[sordmrp]</textarea></td>
			<td width='5%'><input type='button' value='SAVE' class='edit filter_table' style='display:none'/></td>
			<td width='5%'><input type='button' class='deletedet  filter_table' value='X' /></td>
			</tr>";
			
			/*
			<td width='5%'><textarea style='height: 32px;' name='sizeset' sizeChartId='$row_det[entryid]' class='sizeset' readonly title='Please double click to see size chart'>$row_det[sizeset]</textarea></td>
			<td width='5%'><textarea  style='height: 32px;' name='set' sizeChartId='$row_det[entryid]' class='set' >$row_det[set]</textarea></td>*/
			
			
			$sizeset_spilt = explode(",",$row_det['sizeset']);
			//echo "SELECT * FROM sordervar  where `job_id` = '$row_det[orderid]' and `prodname` = '$row_det[prodcode]' order by entryid";
			if(($prodvar_data = mysqli_query($con,"SELECT * FROM sordervar  where `job_id` = '$row_det[orderid]' and `prodname` = '$row_det[prodcode]' and srno = '$row_det[srno]' order by entryid"))){
			$tr ='';
			$index=1;
			while($prodvar_row = mysqli_fetch_array($prodvar_data)){
				$qnty += $prodvar_row[qnty];
				$fresh += $prodvar_row[fresh];
				$reprocess += $prodvar_row[reprocess];
				
				$tr.= "<tr><td style='display:none'><textarea style='height: 32px;' name='entryid_pv[]' class='entryid_pv'>$prodvar_row[entryid]</textarea></td><td style='display:none'><textarea style='height: 32px;' name='prodname_pv[]' class='prodname_pv'>$row_det[prodcode]</textarea></td><td>".($index++)."</td><td><textarea style='height: 32px;' name='size_pv[]' class='size_pv'>$prodvar_row[size]</textarea></td> <td><textarea name='qnty_pv[]' style='height: 32px;' class='qnty_pv'>$prodvar_row[qnty]</textarea></td><td><textarea name='fresh_pv[]' style='height: 32px;' class='fresh_pv'>$prodvar_row[fresh]</textarea></td><td><textarea style='height: 32px;' name='reprocess_pv[]' class='reprocess_pv'>$prodvar_row[reprocess]</textarea></td></tr>";
				
			}//while($prodvar_row = mysqli_fetch_array($prodvar_data)){
			 $tr.= "<tr class='foot'><td style='display:none'><textarea style='height: 32px;' name='tentryid_pv[]' class='tentryid_pv'></textarea></td><td>TOTAL</td><td><textarea style='height: 32px;' name='tsize_pv[]' class='tsize_pv'>".($index-1)."</textarea></td> <td><textarea name='tqnty_pv[]' style='height: 32px;' class='tqnty_pv'></textarea></td><td><textarea name='tfresh_pv[]' style='height: 32px;' class='tfresh_pv'></textarea></td><td><textarea style='height: 32px;' name='treprocess_pv[]' class='treprocess_pv'></textarea></td></tr>";
			}//while($row_det = mysqli_fetch_array($result_det)){
				
				
			
						$sizeTable.= "<div class='sizechartdiv' id='$row_det[entryid]' style='display:none;position:absolute'><div class='closediv'> X </div>
       <table  style='border: 1px solid black;background-color:white' border='1' cellspacing='0'>
  <tr>
    <th>Sr. No.</th>
    <th>Size</th>
    <th>Quantity</th>
	<th>Issued</th>
    <th>Pending</th>
  </tr>
    $tr
  </table>
</div>
";
}
$temp=$sr_track+1;
$table.="<tr class='last'>
			
			<td style='display:none'><textarea name='entryid'>$row_det[entryid]</textarea></td>
			<td style='display:none'><textarea name='orderid'>$orderid</textarea></td>
			<td style='display:none'><textarea name='frm' class='frm'></textarea></td>
			<td width='5%'><textarea name='srno' readonly>$temp</textarea></td>
			<td width='10%'><textarea name='prodcode' class='prodcode'></textarea></td>
			<td width='10%'><textarea style=' ' name='cat' class='cat'></textarea></td>
			<td width='10%'><textarea style='' name='colorcode' class='colorcode'></textarea></td>
			<td width='10%'><textarea style='' name='shortdesc' class='shortdesc'></textarea></td>
			<td width='10%'><textarea style='' name='hsncode' class='hsncode'></textarea></td>
			<td width='5%'><textarea style='' name='qty' class='qty' ></textarea></td>
			<td width='5%' $style><textarea style='' name='rate' class='rate'></textarea></td>
			<td width='5%' $style><textarea style='' name='amount' class='amount'></textarea></td>
			<td width='5%' $style><textarea style='' name='discount' class='discount'></textarea></td>
			<td width='5%' $style><textarea style='' name='percgst' class='percgst'></textarea></td>
			<td width='5%' $style><textarea style='' name='cgst' class='cgst'></textarea></td>
			<td width='5%' $style><textarea style='' name='sgst' class='sgst'></textarea></td>
			<td width='5%' $style><textarea style='' name='igst' class='igst'></textarea></td>
			<td width='5%' $style><textarea style='' name='gtotal' class='gtotal'></textarea></td>
			<td width='5%' style='display:none'><textarea   name='set' class='set' ></textarea></td>
			<td width='5%' style='display:none'><textarea style='' name='mrp' class='mrp' ></textarea></td>
			<td width='5%'><input type='button' value='SAVE' class='addnew filter_table' style='display:none'/></td>
			<td width='5%'><input type='button' value='' class='' style='display:none'/></td>
			</tr>";
			
			$table.="<tr class='foot'>
			
			<td width='5%'><textarea name='srno' readonly>Total</textarea></td>
			<td width='10%'><textarea name='prodcode' class='prodcode'></textarea></td>
			<td width='10%'><textarea style=' ' name='cat' class='cat'></textarea></td>
			<td width='10%'><textarea style='' name='colorcode' class='colorcode'></textarea></td>
			<td width='10%'><textarea style='' name='shortdesc' class='shortdesc'></textarea></td>
			<td width='10%'><textarea style='' name='hsncode' class='hsncode'></textarea></td>
			<td width='5%'><textarea style='' name='qty' class='qty' >$qty</textarea></td>
			<td width='5%' $style><textarea style='' name='rate' class='rate'></textarea></td>
			<td width='5%' $style><textarea style='' name='amount' class='amount'>$totpamt</textarea></td>
			<td width='5%' $style><textarea style='' name='discount' class='discount'>$totdiscamt</textarea></td>
			<td width='5%' $style><textarea style='' name='percgst' class='percgst'></textarea></td>
			<td width='5%' $style><textarea style='' name='cgst' class='cgst'>$totcgst</textarea></td>
			<td width='5%' $style><textarea style='' name='sgst' class='sgst'>$totsgst</textarea></td>
			<td width='5%' $style><textarea style='' name='igst' class='igst'>$totigst</textarea></td>
			<td width='5%' $style><textarea style='' name='gtotal' class='gtotal'>$Grandtot</textarea></td>
			<td width='5%' style='display:none'><textarea   name='set' class='set' ></textarea></td>
			<td width='5%' style='display:none'><textarea style='' name='mrp' class='mrp' ></textarea></td>
			<td width='5%'></td>
			<td width='5%'></td>
			</tr>";
			
			$sizeTable.= "<div id='new' class='sizechartdiv' style='display:none;position:absolute'><div class='closediv'> X </div>
       <table  style='border: 1px solid black;background-color:white' border='1' cellspacing='0'>
  <tr>
    <th>Sr. No.</th>
    <th>Size</th>
    <th>Quantity</th>
	<th>Fresh</th>
    <th>Seconds</th>
  </tr>

  </table>
</div>
";
			
			

$table.="</tbody></table></div>".$sizeTable;
}
}
function time_formatc($temp_time)
{
list($hour, $min, $sec) = explode(':', $temp_time);

return "$hour:$min";
}


function date_formatc($temp_date)
{
list($year, $month, $day) = explode('-', $temp_date);
return "$day/$month/$year";
}
?>
      
      
<div class="main">
    <div id="formbox">
        <form id="bookingform" action=""  method="">
         
         <table width="100%" border="0" height="100%" cellspacing="2">
  <tr class="master_detrow">
    <td width="12%" align="left" >Order Id:</td>
    <td colspan="3"><span style="float:left;width:45%"><input type="text" name="orderid" id="orderid" tabindex="3" readonly  style="width:70%;float:left;" /> Ref No.</span> 
    <span style="float:right;width:48%"><input type="text" name="refno" id="refno" tabindex="17" /></span></td>
    <td width="9%" align="left">&nbsp;</td>
    <td width="12%" align="left">Order Date:<span style="color:red; ">*</span></td>
    <td width="15%"><input type="text" autocomplete="off" name="orderdate" id="orderdate" tabindex="13"  /></td>
    <td width="8%" align="left">&nbsp;</td>
    <td width="14%">&nbsp;</td>
  </tr>
  <tr class="master_detrow">
    <td align="left">Billed To<span style="color:red; ">*</span></td>
    <td colspan="2" align="left"><input type="text" name="buyercode" id="buyercode" tabindex="3"  /></td>
    <td width="5%" align="left"><input type="text" name="buyerma" id="buyerma" tabindex="3"  /></td>
    
    <td align="left"><input type="button" name="guesmas" id="guesmas" class="button" value="+" style="  width: 28px;padding-left: 8px;padding-right: 8px; cursor:pointer; " title="click to add to master" /></td>
    <td align="left">Type</td>
    <td><select type="text" name="ordertype" id="ordertype" style="width:100%">
    	<option value="ACCESSORIES">ACCESSORIES</option>
    	<option value="RAW MATERIAL">RAW MATERIAL</option>
        <option value="READAY STOCK" selected="selected">READY STOCK</option>
      	<option value="TRIMS">TRIMS</option>
    </select></td>
    <td align="left">Dlv Date<span style="color:red; ">*</span></td>
    <td><input type="text" autocomplete="off" name="dlvdate" id="dlvdate" tabindex="17" /></td>
    </tr>
  <tr class="master_detrow">
    <td align="left">Address:</td>
    <td colspan="3" rowspan="2"  valign="top"><textarea name="adress" style="height: 52px;" rows="2" tabindex="4" id="adress"></textarea></td>
    <td align="left">&nbsp;</td>
    <td align="left">Rate Type</td>
    <td colspan="2"><select type="text" name="ratetype" id="ratetype" style="width:100%">
    <option value="ADVANCE">ADVANCE</option>
     <option value="CREDIT">CREDIT</option>
      <option value="ON DELIVERY">ON DELIVERY</option>
    </select></td>
     <td align="left"><input type="text" name="rtvalue" id="rtvalue"  /></td>
    </tr>
  <tr class="master_detrow">
    <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td>
    <td align="left">Ship to</td>
    <td colspan="2"><input type="text" name="shipto" id="shipto" tabindex="15" /></td>
    <td align="left"><input type="text" name="pos" id="pos" tabindex="15" /></td>
    </tr>
  <tr>
    <td align="left">City</td>
    <td><input type="text" name="city" id="city" tabindex="17" /></td>
    <td width="2%" align="left">Pin</td>
    <td width="17%"><input type="text" name="pincode" id="pincode" tabindex="15" /></td>
    <td align="right">&nbsp;</td>
    <td align="left">Shipment</td>
    <td align="right">
    <select type="text" name="shipvia" id="shipvia" style="width:100%">
    <option value=""></option>
    <option value="AIR">AIR</option>
     <option value="TRANSPORT">TRANSPORT</option>
      <option value="SHIP">SHIP</option>
        <option value="COURIER">COURIER</option>
    </select></td>
    <td align="left">Paid by</td>
    <td align="right">
    <select type="text" name="shippingpaid" id="shippingpaid" style="width:100%">
    <option value=""></option>
    <option value="CONSINGNEE">CONSINGNEE</option>
     <option value="BUYER">BUYER</option>
      <option value="SELF">SELF</option>
    </select>
    </td>
  </tr>
  <tr>
    <td align="left">Distributor</td>
    <td colspan="2"><input type="text" name="distrcode" id="distrcode" tabindex="17" /></td>
    <td><input type="text" name="distrname" id="distrname" tabindex="17" /></td>
    <td align="left">&nbsp;</td>
    <td align="left">Agent
      <input type="button" name="penrmlist" id="penrmlist" class="button" value="FP" style="  width: 38px;cursor:pointer;padding: 0px 3px;display:none " title="click to get Raw Material List" /></td>
    <td align="left"><input type="text" name="agentcode" id="agentcode" tabindex="17" /></td>
    <td colspan="2" align="left"><input type="text" name="agent" id="agent" tabindex="17" /></td>
    </tr>
  <tr>
    <td align="left">Consignee<span style="color:red; ">*</span></td>
    <td colspan="2"><input type="text" name="billedto" id="billedto" tabindex="17" /></td>
    <td align="left"><input type="text" name="billedtoname" id="billedtoname" tabindex="17" /></td>
    <td align="right">&nbsp;</td>
    <td align="left">Comm.%</td>
    <td align="right"><input type="text" name="comm" id="comm" tabindex="17" /></td>
    <td align="left">On</td>
    <td align="right"><input type="text" name="comm_on" id="comm_on" tabindex="17" /></td>
  </tr>
  <tr>
    <td align="left">&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="2" align="left">&nbsp;</td>
    <td colspan="5" align="right">&nbsp;</td>
  </tr>
  <tr>
    <td align="left">&nbsp;</td>
    <td>&nbsp;</td>
    <td align="left">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><select type="text" name="printopt" id="printopt" style="width:100%">
      <option value="ORDERFORM" selected="selected">ORDER FORM</option>
      <option value="PROFORMA">PROFORMA INVOICE</option>
    </select></td>
    <td colspan="5" align="right"><input type="button" class="button" id="print" value="PRINT" />
      <input name="Update" type="button" class="Update button" id="Update" value="UPDATE" style="display:none"  />
      <input type="button" class="save button" id="Save" tabindex="30" value="SAVE"  />
      <input type="button" class="button" id="New" value="NEW" />
      <input type="button" class="close button" id="Close" value="CLOSE"  /></td>
  </tr>
  
 
  <tr>
    <td height="70%" colspan="9" align="left" valign="top" ><div class="table_contain" id="jobdet_container" style="height: 100%;overflow-y: auto;">
    
    
    </div></td>
    </tr>
  <tr>
    	<td colspan="9" align="left">
			<table width="100%" border="0">
					<tr>
						<td width="10%" align="left">Notes:</td>
						<td colspan="5" rowspan="2" valign="top"><textarea name="notes" style="height: 64px;" rows="2" id="notes"></textarea>         
							<table width="100%" border="0">
								<tr>
									<td colspan="2" align="left">&nbsp;</td>
								</tr>
							</table>
						</td>
						<td width="5%">&nbsp;</td>
						<td width="10%" align="left" <?php echo $style?> >Total Amount:</td>
						<td width="10%" <?php echo $style?>><input type="text" size="10"  class="tpcost"  name="ptotal" id="ptotal" value="<?php echo $totpamt?>"/></td>
						<!--<td align="left" <?php echo $style?>>Total Cost:</td>
						<td colspan="2" <?php echo $style?>><input type="text" size="10"  name="stotal" id="stotal" class="tscost" value="<?php echo $totscost?>"/></td>-->
					</tr>
					<tr>
						<td  align="left">&nbsp;</td>
						<td width="5%">&nbsp;</td>
						<td align="left" <?php echo $style?>>
						<table>
							<tr>
								<td>Discount:</td>
								<td width="20%">&nbsp;</td>
								<td <?php echo $style?>  width="35%"> <input type="text" name="disper" id="disper" class="calc" size="10"/></td>
							</tr>
						</table>
						<td <?php echo $style?> > <input type="text" name="pdiscount" id="pdiscount" class="calc" size="10"/></td>
					</tr>
			
					<!--<td align="left" <?php echo $style?>>Discount:</td>
					<td <?php echo $style?>>
					<input type="text" name="sdiscount" id="sdiscount" class="calc" size="10"/></td>-->
			
					<tr>
						<td align="left" >Total in word</td>
						<td colspan="4" align="left"><input type="text" name="totalinword" id="totalinword" tabindex="17" /></td>
						<td></td>
						<td width="5%">&nbsp;</td>
						<td align="left" width="10%" <?php echo $style?>>Net Amount:</td>
						<td width="10%" <?php echo $style?> ><input type="text" name="pnamount" id="pnamount" class="calc" size="10"/></td>
						<!--<td align="left" <?php echo $style?>>Net amount:</td>
						<td <?php echo $style?> >
						<input type="text" name="snamount" id="snamount" class="calc" size="10"/></td>-->
					</tr>
					<tr>
						<td colspan="5" align="left">
							<fieldset>
								<legend>Transfer to Packing list</legend>
								<table width="100%" border="0">
									<tr>
										<td align="left" width="16%">Packing list no:</td>
										<td width="20%"><input type="text" name="packinglistno" id="packinglistno"  /></td>
										<td width="30%">&nbsp;</td>
										<td colspan="2" align="center"><input type="button"  class="save button" id="process" value="PROCESS"  /></td>
									</tr>
								</table>
							</fieldset>
						</td>
						<td width="5%">&nbsp;</td>
						<td width="5%">&nbsp;</td>
						<td align="left" <?php echo $style?>>
							<table>
								<tr>
									<td>CGST:</td>
									<!-- <td width="45%">&nbsp;</td> -->
									<!-- <td <?php echo $style?> ><input type="text" name="pervat" id="pervat" class="calc" size="10"/></td> -->
								</tr>
								<tr>
									<td>SGST:</td>
									<!-- <td width="45%">&nbsp;</td> -->
									<!-- <td <?php echo $style?> ><input type="text" name="pervat" id="pervat" class="calc" size="10"/></td> -->
								</tr>
								<tr>
									<td>IGST:</td>
									<!-- <td width="45%">&nbsp;</td> -->
									<!-- <td <?php echo $style?> ><input type="text" name="pervat" id="pervat" class="calc" size="10"/></td> -->
								</tr>
							</table>
							<td <?php echo $style?> >
								<input type="text"  name="totcgst" id="totcgst" class="calc" size="10" value="<?php echo $totcgst?>"/>
								<input type="text"  name="totsgst" id="totsgst" class="calc" size="10" value="<?php echo $totsgst?>"/>
								<input type="text"  name="totigst" id="totigst" class="calc" size="10" value="<?php echo $totigst?>"/>
							</td>
							<!--<td width="5%" align="left" <?php echo $style?>>Gst:</td>
							<td width="8%" <?php echo $style?>><input type="text" name="servicetax" id="servicetax" class="calc" size="10"/></td>-->
							<tr>
								<td align="left">&nbsp;</td>
								<td width="18%" valign="top">&nbsp;</td>
								<td width="6%" valign="top">&nbsp;</td>
								<td width="27%" colspan="2" valign="top">&nbsp;</td>
								<td width="9%">&nbsp;</td> 
								<td width="5%">&nbsp;</td>
								<td align="left" width="10%" <?php echo $style?>>Grand Total:</td>
								<td width="10%" <?php echo $style?>><input type="text" name="grtotal" id="grtotal" class="calc" value="<?php echo $Grandtot?>" size="10" /></td>
							</tr>
						</td>
					</tr>	
			</table>
		</td>
    </tr>

    </table>
    </form>
    </div>
    <div id="message" style="width:100%; border:thin solid;text-align: center;font-weight: bold;color: #0064D1;"> </div>

</div>
<script type="text/javascript">
<?php if($orderid!='')
{?>
$(window).load(function(){
	
	//data to be from commst
	$('#orderid').val('<?php echo clean($con,$row['orderid']); ?>');
	$('#orderdate').val('<?php if(clean($con,$row['orderdate'])!='0000-00-00') echo date_formatc(clean($con,$row['orderdate'])); ?>');
	$('#ordertype').val('<?php echo clean($con,$row['ordertype']);?>');
	$('#buyercode').val('<?php echo clean($con,$row['buyercode']); ?>');
	$('#buyerma').val('<?php echo clean($con,$client_detrow['name']); ?>');
	$('#adress').val('<?php echo clean($con,$client_detrow['address']); ?>');	
	$('#city').val('<?php echo clean($con,$client_detrow['cmpcity']); ?>');
	$('#pincode').val('<?php echo clean($con,$client_detrow['pincode']); ?>');	
	$('#agent').val('<?php echo clean($con,$agentcoderow['name']); ?>');
	$('#agentcode').val('<?php echo clean($con,$row['agentcode']);?>');	
	$('#distrcode').val('<?php echo clean($con,$row['distr']); ?>');
	$('#distrname').val('<?php echo clean($con,$distrcoderow['name']);?>');	
	$('#billedto').val('<?php echo clean($con,$row['billedto']); ?>');
	$('#billedtoname').val('<?php echo clean($con,$billedtorow['name']);?>')		
	$('#refno').val('<?php echo clean($con,$row['refno']); ?>');
	$('#dlvdate').val('<?php  if(clean($con,$row['dlvdate'])!='0000-00-00') echo date_formatc(clean($con,$row['dlvdate'])); ?>');
	$('#ratetype').val('<?php echo clean($con,$row['ratetype']);?>');
	$('#rtvalue').val('<?php echo clean($con,$row['rtvalue']);?>');
	$('#shipto').val('<?php echo clean($con,$row['shipto']);?>');
	$('#pos').val('<?php echo clean($con,$row['pos']);?>');
	$('#agentcode').val('<?php echo clean($con,$row['agentcode']);?>');
	$('#shipvia').val('<?php echo clean($con,$row['shipvia']);?>');
	$('#shippingpaid').val('<?php echo clean($con,$row['shippingpaid']); ?>');
	$('#comm').val('<?php echo clean($con,$row['comm']); ?>');
	$('#comm_on').val('<?php echo clean($con,$row['comm_on']); ?>');
	$('#notes').val('<?php echo clean($con,$row['notes']); ?>');
	$('#packinglistno').val('<?php echo clean($con,$row['packinglistno']); ?>');
	$('#ptotal').val('<?php echo clean($con,$row['ptotal']); ?>');
	$('#disper').val('<?php echo clean($con,$row['disper']); ?>');
	$('#pdiscount').val('<?php echo clean($con,$row['pdiscount']); ?>');
	$('#pnamount').val('<?php echo clean($con,$row['pnamount']); ?>');
	$('#pervat').val('<?php echo clean($con,$row['pervat']); ?>');
	$('#vat').val('<?php echo clean($con,$row['vat']); ?>');
	$('#grtotal').val('<?php echo clean($con,$row['grtotal']); ?>');
	$('#status').val('<?php echo clean($con,$row['status']); ?>');
	


	$('#jobdet_container').html('<?php echo clean($con,$table); ?>');
	$(document).ready(function(){
	if($('#cat').val()=='SERVICES'){
	
	}
		
			if ($('#orderid').val()==''||$('#packinglistno').val()!='')
			{
			$('#process').hide();
			}
			else{
			$('#process').show();
			}
			$("#guesmas").hide();
			$('#Update').show();
			$('#Save').hide();
	run();
	inline_edit();
	jobentry_rel();
	

	});
	
	
	});
<?php }
else 
 ?>
$('#orderid').focus();
	
$(window).load(function() {
	/*$('#transperent').hide();*/
	var div_scr = $('#jobdet_container');
					 div_scr.scrollTop(div_scr.prop("scrollHeight"));
					 
		$('#transperent').hide();
					 
			var qty = 0;
			var	sordmrp = 0;
			var rate = 0;
			var amount = 0;
			
			
	   		var thistable = $('#formbox td div div#form_bookdetails table');
			
			thistable.find('.qty').each(function( index ) {
			qty+=Number($(this).val());
			 });
			 
			thistable.find('.sordmrp').each(function( index ) {
			sordmrp+=Number($(this).val());
			 });
			  
			thistable.find('.rate').each(function( index ) {
			rate+=Number($(this).val());
			 });
			   
			thistable.find('.amount').each(function( index ) {
			amount+=Number($(this).val());
			  });
			  
			  
			 thistable.find('.tqty').val(qty);
			 thistable.find('.tsordmrp').val(sordmrp);
			 thistable.find('.trate').val(rate);
			 thistable.find('.tamount').val(amount);
});




$("#buyercode").autocomplete(
      "client_fill.php",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
			mustMatch:0,
  			cacheLength:10,
			sortResults :false,
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#buyerma').val(row.data[0]);
				if(row.data[1]!='undefined')
				$('#adress').val(row.data[1]);	
				if(row.data[2]!='undefined')
				$('#city').val(row.data[2]);
				if(row.data[3]!='undefined')
				$('#pincode').val(row.data[3]);	
				
				if(row.data[4]!='undefined')
				$('#agentcode').val(row.data[4]);
				if(row.data[5]!='undefined')
				$('#shipvia').val(row.data[5]);
				if(row.data[6]!='undefined')
				$('#ratetype').val(row.data[6]);			
				$("#guesmas").hide();								
			},
			showResult:function(row,data) {
    	return row+"|"+data[0];
  			},
			onNoMatch:function(){

				$("#guesmas").show();
				},
  		
  			autoFill:false
  		});
		
		
		$("#billedto").autocomplete(
      "../../client_fill.php",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
			mustMatch:0,
  			cacheLength:10,
			sortResults :false,
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#billedtoname').val(row.data[0]);
						
								
			},
			showResult:function(row,data) {
    	return row+"|"+data[0];
  			},
  		
  			autoFill:false
  		});
	
	
	
	
	$("#distrcode").autocomplete(
      "../../client_fill.php",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
			mustMatch:0,
  			cacheLength:10,
			sortResults :false,
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#distrname').val(row.data[0]);
						
								
			},
			showResult:function(row,data) {
    	return row+"|"+data[0];
  },
  		
  			autoFill:false
  		});
		
		
	$("#agentcode").autocomplete(
      "../../client_fill.php",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
			mustMatch:0,
  			cacheLength:10,
			sortResults :false,
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#agent').val(row.data[0]);
						
								
			},
			showResult:function(row,data) {
    	return row+"|"+data[0];
  },
  		
  			autoFill:false
  		});
		
		
	
	$("#shipto").autocomplete(
      "../../client_fill.php?mode=shipto",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
			mustMatch:0,
  			cacheLength:10,
			sortResults :false,
  			onItemSelect:function(row){
				if(row.data[0]!='undefined'&&row.data[1]!='undefined')
				$('#pos').val(row.data[1]+'|'+row.data[0]);
						
								
			},
			showResult:function(row,data) {
    	return row+"|"+data[0]+"|"+data[1];
  },
  		
  			autoFill:false
  		});
	
	
	

	

	
	
	

	
</script>

</body>
</html>