app = &$app; $this->background = false; $this->labels = false; $this->animate = true; $this->type = $type; $this->sql =""; $this->limit =""; $this->stacked = false; $this->duration = 1000; $this->datasets = null; $this->headings = null; $this->lheadings = null; $this->yAxes = null; $this->colorcol = false; $this->colors = array( '45b9d3','a2c55a','0e8394','f69e06','f2c289','8dd4de','cbe0a4','c5e3e9', '0b8092', 'a9ca45', 'FF6600','f69e06', 'be3978', 'cb5a20', '41b3ce', '85cddb', '000000', '993300', '333300', '000080', '333399', '333333', '800000', '808000', '008000', '008080', '0000FF', '666699', '808080', 'FF0000', 'FF9900', '99CC00', '339966', '33CCCC', '3366FF', '800080', '999999', 'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0', 'FF99CC', 'FFCC99', 'FFFF99', 'CCFFFF', '99CCFF', '808cc8', 'FFFFFF'); foreach($this->colors as $k => $v)$this->colors[$k] = '#'.$v; self::$instancescount++; if(false && self::$instancescount == 1) { $this->app->Tpl->Add($targetjquery,' Chart.pluginService.register({ beforeRender: function (chart) { if (chart.config.options.showAllTooltips) { chart.pluginTooltips = []; chart.config.data.datasets.forEach(function (dataset, i) { chart.getDatasetMeta(i).data.forEach(function (sector, j) { chart.pluginTooltips.push(new Chart.Tooltip({ _chart: chart.chart, _chartInstance: chart, _data: chart.data, _options: chart.options.tooltips, _active: [sector] }, chart)); }); }); chart.options.tooltips.enabled = false; } }, afterDraw: function (chart, easing) { if (chart.config.options.showAllTooltips) { if (!chart.allTooltipsOnce) { if (easing !== 1) return; chart.allTooltipsOnce = true; } chart.options.tooltips.enabled = true; Chart.helpers.each(chart.pluginTooltips, function (tooltip) { tooltip.initialize(); tooltip.update(); tooltip.pivot(); tooltip.transition(easing).draw(); }); chart.options.tooltips.enabled = false; } } }); '); } } function AddRow($rows) { $this->datasets[] = $rows; } function Query($sql,$labels=false,$fuelleluecken = false,$limit="") { $this->labels = $labels; $this->sql = $sql; $this->limit= $limit; $this->headings=null; $xcol = 0; if($limit!=0){ $page = $this->app->Secure->GetGET("page"); if(!is_numeric($page)) $page = 1; $this->page = $page; $this->start= ($page-1) * $this->limit; if(!is_array($sql))$sql.= " LIMIT {$this->start},{$this->limit}"; } $this->searchrow=""; if(is_array($sql)) { $daten = $sql; }else{ $daten = $this->app->DB->SelectArr($sql); } if(count($daten)>0){ foreach($daten[0] as $colkey=>$value) { $this->headings[]=ucfirst($colkey); $this->lheadings[] = $colkey; $empty[$colkey] = 0; } } $first = $daten[0][$this->lheadings[$xcol]]; $mysqlformat = true; if(strpos($first,'.') !== false)$mysqlformat = false; $last = $daten[count($fuelleluecken) - 1][$this->lheadings[$xcol]]; if($fuelleluecken && is_array($fuelleluecken) && isset($fuelleluecken['typ'])) { $von = false; $bis = false; $zeitraum = false; if(isset($fuelleluecken['von'])) { $von = $fuelleluecken['von']; } if(isset($fuelleluecken['bis'])) { $bis = $fuelleluecken['bis']; } if(isset($fuelleluecken['zeitraum'])) { $zeitraum = $fuelleluecken['zeitraum']; } if($von || $bis || $zeitraum) { switch($fuelleluecken['typ']) { case 'tag': case 'tage': if(!$von && !$bis) { $bis = date('Y-m-d'); $date=new DateTime(date('Y-m-d')); $date->sub(new DateInterval('P'.$zeitraum.'D')); $von = $date->format('Y-m-d'); }elseif(!$von) { if(strpos($bis, '.') !== false)$bis = $this->app->String->Convert($bis, "%1.%2.%3","%3-%2-%1"); $date=new DateTime($bis); $date->sub(new DateInterval('P'.$zeitraum.'D')); $von = $date->format('Y-m-d'); }elseif(!$bis) { if(strpos($von, '.') !== false)$von = $this->app->String->Convert($von, "%1.%2.%3","%3-%2-%1"); $date=new DateTime($von); $date->add(new DateInterval('P'.$zeitraum.'D')); $bis = $date->format('Y-m-d'); } if($von && $bis) { $datetime1 = new DateTime($bis); $datetime2 = new DateTime($von); $interval = $datetime1->diff($datetime2); $zeitraum = $interval->format('%a'); foreach($daten as $key => $data) { $aktdat = $data[$this->lheadings[$xcol]]; if(strpos($aktdat,'.') !== false)$aktdat = $this->app->String->Convert($aktdat ,"%1.%2.%3","%3-%2-%1"); $datumzuid[$aktdat] = $key; } $aktdat = $datetime2; for($i = 0; $i <= $zeitraum; $i++) { if($i > 0)$aktdat->add(new DateInterval('P1D')); $aktdatstr = $aktdat->format('Y-m-d'); if(isset($datumzuid[$aktdatstr])) { $this->datasets[] = $daten[$datumzuid[$aktdatstr]]; }else{ if($mysqlformat) { $empty[$this->lheadings[$xcol]] = $aktdatstr; }else{ $empty[$this->lheadings[$xcol]] = $this->app->String->Convert($aktdatstr,"%3-%2-%1","%1.%2.%3"); } $this->datasets[] = $empty; } } } break; case 'monat': case 'monate': if(!$von && !$bis) { $bis = date('m/Y'); $date=new DateTime(date("Y-m-d")); $date->sub(new DateInterval('P'.($zeitraum-1).'M')); $von = $date->format('m/Y'); }elseif(!$von) { if(strpos($bis, '.') !== false)$bis = $this->app->String->Convert($bis, "%1.%2.%3","%2\/%3"); $date=new DateTime($bis); $date->sub(new DateInterval('P'.($zeitraum-1).'M')); $von = $date->format('m/Y'); }elseif(!$bis) { if(strpos($von, '.') !== false)$von = $this->app->String->Convert($von, "%1.%2.%3","%2\/%3"); $date=new DateTime($von); $date->add(new DateInterval('P'.($zeitraum-1).'M')); $bis = $date->format('m/Y'); } if($von && $bis) { $von = $this->app->String->Convert($von,"%2\/%3","%3-%2-01"); $bis = $this->app->String->Convert($bis,"%2\/%3","%3-%2-01"); $datetime1 = new DateTime($bis); $datetime2 = new DateTime($von); $interval = $datetime1->diff($datetime2); $zeitraum = ($interval->format('%d') > 27?1:0)+$interval->format('%m')+12*$interval->format('%y'); $_zeitbis = new DateTime($bis); $_zeitbis->add(new DateInterval('P'.$zeitraum.'M')); if($datetime1->format('m/Y') != $_zeitbis->format('m/Y'))$zeitraum++; foreach($daten as $key => $data) { $aktdat = $data[$this->lheadings[$xcol]]; if(strpos($aktdat,'.') !== false)$aktdat = $this->app->String->Convert($aktdat ,"%1.%2.%3","%2\/%3"); $datumzuid[$aktdat] = $key; } $aktdat = $datetime2; for($i = 0; $i < $zeitraum; $i++) { if($i > 0)$aktdat->add(new DateInterval('P1M')); $aktdatstr = $aktdat->format('m/Y'); if(isset($datumzuid[$aktdatstr])) { $this->datasets[] = $daten[$datumzuid[$aktdatstr]]; }else{ if($mysqlformat) { $empty[$this->lheadings[$xcol]] = $aktdatstr; }else{ $empty[$this->lheadings[$xcol]] = $this->app->String->Convert($aktdatstr,"%1.%2.%3","%2\/%3"); } $this->datasets[] = $empty; } } } break; } }else{ $this->datasets = $daten; } } else { $this->datasets = $daten; } } function kommulieren() { if($this->datasets) { foreach($this->datasets as $k => $row) { $first = true; foreach($row as $key => $v) { if($first) { $first = false; }else{ if(!isset($sum[$key]))$sum[$key] = 0; $sum[$key] += $v; $this->datasets[$k][$key] = $sum[$key]; } } } } } function replaceLabelsDate($label) { if(preg_match_all('/^[1-2]{1}[0-9]{3}\-[0-1]{1}[0-9]{1}\-[0-3]{1}[0-9]{1}$/', $label, $erg))$label = $this->app->String->Convert($label, '%1-%2-%3', '%3.%2.%1'); return $label; } // Fügt $value in $array ein, an der Stelle $index function array_insert($array, $index, $value) { return array_merge(array_slice($array, 0, $index), $value, array_slice($array, $index)); } function DisplayWithBox($parsetarget,$id,$name,$width = "300",$height = "250",$style="") { $this->calcbcolors(); $_width = $width; $this->app->Tpl->Add($parsetarget, '