<link rel="stylesheet" href="css/new_mxerp.css">

<?php extract($_POST);
$PageSecurity = 1;
$tabindex=0;
include('includes/DefinePaymentClass.php');
$title = _('Break Down Report');
include('includes/SQL_CommonFunctions.inc');
?>


<div class="body_contain">
<div class="tab_div">

<h1><?php echo $title;?></h1>



			<form  action="" method="post">
			   <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
			  <tr>
			<td class="tabledata" style="width:146px;">Order No. Wise</th>
			    <td style="width:246px;"><select name="orderno" onchange="getdata(this.value)" style="width:100%">
	<option value="000">Select</option>
	<?php 
	$name_sql=DB_query("Select  orderNo,id from salesorder",$db);
	while($name_row=DB_fetch_array($name_sql)) {
	?>
	<option value="<?php echo $name_row['id'];?>"><?php echo $name_row['orderNo'];?></option>
	<?php } ?>
    </select>	</td>
    <td class="tabledata" style="width:146px">Job Card No</th>
				<td id="hotfoil" ><select name="jobcard" id="jobcard" style="width:100%">
				     <option value="0">Select</option>
				</select></td>
			  </tr>	 
		  </table>
		  <p align="center"><input type="Submit" name="Proceed" value="Proceed" /></p>
		  </form>

	  	
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
              <tr>
               <td class="tabledata"><strong>Sr.No</strong></td>
               <td class="tabledata"><strong>JC No</strong> </td>
               <td class="tabledata"><strong>BD Start Date</strong> </td>
               <td class="tabledata"><strong>BD Start Time</strong> </td>
				<td class="tabledata"><strong>BD End Date</strong></td>
				<td class="tabledata"><strong>BD End Time</strong></td>
               <td class="tabledata"><strong>BD Type</strong></td>
                <td class="tabledata"><strong>BD Reason</strong></td>
               <td class="tabledata"><strong>Total Hours</strong></td>
               <td class="tabledata"><strong>Machine Center</strong></td>
              </tr>
    	  <?php 
    	 if(isset($_POST['Proceed']))
		 {		  	
    	$filter=array();		
		if($_REQUEST['jobcard']!='0')
		$filter[]="A.job_card_id='".$_REQUEST['jobcard']."'";
		if($filter!='')
		{
			if($_REQUEST['jobcard']!='0'){$filter2=implode(" and ",$filter)." group by job_card_id";}
			else
			$filter2=implode(" and ",$filter);
		}			
				
		if($_REQUEST['jobcard']!='0')
		{
		 $sql="Select A.*, B.*  from daily_production_process A, daily_production_breakdown B where B.daily_id=A.daily_id and $filter2 ";	
	 		}
		else{
		   $sql="Select A.*, B.*  from daily_production_process A, daily_production_breakdown B where B.daily_id=A.daily_id"; }
                   $SQL1="Select A.*, B.*  from daily_production_process A, daily_production_breakdown B where B.daily_id=A.daily_id AND   B.breakdown_applicable='Yes'";
		$result=DB_query($SQL1,$db);
		$i=1;
		 $mmm=DB_num_rows($result);
		if(DB_num_rows($result)>0)
		{
				while($myrow=DB_fetch_array($result))
			{
					
          ?>
	  <tr bgcolor="#c1c1c1">
    	    <td ><?php echo $i;?></td>
    	    <td ><?php   $jobcard=$s->getField('daily_production_process','daily_id',$myrow['daily_id'],'job_card_id');  echo $s->getField('job_card','id',$jobcard,'job_card_no'); ?></td>
	 	    <td><?php  echo ConvertSQLDate($myrow['break_down_strat_date']);?></td>
    	    <td><?php echo $myrow['break_down_s_time'];?></td>
    	    <td><?php echo ConvertSQLDate($myrow['break_down_end_date']);?></td>
    	     <td><?php echo $myrow['break_down_e_time'];?></td>
    	     <td><?php  echo $breaktype=$s->getField('break_down_master','id',$myrow['breakdown_type'],'brack_down_type'); ?> </td>
    	       <td><?php echo $breakreason=$s->getField('break_down_type','id',$myrow['breakdown_reason'],'breakdown_reason');  ?> </td>
    	         <td><?php echo $myrow['breakdown_minute'];?></td>
    	         <td><?php echo $machine=$s->getField('machine_center','id',$myrow['machine_center'],'code'); ?></td>
    	          </tr>    	  
  	  <?php $i++; }  }else
		{?>
		<tr bgcolor="#c1c1c1">
		   <td colspan="10"><font color="#FF0000">No Record Found</font></td></tr>
		<?php 	
		}
		}
	?></table>
	
</div></div>




     <?php
//include('includes/footer.inc');
?>
<script language="JavaScript">
function getdata(data)
{
if (data.length==0)
  {
  document.getElementById("hotfoil").innerHTML="";
 
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("hotfoil").innerHTML=xmlhttp.responseText;
      }
  }
 
xmlhttp.open("GET","get_entryslip_jobcard.php?data="+data,true);
xmlhttp.send();	
	
	
}	
	
	
	
</script>