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