Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions inc/baseclass.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
class PluginMreportingBaseclass
{
protected $sql_date;
protected $sql_closedate;
protected $sql_date_create;
protected $sql_date_solve;
protected $sql_date_closed;
Expand Down
66 changes: 33 additions & 33 deletions inc/graphpng.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public function initGraph($options)
$width = $this->width + 100;

if (!isset($_REQUEST['date1' . $randname])) {
$_REQUEST['date1' . $randname] = strftime('%Y-%m-%d', time()
$_REQUEST['date1' . $randname] = date('Y-m-d', time()
- ($options['delay'] * 24 * 60 * 60));
}
if (!isset($_REQUEST['date2' . $randname])) {
$_REQUEST['date2' . $randname] = strftime('%Y-%m-%d');
$_REQUEST['date2' . $randname] = date('Y-m-d');
}

$backtrace = debug_backtrace();
Expand Down Expand Up @@ -404,13 +404,13 @@ public function imageSmoothAlphaLine($image, $x1, $y1, $x2, $y2, $dcol)
continue;
}

$trgb = ImageColorAt($image, $x, (int) floor($y));
$trgb = ImageColorAt($image, (int) floor($x), (int) floor($y));
$tcr = ($trgb >> 16) & 0xFF;
$tcg = ($trgb >> 8) & 0xFF;
$tcb = $trgb & 0xFF;
imagesetpixel(
$image,
$x,
(int) floor($x),
(int) floor($y),
imagecolorallocatealpha(
$image,
Expand All @@ -421,13 +421,13 @@ public function imageSmoothAlphaLine($image, $x1, $y1, $x2, $y2, $dcol)
),
);

$trgb = ImageColorAt($image, $x, (int) ceil($y));
$trgb = ImageColorAt($image, (int) ceil($x), (int) ceil($y));
$tcr = ($trgb >> 16) & 0xFF;
$tcg = ($trgb >> 8) & 0xFF;
$tcb = $trgb & 0xFF;
imagesetpixel(
$image,
$x,
(int) ceil($x),
(int) ceil($y),
imagecolorallocatealpha(
$image,
Expand Down Expand Up @@ -681,9 +681,9 @@ public function showHbar($params, $dashboard = false, $width = false)
$index = 0;
foreach ($datas as $label => $data) {
$bx1 = 250;
$by1 = ($index + 1) * 1.25 * $height_bar + .05 * $height + 2;
$by1 = round(($index + 1) * 1.25 * $height_bar + .05 * $height + 2);
$bx2 = $bx1 + round(($data * ($width - 300)) / $max);
$by2 = $by1 + $height_bar;
$by2 = round($by1 + $height_bar);

//createbar
ImageFilledRectangle($image, $bx1, (int) $by1, (int) $bx2, (int) $by2, hexdec($palette[$index]));
Expand Down Expand Up @@ -922,8 +922,8 @@ public function showPie($params, $dashboard = false, $width = false)

//text associated with pie arc (only for angle > 2°)
if ($angle > 2 && ($show_label == 'always' || $show_label == 'hover')) {
$xtext = $x - 1 + cos(deg2rad(($start_angle + $angle) / 2)) * ($radius / 1.7);
$ytext = $y + 5 - sin(deg2rad(($start_angle + $angle) / 2)) * ($radius / 1.7);
$xtext = round($x - 1 + cos(deg2rad(($start_angle + $angle) / 2)) * ($radius / 1.7));
$ytext = round($y + 5 - sin(deg2rad(($start_angle + $angle) / 2)) * ($radius / 1.7));
imagettftext(
$image,
$this->fontsize,
Expand Down Expand Up @@ -1274,12 +1274,12 @@ public function drawSunburstLevel($image, $datas, $params = [])
//define label position
if (is_array($data)) {
//show label inside its arc
$xtext = $x - $dx * $tw + cos($amr) * (0.5 * $radius - $step / 3);
$ytext = $y + $dy * $th - sin($amr) * (0.5 * $radius - $step / 4);
$xtext = round($x - $dx * $tw + cos($amr) * (0.5 * $radius - $step / 3));
$ytext = round($y + $dy * $th - sin($amr) * (0.5 * $radius - $step / 4));
} else {
//show label outside of its arc
$xtext = $x + 3 - $dx * $tw + cos($amr) * (0.5 * $radius + $step / 16);
$ytext = $y + $dy * $th - sin($amr) * (0.5 * $radius + $step / 8);
$xtext = round($x + 3 - $dx * $tw + cos($amr) * (0.5 * $radius + $step / 16));
$ytext = round($y + $dy * $th - sin($amr) * (0.5 * $radius + $step / 8));
}

//draw label
Expand Down Expand Up @@ -1310,8 +1310,8 @@ public function drawSunburstLevel($image, $datas, $params = [])
$th = abs($box[5] - $box[1]);

//define label position
$xtext = $x - $dx * $tw + cos($samr) * (0.5 * $radius - $step / 8);
$ytext = $y + $dy * $th - sin($samr) * (0.5 * $radius - $step / 16);
$xtext = round($x - $dx * $tw + cos($samr) * (0.5 * $radius - $step / 8));
$ytext = round($y + $dy * $th - sin($samr) * (0.5 * $radius - $step / 16));

//draw label
imagettftext(
Expand Down Expand Up @@ -1715,10 +1715,10 @@ public function showVstackbar($params, $dashboard = false, $width = false)
if ($dashboard) {
$height = 350;
}
$x_bar = (0.85 * $this->width / $nb_bar);
$width_bar = $x_bar * .85;
$y_labels_width = .1 * $this->width;
$x_labels_height = $height - 0.95 * $height;
$x_bar = round(0.85 * $this->width / $nb_bar);
$width_bar = round($x_bar * .85);
$y_labels_width = round(.1 * $this->width);
$x_labels_height = round($height - 0.95 * $height);
$legend_height = $nb_labels2 * 15 + 10;

//longueur du texte en dessous des barres
Expand Down Expand Up @@ -1753,8 +1753,8 @@ public function showVstackbar($params, $dashboard = false, $width = false)
//draw x-axis grey step line and values ticks
$xstep = round(($height - $legend_height - $x_labels_height) / 12);
for ($i = 0; $i <= 12; $i++) {
$yaxis = $height - $x_labels_height - $xstep * $i;
imageLine($image, (int) (.9 * $y_labels_width), (int) $yaxis, (int) (0.95 * $this->width), (int) $yaxis, hexdec($this->grey));
$yaxis = round($height - $x_labels_height - $xstep * $i);
imageLine($image, (int) round(.9 * $y_labels_width), (int) $yaxis, (int) round(0.95 * $this->width), (int) $yaxis, hexdec($this->grey));

//value label
$val = round($i * $cum / 12, 1);
Expand Down Expand Up @@ -1822,7 +1822,7 @@ public function showVstackbar($params, $dashboard = false, $width = false)
foreach ($data as $subdata) {
$by1 = $by2;
$bx1 = $y_labels_width + $index1 * $x_bar;
$by2 = $by1 - $subdata * ($height - $legend_height - $x_labels_height) / $cum;
$by2 = round($by1 - $subdata * ($height - $legend_height - $x_labels_height) / $cum);
$bx2 = $bx1 + $width_bar;

if ($by1 != $by2) { // no draw for empty datas
Expand Down Expand Up @@ -1855,7 +1855,7 @@ public function showVstackbar($params, $dashboard = false, $width = false)
$textwidth = abs($box[4] - $box[6]);
$textwidth = abs(sqrt((pow($textwidth, 2) / 2)));

$lx = $y_labels_width + $index1 * $x_bar + ($width_bar / 2.5);
$lx = round($y_labels_width + $index1 * $x_bar + ($width_bar / 2.5));
imagettftext(
$image,
$this->fontsize - 1,
Expand Down Expand Up @@ -2030,7 +2030,7 @@ public function showArea($params, $dashboard = false, $width = false)
$nb = count($datas);
$width = $this->width;
$height = 350;
$width_line = ($width - 45) / $nb;
$width_line = (int) round(($width - 45) / $nb);
$step = ceil($nb / 20);

//create image
Expand Down Expand Up @@ -2125,9 +2125,9 @@ public function showArea($params, $dashboard = false, $width = false)

// determine coords
$x1 = $index * $width_line - $width_line + 30;
$y1 = $height - 30 - $old_data * ($height - 85) / $max;
$y1 = floor($height - 30 - $old_data * ($height - 85) / $max);
$x2 = $x1 + $width_line;
$y2 = $height - 30 - $data * ($height - 85) / $max;
$y2 = floor($height - 30 - $data * ($height - 85) / $max);
$aCoords[$x1] = $y1;

//in case of area chart fill under point space
Expand Down Expand Up @@ -2170,9 +2170,9 @@ public function showArea($params, $dashboard = false, $width = false)

// determine coords
$x1 = $index * $width_line - $width_line + 30;
$y1 = $height - 30 - $old_data * ($height - 85) / $max;
$y1 = (int) floor($height - 30 - $old_data * ($height - 85) / $max);
$x2 = $x1 + $width_line;
$y2 = $height - 30 - $data * ($height - 85) / $max;
$y2 = (int) floor($height - 30 - $data * ($height - 85) / $max);

//trace dots
$color_rbg = self::colorHexToRGB($darkerpalette[0]);
Expand Down Expand Up @@ -2372,7 +2372,7 @@ public function showGArea($params, $dashboard = false, $width = false)
$nb_bar = count($labels2);
$nb_labels2 = count($datas);

$width_line = ($this->width - 45) / $nb;
$width_line = (int) floor(($this->width - 45) / $nb);
$index1 = 0;
$index3 = 1;
$step = ceil($nb / 21);
Expand Down Expand Up @@ -2479,10 +2479,10 @@ public function showGArea($params, $dashboard = false, $width = false)
}

// determine coords
$x1 = $index2 * $width_line - $width_line + $x_bar;
$y1 = $height - $x_labels_height - $old_data * ($height - $legend_height - $x_labels_height) / $max;
$x1 = $index2 * $width_line - $width_line + $x_bar;
$y1 = (int) round($height - $x_labels_height - $old_data * ($height - $legend_height - $x_labels_height) / $max);
$x2 = $x1 + $width_line;
$y2 = $height - $x_labels_height - $subdata * ($height - $legend_height - $x_labels_height) / $max;
$y2 = (int) round($height - $x_labels_height - $subdata * ($height - $legend_height - $x_labels_height) / $max);

//in case of area chart fill under point space
if ($area > 0) {
Expand Down
2 changes: 1 addition & 1 deletion inc/helpdesk.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ public function reportVstackbarTicketStatusByTechnician($config = [])
foreach ($technicians as $technician) {
$datas['datas'][$current_status][$technician['username']] = 0;

$fullname = trim($technician['fullname']);
$fullname = trim($technician['fullname'] ?? "");
if (!empty($fullname)) {
$datas['labels2'][$technician['username']] = $fullname;
} else {
Expand Down
24 changes: 16 additions & 8 deletions inc/notificationtargetnotification.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,25 @@ private function buildPDF($user_name = '')
$image_width = imagesx($image);
$image_height = imagesy($image);

$format = '%e';
Comment thread
Vireth4114 marked this conversation as resolved.
if (strftime('%Y', strtotime($graph['start'])) != strftime('%Y', strtotime($graph['end']))) {
$format .= ' %B %Y';
} elseif (strftime('%B', strtotime($graph['start'])) != strftime('%B', strtotime($graph['end']))) {
$format .= ' %B';
$start = new DateTime($graph['start']);
$end = new DateTime($graph['end']);

$format = 'd';
if ($start->format('Y') != $end->format('Y')) {
$format .= ' MMMM y';
} elseif ($start->format('F') != $end->format('F')) {
$format .= ' MMMM';
}

$language = $_SESSION['glpilanguage'] ?? 'en_GB';
$image_title = $LANG['plugin_mreporting'][$graph['class']][$graph['method']]['title'];
$image_title .= ' du ' . strftime($format, strtotime($graph['start']));
$image_title .= ' au ' . strftime('%e %B %Y', strtotime($graph['end']));

$image_title .= ' ' . lcfirst(
sprintf(
__('From %1$s to %2$s'),
IntlDateFormatter::formatObject($start, $format, $language),
IntlDateFormatter::formatObject($end, 'd MMMM Y', $language),
),
);
array_push($images, ['title' => $image_title,
'base64' => $image_base64,
'width' => $image_width,
Expand Down
2 changes: 1 addition & 1 deletion lib/cubic_splines/classes/CubicSplines.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private function funcInterp($x)
$i = 0;
$j = $n - 1;
while ($i + 1 < $j) {
$k = $i + ($j - $i) / 2;
$k = floor($i + ($j - $i) / 2);
if ($x <= $this->aSplines[$k]['x']) {
$j = $k;
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/cubic_splines/classes/Plot.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function drawAxis($vImage, $vColor, $iPosX = 0, $iPosY = false)
imageline($vImage, $iPosX, $iPosY, $iPosX, 0, $vColor);
imageline($vImage, $iPosX, $iPosY, $vImageWidth, $iPosY, $vColor);

imagefilledpolygon($vImage, [$iPosX, 0, $iPosX - 3, 5, $iPosX + 3, 5], 3, $vColor);
imagefilledpolygon($vImage, [$vImageWidth, $iPosY, $vImageWidth - 5, $iPosY - 3, $vImageWidth - 5, $iPosY + 3], 3, $vColor);
imagefilledpolygon($vImage, [$iPosX, 0, $iPosX - 3, 5, $iPosX + 3, 5], $vColor);
imagefilledpolygon($vImage, [$vImageWidth, $iPosY, $vImageWidth - 5, $iPosY - 3, $vImageWidth - 5, $iPosY + 3], $vColor);
}
}
Loading