<style type="text/css">.style4 {font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.text {font-family: Verdana; font-size:13px;}
.stylebottom
{
	border-right:1px solid #999;

	
	border-bottom:1px solid #999;
}	
</style>
<?php 
  include ("../../include/db.php");
error_reporting(0);
ob_start();
session_start();
$session_branch=$_SESSION['branch'];
$session_user_type=$_SESSION['user_type'];
  $branch_name=$_GET['branch_name'];
$fabric_types=$_GET['fabric_types'];
function get_categ_branch_id($branch_name)
{
$sql_query11="select * from branch_creation where branch_id='$branch_name' and delete_status!='1'";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $id=$rsdata11->branch_name;
 } 
	return $id;
 }
 $bran_name=get_categ_branch_id($branch_name);
if($session_user_type!=1)
{
$query="select * from branch_creation  WHERE branch_id='$session_branch'";
}
$rs=mysql_query($query);						 
                                                $i=0;
                                                while($list=mysql_fetch_array($rs))
                                                {
                                                $i=$i+1;
												$branch_address=$list['branch_address'];
												$head_off=$list['head_off'];
												$branch_off=$list['branch_off'];
												$branch_ph=$list['branch_ph'];
												$delivery_ph=$list['delivery_ph'];
												$delivery_off=$list['delivery_off'];
											    }
											 ?>
<table width="980" height="30" border="0"  cellpadding="0" cellspacing="0" align="center">
<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/>
       <br/>

  <span width="80%" class="title1" style="font-size:18px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Jobcard Creation Print</span></p></td>
</tr>
</table>
<table width="980" height="40" border="0"  cellpadding="0" cellspacing="0" align="center">
<tr>
<td height="28" colspan="2" align="left" class="style4"><strong>Customer Name :</strong> 
  <?php if($_GET['customer_name']==''){ echo "All";} else { echo ucfirst($_GET['customer_name']);}?>&nbsp;&nbsp;</td>
<td colspan="2" align="center" 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']));}?></td>
<td colspan="2" align="right" scope="col" 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'])); }?></td>
<td width="27%" colspan="2" align="right" class="style4" scope="col"><strong>Jobtype :</strong> 
  <?php if($_GET['paid_status']!=''){  echo ucfirst($_GET['paid_status']);} else { echo "All"; }?>&nbsp;</td></tr></table>
<table  width="980"  cellpadding="0" cellspacing="0" style="border-top:dashed 1px" align="center">
      <tr>
      <td width="42" height="26" align="center"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"><strong>S.No</strong></td>
      <td width="97" align="left"  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 width="114" align="left"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col"><strong>&nbsp;&nbsp;Jobcard No</strong></td>
      <td width="96" scope="col" align="left" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" ><strong>&nbsp;&nbsp;Created By</strong></td>
      <td width="243"  align="left" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col" ><strong>&nbsp;&nbsp;Customer Name</strong></td>
      <td width="110"  align="left" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"   scope="col"><strong>&nbsp;Job Type</strong></td>
      <td width="165" align="left" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"    scope="col">&nbsp;&nbsp;<strong>Fabric Type&nbsp;</strong></td>
      <td width="165" align="right" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"    scope="col">&nbsp;&nbsp;<strong>Total Qty&nbsp;</strong></td>
      <td  align="right" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"  scope="col"><strong>Total Value </strong>&nbsp;</td>
  </tr>
  <?php
  include ("../../include/db.php");

function book_place_names1($book_place)
  {
	$sql_user="select * from place_creation where id='$book_place'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$location=$rsdata_user->location;
	}
	return $location;
  }

  function place_branch_name($book_branch)
  {
	$sql_user="select * from branch_creation where branch_id='$book_branch' and delete_status!='1' ";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$branch_name=$rsdata_user->branch_name;
	}
	return $branch_name;
  }
   function get_tot_qty_jobcard($jobcard_no)
  {
  $sql_user="select sum(qty) as qty from jobcard_sublist where jobcard_no='$jobcard_no'";
  $rs_user=mysql_query($sql_user);
  while($rsdata_user=mysql_fetch_object($rs_user))
  { 
  $qty12=$rsdata_user->qty;
  }
  return $qty12;
  }
 
  function gets_book_count1($booking_no)
  {
	  $sql_user="select * from booking_sub_list where book_no='$booking_no'";
	  $rs_user=mysql_query($sql_user);
	  $rs_count=mysql_num_rows($rs_user);
	  return $rs_count;
  } 
  
$cust_name=$_GET['customer_name'];
$from_date=$_GET['from_date'];
$to_date=$_GET['to_date'];
$status=$_GET['jobtype'];
$current_date=date('Y-m-d');
$job_card_num=$_GET['job_card_num'];
$fabric_types=$_GET['fabric_types'];
$value=explode(',',$_GET['fabric_types']);
 
                   for($i=0;$i<count($value);$i++){                  
                    $fabric1.=$value[$i];                 
				    
				   if($i<(count($value)-1)) {
                   $fabric1.="','";
                  
                   }
				   }

if($cust_name!=""){ $customer_name1= "cust_name='$cust_name'"; }else{$customer_name1=''; }
if($from_date!=""){ $from_date1= "DATE_FORMAT( entry_date,'%Y-%m-%d' )>='$from_date'"; }else{$from_date1="DATE_FORMAT(entry_date,'%Y-%m-%d' )='$cur_dates'"; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(entry_date,'%Y-%m-%d' )<='$to_date'";}else{$to_date1="DATE_FORMAT(entry_date,'%Y-%m-%d' )='$cur_dates'";}
if($status!=""){ $jobtype1 = "job_type='$status'";}else{$jobtype1='';}
if($job_card_num!=""){ $job_card_nums = "jobcard_no='$job_card_num'";}else{$job_card_nums='';}
if($fabric_types!=""){ $fabric_type1 = "fabric_type IN ('$fabric1')";}else{$fabric_type1='';}

$all_value10 = $customer_name1.";".$from_date1.";".$to_date1.";".$jobtype1.";".$job_card_nums.";".$fabric_type1;
$all_array10 = explode(';',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
$get_query103 .= $value10." AND ";
}
}	  
if(($from_date=='')&&($to_date==''))
  {
   $sql="select * from  jobcard_main where  DATE_FORMAT( entry_date,  '%Y-%m-%d' )='$current_date'  order by jobcard_no ASC";
  } 
  else
  {
   $sql="select * from  jobcard_main where $get_query103 	main_id!='' order by jobcard_no ASC ";
  }
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				$sno=$sno+1;
				$from=$from+1;
   				$main_id=$rsdata['main_id'];
   				$jobcard_no=$rsdata['jobcard_no'];
				$created_by=$rsdata['created_by'];
	   			$cust_name=$rsdata['cust_name'];
	   			$entry_date=$rsdata['entry_date'];
				$job_type=$rsdata['job_type'];
	   			$fabric_type=$rsdata['fabric_type'];
	   			$overall_value=$rsdata['overall_value'];
	   			$net_total=$rsdata['net_total'];
          $tot_qty=get_tot_qty_jobcard($jobcard_no);
          $get_qty=mysql_fetch_array(mysql_query("select qty from   jobcard_sublist where jobcard_no='$jobcard_no'"));
          $qtys=$get_qty[qty];
  ?>
  <tr>
    <td width="42" height="26" style=" font-family:Verdana, sans-serif; font-size:12px;"   align="center" ><?php echo $from; ?></td>&nbsp;
    <td width="97" style=" font-family:Verdana, sans-serif; font-size:12px;"  align="left" >&nbsp;<?php echo date("d-m-Y",strtotime($entry_date));?></td>&nbsp;
    <td align="left" style=" font-family:Verdana, sans-serif; font-size:12px;"  >&nbsp;<?php echo $jobcard_no;?></td>&nbsp;
    <td width="96" style=" font-family:Verdana, sans-serif; font-size:12px;"  align="left" >&nbsp;<?php echo $created_by;?></td>&nbsp;
    <td align="left" style=" font-family:Verdana, sans-serif; font-size:12px;"  >&nbsp;<?php echo $cust_name;?></td>&nbsp;
    <td align="left" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo $job_type;?></td>&nbsp;
    <td align="left" style=" font-family:Verdana, sans-serif; font-size:12px;"  >&nbsp;<?php echo $fabric_type;?></td>&nbsp;
    <td align="right" style=" font-family:Verdana, sans-serif; font-size:12px;"  >&nbsp;<?php echo $tot_qty;?></td>&nbsp;
    <td align="right" style=" font-family:Verdana, sans-serif; font-size:12px;"  ><?php echo number_format($net_total,2);?></td>&nbsp;&nbsp;
   </tr>&nbsp;
  <?php 
  $net_tot+=$net_total;
  $net_qty+=$tot_qty;

  } ?>
<tr style="border-bottom:dashed 1px">
    <td height="27" colspan="7" align="right" style="border-bottom:dashed 1px; border-top:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"  scope="col"><strong>Total :</strong></td>
    <td width="111"  align="right" style="border-bottom:dashed 1px; border-top:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col"> <?php echo  number_format(round($net_qty)); ?></td>
    <td width="111"  align="right" style="border-bottom:dashed 1px; border-top:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col"> <?php echo  number_format(round($net_tot),2); ?></td>
</tr>
<td height="30" colspan="15"align="right" style=" font-family:Verdana, sans-serif; font-size:12px;">Printed Date : <?php echo $curdate=date('d-m-Y');?>&nbsp;</p></td>
</table>