Is there some tightness, cramping, squeezing?

This commit is contained in:
nik gaffney 2021-08-29 12:06:08 +02:00
parent 6acdfd29a9
commit cfa7d75621
2 changed files with 106 additions and 51 deletions

View file

@ -54,7 +54,7 @@ body {
border-style: dotted; border-style: dotted;
border-color: #ffa000; border-color: #ffa000;
font-family: Courier; font-family: Courier;
font-size: 1.5em font-size: 1.5em;
text-align: center; text-align: center;
padding: 5px; padding: 5px;
margin-top: 5px; margin-top: 5px;

View file

@ -8,7 +8,7 @@ no warnings qw(experimental::smartmatch);
############################################################################## ##############################################################################
# # # #
# configuration details are kept in a separate file # # configuration options are kept in a separate file #
# # # #
############################################################################## ##############################################################################
@ -660,52 +660,101 @@ sub compile_budget {
my $dbh = DBI->connect($db_conect,$db_user,$db_pass) my $dbh = DBI->connect($db_conect,$db_user,$db_pass)
or die ("can't connect: $DBI::errstr"); or die ("can't connect: $DBI::errstr");
my $sqld = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id my $sqld = qq(
LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status='delivered' ORDER BY nonfinance.item); SELECT * FROM nonfinance
LEFT JOIN agents ON nonfinance.agent_id=agents.id
LEFT JOIN budgets ON nonfinance.budget_id=budgets.id
LEFT JOIN locations ON locations.structure=budgets.location
WHERE nonfinance.budget_id=$budget_id
AND nonfinance.status='delivered'
ORDER BY nonfinance.item);
my $sthd = $dbh->prepare($sqld); my $sthd = $dbh->prepare($sqld);
$sthd->execute; $sthd->execute;
my $sqlol = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id my $sqlol = qq(
LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status!='delivered' AND kind='labour' ORDER BY nonfinance.item); SELECT * FROM nonfinance
LEFT JOIN agents on nonfinance.agent_id=agents.id
LEFT JOIN budgets ON nonfinance.budget_id=budgets.id
LEFT JOIN locations ON locations.structure=budgets.location
WHERE nonfinance.budget_id=$budget_id
AND nonfinance.status!='delivered'
AND kind='labour'
ORDER BY nonfinance.item);
my $sthol = $dbh->prepare($sqlol); my $sthol = $dbh->prepare($sqlol);
$sthol->execute; $sthol->execute;
my $sqlor = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id my $sqlor = qq(
LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status!='delivered' AND kind='resources' ORDER BY nonfinance.item); SELECT * FROM nonfinance
LEFT JOIN agents on nonfinance.agent_id=agents.id
LEFT JOIN budgets ON nonfinance.budget_id=budgets.id
LEFT JOIN locations ON locations.structure=budgets.location
WHERE nonfinance.budget_id=$budget_id
AND nonfinance.status!='delivered'
AND kind='resources'
ORDER BY nonfinance.item);
my $sthor = $dbh->prepare($sqlor); my $sthor = $dbh->prepare($sqlor);
$sthor->execute; $sthor->execute;
my $sqldl = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id my $sqldl = qq(
LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status='delivered' AND kind='labour' ORDER BY nonfinance.item); SELECT * FROM nonfinance
LEFT JOIN agents on nonfinance.agent_id=agents.id
LEFT JOIN budgets ON nonfinance.budget_id=budgets.id
LEFT JOIN locations ON locations.structure=budgets.location
WHERE nonfinance.budget_id=$budget_id
AND nonfinance.status='delivered'
AND kind='labour'
ORDER BY nonfinance.item);
my $sthdl = $dbh->prepare($sqldl); my $sthdl = $dbh->prepare($sqldl);
$sthdl->execute; $sthdl->execute;
my $sqldr = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id my $sqldr = qq(
LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status='delivered' AND kind='resources' ORDER BY nonfinance.item); SELECT * FROM nonfinance
LEFT JOIN agents on nonfinance.agent_id=agents.id
LEFT JOIN budgets ON nonfinance.budget_id=budgets.id
LEFT JOIN locations ON locations.structure=budgets.location
WHERE nonfinance.budget_id=$budget_id
AND nonfinance.status='delivered'
AND kind='resources'
ORDER BY nonfinance.item);
my $sthdr = $dbh->prepare($sqldr); my $sthdr = $dbh->prepare($sqldr);
$sthdr->execute; $sthdr->execute;
## count potential deposits ## count potential deposits
my $sqla = qq( SELECT COUNT(fullname) AS qty FROM agents WHERE budget_id=$budget_id AND status!='staff'); my $sqla = qq(
SELECT COUNT(fullname) AS qty FROM agents
WHERE budget_id=$budget_id
AND status!='staff');
my $stha = $dbh->prepare($sqla); my $stha = $dbh->prepare($sqla);
$stha->execute; $stha->execute;
## count deposits received ## count deposits received
my $sqlar = qq( SELECT COUNT(fullname) AS qty FROM agents WHERE budget_id=$budget_id AND status='deposit'); my $sqlar = qq(
SELECT COUNT(fullname) AS qty FROM agents
WHERE budget_id=$budget_id
AND status='deposit');
my $sthar = $dbh->prepare($sqlar); my $sthar = $dbh->prepare($sqlar);
$sthar->execute; $sthar->execute;
my $sqlc = qq( SELECT COUNT(*) FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agent.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id my $sqlc = qq(
LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id); SELECT COUNT(*) FROM nonfinance
LEFT JOIN agents on nonfinance.agent_id=agent.id
LEFT JOIN budgets ON nonfinance.budget_id=budgets.id
LEFT JOIN locations ON locations.structure=budgets.location
WHERE nonfinance.budget_id=$budget_id);
my $sthc = $dbh->prepare($sqlc); my $sthc = $dbh->prepare($sqlc);
$sthc->execute; $sthc->execute;
my $sqlf = qq( SELECT * FROM finance WHERE budget_id=$budget_id ORDER by amount); my $sqlf = qq(
SELECT * FROM finance WHERE budget_id=$budget_id
ORDER by amount);
my $sthf = $dbh->prepare($sqlf); my $sthf = $dbh->prepare($sqlf);
$sthf->execute; $sthf->execute;
my $sqlb = qq( SELECT *, date_format(deliver_date,'%d-%m-%Y') AS end_date FROM budgets LEFT JOIN locations on budgets.location=locations.structure WHERE budgets.id=$budget_id); my $sqlb = qq(
SELECT *, date_format(deliver_date,'%d-%m-%Y')
AS end_date FROM budgets
LEFT JOIN locations on budgets.location=locations.structure
WHERE budgets.id=$budget_id);
my $sthb = $dbh->prepare($sqlb); my $sthb = $dbh->prepare($sqlb);
$sthb->execute; $sthb->execute;
@ -721,8 +770,12 @@ sub compile_budget {
my $sthse = $dbh->prepare($sqlse); my $sthse = $dbh->prepare($sqlse);
$sthse->execute; $sthse->execute;
my $sqlr = qq( SELECT name, fullname, codename from finance LEFT JOIN agents ON finance.agent_id=agents.id my $sqlr = qq(
LEFT JOIN budgets ON finance.budget_id = budgets.id WHERE finance.budget_id="$budget_id" AND finance.agent_id="$agent_id"); SELECT name, fullname, codename FROM finance
LEFT JOIN agents ON finance.agent_id=agents.id
LEFT JOIN budgets ON finance.budget_id = budgets.id
WHERE finance.budget_id="$budget_id"
AND finance.agent_id="$agent_id");
my $sthr = $dbh->prepare($sqlr); my $sthr = $dbh->prepare($sqlr);
$sthr->execute; $sthr->execute;
@ -730,17 +783,27 @@ sub compile_budget {
SELECT budget_id, item, cost, currency, type SELECT budget_id, item, cost, currency, type
FROM expenditure FROM expenditure
LEFT JOIN budgets on expenditure.budget_id=budgets.id LEFT JOIN budgets on expenditure.budget_id=budgets.id
WHERE expenditure.budget_id = '$budget_id' WHERE expenditure.budget_id = '$budget_id'
AND type='fee' AND type='fee'
ORDER BY expenditure.item); ORDER BY expenditure.item);
my $sthef = $dbh->prepare($sqlef); my $sthef = $dbh->prepare($sqlef);
$sthef->execute; $sthef->execute;
my $sqlem = qq( SELECT budget_id, item, cost, currency, type FROM expenditure LEFT JOIN budgets on expenditure.budget_id=budgets.id WHERE expenditure.budget_id = '$budget_id' AND type='materials' ORDER BY expenditure.item); my $sqlem = qq(
SELECT budget_id, item, cost, currency, type FROM expenditure
LEFT JOIN budgets on expenditure.budget_id=budgets.id
WHERE expenditure.budget_id = '$budget_id'
AND type='materials'
ORDER BY expenditure.item);
my $sthem = $dbh->prepare($sqlem); my $sthem = $dbh->prepare($sqlem);
$sthem->execute; $sthem->execute;
my $sqlex = qq( SELECT budget_id, item, cost, currency, type FROM expenditure LEFT JOIN budgets on expenditure.budget_id=budgets.id WHERE expenditure.budget_id = '$budget_id' AND type='misc' ORDER BY expenditure.item); my $sqlex = qq(
SELECT budget_id, item, cost, currency, type FROM expenditure
LEFT JOIN budgets on expenditure.budget_id=budgets.id
WHERE expenditure.budget_id = '$budget_id'
AND type='misc'
ORDER BY expenditure.item);
my $sthex = $dbh->prepare($sqlex); my $sthex = $dbh->prepare($sqlex);
$sthex->execute; $sthex->execute;
@ -850,14 +913,12 @@ END
print_item("$recordex->{item}", ">$recordex->{currency}$display_cost"); print_item("$recordex->{item}", ">$recordex->{currency}$display_cost");
} }
print_subtotal("INCOME: / donations, contributions, sums, funds"); print_subtotal("INCOME: / donations, contributions, sums, funds");
while (my $recordf = $sthf->fetchrow_hashref) { while (my $recordf = $sthf->fetchrow_hashref) {
print_item("", sprintf("€%.2f", $recordf->{amount})); print_item("", sprintf("€%.2f", $recordf->{amount}));
} }
## actual paid deposits ## actual paid deposits
while (my $recordar = $sthar->fetchrow_hashref) { while (my $recordar = $sthar->fetchrow_hashref) {
while (my @sum = $sths->fetchrow_array()) { while (my @sum = $sths->fetchrow_array()) {
@ -879,13 +940,13 @@ END
$display_surplus =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma $display_surplus =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma
print_subtotal("RUNNING total OUT:","€$display_runningex"); print_subtotal("RUNNING total OUT:","€$display_runningex");
print_subtotal(" "," "); # spacing between running & balance lines
print_subtotal("BALANCE OF FINANCIAL TRADE:"," €$display_surplus"); print_subtotal("BALANCE OF FINANCIAL TRADE:"," €$display_surplus");
} }
print <<END; print <<END;
</div> </div>
<div id="right" class="column"> <div id="right" class="column">
<div class="title">NONFINANCIAL</div> <div class="title">NONFINANCIAL</div>
END END
@ -896,14 +957,8 @@ END
$sthdl->execute; $sthdl->execute;
while (my $record = $sthdl->fetchrow_hashref) { while (my $record = $sthdl->fetchrow_hashref) {
$record->{item} =~ s/^([a-z])/\U$1/; ## capitalise first letter $record->{item} =~ s/^([a-z])/\U$1/; ## capitalise first letter
my $first=$record->{firstname} ; $initials = get_initials($record);
my $last=$record->{lastname} ; print_item("$record->{item} [$initials]");
$first_init = substr($first, 0, 1);
$last_init = substr($last, 0, 1);
$first_init =~ s/^([a-z])/\U$1/; ## capitalise first letter
$last_init =~ s/^([a-z])/\U$1/; ## capitalise first letter
print_item("$record->{item} [$first_init$last_init]");
} }
print_subtitle("Resources / deployed"); print_subtitle("Resources / deployed");
@ -911,14 +966,8 @@ END
$sthdr->execute; $sthdr->execute;
while (my $record = $sthdr->fetchrow_hashref) { while (my $record = $sthdr->fetchrow_hashref) {
$record->{item} =~ s/^([a-z])/\U$1/; ## capitalise first letter $record->{item} =~ s/^([a-z])/\U$1/; ## capitalise first letter
my $first=$record->{firstname} ; $initials = get_initials($record);
my $last=$record->{lastname} ; print_item("$record->{item} [$initials]");
$first_init = substr($first, 0, 1);
$last_init = substr($last, 0, 1);
$first_init =~ s/^([a-z])/\U$1/; ## capitalise first letter
$last_init =~ s/^([a-z])/\U$1/; ## capitalise first letter
print_item("$record->{item} [$first_init$last_init]");
} }
print_subtitle("Labour / offered"); print_subtitle("Labour / offered");
@ -926,14 +975,8 @@ END
$sthol->execute; $sthol->execute;
while (my $record = $sthol->fetchrow_hashref) { while (my $record = $sthol->fetchrow_hashref) {
$record->{item} =~ s/^([a-z])/\U$1/; ## capitalise first letter $record->{item} =~ s/^([a-z])/\U$1/; ## capitalise first letter
my $first=$record->{firstname} ; $initials = get_initials($record);
my $last=$record->{lastname} ; print_item("$record->{item} [$initials]");
$first_init = substr($first, 0, 1);
$last_init = substr($last, 0, 1);
$first_init =~ s/^([a-z])/\U$1/; ## capitalise first letter
$last_init =~ s/^([a-z])/\U$1/; ## capitalise first letter
print_item("$record->{item} [$first_init$last_init]");
} }
print_subtitle("Resources / offered"); print_subtitle("Resources / offered");
@ -959,6 +1002,18 @@ END
} }
# capitalise the initials of a name from a record
sub get_initials {
$record = shift;
my $first=$record->{firstname} ;
my $last=$record->{lastname} ;
$first_init = substr($first, 0, 1);
$last_init = substr($last, 0, 1);
$first_init =~ s/^([a-z])/\U$1/;
$last_init =~ s/^([a-z])/\U$1/;
return "$first_init$last_init"
}
############################################################################ ############################################################################
# prepare expenditure # prepare expenditure