<script src="js/jquery/jquery.js" type="text/javascript"></script>
<script src="js/jquery/jquery-1.8.2.js"></script>
<script src="js/jquery/jquery-ui.js"></script>
<?php
error_reporting(0);
include("../../include/db.php");
date_default_timezone_set('Asia/Kolkata');
?>
<style type="text/css">
.txt{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size:13px;}
.headings{ font-family:verdana; font-size:10px;}
.form-style-6 ul{
    font: 95% Arial, Helvetica, sans-serif;
    max-width: 200px;
    margin-left: 10px;
    padding: 36px;
}
.form-style-6 li h1{
    background: #777777;
    font-size: 140%;
    font-weight: 300;
    text-align: center;
    color: #fff;
	padding:20px;
}
.form-style-7{
    font: 95% Arial, Helvetica, sans-serif;
    max-width: 200px;
    padding: 36px;
}
.form-style-7 h2{
    background: #777777;
    font-size: 140%;
    font-weight: 300;
    text-align: center;
    color: #fff;
	padding:20px;
}
.pad{margin-right:2px}
.class_px{ font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold }
</style>
<script>
function process_jobcard_report_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>
<table width="850" height="100%" align="center" cellpadding="0" cellspacing="0">
  <tr>
<td height="152" align="left" valign="top">
<table width="100%" border="0" align="center"  cellpadding="0" cellspacing="0" >
        <?php
	 function get_cust_address($cust_name)
{
$sql_query11="select * from party_creation where party_name='$cust_name' and delete_status!='1' and `party_type`='Customer'   order by party_name ASC ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $address=$rsdata11->address;
 } 
return $address;
}
  $sql="select * from  jobcard_main where jobcard_no='$_GET[job_card_no]' ";

    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				$cust_name=$rsdata['cust_name'];
               $cust_address=get_cust_address($cust_name);
			  
				  }
			
			 $sql1="select sum(qty) as qty from  jobcard_sublist where jobcard_no='$_GET[job_card_no]' ";

    $rs1=mysql_query($sql1);
	$s_no=0;
   		while($rsdata1=mysql_fetch_array($rs1))
  			{
   				$job_qty=$rsdata1['qty'];
               } ?>
       <tr style="height:60">
<td width="137" height="106" align="right" style="font-size:12px;"><img src="../../img/logo_image.png" width="126" height="130"/></td>
<td width="711" colspan="5" align="center" valign="top" style=""><strong style="font-size: 30px; color: #06F; padding-top: 5px; width: 80px; font-family: Verdana, sans-serif">SRI AMMAN DIGITAL PRINTS</strong><br />
        <span width="80%" class="title1" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b> DOOR No: 1/2,1/3  KOMBAI THOTTAM MAIN ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>SELLANDIAMMAN THURAI ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>TIRUPPUR-641604 TAMILNADU STATE INDIA,</span><br/>
       <span width="80%" class="title00" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Contact Office: 0421-4355333,+91 83442-33555,+91 83442-33888,</span><br/>
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Email Id : sriammandigitalprints@gmail.com/yahoo.com.</span><br/>
    
    <span width="80%" class="title1" style="font-size:18px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Customer Details</span></p></td>
  </tr>
         <tr>
           <td width="136" height="36"  align="left" class="class_px">&nbsp;Customer Name</td>
           <td width="257" align="left" class="class_px"><span style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;"><?php echo $cust_name; ?></span></td>
           
           <td width="455" align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;">&nbsp;</td>
         </tr>
         <tr>
           <td height="32"  align="left" ><span class="class_px">&nbsp;Address</span></td>
           <td width="257" align="left" class="class_px"><span style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;"><?php echo $cust_address; ?></span></td>
           
           <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;">&nbsp;</td>
        </tr>
         <tr>
           <td height="36"  align="left" class="class_px">Quantity</td>
           <td width="257" align="left" class="class_px"><span style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;"><?php echo number_format($job_qty,2) ?></span></td>
           
           <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;">&nbsp;</td>
        </tr>
  </table>
<div style="border-top: 1px dashed #000000; font-family: Verdana, sans-serif; font-size: 14px; font-weight: bold; color: #000000;">Printing Report</div>
  <table width="100%" border="0" align="center"  cellpadding="0" cellspacing="0" >
    <tr>
      <td width="31" height="23"  align="center" class="class_px" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">&nbsp;S.No</td>
      <td width="31" height="23"  align="center" class="class_px"  style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">&nbsp;Date</td>
      <td width="97" align="left" class="class_px" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">&nbsp;Shift</td>
      <td width="104" align="left" class="class_px" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">&nbsp;Machine No</td>
      <td width="92" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Operator</td>
      <td width="88" align="left" class="class_px" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">Particulars</td>
      <td width="68" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">O.Qty</td>
      <td width="58" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">P.Qty</td>
      <td width="70" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Balance</td>
      </tr>
    <?php
	
	
	
	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;
}	  	  
	   function get_shift_name_process($shift_time)
{
$sql_query11="select * from shift_creation where id='$shift_time' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
  $to_time=$rsdata11->to_time;
  $shift_name=$rsdata11->shift_name;
  $from_time=$rsdata11->from_time;
 } 
 $tot_shift=array($from_time,$to_time,$shift_name);
 return $tot_shift;
}

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

function get_operator_name_process($operator_no)
{
$sql_query11="select * from operator_creation where id='$operator_no' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $operator_name=$rsdata11->operator_name;
 } 
return $operator_name;
}
	  
$job_card_no=$_GET['job_card_no'];

if($job_card_no!=""){ $job_card_no1= "job_card_no='$job_card_no'"; }else{$job_card_no1=''; }

$all_value102 = $job_card_no1;

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

if($job_card_no!='')
{
 $sql="select * from  printer_production_sublist where $get_query103 pr_id!=''  and deliv_status='0' ";
}
    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				 $s_no=$s_no+1;
				 $from=$from+1;
                 $id=$rsdata['pr_id'];
                  $shift_time=$rsdata['shift_time'];
				list($frm_time,$to_ti,$type)=get_shift_name_process($shift_time);
				 $print_date=$rsdata['production_time'];
				 $machine_no=$rsdata['machine_no'];
				 $machine_name=get_machine_name_process($machine_no);
				 $operator_no=$rsdata['operator_name'];
				 $operator_name=get_operator_name_process($operator_no);
				 $prod_size=$rsdata['prod_size'];
				
				 $prod_qty=$rsdata['prod_qty'];
				 $total_qty=$rsdata['total_qty'];
				 $balance_qty=$rsdata['balance_qty'];
				 $printed_qty=$rsdata['printed_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 height="27">
      <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $s_no;?></td>
      <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo date('d-m-Y',strtotime($print_date));?></td>
      <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $type."(".$frm_time."-".$to_ti.")";?></td>   
      <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $machine_name;?></td>
      
      <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $operator_name;?></td>
      <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $prod_size;?></td>
       <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $qty;?></td>
       <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $prod_qty;?></td>
        <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $balance_qty;?></td>
      </tr>
    <?php $tot1+=$qty;
	$tot2+=$prod_qty;
	$tot3+=$balance_qty; } ?>
        <tr>
         <td width="31" height="23"  align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="97" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="104" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="92" align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="92" align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="88" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Total</td>
         <td width="68" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;<?php echo number_format($tot1,2); ?></td>
         <td width="58" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;<?php echo number_format($tot2,2); ?></td>
                  <td width="70" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;<?php echo number_format($tot1-$tot2,2); ?></td>
       </tr>
    </table><br/>
  </a><p></p>
  <div style="border-top: 1px dashed #000000;font-family: Verdana, sans-serif; font-size: 14px; font-weight: bold; color: #000000;">Fusing Report</div>
         <table width="100%" border="0" align="center"  cellpadding="0" cellspacing="0" >
           <tr>
        <td width="31" height="23"  align="center" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Sno</td>
        <td width="31" height="23"  align="center" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Date</td>
        <td width="97" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Shift</td>
         <td width="104" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Machine No</td>
         <td width="92" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;Operator</td>
         <td width="88" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Particulars</td>
         <td width="68" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">O.Qty</td>
         <td width="58" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">P.Qty</td>
        <td width="70" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Balance</td>
           </tr>
           <?php
 function get_operator_name10($ope_name)
{
$sql="select * from operator_creation where id='$ope_name'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
 {
$operator_namess=$rsdata['operator_name'];
}
return $operator_namess;
}


function get_shift_time10($shift_id)
{
$sql="select * from shift_creation where id='$shift_id'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
{
$from_time[0]=$rsdata['from_time'];
$from_time[1]=$rsdata['to_time'];
$from_time[2]=$rsdata['shift_name'];
}
return $from_time;
}

function get_machine_no10($machine_no)
{
$sql="select * from machine_creation where id='$machine_no'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
 {
$machine_no=$rsdata['machine_no'];
}
return $machine_no;
}

$job_card_no=$_GET['job_card_no'];

if($job_card_no!=""){ $job_card_no1= "job_card_no='$job_card_no'"; }else{$job_card_no1=''; }

$all_value102 = $job_card_no1;

$all_array102 = explode(',',$all_value102);
foreach($all_array102 as $value1022)
{ 
if($value1022!='')
{
  $get_query104 .= $value1022." AND ";
}
}	  
function get_order_qty_inhouse($job_card_no,$prod_size)
{
	$sql_query="select * from fusing_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_inhouse($job_card_no,$prod_size)
{
$sql_query="select max(total_qty) as total_qty from fusing_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_inhouse($job_card_no,$prod_size,$pr_id)
{
$sql_query="select total_qty from fusing_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;
}	  	  
if($job_card_no!='')
{
  $sql="select *  from  fusing_production_sublist where $get_query104 pr_id!=''  and deliv_status='0' ";
}
    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				 $s_no=$s_no+1;
				 $from=$from+1;
                 $id=$rsdata['pr_id'];
                 $print_date=$rsdata['production_time'];
				 $shift_id=$rsdata['shift_time'];
				$shift_time=get_shift_time10($shift_id);
				$machine_id=$rsdata['machine_no'];
				$machine_no=get_machine_no10($machine_id);
				$operator_id=$rsdata['operator_name'];
				$operator_name=get_operator_name10($operator_id);
				 $prod_size=$rsdata['prod_size'];
				$prod_qty=$rsdata['prod_qty'];
				 $total_qty=$rsdata['total_qty'];
				 $balance_qty=$rsdata['balance_qty'];
				 $printed_qty=$rsdata['printed_qty'];
				 
				 $count_order_qty = get_order_qty_inhouse($job_card_no,$prod_size); 
	 $max_order_qty = get_max_order_qty_inhouse($job_card_no,$prod_size);
	 $qty=  get_order_qty1_inhouse($job_card_no,$prod_size,$pr_id);
	if($max_order_qty==$qty)
	{
		$qty=$max_order_qty;
	}
	else
	{
		$qty='';
	}

?>
           <tr height="27">
             <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $s_no;?></td>
             <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo date('d-m-Y',strtotime($print_date));?></td>    
             <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $shift_time[2]."(".$shift_time[0]."-".$shift_time[1].")";?></td>
             
             <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $machine_no;?></td>
             <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $operator_name;?></td>
             <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $prod_size;?></td>
              <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $qty;?></td>
       <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $prod_qty;?></td>
        <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $balance_qty;?></td>
  </tr>
           <?php $tot1+=$qty;
	$tot2+=$prod_qty;
	$tot3+=$balance_qty;} ?>
            <tr>
         <td width="31" height="23"  align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="97" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="104" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
 <td width="104" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="92" align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="88" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Total</td>
         <td width="68" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;<?php echo number_format($tot1,2); ?></td>
         <td width="58" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;<?php echo number_format($tot2,2); ?></td>
                  <td width="70" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;<?php echo number_format($tot1-$tot2,2); ?></td>
       </tr>
  </table>
  <br/>
  </a><p></p>
      <div style="border-top: 1px dashed #000000; font-family: Verdana, sans-serif; font-size: 14px; font-weight: bold; color: #000000;">Delivery Report</div>
         <table width="100%" border="0" align="center"  cellpadding="0" cellspacing="0" >
           <tr>
             <td width="67" height="23"  align="center" class="class_px" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">&nbsp;S.No</td>
             <td width="118" height="23"  align="left" class="class_px" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">&nbsp;Date</td>
             <td width="211" align="left" class="class_px" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">&nbsp;DC No</td>
             <td width="333" align="left" class="class_px"  style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">Particulars</td>
             <td width="185" align="right" class="class_px" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">Inward</td>
             <td width="169" align="right" class="class_px" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;">Outward</td>
           </tr>
           <?php
	   
	
	function get_cust_dc_no($jobcard_no)
{
$sql="select * from inward_main where jobcard_no='$jobcard_no' union ";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
 {
$customer_dc_no=$rsdata['customer_dc_no'];
}
return $customer_dc_no;
}

$job_card_no=$_GET['job_card_no'];

if($job_card_no!=""){ $job_card_no11 = "job_no='$job_card_no'";}else{$job_card_no11="";}

$all_value10 = $job_card_no11;
$all_array10 = explode(',',$all_value10);
foreach($all_array10 as $value11)
{ 
if($value11!='')
{
  $get_query105.=$value11." AND ";
}
}	
if($job_card_no!=""){ $job_card_no12 = "jobcard_no='$job_card_no'";}else{$job_card_no12="";}

$all_value102 = $job_card_no12;
$all_array102 = explode(',',$all_value102);
foreach($all_array102 as $value112)
{ 
if($value112!='')
{
  $get_query106.=$value112." AND ";
}
}	
if($job_card_no!='')
{
  $sql="select delivery_no as delivery_no,cust_name as cust_name,job_no as jobcard_no,delivery_no as delivery_no,date_time as date_time,qty as total_qty,particulars as inward_particular from  delivery_challan_sub where $get_query105  sub_id!='' union  select invoice_no as delivery_no,in_cust_name as cust_name,jobcard_no as jobcard_no,invoice_no as delivery_no,inward_date as date_time,inward_qty as total_qty,inward_particular as inward_particular from  inward_sub_list where $get_query106  id!='' order by inward_particular asc ";
}
$rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				 $s_no=$s_no+1;
				 $from=$from+1;
                 $id=$rsdata['sub_id'];
                 $job_card_no=$rsdata['job_no'];
				 $print_date=$rsdata['date_time'];
				  $cust_dc_no=get_cust_dc_no($jobcard_no);
				 $delivery_no=$rsdata['delivery_no'];
				 $date_time=$rsdata['date_time'];
				 $a = explode("-",$delivery_no);
				 $particulars=$rsdata['inward_particular'];
				 $job_type=$rsdata['job_type'];
				 $qty=$rsdata['qty'];
				 $bal_qty=$tot_qty1-$qty;

?>
           <tr height="27">
             <td align="center" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $s_no;?></td>
             <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo date('d-m-Y',strtotime($print_date));?></td>       
             <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $delivery_no;?></td>
             <td align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php echo $particulars;?></td>
             <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php   
				 if($a[0]=='GRN')
				 {
				 $in_qty=$rsdata['total_qty'];
				 echo number_format($in_qty,2);
				 } ?></td>
             <td align="right" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;color:#666;">&nbsp;<?php if($a[0]=='DC')
				 {
				  $out_qty=$rsdata['total_qty'];
				 echo number_format($out_qty,2);
				 } ?></td>
           </tr>
            <?php 
			$in_qtys+=$in_qty;
	        $out_qtys+=$out_qty;
	        } ?>
         <tr>
         <td width="31" height="23"  align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="92" align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="88" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="68" align="left" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Total</td>
         <td width="58" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold"><?php echo number_format($in_qtys,2); ?></td>
                  <td width="70" align="right" style="border-bottom: 1px dashed #000000;border-top: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold"><?php echo number_format($out_qtys,2); ?></td>
       </tr>
        <tr>
         <td width="31" height="23"  align="center" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="92" align="left" style="font-size: 12px;font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="88" align="left" style="font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">&nbsp;</td>
         <td width="68" align="left" style="border-bottom: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold">Balance</td>
         <td width="58" align="right" style="border-bottom: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold"><?php echo number_format(($in_qtys-$out_qtys),2); ?></td>
                  <td width="70" align="right" style="border-bottom: 1px dashed #000000;font-size: 12px;  font-family: Verdana, Arial, Helvetica, sans-serif;font-weight:bold"></td>
       </tr>
       <td height="30" colspan="16"align="right" style=" font-family:Verdana, sans-serif; font-size:12px; border-top:dashed 1px;">Printed Date : <?php echo $curdate=date('d-m-Y');?>&nbsp;&nbsp;&nbsp;&nbsp;<br>Printed Time : <?php echo $current_time=date('h:i:s A');?>&nbsp;&nbsp;<br>IP Address   : <?php echo $ip_address = $_SERVER['REMOTE_ADDR'];?>&nbsp;
    </p></td>
  </table></td>
         </table>
         </div>
</td>
</tr>
</table>