<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");
error_reporting(0);
ob_start();
session_start();
$session_branch=$_SESSION['branch'];
$session_user_type=$_SESSION['user_type'];
  $branch_name=$_GET['branch_name'];

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="99%" height="118" border="0"  cellpadding="0" cellspacing="0">
<tr>
  <td colspan="9"  align="center" style="font-size:18px; padding-center:5px; font-family:Verdana" ><span class="style28">RAJA TRANSPORT LORRY BOOKING SERVICE</span></td>
</tr>
<tr>
  <td colspan="9"  align="center" style="font-size:13px; padding-center:5px; font-family:Verdana" ><span class="style20">(GOODS CONSIGNMENT RECEIPT)</span></td>
</tr>
    <?php if($session_user_type!=1)
{
?>
<tr>
  <td colspan="9"  align="center" style="font-size:13px; padding-center:5px; font-family:Verdana" ><?php echo $branch_address; ?></td>
</tr>
<tr><td colspan="9"  align="center" class="style20" style=" padding-center:5px; font-family:Verdana" ><span class="style29"><span class="style20 style55">H.O.Ph : <?php echo $head_off; ?> B. Off : Cell : <?php echo $branch_off; ?> ,Ph : <?php echo $branch_ph; ?> <br/>
Delivery Off Ph : <?php echo $delivery_ph; ?> , Cell : <?php echo $delivery_off; ?>.</span></span></td>
</tr>
 <?php } ?>
<tr><td colspan="9"  align="center" class="style20" style=" padding-center:5px; font-family:Verdana" ></td></tr>
<tr><td colspan="8"  align="center" class="style20" style=" padding-center:5px; font-family:Verdana" ></td></tr>
<tr><td height="33" colspan="8" align="center" class="style5 style23">Booking Entry Print</td>
</tr>
<tr>
<td height="28" colspan="2" align="center" class="style4"><strong>Branch Name :</strong> 
  <?php if($_GET['branch_name']==''){ echo "All";} else { echo ucfirst($bran_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>Status :</strong> 
  <?php if($_GET['paid_status']!=''){  echo ucfirst($_GET['paid_status']);} else { echo "All"; }?>&nbsp;</td>
</tr></table>

<table border="0" width="100%"  cellpadding="0" cellspacing="0"  >
      <tr>
      <td height="26" align="center" class="stylebottom style11 style10 style3" style="border-left:1px solid #999;" ><strong>S.No</strong></td>
      <td width="132" align="left" class="stylebottom style11 style10 style3" scope="col"><strong>&nbsp;Date</strong><strong>&nbsp;</strong></td>
      <td scope="col" align="left" class="stylebottom style11 style10 style3"><strong>&nbsp;Booking No</strong></td>
      <td scope="col" align="left" class="stylebottom style11 style10 style3"><strong>&nbsp;Consignor M/s</strong></td>
      <td width="294" align="left" scope="col" class="stylebottom style10 style11 style3"><strong>&nbsp;Consignee M/s</strong></td>
      <td width="148" align="left" class="stylebottom style11 style10 style3"  scope="col"><strong>&nbsp;Place</strong></td>
      <td width="83" align="center" class="stylebottom style11 style10 style3"  scope="col"><strong>Pay Type&nbsp;</strong></td>
      <td width="84" align="center" class="stylebottom style11 style10 style3"  scope="col"><strong>Bale Count</strong></td>
      <td width="88" align="right" scope="col" class="stylebottom style10 style11 style3"><strong>Amount&nbsp;</strong></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 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;
  } 
  
$branch_name=$_GET['branch_name'];
$from_date=$_GET['from_date'];
$to_date=$_GET['to_date'];
$status=$_GET['paid_status'];
$get_user_type=$_GET['get_user_type'];
$current_date=date('Y-m-d');

if($branch_name!=""){ $branch_name1= "book_branch='$branch_name'"; }else{$branch_name1=''; }
if($from_date!=""){ $from_date1= "book_date>='$from_date'"; }else{$from_date1="book_date='$cur_dates'"; }
if($to_date!=""){ $to_date1 = "book_date<='$to_date'";}else{$to_date1="book_date='$cur_dates'";}
if($status!=""){ $status1 = "pay_type='$status'";}else{$status1='';}

$all_value10 = $branch_name1."@".$from_date1."@".$to_date1."@".$status1;
$all_array10 = explode('@',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
$get_query102 .= $value10." AND ";
}
}	  

if($get_user_type=='1')
{
	if(($from_date=='')&&($to_date==''))
  {
   $sql="select * from  booking_main_list where  book_date='$current_date'  order by book_date ";
  } 
  else
  {
   $sql="select * from  booking_main_list where $get_query102 id!=''  order by book_date ";
  }
}
else
{
	if(($from_date=='')&&($to_date==''))
  {
    $sql="select * from  booking_main_list where  book_date='$current_date' and book_branch='$branch_name' order by book_date ";
  } 
  else
  {
    $sql="select * from  booking_main_list where $get_query102 id!=''  order by book_date ";
  }
}

    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				$sno=$sno+1;
   				$id=$rsdata['id'];
   				$booking_no=$rsdata['booking_no'];
				$book_count=gets_book_count1($booking_no);
				$book_date=$rsdata['book_date'];
	   			$book_place=$rsdata['book_place'];
				$book_place_names=book_place_names1($book_place);
	   			$book_branch=$rsdata['book_branch'];
				$book_branch_names=place_branch_name($book_branch);
				$pay_type=$rsdata['pay_type'];
	   			$from_party_name=$rsdata['from_party_name'];
	   			$from_party_address=$rsdata['from_party_address'];
				$from_party_mob=$rsdata['from_party_mob'];
	   			$to_party_name=$rsdata['to_party_name'];
	   			$to_party_addrs=$rsdata['to_party_addrs'];
				$to_party_mob=$rsdata['to_party_mob'];
	   			$unloading_st_charge=$rsdata['unloading_st_charge'];
	   			$tot_amt=$rsdata['tot_amt'];
	   			$remarks=$rsdata['reamarks'];
				$cr_date=$rsdata['cr_date'];
				$net+=$tot_amt;
  ?>
  <tr class="stylebottom">
    <td width="40" height="26"  align="center" class="style3 stylebottom" style="border-left:1px solid #999;"><?php echo $sno; ?></td>
    <td align="left" class="style3 stylebottom" >&nbsp;<?php echo date("d-m-Y",strtotime($book_date));?>&nbsp;</td>
    <td width="137" align="left" class="style3 stylebottom" >&nbsp;<?php echo $booking_no;?></td>
    <td width="250" align="left" class="style3 stylebottom" >&nbsp;<?php echo ucfirst($from_party_name);?></td>
    <td align="left" class="style3 stylebottom" >&nbsp;<?php echo ucfirst($to_party_name);?></td>
    <td align="left" class="style3 stylebottom" >&nbsp;<?php echo $book_place_names;?></td>
    <td align="center" class="style3 stylebottom" ><?php echo $pay_type;?>&nbsp;</td>
    <td align="center" class="style3 stylebottom" ><?php echo  $book_count; ?></td>
    <td align="right" class="style3 stylebottom" ><?php echo  number_format($tot_amt,2); ?>&nbsp;</td>
   </tr>
  <?php } ?>
<tr>
    <td height="27" colspan="8" align="right"  class="style4  " scope="col" style="border-left:1px solid #999; border-bottom:1px solid #999;"><strong>Total :</strong></td>
    <td width="88"  align="right" class="style4 stylebottom " scope="col"> <?php echo  number_format(round($net),2); ?>&nbsp;</td>
</tr>
       <td height="30" colspan="15"align="right" class=" style4 " >Printed Date : <?php echo $curdate=date('d-m-Y');?>&nbsp;</p></td>
</table>
