<?php
$PageSecurity = 2;
include('includes/DefineSuppTransClass.php');
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
include('includes/session.inc');
include('includes/function_lib.php');

     $wono=$s->getField('job_card','id',$_GET['salid'],'wo_no');
	  $worid=$s->getField('job_card','id',$_GET['salid'],'work_itemid');
	 $item=$s->getField('item_master','id',$worid,'item_name');
    $data5='';
	$data5.="<select name='work_order_no' style='width:100%' id='work_order_no'  >'";
	
	$floor_sql=DB_query("Select * from salesorder where id='".$wono."' order by orderNo ASC",$db);
	while($floor_row=DB_fetch_array($floor_sql))
	{	
	$data5.="<option value=".$floor_row['id']." >".$floor_row['orderNo']."</option>";
		
	}
	
    $data5.="</select>";	
   
    $data1='';
	$data1.="<input type='text' name='finished_item' style='width:100%' id='finished_item' 
    value='".$item."'>";     
		
	$data2='';
	$orderdate=$s->getField('salesorder','id ',$wono,'orderDate');
	$data2.="<input type='text' name='orderdate' id='orderdate' value='".ConvertSQLDate($orderdate)."' 
	readonly='readonly' style='width:100%;' >";
	$data3='';
	 $ven=$s->getField('salesorder','id ',$wono,'client');
	 $venname=$s->getField('clientmaster','id ',$ven,'c_name');
	$data3.="<input type='text' name='client' id='client' value='".$venname."'  style='width:100%;' >";
	
	$data4='';
	$delivery=$s->getField('salesorder','id ',$wono,'deliverydate');
	$data4.="<input type='text' name='deliverydate' id='deliverydate' value='".ConvertSQLDate($delivery)."' 
	 style='width:100%;' readonly='readonly' >";



  $data6='';
  $data6.="<table width='100%' border='1' cellspacing='0' cellpadding='2'>
  <tr>
		
           <th><strong>S. No.</strong></th>
            <th><strong>PART CODE </strong></th>
           <th><strong>ITEM NAME</strong></th>
           <th><strong>UOM</strong></th>
           <th><strong>ITEM QTY.</strong></th>
           <th><strong>EXPECTED COMPLETION  DATE</strong></th>
        </tr>";
		$i=1;
		$sql1=DB_query("select * from job_card_item_details where jobid='".$_GET['salid']."'",$db);
		while($row1=DB_fetch_array($sql1))
		{
		$Stockid=$s->getField('item_master','id',$row1['mst_itemid'],'StockID');
		$itemnam=$s->getField('item_master','id',$row1['mst_itemid'],'item_name');
		$unit=$s->getField('item_master','id',$row1['mst_itemid'],'mst_unitid');
		$unitname=$s->getField('unitsofmeasure','unitid',$unit,'unitname');
      $data6.="<tr>";
       $data6.="<td>".$i."</td>";
	   $data6.="<td>".$Stockid."</td>";
      $data6.= "<td>".$itemnam."</td>";
       $data6.="<td>".$unitname."</td>";
       $data6.="<td>".$row1['item_qty']."</td>";
       $data6.="<td>".ConvertSQLDate($row1['expected_date'])."</td>";
      
  $data6.="</tr>";
$i++; }

$data6.="</table>";



$data7='';



		
	

  $data7.="<table width='100%' border='1' cellspacing='0' cellpadding='2'>
          <tr>		
          <th width='6%'><strong>S.No. </strong></th>
		   <th width='12%'><strong>Item</strong></th>
          <th width='12%'><strong>PROCESS</strong></th>
          <th width='12%'><strong>MACHINE</strong></th>
          <th width='17%'><strong>OPERATOR</strong></th>
          <th width='16%'><strong>EXP COM DATE</strong></th>
          <th width='18%'><strong>CURRENT STATUS</strong></th>
          <th width='19%'>Remarks</th>
        </tr>";
		$i=1;
		$sql2=DB_query("select * from job_process_details where jobid='".$_GET['salid']."' and status1=0;",$db);
		while($row2=DB_fetch_array($sql2))
		{
		$itemprocess=$s->getField('item_master','id',$row2['item'],'item_name');
		$process=$s->getField('production_process_master','id',$row2['process'],'manuf_process_name');
		$machine=$s->getField('machine_center','id',$row2['machine'],'name');
		$operator=$s->getField('production_operator_master','id',$row2['operator'],'operator_name');
		$c='';
		if($row2['current_status']=='Pending')
		$c='selected';
			
      $data7.="<tr>";
	   $data7.="<td>".$i."<input type='hidden' name='jobprocessid[]' value='".$row2['id']."'></td>";
	    $data7.="<td>".$itemprocess."<input type='hidden' name='itemid[]' value='".$row2['item']."'></td>";
	     $data7.="<td>".$process."<input type='hidden' name='process[]' value='".$row2['process']."'></td>";
      $data7.= "<td>".$machine."<input type='hidden' name='machine[]' value='".$row2['machine']."'></td>";
       $data7.="<td>".$operator."<input type='hidden' name='operator[]' value='".$row2['operator']."'></td>";
       $data7.="<td>".ConvertSQLDate($row2['exp_date'])." <input type='hidden' name='date[]' value='".ConvertSQLDate($row2['exp_date'])."'></td>";
	   $data7.="<td><select name='status[]' id='status' style='width:100%' >";
	   $data7.="<option value='0'>---Select----</option>";
       $data7.="<option value='Pending'".$c.">Pending</option>";
	  $data7.="<option value='In Process'  >In Process</option>";
	 $data7.="<option value='Complete' >Complete</option>";
	 $data7.="</select></td>";
       $data7.="<td><textarea name='remarks1[]' id='remarks'></textarea></td>";
      
  $data7.="</tr>";
$i++; }

$data6.="</table>";




$data8='';
$data8.="<table width='100%' border='1' cellspacing='0' cellpadding='2'>
          <tr>		
          <th width='6%'><strong>S.No. </strong></th>
		    <th width='12%'><strong>Item</strong></th>
          <th width='12%'><strong>PROCESS</strong></th>
          <th width='12%'><strong>MACHINE</strong></th>
          <th width='17%'><strong>OPERATOR</strong></th>
          <th width='16%'><strong>EXP COM DATE</strong></th>
          <th width='18%'><strong>CURRENT STATUS</strong></th>
          <th width='19%'>Remarks</th>
        </tr>";
		$i=1;
		
		$iddata=$s->getField('daily_jobwork','jobcardid',$_GET['salid'],'id');
		
		$sql2=DB_query("select * from daily_jobwork_process where dailyid='".$iddata."'",$db);
		while($row2=DB_fetch_array($sql2))
		{
		$itemprocess=$s->getField('item_master','id',$row2['item'],'item_name');
		$process=$s->getField('production_process_master','id',$row2['process'],'manuf_process_name');
		$machine=$s->getField('machine_center','id',$row2['machine'],'name');
		$operator=$s->getField('production_operator_master','id',$row2['operator'],'operator_name');
		$c='';
		if($row2['status']=='Pending')
		$c='selected';
		$d='';
		if($row2['status']=='In Process')
		$d='selected';
		$e='';
		if($row2['status']=='Complete')
		$e='selected';
		$data8.="<tr>";
		$data8.="<td>".$i."<input type='hidden' name='jobprocessid1[]' value='".$row2['id']."'></td>";
		$data8.="<td>".$itemprocess."<input type='hidden' name='itemid1[]' value='".$row2['item']."'></td>";
		$data8.="<td>".$process."<input type='hidden' name='process1[]' value='".$row2['process']."'></td>";
		$data8.= "<td>".$machine."<input type='hidden' name='machine1[]' value='".$row2['machine']."'></td>";
		$data8.="<td>".$operator."<input type='hidden' name='operator1[]' value='".$row2['operator']."'></td>";
		$data8.="<td>".ConvertSQLDate($row2['exp_date'])."</td>";
		$data8.="<td>".$row2['status']."</td>";
		$data8.="<td><textarea name='remarks1[]' id='remarks' readonly='readonly'>".$row2['remarks']."</textarea></td>";
		$data8.="</tr>";
$i++; }$data8.="</table>";










	
	echo $data=$data1."__".$data2."__".$data3."__".$data4."__".$data5."__".$data6."__".$data7."__".$data8;		
					
			
