ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/includes/functions/html_graphs.php
Go to the documentation of this file.
00001 <?php
00010 
00011 // calls routines to initialize defaults, set up table
00012 // print data, and close table.
00013   function html_graph($names, $values, $bars, $vals, $dvalues = 0, $dbars = 0) {
00014 // set the error level on entry and exit so as not to interfear with anyone elses error checking.
00015     $er = error_reporting(1);
00016 
00017 // set the values that the user didn't
00018     $vals = hv_graph_defaults($vals);
00019     $html_graph_string = start_graph($vals, $names);
00020 
00021     if ($vals['type'] == 0) {
00022       $html_graph_string .= horizontal_graph($names, $values, $bars, $vals);
00023     } elseif ($vals['type'] == 1) {
00024       $html_graph_string .= vertical_graph($names, $values, $bars, $vals);
00025     } elseif ($vals['type'] == 2) {
00026       $html_graph_string .= double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars);
00027     } elseif ($vals['type'] == 3) {
00028       $html_graph_string .= double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars);
00029     }
00030 
00031     $html_graph_string .= end_graph();
00032 
00033 // Set the error level back to where it was.
00034     error_reporting($er);
00035 
00036     return $html_graph_string;
00037   }
00038 
00040 // sets up the $vals array by initializing all values to null. Used to avoid
00041 // warnings from error_reporting being set high. This routine only needs to be
00042 // called if you are worried about using uninitialized variables.
00043   function html_graph_init() {
00044     $vals = array('vlabel'=>'',
00045                   'hlabel'=>'',
00046                   'type'=>'',
00047                   'cellpadding'=>'',
00048                   'cellspacing'=>'',
00049                   'border'=>'',
00050                   'width'=>'',
00051                   'background'=>'',
00052                   'vfcolor'=>'',
00053                   'hfcolor'=>'',
00054                   'vbgcolor'=>'',
00055                   'hbgcolor'=>'',
00056                   'vfstyle'=>'',
00057                   'hfstyle'=>'',
00058                   'noshowvals'=>'',
00059                   'scale'=>'',
00060                   'namebgcolor'=>'',
00061                   'valuebgcolor'=>'',
00062                   'namefcolor'=>'',
00063                   'valuefcolor'=>'',
00064                   'namefstyle'=>'',
00065                   'valuefstyle'=>'',
00066                   'doublefcolor'=>'');
00067 
00068     return($vals);
00069   }
00070 
00072 // prints out the table header and graph labels
00073   function start_graph($vals, $names) {
00074     $start_graph_string = '<table cellpadding="' . $vals['cellpadding'] . '" cellspacing="' . $vals['cellspacing'] . '" border="' . $vals['border'] . '"';
00075 
00076     if ($vals['width'] != 0) $start_graph_string .= ' width="' . $vals['width'] . '"';
00077     if ($vals['background']) $start_graph_string .= ' background="' . $vals['background'] . '"';
00078 
00079     $start_graph_string .= '>' . "\n";
00080 
00081     if ( ($vals['vlabel']) || ($vals['hlabel']) ) {
00082       if ( ($vals['type'] == 0) || ($vals['type'] == 2) ) {
00083 // horizontal chart
00084         $rowspan = sizeof($names) + 1;
00085         $colspan = 3;
00086       } elseif ( ($vals['type'] == 1) || ($vals['type'] == 3) ) {
00087 // vertical chart
00088         $rowspan = 3;
00089         $colspan = sizeof($names) + 1;
00090       }
00091 
00092       $start_graph_string .= '  <tr>' . "\n" .
00093                              '    <td align="center" valign="center"';
00094 
00095 // if a background was choosen don't print cell BGCOLOR
00096       if (!$vals['background']) $start_graph_string .= ' bgcolor="' . $vals['hbgcolor'] . '"';
00097 
00098       $start_graph_string .= ' colspan="' . $colspan . '"><font color="' . $vals['hfcolor'] . '" style="' . $vals['hfstyle'] . '"><b>' . $vals['hlabel'] . '</b></font></td>' . "\n" .
00099                              '  </tr>' . "\n" .
00100                              '  <tr>' . "\n" .
00101                              '    <td align="center" valign="center"';
00102 
00103 // if a background was choosen don't print cell BGCOLOR
00104       if (!$vals['background']) $start_graph_string .= ' bgcolor="' . $vals['vbgcolor'] . '"';
00105 
00106       $start_graph_string .=  ' rowspan="' . $rowspan . '"><font color="' . $vals['vfcolor'] . '" style="' . $vals['vfstyle'] . '"><b>' . $vals['vlabel'] . '</b></font></td>' . "\n" .
00107                               '  </tr>' . "\n";
00108     }
00109 
00110     return $start_graph_string;
00111   }
00112 
00114 // prints out the table footer
00115   function end_graph() {
00116     return '</table>' . "\n";
00117   }
00118 
00120 // sets the default values for the $vals array
00121   function hv_graph_defaults($vals) {
00122     if (!$vals['vfcolor']) $vals['vfcolor'] = '#000000';
00123     if (!$vals['hfcolor']) $vals['hfcolor'] = '#000000';
00124     if (!$vals['vbgcolor']) $vals['vbgcolor'] = '#FFFFFF';
00125     if (!$vals['hbgcolor']) $vals['hbgcolor'] = '#FFFFFF';
00126     if (!$vals['cellpadding']) $vals['cellpadding'] = '0';
00127     if (!$vals['cellspacing']) $vals['cellspacing'] = '0';
00128     if (!$vals['border']) $vals['border'] = '0';
00129     if (!$vals['scale']) $vals['scale'] = '1';
00130     if (!$vals['namebgcolor']) $vals['namebgcolor'] = '#FFFFFF';
00131     if (!$vals['valuebgcolor']) $vals['valuebgcolor'] = '#FFFFFF';
00132     if (!$vals['namefcolor']) $vals['namefcolor'] = '#000000';
00133     if (!$vals['valuefcolor']) $vals['valuefcolor'] = '#000000';
00134     if (!$vals['doublefcolor']) $vals['doublefcolor'] = '#886666';
00135 
00136     return $vals;
00137   }
00138 
00140 // prints out the actual data for the horizontal chart
00141   function horizontal_graph($names, $values, $bars, $vals) {
00142     $horizontal_graph_string = '';
00143     for($i = 0, $n = sizeof($values); $i < $n; $i++) {
00144       $horizontal_graph_string .= '  <tr>' . "\n" .
00145                                   '    <td align="right"';
00146 // if a background was choosen don't print cell BGCOLOR
00147       if (!$vals['background']) $horizontal_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
00148 
00149       $horizontal_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n" .
00150                                   '    <td';
00151 
00152 // if a background was choosen don't print cell BGCOLOR
00153       if (!$vals['background']) $horizontal_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
00154 
00155       $horizontal_graph_string .= '>';
00156 
00157 // decide if the value in bar is a color code or image.
00158       if (preg_match('/^#/', $bars[$i])) {
00159         $horizontal_graph_string .= '<table cellpadding="0" cellspacing="0" bgcolor="' . $bars[$i] . '" width="' . ($values[$i] * $vals['scale']) . '">' . "\n" .
00160                                     '  <tr>' . "\n" .
00161                                     '    <td>&nbsp;</td>' . "\n" .
00162                                     '  </tr>' . "\n" .
00163                                     '</table>';
00164       } else {
00165         $horizontal_graph_string .= '<img src="' . $bars[$i] . '" height="10" width="' . ($values[$i] * $vals['scale']) . '">';
00166       }
00167 
00168       if (!$vals['noshowvals']) {
00169         $horizontal_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i>';
00170       }
00171 
00172       $horizontal_graph_string .= '</td>' . "\n" .
00173                                   '  </tr>' . "\n";
00174     } // endfor
00175 
00176     return $horizontal_graph_string;
00177   }
00178 
00180 // prints out the actual data for the vertical chart
00181   function vertical_graph($names, $values, $bars, $vals) {
00182     $vertical_graph_string = '  <tr>' . "\n";
00183 
00184     for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
00185       $vertical_graph_string .= '    <td align="center" valign="bottom"';
00186 
00187 // if a background was choosen don't print cell BGCOLOR
00188       if (!$vals['background']) $vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
00189 
00190       $vertical_graph_string .= '>';
00191 
00192       if (!$vals['noshowvals']) {
00193         $vertical_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i><br>';
00194       }
00195 
00196       $vertical_graph_string .= '<img src="' . $bars[$i] . '" width="5" height="';
00197 
00198 // values of zero are displayed wrong because a image height of zero
00199 // gives a strange behavior in Netscape. For this reason the height
00200 // is set at 1 pixel if the value is zero. - Jan Diepens
00201       if ($values[$i] != 0) {
00202         $vertical_graph_string .= $values[$i] * $vals['scale'];
00203       } else {
00204         $vertical_graph_string .= '1';
00205       }
00206 
00207       $vertical_graph_string .= '"></td>' . "\n";
00208     } // endfor
00209 
00210     $vertical_graph_string .= '  </tr>' . "\n" .
00211                               '  <tr>' . "\n";
00212 
00213     for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
00214       $vertical_graph_string .= '    <td align="center" valign="top"';
00215 
00216 // if a background was choosen don't print cell BGCOLOR
00217       if (!$vals['background']) $vertical_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
00218 
00219       $vertical_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n";
00220     } // endfor
00221 
00222     $vertical_graph_string .= '  </tr>' . "\n";
00223 
00224     return $vertical_graph_string;
00225   }
00226 
00228 // prints out the actual data for the double horizontal chart
00229   function double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars) {
00230     $double_horizontal_graph_string = '';
00231     for($i = 0, $n = sizeof($values); $i < $n; $i++) {
00232       $double_horizontal_graph_string .= '  <tr>' . "\n" .
00233                                         '    <td align="right"';
00234 
00235 // if a background was choosen don't print cell BGCOLOR
00236       if (!$vals['background']) $double_horizontal_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
00237 
00238       $double_horizontal_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n" .
00239                                          '    <td';
00240 
00241 // if a background was choosen don't print cell BGCOLOR
00242       if (!$vals['background']) $double_horizontal_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
00243 
00244       $double_horizontal_graph_string .= '><table align="left" cellpadding="0" cellspacing="0" width="' . ($dvalues[$i] * $vals['scale']) . '">' . "\n" .
00245                                          '      <tr>' . "\n" .
00246                                          '        <td';
00247 
00248 // set background to a color if it starts with # or an image otherwise.
00249       if (preg_match('/^#/', $dbars[$i])) {
00250         $double_horizontal_graph_string .= ' bgcolor="' . $dbars[$i] . '">';
00251       } else {
00252         $double_horizontal_graph_string .= ' background="' . $dbars[$i] . '">';
00253       }
00254 
00255       $double_horizontal_graph_string .= '<nowrap>';
00256 
00257 // decide if the value in bar is a color code or image.
00258       if (preg_match('/^#/', $bars[$i])) {
00259         $double_horizontal_graph_string .= '<table align="left" cellpadding="0" cellspacing="0" bgcolor="' . $bars[$i] . '" width="' . ($values[$i] * $vals['scale']) . '">' . "\n" .
00260                                            '  <tr>' . "\n" .
00261                                            '    <td>&nbsp;</td>' . "\n" .
00262                                            '  </tr>' . "\n" .
00263                                            '</table>';
00264       } else {
00265         $double_horizontal_graph_string .= '<img src="' . $bars[$i] . '" height="10" width="' . ($values[$i] * $vals['scale']) . '">';
00266       }
00267 
00268       if (!$vals['noshowvals']) {
00269         $double_horizontal_graph_string .= '<i><font size="-3" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i>';
00270       }
00271 
00272       $double_horizontal_graph_string .= '</nowrap></td>' . "\n" .
00273                                          '        </tr>' . "\n" .
00274                                          '      </table>';
00275 
00276       if (!$vals['noshowvals']) {
00277         $double_horizontal_graph_string .= '<i><font size="-3" color="' . $vals['doublefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $dvalues[$i] . ')</font></i>';
00278       }
00279 
00280       $double_horizontal_graph_string .= '</td>' . "\n" .
00281                                          '  </tr>' . "\n";
00282     } // endfor
00283 
00284     return $double_horizontal_graph_string;
00285   }
00286 
00288 // prints out the actual data for the double vertical chart
00289   function double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars) {
00290     $double_vertical_graph_string = '  <tr>' . "\n";
00291     for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
00292       $double_vertical_graph_string .= '    <td align="center" valign="bottom"';
00293 
00294 // if a background was choosen don't print cell BGCOLOR
00295       if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
00296 
00297       $double_vertical_graph_string .= '><table>' . "\n" .
00298                                        '      <tr>' . "\n" .
00299                                        '        <td align="center" valign="bottom"';
00300 
00301 // if a background was choosen don't print cell BGCOLOR
00302       if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
00303 
00304       $double_vertical_graph_string .= '>';
00305 
00306       if (!$vals['noshowvals'] && $values[$i]) {
00307         $double_vertical_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i><br>';
00308       }
00309 
00310       $double_vertical_graph_string .= '<img src="' . $bars[$i] . '" width="10" height="';
00311 
00312       if ($values[$i] != 0) {
00313         $double_vertical_graph_string .= $values[$i] * $vals['scale'];
00314       } else {
00315         $double_vertical_graph_string .= '1';
00316       }
00317 
00318       $double_vertical_graph_string .= '"></td>' . "\n" .
00319                                        '        <td align="center" valign="bottom"';
00320 
00321 // if a background was choosen don't print cell BGCOLOR
00322       if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
00323 
00324       $double_vertical_graph_string .= '>';
00325 
00326       if (!$vals['noshowvals'] && $dvalues[$i]) {
00327         $double_vertical_graph_string .= '<i><font size="-2" color="' . $vals['doublefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $dvalues[$i] . ')</font></i><br>';
00328       }
00329 
00330       $double_vertical_graph_string .= '<img src="' . $dbars[$i] . '" width="10" height="';
00331 
00332       if ($dvalues[$i] != 0) {
00333         $double_vertical_graph_string .= $dvalues[$i] * $vals['scale'];
00334       } else {
00335         $double_vertical_graph_string .= '1';
00336       }
00337 
00338       $double_vertical_graph_string .= '"></td>' . "\n" .
00339                                        '      </tr>' . "\n" .
00340                                        '    </table></td>' . "\n";
00341     } // endfor
00342 
00343     $double_vertical_graph_string .= '  </tr>' . "\n" .
00344                                      '  <tr>' . "\n";
00345 
00346     for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
00347       $double_vertical_graph_string .= '    <td align="center" valign="top"';
00348 
00349 // if a background was choosen don't print cell BGCOLOR
00350       if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
00351 
00352       $double_vertical_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n";
00353     } // endfor
00354 
00355     $double_vertical_graph_string .= '  </tr>' . "\n";
00356 
00357     return $double_vertical_graph_string;
00358   }
00359 
00361 // draws a double vertical bar graph for the banner views vs clicks statistics
00362   function zen_banner_graph_infoBox($banner_id, $days) {
00363     global $db;
00364     $names = array();
00365     $values = array();
00366     $dvalues = array();
00367 
00368     $banner_stats = $db->Execute("select dayofmonth(banners_history_date) as name,
00369                                              banners_shown as value, banners_clicked as dvalue
00370                                                                                  from " . TABLE_BANNERS_HISTORY . "
00371                                                                                  where banners_id = '" . (int)$banner_id . "'
00372                                                                                  and to_days(now()) - to_days(banners_history_date) < " . zen_db_input($days) . "
00373                                                                                  order by banners_history_date");
00374 
00375     while (!$banner_stats->EOF) {
00376       $names[] = $banner_stats->fields['name'];
00377       $values[] = $banner_stats->fields['value'];
00378       $dvalues[] = $banner_stats->fields['dvalue'];
00379           $banner_stats->MoveNext();
00380     }
00381     $largest = @max($values);
00382 
00383     $bars = array();
00384     $dbars = array();
00385     for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
00386       $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
00387       $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
00388     }
00389 
00390     $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
00391                         'hlabel'=>TEXT_BANNERS_LAST_3_DAYS,
00392                         'type'=>'3',
00393                         'cellpadding'=>'',
00394                         'cellspacing'=>'1',
00395                         'border'=>'',
00396                         'width'=>'',
00397                         'vfcolor'=>'#ffffff',
00398                         'hfcolor'=>'#ffffff',
00399                         'vbgcolor'=>'#81a2b6',
00400                         'hbgcolor'=>'#81a2b6',
00401                         'vfstyle'=>'Verdana, Arial, Helvetica',
00402                         'hfstyle'=>'Verdana, Arial, Helvetica',
00403                         'scale'=>100/$largest,
00404                         'namebgcolor'=>'#f3f5fe',
00405                         'valuebgcolor'=>'#f3f5fe',
00406                         'namefcolor'=>'',
00407                         'valuefcolor'=>'#0000d0',
00408                         'namefstyle'=>'Verdana, Arial, Helvetica',
00409                         'valuefstyle'=>'',
00410                         'doublefcolor'=>'#ff7339');
00411 
00412     return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
00413   }
00414 
00416 // draws a double vertical bar graph for the banner views vs clicks statistics
00417   function zen_banner_graph_yearly($banner_id) {
00418     global $db, $banner, $_GET;
00419 
00420     $banner_stats = $db->Execute("select year(banners_history_date) as year,
00421                                              sum(banners_shown) as value, sum(banners_clicked) as dvalue
00422                                                                                  from " . TABLE_BANNERS_HISTORY . "
00423                                                                                  where banners_id = '" . (int)$banner_id . "'
00424                                                                                  group by year(banners_history_date)");
00425 
00426     while (!$banner_stats->EOF) {
00427       $names[] = $banner_stats->fields['year'];
00428       $values[] = (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0');
00429       $dvalues[] = (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0');
00430           $banner_stats->MoveNext();
00431     }
00432 
00433     $largest = @max($values);
00434 
00435     $bars = array();
00436     $dbars = array();
00437     for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
00438       $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
00439       $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
00440     }
00441 
00442     $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
00443                         'hlabel'=>sprintf(TEXT_BANNERS_YEARLY_STATISTICS, $banner->fields['banners_title']),
00444                         'type'=>'3',
00445                         'cellpadding'=>'',
00446                         'cellspacing'=>'1',
00447                         'border'=>'',
00448                         'width'=>'',
00449                         'vfcolor'=>'#ffffff',
00450                         'hfcolor'=>'#ffffff',
00451                         'vbgcolor'=>'#81a2b6',
00452                         'hbgcolor'=>'#81a2b6',
00453                         'vfstyle'=>'Verdana, Arial, Helvetica',
00454                         'hfstyle'=>'Verdana, Arial, Helvetica',
00455                         'scale'=>100/$largest,
00456                         'namebgcolor'=>'#f3f5fe',
00457                         'valuebgcolor'=>'#f3f5fe',
00458                         'namefcolor'=>'',
00459                         'valuefcolor'=>'#0000d0',
00460                         'namefstyle'=>'Verdana, Arial, Helvetica',
00461                         'valuefstyle'=>'',
00462                         'doublefcolor'=>'#ff7339');
00463 
00464     return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
00465   }
00466 
00468 // draws a double vertical bar graph for the banner views vs clicks statistics
00469   function zen_banner_graph_monthly($banner_id) {
00470     global $db, $banner, $_GET;
00471 
00472     $year = (($_GET['year']) ? $_GET['year'] : date('Y'));
00473 
00474     for ($i=1; $i<13; $i++) {
00475       $names[] = strftime('%b', mktime(0,0,0,$i));
00476       $values[] = '0';
00477       $dvalues[] = '0';
00478     }
00479 
00480     $banner_stats = $db->Execute("select month(banners_history_date) as banner_month, sum(banners_shown) as value,
00481                                       sum(banners_clicked) as dvalue
00482                                                                   from " . TABLE_BANNERS_HISTORY . "
00483                                                                   where banners_id = '" . (int)$banner_id . "'
00484                                                                   and year(banners_history_date) = '" . zen_db_input($year) . "'
00485                                                                   group by month(banners_history_date)");
00486 
00487     while (!$banner_stats->EOF) {
00488       $names[($banner_stats->fields['banner_month']-1)] = strftime('%b', mktime(0,0,0,$banner_stats->fields['banner_month']));
00489       $values[($banner_stats->fields['banner_month']-1)] = (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0');
00490       $dvalues[($banner_stats->fields['banner_month']-1)] = (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0');
00491           $banner_stats->MoveNext();
00492     }
00493 
00494     $largest = @max($values);
00495 
00496     $bars = array();
00497     $dbars = array();
00498     for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
00499       $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
00500       $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
00501     }
00502 
00503     $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
00504                         'hlabel'=>sprintf(TEXT_BANNERS_MONTHLY_STATISTICS, $banner->fields['banners_title'], date('Y')),
00505                         'type'=>'3',
00506                         'cellpadding'=>'',
00507                         'cellspacing'=>'1',
00508                         'border'=>'',
00509                         'width'=>'',
00510                         'vfcolor'=>'#ffffff',
00511                         'hfcolor'=>'#ffffff',
00512                         'vbgcolor'=>'#81a2b6',
00513                         'hbgcolor'=>'#81a2b6',
00514                         'vfstyle'=>'Verdana, Arial, Helvetica',
00515                         'hfstyle'=>'Verdana, Arial, Helvetica',
00516                         'scale'=>100/$largest,
00517                         'namebgcolor'=>'#f3f5fe',
00518                         'valuebgcolor'=>'#f3f5fe',
00519                         'namefcolor'=>'',
00520                         'valuefcolor'=>'#0000d0',
00521                         'namefstyle'=>'Verdana, Arial, Helvetica',
00522                         'valuefstyle'=>'',
00523                         'doublefcolor'=>'#ff7339');
00524 
00525     return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
00526   }
00527 
00529 // draws a double vertical bar graph for the banner views vs clicks statistics
00530   function zen_banner_graph_daily($banner_id) {
00531     global $db, $banner, $_GET;
00532 
00533     $year = (isset($_GET['year']) ? $_GET['year'] : date('Y'));
00534     $month = (isset($_GET['month']) ? $_GET['month'] : date('n'));
00535 
00536     $days = (date('t', mktime(0,0,0,$month))+1);
00537     $stats = array();
00538     for ($i=1; $i<$days; $i++) {
00539       $names[] = $i;
00540       $values[] = '0';
00541       $dvalues[] = '0';
00542     }
00543 
00544     $banner_stats = $db->Execute("select dayofmonth(banners_history_date) as banner_day,
00545                                              banners_shown as value, banners_clicked as dvalue
00546                                                                                  from " . TABLE_BANNERS_HISTORY . "
00547                                                                                  where banners_id = '" . (int)$banner_id . "'
00548                                                                                  and month(banners_history_date) = '" . zen_db_input($month) . "'
00549                                                                                  and year(banners_history_date) = '" . zen_db_input($year) . "'");
00550 
00551     while (!$banner_stats->EOF) {
00552       $names[($banner_stats->fields['banner_day']-1)] = $banner_stats->fields['banner_day'];
00553       $values[($banner_stats->fields['banner_day']-1)] = (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0');
00554       $dvalues[($banner_stats->fields['banner_day']-1)] = (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0');
00555           $banner_stats->MoveNext();
00556     }
00557 
00558     $largest = @max($values);
00559 
00560     $bars = array();
00561     $dbars = array();
00562     for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
00563       $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
00564       $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
00565     }
00566 
00567     $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
00568                         'hlabel'=>sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner->fields['banners_title'], strftime('%B', mktime(0,0,0,$month)), $year),
00569                         'type'=>'3',
00570                         'cellpadding'=>'',
00571                         'cellspacing'=>'1',
00572                         'border'=>'',
00573                         'width'=>'',
00574                         'vfcolor'=>'#ffffff',
00575                         'hfcolor'=>'#ffffff',
00576                         'vbgcolor'=>'#81a2b6',
00577                         'hbgcolor'=>'#81a2b6',
00578                         'vfstyle'=>'Verdana, Arial, Helvetica',
00579                         'hfstyle'=>'Verdana, Arial, Helvetica',
00580                         'scale'=>100/$largest,
00581                         'namebgcolor'=>'#f3f5fe',
00582                         'valuebgcolor'=>'#f3f5fe',
00583                         'namefcolor'=>'',
00584                         'valuefcolor'=>'#0000d0',
00585                         'namefstyle'=>'Verdana, Arial, Helvetica',
00586                         'valuefstyle'=>'',
00587                         'doublefcolor'=>'#ff7339');
00588 
00589     return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
00590   }
00591 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations