'',
'hlabel'=>'',
'type'=>'',
'cellpadding'=>'',
'cellspacing'=>'',
'border'=>'',
'width'=>'',
'background'=>'',
'vfcolor'=>'',
'hfcolor'=>'',
'vbgcolor'=>'',
'hbgcolor'=>'',
'vfstyle'=>'',
'hfstyle'=>'',
'noshowvals'=>'',
'scale'=>'',
'namebgcolor'=>'',
'valuebgcolor'=>'',
'namefcolor'=>'',
'valuefcolor'=>'',
'namefstyle'=>'',
'valuefstyle'=>'',
'doublefcolor'=>'');
return($vals);
}
////
// prints out the table header and graph labels
function start_graph($vals, $names) {
$start_graph_string = '
' . $vals['hlabel'] . '' . "\n" .
' ' . "\n" .
' ' . "\n" .
' ' . $vals['vlabel'] . ' | ' . "\n" .
'
' . "\n";
}
return $start_graph_string;
}
////
// prints out the table footer
function end_graph() {
return '
' . "\n";
}
////
// sets the default values for the $vals array
function hv_graph_defaults($vals) {
if (!$vals['vfcolor']) $vals['vfcolor'] = '#000000';
if (!$vals['hfcolor']) $vals['hfcolor'] = '#000000';
if (!$vals['vbgcolor']) $vals['vbgcolor'] = '#FFFFFF';
if (!$vals['hbgcolor']) $vals['hbgcolor'] = '#FFFFFF';
if (!$vals['cellpadding']) $vals['cellpadding'] = '0';
if (!$vals['cellspacing']) $vals['cellspacing'] = '0';
if (!$vals['border']) $vals['border'] = '0';
if (!$vals['scale']) $vals['scale'] = '1';
if (!$vals['namebgcolor']) $vals['namebgcolor'] = '#FFFFFF';
if (!$vals['valuebgcolor']) $vals['valuebgcolor'] = '#FFFFFF';
if (!$vals['namefcolor']) $vals['namefcolor'] = '#000000';
if (!$vals['valuefcolor']) $vals['valuefcolor'] = '#000000';
if (!$vals['doublefcolor']) $vals['doublefcolor'] = '#886666';
return $vals;
}
////
// prints out the actual data for the horizontal chart
function horizontal_graph($names, $values, $bars, $vals) {
$horizontal_graph_string = '';
for($i = 0, $n = sizeof($values); $i < $n; $i++) {
$horizontal_graph_string .= ' ' . "\n" .
' ' . $names[$i] . ' | ' . "\n" .
' ' . "\n" .
' |
' . "\n" .
' | ' . "\n" .
'
' . "\n" .
'';
} else {
$horizontal_graph_string .= '';
}
if (!$vals['noshowvals']) {
$horizontal_graph_string .= '(' . $values[$i] . ')';
}
$horizontal_graph_string .= '' . "\n" .
' ' . "\n";
} // endfor
return $horizontal_graph_string;
}
////
// prints out the actual data for the vertical chart
function vertical_graph($names, $values, $bars, $vals) {
$vertical_graph_string = ' ' . "\n";
for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
$vertical_graph_string .= ' (' . $values[$i] . ') ';
}
$vertical_graph_string .= ' | ' . "\n";
} // endfor
$vertical_graph_string .= '
' . "\n" .
' ' . "\n";
for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
$vertical_graph_string .= ' ' . $names[$i] . ' | ' . "\n";
} // endfor
$vertical_graph_string .= '
' . "\n";
return $vertical_graph_string;
}
////
// prints out the actual data for the double horizontal chart
function double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars) {
$double_horizontal_graph_string = '';
for($i = 0, $n = sizeof($values); $i < $n; $i++) {
$double_horizontal_graph_string .= ' ' . "\n" .
' ' . $names[$i] . ' | ' . "\n" .
' ' . "\n" .
' |
' . "\n" .
' ';
} else {
$double_horizontal_graph_string .= ' background="' . $dbars[$i] . '">';
}
$double_horizontal_graph_string .= '';
// decide if the value in bar is a color code or image.
if (ereg('^#', $bars[$i])) {
$double_horizontal_graph_string .= '' . "\n" .
' ' . "\n" .
' | ' . "\n" .
' ' . "\n" .
' ';
} else {
$double_horizontal_graph_string .= '';
}
if (!$vals['noshowvals']) {
$double_horizontal_graph_string .= '(' . $values[$i] . ')';
}
$double_horizontal_graph_string .= ' | ' . "\n" .
'
' . "\n" .
' ';
if (!$vals['noshowvals']) {
$double_horizontal_graph_string .= '(' . $dvalues[$i] . ')';
}
$double_horizontal_graph_string .= '' . "\n" .
' ' . "\n";
} // endfor
return $double_horizontal_graph_string;
}
////
// prints out the actual data for the double vertical chart
function double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars) {
$double_vertical_graph_string = ' ' . "\n";
for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
$double_vertical_graph_string .= ' ' . "\n" .
' | (' . $values[$i] . ') ';
}
$double_vertical_graph_string .= ' | ' . "\n" .
' (' . $dvalues[$i] . ') ';
}
$double_vertical_graph_string .= ' | ' . "\n" .
'
' . "\n" .
' ' . "\n";
} // endfor
$double_vertical_graph_string .= ' ' . "\n" .
' ' . "\n";
for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
$double_vertical_graph_string .= ' ' . $names[$i] . ' | ' . "\n";
} // endfor
$double_vertical_graph_string .= '
' . "\n";
return $double_vertical_graph_string;
}
////
// draws a double vertical bar graph for the banner views vs clicks statistics
function tep_banner_graph_infoBox($banner_id, $days) {
$names = array();
$values = array();
$dvalues = array();
$banner_stats_query = tep_db_query("select dayofmonth(banners_history_date) as name, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and to_days(now()) - to_days(banners_history_date) < " . $days . " order by banners_history_date");
while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
$names[] = $banner_stats['name'];
$values[] = $banner_stats['value'];
$dvalues[] = $banner_stats['dvalue'];
}
$largest = @max($values);
$bars = array();
$dbars = array();
for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
$bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
$dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
}
$graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
'hlabel'=>TEXT_BANNERS_LAST_3_DAYS,
'type'=>'3',
'cellpadding'=>'',
'cellspacing'=>'1',
'border'=>'',
'width'=>'',
'vfcolor'=>'#ffffff',
'hfcolor'=>'#ffffff',
'vbgcolor'=>'#81a2b6',
'hbgcolor'=>'#81a2b6',
'vfstyle'=>'Verdana, Arial, Helvetica',
'hfstyle'=>'Verdana, Arial, Helvetica',
'scale'=>100/$largest,
'namebgcolor'=>'#f3f5fe',
'valuebgcolor'=>'#f3f5fe',
'namefcolor'=>'',
'valuefcolor'=>'#0000d0',
'namefstyle'=>'Verdana, Arial, Helvetica',
'valuefstyle'=>'',
'doublefcolor'=>'#ff7339');
return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
}
////
// draws a double vertical bar graph for the banner views vs clicks statistics
function tep_banner_graph_yearly($banner_id) {
global $banner, $HTTP_GET_VARS;
$banner_stats_query = tep_db_query("select year(banners_history_date) as year, sum(banners_shown) as value, sum(banners_clicked) as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' group by year(banners_history_date)");
while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
$names[] = $banner_stats['year'];
$values[] = (($banner_stats['value']) ? $banner_stats['value'] : '0');
$dvalues[] = (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0');
}
$largest = @max($values);
$bars = array();
$dbars = array();
for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
$bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
$dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
}
$graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
'hlabel'=>sprintf(TEXT_BANNERS_YEARLY_STATISTICS, $banner['banners_title']),
'type'=>'3',
'cellpadding'=>'',
'cellspacing'=>'1',
'border'=>'',
'width'=>'',
'vfcolor'=>'#ffffff',
'hfcolor'=>'#ffffff',
'vbgcolor'=>'#81a2b6',
'hbgcolor'=>'#81a2b6',
'vfstyle'=>'Verdana, Arial, Helvetica',
'hfstyle'=>'Verdana, Arial, Helvetica',
'scale'=>100/$largest,
'namebgcolor'=>'#f3f5fe',
'valuebgcolor'=>'#f3f5fe',
'namefcolor'=>'',
'valuefcolor'=>'#0000d0',
'namefstyle'=>'Verdana, Arial, Helvetica',
'valuefstyle'=>'',
'doublefcolor'=>'#ff7339');
return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
}
////
// draws a double vertical bar graph for the banner views vs clicks statistics
function tep_banner_graph_monthly($banner_id) {
global $banner, $HTTP_GET_VARS;
$year = (($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y'));
for ($i=1; $i<13; $i++) {
$names[] = strftime('%b', mktime(0,0,0,$i));
$values[] = '0';
$dvalues[] = '0';
}
$banner_stats_query = tep_db_query("select month(banners_history_date) as banner_month, sum(banners_shown) as value, sum(banners_clicked) as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and year(banners_history_date) = '" . $year . "' group by month(banners_history_date)");
while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
$names[($banner_stats['banner_month']-1)] = strftime('%b', mktime(0,0,0,$banner_stats['banner_month']));
$values[($banner_stats['banner_month']-1)] = (($banner_stats['value']) ? $banner_stats['value'] : '0');
$dvalues[($banner_stats['banner_month']-1)] = (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0');
}
$largest = @max($values);
$bars = array();
$dbars = array();
for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
$bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
$dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
}
$graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
'hlabel'=>sprintf(TEXT_BANNERS_MONTHLY_STATISTICS, $banner['banners_title'], date('Y')),
'type'=>'3',
'cellpadding'=>'',
'cellspacing'=>'1',
'border'=>'',
'width'=>'',
'vfcolor'=>'#ffffff',
'hfcolor'=>'#ffffff',
'vbgcolor'=>'#81a2b6',
'hbgcolor'=>'#81a2b6',
'vfstyle'=>'Verdana, Arial, Helvetica',
'hfstyle'=>'Verdana, Arial, Helvetica',
'scale'=>100/$largest,
'namebgcolor'=>'#f3f5fe',
'valuebgcolor'=>'#f3f5fe',
'namefcolor'=>'',
'valuefcolor'=>'#0000d0',
'namefstyle'=>'Verdana, Arial, Helvetica',
'valuefstyle'=>'',
'doublefcolor'=>'#ff7339');
return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
}
////
// draws a double vertical bar graph for the banner views vs clicks statistics
function tep_banner_graph_daily($banner_id) {
global $banner, $HTTP_GET_VARS;
$year = (isset($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y'));
$month = (isset($HTTP_GET_VARS['month']) ? $HTTP_GET_VARS['month'] : date('n'));
$days = (date('t', mktime(0,0,0,$month))+1);
$stats = array();
for ($i=1; $i<$days; $i++) {
$names[] = $i;
$values[] = '0';
$dvalues[] = '0';
}
$banner_stats_query = tep_db_query("select dayofmonth(banners_history_date) as banner_day, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and month(banners_history_date) = '" . $month . "' and year(banners_history_date) = '" . $year . "'");
while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
$names[($banner_stats['banner_day']-1)] = $banner_stats['banner_day'];
$values[($banner_stats['banner_day']-1)] = (($banner_stats['value']) ? $banner_stats['value'] : '0');
$dvalues[($banner_stats['banner_day']-1)] = (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0');
}
$largest = @max($values);
$bars = array();
$dbars = array();
for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
$bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
$dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
}
$graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
'hlabel'=>sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0,0,0,$month)), $year),
'type'=>'3',
'cellpadding'=>'',
'cellspacing'=>'1',
'border'=>'',
'width'=>'',
'vfcolor'=>'#ffffff',
'hfcolor'=>'#ffffff',
'vbgcolor'=>'#81a2b6',
'hbgcolor'=>'#81a2b6',
'vfstyle'=>'Verdana, Arial, Helvetica',
'hfstyle'=>'Verdana, Arial, Helvetica',
'scale'=>100/$largest,
'namebgcolor'=>'#f3f5fe',
'valuebgcolor'=>'#f3f5fe',
'namefcolor'=>'',
'valuefcolor'=>'#0000d0',
'namefstyle'=>'Verdana, Arial, Helvetica',
'valuefstyle'=>'',
'doublefcolor'=>'#ff7339');
return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
}
?>