<?php ob_start();
$PageSecurity = 2;
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
$data1='';
$data2='';
$data3='';
$data4='';
if($_REQUEST['jwID']!='')
{
		 // // Job Work Date
		  	$sql_JobDate ="Select jobDate,partyJWNo,job_type from job_work where id='".$_REQUEST['jwID']."'";
			$result_JobDate = DB_query($sql_JobDate,$db);
			$Job_Data=DB_fetch_array($result_JobDate);
			$data1.=ConvertSQLDate($Job_Data['jobDate']);
			$data2.=$Job_Data['partyJWNo'];
         if($Job_Data['job_type']=='S')
         $jobtype='Service';
        else
         $jobtype='Job Process';
         
        
		
$data3.='<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">';
$data3.='<tr>';
$data3.='<td class="tabledata">Select</td>';
$data3.='<td class="tabledata">Item Code </td>';
$data3.='<td class="tabledata">Item Name </td>';
$data3.='<td class="tabledata">Item Description </td>';
$data3.='<td class="tabledata">Uom</td>';
$data3.='<td class="tabledata">Quantity</td>';
$data3.='<td class="tabledata">Process</td>';
$data3.='</tr>';
	$details_sql="Select * from job_work_details where masterId='".$_REQUEST['jwID']."'";
	$details_result=DB_query($details_sql,$db);
	$j=0;
	while($details_row=DB_fetch_array($details_result))
	{
		$item_sql="Select * from item_master where id ='".$details_row['mst_itemId']."'";
		$item_result=DB_query($item_sql,$db);
		$item_row=DB_fetch_array($item_result);
		
		$unit_sql="Select * from unitsofmeasure where unitid ='".$item_row['mst_unitid']."'";
		$unit_result=DB_query($unit_sql,$db);
		$unit_row=DB_fetch_array($unit_result);
$data3.='<input type="hidden" name="itemID['.$j.']" id="itemID" value="'.$details_row['mst_itemId'].'"';
		
$data3.='<tr bgcolor="#c1c1c1">';
$data3.='<td><input type="checkbox" value="'.$j.'" size="15" name="chk[]"
      checked="checked"></td>';
$data3.='<td>'.$item_row['StockID'].'</td>';
$data3.='<td>'.$item_row['item_name'].'</td>';
$data3.='<td>'.$item_row['item_desc'].'</td>';
$data3.='<td>'.$unit_row['unitname'].'</td>';
$data3.='<td><input type="text" value="'.$details_row['quantity'].'" size="15" name="quantity['.$j.']"></td>';
$data3.='<td><select name="process['.$j.']" id="process" style="width:100px" >
	<option value="0">Select</option>';
	$floor_sql=DB_query("select * from job_work_master",$db);
	while($floor_row=DB_fetch_array($floor_sql))
	{
	if($details_row['process']==$floor_row['id']) { $u='selected'; } else { $u=''; }
	$data3.='<option value="'.$floor_row['id'].'"'.$u.'>'.$floor_row['jobwork_name'].'</option>';
	}
    $data3.='</select></td>';
$data3.='</tr>';
$j++; }	
$data3.='</table>';


if($jobtype!='Service')
{
$data5='';
$data5.='<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">';
$data5.="<tr><td colspan='10'><input type='button' onclick=addRow('dataTable') value='Add Rows' class='search' />
 <input type='button' class='search'   onclick=deleteRowOrder('dataTable') value='Delete' /></td></tr>";

$data5.="<tr class='row1'>
          <th><strong>S.R.</strong></th>
          <th></th>
          <th><strong>Part Code</strong></th>
          <th><strong>Part Name</strong></th>
          <th><strong>Unit</strong></th>
		    <th><strong>Batch No.</strong></th>
		    <th><strong>Stock Qty.</strong></th>
          <th><strong>Qty</strong></th>
          <th><strong>Job Rate</strong></th>
		    <th><strong>Job Value</strong></th>		   
        </tr>";

 $data5.="<tbody id='dataTable'>
           <tr class='row1'>
            <td><input name='delitem[]' type='checkbox'  id='delitem' /></td>
            <td><input  type='hidden'   readonly=''  id='itemdataid'  name='itemdataid[]' /></td>
            <td><input type='text' value='' tabindex=''   id='itemcode' name='itemcode[]' style='width:100%' onkeyup=opendata(this.value,this.id) /></td>
            <td><input type='text' name='desc[]'  id='descriptions' style='width:100%'  value=''/></td>
            <td><input type='text' name='uom[]' id='uom' size='5' value='' readonly /></td>
            <td><input type='text' name='batch_no[]'  id='batchno'  size='18'  /></td>
			   <td><input type='text' name='stock_qty[]'  id='stock_qty'  size='18'  /></td>
            <td><input  type='text' name='qty[]'  id='qty' size='15' onkeyup=chkstockqty(this.id,this.value)  value=''/></td>
            <td><input  type='text' name='job_rate[]'  id='jobrate' size='15' onkeyup=caltotal(this.id) ></td><td><input  type='text' name='job_value[]'  id='jobvalue' size='15'/></td>
            </tr>
        </tbody>
      </table>
    <input type='hidden' name='hiditemcount' id='hiditemcount' value='' />
  <input type='hidden'  value='' id='edit_cnt' />      

";
 


}
}



echo $data=$data1.'__'.$data2.'__'.$data3.'__'.$jobtype.'__'.$data5.'__'.$Job_Data['job_type'];
?>