From: Hamatoma Date: Wed, 26 Feb 2025 22:40:01 +0000 (+0100) Subject: V 0.2.7 ExportHelperLocal X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=88b3347772f7f40666e32e50d2ba2e1d11bfb082;p=oo4f.git V 0.2.7 ExportHelperLocal - ExportHelperLocal: exportHoursAsCsv improved --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 67ffa06..120b9ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# V 0.2.7 ExportHelperLocal + +- ExportHelperLocal: exportHoursAsCsv improved + # V 0.2.6 Hours - new: ExportHelperLocal diff --git a/app/Helpers/ExportHelperLocal.php b/app/Helpers/ExportHelperLocal.php index 6a53fc9..77ee85c 100644 --- a/app/Helpers/ExportHelperLocal.php +++ b/app/Helpers/ExportHelperLocal.php @@ -6,15 +6,50 @@ use App\Helpers\FileHelper; class ExportHelperLocal { + public static function formatDuration(int $duration): string + { + $rc = sprintf("%d:%02d", intval($duration / 60), intval($duration % 60)); + return $rc; + } public static function exportHoursAsCsv(array &$records): string { $dateStr = (new \DateTime())->format('Y.m.d'); $filename = FileHelper::buildExportName("hours.$dateStr", '.csv'); - $lines = ["Datum\tDauer\tTyp\tFaktor\tInteressierte\tBeschreibung\n"]; + $lines = ["Datum\tDauer\tTyp\tFaktor\tGesamtdauer\tInteressierte\tBeschreibung\n"]; + $sums = []; + $interesteds = []; foreach ($records as $record) { - $line = "$record->time\t$record->duration\t$record->hourtype\t$record->factor\t$record->interested\t$record->description\n"; + $date = DateTimeHelper::dBDateTimeToDateTime($record->time); + $date2 = DateTimeHelper::dateTimeToString($date, false); + $duration1 = ExportHelperLocal::formatDuration(intval($record->duration)); + $duration = intval($record->duration) * intval($record->factor); + $duration2 = ExportHelperLocal::formatDuration($duration); + $line = "$date2\t$duration1\t$record->hourtype\t$record->factor\t$duration2\t$record->interested\t$record->description\n"; + if (array_key_exists($record->hourtype, $sums)) { + $sums[$record->hourtype] += $duration; + } else { + $sums[$record->hourtype] = $duration; + } + if ($record->interested != null) { + + if (array_key_exists($record->hourtype, $interesteds)) { + $interesteds[$record->hourtype] += $record->interested; + } else { + $interesteds[$record->hourtype] = $record->interested; + } + } array_push($lines, $line); } + $line = "\nKategorie\tGesamtdauer\tInteressierte\n"; + foreach ($sums as $key => $value) { + $interested = array_key_exists($key, $interesteds) ? $interesteds[$key] : 0; + if ($interested == 0) { + $interested = ''; + } + $line .= "$key\t" . ExportHelperLocal::formatDuration(duration: $value) . "\t$interested\n"; + } + $line .= "\n"; + array_push($lines, $line); file_put_contents($filename, $lines); return $filename; } diff --git a/composer.lock b/composer.lock index 5972a05..5c1c21d 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "brick/math", - "version": "0.12.1", + "version": "0.12.2", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "f510c0a40911935b77b86859eb5223d58d660df1" + "reference": "901eddb1e45a8e0f689302e40af871c181ecbe40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/f510c0a40911935b77b86859eb5223d58d660df1", - "reference": "f510c0a40911935b77b86859eb5223d58d660df1", + "url": "https://api.github.com/repos/brick/math/zipball/901eddb1e45a8e0f689302e40af871c181ecbe40", + "reference": "901eddb1e45a8e0f689302e40af871c181ecbe40", "shasum": "" }, "require": { @@ -26,7 +26,7 @@ "require-dev": { "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^10.1", - "vimeo/psalm": "5.16.0" + "vimeo/psalm": "6.8.8" }, "type": "library", "autoload": { @@ -56,7 +56,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.12.1" + "source": "https://github.com/brick/math/tree/0.12.2" }, "funding": [ { @@ -64,7 +64,7 @@ "type": "github" } ], - "time": "2023-11-29T23:19:16+00:00" + "time": "2025-02-26T10:21:45+00:00" }, { "name": "carbonphp/carbon-doctrine-types", @@ -1060,7 +1060,7 @@ "dist": { "type": "path", "url": "../laraknife", - "reference": "7d27950ee05d6319afcb1068201f21374dc995a9" + "reference": "2a0a5702f289ed130b62adad2095eb4a09214d0a" }, "require-dev": { "phpunit/phpunit": "11.0.x-dev" @@ -1091,16 +1091,16 @@ }, { "name": "laravel/framework", - "version": "v11.43.2", + "version": "v11.44.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "99d1573698abc42222f04d25fcd5b213d0eedf21" + "reference": "e9a33da34815ac1ed46c7e4c477a775f4592f0a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/99d1573698abc42222f04d25fcd5b213d0eedf21", - "reference": "99d1573698abc42222f04d25fcd5b213d0eedf21", + "url": "https://api.github.com/repos/laravel/framework/zipball/e9a33da34815ac1ed46c7e4c477a775f4592f0a7", + "reference": "e9a33da34815ac1ed46c7e4c477a775f4592f0a7", "shasum": "" }, "require": { @@ -1302,7 +1302,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2025-02-19T21:53:48+00:00" + "time": "2025-02-24T13:08:54+00:00" }, { "name": "laravel/prompts", @@ -3781,16 +3781,16 @@ }, { "name": "symfony/error-handler", - "version": "v7.2.3", + "version": "v7.2.4", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "959a74d044a6db21f4caa6d695648dcb5584cb49" + "reference": "aabf79938aa795350c07ce6464dd1985607d95d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/959a74d044a6db21f4caa6d695648dcb5584cb49", - "reference": "959a74d044a6db21f4caa6d695648dcb5584cb49", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/aabf79938aa795350c07ce6464dd1985607d95d5", + "reference": "aabf79938aa795350c07ce6464dd1985607d95d5", "shasum": "" }, "require": { @@ -3836,7 +3836,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v7.2.3" + "source": "https://github.com/symfony/error-handler/tree/v7.2.4" }, "funding": [ { @@ -3852,7 +3852,7 @@ "type": "tidelift" } ], - "time": "2025-01-07T09:39:55+00:00" + "time": "2025-02-02T20:27:07+00:00" }, { "name": "symfony/event-dispatcher", @@ -4154,16 +4154,16 @@ }, { "name": "symfony/http-kernel", - "version": "v7.2.3", + "version": "v7.2.4", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "caae9807f8e25a9b43ce8cc6fafab6cf91f0cc9b" + "reference": "9f1103734c5789798fefb90e91de4586039003ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/caae9807f8e25a9b43ce8cc6fafab6cf91f0cc9b", - "reference": "caae9807f8e25a9b43ce8cc6fafab6cf91f0cc9b", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/9f1103734c5789798fefb90e91de4586039003ed", + "reference": "9f1103734c5789798fefb90e91de4586039003ed", "shasum": "" }, "require": { @@ -4248,7 +4248,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v7.2.3" + "source": "https://github.com/symfony/http-kernel/tree/v7.2.4" }, "funding": [ { @@ -4264,7 +4264,7 @@ "type": "tidelift" } ], - "time": "2025-01-29T07:40:13+00:00" + "time": "2025-02-26T11:01:22+00:00" }, { "name": "symfony/mailer", @@ -4348,16 +4348,16 @@ }, { "name": "symfony/mime", - "version": "v7.2.3", + "version": "v7.2.4", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "2fc3b4bd67e4747e45195bc4c98bea4628476204" + "reference": "87ca22046b78c3feaff04b337f33b38510fd686b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/2fc3b4bd67e4747e45195bc4c98bea4628476204", - "reference": "2fc3b4bd67e4747e45195bc4c98bea4628476204", + "url": "https://api.github.com/repos/symfony/mime/zipball/87ca22046b78c3feaff04b337f33b38510fd686b", + "reference": "87ca22046b78c3feaff04b337f33b38510fd686b", "shasum": "" }, "require": { @@ -4412,7 +4412,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v7.2.3" + "source": "https://github.com/symfony/mime/tree/v7.2.4" }, "funding": [ { @@ -4428,7 +4428,7 @@ "type": "tidelift" } ], - "time": "2025-01-27T11:08:17+00:00" + "time": "2025-02-19T08:51:20+00:00" }, { "name": "symfony/polyfill-ctype", @@ -5068,16 +5068,16 @@ }, { "name": "symfony/process", - "version": "v7.2.0", + "version": "v7.2.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e" + "reference": "d8f411ff3c7ddc4ae9166fb388d1190a2df5b5cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/d34b22ba9390ec19d2dd966c40aa9e8462f27a7e", - "reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e", + "url": "https://api.github.com/repos/symfony/process/zipball/d8f411ff3c7ddc4ae9166fb388d1190a2df5b5cf", + "reference": "d8f411ff3c7ddc4ae9166fb388d1190a2df5b5cf", "shasum": "" }, "require": { @@ -5109,7 +5109,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.2.0" + "source": "https://github.com/symfony/process/tree/v7.2.4" }, "funding": [ { @@ -5125,7 +5125,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T14:24:19+00:00" + "time": "2025-02-05T08:33:46+00:00" }, { "name": "symfony/routing", @@ -5380,16 +5380,16 @@ }, { "name": "symfony/translation", - "version": "v7.2.2", + "version": "v7.2.4", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "e2674a30132b7cc4d74540d6c2573aa363f05923" + "reference": "283856e6981286cc0d800b53bd5703e8e363f05a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/e2674a30132b7cc4d74540d6c2573aa363f05923", - "reference": "e2674a30132b7cc4d74540d6c2573aa363f05923", + "url": "https://api.github.com/repos/symfony/translation/zipball/283856e6981286cc0d800b53bd5703e8e363f05a", + "reference": "283856e6981286cc0d800b53bd5703e8e363f05a", "shasum": "" }, "require": { @@ -5455,7 +5455,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v7.2.2" + "source": "https://github.com/symfony/translation/tree/v7.2.4" }, "funding": [ { @@ -5471,7 +5471,7 @@ "type": "tidelift" } ], - "time": "2024-12-07T08:18:10+00:00" + "time": "2025-02-13T10:27:23+00:00" }, { "name": "symfony/translation-contracts", @@ -6734,23 +6734,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "11.0.8", + "version": "11.0.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "418c59fd080954f8c4aa5631d9502ecda2387118" + "reference": "14d63fbcca18457e49c6f8bebaa91a87e8e188d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/418c59fd080954f8c4aa5631d9502ecda2387118", - "reference": "418c59fd080954f8c4aa5631d9502ecda2387118", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/14d63fbcca18457e49c6f8bebaa91a87e8e188d7", + "reference": "14d63fbcca18457e49c6f8bebaa91a87e8e188d7", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^5.3.1", + "nikic/php-parser": "^5.4.0", "php": ">=8.2", "phpunit/php-file-iterator": "^5.1.0", "phpunit/php-text-template": "^4.0.1", @@ -6762,7 +6762,7 @@ "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^11.5.0" + "phpunit/phpunit": "^11.5.2" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -6800,7 +6800,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.8" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.9" }, "funding": [ { @@ -6808,7 +6808,7 @@ "type": "github" } ], - "time": "2024-12-11T12:34:27+00:00" + "time": "2025-02-25T13:26:39+00:00" }, { "name": "phpunit/php-file-iterator", @@ -7057,16 +7057,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.9", + "version": "11.5.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c91c830e7108a81e5845aeb6ba8fe3c1a4351c0b" + "reference": "d5df2b32d729562ff8db634678d71085ee579006" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c91c830e7108a81e5845aeb6ba8fe3c1a4351c0b", - "reference": "c91c830e7108a81e5845aeb6ba8fe3c1a4351c0b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d5df2b32d729562ff8db634678d71085ee579006", + "reference": "d5df2b32d729562ff8db634678d71085ee579006", "shasum": "" }, "require": { @@ -7138,7 +7138,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.9" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.10" }, "funding": [ { @@ -7154,7 +7154,7 @@ "type": "tidelift" } ], - "time": "2025-02-21T06:08:50+00:00" + "time": "2025-02-25T06:11:48+00:00" }, { "name": "sebastian/cli-parser",