OXID eShop CE  4.10.5
 All Classes Namespaces Files Functions Variables Pages
report_user_per_group.php
Go to the documentation of this file.
1 <?php
2 
3 if (!class_exists("report_user_per_group")) {
9  class Report_user_per_group extends report_base
10  {
11 
17  protected $_sThisTemplate = "report_user_per_group.tpl";
18 
24  public function drawReport()
25  {
26  $sQ = "SELECT 1 FROM oxobject2group, oxuser, oxgroups
27  WHERE oxobject2group.oxobjectid = oxuser.oxid AND
28  oxobject2group.oxgroupsid = oxgroups.oxid";
29 
30  return oxDb::getDb()->getOne($sQ);
31  }
32 
36  public function user_per_group()
37  {
38  $myConfig = $this->getConfig();
39  $oDb = oxDb::getDb();
40 
41  global $aTitles;
42 
43  $aDataX = array();
44  $aDataY = array();
45 
46  $sSQL = "SELECT oxgroups.oxtitle,
47  count(oxuser.oxid)
48  FROM oxobject2group,
49  oxuser,
50  oxgroups
51  WHERE oxobject2group.oxobjectid = oxuser.oxid AND
52  oxobject2group.oxgroupsid = oxgroups.oxid
53  GROUP BY oxobject2group.oxgroupsid
54  ORDER BY oxobject2group.oxgroupsid";
55 
56  $rs = $oDb->execute($sSQL);
57  if ($rs != false && $rs->recordCount() > 0) {
58  while (!$rs->EOF) {
59  if ($rs->fields[1]) {
60  $aDataX[] = $rs->fields[1];
61  $aDataY[] = $rs->fields[0];
62  }
63  $rs->moveNext();
64  }
65  }
66 
67  header("Content-type: image/png");
68 
69  // New graph with a drop shadow
70  if (count($aDataX) > 10) {
71  $graph = new PieGraph(800, 830);
72  } else {
73  $graph = new PieGraph(600, 600);
74  }
75 
76  $graph->setBackgroundImage($myConfig->getImageDir(true) . "/reportbgrnd.jpg", BGIMG_FILLFRAME);
77  $graph->setShadow();
78 
79  // Set title and subtitle
80  //$graph->title->set($this->aTitles[$myConfig->getConfigParam( 'iAdminLanguage' ) ]);
81  $graph->title->set($this->aTitles[oxRegistry::getLang()->getObjectTplLanguage()]);
82 
83  // Use built in font
84  $graph->title->setFont(FF_FONT1, FS_BOLD);
85 
86  // Create the bar plot
87  $bplot = new PiePlot3D($aDataX);
88 
89  $bplot->setSize(0.4);
90  $bplot->setCenter(0.5, 0.32);
91 
92  // explodes all chunks of Pie from center point
93  $bplot->explodeAll(10);
94  $iUserCount = 0;
95  foreach ($aDataX as $iVal) {
96  $iUserCount += $iVal;
97  }
98  for ($iCtr = 0; $iCtr < count($aDataX); $iCtr++) {
99  $iSLeng = strlen($aDataY[$iCtr]);
100  if ($iSLeng > 20) {
101  if ($iSLeng > 23) {
102  $aDataY[$iCtr] = trim(substr($aDataY[$iCtr], 0, 20)) . "...";
103  }
104 
105  }
106  $aDataY[$iCtr] .= " - " . $aDataX[$iCtr] . " Kund.";
107  }
108  $bplot->setLegends($aDataY);
109 
110  if (count($aDataX) > 10) {
111  $graph->legend->pos(0.49, 0.66, 'center');
112  $graph->legend->setFont(FF_FONT0, FS_NORMAL);
113  $graph->legend->setColumns(4);
114  } else {
115  $graph->legend->pos(0.49, 0.70, 'center');
116  $graph->legend->setFont(FF_FONT1, FS_NORMAL);
117  $graph->legend->setColumns(2);
118  }
119 
120  $graph->add($bplot);
121 
122  // Finally output the image
123  $graph->stroke();
124  }
125  }
126 }