<link rel="stylesheet" href="css/font.css" type="text/css" />
<script>
function job_no_wise_print(url)
{
onmouseover43= window.open(url,'onmouseover43','height=580,width=1100,scrollbars=yes,left=50,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no');
}
</script>
<?php error_reporting(0);
/*********************************Get Found Result And Pagination********************************************************/
include("../../include/db.php");

$show =20;
$num_links = 9;
$from = $_GET['from'];
if (empty($from))
	 {
		$from = "0";
	 } 
else 
	{
	    $html_query = $html_query. "&from=$from";
	}
$from_date=$_GET['from_date'];
$to_date=$_GET['to_date'];
$current_date=date('Y-m-d');
if($from_date!=""){ $from_date1= "print_date>='$from_date'"; }else{$from_date1="print_date='$current_date'"; }
if($to_date!=""){ $to_date1 = "print_date<='$to_date'";}else{$to_date1="print_date='$current_date'";}
{
$all_value10 = $from_date1.",".$to_date1;
}
$all_array10 = explode(',',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
$get_query104 .= $value10." AND ";
}
}	  

 $sql="select * from printer_production_main where $get_query104 p_id!='' ";

$html_query = "main_fram.php?file=Date_wise_printer";
$result=mysql_query($sql);
$num_results=mysql_num_rows($result);
if ($num_results == 0) 
{
 $confirmation = "No Records!";
} 
elseif ($num_results == 1) 
{
$confirmation = "Found 1 Record.";
} 
else 
{
$confirmation = "Found $num_results Records.";
} 
$customer_name=$_GET['customer_name'];
$from_date=$_GET['from_date'];
$to_date=$_GET['to_date'];
?>
<style type="text/css">
<!--
.style1 {font-size: 16px}
-->
</style>
<table width="100%">
<tr>
<td width="1%" height="38">&nbsp;</td>
<td width="7%" class="style15">&nbsp;</td> 
<td width="13%" align="center">&nbsp;</td>
<td width="1%">&nbsp;</td>
<td width="6%" class="style15">&nbsp;</td>
<td width="14%" align="center"  class="style15">&nbsp;</td>
<td width="2%">&nbsp;</td>
<td width="11%" class="style15">&nbsp;</td>
<td width="24%" align="left" >&nbsp;</td>
<td width="8%" align="center">&nbsp;</td>
<td width="2%"></td>
<td width="7%" align="center"><a href="javascript:job_no_wise_print('report/date_wise_printer/date_wise_print1.php?from_date=<?php echo $_GET['from_date'];?>&to_date=<?php echo $_GET['to_date'];?>');" style="text-decoration:none;"><img src="img/PrinterBlack.png" width="35" height="30" title="Print" value="Print"/></a></td>
  </tr>
</table>
<div class="container">
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<div class="CSSTableGenerator">  
<table border="0" width="97%"  align="center" cellpadding="0" cellspacing="0" style="border:1px solid #ddd" >
<thead>
<tr>
    <th  height="23"  align="center" style="border:1px solid #ddd" >S.No</th>
    <th  align="left" style="border:1px solid #ddd" >Date</th>
    <th  align="left" style="border:1px solid #ddd" >Jobcard No</th>
    <th  align="left" style="border:1px solid #ddd" >Customer Name</th>
    <th width="85"  align="left" style="border:1px solid #ddd" >Date</th>
    <th width="85"  align="left" style="border:1px solid #ddd" >Shift</th>
    <th width="111"  align="left" style="border:1px solid #ddd" >Operator</th>
        <th width="89"  align="left" style="border:1px solid #ddd" >Machine No	</th>

    <th width="91"  align="left" style="border:1px solid #ddd" >Particulars</th>
        <th width="79"  align="right" style="border:1px solid #ddd" >Order Qty&nbsp;</th>
                <th width="80"  align="right" style="border:1px solid #ddd" >Product Qty&nbsp;</th>

        <th width="95"  align="right" style="border:1px solid #ddd" >Balance Qty&nbsp;</th>
    </tr>
  <?php
include("../../include/db.php");
function get_operator_names_cust($ope_name)
{
	$entity11="select * from operator_creation where id='$ope_name'";
$rs11=mysql_query($entity11);
 while($trips=mysql_fetch_array($rs11))
 {
$operator_namess=$trips['operator_name'];

}
return $operator_namess;
}
function get_machine_name_cust($machine_no)
{
	
  $sql_query11="select * from machine_creation where id='$machine_no' and  mach_type='printer'";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $machine_no=$rsdata11->machine_no;
 } 
return $machine_no;
}

function get_shift_name_from_cust($shift_time)
{
$sql_query11="select * from shift_creation where id='$shift_time' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $from_time=$rsdata11->from_time;
  $to_time=$rsdata11->to_time;
 $shift_name=$rsdata11->shift_name;

 } 
 $tot_shift=array($from_time,$to_time,$shift_name);
return $tot_shift;
}
 
 
 function get_order_qty($job_card_no,$prod_size)
{
	$sql_query="select * from printer_production_sublist where job_card_no='$job_card_no' and prod_size='$prod_size' ";
    $rs=mysql_query($sql_query);
    $rscount=mysql_num_rows($rs);
	return $rscount;
 }
 
 
 function get_max_order_qty($job_card_no,$prod_size)
{
$sql_query="select max(total_qty) as total_qty from printer_production_sublist where job_card_no='$job_card_no' and prod_size='$prod_size' ";
    $rs11=mysql_query($sql_query);
 while($rsdata=mysql_fetch_array($rs11))
 {
$total_qty=$rsdata['total_qty'];
}
return $total_qty;
}

 function get_order_qty1($job_card_no,$prod_size,$pr_id)
{
 $sql_query="select total_qty from printer_production_sublist where job_card_no='$job_card_no' and prod_size='$prod_size' and pr_id='$pr_id'  ";
    $rs11=mysql_query($sql_query);
 while($rsdata=mysql_fetch_array($rs11))
 {
$total_qty=$rsdata['total_qty'];
}
return $total_qty;
}	  
$from_date=$_GET['from_date'];
$to_date=$_GET['to_date'];
$current_date=date('Y-m-d');
if($from_date!=""){ $from_date1= "print_date>='$from_date'"; }else{$from_date1="print_date='$current_date'"; }
if($to_date!=""){ $to_date1 = "print_date<='$to_date'";}else{$to_date1="print_date='$current_date'";}

{
$all_value102 = $from_date1.",".$to_date1;
}
$all_array102 = explode(',',$all_value102);
foreach($all_array102 as $value102)
{ 
if($value102!='')
{
  $get_query103 .= $value102." AND ";
}
}	  

    $sql="select * from printer_production_main where $get_query103 p_id!='' ";
    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				 $s_no=$s_no+1;
				 $from=$from+1;
                 $id=$rsdata['p_id'];
                 $job_card_no=$rsdata['job_card_no'];
				 $print_date=$rsdata['print_date'];
				 $cust_name=$rsdata['cust_name'];
				 $job_type=$rsdata['job_type'];
				 $billed_status=$rsdata['billed_status'];
				 $fabric_type=$rsdata['fabric_type'];
				 $printed_qty=$rsdata['printed_qty'];

				 
 ?>
    <tr>
    <td width="46"  align="center" style="border:1px solid #ddd">&nbsp;<?php echo $from; ?></td>
    <td width="72" align="left" style="border:1px solid #ddd" >&nbsp;<?php echo date("d-m-Y",strtotime($print_date));?></td>
    <td width="99" align="left" style="border:1px solid #ddd" >&nbsp;<?php echo $job_card_no; ?></td>
    <td width="120" align="left" style="border:1px solid #ddd" >&nbsp;<?php echo $cust_name; ?></td>
      <td colspan="8" style="border:1px solid #ddd" align="right"><table width="100%" style="border:0px;">
   <tbody >   <?php
	$entity11="select * from printer_production_sublist where job_card_no='$job_card_no' order by job_card_no,operator_name,prod_size ASC";
	$rs11=mysql_query($entity11);
 while($trips=mysql_fetch_array($rs11))
 {
$pr_id=$trips['pr_id'];
$job_card_no=$trips['job_card_no'];
$machine_no=$trips['machine_no'];
$operator_name=$trips['operator_name'];
 $operator_name2=get_operator_names_cust($operator_name);
$shift_time=$trips['shift_time'];
$prod_size=$trips['prod_size'];
$production_time=$trips['production_time'];
$prod_qty=$trips['prod_qty'];
$mach_no=get_machine_name_cust($machine_no);
list($frm_ti,$to_ti,$type)=get_shift_name_from_cust($shift_time);

                  $total_qty=$trips['total_qty'];
                  $balance_qty=$trips['balance_qty'];
				  $count_order_qty = get_order_qty($job_card_no,$prod_size); 
	 $max_order_qty = get_max_order_qty($job_card_no,$prod_size);
	 $qty=  get_order_qty1($job_card_no,$prod_size,$pr_id);
	if($max_order_qty==$qty)
	{
		$qty=$max_order_qty;
	}
	else
	{
		$qty='';
	}
	?>
    <tr>
      <th width="15%" align="left" style="border:0px;color:#000;"><?php echo date('d-m-y h:m a',strtotime($production_time)); ?>&nbsp;</th>
      <th width="15%" align="left" style="border:0px;color:#000;"><?php echo $type; ?>&nbsp;</th>
    <th width="18%" align="left" style="border:0px; color:#000"><?php echo $operator_name2; ?>&nbsp;</th>
    <th width="14%" align="left" style="border:0px; color:#000"><?php echo $mach_no; ?>&nbsp;</th>
        <th width="14%" align="left" style="border:0px; color:#000"><?php echo $prod_size; ?>&nbsp;</th>
        <th width="12%" align="right" style="border:0px; color:#000"><?php echo $qty; ?>&nbsp;</th>
                <th width="12%" align="right" style="border:0px; color:#000"><?php echo number_format($prod_qty,2); ?>&nbsp;</th>

        <th width="15%" align="right" style="border:0px; color:#000"><?php echo $balance_qty; ?>&nbsp;</th>
    </tr><?php $total1+=$qty; 
	$total2+=$prod_qty; 
	$total3+=$balance_qty; }  ?></tbody></table></td>
    </tr>
  <?php } ?>
   <tr>
   <td colspan="9" align="right" class="style1"><strong>Total</strong></td>
   <td align="right" class="style1"><strong><?php echo number_format($total1,2); ?></strong></td>
      <td align="right" class="style1"><strong><?php echo number_format($total2,2); ?></strong></td>

   <td align="right" class="style1"><strong><?php echo number_format($total1-$total2,2); ?></strong></td>
    </tr>
  </thead>
</table>
</div>
</div>
</div>
</div>

