<?php
	//Start session
	session_start();
	
	//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>JOB 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/job_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" src="../../tablesorter/js/jquery.tablesorter.js"></script>

<!-- tablesorter widgets (optional) -->
<script type="text/javascript" src="../../tablesorter/js/jquery.tablesorter.widgets.js"></script>
<script src="../../tablesorter/js/widgets/widget-scroller.js"></script>

<!-- choose a theme file -->
<link rel="stylesheet" href="../../tablesorter/css/theme.default.css">

<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 >

<table style="display:none">
<tr  id="prototype"><td style="display:none"><textarea style="height: 32px;" name="entryid_pv[]" class="entryid_pv"></textarea></td><td></td><td><textarea style="height: 32px;" name="size_pv[]" class="size_pv"></textarea></td> <td><textarea style="height: 32px;" name="qnty_pv[]" class="qnty_pv"></textarea></td><td><textarea style="height: 32px;" name="fresh_pv[]"  class="fresh_pv"></textarea></td><td><textarea style="height: 32px;" name="reprocess_pv[]" class="reprocess_pv"></textarea></td><td><textarea style="height: 32px;" name="demage_pv[]" class="demage_pv"></textarea></td></tr></table>

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

<div class="dragDown">Pending orders</div >

</div>


<div id="pendingQuanList" class="pendingQuanList" ><div class='closediv' style="display:none"> X </div>
<div style=" background-color:white; height:0px;overflow-y: auto;" class="dataDiv dataTableContainer" > </div>

</div>


<input  id="inline_edit" type="hidden" value="0"   />

		
        
      <?php 
	    
		
  include '../../db_connect.php';

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

if($toresult = mysqli_query($con,"SELECT * FROM commst  where compid='$row[jobcodeto]'"))
$jobto_detrow = mysqli_fetch_array($toresult);

if(($result_det = mysqli_query($con,"SELECT * FROM jobregdet inner join prodreg on prodcode = code where jobid='$jobid' order by srno"))&&(!empty($jobid))){
	
		$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[STYLECODE]</th>
			<th width='10%'>$pcdArray[STYLENAME]</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='height: 32px;' width='5%'>$pcdArray[SIZESETCODE]</th>			
			<th style='height: 32px;' width='5%'>$pcdArray[SETS]</th>
			<th style='height: 32px;' width='5%'>Qty</th>
			<th style='height: 32px;' width='5%'>Fresh</th>
			<th style='height: 32px;' width='5%'>Reprocess</th>
			<th style='height: 32px;' width='5%'>Balance </th>
			<th style='height: 32px;$styleHide' width='5%' >Rate</th>
			<th style='height: 32px;$styleHide' width='5%' >Amount</th>
			<th style='height: 32px;' width='5%'></th>
			<th style='height: 32px;' width='5%'></th>
			</tr>
			</thead><tbody>";
			
while($row_det = mysqli_fetch_array($result_det)){
			$totpcost+=$row_det['pcost'];
			$totscost+=$row_det['scost'];
			$totpamt+=$row_det['pamt'];
			$qty+=$row_det['qty'];
			$sr_track=$row_det['srno'];
				
  $table.="<tr>
  <td style='display:none'><textarea name='ratiotota' class='ratiotota'>$row_det[ratiotot]</textarea></td>
  <td style='display:none'><textarea name='entryid' class='entryid'>$row_det[entryid]</textarea></td>
  <td style='display:none'><textarea name='jobid' class='jobid'>$row_det[jobid]</textarea></td>
  <td width='5%'><textarea name='srno' class='srno'>$row_det[srno]</textarea></td>
  <td width='10%'><textarea name='prodcode' class='prodcode rmset' rmChartId='$row_det[prodcode]' >$row_det[prodcode]</textarea></td>
   <td width='10%'><textarea name='gencode' class='gencode'  >$row_det[gencode]</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='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' class='set' >$row_det[set]</textarea></td>
  <td width='5%'><textarea style='height: 32px;' name='qty'  class='qty' >$row_det[qty]</textarea></td>
  <td width='5%'><textarea style='height: 32px;' name='fresh' class='fresh'>$row_det[fresh]</textarea></td>
  <td width='5%'><textarea style='height: 32px;' name='reprocess' class='reprocess'>$row_det[reprocess]</textarea></td>
  <td width='5%'><textarea style='height: 32px;' name='demage' class='demage'>$row_det[demage]</textarea></td>
  <td width='5%' $style><textarea style='height: 32px;' 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%'><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>";
			
			
			//$sizeset_spilt = explode(",",$row_det['sizeset']);
			
			if(($prodvar_data = mysqli_query($con,"SELECT * FROM jobvar  where `job_id` = '$row_det[jobid]'  and prodname = '$row_det[prodcode]'   order by entryid"))){
			$tr ='';
			$index=1;
			while($prodvar_row = mysqli_fetch_array($prodvar_data)){
				
				$tr.= "<tr><td style='display:none'><textarea style='height: 32px;' name='entryid_pv[]' class='entryid_pv' >$prodvar_row[entryid]</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><td><textarea style='height: 32px;' name='demage_pv[]' class='demage_pv'>$prodvar_row[demage]</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><td><textarea style='height: 32px;' name='tdemage_pv[]' class='tdemage_pv'></textarea></td></tr>";
		
			}//while($row_det = mysqli_fetch_array($result_det))
			
						$sizeTable.= "<div class='sizechartdiv addrow' 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>Fresh</th>
    <th>Reprocess</th>
    <th>Demage</th>
  </tr>
    $tr
  </table>
</div>
";
$tr ='';
$sizeset_spilt = explode(",",$row_det['sizeset']);
             $rnmSql = "SELECT * FROM rawmatdet  where `jobid` = '$row_det[jobid]' and prodcode = '$row_det[prodcode]'  order by entryid";
			$rawmatdet_data = mysqli_query($con,  $rnmSql);
			
			
			$tr ='';
			$index=1;
			if(mysqli_num_rows($rawmatdet_data)!=0)
	       {
			while($rawmatdet_row = mysqli_fetch_array($rawmatdet_data)){
				
				$tr.= "<tr>
				<td style='display:none'><textarea style='height: 32px;' name='rmentryid_pv[]' class='rmentryid_pv'>$rawmatdet_row[entryid]</textarea></td>
				<td><textarea style='height: 32px;' name='rmcode_pv[]' class='rmcode_pv'>$rawmatdet_row[rmcode]</textarea></td> 
				<td><textarea name='rmunit_pv[]' style='height: 32px;' class='rmunit_pv'>$rawmatdet_row[unit]</textarea></td>
				<td><textarea name='rmrequired_pv[]' style='height: 32px;' class='rmrequired_pv'>$rawmatdet_row[required]</textarea></td>
				<td><textarea style='height: 32px;' name='rmissued_pv[]' class='rmissued_pv'>$rawmatdet_row[issued]</textarea></td>
				<td><textarea style='height: 32px;' name='rmconsumed_pv[]' class='rmconsumed_pv'>$rawmatdet_row[consumed]</textarea></td>
				<td><textarea style='height: 32px;' name='rmreturned_pv[]' class='rmreturned_pv'>$rawmatdet_row[returned]</textarea></td></tr>";
			}
		   }
		   else
		   {
			   
			$PrnmSql = "SELECT * FROM proddet inner join prodreg on srno = id  where  code = '$row_det[prodcode]'  order by entryid";
			$Prawmatdet_data = mysqli_query($con, $PrnmSql);
			   
			   while($Prawmatdet_row = mysqli_fetch_array($Prawmatdet_data)){
				$qtyVal = $Prawmatdet_row[qty] * $row_det[qty];
				$tr.= "<tr>
				<td style='display:none'><textarea style='height: 32px;' name='rmentryid_pv[]' class='rmentryid_pv'>$Prawmatdet_row[entryid]</textarea></td>
				<td><textarea style='height: 32px;' name='rmcode_pv[]' class='rmcode_pv'>$Prawmatdet_row[rmcode]</textarea></td> 
				<td><textarea name='rmunit_pv[]' style='height: 32px;' class='rmunit_pv'>$Prawmatdet_row[unit]</textarea></td>
				<td><textarea name='rmrequired_pv[]' style='height: 32px;' class='rmrequired_pv'>$qtyVal</textarea></td>
				<td><textarea style='height: 32px;' name='rmissued_pv[]' class='rmissued_pv'>$Prawmatdet_row[issued]</textarea></td>
				<td><textarea style='height: 32px;' name='rmconsumed_pv[]' class='rmconsumed_pv'>$Prawmatdet_row[consumed]</textarea></td>
				<td><textarea style='height: 32px;' name='rmreturned_pv[]' class='rmreturned_pv'>$Prawmatdet_row[returned]</textarea></td></tr>";
					}
			   
			   }
		   
			
			
						$rmTable.= "<div class='rmchartdiv' id='$row_det[prodcode]' 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>RM CODE</th>
    <th>UNIT</th>
    <th>Required</th>
	<th>Issued</th>
    <th>Consumed</th>
    <th>Returned</th>
  </tr>
    $tr
  </table>
</div>
";



}
$temp=$sr_track+1;
$table.="<tr class='last'>
			<td style='display:none'><textarea name='ratiotota' class='ratiotota'></textarea></td>
			<td style='display:none'><textarea name='entryid'>$row_det[entryid]</textarea></td>
			
			<td style='display:none'><textarea name='jobid'>$jobid</textarea></td>
			<td width='5%'><textarea name='srno' readonly>$temp</textarea></td>
			<td width='10%'><textarea name='prodcode' class='prodcode rmset' rmChartId='rmnew' ></textarea></td>
			<td width='10%'><textarea name='gencode' class='gencode'  ></textarea></td>
			<td width='10%'><textarea style='height: 32px; ' name='cat' class='cat'></textarea></td>
			<td width='10%'><textarea style='height: 32px;' name='colorcode' class='colorcode'></textarea></td>
			<td width='10%'><textarea style='height: 32px;' name='shortdesc' class='shortdesc'></textarea></td>
			<td width='5%' ><textarea style='height: 32px;' name='sizeset' class='sizeset' sizeChartId='new' readonly></textarea>  </td>
			<td width='5%'><textarea  style='height: 32px;' name='set' class='set' ></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='qty' class='qty' ></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='fresh' class='fresh'></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='reprocess' class='reprocess'></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='demage' class='demage'></textarea></td>
			<td width='5%' $style><textarea style='height: 32px;' name='rate' class='rate'></textarea></td>
			<td width='5%' $style><textarea style='height: 32px;' name='amount' class='amount'></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='tsrno' readonly></textarea></td>
			<td width='10%'><textarea name='tprodcode' class='tprodcode'  >Total</textarea></td>
			<td width='10%'><textarea name='tgencode' class='tgencode'  >".($temp-1)."</textarea></td>
			<td width='10%'><textarea name='tcat' class='tcat' style='height: 32px; ' ></textarea></td>
			<td width='10%'><textarea style='height: 32px;' name='tcolorcode' class='tcolorcode'></textarea></td>
			<td width='10%'><textarea style='height: 32px;' name='tshortdesc' class='tshortdesc'></textarea></td>
			<td width='5%' ><textarea style='height: 32px;' name='tsizeset' class='tsizeset'  readonly></textarea>  </td>
			<td width='5%'><textarea  style='height: 32px;' name='tset' class='tset' ></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='tqty' class='tqty' ></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='tfresh' class='tfresh'></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='treprocess' class='treprocess'></textarea></td>
			<td width='5%'><textarea style='height: 32px;' name='tdemage' class='tdemage'></textarea></td>
			<td width='5%' $style><textarea style='height: 32px;' name='trate' class='trate'></textarea></td>
			<td width='5%' $style><textarea style='height: 32px;' name='tamount' class='tamount'></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>";
			
			$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>Reprocess</th>
    <th>Demage</th>
  </tr>

  </table>
</div>
";


		
$table.="</tbody></table></div>".$sizeTable.$rmTable;
}
}
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" >Job Id:<span style="color:red; ">*</span></td>
    <td colspan="2">
    <span style="float:left;width:45%"><input type="text" name="jobid" id="jobid" tabindex="3" readonly  style="width:70%;float:left;" /> Batch</span> 
    <span style="float:right;width:45%"><input type="text" name="batchno" id="batchno" tabindex="3" placeholder="Batch No"   /></span>
    </td>
    <td width="9%" align="left">&nbsp;</td>
    <td width="12%" align="left">Iss Date:</td>
    <td width="15%"><input type="text" name="issdate" id="issdate" tabindex="13" value="<?php echo date('d/m/Y')?>" /></td>
    <td width="8%" align="left">&nbsp;</td>
    <td width="14%">&nbsp;</td>
  </tr>
  <tr class="master_detrow">
    <td align="left">Jobber</td>
    <td width="12%" align="left"><input type="text" name="jobcode" id="jobcode" tabindex="3"  /></td>
    <td width="18%" align="left"><input type="text" name="jobbername" id="jobbername" 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">Dlv Date</td>
    <td><input type="text" name="divdate" autocomplete="off" id="divdate" tabindex="14" /></td>
    <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td>
    </tr>
  <tr class="master_detrow">
    <td align="left">Department</td>
    <td colspan="2"  valign="top"><input type="text" name="department" id="department" tabindex="17" /></td>
    <td align="left">&nbsp;</td>
    <td align="left">Ref No.</td>
    <td><input type="text" name="refno" id="refno" tabindex="14" /></td>
    <td colspan="2" align="left">&nbsp;</td>
    </tr>
  <tr class="master_detrow">
    <td align="left">Address</td>
    <td colspan="2" rowspan="2"  valign="top"><textarea name="adress" id="adress" style="height: 63px;" tabindex="4" ></textarea></td>
    <td align="left"><!--<input type="button" name="penrmlist" id="penrmlist" class="button" value="FP" style="  width: 50px;padding-left: 8px;padding-right: 8px; cursor:pointer; " title="click to get Raw Material List" />--></td> 
    <td align="left">Transport</td>
    <td><input type="text" name="transcode" id="transcode" tabindex="15" /></td>
    <!--<td colspan="2" align="left"><input type="text" name="transport" id="transport" tabindex="15" /></td>-->
    
    <td align="left">Paid by</td>
    <!--<td align="right"><input type="text" name="paidby" id="paidby" tabindex="17" /></td>-->
    <td align="right"><select name="paidby" style="width:100%" id="paidby"> 
     <option value="" selected="selected" >--select--</option>
     <option value="cash" >CASH</option>
     <option value="card" >CARD</option>
     </select></td>
    </tr>
    <tr>
    <td align="left">&nbsp;</td>
    <td align="right">&nbsp;</td>
    <td align="left">Supervisor</td>
    <td><input type="text" name="supervisor" id="supervisor" tabindex="15" /></td>
    <td align="left">Contact no </td>
    <td><input type="text" name="scontact" id="scontact" tabindex="16" /></td> 
  </tr>
  <tr>
	 <td align="left">City</td>
    <td width="12%"><input type="text" name="city" id="city" tabindex="17" /></td>
    <td width="18%" align="left"><input type="text" name="pincode" id="pincode" placeholder="Pincode" tabindex="15" /></td>
    <td align="left">&nbsp;</td>
    <td align="left" title="Add Style Name">Short desc</td>
    <td align="right"><input type="text" name="subdesc" id="subdesc"  /></td>
    <td align="left">Status </td>
    <td align="right"><select name="jobstatus" style="width:100%" id="jobstatus">
      <option value="" >--select--</option>
      <option value="PENDING" selected="selected" >PENDING</option>
      <option value="PROCESSING" >PROCESSING</option>
      <option value="COMPLETED" >COMPLETED</option>
    </select></td>
  </tr>
  <tr>
  <td align="left">GSTIN</td>
     <td colspan="2"><input type="text" name="gstin" id="gstin"  /><input type="hidden" name="cmpgstin" id="cmpgstin" value="<?php echo $_SESSION['SESS_SERTAX']?>" /></td>
  </tr>
  <tr>
    <td align="left">Job Type</td>
    <td colspan="2"><select name="jobypeval" id="jobypeval"  style="width:100%" >
                        <option value="" selected="selected" >--select--</option>
                        <option value="10" >CUTTING</option>
                        <option value="20" >STITCHING</option>
                        <option value="30" >QUALITY CHECK</option>
                        <option value="40">WASHING</option>
                        <option value="50" >PRINTING</option>
                        <option value="60" >EMBROIDERY</option>
                        <option value="70" >FINISHING</option>
                      </select></td>
    <td colspan="5" align="right">&nbsp;</td>
  </tr>
  <tr>
    <td align="left"><input type="hidden" class="button" id="history" value="HISTORY" /></td>
    <td colspan="2">&nbsp;</td>
    <td colspan="5" align="right">
      <input type="button" class="button" id="print" value="PRINT" />
      <input type="button" class="Update button" id="Update" value="UPDATE" style="display:none"  />
      <input type="button" class="save button" id="Save" 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="8" align="left" valign="top" ><div class="table_contain" id="jobdet_container" style="height: 100%;overflow-y: auto;">
    
    
    </div></td>
    </tr>
  <tr>
    <td colspan="8" 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 align="left"><input type="text" name="invoiceno" id="invoiceno" style="display:none"  /></td>
             <td align="left">&nbsp;</td>
             </tr>
         </table></td>
         <td width="2%">&nbsp;</td>
       <td width="10%" align="left" <?php echo $style?> >Total Amt:</td>
        <td <?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 Service 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 width="2%">&nbsp;</td>
        <td  align="left">&nbsp;</td>
        <td align="left" <?php echo $style?>>
        <table>
        <tr>
        <td>Discount:</td>
       <td width="13%">&nbsp;</td>
        <td <?php echo $style?>><input type="text" name="disper" id="disper" class="calc" /></td>
        </tr>
        </table>
        <td <?php echo $style?> ><input type="text" name="pdiscount" id="pdiscount" class="calc" size="10"/></td>
        </td>
        <!--<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 colspan="5" rowspan="3"  align="left"><fieldset>
                  <legend>Process Transfer</legend>
                  <table width="100%" border="0">
                    <tr>
                      <td width="10%" align="left">Jobber</td>
                      <td width="23%"><input type="text" name="jobcodeto" id="jobcodeto" tabindex="3"  /></td>
                      <td width="39%"><input type="text" name="jobbernameto" id="jobbernameto" tabindex="3"  /></td>
                      <td width="28%"><select name="status" style="width:100%" id="status">
                        <option value="" selected="selected" >--select--</option>
                        <option value="10" >CUTTING</option>
                        <option value="20" >STITCHING</option>
                        <option value="30" >QUALITY CHECK</option>
                        <option value="40">WASHING</option>
                        <option value="50" >PRINTING</option>
                        <option value="60" >EMBROIDERY</option>
                        <option value="70" >FINISHING</option>
                      </select></td>
                    </tr>
                    <tr>
                      <td align="left">Department</td>
                      <td colspan="2"><input type="text" name="departmentto" id="departmentto" tabindex="17" /></td>
                      <td align="center"><input type="button" style="display:none;" class="save button" id="process" value="PROCESS "  />
                        </td>
                    </tr>
                    <tr>
                      <td align="left">Address</td>
                      <td colspan="2" rowspan="2"><textarea name="adressto" style="height: 39px;" rows="2" tabindex="4" id="adressto"></textarea></td>
                      <td align="left">&nbsp;</td>
                      </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                  </table>
        </fieldset></td>
        <td width="2%">&nbsp;</td>
        <td width="9%">&nbsp;</td>
        <td align="left" <?php echo $style?>>Net Amt:</td>
        <td <?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 width="2%">&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td width="5%" align="left" <?php echo $style?>>
        <table>
        <tr>
        <td>CGST:</td>
        <td width="30%">&nbsp;</td>
        <td <?php echo $style?> ><input type="text" name="tpercgst" id="tpercgst" class="calc" size="10"/></td>
        </tr>
        </table>
        <td width="8%" <?php echo $style?> ><input type="text" name="totcgst" id="totcgst" class="calc" size="10"/></td>
        </td>
         <!--<td width="5%" align="left" <?php echo $style?>>St/Vat:</td>
        <td width="8%" <?php echo $style?>><input type="text" name="servicetax" id="servicetax" class="calc" size="10"/></td>-->
      </tr>
      <tr>
      	<td width="2%">&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td width="5%" align="left" <?php echo $style?>>
        <table>
        <tr>
        <td>SGST:</td>
        <td width="33%">&nbsp;</td>
        <td <?php echo $style?> ><input type="text" name="tpersgst" id="tpersgst" class="calc" size="10"/></td>
        </tr>
        </table>
        <td width="8%" <?php echo $style?> ><input type="text" name="totsgst" id="totsgst" class="calc" size="10"/></td>
        </td>
      </tr>
       <tr>
        <td width="2%"></td>
        <td align="left"></td>
         <td align="left">&nbsp;</td>
        <td colspan="4">&nbsp;</td>
        <td width="5%" align="left" <?php echo $style?>>
        <table>
        <tr>
        <td>IGST:</td>
        <td width="37%">&nbsp;</td>
        <td <?php echo $style?> ><input type="text" name="pervat" id="pervat" class="calc" size="10"/></td>
        </tr>
        </table>
        <td width="8%" <?php echo $style?> ><input type="text" name="vat" id="vat" class="calc" size="10"/></td>
        </td>
      </tr>
      <tr>
        <td align="left" >Total in word</td>
        <td colspan="4" align="left"><input type="text" name="totalinword" class="totalinword input_field" id="totalinword" tabindex="17" />
        </td>
        <td width="2%">&nbsp;</td>
        <td></td>  
        <td  width="10%" align="left" <?php echo $style?>>Grand Total:</td>
        <td <?php echo $style?>><input type="text" name="grtotal" id="grtotal" class="calc" size="10"/>
        <!--<td width="5%" align="left" <?php echo $style?>>Grand Total:</td>
        <td width="8%" <?php echo $style?>><input type="text" name="newrecp" id="newrecp" class="newrecp" value="<?php echo $newrecp;?>" size="10"/></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($jobid!='')
{?>
$(window).load(function(){
	
	//data to be from commst
	$('#jobid').val('<?php echo clean($con,$row['jobid']); ?>');
	$('#jobcode').val('<?php echo clean($con,$row['jobcode']); ?>');
	$('#jobbername').val('<?php echo clean($con,$row['jobbername']);?>');
	$('#city').val('<?php echo clean($con,$client_detrow['cmpcity']); ?>');
	$('#gstin').val('<?php echo clean($con,$client_detrow['gstin']); ?>');
	$('#pincode').val('<?php echo clean($con,$client_detrow['pincode']); ?>');
	$('#transcode').val('<?php echo clean($con,$row['transcode']); ?>');
	$('#transport').val('<?php echo clean($con,$row['transport']); ?>');
	$('#paidby').val('<?php echo clean($con,$row['paidby']);?>');
	$('#supervisor').val('<?php echo clean($con,$row['Supervisor']);?>');
	$('#scontact').val('<?php echo clean($con,$row['scontact']);?>');
	//$('#status').val('<?php $statusArray = $_SESSION[SESS_STATUSARR]; echo clean($con,$statusArray[$row['status']]);?>');
	$('#jobypeval').val('<?php  echo clean($con,$row['statusto']);?>');
	$('#status').val('<?php  echo clean($con,$row['status']);?>');
	$('#notes').val('<?php echo clean($con,$row['notes']);?>');
	$('#disper').val('<?php echo clean($con,$row['disper']); ?>');
	$('#pdiscount').val('<?php echo clean($con,$row['pdiscount']); ?>');
	$('#pnamount').val('<?php echo clean($con,$row['pnamount']); ?>');
	$('#tpercgst').val('<?php echo clean($con,$row['tpercgst']); ?>');
	$('#totcgst').val('<?php echo clean($con,$row['totcgst']); ?>');
	$('#tpersgst').val('<?php echo clean($con,$row['tpersgst']); ?>');
	$('#totsgst').val('<?php echo clean($con,$row['totsgst']); ?>');	
	$('#pervat').val('<?php echo clean($con,$row['pervat']); ?>');
	$('#vat').val('<?php echo clean($con,$row['vat']); ?>');
	$('#grtotal').val('<?php echo clean($con,$row['grtotal']); ?>');
	$('#issdate').val('<?php if(clean($con,$row['date'])!='0000-00-00') echo date_formatc(clean($con,$row['issdate'])); ?>');
	$('#divdate').val('<?php if(clean($con,$row['date'])!='0000-00-00') echo date_formatc(clean($con,$row['divdate'])); ?>');
	$('#adress').val('<?php echo clean($con,$client_detrow['address']); ?>');
    $('#batchno').val('<?php echo clean($con,$row['batchno']); ?>');
    $('#department').val('<?php echo clean($con,$row['department']); ?>');
	$('#refno').val('<?php echo clean($con,$row['refno']); ?>');
	
	$('#jobcodeto').val('<?php echo clean($con,$row['jobcodeto']); ?>');
	$('#jobbernameto').val('<?php echo clean($con,$jobto_detrow['name']); ?>');
	$('#adressto').val('<?php echo clean($con,$jobto_detrow['address']); ?>');
    $('#jobstatus').val('<?php echo clean($con,$row['jobstatus']); ?>');
	 $('#subdesc').val('<?php echo clean($con,$row['subdesc']); ?>');
	$('#jobdet_container').html('<?php echo clean($con,$table); ?>');
	$(document).ready(function(){
	if($('#cat').val()=='SERVICES'){
	
	}
		
		if ($('#jobcodeto').val()!='')
		   {
			$('#process').hide();
			}
		else{
			$('#process').show();
			}
			$("#guesmas").hide();
			$('#Update').show();
			$('#Save').hide();
	run();
	inline_edit();
	jobentry_rel();
	
	
	});
	
	
	});
<?php }
else 
 ?>
$('#jobid').focus();
	
$(window).load(function() {
	
	var div_scr = $('#jobdet_container');
					 div_scr.scrollTop(div_scr.prop("scrollHeight"));
	
	$('#transperent').hide();
	
			var fresh = 0;
			var qty = 0;
			var reprocess = 0;	
			var demage = 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('.fresh').each(function( index ) {
				fresh+=Number($(this).val());
			  });
			  
			  thistable.find('.reprocess').each(function( index ) {
				reprocess+=Number($(this).val());
			  });
			  
			  thistable.find('.demage').each(function( index ) {
				demage+=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('.tfresh').val(fresh);
			 thistable.find('.treprocess').val(reprocess);
			 thistable.find('.tdemage').val(demage);
			 thistable.find('.trate').val(rate);
			 thistable.find('.tamount').val(amount);
});



	$("#jobcode").autocomplete(
      "../../client_fill.php",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
			mustMatch:0,
  			cacheLength:10,
			
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#jobbername').val(row.data[0]);			
				if(row.data[1]!='undefined')
				$('#adress').val(row.data[1]);
				if(row.data[3]!='undefined')
				$('#city').val(row.data[3]);
				if(row.data[4]!='undefined')
				$('#pincode').val(row.data[4]);
				if(row.data[5]!='undefined')
				$('#gstin').val(row.data[5]);
				$("#guesmas").hide();				
			},
			showResult:function(row,data) {
    			return row+"|"+data[0];
  			},
			onNoMatch:function(){

				$("#guesmas").show();
				},
  		
  			autoFill:false
  		});
		
		
		$("#jobcodeto").autocomplete(
      "../../client_fill.php",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#jobbernameto').val(row.data[0]);			
				if(row.data[1]!='undefined')
				$('#adressto').val(row.data[1]);
								
			},
			showResult:function(row,data) {
    			return row+"|"+data[0];
  			},
  		
  			autoFill:false
  		});
		
	$("#transcode").autocomplete(
      "../../client_fill.php",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			
  			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#transport').val(row.data[0]);			
				
								
			},
			showResult:function(row,data) {
    			return row+"|"+data[0];
  			},
  		
  			autoFill:false
  		});
	
	
	$("#supervisor").autocomplete(
      "../../supervisor_fill.php",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#scontact').val(row.data[0]);			
				
								
			},
			showResult:function(row,data) {
    			return row+"|"+data[0];
  			},
  		
  			autoFill:false
  		});
		
		
	$("#department").autocomplete(
      "../../supervisor_fill.php?mode=department",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			
			showResult:function(row,data) {
    			return row;
  			},
  		
  			autoFill:false
  		});
		
		$("#departmentto").autocomplete(
      "../../supervisor_fill.php?mode=department",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			
			showResult:function(row,data) {
    			return row;
  			},
  		
  			autoFill:false
  		});

	
</script>

</body>
</html>