|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/academic/demo/SmartReport/wizard/engine/layouts/ |
Upload File : |
<?php
/**
* Generated by Smart Report Maker
*All copyrights are preserved to StarSoft
*http://mysqlreports.com/
*
*/
error_reporting(E_ERROR | E_PARSE);
require_once("lib.php");
$css = $style_name . ".css" ;
//*************************create sql statement ******************* $$$
if($datasource=='sql')
{
$sql = Prepare_QSql();
}
else
{
$sql = Prepare_TSql();
}
//get number of rows
$result = query($sql);
$nRecords = mysql_num_rows($result); //$$$
if(isset($_GET["start"]))
$start = $_GET["start"];
if(isset($_GET["print"]))
$print = $_GET["print"];
else
$print = 0;
if(empty($records_per_page)) $records_per_page = 10;
if(empty($start)) $start = 0;
/* begin of export section*********** */
//Exporting section
if(isset($_GET['export']))
{
$export = $_GET['export'];
}
else
{
$export = "";
}
//export data
if($export =='csv' )
{
export_csv($sql,false,0,10);
exit;
}
elseif($export == 'csv1')
{
export_csv($sql,true,$start,$records_per_page);
exit;
}
else if($export=='xml')
{
export_xml($sql,false,0,10);
exit;
}
elseif($export == 'xml1')
{
export_xml($sql,true,$start,$records_per_page);
exit;
}
else if($export =='pdf1')
{
if(count($fields)>8)
get_pdf($sql,'a4','landscape',10,10,10,10,780,800,10,11,true,$start,$records_per_page);
else
get_pdf($sql,'a4','portrait',10,10,10,10,490,500,9,10,true,$start,$records_per_page);
exit;
}
else if($export =='pdf')
{
if(count($fields)>8)
get_pdf($sql,'a4','landscape',10,10,10,10,780,800,10,11,false,$start,$records_per_page);
else
get_pdf($sql,'a4','portrait',10,10,10,10,490,500,9,10,false,$start,$records_per_page);
exit;
}
//exporting links
$link_pdf_current = $_SERVER["PHP_SELF"]."?export=pdf1&&start=$start";
$link_csv_current = $_SERVER["PHP_SELF"]."?export=csv1&&start=$start";
$link_xml_current = $_SERVER["PHP_SELF"]."?export=xml1&&start=$start";
$link_csv_all = $_SERVER["PHP_SELF"]."?export=csv";
$link_xml_all = $_SERVER["PHP_SELF"]."?export=xml";
$link_pdf_all = $_SERVER["PHP_SELF"]."?export=pdf";
// ********************************************/
//**************************print links****************************** $$$
$link_print1 = $_SERVER["PHP_SELF"]."?print=1&&start=$start";
$link_print2 = $_SERVER["PHP_SELF"]."?print=2";
$link_print_real = $_SERVER['PHP_SELF']."?print=3&start=$start";
//*************************next and prev links ********************* $$$
$levels = count($group_by);
$link1 = query($sql) ;
$next_start = $start+$records_per_page;
if($next_start >= $nRecords) $next_start = $start;
$link_next=$_SERVER["PHP_SELF"]."?start=$next_start ";
$prev_start = $start - $records_per_page;
if($prev_start < 0) $prev_start = 0;
$link_prev=$_SERVER["PHP_SELF"]."?start=$prev_start";
$link_home = $_SERVER["PHP_SELF"];
if($print !=2)
$sql .= " limit $start,$records_per_page";
//echo $sql;
$link = query($sql);
$columns = mysql_num_fields($link);
$span = "colspan='$columns'";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $title ?></title>
<link href="
<?php
if($print!= 0)
{
echo "print.css" ;
}
else
{
echo $css;
}
?>" rel="stylesheet" type="text/css" />
</head>
<body class="MainPage">
<table border="0" width="500" align="center" cellpadding="2" cellspacing="2" class="MainTable">
<!-- ************************* Menu code **************************** !-->
<?php
if($print !=3 ) //not in real priting mode
{
?>
<tr>
<td height="27" class="menu" <?php echo($span);?> id="menu_row">
<?php
include("menu.php")
?></td>
</tr>
<?php
}
?>
<!-- *************************End Of Menu code **************************** !-->
<?php
if(!empty($header))
{
?>
<tr>
<td <?php echo $span; ?> valign="top" ><?php echo $header;?></td>
</tr>
<tr>
<td <?php echo $span;?> valign="top" class="Separator" ></td>
</tr>
<?php
}
?>
<!-- ******************** end custom header ******************** !-->
<tr>
<td <?php echo $span; ?> height="33" valign="top" class="Title"><?php echo $title; ?></td>
</tr>
<?php
if(!empty($group_by))
{
?>
<tr>
<td <?php echo $span; ?> class="Separator"> </td>
</tr>
<?php
}
$cur_grouped = array();
$saved_grouped = array();
$records = 0;
$state = true; //flag for toggling
/*Table headers *****************************/
//the table header
echo"<tr><td height='15' $span class='TableHeader'></td>
</tr>";
//the columns header
echo"<tr>";
//drawing the other fields
foreach($group_by as $g)
{
echo"<td align='center' class='ColumnHeader'><b>$g</b> </td>";
}
foreach($fields as $f)
{
if(in_array($f,$group_by))
{
continue;
}
else
{
echo"<td align='center' class='ColumnHeader'><b>$f</b> </td>";
}
}
echo "</tr>";
/* header ends here ********************************/
/**************************************************/
/*body here ****************************************/
while($row = mysql_fetch_array($link,MYSQL_ASSOC))
//$row = mysql_fetch_array($link,MYSQL_ASSOC);
{
//filling array with current grouping vals
foreach($group_by as $val)
{
$cur_grouped[$val]=$row[$val];
}
//checking the variations
if(count($saved_grouped) != 0)
{
$index = grouping_diff_index($cur_grouped,$saved_grouped);
}
else
{
if($records == 0)
{
$index = 0; //intialize the structure
}
else
{
$index = -1;//No grouping and the structure is intialized
}
}
//starting of new row
echo "<tr class='mainpage' >";
//print the starting empty columns
if($index ==-1)
{
for($i=0;$i<$levels;$i++)
{
echo "<td class='mainpage'> </td>";
}
}
else
{
for($i = 0;$i<$index;$i++)
{
echo "<td class='mainpage'> </td>";
}
}
if($index != -1)
{
//things that done only when there is variations
// if($records != 0 )echo"</table></td></tr>";
if(!empty($group_by))
{
for($i=$index;$i<$levels;$i++)
{
if($i==0&&$index ==0)
{
//main grouping
echo "<td align='center' class='TableCell' >".$row[$group_by[0]]."</td>";
}
else
{
//sub grouping
//$step_length = 3 * $i;
//$step = str_repeat(" ",$step_length);
//echo "<tr class='mainpage'>";
//$x = str_repeat("<td>  </td>", $i);
//echo $x;
echo "<td class='TableCell' align='center' >".$row[$group_by[$i]]."</td>";
//echo "<td colspan='".($columns - ($i + 1))."'></td>" ;
//echo "</tr>";
}
}
}
//columns and table head
//echo"<tr><td><table width='100%' cellspacing='0' cellpadding='10'>";
//that's all the things that done only when there is variation in grouping array
}
// things that should be done weather or not there is a variations
//adding a data row
// echo"<tr>";
// $state = !$state;
// if(count($group_by)>0)
//echo "<td colspan=".count($group_by)."> </td>";
foreach($fields as $f)
{
if(empty($row[$f]))$row[$f]="  ";
if(in_array($f,$group_by))
{
continue;
}
else
{
if($state)
echo"<td align='center' class='TableCell'>$row[$f]</td>";
else
echo"<td align='center' class='AlternateTableCell'>$row[$f]</td>";
}
$state =!$state;
}
echo"</tr>";
//updating saved array
foreach($group_by as $v)
{
$saved_grouped[$v]=$row[$v];
}
$records++;
} //ending of main while loop
// echo"</table></td></tr>";
?>
<!--*****************************-->
<!-- ******************** start custom footer ******************** !-->
<?php
if(!empty($footer))
{
echo "<tr><td $span > $footer</td></tr>";
}
?>
<!-- ******************** end custom footer ******************** !-->
<!--Footer of report******************-->
<tr>
<td <?php echo $span; ?> class="TableFooter"> </td>
</tr>
</table>
</body>
<!-- ************************* Show print Dialog **************************** !-->
<?php
//show print dialog in case of print mode $$$
if($print==3)
{
?>
<script>
window.print();
</script>
<?php
}
?>
<!-- ************************* End Of Show print Dialog ********************* !-->
</html>