/modules/shop/admin/includes/functions/html_graphs.php

https://github.com/severnaya99/Sg-2010 · PHP · 604 lines · 424 code · 108 blank · 72 comment · 81 complexity · d46a6d6649e49fde0525761a9188d2a1 MD5 · raw file

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // |zen-cart Open Source E-commerce |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2003 The zen-cart developers |
  7. // | |
  8. // | http://www.zen-cart.com/index.php |
  9. // | |
  10. // | Portions Copyright (c) 2003 osCommerce |
  11. // +----------------------------------------------------------------------+
  12. // | This source file is subject to version 2.0 of the GPL license, |
  13. // | that is bundled with this package in the file LICENSE, and is |
  14. // | available through the world-wide-web at the following url: |
  15. // | http://www.zen-cart.com/license/2_0.txt. |
  16. // | If you did not receive a copy of the zen-cart license and are unable |
  17. // | to obtain it through the world-wide-web, please send a note to |
  18. // | license@zen-cart.com so we can mail you a copy immediately. |
  19. // +----------------------------------------------------------------------+
  20. // $Id: html_graphs.php 290 2004-09-15 19:48:26Z wilt $
  21. //
  22. ////
  23. // calls routines to initialize defaults, set up table
  24. // print data, and close table.
  25. function html_graph($names, $values, $bars, $vals, $dvalues = 0, $dbars = 0) {
  26. // set the error level on entry and exit so as not to interfear with anyone elses error checking.
  27. $er = error_reporting(1);
  28. // set the values that the user didn't
  29. $vals = hv_graph_defaults($vals);
  30. $html_graph_string = start_graph($vals, $names);
  31. if ($vals['type'] == 0) {
  32. $html_graph_string .= horizontal_graph($names, $values, $bars, $vals);
  33. } elseif ($vals['type'] == 1) {
  34. $html_graph_string .= vertical_graph($names, $values, $bars, $vals);
  35. } elseif ($vals['type'] == 2) {
  36. $html_graph_string .= double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars);
  37. } elseif ($vals['type'] == 3) {
  38. $html_graph_string .= double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars);
  39. }
  40. $html_graph_string .= end_graph();
  41. // Set the error level back to where it was.
  42. error_reporting($er);
  43. return $html_graph_string;
  44. }
  45. ////
  46. // sets up the $vals array by initializing all values to null. Used to avoid
  47. // warnings from error_reporting being set high. This routine only needs to be
  48. // called if you are worried about using uninitialized variables.
  49. function html_graph_init() {
  50. $vals = array('vlabel'=>'',
  51. 'hlabel'=>'',
  52. 'type'=>'',
  53. 'cellpadding'=>'',
  54. 'cellspacing'=>'',
  55. 'border'=>'',
  56. 'width'=>'',
  57. 'background'=>'',
  58. 'vfcolor'=>'',
  59. 'hfcolor'=>'',
  60. 'vbgcolor'=>'',
  61. 'hbgcolor'=>'',
  62. 'vfstyle'=>'',
  63. 'hfstyle'=>'',
  64. 'noshowvals'=>'',
  65. 'scale'=>'',
  66. 'namebgcolor'=>'',
  67. 'valuebgcolor'=>'',
  68. 'namefcolor'=>'',
  69. 'valuefcolor'=>'',
  70. 'namefstyle'=>'',
  71. 'valuefstyle'=>'',
  72. 'doublefcolor'=>'');
  73. return($vals);
  74. }
  75. ////
  76. // prints out the table header and graph labels
  77. function start_graph($vals, $names) {
  78. $start_graph_string = '<table cellpadding="' . $vals['cellpadding'] . '" cellspacing="' . $vals['cellspacing'] . '" border="' . $vals['border'] . '"';
  79. if ($vals['width'] != 0) $start_graph_string .= ' width="' . $vals['width'] . '"';
  80. if ($vals['background']) $start_graph_string .= ' background="' . $vals['background'] . '"';
  81. $start_graph_string .= '>' . "\n";
  82. if ( ($vals['vlabel']) || ($vals['hlabel']) ) {
  83. if ( ($vals['type'] == 0) || ($vals['type'] == 2) ) {
  84. // horizontal chart
  85. $rowspan = sizeof($names) + 1;
  86. $colspan = 3;
  87. } elseif ( ($vals['type'] == 1) || ($vals['type'] == 3) ) {
  88. // vertical chart
  89. $rowspan = 3;
  90. $colspan = sizeof($names) + 1;
  91. }
  92. $start_graph_string .= ' <tr>' . "\n" .
  93. ' <td align="center" valign="center"';
  94. // if a background was choosen don't print cell BGCOLOR
  95. if (!$vals['background']) $start_graph_string .= ' bgcolor="' . $vals['hbgcolor'] . '"';
  96. $start_graph_string .= ' colspan="' . $colspan . '"><font color="' . $vals['hfcolor'] . '" style="' . $vals['hfstyle'] . '"><b>' . $vals['hlabel'] . '</b></font></td>' . "\n" .
  97. ' </tr>' . "\n" .
  98. ' <tr>' . "\n" .
  99. ' <td align="center" valign="center"';
  100. // if a background was choosen don't print cell BGCOLOR
  101. if (!$vals['background']) $start_graph_string .= ' bgcolor="' . $vals['vbgcolor'] . '"';
  102. $start_graph_string .= ' rowspan="' . $rowspan . '"><font color="' . $vals['vfcolor'] . '" style="' . $vals['vfstyle'] . '"><b>' . $vals['vlabel'] . '</b></font></td>' . "\n" .
  103. ' </tr>' . "\n";
  104. }
  105. return $start_graph_string;
  106. }
  107. ////
  108. // prints out the table footer
  109. function end_graph() {
  110. return '</table>' . "\n";
  111. }
  112. ////
  113. // sets the default values for the $vals array
  114. function hv_graph_defaults($vals) {
  115. if (!$vals['vfcolor']) $vals['vfcolor'] = '#000000';
  116. if (!$vals['hfcolor']) $vals['hfcolor'] = '#000000';
  117. if (!$vals['vbgcolor']) $vals['vbgcolor'] = '#FFFFFF';
  118. if (!$vals['hbgcolor']) $vals['hbgcolor'] = '#FFFFFF';
  119. if (!$vals['cellpadding']) $vals['cellpadding'] = '0';
  120. if (!$vals['cellspacing']) $vals['cellspacing'] = '0';
  121. if (!$vals['border']) $vals['border'] = '0';
  122. if (!$vals['scale']) $vals['scale'] = '1';
  123. if (!$vals['namebgcolor']) $vals['namebgcolor'] = '#FFFFFF';
  124. if (!$vals['valuebgcolor']) $vals['valuebgcolor'] = '#FFFFFF';
  125. if (!$vals['namefcolor']) $vals['namefcolor'] = '#000000';
  126. if (!$vals['valuefcolor']) $vals['valuefcolor'] = '#000000';
  127. if (!$vals['doublefcolor']) $vals['doublefcolor'] = '#886666';
  128. return $vals;
  129. }
  130. ////
  131. // prints out the actual data for the horizontal chart
  132. function horizontal_graph($names, $values, $bars, $vals) {
  133. $horizontal_graph_string = '';
  134. for($i = 0, $n = sizeof($values); $i < $n; $i++) {
  135. $horizontal_graph_string .= ' <tr>' . "\n" .
  136. ' <td align="right"';
  137. // if a background was choosen don't print cell BGCOLOR
  138. if (!$vals['background']) $horizontal_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
  139. $horizontal_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n" .
  140. ' <td';
  141. // if a background was choosen don't print cell BGCOLOR
  142. if (!$vals['background']) $horizontal_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
  143. $horizontal_graph_string .= '>';
  144. // decide if the value in bar is a color code or image.
  145. if (ereg('^#', $bars[$i])) {
  146. $horizontal_graph_string .= '<table cellpadding="0" cellspacing="0" bgcolor="' . $bars[$i] . '" width="' . ($values[$i] * $vals['scale']) . '">' . "\n" .
  147. ' <tr>' . "\n" .
  148. ' <td>&nbsp;</td>' . "\n" .
  149. ' </tr>' . "\n" .
  150. '</table>';
  151. } else {
  152. $horizontal_graph_string .= '<img src="' . $bars[$i] . '" height="10" width="' . ($values[$i] * $vals['scale']) . '">';
  153. }
  154. if (!$vals['noshowvals']) {
  155. $horizontal_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i>';
  156. }
  157. $horizontal_graph_string .= '</td>' . "\n" .
  158. ' </tr>' . "\n";
  159. } // endfor
  160. return $horizontal_graph_string;
  161. }
  162. ////
  163. // prints out the actual data for the vertical chart
  164. function vertical_graph($names, $values, $bars, $vals) {
  165. $vertical_graph_string = ' <tr>' . "\n";
  166. for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
  167. $vertical_graph_string .= ' <td align="center" valign="bottom"';
  168. // if a background was choosen don't print cell BGCOLOR
  169. if (!$vals['background']) $vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
  170. $vertical_graph_string .= '>';
  171. if (!$vals['noshowvals']) {
  172. $vertical_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i><br>';
  173. }
  174. $vertical_graph_string .= '<img src="' . $bars[$i] . '" width="5" height="';
  175. // values of zero are displayed wrong because a image height of zero
  176. // gives a strange behavior in Netscape. For this reason the height
  177. // is set at 1 pixel if the value is zero. - Jan Diepens
  178. if ($values[$i] != 0) {
  179. $vertical_graph_string .= $values[$i] * $vals['scale'];
  180. } else {
  181. $vertical_graph_string .= '1';
  182. }
  183. $vertical_graph_string .= '"></td>' . "\n";
  184. } // endfor
  185. $vertical_graph_string .= ' </tr>' . "\n" .
  186. ' <tr>' . "\n";
  187. for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
  188. $vertical_graph_string .= ' <td align="center" valign="top"';
  189. // if a background was choosen don't print cell BGCOLOR
  190. if (!$vals['background']) $vertical_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
  191. $vertical_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n";
  192. } // endfor
  193. $vertical_graph_string .= ' </tr>' . "\n";
  194. return $vertical_graph_string;
  195. }
  196. ////
  197. // prints out the actual data for the double horizontal chart
  198. function double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars) {
  199. $double_horizontal_graph_string = '';
  200. for($i = 0, $n = sizeof($values); $i < $n; $i++) {
  201. $double_horizontal_graph_string .= ' <tr>' . "\n" .
  202. ' <td align="right"';
  203. // if a background was choosen don't print cell BGCOLOR
  204. if (!$vals['background']) $double_horizontal_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
  205. $double_horizontal_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n" .
  206. ' <td';
  207. // if a background was choosen don't print cell BGCOLOR
  208. if (!$vals['background']) $double_horizontal_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
  209. $double_horizontal_graph_string .= '><table align="left" cellpadding="0" cellspacing="0" width="' . ($dvalues[$i] * $vals['scale']) . '">' . "\n" .
  210. ' <tr>' . "\n" .
  211. ' <td';
  212. // set background to a color if it starts with # or an image otherwise.
  213. if (ereg('^#', $dbars[$i])) {
  214. $double_horizontal_graph_string .= ' bgcolor="' . $dbars[$i] . '">';
  215. } else {
  216. $double_horizontal_graph_string .= ' background="' . $dbars[$i] . '">';
  217. }
  218. $double_horizontal_graph_string .= '<nowrap>';
  219. // decide if the value in bar is a color code or image.
  220. if (ereg('^#', $bars[$i])) {
  221. $double_horizontal_graph_string .= '<table align="left" cellpadding="0" cellspacing="0" bgcolor="' . $bars[$i] . '" width="' . ($values[$i] * $vals['scale']) . '">' . "\n" .
  222. ' <tr>' . "\n" .
  223. ' <td>&nbsp;</td>' . "\n" .
  224. ' </tr>' . "\n" .
  225. '</table>';
  226. } else {
  227. $double_horizontal_graph_string .= '<img src="' . $bars[$i] . '" height="10" width="' . ($values[$i] * $vals['scale']) . '">';
  228. }
  229. if (!$vals['noshowvals']) {
  230. $double_horizontal_graph_string .= '<i><font size="-3" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i>';
  231. }
  232. $double_horizontal_graph_string .= '</nowrap></td>' . "\n" .
  233. ' </tr>' . "\n" .
  234. ' </table>';
  235. if (!$vals['noshowvals']) {
  236. $double_horizontal_graph_string .= '<i><font size="-3" color="' . $vals['doublefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $dvalues[$i] . ')</font></i>';
  237. }
  238. $double_horizontal_graph_string .= '</td>' . "\n" .
  239. ' </tr>' . "\n";
  240. } // endfor
  241. return $double_horizontal_graph_string;
  242. }
  243. ////
  244. // prints out the actual data for the double vertical chart
  245. function double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars) {
  246. $double_vertical_graph_string = ' <tr>' . "\n";
  247. for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
  248. $double_vertical_graph_string .= ' <td align="center" valign="bottom"';
  249. // if a background was choosen don't print cell BGCOLOR
  250. if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
  251. $double_vertical_graph_string .= '><table>' . "\n" .
  252. ' <tr>' . "\n" .
  253. ' <td align="center" valign="bottom"';
  254. // if a background was choosen don't print cell BGCOLOR
  255. if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
  256. $double_vertical_graph_string .= '>';
  257. if (!$vals['noshowvals'] && $values[$i]) {
  258. $double_vertical_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i><br>';
  259. }
  260. $double_vertical_graph_string .= '<img src="' . $bars[$i] . '" width="10" height="';
  261. if ($values[$i] != 0) {
  262. $double_vertical_graph_string .= $values[$i] * $vals['scale'];
  263. } else {
  264. $double_vertical_graph_string .= '1';
  265. }
  266. $double_vertical_graph_string .= '"></td>' . "\n" .
  267. ' <td align="center" valign="bottom"';
  268. // if a background was choosen don't print cell BGCOLOR
  269. if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"';
  270. $double_vertical_graph_string .= '>';
  271. if (!$vals['noshowvals'] && $dvalues[$i]) {
  272. $double_vertical_graph_string .= '<i><font size="-2" color="' . $vals['doublefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $dvalues[$i] . ')</font></i><br>';
  273. }
  274. $double_vertical_graph_string .= '<img src="' . $dbars[$i] . '" width="10" height="';
  275. if ($dvalues[$i] != 0) {
  276. $double_vertical_graph_string .= $dvalues[$i] * $vals['scale'];
  277. } else {
  278. $double_vertical_graph_string .= '1';
  279. }
  280. $double_vertical_graph_string .= '"></td>' . "\n" .
  281. ' </tr>' . "\n" .
  282. ' </table></td>' . "\n";
  283. } // endfor
  284. $double_vertical_graph_string .= ' </tr>' . "\n" .
  285. ' <tr>' . "\n";
  286. for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
  287. $double_vertical_graph_string .= ' <td align="center" valign="top"';
  288. // if a background was choosen don't print cell BGCOLOR
  289. if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"';
  290. $double_vertical_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n";
  291. } // endfor
  292. $double_vertical_graph_string .= ' </tr>' . "\n";
  293. return $double_vertical_graph_string;
  294. }
  295. ////
  296. // draws a double vertical bar graph for the banner views vs clicks statistics
  297. function zen_banner_graph_infoBox($banner_id, $days) {
  298. global $db;
  299. $names = array();
  300. $values = array();
  301. $dvalues = array();
  302. $banner_stats = $db->Execute("select dayofmonth(banners_history_date) as name,
  303. banners_shown as value, banners_clicked as dvalue
  304. from " . TABLE_BANNERS_HISTORY . "
  305. where banners_id = '" . $banner_id . "'
  306. and to_days(now()) - to_days(banners_history_date) < " . $days . "
  307. order by banners_history_date");
  308. while (!$banner_stats->EOF) {
  309. $names[] = $banner_stats->fields['name'];
  310. $values[] = $banner_stats->fields['value'];
  311. $dvalues[] = $banner_stats->fields['dvalue'];
  312. $banner_stats->MoveNext();
  313. }
  314. $largest = @max($values);
  315. $bars = array();
  316. $dbars = array();
  317. for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
  318. $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
  319. $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
  320. }
  321. $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
  322. 'hlabel'=>TEXT_BANNERS_LAST_3_DAYS,
  323. 'type'=>'3',
  324. 'cellpadding'=>'',
  325. 'cellspacing'=>'1',
  326. 'border'=>'',
  327. 'width'=>'',
  328. 'vfcolor'=>'#ffffff',
  329. 'hfcolor'=>'#ffffff',
  330. 'vbgcolor'=>'#81a2b6',
  331. 'hbgcolor'=>'#81a2b6',
  332. 'vfstyle'=>'Verdana, Arial, Helvetica',
  333. 'hfstyle'=>'Verdana, Arial, Helvetica',
  334. 'scale'=>100/$largest,
  335. 'namebgcolor'=>'#f3f5fe',
  336. 'valuebgcolor'=>'#f3f5fe',
  337. 'namefcolor'=>'',
  338. 'valuefcolor'=>'#0000d0',
  339. 'namefstyle'=>'Verdana, Arial, Helvetica',
  340. 'valuefstyle'=>'',
  341. 'doublefcolor'=>'#ff7339');
  342. return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
  343. }
  344. ////
  345. // draws a double vertical bar graph for the banner views vs clicks statistics
  346. function zen_banner_graph_yearly($banner_id) {
  347. global $db, $banner, $_GET;
  348. $banner_stats = $db->Execute("select year(banners_history_date) as year,
  349. sum(banners_shown) as value, sum(banners_clicked) as dvalue
  350. from " . TABLE_BANNERS_HISTORY . "
  351. where banners_id = '" . $banner_id . "'
  352. group by year(banners_history_date)");
  353. while (!$banner_stats->EOF) {
  354. $names[] = $banner_stats->fields['year'];
  355. $values[] = (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0');
  356. $dvalues[] = (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0');
  357. $banner_stats->MoveNext();
  358. }
  359. $largest = @max($values);
  360. $bars = array();
  361. $dbars = array();
  362. for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
  363. $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
  364. $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
  365. }
  366. $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
  367. 'hlabel'=>sprintf(TEXT_BANNERS_YEARLY_STATISTICS, $banner->fields['banners_title']),
  368. 'type'=>'3',
  369. 'cellpadding'=>'',
  370. 'cellspacing'=>'1',
  371. 'border'=>'',
  372. 'width'=>'',
  373. 'vfcolor'=>'#ffffff',
  374. 'hfcolor'=>'#ffffff',
  375. 'vbgcolor'=>'#81a2b6',
  376. 'hbgcolor'=>'#81a2b6',
  377. 'vfstyle'=>'Verdana, Arial, Helvetica',
  378. 'hfstyle'=>'Verdana, Arial, Helvetica',
  379. 'scale'=>100/$largest,
  380. 'namebgcolor'=>'#f3f5fe',
  381. 'valuebgcolor'=>'#f3f5fe',
  382. 'namefcolor'=>'',
  383. 'valuefcolor'=>'#0000d0',
  384. 'namefstyle'=>'Verdana, Arial, Helvetica',
  385. 'valuefstyle'=>'',
  386. 'doublefcolor'=>'#ff7339');
  387. return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
  388. }
  389. ////
  390. // draws a double vertical bar graph for the banner views vs clicks statistics
  391. function zen_banner_graph_monthly($banner_id) {
  392. global $db, $banner, $_GET;
  393. $year = (($_GET['year']) ? $_GET['year'] : date('Y'));
  394. for ($i=1; $i<13; $i++) {
  395. $names[] = strftime('%b', mktime(0,0,0,$i));
  396. $values[] = '0';
  397. $dvalues[] = '0';
  398. }
  399. $banner_stats = $db->Execute("select month(banners_history_date) as banner_month, sum(banners_shown) as value,
  400. sum(banners_clicked) as dvalue
  401. from " . TABLE_BANNERS_HISTORY . "
  402. where banners_id = '" . $banner_id . "'
  403. and year(banners_history_date) = '" . $year . "'
  404. group by month(banners_history_date)");
  405. while (!$banner_stats->EOF) {
  406. $names[($banner_stats->fields['banner_month']-1)] = strftime('%b', mktime(0,0,0,$banner_stats->fields['banner_month']));
  407. $values[($banner_stats->fields['banner_month']-1)] = (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0');
  408. $dvalues[($banner_stats->fields['banner_month']-1)] = (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0');
  409. $banner_stats->MoveNext();
  410. }
  411. $largest = @max($values);
  412. $bars = array();
  413. $dbars = array();
  414. for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
  415. $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
  416. $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
  417. }
  418. $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
  419. 'hlabel'=>sprintf(TEXT_BANNERS_MONTHLY_STATISTICS, $banner->fields['banners_title'], date('Y')),
  420. 'type'=>'3',
  421. 'cellpadding'=>'',
  422. 'cellspacing'=>'1',
  423. 'border'=>'',
  424. 'width'=>'',
  425. 'vfcolor'=>'#ffffff',
  426. 'hfcolor'=>'#ffffff',
  427. 'vbgcolor'=>'#81a2b6',
  428. 'hbgcolor'=>'#81a2b6',
  429. 'vfstyle'=>'Verdana, Arial, Helvetica',
  430. 'hfstyle'=>'Verdana, Arial, Helvetica',
  431. 'scale'=>100/$largest,
  432. 'namebgcolor'=>'#f3f5fe',
  433. 'valuebgcolor'=>'#f3f5fe',
  434. 'namefcolor'=>'',
  435. 'valuefcolor'=>'#0000d0',
  436. 'namefstyle'=>'Verdana, Arial, Helvetica',
  437. 'valuefstyle'=>'',
  438. 'doublefcolor'=>'#ff7339');
  439. return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
  440. }
  441. ////
  442. // draws a double vertical bar graph for the banner views vs clicks statistics
  443. function zen_banner_graph_daily($banner_id) {
  444. global $db, $banner, $_GET;
  445. $year = (isset($_GET['year']) ? $_GET['year'] : date('Y'));
  446. $month = (isset($_GET['month']) ? $_GET['month'] : date('n'));
  447. $days = (date('t', mktime(0,0,0,$month))+1);
  448. $stats = array();
  449. for ($i=1; $i<$days; $i++) {
  450. $names[] = $i;
  451. $values[] = '0';
  452. $dvalues[] = '0';
  453. }
  454. $banner_stats = $db->Execute("select dayofmonth(banners_history_date) as banner_day,
  455. banners_shown as value, banners_clicked as dvalue
  456. from " . TABLE_BANNERS_HISTORY . "
  457. where banners_id = '" . $banner_id . "'
  458. and month(banners_history_date) = '" . $month . "'
  459. and year(banners_history_date) = '" . $year . "'");
  460. while (!$banner_stats->EOF) {
  461. $names[($banner_stats->fields['banner_day']-1)] = $banner_stats->fields['banner_day'];
  462. $values[($banner_stats->fields['banner_day']-1)] = (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0');
  463. $dvalues[($banner_stats->fields['banner_day']-1)] = (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0');
  464. $banner_stats->MoveNext();
  465. }
  466. $largest = @max($values);
  467. $bars = array();
  468. $dbars = array();
  469. for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
  470. $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif';
  471. $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif';
  472. }
  473. $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA,
  474. 'hlabel'=>sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner->fields['banners_title'], strftime('%B', mktime(0,0,0,$month)), $year),
  475. 'type'=>'3',
  476. 'cellpadding'=>'',
  477. 'cellspacing'=>'1',
  478. 'border'=>'',
  479. 'width'=>'',
  480. 'vfcolor'=>'#ffffff',
  481. 'hfcolor'=>'#ffffff',
  482. 'vbgcolor'=>'#81a2b6',
  483. 'hbgcolor'=>'#81a2b6',
  484. 'vfstyle'=>'Verdana, Arial, Helvetica',
  485. 'hfstyle'=>'Verdana, Arial, Helvetica',
  486. 'scale'=>100/$largest,
  487. 'namebgcolor'=>'#f3f5fe',
  488. 'valuebgcolor'=>'#f3f5fe',
  489. 'namefcolor'=>'',
  490. 'valuefcolor'=>'#0000d0',
  491. 'namefstyle'=>'Verdana, Arial, Helvetica',
  492. 'valuefstyle'=>'',
  493. 'doublefcolor'=>'#ff7339');
  494. return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars);
  495. }
  496. ?>