PageRenderTime 36ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/statistic/admin/country_graph.php

https://gitlab.com/alexprowars/bitrix
PHP | 100 lines | 66 code | 14 blank | 20 comment | 9 complexity | f32aaa1bc982febb62210dbe7bf873d7 MD5 | raw file
  1. <?php
  2. define("STOP_STATISTICS", true);
  3. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
  4. /** @var CMain $APPLICATION */
  5. $STAT_RIGHT = $APPLICATION->GetGroupRight("statistic");
  6. if($STAT_RIGHT=="D") $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
  7. include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/statistic/colors.php");
  8. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/img.php");
  9. $width = intval($_GET["width"]);
  10. $max_width = COption::GetOptionInt("statistic", "GRAPH_WEIGHT");
  11. if($width <= 0 || $width > $max_width)
  12. $width = $max_width;
  13. $height = intval($_GET["height"]);
  14. $max_height = COption::GetOptionInt("statistic", "GRAPH_HEIGHT");
  15. if($height <= 0 || $height > $max_height)
  16. $height = $max_height;
  17. // create image
  18. $ImageHandle = CreateImageHandle($width, $height);
  19. $arrX=Array(); // data points X
  20. $arrY=Array(); // data points Y
  21. $arrayX=Array(); // axis X
  22. $arrayY=Array(); // axis Y
  23. /******************************************************
  24. Get data
  25. *******************************************************/
  26. $str = (is_array($find_country_id)) ? implode(" | ",$find_country_id) : "";
  27. $arF = array(
  28. "COUNTRY_ID" => $str,
  29. "DATE1" => $find_date1,
  30. "DATE2" => $find_date2
  31. );
  32. $arrDays = CCountry::GetGraphArray($arF, $arrLegend);
  33. foreach ($arrDays as $keyD => $arD)
  34. {
  35. $date = mktime(0,0,0,$arD["M"],$arD["D"],$arD["Y"]);
  36. $date_tmp = 0;
  37. $next_date = AddTime($prev_date,1,"D");
  38. if ($date>$next_date && intval($prev_date)>0)
  39. {
  40. $date_tmp = $next_date;
  41. while ($date_tmp<$date)
  42. {
  43. $arrX[] = $date_tmp;
  44. foreach ($arrLegend as $keyL => $arrL)
  45. {
  46. $arrY_data[$keyL][] = 0;
  47. $arrY[] = 0;
  48. }
  49. $date_tmp = AddTime($date_tmp,1,"D");
  50. }
  51. }
  52. $arrX[] = $date;
  53. foreach ($arrLegend as $keyL => $arrL)
  54. {
  55. $value = $arD[$keyL][$find_data_type];
  56. $arrY_data[$keyL][] = $value;
  57. $arrY[] = $value;
  58. }
  59. $prev_date = $date;
  60. }
  61. /******************************************************
  62. Axes X
  63. *******************************************************/
  64. $arrayX = GetArrayX($arrX, $MinX, $MaxX);
  65. /******************************************************
  66. Axes Y
  67. *******************************************************/
  68. $arrayY = GetArrayY($arrY, $MinY, $MaxY);
  69. /******************************************************
  70. Draw grid
  71. *******************************************************/
  72. DrawCoordinatGrid($arrayX, $arrayY, $width, $height, $ImageHandle);
  73. /******************************************************
  74. Plot data
  75. *******************************************************/
  76. foreach ($arrLegend as $keyL => $arrL)
  77. {
  78. if ($keyL <> '')
  79. {
  80. Graf($arrX, $arrY_data[$keyL], $ImageHandle, $MinX, $MaxX, $MinY, $MaxY, $arrL["COLOR"]);
  81. }
  82. }
  83. /******************************************************
  84. Send image
  85. *******************************************************/
  86. ShowImageHeader($ImageHandle);