OXID eShop CE  4.8.12
 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 {
14  protected $_sThisTemplate = "report_user_per_group.tpl";
15 
21  public function drawReport()
22  {
23  $sQ = "SELECT 1 FROM oxobject2group, oxuser, oxgroups
24  WHERE oxobject2group.oxobjectid = oxuser.oxid AND
25  oxobject2group.oxgroupsid = oxgroups.oxid";
26  return oxDb::getDb()->getOne( $sQ );
27  }
28 
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  $graph->setBackgroundImage( $myConfig->getImageDir(true)."/reportbgrnd.jpg", BGIMG_FILLFRAME);
74  $graph->setShadow();
75 
76  // Set title and subtitle
77  //$graph->title->set($this->aTitles[$myConfig->getConfigParam( 'iAdminLanguage' ) ]);
78  $graph->title->set($this->aTitles[oxRegistry::getLang()->getObjectTplLanguage() ]);
79 
80  // Use built in font
81  $graph->title->setFont(FF_FONT1, FS_BOLD);
82 
83  // Create the bar plot
84  $bplot = new PiePlot3D($aDataX);
85 
86  $bplot->setSize(0.4);
87  $bplot->setCenter(0.5, 0.32);
88 
89  // explodes all chunks of Pie from center point
90  $bplot->explodeAll(10);
91  $iUserCount = 0;
92  foreach ($aDataX as $iVal)
93  $iUserCount += $iVal;
94  for ($iCtr = 0; $iCtr < count($aDataX); $iCtr++) {
95  $iSLeng = strlen($aDataY[$iCtr]);
96  if ($iSLeng > 20) {
97  if ($iSLeng > 23)
98  $aDataY[$iCtr] = trim(substr($aDataY[$iCtr], 0, 20))."...";
99 
100  }
101  $aDataY[$iCtr] .= " - ".$aDataX[$iCtr]." Kund.";
102  }
103  $bplot->setLegends($aDataY);
104 
105  if (count($aDataX) > 10) {
106  $graph->legend->pos(0.49, 0.66, 'center');
107  $graph->legend->setFont(FF_FONT0, FS_NORMAL);
108  $graph->legend->setColumns(4);
109  } else {
110  $graph->legend->pos(0.49, 0.70, 'center');
111  $graph->legend->setFont(FF_FONT1, FS_NORMAL);
112  $graph->legend->setColumns(2);
113  }
114 
115  $graph->add($bplot);
116 
117  // Finally output the image
118  $graph->stroke();
119  }
120 }
121 }