summaryrefslogtreecommitdiff
path: root/bin/k4-ifyllning.pl
blob: c5a9a00d87bdace0e661c8de05abdcc35c8e50b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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;