<link rel="stylesheet" href="css/font.css" type="text/css" />
<script>
function media_report_print(url)
{
onmouseover650= window.open(url,'onmouseover650','height=580,width=1200,scrollbars=yes,left=50,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no');
}
function media_pending_report_overall_excel(from_date,to_date,job_card_no,buyer_name,type_1)
{
	
window.location.href="report/media_report/pending_excel.php?from_date="+from_date+"&to_date="+to_date+"&job_card_no="+job_card_no+"&buyer_name="+buyer_name+"&type_1="+type_1;
}
</script>
<?php error_reporting(0);
/*********************************Get Found Result And Pagination********************************************************/
include("../../include/db.php");


$type_1=$_GET['type_1'];
 $job_card_no=$_GET['job_card_no'];
 $buyer_name=$_GET['buyer_name'];
 
  $from_date=$_GET['from_date'];
 $to_date=$_GET['to_date'];
 $cur_date=date("Y-m-d");
if($from_date!=""){ $from_date1= "DATE_FORMAT(b.media_date,'%Y-%m-%d')>='$from_date'"; }else{$from_date1="DATE_FORMAT(b.media_date,'%Y-%m-%d')='$cur_date'"; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(b.media_date,'%Y-%m-%d')<='$to_date'";}else{$to_date1="DATE_FORMAT(b.media_date,'%Y-%m-%d')='$cur_date'";}
if($job_card_no!=""){ $job_card_no41 = "b.jobcard_no='$job_card_no'";}else{$job_card_no41="";}
if($buyer_name!=""){ $buyer_name41 = "b.in_cust_name='$buyer_name'";}else{$buyer_name41="";}


$all_value10 = $from_date1."@".$to_date1."@".$job_card_no41."@".$buyer_name41;
$all_array10 = explode('@',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
$get_query105 .= $value10." AND ";
}
}
if($from_date!=""){ $from_date2= "DATE_FORMAT(a.entry_time,'%Y-%m-%d')>='$from_date'"; }else{$from_date2="DATE_FORMAT(a.entry_time,'%Y-%m-%d')='$cur_date'"; }
if($to_date!=""){ $to_date2 = "DATE_FORMAT(a.entry_time,'%Y-%m-%d')<='$to_date'";}else{$to_date2="DATE_FORMAT(a.entry_time,'%Y-%m-%d')='$cur_date'";}
if($job_card_no!=""){ $job_card_no2 = "a.jobcard_no='$job_card_no'";}else{$job_card_no2="";}
if($buyer_name!=""){ $buyer_name2 = "a.customer_name='$buyer_name'";}else{$buyer_name2="";}


$all_value101 = $from_date2."@".$to_date2."@".$job_card_no2."@".$buyer_name2;
$all_array101 = explode('@',$all_value101);
foreach($all_array101 as $value101)
{ 
if($value101!='')
{
$get_query1051 .= $value101." AND ";
}
}

?>

<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 onclick="javascript:media_pending_report_overall_excel('<?php echo $_GET['from_date']; ?>','<?php echo $_GET['to_date']; ?>','<?php echo $job_card_no; ?>','<?php echo $buyer_name; ?>','<?php echo $type_1; ?>')" style="float:right"><img  align="right" src="img/excel-icon.png" width="30" height="30" border="0" title="click to export"></a>
        </td> 
<td width="7%" align="center"><a href="javascript:media_report_print('report/media_report/media_pending_report_print.php?from_date=<?php echo $_GET['from_date']; ?>&to_date=<?php echo $_GET['to_date']; ?>&job_card_no=<?php echo $job_card_no;?>&buyer_name=<?php echo $buyer_name; ?>&type_1=<?php echo $type_1; ?>');" 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="100%"  align="center" cellpadding="0" cellspacing="0"  >
<thead>
<tr>
 
 <th height="23" colspan="2"  valign="middle">Pending</th>


</tr>
<tr>   
   
 <th height="23" colspan="2" valign="middle">

<table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0"  >
<tr>
    <th   align="left" >S.No</th>
    <th   align="left" >Date</th>
	<th  align="left" >Jobcard No</th>
	<th   align="left" >Buyer Name</th>    
    <th   align="left" >Particulars</th>
	 <th   align="center" >Order Qty</th>
    <th   align="center" >Plan Qty</th>
	 <th   align="center" >Pending Qty</th>
	
 </tr>
 
 </td>
 
 <td colspan="2">
 
   <?php
$i=0;



//$sql="select *,sum(order_qty) as order_qty,sum(plan_qty) as plan_qty  from media_sub_list where $get_query105 id!='' group by  media_particular ASC ";

$sql="select a.entry_time as media_date,a.particulars as media_particular,a.customer_name as in_cust_name,a.jobcard_no as jobcard_no,a.qty as order_qty,a.jobcard_no as plan_qty, sum(a.jobcard_no)  as totalplanqty from jobcard_sublist as a LEFT JOIN media_sub_list as b ON a.jobcard_no=b.jobcard_no where $get_query1051 b.jobcard_no IS NULL group by a.particulars 
UNION

select b.media_date as media_date,b.media_particular as media_particular,b.in_cust_name as in_cust_name,b.jobcard_no as jobcard_no,b.order_qty as order_qty,b.plan_qty as plan_qty, sum(b.plan_qty)  as totalplanqty from  media_sub_list as b  where $get_query105 b.id!='' group by b.media_particular ";



//echo $sql;

    $rs=mysql_query($sql);
     $rscount=mysql_num_rows($rs);
  if($rscount!='')
  {
  $s_no=0;
      while($rsdata=mysql_fetch_array($rs))
        {
        $media_date=$rsdata['media_date'];
		$media_particular=$rsdata['media_particular'];
		$customer_name=$rsdata['in_cust_name'];
        $jobcard_no=$rsdata['jobcard_no'];
       
		$order_qty=$rsdata['order_qty'];
		$plan_qty=$rsdata['plan_qty'];
		$totalplanqty =$rsdata['totalplanqty']; 
		$pending_qty=$order_qty-$plan_qty;
        $newpendingqty = $order_qty - $rsdata['totalplanqty']; 
        
/********************Filtering F EMBOSS GEL********************************* */ 		
		 $is_f_embosss= 0; 
              $sql_user="select * from  jobcard_main where jobcard_no='$jobcard_no'";

		
              $rs_user=mysql_query($sql_user);
                    while($rsdata_user=mysql_fetch_object($rs_user))
                    { 
                    $fabrictype=$rsdata_user->fabric_type;
                    }
              
               if ($fabrictype == "F EMBOSS GEL   EMBOSING ") {
                 $is_f_embosss = 1;
               }		
          
 /*************************************************************************** */         
        
       if($newpendingqty > 0 && $is_f_embosss == 0 ){ 
           $i=$i+1;
    ?>
        <tr>
           <td  align="left" style="border:1px solid #ddd;width: 50px;" ><?php  echo $i; ?>&nbsp;&nbsp;</td>
          <td  height="28" align="left" style="border:1px solid #ddd;width: 100px;" >&nbsp;&nbsp;&nbsp;<?php echo date("d-m-Y",strtotime($media_date)); ?></td>
		  <td  align="left" style="border:1px solid #ddd;width: 150px;" ><?php  echo $jobcard_no; ?>&nbsp;&nbsp;</td>
		   <td  align="left" style="border:1px solid #ddd;width: 200px;" ><?php  echo $customer_name; ?>&nbsp;&nbsp;</td> 
         <td  align="left" style="border:1px solid #ddd;width: 200px;" ><?php  echo $media_particular; ?>&nbsp;&nbsp;</td>
         
		  <td  align="right" style="border:1px solid #ddd;width: 100px;" ><?php  echo number_format($order_qty,2); ?>&nbsp;&nbsp;</td>
          <td  align="right" style="border:1px solid #ddd;width: 100px;" ><?php  echo number_format($totalplanqty,2); ?>&nbsp;&nbsp;</td>
		  <!--<td  align="right" style="border:1px solid #ddd;width: 100px;" ><?php  echo number_format($pending_qty,2); ?>&nbsp;&nbsp;</td>-->
		  <td  align="right" style="border:1px solid #ddd;width: 100px;" ><?php  echo number_format($newpendingqty ,2); ?>&nbsp;&nbsp;</td>
     </tr>
      <?php 
       
      $sum_tot1+=$order_qty;
	  $sum_tot2+=$plan_qty;
// 	  $sum_tot3+=$pending_qty;
      $sum_tot3+=$newpendingqty;
      }
      }
  }
      ?>
         <tr>
       <th height="28" colspan="5" align="right" style="border:1px solid #ddd" ><strong>Total&nbsp;&nbsp;</strong></th>
          <th width="87" align="right" style="border:1px solid #ddd" ><strong><?php  echo number_format($sum_tot1,2); ?>&nbsp;&nbsp;</strong></th>
		  <th width="87" align="right" style="border:1px solid #ddd" ><strong><?php  echo number_format($sum_tot2,2); ?>&nbsp;&nbsp;</strong></th>
          <th width="87" align="right" style="border:1px solid #ddd" ><strong><?php  echo number_format($sum_tot3,2); ?>&nbsp;&nbsp;</strong></th>
    </tr>
    </table>
 </td>
  