diff options
Diffstat (limited to 'bin/k4-ifyllning.pl')
-rwxr-xr-x | bin/k4-ifyllning.pl | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/bin/k4-ifyllning.pl b/bin/k4-ifyllning.pl new file mode 100755 index 0000000..c5a9a00 --- /dev/null +++ b/bin/k4-ifyllning.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl +# FIXME Rewrite to handle multiple entries. + +use strict; +use warnings; + +use GD::SVG; +use User::pwent; + +my ($full_name) = (User::pwent::getpwnam(getlogin)->gecos)[0] =~ /([^,]*),+$/; + +open FILE, $ARGV[0] or die $!; +my %values; +my ($key, $value); +while (my $line = <FILE>) { + chomp($line); + ($key, $value) = $line =~ /^(.*): *(.*)/g; + $values{$key} = $value; +} +close FILE; + +my $k4_1 = GD::SVG::Image->new(792, 1122); +my $k4_2 = GD::SVG::Image->new(792, 1122); + +my $k4_1_white = $k4_1->colorAllocate(255,255,255); +my $k4_1_black = $k4_1->colorAllocate(0,0,0); +my $k4_2_white = $k4_2->colorAllocate(255,255,255); +my $k4_2_black = $k4_2->colorAllocate(0,0,0); +my $font = gdLargeFont; + +$k4_1->startGroup('k4-1'); +$k4_1->rectangle(0,0,792,1122, $k4_1_white); + +$k4_1->string($font, 580, 112, `date +%Y-%m-%d`, $k4_1_black); + +$k4_1->string($font, 60, 225, $full_name, $k4_1_black); +$k4_1->string($font, 580, 225, $values{'Personnummer'}, $k4_1_black); + +# Antal +$k4_1->string($font, 80, 321, $values{'Antal'}, $k4_1_black); +# Beteckning +$k4_1->string($font, 165, 321, $values{'Beteckning'}, $k4_1_black); +# Forsaljningspris +$k4_1->string($font, 290, 321, $values{'Forsaljningspris'}, $k4_1_black); +# Omkostnadsbelopp +$k4_1->string($font, 405, 321, $values{'Omkostnadsbelopp'}, $k4_1_black); +# Vinst +$k4_1->string($font, 520, 321, $values{'Vinst'}, $k4_1_black); +# Forlust +#$k4_1->string($font, 635, 321, "0", $k4_1_black); + +# Summa +# Forsaljningspris +$k4_1->string($font, 290, 615, $values{'Forsaljningspris'}, $k4_1_black); +# Omkostnadsbelopp +$k4_1->string($font, 405, 615, $values{'Omkostnadsbelopp'}, $k4_1_black); +# Vinst +$k4_1->string($font, 520, 615, $values{'Vinst'}, $k4_1_black); +# Forlust +#$k4_1->string($font, 635, 615, "0", $k4_1_black); + +$k4_1->endGroup; + +open(SVGFILE, ">k4_1-overlay.svg"); +print SVGFILE $k4_1->svg; |