<?php
	$module_name = "Anagrafiche";
	include_once( $docroot."/lib/permissions_check.php" );
	
	//carica report html
	$report = file_get_contents ($docroot."/templates/prt_anagrafiche/prt_anagrafiche.html");
	$body = file_get_contents ($docroot."/templates/prt_anagrafiche/prt_anagrafiche_body.html");

	include_once( "pdfgen_variables.php" );

	$search_tipo = $html->form('search_tipo');

	$titolo = "Stampa Elenco Anagrafiche ";
		
	
	$body .= "<h3>".$titolo."</h3>\n";
	$body .= "<table class=\"table_values\" cellspacing=\"0\" border=\"0\" cellpadding=\"0\" style=\"table-layout:fixed; border-color:#aaa;\">\n";
	$body .= "<col width=\"450\"><col width=\"100\"><col width=\"150\"><col width=\"25\"><col width=\"50\"><col width=\"80\">\n";
	
	$body .= "<thead>\n";
	$body .= "	<tr>\n";
	$body .= "		<th style='padding:2mm; background:#eee;'>Ragione Sociale</th>\n";
	$body .= "		<th style='padding:2mm; background:#eee;'>Tipologia</th>\n";
	$body .= "		<th style='padding:2mm; background:#eee;'>Città</th>\n";
	$body .= "		<th style='padding:2mm; background:#eee;'>Pv</th>\n";
	$body .= "		<th style='padding:2mm; background:#eee;'>CAP</th>\n";
	$body .= "		<th style='padding:2mm; background:#eee;'>Telefono</th>\n";
	$body .= "	</tr>\n";
	$body .= "</thead>\n";
	
	
	$body .= "<tbody>\n";
	
	$query=$_SESSION['query_controller'] ;
	
	$rs = $dbo->fetchArray($query);
	
	for( $i=0; $i<sizeof($rs); $i++ ){
		$rs_det = $dbo->fetchArray("select provincia,cap from an_anagrafiche where idanagrafica='".$rs[$i]['id']."'");
		
		$body .= "	<tr>";
		$body .= "		<td>".$rs[$i]['Ragione sociale']."</td>\n";
		$body .= "		<td>".$rs[$i]['Tipologia']."</td>\n";
		$body .= "		<td>".$rs[$i]['Città']."</td>\n";
		$body .= "		<td>".$rs_det[0]['provincia']."</td>\n";
		$body .= "		<td>".$rs_det[0]['cap']."</td>\n";
		$body .= "		<td>".$rs[$i]['Telefono']."</td>\n";
		$body .= "	</tr>\n";

	}
	
	
	
	$body .= "</tbody>\n";
	$body .= "</table>\n";
	
	
	
	$orientation = "L";
	$report_name = "prt_anagrafiche.pdf";
?>
