diff --git a/api/v1/class/arbeitszeit.inc.php b/api/v1/class/arbeitszeit.inc.php index db611a2..73477bb 100644 --- a/api/v1/class/arbeitszeit.inc.php +++ b/api/v1/class/arbeitszeit.inc.php @@ -924,8 +924,8 @@ public function renderGUIUpdateCheck() { $text = ""; - $current = $this->getTimeTrackVersion(); - $latest = $this->checkForUpdate(); + $current = trim($this->getTimeTrackVersion()); + $latest = trim($this->checkForUpdate()); if ($this->checkForUpdate() != false) { diff --git a/api/v1/class/exports/modules/PDFExportModule/PDFExportModule.em.arbeit.inc.php b/api/v1/class/exports/modules/PDFExportModule/PDFExportModule.em.arbeit.inc.php index 2fe1675..3de0d85 100644 --- a/api/v1/class/exports/modules/PDFExportModule/PDFExportModule.em.arbeit.inc.php +++ b/api/v1/class/exports/modules/PDFExportModule/PDFExportModule.em.arbeit.inc.php @@ -8,36 +8,54 @@ /** * PDFExportModule - Allows you to export worktime sheets */ -class PDFExportModule implements ExportModuleInterface { - public function export($args) { - $i18n = new i18n; - $arbeit = new Arbeitszeit; - $user = $args["user"]; - $month = $args["month"]; - $year = $args["year"]; - $i18nn = $i18n->loadLanguage(null, "class/pdf"); - $ini = Arbeitszeit::get_app_ini(); - $hours = $arbeit->calculate_hours_specific_time($user, $month, $year); - if(is_string($year) != true){ - $year = date("Y"); - } - $sql = "SELECT * FROM `arbeitszeiten` WHERE YEAR(schicht_tag) = ? AND MONTH(schicht_tag) = ? AND username = ? ORDER BY schicht_tag DESC;"; - $statement = $arbeit->db()->sendQuery($sql); - $userdata = $statement->execute([$year, $month, $user]); - if($userdata == false){ - Exceptions::error_rep("An error occurred while generating worktime pdf. See previous message for more information"); - die("An error occurred!"); - } - $user_data = Benutzer::get_user($user); - $user_data["name"] ?? $statement->fetch(\PDO::FETCH_ASSOC)[0]["name"]; # Bug 14 Fix -> http://bugzilla.openducks.org/show_bug.cgi?id=14 - try { - $css = @file_get_contents($ini["exports"]["pdf"]["css"]); - } catch (\ValueError $e) { - $css = file_get_contents(__DIR__ . "/css/index.css"); - } - $data = <<< DATA +class PDFExportModule implements ExportModuleInterface +{ + + function loadUserContent(string $file): string + { + if (!is_file($file)) { + return ''; + } + + ob_start(); + include $file; + return ob_get_clean(); + } + + + public function export($args) + { + $i18n = new i18n; + $arbeit = new Arbeitszeit; + $user = $args["user"]; + $month = $args["month"]; + $year = $args["year"]; + $i18nn = $i18n->loadLanguage(null, "class/pdf"); + $ini = Arbeitszeit::get_app_ini(); + $hours = $arbeit->calculate_hours_specific_time($user, $month, $year); + if (is_string($year) != true) { + $year = date("Y"); + } + $userGeneratedBeginning = $this->loadUserContent(__DIR__ . '/php/user_content_beginning.php') ?? ""; + $userGeneratedEnding = $this->loadUserContent(__DIR__ . '/php/user_content_ending.php') ?? ""; + $sql = "SELECT * FROM `arbeitszeiten` WHERE YEAR(schicht_tag) = ? AND MONTH(schicht_tag) = ? AND username = ? ORDER BY schicht_tag DESC;"; + $statement = $arbeit->db()->sendQuery($sql); + $userdata = $statement->execute([$year, $month, $user]); + if ($userdata == false) { + Exceptions::error_rep("An error occurred while generating worktime pdf. See previous message for more information"); + die("An error occurred!"); + } + $user_data = Benutzer::get_user($user); + $user_data["name"] ?? $statement->fetch(\PDO::FETCH_ASSOC)[0]["name"]; # Bug 14 Fix -> http://bugzilla.openducks.org/show_bug.cgi?id=14 + try { + $css = @file_get_contents($ini["exports"]["pdf"]["css"]); + } catch (\ValueError $e) { + $css = file_get_contents(__DIR__ . "/css/index.css"); + } + $data = << + {$userGeneratedBeginning}

{$i18nn["worktime_note"]} {$user_data["name"]}