[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/includes/functions/ -> html_graphs.php (source)

   1  <?php
   2  /*

   3  $Id: html_graphs.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax2005 osCMax, 2002 osCommerce

   9  

  10    Released under the GNU General Public License

  11  

  12    HTML_Graphs (v1.5 1998/11/05 06:15:52) by Phil Davis, http://www.pobox.com/~pdavis/

  13  */
  14  
  15  ////

  16  // calls routines to initialize defaults, set up table

  17  // print data, and close table.

  18    function html_graph($names, $values, $bars, $vals, $dvalues = 0, $dbars = 0) {
  19  // set the error level on entry and exit so as not to interfear with anyone elses error checking.

  20      $er = error_reporting(1);
  21  
  22  // set the values that the user didn't

  23      $vals = hv_graph_defaults($vals);
  24      $html_graph_string = start_graph($vals, $names);
  25  
  26      if ($vals['type'] == 0) {
  27        $html_graph_string .= horizontal_graph($names, $values, $bars, $vals);
  28      } elseif ($vals['type'] == 1) {
  29        $html_graph_string .= vertical_graph($names, $values, $bars, $vals);
  30      } elseif ($vals['type'] == 2) {
  31        $html_graph_string .= double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars);
  32      } elseif ($vals['type'] == 3) {
  33        $html_graph_string .= double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars);
  34      }
  35  
  36      $html_graph_string .= end_graph();
  37  
  38  // Set the error level back to where it was.

  39      error_reporting($er);  
  40  
  41      return $html_graph_string;
  42    }
  43  
  44  ////

  45  // sets up the $vals array by initializing all values to null. Used to avoid

  46  // warnings from error_reporting being set high. This routine only needs to be

  47  // called if you are worried about using uninitialized variables.

  48    function html_graph_init() {
  49      $vals = array('vlabel'=>'',
  50                    'hlabel'=>'',
  51                    'type'=>'',
  52                    'cellpadding'=>'',
  53                    'cellspacing'=>'',
  54                    'border'=>'',
  55                    'width'=>'',
  56                    'background'=>'',
  57                    'vfcolor'=>'',
  58                    'hfcolor'=>'',
  59                    'vbgcolor'=>'',
  60                    'hbgcolor'=>'',
  61                    'vfstyle'=>'',
  62                    'hfstyle'=>'',
  63                    'noshowvals'=>'',
  64                    'scale'=>'',
  65                    'namebgcolor'=>'',
  66                    'valuebgcolor'=>'',
  67                    'namefcolor'=>'',
  68                    'valuefcolor'=>'',
  69                    'namefstyle'=>'',
  70                    'valuefstyle'=>'',
  71                    'doublefcolor'=>'');
  72  
  73      return($vals);
  74    }
  75  
  76  ////

  77  // prints out the table header and graph labels

  78    function start_graph($vals, $names) {
  79      $start_graph_string = '<table cellpadding="' . $vals['cellpadding'] . '" cellspacing="' . $vals['cellspacing'] . '" border="' . $vals['border'] . '"';
  80  
  81      if ($vals['width'] != 0) $start_graph_string .= ' width="' . $vals['width'] . '"';
  82      if ($vals['background']) $start_graph_string .= ' background="' . $vals['background'] . '"';
  83  
  84      $start_graph_string .= '>' . "\n";
  85  
  86      if ( ($vals['vlabel']) || ($vals['hlabel']) ) {
  87        if ( ($vals['type'] == 0) || ($vals['type'] == 2) ) {
  88  // horizontal chart

  89          $rowspan = sizeof($names) + 1; 
  90          $colspan = 3; 
  91        } elseif ( ($vals['type'] == 1) || ($vals['type'] == 3) ) {
  92  // vertical chart

  93          $rowspan = 3;
  94          $colspan = sizeof($names) + 1; 
  95        }
  96  
  97        $start_graph_string .= '  <tr>' . "\n" .
  98                               '    <td align="center" valign="center"';
  99  
 100  // if a background was choosen don't print cell BGCOLOR

 101        if (!$vals['background']) $start_graph_string .= ' bgcolor="' . $vals['hbgcolor'] . '"';
 102  
 103        $start_graph_string .= ' colspan="' . $colspan . '"><font color="' . $vals['hfcolor'] . '" style="' . $vals['hfstyle'] . '"><b>' . $vals['hlabel'] . '</b></font></td>' . "\n" .
 104                               '  </tr>' . "\n" .
 105                               '  <tr>' . "\n" .
 106                               '    <td align="center" valign="center"';
 107  
 108  // if a background was choosen don't print cell BGCOLOR

 109        if (!$vals['background']) $start_graph_string .= ' bgcolor="' . $vals['vbgcolor'] . '"';
 110  
 111        $start_graph_string .=  ' rowspan="' . $rowspan . '"><font color="' . $vals['vfcolor'] . '" style="' . $vals['vfstyle'] . '"><b>' . $vals['vlabel'] . '</b></font></td>' . "\n" .
 112                                '  </tr>' . "\n";
 113      }
 114  
 115      return $start_graph_string;
 116    }
 117  
 118  ////

 119  // prints out the table footer

 120    function end_graph() {
 121      return '</table>' . "\n";
 122    }
 123  
 124  ////

 125  // sets the default values for the $vals array

 126    function hv_graph_defaults($vals) {
 127      if (!$vals['vfcolor']) $vals['vfcolor'] = '#000000';
 128      if (!$vals['hfcolor']) $vals['hfcolor'] = '#000000';
 129      if (!$vals['vbgcolor']) $vals['vbgcolor'] = '#FFFFFF';
 130      if (!$vals['hbgcolor']) $vals['hbgcolor'] = '#FFFFFF';
 131      if (!$vals['cellpadding']) $vals['cellpadding'] = '0';
 132      if (!$vals['cellspacing']) $vals['cellspacing'] = '0';
 133      if (!$vals['border']) $vals['border'] = '0';
 134      if (!$vals['scale']) $vals['scale'] = '1';
 135      if (!$vals['namebgcolor']) $vals['namebgcolor'] = '#FFFFFF';
 136      if (!$vals['valuebgcolor']) $vals['valuebgcolor'] = '#FFFFFF';
 137      if (!$vals['namefcolor']) $vals['namefcolor'] = '#000000';
 138      if (!$vals['valuefcolor']) $vals['valuefcolor'] = '#000000';
 139      if (!$vals['doublefcolor']) $vals['doublefcolor'] = '#886666';
 140  
 141      return $vals;
 142    }
 143  
 144  ////

 145  // prints out the actual data for the horizontal chart

 146    function horizontal_graph($names, $values, $bars, $vals) {
 147      $horizontal_graph_string = '';
 148      for($i = 0, $n = sizeof($values); $i < $n; $i++) { 
 149        $horizontal_graph_string .= '  <tr>' . "\n" .
 150                                    '    <td align="right"';
 151  // if a background was choosen don't print cell BGCOLOR

 152        if (!$vals['background']) $horizontal_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
 153  
 154        $horizontal_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n" .
 155                                    '    <td'; 
 156  
 157  // if a background was choosen don't print cell BGCOLOR

 158        if (!$vals['background']) $horizontal_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
 159  
 160        $horizontal_graph_string .= '>';
 161  
 162  // decide if the value in bar is a color code or image.

 163        if (ereg('^#', $bars[$i])) { 
 164          $horizontal_graph_string .= '<table cellpadding="0" cellspacing="0" bgcolor="' . $bars[$i] . '" width="' . ($values[$i] * $vals['scale']) . '">' . "\n" .
 165                                      '  <tr>' . "\n" .
 166                                      '    <td>&nbsp;</td>' . "\n" .
 167                                      '  </tr>' . "\n" .
 168                                      '</table>';
 169        } else {
 170          $horizontal_graph_string .= '<img src="' . $bars[$i] . '" height="10" width="' . ($values[$i] * $vals['scale']) . '">';
 171        }
 172  
 173        if (!$vals['noshowvals']) {
 174          $horizontal_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i>';
 175        }
 176  
 177        $horizontal_graph_string .= '</td>' . "\n" .
 178                                    '  </tr>' . "\n";
 179      } // endfor

 180  
 181      return $horizontal_graph_string;
 182    }
 183  
 184  ////

 185  // prints out the actual data for the vertical chart

 186    function vertical_graph($names, $values, $bars, $vals) {
 187      $vertical_graph_string = '  <tr>' . "\n";
 188  
 189      for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
 190        $vertical_graph_string .= '    <td align="center" valign="bottom"';
 191  
 192  // if a background was choosen don't print cell BGCOLOR

 193        if (!$vals['background']) $vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
 194  
 195        $vertical_graph_string .= '>';
 196  
 197        if (!$vals['noshowvals']) {
 198          $vertical_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i><br>';
 199        }
 200  
 201        $vertical_graph_string .= '<img src="' . $bars[$i] . '" width="5" height="';
 202  
 203  // values of zero are displayed wrong because a image height of zero 

 204  // gives a strange behavior in Netscape. For this reason the height 

 205  // is set at 1 pixel if the value is zero. - Jan Diepens

 206        if ($values[$i] != 0) {
 207          $vertical_graph_string .= $values[$i] * $vals['scale'];
 208        } else {
 209          $vertical_graph_string .= '1';
 210        } 
 211  
 212        $vertical_graph_string .= '"></td>' . "\n";
 213      } // endfor

 214  
 215      $vertical_graph_string .= '  </tr>' . "\n" .
 216                                '  <tr>' . "\n";
 217  
 218      for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
 219        $vertical_graph_string .= '    <td align="center" valign="top"';
 220  
 221  // if a background was choosen don't print cell BGCOLOR

 222        if (!$vals['background']) $vertical_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
 223  
 224        $vertical_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n";
 225      } // endfor

 226  
 227      $vertical_graph_string .= '  </tr>' . "\n";
 228  
 229      return $vertical_graph_string;
 230    }
 231  
 232  ////

 233  // prints out the actual data for the double horizontal chart

 234    function double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars) {
 235      $double_horizontal_graph_string = '';
 236      for($i = 0, $n = sizeof($values); $i < $n; $i++) {
 237        $double_horizontal_graph_string .= '  <tr>' . "\n" .
 238                                          '    <td align="right"';
 239  
 240  // if a background was choosen don't print cell BGCOLOR

 241        if (!$vals['background']) $double_horizontal_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
 242  
 243        $double_horizontal_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n" .
 244                                           '    <td';
 245  
 246  // if a background was choosen don't print cell BGCOLOR

 247        if (!$vals['background']) $double_horizontal_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
 248  
 249        $double_horizontal_graph_string .= '><table align="left" cellpadding="0" cellspacing="0" width="' . ($dvalues[$i] * $vals['scale']) . '">' . "\n" .
 250                                           '      <tr>' . "\n" .
 251                                           '        <td';
 252  
 253  // set background to a color if it starts with # or an image otherwise.

 254        if (ereg('^#', $dbars[$i])) {
 255          $double_horizontal_graph_string .= ' bgcolor="' . $dbars[$i] . '">';
 256        } else {
 257          $double_horizontal_graph_string .= ' background="' . $dbars[$i] . '">';
 258        }
 259  
 260        $double_horizontal_graph_string .= '<nowrap>';
 261  
 262  // decide if the value in bar is a color code or image.

 263        if (ereg('^#', $bars[$i])) { 
 264          $double_horizontal_graph_string .= '<table align="left" cellpadding="0" cellspacing="0" bgcolor="' . $bars[$i] . '" width="' . ($values[$i] * $vals['scale']) . '">' . "\n" .
 265                                             '  <tr>' . "\n" .
 266                                             '    <td>&nbsp;</td>' . "\n" .
 267                                             '  </tr>' . "\n" .
 268                                             '</table>';
 269        } else {
 270          $double_horizontal_graph_string .= '<img src="' . $bars[$i] . '" height="10" width="' . ($values[$i] * $vals['scale']) . '">';
 271        }          
 272  
 273        if (!$vals['noshowvals']) {
 274          $double_horizontal_graph_string .= '<i><font size="-3" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i>';
 275        }
 276  
 277        $double_horizontal_graph_string .= '</nowrap></td>' . "\n" .
 278                                           '        </tr>' . "\n" .
 279                                           '      </table>';
 280  
 281        if (!$vals['noshowvals']) {
 282          $double_horizontal_graph_string .= '<i><font size="-3" color="' . $vals['doublefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $dvalues[$i] . ')</font></i>';
 283        }
 284  
 285        $double_horizontal_graph_string .= '</td>' . "\n" .
 286                                           '  </tr>' . "\n";
 287      } // endfor

 288  
 289      return $double_horizontal_graph_string;
 290    }
 291  
 292  ////

 293  // prints out the actual data for the double vertical chart

 294    function double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars) {
 295      $double_vertical_graph_string = '  <tr>' . "\n";
 296      for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
 297        $double_vertical_graph_string .= '    <td align="center" valign="bottom"';
 298  
 299  // if a background was choosen don't print cell BGCOLOR

 300        if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
 301  
 302        $double_vertical_graph_string .= '><table>' . "\n" .
 303                                         '      <tr>' . "\n" .
 304                                         '        <td align="center" valign="bottom"';
 305  
 306  // if a background was choosen don't print cell BGCOLOR

 307        if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
 308  
 309        $double_vertical_graph_string .= '>';
 310  
 311        if (!$vals['noshowvals'] && $values[$i]) {
 312          $double_vertical_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i><br>';
 313        }
 314  
 315        $double_vertical_graph_string .= '<img src="' . $bars[$i] . '" width="10" height="';
 316  
 317        if ($values[$i] != 0) {
 318          $double_vertical_graph_string .= $values[$i] * $vals['scale'];
 319        } else {
 320          $double_vertical_graph_string .= '1';
 321        }
 322  
 323        $double_vertical_graph_string .= '"></td>' . "\n" .
 324                                         '        <td align="center" valign="bottom"';
 325  
 326  // if a background was choosen don't print cell BGCOLOR

 327        if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
 328  
 329        $double_vertical_graph_string .= '>';
 330  
 331        if (!$vals['noshowvals'] && $dvalues[$i]) {
 332          $double_vertical_graph_string .= '<i><font size="-2" color="' . $vals['doublefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $dvalues[$i] . ')</font></i><br>';
 333        }
 334  
 335        $double_vertical_graph_string .= '<img src="' . $dbars[$i] . '" width="10" height="';
 336  
 337        if ($dvalues[$i] != 0) {
 338          $double_vertical_graph_string .= $dvalues[$i] * $vals['scale'];
 339        } else {
 340          $double_vertical_graph_string .= '1';
 341        }
 342  
 343        $double_vertical_graph_string .= '"></td>' . "\n" .
 344                                         '      </tr>' . "\n" .
 345                                         '    </table></td>' . "\n";
 346      } // endfor

 347  
 348      $double_vertical_graph_string .= '  </tr>' . "\n" .
 349                                       '  <tr>' . "\n";
 350  
 351      for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
 352        $double_vertical_graph_string .= '    <td align="center" valign="top"';
 353  
 354  // if a background was choosen don't print cell BGCOLOR

 355        if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
 356  
 357        $double_vertical_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n";
 358      } // endfor

 359  
 360      $double_vertical_graph_string .= '  </tr>' . "\n";
 361  
 362      return $double_vertical_graph_string;
 363    }
 364  
 365  ////

 366  // draws a double vertical bar graph for the banner views vs clicks statistics

 367    function tep_banner_graph_infoBox($banner_id, $days) {
 368      $names = array();
 369      $values = array();
 370      $dvalues = array();
 371  
 372      $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");
 373      while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
 374        $names[] = $banner_stats['name'];
 375        $values[] = $banner_stats['value'];
 376        $dvalues[] = $banner_stats['dvalue'];
 377      }
 378      $largest = @max($values);
 379  
 380      $bars = array();
 381      $dbars = array();
 382      for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
 383        $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
 384        $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
 385      }
 386  
 387      $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
 388                          'hlabel'=>TEXT_BANNERS_LAST_3_DAYS,
 389                          'type'=>'3',
 390                          'cellpadding'=>'',
 391                          'cellspacing'=>'1',
 392                          'border'=>'',
 393                          'width'=>'',
 394                          'vfcolor'=>'#ffffff',
 395                          'hfcolor'=>'#ffffff',
 396                          'vbgcolor'=>'#81a2b6',
 397                          'hbgcolor'=>'#81a2b6',
 398                          'vfstyle'=>'Verdana, Arial, Helvetica',
 399                          'hfstyle'=>'Verdana, Arial, Helvetica',
 400                          'scale'=>100/$largest,
 401                          'namebgcolor'=>'#f3f5fe',
 402                          'valuebgcolor'=>'#f3f5fe',
 403                          'namefcolor'=>'',
 404                          'valuefcolor'=>'#0000d0',
 405                          'namefstyle'=>'Verdana, Arial, Helvetica',
 406                          'valuefstyle'=>'',
 407                          'doublefcolor'=>'#ff7339');
 408  
 409      return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
 410    }
 411  
 412  ////

 413  // draws a double vertical bar graph for the banner views vs clicks statistics

 414    function tep_banner_graph_yearly($banner_id) {
 415      global $banner, $HTTP_GET_VARS;
 416  
 417      $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)");
 418      while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
 419        $names[] = $banner_stats['year'];
 420        $values[] = (($banner_stats['value']) ? $banner_stats['value'] : '0');
 421        $dvalues[] = (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0');
 422      }
 423  
 424      $largest = @max($values);
 425  
 426      $bars = array();
 427      $dbars = array();
 428      for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
 429        $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
 430        $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
 431      }
 432  
 433      $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
 434                          'hlabel'=>sprintf(TEXT_BANNERS_YEARLY_STATISTICS, $banner['banners_title']),
 435                          'type'=>'3',
 436                          'cellpadding'=>'',
 437                          'cellspacing'=>'1',
 438                          'border'=>'',
 439                          'width'=>'',
 440                          'vfcolor'=>'#ffffff',
 441                          'hfcolor'=>'#ffffff',
 442                          'vbgcolor'=>'#81a2b6',
 443                          'hbgcolor'=>'#81a2b6',
 444                          'vfstyle'=>'Verdana, Arial, Helvetica',
 445                          'hfstyle'=>'Verdana, Arial, Helvetica',
 446                          'scale'=>100/$largest,
 447                          'namebgcolor'=>'#f3f5fe',
 448                          'valuebgcolor'=>'#f3f5fe',
 449                          'namefcolor'=>'',
 450                          'valuefcolor'=>'#0000d0',
 451                          'namefstyle'=>'Verdana, Arial, Helvetica',
 452                          'valuefstyle'=>'',
 453                          'doublefcolor'=>'#ff7339');
 454  
 455      return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
 456    }
 457  
 458  ////

 459  // draws a double vertical bar graph for the banner views vs clicks statistics

 460    function tep_banner_graph_monthly($banner_id) {
 461      global $banner, $HTTP_GET_VARS;
 462  
 463      $year = (($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y'));
 464  
 465      for ($i=1; $i<13; $i++) {
 466        $names[] = strftime('%b', mktime(0,0,0,$i));
 467        $values[] = '0';
 468        $dvalues[] = '0';
 469      }
 470  
 471      $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)");
 472      while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
 473        $names[($banner_stats['banner_month']-1)] = strftime('%b', mktime(0,0,0,$banner_stats['banner_month']));
 474        $values[($banner_stats['banner_month']-1)] = (($banner_stats['value']) ? $banner_stats['value'] : '0');
 475        $dvalues[($banner_stats['banner_month']-1)] = (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0');
 476      }
 477  
 478      $largest = @max($values);
 479  
 480      $bars = array();
 481      $dbars = array();
 482      for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
 483        $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
 484        $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
 485      }
 486  
 487      $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
 488                          'hlabel'=>sprintf(TEXT_BANNERS_MONTHLY_STATISTICS, $banner['banners_title'], date('Y')),
 489                          'type'=>'3',
 490                          'cellpadding'=>'',
 491                          'cellspacing'=>'1',
 492                          'border'=>'',
 493                          'width'=>'',
 494                          'vfcolor'=>'#ffffff',
 495                          'hfcolor'=>'#ffffff',
 496                          'vbgcolor'=>'#81a2b6',
 497                          'hbgcolor'=>'#81a2b6',
 498                          'vfstyle'=>'Verdana, Arial, Helvetica',
 499                          'hfstyle'=>'Verdana, Arial, Helvetica',
 500                          'scale'=>100/$largest,
 501                          'namebgcolor'=>'#f3f5fe',
 502                          'valuebgcolor'=>'#f3f5fe',
 503                          'namefcolor'=>'',
 504                          'valuefcolor'=>'#0000d0',
 505                          'namefstyle'=>'Verdana, Arial, Helvetica',
 506                          'valuefstyle'=>'',
 507                          'doublefcolor'=>'#ff7339');
 508  
 509      return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
 510    }
 511  
 512  ////

 513  // draws a double vertical bar graph for the banner views vs clicks statistics

 514    function tep_banner_graph_daily($banner_id) {
 515      global $banner, $HTTP_GET_VARS;
 516  
 517      $year = (isset($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y'));
 518      $month = (isset($HTTP_GET_VARS['month']) ? $HTTP_GET_VARS['month'] : date('n'));
 519  
 520      $days = (date('t', mktime(0,0,0,$month))+1);
 521      $stats = array();
 522      for ($i=1; $i<$days; $i++) {
 523        $names[] = $i;
 524        $values[] = '0';
 525        $dvalues[] = '0';
 526      }
 527  
 528      $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 . "'");
 529      while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
 530        $names[($banner_stats['banner_day']-1)] = $banner_stats['banner_day'];
 531        $values[($banner_stats['banner_day']-1)] = (($banner_stats['value']) ? $banner_stats['value'] : '0');
 532        $dvalues[($banner_stats['banner_day']-1)] = (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0');
 533      }
 534  
 535      $largest = @max($values);
 536  
 537      $bars = array();
 538      $dbars = array();
 539      for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
 540        $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
 541        $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
 542      }
 543  
 544      $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
 545                          'hlabel'=>sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0,0,0,$month)), $year),
 546                          'type'=>'3',
 547                          'cellpadding'=>'',
 548                          'cellspacing'=>'1',
 549                          'border'=>'',
 550                          'width'=>'',
 551                          'vfcolor'=>'#ffffff',
 552                          'hfcolor'=>'#ffffff',
 553                          'vbgcolor'=>'#81a2b6',
 554                          'hbgcolor'=>'#81a2b6',
 555                          'vfstyle'=>'Verdana, Arial, Helvetica',
 556                          'hfstyle'=>'Verdana, Arial, Helvetica',
 557                          'scale'=>100/$largest,
 558                          'namebgcolor'=>'#f3f5fe',
 559                          'valuebgcolor'=>'#f3f5fe',
 560                          'namefcolor'=>'',
 561                          'valuefcolor'=>'#0000d0',
 562                          'namefstyle'=>'Verdana, Arial, Helvetica',
 563                          'valuefstyle'=>'',
 564                          'doublefcolor'=>'#ff7339');
 565  
 566      return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
 567    }
 568  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7