<?php
// $Id: admin.statistics.html.php,v 1.21 2003/12/23 06:09:30 eddieajau Exp $
/**
* Statistics admin HTML
* @package Mambo Open Source
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License: http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.21 $
**/

class HTML_statistics {
	function show( &$browsers, &$platforms, $tldomains, $bstats, $pstats, $dstats, $sorts, $option ) {
		$tab = mosGetParam( $_REQUEST, 'tab', 'tab1' );
		$width = 400;	// width of 100%
?>
		<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td width="100%" class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle">Browser, OS, Domain Statistics</td>
		</tr>
		</table>
	<script language="javascript" src="js/dhtml.js"></script>
	<form action="index2.php" method="post" name="adminForm">
	<table cellspacing="0" cellpadding="4" border="0" width="100%">
		<tr>
			<td width="" class="tabpadding">&nbsp; </td>
			<td id="tab1" class="offtab" onclick="dhtml.cycleTab(this.id);document.adminForm.tab.value=this.id" nowrap="nowrap">Browsers Stats</td>
			<td id="tab2" class="offtab" onclick="dhtml.cycleTab(this.id);document.adminForm.tab.value=this.id" nowrap="nowrap">OS Stats</td>
			<td id="tab3" class="offtab" onclick="dhtml.cycleTab(this.id);document.adminForm.tab.value=this.id" nowrap="nowrap">Top Level Domain Stats</td>
			<td width="90%" class="tabpadding">&nbsp;</td>
		</tr>
		</table>

	<div id="page1" class="pagetext">

	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
	<tr>
		<th align="left">&nbsp;Browser <?php echo $sorts['b_agent'];?></th>
		<th>&nbsp;</th>
		<th width="100" align="left">% <?php echo $sorts['b_hits'];?></th>
		<th width="100" align="left">#</th>
	</tr>
<?php	$c = 1;
if (is_array($browsers) && count($browsers) > 0) {
	$k = 0;
	foreach ($browsers as $b) {
		$f = $bstats->totalhits > 0 ? $b->hits / $bstats->totalhits : 0;
		$w = $width * $f;
?>
		<tr class="row<?php echo $k;?>">
			<td width="200" align="left">
				&nbsp;<?php echo $b->agent; ?>&nbsp;
			</td>
			<td align="left" width="<?php echo $width+10;?>">
				<img src="../images/graphs/Col<?php echo $c;?>M.png" width="<?php echo $w;?>" height="6" hspace="0" alt="<?php echo $b->hits;?>" />
			</td>
			<td align="left">
				<?php printf( "%.2f%%", $f * 100 );?>
			</td>
			<td align="left">
				<?php echo $b->hits;?>
			</td>
		</tr>
<?php	$c = $c % 12 + 1;
		$k = 1 - $k;
		}
	}?>
	<tr>
		<th colspan="4">&nbsp;</th>
	</tr>
	</table>

	</div>

	<div id="page2" class="pagetext">

	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
	<tr>
		<th align="left">&nbsp;Operating System <?php echo $sorts['o_agent'];?></th>
		<th>&nbsp;</th>
		<th width="100" align="left">% <?php echo $sorts['o_hits'];?></th>
		<th width="100" align="left">#</th>
	</tr>
<?php	$c = 1;
if (is_array($platforms) && count($platforms) > 0) {
	$k = 0;
	foreach ($platforms as $p) {
		$f = $pstats->totalhits > 0 ? $p->hits / $pstats->totalhits : 0;
		$w = $width * $f;
?>
		<tr class="row<?php echo $k;?>">
			<td width="200" align="left">
				&nbsp;<?php echo $p->agent; ?>&nbsp;
			</td>
			<td align="left" width="<?php echo $width+10;?>">
				<img src="../images/graphs/Col<?php echo $c;?>M.png" width="<?php echo $w;?>" height="6" hspace="0" alt="" />
			</td>
			<td align="left">
				<?php printf( "%.2f%%", $f * 100 );?>
			</td>
			<td align="left">
				<?php echo $p->hits;?>
			</td>
		</tr>
<?php	$c = $c % 12 + 1;
			$k = 1 - $k;
		}
	}?>
	<tr>
		<th colspan="4">&nbsp;</th>
	</tr>
	</table>
	</div>

	<div id="page3" class="pagetext">

	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
	<tr>
		<th align="left">&nbsp;Domain <?php echo $sorts['d_agent'];?></th>
		<th>&nbsp;</th>
		<th width="100" align="left">% <?php echo $sorts['d_hits'];?></th>
		<th width="100" align="left">#</th>
	</tr>
<?php	$c = 1;
if (is_array($tldomains) && count($tldomains) > 0) {
	$k = 0;
	foreach ($tldomains as $b) {
		$f = $dstats->totalhits > 0 ? $b->hits / $dstats->totalhits : 0;
		$w = $width * $f;
?>
		<tr class="row<?php echo $k;?>">
			<td width="200" align="left">
				&nbsp;<?php echo $b->agent; ?>&nbsp;
			</td>
			<td align="left" width="<?php echo $width+10;?>">
				<img src="../images/graphs/Col<?php echo $c;?>M.png" width="<?php echo $w;?>" height="6" hspace="0" alt="<?php echo $b->hits;?>" />
			</td>
			<td align="left">
				<?php printf( "%.2f%%", $f * 100 );?>
			</td>
			<td align="left">
				<?php echo $b->hits;?>
			</td>
		</tr>
<?php	$c = $c % 12 + 1;
		$k = 1 - $k;
		}
	}?>
	<tr>
		<th colspan="4">&nbsp;</th>
	</tr>
	</table>

	</div>

  	<input type="hidden" name="option" value="<?php echo $option;?>" />
	<input type="hidden" name="tab" value="<?php echo $tab;?>" />
	</form>

<script language="javascript" type="text/javascript">
		dhtml.cycleTab('<?php echo $tab;?>');
</script>
<?php 	}

	function pageImpressions( &$rows, $pageNav, $option, $task ) {
?>
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td width="100%" class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle">Page Impression Statistics</td>
		</tr>
	</table>
	<form action="index2.php" method="post" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
		<tr>
			<th style="text-align:right">#</th>
			<th class="title">Title</th>
			<th align="center" nowrap="nowrap">Page Impressions</th>
			  <th><div align="right">Display # <?php echo $pageNav->writeLimitBox(); ?></div></th>
			</tr>


<?php	$i = $pageNav->limitstart;
		$k = 0;
		foreach ($rows as $row) {
		?>
		<tr class="row<?php echo $k;?>">
			<td align="right">
				<?php echo ++$i; ?>
			</td>
			<td align="left">
				&nbsp;<?php echo $row->title." (".$row->created.")"; ?>&nbsp;
			</td>
			<td align="center">
				<?php echo $row->hits; ?>
			</td>
			<td>
				&nbsp;
			</td>
		</tr>
<?php		$k = 1 - $k;
		} ?>
	</td></tr>
    <tr>
      <th align="center" colspan="4"> <center><?php echo $pageNav->writePagesLinks(); ?></center></th>
    </tr>
    <tr>
      <td align="center" colspan="4"> <?php echo $pageNav->writePagesCounter(); ?></td>
    </tr>
	</table>

  	<input type="hidden" name="option" value="<?php echo $option;?>" />
  	<input type="hidden" name="task" value="<?php echo $task;?>" />
	</form>
<?php
	}

	function showSearches( &$rows, $pageNav, $option, $task ) {
		global $mainframe;
?>
	<form action="index2.php" method="post" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td width="100%" class="sectionname">
				<img src="images/mos_gel.png" width="70" height="67" align="middle">Search Engine Text :
				<span class="componentheading">logging is :
		<?php echo $mainframe->getCfg( 'enable_log_searches' ) ? '<b><font color="green">Enabled</font></b>' : '<b><font color="red">Disabled</font></b>' ?>
				</span>
			</td>
		</tr>
	</table>

	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
		<tr>
			<th style="text-align:right">#</th>
			<th class="title">Search Text</th>
			<th align="center" nowrap="nowrap">Times Requested</th>
			<th align="center" nowrap="nowrap">Results Returned</th>
			<th><div align="right">Display # <?php echo $pageNav->writeLimitBox(); ?></div></th>
		</tr>

<?php
		$k = 0;
		for ($i=0, $n = count($rows); $i < $n; $i++) {
			$row =& $rows[$i];
?>
		<tr class="row<?php echo $k;?>">
			<td align="right">
				<?php echo $i+1+$pageNav->limitstart; ?>
			</td>
			<td align="left"><?php echo $row->search_term;?></td>
			<td><?php echo $row->hits; ?></td>
			<td><?php echo $row->returns; ?></td>
			<td>
				&nbsp;
			</td>
		</tr>
<?php		$k = 1 - $k;
		} ?>
	</td></tr>
    <tr>
      <th align="center" colspan="6"> <center><?php echo $pageNav->writePagesLinks(); ?></center></th>
    </tr>
    <tr>
      <td align="center" colspan="6"> <?php echo $pageNav->writePagesCounter(); ?></td>
    </tr>
	</table>

  	<input type="hidden" name="option" value="<?php echo $option;?>" />
  	<input type="hidden" name="task" value="<?php echo $task;?>" />
	</form>
<?php
	}
}
?>
