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-color: #ffa000;
font-family: Courier;
font-size: 1.5em
font-size: 1.5em;
text-align: center;
padding: 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)
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
LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status='delivered' ORDER BY nonfinance.item);
my $sqld = qq(
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);
$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
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 $sqlol = qq(
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);
$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
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 $sqlor = qq(
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);
$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
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 $sqldl = qq(
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);
$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
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 $sqldr = qq(
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);
$sthdr->execute;
## 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);
$stha->execute;
## 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);
$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
LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id);
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
LEFT JOIN locations ON locations.structure=budgets.location
WHERE nonfinance.budget_id=$budget_id);
my $sthc = $dbh->prepare($sqlc);
$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);
$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);
$sthb->execute;
@ -721,8 +770,12 @@ sub compile_budget {
my $sthse = $dbh->prepare($sqlse);
$sthse->execute;
my $sqlr = qq( 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 $sqlr = qq(
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);
$sthr->execute;
@ -730,17 +783,27 @@ sub compile_budget {
SELECT budget_id, item, cost, currency, type
FROM expenditure
LEFT JOIN budgets on expenditure.budget_id=budgets.id
WHERE expenditure.budget_id = '$budget_id'
WHERE expenditure.budget_id = '$budget_id'
AND type='fee'
ORDER BY expenditure.item);
my $sthef = $dbh->prepare($sqlef);
$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);
$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);
$sthex->execute;
@ -850,14 +913,12 @@ END
print_item("$recordex->{item}", ">$recordex->{currency}$display_cost");
}
print_subtotal("INCOME: / donations, contributions, sums, funds");
while (my $recordf = $sthf->fetchrow_hashref) {
print_item("", sprintf("€%.2f", $recordf->{amount}));
}
## actual paid deposits
while (my $recordar = $sthar->fetchrow_hashref) {
while (my @sum = $sths->fetchrow_array()) {
@ -879,13 +940,13 @@ END
$display_surplus =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma
print_subtotal("RUNNING total OUT:","€$display_runningex");
print_subtotal(" "," "); # spacing between running & balance lines
print_subtotal("BALANCE OF FINANCIAL TRADE:"," €$display_surplus");
}
print <<END;
</div>
<div id="right" class="column">
<div class="title">NONFINANCIAL</div>
END
@ -896,14 +957,8 @@ END
$sthdl->execute;
while (my $record = $sthdl->fetchrow_hashref) {
$record->{item} =~ s/^([a-z])/\U$1/; ## capitalise first letter
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/; ## capitalise first letter
$last_init =~ s/^([a-z])/\U$1/; ## capitalise first letter
print_item("$record->{item} [$first_init$last_init]");
$initials = get_initials($record);
print_item("$record->{item} [$initials]");
}
print_subtitle("Resources / deployed");
@ -911,14 +966,8 @@ END
$sthdr->execute;
while (my $record = $sthdr->fetchrow_hashref) {
$record->{item} =~ s/^([a-z])/\U$1/; ## capitalise first letter
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/; ## capitalise first letter
$last_init =~ s/^([a-z])/\U$1/; ## capitalise first letter
print_item("$record->{item} [$first_init$last_init]");
$initials = get_initials($record);
print_item("$record->{item} [$initials]");
}
print_subtitle("Labour / offered");
@ -926,14 +975,8 @@ END
$sthol->execute;
while (my $record = $sthol->fetchrow_hashref) {
$record->{item} =~ s/^([a-z])/\U$1/; ## capitalise first letter
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/; ## capitalise first letter
$last_init =~ s/^([a-z])/\U$1/; ## capitalise first letter
print_item("$record->{item} [$first_init$last_init]");
$initials = get_initials($record);
print_item("$record->{item} [$initials]");
}
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