Go to the documentation of this file.00001 <?php
00002
00003 if (!class_exists("report_user_per_group")) {
00007 class Report_user_per_group extends report_base
00008 {
00009
00015 protected $_sThisTemplate = "report_user_per_group.tpl";
00016
00022 public function drawReport()
00023 {
00024 $sQ = "SELECT 1 FROM oxobject2group, oxuser, oxgroups
00025 WHERE oxobject2group.oxobjectid = oxuser.oxid AND
00026 oxobject2group.oxgroupsid = oxgroups.oxid";
00027
00028 return oxDb::getDb()->getOne($sQ);
00029 }
00030
00034 public function user_per_group()
00035 {
00036 $myConfig = $this->getConfig();
00037 $oDb = oxDb::getDb();
00038
00039 global $aTitles;
00040
00041 $aDataX = array();
00042 $aDataY = array();
00043
00044 $sSQL = "SELECT oxgroups.oxtitle,
00045 count(oxuser.oxid)
00046 FROM oxobject2group,
00047 oxuser,
00048 oxgroups
00049 WHERE oxobject2group.oxobjectid = oxuser.oxid AND
00050 oxobject2group.oxgroupsid = oxgroups.oxid
00051 GROUP BY oxobject2group.oxgroupsid
00052 ORDER BY oxobject2group.oxgroupsid";
00053
00054 $rs = $oDb->execute($sSQL);
00055 if ($rs != false && $rs->recordCount() > 0) {
00056 while (!$rs->EOF) {
00057 if ($rs->fields[1]) {
00058 $aDataX[] = $rs->fields[1];
00059 $aDataY[] = $rs->fields[0];
00060 }
00061 $rs->moveNext();
00062 }
00063 }
00064
00065 header("Content-type: image/png");
00066
00067
00068 if (count($aDataX) > 10) {
00069 $graph = new PieGraph(800, 830);
00070 } else {
00071 $graph = new PieGraph(600, 600);
00072 }
00073
00074 $graph->setBackgroundImage($myConfig->getImageDir(true) . "/reportbgrnd.jpg", BGIMG_FILLFRAME);
00075 $graph->setShadow();
00076
00077
00078
00079 $graph->title->set($this->aTitles[oxRegistry::getLang()->getObjectTplLanguage()]);
00080
00081
00082 $graph->title->setFont(FF_FONT1, FS_BOLD);
00083
00084
00085 $bplot = new PiePlot3D($aDataX);
00086
00087 $bplot->setSize(0.4);
00088 $bplot->setCenter(0.5, 0.32);
00089
00090
00091 $bplot->explodeAll(10);
00092 $iUserCount = 0;
00093 foreach ($aDataX as $iVal) {
00094 $iUserCount += $iVal;
00095 }
00096 for ($iCtr = 0; $iCtr < count($aDataX); $iCtr++) {
00097 $iSLeng = strlen($aDataY[$iCtr]);
00098 if ($iSLeng > 20) {
00099 if ($iSLeng > 23) {
00100 $aDataY[$iCtr] = trim(substr($aDataY[$iCtr], 0, 20)) . "...";
00101 }
00102
00103 }
00104 $aDataY[$iCtr] .= " - " . $aDataX[$iCtr] . " Kund.";
00105 }
00106 $bplot->setLegends($aDataY);
00107
00108 if (count($aDataX) > 10) {
00109 $graph->legend->pos(0.49, 0.66, 'center');
00110 $graph->legend->setFont(FF_FONT0, FS_NORMAL);
00111 $graph->legend->setColumns(4);
00112 } else {
00113 $graph->legend->pos(0.49, 0.70, 'center');
00114 $graph->legend->setFont(FF_FONT1, FS_NORMAL);
00115 $graph->legend->setColumns(2);
00116 }
00117
00118 $graph->add($bplot);
00119
00120
00121 $graph->stroke();
00122 }
00123 }
00124 }