<?php 
	session_start();
	
	include('../pertial_page/pertial_function.php');
 
	function getHeaderReport($header, $business, $address, $count, $class)
	{
		$display = "";
	
		$display .= "<div  class='pageBreakHide' id='pageBreakTag$count' ></div>";
		$display .= "<div class='$class' id='page$count' align='left'> ";
		$display .= "\n<table style='width:100%; height:11in; font-family: Arial; font-size:12px;' >";
		
		$display .= "<tr>
				<td style='width:.5in'>
				
				</td>
				<td style='height:1in;border-bottom:1px solid #000;' align='center' valign='bottom' >
					<div style='font-family: Baker-Signet-B-T; font-size:20px;'>
						$business
					</div>
					<div style='width:4.5in;font-family: Baker-Signet-B-T; font-size:15px;'  >
						$address
					</div>
	 
				</td>
				<td style='width:.5in'> 
				</td>
			</tr>
			
			
			<tr>
			<td>&nbsp;</td>
			<td style='height:8.8in;' valign='top' >
						
			<table style='width:100%;font-family: Arial; font-size:12px;' >";
			$display .= "<thead style='border:1px solid #000;' >";
			
			
			$header = explode("|", $header);
			
	  
			for($i = 0; $i < count($header); $i++)
			{
 				$display .= "<th>".$header[$i]."</th>"; 
			}
            		
            $display .= "</thead>";
		
		return $display;
	}
	
	function getFooterReport($count, $number )
	{
			$display = "</table>
			</td>
			<td>&nbsp;</td>
			</tr>
	 
			<tr>
				<td>&nbsp;</td>
				<td style='height:1in;' align='center'>
					$count of $number  
					<!--
					<div style='font-size:10px;' align='right'>  
						<img  src='../upload_image/business_logo.jpg' style='width:2.4cm; height=1.2cm; opacity: 0.50; ' /> 				                               <div style='font-size:7px;' align='right' >
							Ensuring Power Since 1982
						</div>
					</div>
					-->
				</td>
				<td>&nbsp;</td>
			</tr>
		
 
    	</table></div>"; 
		
		return $display;
	}
	

 
	include('../config/database_connection.php');
 							  
	$connecttion = getSQlConection();
	$result  = mssql_query(getActualData($_REQUEST['query']));
	closeSQLConnection($connecttion);
	
	
	$header = "SL|"; 
	for($i = 0; $i < $_REQUEST['count']; $i++)
	{
		$fields = mssql_fetch_field($result);
		if($i != 0)
			$header .= 	$fields->name."|"; 
	}
            		
	
	$display = getHeaderReport($header, 'CROSS WORLD', 'CROSS WORLD GROUP House 06, Road 92, Gulshan, Dhaka 1212, Bangladesh Tel: (8802) 8811858, 8816528, 9891442 Fax: (8802) 8816205 E-mail: info@cross-world.com', 0, 'show');
 
 	$num = mssql_num_rows($result);
	
 
	
	$num = (int)($num / 40) + 1;
	
	$k = 1;
	$l = 0;
				
	for($j = 1; $row = mssql_fetch_array($result); $j++)
	{
		$display .= 	"<tr style=''><td>$k</td>"; 
		for($i = 1; $i < $_REQUEST['count']; $i++)
		{
			if(strlen($row[$i]) > 20)
			
				$display .= "<td>".substr($row[$i], 0 , 20). "</td>";
			else	
				$display .= 	"<td>$row[$i]</td>"; 	
		}
		$display .= "</tr>";
		
		if($j == 40)
		{

			$j = 0;
			$l++; 
			$display .= getFooterReport($l, $num);
		
			$display .= getHeaderReport($header, '', '', $l, 'hide');
		}
		$k++;
	}
    
	$l++; 
	$display .= getFooterReport($l, $num);


 
	$display .= "<input type='hidden' value='page0' id='current_page' />";
	$display .= "<input type='hidden' value='$l' id='page_counter' />";
	
	
	echo $display;
	
 
 
 
?>
 



 
 
 

 