<style type="text/css">
.style20 {
	font-family: Verdana;
	font-size: 12px;
}
.style5 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
}
.style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.style10{ border-top:solid 1px; border-top-color:#999;}
.style11{ border-bottom:dashed 1px; border-bottom-color:#333333;}
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.style23 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.style27 {font-size: 12px}
.style28 {
	font-size: 16px;
	font-weight: bold;
}
.text {font-family: Verdana; font-size:13px;}
.style29 {	font-family: Verdana;
	font-size: 14px;

}
.stylebottom
{
	border-right:1px solid #999;

	
	border-bottom:1px solid #999;
}	
</style>
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<div class="CSSTableGenerator">
<?php 
  include ("../../include/db.php");
 ?>
<table width="850px" align="center" height="30" border="0"  cellpadding="0" cellspacing="0">
<tr style="height:60">
<td width="137" height="106" align="right" style="font-size:12px;"><img src="../../img/logo_image.png" width="119" 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="title0" style="font-size:16px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Delivery Report Print</span></p></td>
</tr>

<tr>
  <td align="center" colspan="2" style="font-family:Verdana, sans-serif; font-size:16px; font-family:Verdana, sans-serif; ">
  <table width="850" height="40" border="0"  cellpadding="0" cellspacing="0">
  <tr>
<td height="28" colspan="2" align="left" class="style4"><strong>From Date :</strong>
  <?php if($_GET['from_date']==''){ echo $curdate=date('d-m-Y');} else { echo date("d-m-Y",strtotime($_GET['from_date']));}?>  &nbsp;&nbsp;</td>
<td align="right" class="style4"><strong>To Date :</strong>
  <?php if($_GET['to_date']==''){ echo $curdate=date('d-m-Y');} else { echo date("d-m-Y",strtotime($_GET['to_date'])); }?>  &nbsp;</td>
</tr></table></td></tr>
<tr><td  colspan="2">
<table  width="100%"  cellpadding="0" cellspacing="0" style="border-top:dashed 1px" >
<tr>
<td width="31" height="26" align="center"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"><strong>S.No</strong></td>
<td width="80" align="center"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col"><strong>&nbsp;&nbsp;Date</strong><strong>&nbsp;</strong></td>
<td align="center"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col"><strong>&nbsp;&nbsp;Job Card No</strong></td>
<td align="center"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col"><strong>&nbsp;&nbsp;Customer Name</strong></td>
<td align="center"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col"><strong>&nbsp;&nbsp;Delivery No</strong></td>
<td align="center"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col"><strong>&nbsp;&nbsp;DC No</strong></td>
<td width="125" scope="col" align="left" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" ><strong>&nbsp;&nbsp;Particulars</strong></td>
<td  align="right" scope="col" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" ><strong>&nbsp;&nbsp;Inward Qty</strong></td>
<td  align="right" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"   scope="col"><strong>&nbsp;Outward Qty</strong></td>
  </tr>
  <?php
include("../../include/db.php"); 
date_default_timezone_set('Asia/Kolkata');
function get_cust_dc_no($jobcard_no)
{
$sql="select * from inward_main where jobcard_no='$jobcard_no'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
 {
$customer_dc_no=$rsdata['customer_dc_no'];
}
return $customer_dc_no;
}

$from_date11=$_GET['from_date'];
$to_date11=$_GET['to_date'];
$job_card_no=$_GET['job_card_no'];

$current_date=date('Y-m-d');
if($from_date11!=""){ $from_date12="DATE_FORMAT(date_time,'%Y-%m-%d')>='$from_date11'"; }else{$from_date12="DATE_FORMAT(date_time,'%Y-%m-%d')='$current_date'"; }
if($to_date11!=""){ $to_date12 = "DATE_FORMAT(date_time,'%Y-%m-%d')<='$to_date11'"; }else{ $to_date12="DATE_FORMAT(date_time,'%Y-%m-%d')='$current_date'"; }
if($job_card_no!=""){ $job_card_no1 = "job_no='$job_card_no'";}else{$job_card_no1="";}

$all_value10 = $from_date12."@".$to_date12."@".$job_card_no1;
$all_array10 = explode('@',$all_value10);
foreach($all_array10 as $value11)
{ 
if($value11!='')
{
  $get_query104.=$value11." AND ";
}
}	

if($from_date11!=""){ $from_date122="DATE_FORMAT(inward_date,'%Y-%m-%d')>='$from_date11'"; }else{$from_date122="DATE_FORMAT(inward_date,'%Y-%m-%d')='$current_date'"; }
if($to_date11!=""){ $to_date122 = "DATE_FORMAT(inward_date,'%Y-%m-%d')<='$to_date11'"; }else{ $to_date122="DATE_FORMAT(inward_date,'%Y-%m-%d')='$current_date'"; }
if($job_card_no!=""){ $job_card_no1 = "jobcard_no='$job_card_no'";}else{$job_card_no1="";}

$all_value102 = $from_date122."@".$to_date122."@".$job_card_no1;
$all_array102 = explode('@',$all_value102);
foreach($all_array102 as $value112)
{ 
if($value112!='')
{
  $get_query1042.=$value112." AND ";
}
}	
 $sql="select 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_query104  sub_id!='' union  select 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_query1042  id!='' order by inward_particular asc";
    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
 				 $s_no=$s_no+1;
				  $jobcard_no=$rsdata['jobcard_no'];
				 $cust_dc_no=get_cust_dc_no($jobcard_no);
				  $cust_name=$rsdata['cust_name'];
				 $delivery_no=$rsdata['delivery_no'];
				 $date_time=$rsdata['date_time'];
				 $a = explode("-",$delivery_no);
				
				 $inward_particular=$rsdata['inward_particular'];
 ?>
    <tr>
    <td width="31"  align="center" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo $s_no; ?></td>
    <td width="80" align="center" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo date("d-m-Y",strtotime($date_time));?></td>
     <td width="109" align="center" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo $jobcard_no; ?></td>
      <td width="125" align="center" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo $cust_name; ?></td>
    <td width="116" align="center" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo $delivery_no; ?></td>
      <td width="84" align="center" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo $cust_dc_no; ?></td>
     <td width="125" align="left" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo $inward_particular; ?></td>
    <td width="84" align="right" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php   
				 if($a[0]=='GRN')
				 {
				 $in_qty=$rsdata['total_qty'];
				 echo number_format($in_qty,2);
				 } ?></td>
    <td width="94" align="right" style=" font-family:Verdana, sans-serif; font-size:12px;" >&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 colspan="7"  align="right" style=" font-family:Verdana, sans-serif; font-size:12px;border-top:dashed 1px; " ><strong>Total</strong></td>
     <td align="right" style=" font-family:Verdana, sans-serif; font-size:12px;border-top:dashed 1px; " >&nbsp;<?php echo number_format($in_qtys,2); ?></td>
     <td align="right" style=" font-family:Verdana, sans-serif; font-size:12px;border-top:dashed 1px; " >&nbsp;<?php echo number_format($out_qtys,2); ?></td>
   </tr>
   <tr>
     <td colspan="7"  align="right" style=" font-family:Verdana, sans-serif; font-size:12px;border-top:dashed 1px; " ><strong>Balance</strong></td>
     <td align="right" style=" font-family:Verdana, sans-serif; font-size:12px;border-top:dashed 1px; " >&nbsp;<?php echo number_format($in_qtys-$out_qtys,2); ?></td>
     <td align="right" style=" font-family:Verdana, sans-serif; font-size:12px;border-top:dashed 1px; " >&nbsp;</td>
   </tr>
       <td height="30" colspan="15"align="right" style="border-top:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"><br>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></tr></table>