[*] BO #PSFV-94 : Added AdminStatsController && AdminStatsTabController && norm of statistic modules

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10004 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2011-11-09 15:48:15 +00:00
parent 42bfc372da
commit dc716baa05
28 changed files with 980 additions and 891 deletions
+34 -26
View File
@@ -30,23 +30,25 @@ if (!defined('_PS_VERSION_'))
class StatsLive extends Module
{
function __construct()
{
$this->name = 'statslive';
$this->tab = 'analytics_stats';
$this->version = 1.0;
private $html = '';
public function __construct()
{
$this->name = 'statslive';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
parent::__construct();
$this->displayName = $this->l('Visitors online');
$this->description = $this->l('Display the list of customers and visitors currently online.');
}
$this->displayName = $this->l('Visitors online');
$this->description = $this->l('Display the list of customers and visitors currently online.');
}
public function install()
{
return (parent::install() AND $this->registerHook('AdminStatsModules'));
return parent::install() && $this->registerHook('AdminStatsModules');
}
/**
@@ -115,56 +117,62 @@ class StatsLive extends Module
list($visitors, $totalVisitors) = $this->getVisitorsOnline();
$irow = 0;
echo '<script type="text/javascript" language="javascript">
$this->html .= '<script type="text/javascript" language="javascript">
$("#calendar").next().remove();
$("#calendar").remove();
</script>';
if (!Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
echo '<div class="warn width3">'.$this->l('You must activate the option "pages views for each customer" in the "Stats datamining" module in order to see the pages currently viewed by your customers.').'</div>';
echo '
<fieldset class="width3"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Customers online').'</legend>';
$this->html .= '<div class="warn">'.
$this->l('You must activate the option "pages views for each customer" in the "Stats datamining" module in order to see the pages currently viewed by your customers.').'
</div>';
$this->html .= '
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Customers online').'</legend>';
if ($totalCustomers)
{
echo $this->l('Total:').' '.(int)($totalCustomers).'
$this->html .= $this->l('Total:').' '.(int)$totalCustomers.'
<table cellpadding="0" cellspacing="0" class="table space">
<tr><th>'.$this->l('ID').'</th><th>'.$this->l('Name').'</th><th>'.$this->l('Current Page').'</th><th>'.$this->l('View').'</th></tr>';
foreach ($customers as $customer)
echo '
$this->html .= '
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
<td>'.$customer['id_customer'].'</td>
<td style="width: 200px;">'.$customer['firstname'].' '.$customer['lastname'].'</td>
<td style="width: 200px;">'.$customer['page'].'</td>
<td style="text-align: right; width: 25px;">
<a href="index.php?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id).'" target="_blank">
<a href="index.php?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)Tab::getIdFromClassName('AdminCustomers').(int)$this->context->employee->id).'"
target="_blank">
<img src="../modules/'.$this->name.'/logo.gif" />
</a>
</td>
</tr>';
echo '</table>';
$this->html .= '</table>';
}
else
echo $this->l('There are no customers online.');
echo '</fieldset>
<fieldset class="width3 space"><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Visitors online').'</legend>';
$this->html .= $this->l('There are no customers online.');
$this->html .= '</fieldset>
<br />
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" /> '.$this->l('Visitors online').'</legend>';
if ($totalVisitors)
{
echo $this->l('Total:').' '.(int)($totalVisitors).'
$this->html .= $this->l('Total:').' '.(int)($totalVisitors).'
<div style="overflow-y: scroll; height: 600px;">
<table cellpadding="0" cellspacing="0" class="table space">
<tr><th>'.$this->l('Guest').'</th><th>'.$this->l('IP').'</th><th>'.$this->l('Since').'</th><th>'.$this->l('Current page').'</th><th>'.$this->l('Referrer').'</th></tr>';
foreach ($visitors as $visitor)
echo '<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
$this->html .= '<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
<td>'.$visitor['id_guest'].'</td>
<td style="width: 80px;">'.long2ip($visitor['ip_address']).'</td>
<td style="width: 100px;">'.substr($visitor['date_add'], 11).'</td>
<td style="width: 200px;">'.(isset($visitor['page']) ? $visitor['page'] : $this->l('Undefined')).'</td>
<td style="width: 200px;">'.(empty($visitor['http_referer']) ? $this->l('none') : parse_url($visitor['http_referer'], PHP_URL_HOST)).'</td>
</tr>';
echo '</table></div>';
$this->html .= '</table></div>';
}
else
echo $this->l('There are no visitors online.');
echo '</fieldset>';
$this->html .= $this->l('There are no visitors online.');
$this->html .= '</fieldset>';
return $this->html;
}
}