From a7b602af8ce7d851c27ee865c6d69993d4d6dfd8 Mon Sep 17 00:00:00 2001 From: kate rich Date: Wed, 15 Sep 2021 08:28:14 +0000 Subject: [PATCH] This begins with enquiring about open to whom and, vitally, by whom? --- f20_budget.pl | 2359 +++++++++++++++++++++++++------------------------ 1 file changed, 1194 insertions(+), 1165 deletions(-) diff --git a/f20_budget.pl b/f20_budget.pl index 4b2d957..c48903b 100644 --- a/f20_budget.pl +++ b/f20_budget.pl @@ -12,7 +12,7 @@ no warnings qw(experimental::smartmatch); # # ############################################################################## -do "./f20-budget.config.pl"; +do "./f20_budget_config.pl"; ############################################################################## # # @@ -76,30 +76,33 @@ $new_url=$q->param("new_url"); $new_item = sanitise($q->param("new_item")); $new_labour = sanitise($q->param("new_labour")); $new_resource = sanitise($q->param("new_resource")); +$insert_labour = sanitise($q->param("insert_labour")); +$insert_resources = sanitise($q->param("insert_resources")); $new_status = sanitise($q->param("new_status")); $new_lstatus = sanitise($q->param("new_lstatus")); $new_rstatus = sanitise($q->param("new_rstatus")); +$new_notes = sanitise($q->param("new_notes")); $type = sanitise($q->param("type")); for ( $i=0; $i<=50; $i+=1) { - $new_status{$i} = sanitise($q->param("new_status$i")); - $type{$i} = sanitise($q->param("type$i")); - $new_item{$i} = sanitise($q->param("new_item$i")); - $new_resource{$i} = sanitise($q->param("new_resource$i")); - $new_labour{$i} = sanitise($q->param("new_labour$i")); - $new_status{$i} = sanitise($q->param("new_status$i")); - $new_lstatus{$i} = sanitise($q->param("new_lstatus$i")); - $new_rstatus{$i} = sanitise($q->param("new_rstatus$i")); + $new_status{$i} = sanitise($q->param("new_status$i")); + $type{$i} = sanitise($q->param("type$i")); + $new_item{$i} = sanitise($q->param("new_item$i")); + $new_resource{$i} = sanitise($q->param("new_resource$i")); + $new_labour{$i} = sanitise($q->param("new_labour$i")); + $new_status{$i} = sanitise($q->param("new_status$i")); + $new_lstatus{$i} = sanitise($q->param("new_lstatus$i")); + $new_rstatus{$i} = sanitise($q->param("new_rstatus$i")); - $new_firstname{$i} = sanitise($q->param("new_firstname$i")); - $new_lastname{$i} = sanitise($q->param("new_lastname$i")); - $new_codename{$i} = sanitise($q->param("new_codename$i")); + $new_firstname{$i} = sanitise($q->param("new_firstname$i")); + $new_lastname{$i} = sanitise($q->param("new_lastname$i")); + $new_codename{$i} = sanitise($q->param("new_codename$i")); - $cost{$i}=~ s/\€/@euro/g; - $cost{$i} = $q->param("cost$i"); - $new_cost{$i}=~ s/\€/@euro/g; - $new_cost{$i} = $q->param("new_cost$i"); - $currency{$i} = $q->param("currency$i"); + $cost{$i}=~ s/\€/@euro/g; + $cost{$i} = $q->param("cost$i"); + $new_cost{$i}=~ s/\€/@euro/g; + $new_cost{$i} = $q->param("new_cost$i"); + $currency{$i} = $q->param("currency$i"); } @@ -120,57 +123,57 @@ $new_deliver_date=$q->param('new_deliver_year') . $q->param("new_deliver_month") if ($new_name eq '') { - $new_name=$new_auto_name; + $new_name=$new_auto_name; } if ($new_location eq '') { - $new_location=$new_auto_location; + $new_location=$new_auto_location; } if ($new_remarks eq '') { - $new_remarks=$new_auto_remarks; + $new_remarks=$new_auto_remarks; } if ($new_url eq '') { - $new_remarks=$new_auto_url; + $new_remarks=$new_auto_url; } given ($action) { - when('select_budget') {&select_budget; } - when('add_form') {&add_form; } - when('add_budget') {&add_budget; } - when('add_budget_information') {&add_budget_information; } - when('prepare_agents') {&prepare_agents; } - when('input_agents') {&input_agents; } - when('edit_agent') {&edit_agent; } - when('update_agent') {&update_agent; } - when('edit_form') {&edit_form; } - when('edit_select_form') {&edit_select_form; } - when('edit_budget') {&edit_budget; } - when('list_budgets') {&list_budgets; } - when('prepare_budget') {&prepare_budget; } - when('prepare_money') {&prepare_money; } - when('input_budget') {&input_budget; } - when('input_money') {&input_money; } - when('prepare_expenditure') {&prepare_expenditure; } - when('input_expenditure') {&input_expenditure; } - when('compile_budget') {&compile_budget; } - when('display_budgets') {&display_budgets; } - when('present_budget') {&present_budget; } - when('delete_form') {&delete_form; } - when('delete_budget') {&delete_budget; } - when('select_budget') {&select_budget; } - when('upload_image') {&upload_image; } - #default {&display_budgets; } - default { - &select_budget; - } + when('select_budget') {&select_budget; } + when('add_form') {&add_form; } + when('add_budget') {&add_budget; } + when('add_budget_information') {&add_budget_information; } + when('prepare_agents') {&prepare_agents; } + when('input_agents') {&input_agents; } + when('edit_agent') {&edit_agent; } + when('update_agent') {&update_agent; } + when('edit_form') {&edit_form; } + when('edit_select_form') {&edit_select_form; } + when('edit_budget') {&edit_budget; } + when('list_budgets') {&list_budgets; } + when('prepare_budget') {&prepare_budget; } + when('prepare_money') {&prepare_money; } + when('input_budget') {&input_budget; } + when('input_money') {&input_money; } + when('prepare_expenditure') {&prepare_expenditure; } + when('input_expenditure') {&input_expenditure; } + when('compile_budget') {&compile_budget; } + when('display_budgets') {&display_budgets; } + when('present_budget') {&present_budget; } + when('delete_form') {&delete_form; } + when('delete_budget') {&delete_budget; } + when('select_budget') {&select_budget; } + when('upload_image') {&upload_image; } + #default {&display_budgets; } + default { + &select_budget; + } } exit; # saniti[sz]e parameters and sql inputs as needed sub sanitise { - my $string = shift; - $string =~ s/\'/\'\'/g; # convert ' to '' - $string =~ s/\x92/’/g; # convert "RIGHT SINGLE QUOTATION MARK" to html - return $string; + my $string = shift; + $string =~ s/\'/\'\'/g; # convert ' to '' + $string =~ s/\x92/’/g; # convert "RIGHT SINGLE QUOTATION MARK" to html + return $string; } ############################################################################## @@ -181,20 +184,20 @@ sub sanitise { sub select_budget { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT DISTINCT name from budgets ORDER BY id DESC); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT DISTINCT name from budgets ORDER BY id DESC); + my $sth = $dbh->prepare($sql); + $sth->execute; - my $sql2 = qq( SELECT DISTINCT firstname, lastname from agents ORDER BY firstname); - my $sth2 = $dbh->prepare($sql2); - $sth2->execute; + my $sql2 = qq( SELECT DISTINCT firstname, lastname from agents ORDER BY firstname); + my $sth2 = $dbh->prepare($sql2); + $sth2->execute; - &print_header; + &print_header; - print <
@@ -206,19 +209,19 @@ sub select_budget { END - ## name budget + ## name budget - print(qq(\n)); + print(qq(\n)); - ## enter agent code + ## enter agent code - print <
enter your agent codename:
@@ -230,8 +233,8 @@ END
END - &print_footer; - $dbh->disconnect; + &print_footer; + $dbh->disconnect; } @@ -244,28 +247,28 @@ END sub prepare_budget { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT * from budgets WHERE name="$new_name" ); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT * from budgets WHERE name="$new_name" ); + my $sth = $dbh->prepare($sql); + $sth->execute; - ## identify agent by codename - my $sql2 = qq( SELECT * from agents where codename ="$new_codename" ); - my $sth2 = $dbh->prepare($sql2); - $sth2->execute; + ## identify agent by codename + my $sql2 = qq( SELECT * from agents where codename ="$new_codename" ); + my $sth2 = $dbh->prepare($sql2); + $sth2->execute; - while (my $record = $sth->fetchrow_hashref) { - if (my $record2 = $sth2->fetchrow_hashref) { + while (my $record = $sth->fetchrow_hashref) { + if (my $record2 = $sth2->fetchrow_hashref) { - my $sql3 = qq( SELECT * from finance LEFT JOIN agents ON finance.agent_id=agents.id WHERE finance.budget_id='$record->{id}' AND finance.agent_id ='$record2->{id}' ); - my $sth3 = $dbh->prepare($sql3); - $sth3->execute; + my $sql3 = qq( SELECT * from finance LEFT JOIN agents ON finance.agent_id=agents.id WHERE finance.budget_id='$record->{id}' AND finance.agent_id ='$record2->{id}' ); + my $sth3 = $dbh->prepare($sql3); + $sth3->execute; - &print_header; + &print_header; - print <
@@ -303,151 +306,151 @@ sub prepare_budget { )); - print(qq()); - $i++ - } + @cats = ('select category', 'fee', 'materials', 'misc'); + foreach $cat(@cats) { + print(qq({type}) { + print(qq( selected)); + } + print(qq(>$cat)); + } + print(qq()); + print(qq()); + $i++ + } - if ($i<=5) { + if ($i<=5) { - print <)); + + print(qq()); + } } - print(qq(>$cat)); - } - print(qq()); - print(qq()); + print(qq(
END - my $sql4 = qq( SELECT * from expenditure where budget_id='$record->{id}' AND agent_id ='$record2->{id}' ); - my $sth4 = $dbh->prepare($sql4); - $sth4->execute; + my $sql4 = qq( SELECT * from expenditure where budget_id='$record->{id}' AND agent_id ='$record2->{id}' ); + my $sth4 = $dbh->prepare($sql4); + $sth4->execute; - for ($i=1;$i<=5;$i++) { - while (my $record4 = $sth4->fetchrow_hashref) { - print <fetchrow_hashref) { + print <$i.$currency item
item
$i.€ item
item
\n)); + + print(qq(
)); + print(qq()); + print(qq(\n)); + + + ## resources section + + print(qq(\n)); + print(qq()); + + + my $sql5 = qq( SELECT * from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='labour' ); + my $sth5 = $dbh->prepare($sql5); + $sth5->execute; + + my $sqlCL = qq( SELECT count(id) AS count from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='labour' ); + my $sthCL = $dbh->prepare($sqlCL); + $sthCL->execute; + + while (my $recordCL = $sthCL->fetchrow_hashref) { + my $t = $recordCL->{count}; + + for ($i=1;$i<=$t;$i++) { + while (my $record5 = $sth5->fetchrow_hashref) { + print "\n"; + print "\n"; + print "\n"; + $i++ + } + } + + print "\n"; + + } + + + print(qq(\n)); + print(qq()); + + my $sql5 = qq( SELECT * from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='resources' ); + my $sth5 = $dbh->prepare($sql5); + $sth5->execute; + + + my $sqlCR = qq( SELECT count(id) AS count from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='resources' ); + my $sthCR = $dbh->prepare($sqlCR); + $sthCR->execute; + + while (my $recordCR = $sthCR->fetchrow_hashref) { + my $t = $recordCR->{count}; + + for ($i=1;$i<=$t;$i++) { + while (my $record5 = $sth5->fetchrow_hashref) { + print "\n"; + print "\n"; + print "\n"; + $i++ + } + } + + print "\n"; + } + + my $sql6 = qq( SELECT * from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='notes'); + my $sth6 = $dbh->prepare($sql6); + $sth6->execute; + + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
input moneyyour monetary contribution to the budget (direct payments for materials/services, donations to f20, as a sum total)
fetchrow_hashref) { + print(qq(value="$record3->{amount}" )); + } + print(qq( size="3" maxsize="5">
 
input labourthings you commit to doing, non-remunerated. (check the box if this labour has already been deployed)
$i.{status} eq 'delivered') { print "CHECKED"}; + print ">{item}\" size=\"100\" maxsize=\"200\">
"; + print " enter a number to add budget lines
 
input resourcesmaterials, spaces, tools, previous work etc (check the box if your resource has already been deployed)
$i.{status} eq 'delivered') { print "CHECKED"}; + print ">{item}\" size=\"100\" maxsize=\"200\">
"; + print " enter a number to add budget lines
 
notesfor your own reference only, these notes will not show up in the shared budget
\n)); + + } else { + & print_header; + print(qq(codename not recognised. please retry\n)); } - } - - print(qq(\n)); - - print(qq( )); - print(qq()); - print(qq(\n)); - - - ## resources section !!! read-in notworking !!! - - print(qq(\n)); - print(qq()); - - my $sql5 = qq( SELECT * from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='labour' ); - my $sth5 = $dbh->prepare($sql5); - $sth5->execute; - - my $sqlCL = qq( SELECT count(id) AS count from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='labour' ); - my $sthCL = $dbh->prepare($sqlCL); - $sthCL->execute; - - while (my $recordCL = $sthCL->fetchrow_hashref) { - my $t = $recordCL->{count}; - - for ($i=1;$i<=$t;$i++) { - while (my $record5 = $sth5->fetchrow_hashref) { - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - $i++ - } - } - - print(qq()); - } - - print(qq(\n)); - print(qq()); - - my $sql5 = qq( SELECT * from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='resources' ); - my $sth5 = $dbh->prepare($sql5); - $sth5->execute; - - my $sqlCR = qq( SELECT count(id) AS count from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='resources' ); - my $sthCR = $dbh->prepare($sqlCR); - $sthCR->execute; - - while (my $recordCR = $sthCR->fetchrow_hashref) { - my $t = $recordCR->{count}; - - for ($i=1;$i<=$t;$i++) { - while (my $record5 = $sth5->fetchrow_hashref) { - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - $i++ - } - } - - my $sql6 = qq( SELECT * from nonfinance where budget_id=$record->{id} AND agent_id =$record2->{id} AND kind='notes'); - my $sth6 = $dbh->prepare($sql6); - $sth6->execute; - - print < - -END - } - - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(
input moneyyour monetary contribution to the budget (direct payments for materials/services, donations to f20, as a sum total)
fetchrow_hashref) { - print(qq(value="$record3->{amount}" )); - } - print(qq( size="3" maxsize="5">
 
input labourthings you commit to doing, non-remunerated. (check the box if this labour has already been deployed)
$i.{status} eq 'delivered') { print"CHECKED" }; - print(qq(>
)); - print(qq(enter a number to add budget lines
 
input resourcesmaterials, spaces, tools, previous work etc (check the box if your resource has already been deployed)
$i.{status} eq 'delivered') { print "CHECKED" }; - print(qq(>
- - enter a number to add budget lines
 
notesfor your own reference only, these notes will not show up in the shared budget
\n)); - - } else { - & print_header; - print(qq(codename not recognised. please retry\n)); } - } - &print_footer; - $dbh->disconnect; + &print_footer; + $dbh->disconnect; } @@ -459,112 +462,204 @@ END sub input_budget { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - &print_header; - print(qq(
\n)); - print(qq(\n)); - print(qq(
<\n)); + &print_header; + print(qq(
\n)); + print(qq(
\n)); + print(qq(
\n)); - ## delete expenditure line for agent + budget, if exists - my $sqld = qq( DELETE from expenditure where budget_id="$budget_id" AND agent_id="$agent_id"); - my $sthd= $dbh->prepare($sqld); - $sthd->execute; + ## delete expenditure line for agent + budget, if exists + my $sqld = qq( DELETE from expenditure where budget_id="$budget_id" AND agent_id="$agent_id"); + my $sthd= $dbh->prepare($sqld); + $sthd->execute; - ## input new expenditure lines for agent + ## input new expenditure lines for agent - for ($i=1; $i<=8; $i++) { - if ($new_item{$i} ne '') { - my $sql = (qq{INSERT INTO expenditure (budget_id, agent_id, status, type, item, cost, currency) VALUES ($budget_id, $agent_id, '$new_status{$i}', '$type{$i}', '$new_item{$i}', $new_cost{$i}, '€')}); - my $sth = $dbh->prepare($sql); - $sth->execute; + for ($i=1; $i<=8; $i++) { + if ($new_item{$i} ne '') { + my $sql = (qq{INSERT INTO expenditure (budget_id, agent_id, status, type, item, cost, currency) VALUES ($budget_id, $agent_id, '$new_status{$i}', '$type{$i}', '$new_item{$i}', $new_cost{$i}, '€')}); + my $sth = $dbh->prepare($sql); + $sth->execute; + } } - } - ## read in finance for agent + ## read in finance for agent - my $sql = qq( SELECT * from finance LEFT JOIN agents ON finance.agent_id=agents.id + my $sql = qq( SELECT * 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 $sth = $dbh->prepare($sql); - $sth->execute; + my $sth = $dbh->prepare($sql); + $sth->execute; - #while (my $record = $sth->fetchrow_hashref) { - print(qq(\n)); + #while (my $record = $sth->fetchrow_hashref) { + print(qq(\n)); - ## delete finance line for agent + budget, if exists - my $sqld = qq( DELETE from finance where budget_id="$budget_id" AND agent_id="$agent_id"); - my $sthd= $dbh->prepare($sqld); - $sthd->execute; + ## delete finance line for agent + budget, if exists + my $sqld = qq( DELETE from finance where budget_id="$budget_id" AND agent_id="$agent_id"); + my $sthd= $dbh->prepare($sqld); + $sthd->execute; - ## input money into finance - # if ($new_amount ne '') { - if ($new_amount eq '') { - $new_amount=0; - } - my $sqli = (qq{INSERT INTO finance (budget_id, agent_id, amount) VALUES ($budget_id, $agent_id, $new_amount)}); - my $sthi = $dbh->prepare($sqli); - $sthi->execute; - - my $sqld = qq( DELETE from nonfinance where budget_id="$budget_id" AND agent_id="$agent_id"); - my $sthd= $dbh->prepare($sqld); - $sthd->execute; - - ## input labour into nonfinance for agent - - for ($i=1; $i<=8; $i++) { - if ($new_labour{$i} ne '') { - my $sqll = (qq{INSERT INTO nonfinance (budget_id, agent_id, item, kind, status) VALUES ($budget_id, $agent_id, "$new_labour{$i}", "labour", "$new_lstatus{$i}")}); - my $sthl = $dbh->prepare($sqll); - $sthl->execute; + ## input money into finance + # if ($new_amount ne '') { + if ($new_amount eq '') { + $new_amount=0; } - } + my $sqli = (qq{INSERT INTO finance (budget_id, agent_id, amount) VALUES ($budget_id, $agent_id, $new_amount)}); + my $sthi = $dbh->prepare($sqli); + $sthi->execute; - ## input resources into nonfinance for agent - for ($i=1; $i<=8; $i++) { - if ($new_resource{$i} ne '') { - my $sqlr = (qq{INSERT INTO nonfinance (budget_id, agent_id, item, kind, status) VALUES ($budget_id, $agent_id, "$new_resource{$i}", "resources", "$new_rstatus{$i}")}); - my $sthr = $dbh->prepare($sqlr); - $sthr->execute; + ## delete nonfinance line for agent + budget, if exists + my $sqld = qq( DELETE from nonfinance where budget_id="$budget_id" AND agent_id="$agent_id"); + my $sthd= $dbh->prepare($sqld); + $sthd->execute; + + ## input labour into nonfinance for agent + + for ($i=1; $i<=8; $i++) { + if ($new_labour{$i} ne '') { + my $sqll = (qq{INSERT INTO nonfinance (budget_id, agent_id, item, kind, status) VALUES ($budget_id, $agent_id, "$new_labour{$i}", "labour", "$new_lstatus{$i}")}); + my $sthl = $dbh->prepare($sqll); + $sthl->execute; + } } - } - ## read back in to get these values from the db, not from the cgi + ## input resources into nonfinance for agent + for ($i=1; $i<=8; $i++) { + if ($new_resource{$i} ne '') { + my $sqlr = (qq{INSERT INTO nonfinance (budget_id, agent_id, item, kind, status) VALUES ($budget_id, $agent_id, "$new_resource{$i}", "resources", "$new_rstatus{$i}")}); + my $sthr = $dbh->prepare($sqlr); + $sthr->execute; + } + } - my $sqlv = (qq{SELECT DISTINCT item, cost, expenditure.currency, type, fullname from expenditure RIGHT JOIN agents on expenditure.agent_id=agents.id LEFT JOIN finance on expenditure.agent_id=finance.agent_id + +## add new budget lines for resources or labour *** + +if (param('insert_labour') ne '') { +#if ('$insert_labour' ne '') { + for ($i=1; $i<=$insert_labour; $i++) { + my $sqlIL = (qq{INSERT INTO nonfinance (budget_id, agent_id, item, kind, status) VALUES ('$budget_id','$agent_id','', 'labour', '')}); + my $sthIL = $dbh->prepare($sqlIL); + $sthIL->execute; + } + +} + +if (param('insert_resources') ne '') { +#if ('$insert_resources' ne '') { + for ($i=1; $i<=$insert_resources; $i++) { + my $sqlIR = (qq{INSERT INTO nonfinance (budget_id, agent_id, item, kind, status) VALUES ('$budget_id','$agent_id','', 'resources', '')}); + my $sthIR = $dbh->prepare($sqlIR); + $sthIR->execute; + } +} + + ## input notes nonfinance for agent + if ($new_notes ne '') { + my $sqln = (qq{INSERT INTO nonfinance (budget_id, agent_id, item, kind) VALUES ($budget_id, $agent_id, "$new_notes", "notes")}); + my $sthn = $dbh->prepare($sqln); + $sthn->execute; + } + + ## read back in to get these values from the db, not from the cgi + + my $sqlv = (qq{SELECT DISTINCT item, cost, expenditure.currency, type, fullname from expenditure RIGHT JOIN agents on expenditure.agent_id=agents.id LEFT JOIN finance on expenditure.agent_id=finance.agent_id WHERE expenditure.agent_id=$agent_id AND expenditure.budget_id=$budget_id}); - my $sthv = $dbh->prepare($sqlv); - $sthv->execute; - my $sqln = (qq{ SELECT fullname from agents where id=$agent_id}); - my $sthn = $dbh->prepare($sqln); - $sthn->execute; + my $sthv = $dbh->prepare($sqlv); + $sthv->execute; + my $sqln = (qq{ SELECT fullname from agents where id=$agent_id}); + my $sthn = $dbh->prepare($sqln); + $sthn->execute; - while (my $recordn = $sthn->fetchrow_hashref) { - print(qq( )); - } - - # print(qq(\n)); + while (my $recordn = $sthn->fetchrow_hashref) { + print(qq( )); } - } - print(qq(\n)); - print(qq(\n)); + # print(qq(\n)); + } + } - $sth->execute; - while (my $record = $sth->fetchrow_hashref) { + print(qq(\n)); + print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + $sth->execute; + while (my $record = $sth->fetchrow_hashref) { + + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
feral budget generator: $record->{name}
feral budget generator: $record->{name}
$projectname: $recordn->{fullname}
your PROPOSITION: )); - while (my $recordv = $sthv->fetchrow_hashref) { - if ($recordv->{item} ne '') { - print(qq(
$recordv->{$currency} $recordv->{$cost} $recordv->{$item} $recordv->{$type}
$projectname: $recordn->{fullname}
your PROPOSITION: )); + while (my $recordv = $sthv->fetchrow_hashref) { + if ($recordv->{item} ne '') { + print(qq(
$recordv->{$currency} $recordv->{$cost} $recordv->{$item} $recordv->{$type}
\n)); + print(qq(\n)); + } + &print_footer; +} + +############################################################################### +# input money + +sub input_money { + + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); + + &print_header; + print(qq(
\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); } @@ -1915,57 +1948,53 @@ sub select_start_date { ## print a title sub print_title { - my $string = shift; - print <$string END } - ## print a subtitle +## print a subtitle - sub print_subtitle { +sub print_subtitle { my $string = shift; print <$string END - } +} - ## print a budget subtotal line with a description and optional amount +## print a budget subtotal line with a description and optional amount - sub print_subtotal { +sub print_subtotal { my $string = shift; my $amount = shift; - if (not $amount) { - $amount = ""; - } + if (not $amount) {$amount = "";} print <

$string

$amount

END - } +} - ## print standard budget item with a description and optional amount +## print standard budget item with a description and optional amount - sub print_item { +sub print_item { my $string = shift; my $amount = shift; - if (not $amount) { - $amount = ""; - } + if (not $amount) {$amount = "";} print <

$string

$amount

END - } +} - ## print the page header +## print the page header - sub print_header { +sub print_header { print < END - } +} - ## print a standard footer +## print a standard footer - sub print_footer { +sub print_footer { print < END - } +} - ## print the admin footer +## print the admin footer - sub adminfooter { +sub adminfooter { print(qq(
\n)); print(qq(\n)); @@ -2006,4 +2035,4 @@ END print(qq(\n)); print(qq(\n)); - } +}
\n)); + + + ## read in finance for agent+ budget + + my $sql = qq( SELECT * 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 $sth = $dbh->prepare($sql); + $sth->execute; + + while (my $record = $sth->fetchrow_hashref) { + if ($record->{id} ne '') { + + ## delete finance line for agent + budget, if exists + my $sqld = qq( DELETE from finance where budget_id="$budget_id" AND agent_id="$agent_id"); + my $sthd= $dbh->prepare($sqld); + $sthd->execute; + } + } + + ## input money into finance + if ($new_amount eq '') { + $new_amount=0; + } + my $sqli = (qq{INSERT INTO finance (budget_id, agent_id, amount) VALUES ($budget_id, $agent_id, $new_amount)}); + my $sthi = $dbh->prepare($sqli); + $sthi->execute; + #} + print(qq(\n)); + print(qq( )); + print(qq(\n)); + print(qq(\n)); + + print(qq( )); + print(qq(\n)); + print(qq(\n)); print(qq(\n)); print(qq(\n)); @@ -576,70 +671,8 @@ sub input_budget { print(qq(\n)); print(qq(
feral budget generator: $record->{name}
your name:$new_fullname
your monetary contribution:€$new_amount
\n)); print(qq(\n)); - } - &print_footer; -} -############################################################################### -# input money - -sub input_money { - - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); - - &print_header; - print(qq(
\n)); - print(qq(\n)); - print(qq(
\n)); - - - ## read in finance for agent+ budget - - my $sql = qq( SELECT * 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 $sth = $dbh->prepare($sql); - $sth->execute; - - while (my $record = $sth->fetchrow_hashref) { - if ($record->{id} ne '') { - - ## delete finance line for agent + budget, if exists - my $sqld = qq( DELETE from finance where budget_id="$budget_id" AND agent_id="$agent_id"); - my $sthd= $dbh->prepare($sqld); - $sthd->execute; - } - } - - ## input money into finance - if ($new_amount eq '') { - $new_amount=0; - } - my $sqli = (qq{INSERT INTO finance (budget_id, agent_id, amount) VALUES ($budget_id, $agent_id, $new_amount)}); - my $sthi = $dbh->prepare($sqli); - $sthi->execute; - #} - print(qq(\n)); - print(qq( )); - print(qq(\n)); - print(qq(\n)); - - print(qq( )); - print(qq(\n)); - print(qq(\n)); - - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(
feral budget generator: $record->{name}
your name:$new_fullname
your monetary contribution:€$new_amount
\n)); - print(qq(\n)); - - &print_footer; + &print_footer; } @@ -651,10 +684,10 @@ sub input_money { sub compile_budget { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sqld = qq( + my $sqld = qq( SELECT * FROM nonfinance LEFT JOIN agents ON nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id @@ -662,10 +695,10 @@ sub compile_budget { WHERE nonfinance.budget_id=$budget_id AND nonfinance.status='delivered' ORDER BY nonfinance.item); - my $sthd = $dbh->prepare($sqld); - $sthd->execute; + my $sthd = $dbh->prepare($sqld); + $sthd->execute; - my $sqlol = qq( + my $sqlol = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id @@ -674,10 +707,10 @@ sub compile_budget { AND nonfinance.status!='delivered' AND kind='labour' ORDER BY nonfinance.item); - my $sthol = $dbh->prepare($sqlol); - $sthol->execute; + my $sthol = $dbh->prepare($sqlol); + $sthol->execute; - my $sqlor = qq( + my $sqlor = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id @@ -686,10 +719,10 @@ sub compile_budget { AND nonfinance.status!='delivered' AND kind='resources' ORDER BY nonfinance.item); - my $sthor = $dbh->prepare($sqlor); - $sthor->execute; + my $sthor = $dbh->prepare($sqlor); + $sthor->execute; - my $sqldl = qq( + my $sqldl = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id @@ -698,10 +731,10 @@ sub compile_budget { AND nonfinance.status='delivered' AND kind='labour' ORDER BY nonfinance.item); - my $sthdl = $dbh->prepare($sqldl); - $sthdl->execute; + my $sthdl = $dbh->prepare($sqldl); + $sthdl->execute; - my $sqldr = qq( + my $sqldr = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id @@ -710,105 +743,105 @@ sub compile_budget { AND nonfinance.status='delivered' AND kind='resources' ORDER BY nonfinance.item); - my $sthdr = $dbh->prepare($sqldr); - $sthdr->execute; + my $sthdr = $dbh->prepare($sqldr); + $sthdr->execute; - ## count potential deposits - my $sqla = qq( + ## count potential deposits + 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; + my $stha = $dbh->prepare($sqla); + $stha->execute; - ## count deposits received - my $sqlar = qq( + ## count deposits received + 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 $sthar = $dbh->prepare($sqlar); + $sthar->execute; - my $sqlc = qq( + 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 $sthc = $dbh->prepare($sqlc); + $sthc->execute; - my $sqlf = qq( + my $sqlf = qq( SELECT * FROM finance WHERE budget_id=$budget_id ORDER by amount); - my $sthf = $dbh->prepare($sqlf); - $sthf->execute; + my $sthf = $dbh->prepare($sqlf); + $sthf->execute; - my $sqlb = qq( + 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; + my $sthb = $dbh->prepare($sqlb); + $sthb->execute; - my $sqlfc = qq( SELECT COUNT(id) AS count FROM finance WHERE budget_id=$budget_id); - my $sthfc = $dbh->prepare($sqlfc); - $sthfc->execute; + my $sqlfc = qq( SELECT COUNT(id) AS count FROM finance WHERE budget_id=$budget_id); + my $sthfc = $dbh->prepare($sqlfc); + $sthfc->execute; - my $sqls = qq( SELECT SUM(amount) FROM finance WHERE budget_id=$budget_id); - my $sths = $dbh->prepare($sqls); - $sths->execute; + my $sqls = qq( SELECT SUM(amount) FROM finance WHERE budget_id=$budget_id); + my $sths = $dbh->prepare($sqls); + $sths->execute; - my $sqlse = qq( SELECT SUM(cost) FROM expenditure WHERE budget_id=$budget_id); - my $sthse = $dbh->prepare($sqlse); - $sthse->execute; + my $sqlse = qq( SELECT SUM(cost) FROM expenditure WHERE budget_id=$budget_id); + my $sthse = $dbh->prepare($sqlse); + $sthse->execute; - my $sqlr = qq( + 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; + my $sthr = $dbh->prepare($sqlr); + $sthr->execute; - my $sqlef = qq( + my $sqlef = 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='fee' ORDER BY expenditure.item); - my $sthef = $dbh->prepare($sqlef); - $sthef->execute; + my $sthef = $dbh->prepare($sqlef); + $sthef->execute; - my $sqlem = qq( + 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 $sthem = $dbh->prepare($sqlem); + $sthem->execute; - my $sqlex = qq( + 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; + my $sthex = $dbh->prepare($sqlex); + $sthex->execute; - $sthb->execute; - my $recordb = $sthb->fetchrow_hashref; + $sthb->execute; + my $recordb = $sthb->fetchrow_hashref; - # page header - &print_header; + # page header + &print_header; - # budget header - print <
feral budget generator | | $website_url/$script_name @@ -816,27 +849,27 @@ sub compile_budget {
$projectname | | $recordb->{location} | | - budget adjustments to $currentyear-$currentmonth-$currentdayofmonth + budget adjustments to $currentdayofmonth-$currentmonth-$currentyear
END - if ($agent_id ne "") { - while (my $recordfc = $sthfc->fetchrow_hashref) { - print <[$recordfc->{count}]. This budget will remain open for editing until $recordb->{end_date}. Monetary items will be kept anonymous (although identifable to the budget r/administrators). Labour & resources will be tagged with the name of the contributor. + if ($agent_id ne "") { + while (my $recordfc = $sthfc->fetchrow_hashref) { + print <[$recordfc->{count}]. This multi-player budget will remain open for editing until $recordb->{end_date}. Monetary items will be kept anonymous (although identifable to the budget r/administrators). Labour & resources will be tagged with the name of the contributor. END + } } - } - print <
END - # CGI parameter forms - $sthr->execute; - while (my $recordr = $sthr->fetchrow_hashref) { - print<execute; + while (my $recordr = $sthr->fetchrow_hashref) { + print< @@ -847,10 +880,10 @@ END END - } + } - if ($agent_id eq "") { - print< @@ -858,8 +891,8 @@ END END - } else { - print< @@ -867,146 +900,146 @@ END END - } + } - # budget columns - print <
END - print_title("FINANCIAL"); + print_title("FINANCIAL"); - print_subtitle("OUTGOINGS: / money requested or supplied"); + print_subtitle("OUTGOINGS: / money requested or supplied"); - print_subtitle("Labour / paid"); + print_subtitle("Labour / paid"); - while (my $recordef = $sthef->fetchrow_hashref) { - my $cost = $recordef->{cost}; - $display_cost = sprintf "%.2f",$cost; - $display_cost =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma - print <fetchrow_hashref) { + my $cost = $recordef->{cost}; + $display_cost = sprintf "%.2f",$cost; + $display_cost =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma + print <

$recordef->{item}

$recordef->{currency}$display_cost

END - } - print_subtitle("Resources / remunerated"); - - while (my $recordem = $sthem->fetchrow_hashref) { - my $cost = $recordem->{cost}; - $display_cost = sprintf "%.2f",$cost; - $display_cost =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma - - print_item("$recordem->{item}","$recordem->{currency}$display_cost"); - } - - print_subtitle("Miscellaneous"); - - while (my $recordex = $sthex->fetchrow_hashref) { - my $cost = $recordex->{cost}; - $display_cost = sprintf "%.2f",$cost; - $display_cost =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma - - print_item("$recordex->{item}", ">$recordex->{currency}$display_cost"); - } - - print_subtitle("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()) { - $deposits = $recordar->{qty}*50; - $running = $sum[0]+$deposits; - $display_running = sprintf "%.2f",$running; - $display_running =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma - - print_subtotal(" "); # spacing before running lines - print_subtotal("RUNNING total IN:", "€$display_running"); } - } + print_subtitle("Resources / remunerated"); - while (my @sumex = $sthse->fetchrow_array()) { - $runningex = $sumex[0]; - $surplus = $running - $runningex; - $display_runningex = sprintf "%.2f",$runningex; - $display_runningex =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma - $display_surplus = sprintf "%.2f",$surplus; - $display_surplus =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma + while (my $recordem = $sthem->fetchrow_hashref) { + my $cost = $recordem->{cost}; + $display_cost = sprintf "%.2f",$cost; + $display_cost =~ 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_item("$recordem->{item}","$recordem->{currency}$display_cost"); + } - print <fetchrow_hashref) { + my $cost = $recordex->{cost}; + $display_cost = sprintf "%.2f",$cost; + $display_cost =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma + + print_item("$recordex->{item}", "$recordex->{currency}$display_cost"); + } + + print_subtitle("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()) { + $deposits = $recordar->{qty}*50; + $running = $sum[0]+$deposits; + $display_running = sprintf "%.2f",$running; + $display_running =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma + + print_subtotal(" "); # spacing before running lines + print_subtotal("RUNNING total IN:", "€$display_running"); + } + } + + while (my @sumex = $sthse->fetchrow_array()) { + $runningex = $sumex[0]; + $surplus = $running - $runningex; + $display_runningex = sprintf "%.2f",$runningex; + $display_runningex =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma + $display_surplus = sprintf "%.2f",$surplus; + $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 <
)); - &print_footer; + print(qq()); + &print_footer; } # 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" + $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" } @@ -1015,85 +1048,85 @@ sub get_initials { sub prepare_expenditure { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT item, cost, currency, firstname, lastname, type FROM expenditure LEFT JOIN agents on expenditure.agent_id = agents.id WHERE expenditure.budget_id = $budget_id ORDER BY fullname); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT item, cost, currency, firstname, lastname, type FROM expenditure LEFT JOIN agents on expenditure.agent_id = agents.id WHERE expenditure.budget_id = $budget_id ORDER BY fullname); + my $sth = $dbh->prepare($sql); + $sth->execute; - my $sqln = qq( SELECT name FROM budgets where id = $budget_id); - my $sthn = $dbh->prepare($sqln); - $sthn->execute; + my $sqln = qq( SELECT name FROM budgets where id = $budget_id); + my $sthn = $dbh->prepare($sqln); + $sthn->execute; - &print_header; - print(qq(
\n)); - print(qq(\n)); - print(qq(
\n)); + &print_header; + print(qq(
\n)); + print(qq(
\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); - print(qq(\n)); + print(qq(\n)); - while (my $recordn = $sthn->fetchrow_hashref) { - print(qq()); - } + while (my $recordn = $sthn->fetchrow_hashref) { + print(qq()); + } - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - print(qq(\n)); + print(qq(\n)); - for ($i=1;$i<=23;$i++) { - while (my $record = $sth->fetchrow_hashref) { + for ($i=1;$i<=23;$i++) { + while (my $record = $sth->fetchrow_hashref) { - my $cost = $record->{cost}; - $dec_cost = sprintf "%.2f",$cost; ## 2 decimal places + my $cost = $record->{cost}; + $dec_cost = sprintf "%.2f",$cost; ## 2 decimal places - 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 + 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(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + + $i++ } - print(qq(>$currency)); - } - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); } - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - } - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); } @@ -1102,88 +1135,88 @@ sub prepare_expenditure { sub input_expenditure { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - # clear previous entries - my $sql_del = (qq{DELETE FROM expenditure WHERE budget_id=$budget_id}); - my $sth_del = $dbh->prepare($sql_del); - $sth_del->execute; + # clear previous entries + my $sql_del = (qq{DELETE FROM expenditure WHERE budget_id=$budget_id}); + my $sth_del = $dbh->prepare($sql_del); + $sth_del->execute; - for ($i=1; $i<=25; $i++) { - if ($new_item{$i} ne '') { - my $sql = (qq{INSERT INTO expenditure (budget_id, item, cost, currency) VALUES ($budget_id, '$new_item{$i}', $cost{$i}, '$currency{$i}')}); - my $sth = $dbh->prepare($sql); - $sth->execute; + for ($i=1; $i<=25; $i++) { + if ($new_item{$i} ne '') { + my $sql = (qq{INSERT INTO expenditure (budget_id, item, cost, currency) VALUES ($budget_id, '$new_item{$i}', $cost{$i}, '$currency{$i}')}); + my $sth = $dbh->prepare($sql); + $sth->execute; + } } - } - # read back expenditure info + # read back expenditure info - my $sql2 = qq( SELECT budget_id, item, cost, currency FROM expenditure LEFT JOIN budgets on expenditure.budget_id=budgets.id WHERE expenditure.budget_id = '$budget_id' ORDER BY expenditure.id); - my $sth2 = $dbh->prepare($sql2); - $sth2->execute; + my $sql2 = qq( SELECT budget_id, item, cost, currency FROM expenditure LEFT JOIN budgets on expenditure.budget_id=budgets.id WHERE expenditure.budget_id = '$budget_id' ORDER BY expenditure.id); + my $sth2 = $dbh->prepare($sql2); + $sth2->execute; - &print_header; + &print_header; - print(qq(
\n)); - print(qq(
feral budget generator
feral budget generator
Expenditure: $recordn->{name}
Expenditure: $recordn->{name}
agentitemcostkind
agentitemcostkind
$i.[$first_init$last_init]
$i.[$first_init$last_init]
$i.
$i.




\n)); - print(qq(\n)); + print(qq(
\n)); - print(qq(\n)); - print(qq()); + print(qq(
\n)); + print(qq(
feral budget generator
Expenditure
\n)); + print(qq( \n)); + print(qq( \n)); + } + print(qq(\n)); + print(qq(
\n)); + print(qq(\n)); + print(qq()); - print(qq(
feral budget generator
Expenditure
\n)); - print(qq( \n)); - while (my $record2 = $sth2->fetchrow_hashref) { - my $cost = $record2->{cost}; - $dec_cost = sprintf "%.2f",$cost; ## 2 decimal places + print(qq(
item cost
\n)); + print(qq( \n)); + while (my $record2 = $sth2->fetchrow_hashref) { + my $cost = $record2->{cost}; + $dec_cost = sprintf "%.2f",$cost; ## 2 decimal places - # print(qq( \n)); - print(qq( \n)); - } - print(qq(\n)); - print(qq(
item cost
$record2->{item} $record2->{currency}$record2->{cost}
$record2->{item} $dec_cost
\n)); + # print(qq(
$record2->{item} $record2->{currency}$record2->{cost}
$record2->{item} $dec_cost
\n)); - print(qq(\n)); - print(qq(
\n)); + print(qq(\n)); + print(qq(
\n)); - my $sql = qq( SELECT * from finance LEFT JOIN agents ON finance.agent_id=agents.id + my $sql = qq( SELECT * 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 $sth = $dbh->prepare($sql); - $sth->execute; + my $sth = $dbh->prepare($sql); + $sth->execute; - $sth->execute; - while (my $record = $sth->fetchrow_hashref) { + $sth->execute; + while (my $record = $sth->fetchrow_hashref) { - print(qq(
\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); + print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(
\n)); - print(qq(\n)); - } + print(qq(
\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); + print(qq(\n)); + } - # print(qq(

add or ammend more expenditure items\n)); - # print(qq(

got to view the budget as a whole\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + # print(qq(

add or ammend more expenditure items\n)); + # print(qq(

got to view the budget as a whole\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - $dbh->disconnect; + $dbh->disconnect; } @@ -1192,71 +1225,71 @@ sub input_expenditure { sub prepare_agents { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT * FROM agents WHERE budget_id = $budget_id ORDER BY lastname); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT * FROM agents WHERE budget_id = $budget_id ORDER BY lastname); + my $sth = $dbh->prepare($sql); + $sth->execute; - my $sqlc = qq( SELECT COUNT(*) AS count FROM agents WHERE budget_id = $budget_id); - my $sthc = $dbh->prepare($sqlc); - $sthc->execute; + my $sqlc = qq( SELECT COUNT(*) AS count FROM agents WHERE budget_id = $budget_id); + my $sthc = $dbh->prepare($sqlc); + $sthc->execute; - my $sqln = qq( SELECT name FROM budgets where id = $budget_id); - my $sthn = $dbh->prepare($sqln); - $sthn->execute; + my $sqln = qq( SELECT name FROM budgets where id = $budget_id); + my $sthn = $dbh->prepare($sqln); + $sthn->execute; - &print_header; - print(qq(
\n)); - print(qq(\n)); - print(qq(
\n)); + &print_header; + print(qq(
\n)); + print(qq(
\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); - print(qq(\n)); + print(qq(\n)); - while (my $recordn = $sthn->fetchrow_hashref) { - print(qq()); - } - - print(qq(\n)); - - for ($i=1;$i<=50;$i++) { - while (my $record = $sth->fetchrow_hashref) { - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - $i++ + while (my $recordn = $sthn->fetchrow_hashref) { + print(qq()); } - } - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); - while (my $recordc = $sthc->fetchrow_hashref) { - my $c = ($recordc->{count}); - for ($i=1+$c;$i<=50;$i++) { - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - # $i++ + for ($i=1;$i<=50;$i++) { + while (my $record = $sth->fetchrow_hashref) { + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + $i++ + } } - } - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + + while (my $recordc = $sthc->fetchrow_hashref) { + my $c = ($recordc->{count}); + for ($i=1+$c;$i<=50;$i++) { + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + # $i++ + } + } + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); } @@ -1265,50 +1298,50 @@ sub prepare_agents { sub edit_agent { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - # read in agent data + # read in agent data - &print_header; - print(qq(
\n)); - print(qq(
feral budget generator
feral budget generator
Agents: $recordn->{name}
firstnamelastnamecodename
$record->{firstname}$record->{lastname}$record->{codename}
Agents: $recordn->{name}
firstnamelastnamecodename
$i.
$record->{firstname}$record->{lastname}$record->{codename}


$i.


\n)); - print(qq(
\n)); - print(qq(\n)); - print(qq()); + &print_header; + print(qq(
\n)); + print(qq(
feral budget generator
Edit agent
\n)); + print(qq(
\n)); + print(qq(\n)); + print(qq()); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - print(qq(
feral budget generator
Edit agent
\n)); + print(qq(
\n)); - print(qq(\n)); - print(qq(
\n)); + print(qq(\n)); + print(qq(
\n)); - print(qq(
\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); + print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - $dbh->disconnect; + $dbh->disconnect; } ############################################################################ @@ -1316,37 +1349,37 @@ sub edit_agent { sub update_agent { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = (qq{UPDATE agents set firstname='$new_firstname', lastname='$new_lastname', fullname='$new_firstname $new_lastname', codename='$new_codename' WHERE budget_id=$budget_id AND id=$edit_agent_id}); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = (qq{UPDATE agents set firstname='$new_firstname', lastname='$new_lastname', fullname='$new_firstname $new_lastname', codename='$new_codename' WHERE budget_id=$budget_id AND id=$edit_agent_id}); + my $sth = $dbh->prepare($sql); + $sth->execute; - # read back agent info + # read back agent info - &print_header; - print(qq(
\n)); - print(qq(
\n)); - print(qq(
\n)); - print(qq(\n)); + &print_header; + print(qq(
\n)); + print(qq(
feral budget generator
\n)); + print(qq(\n)); + # print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); + print(qq(\n)); - print(qq(
feral budget generator
\n)); - print(qq(
\n)); + print(qq(\n)); + print(qq(
\n)); - print(qq(
\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); + print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - $dbh->disconnect; + $dbh->disconnect; } @@ -1355,43 +1388,43 @@ sub update_agent { sub input_agents { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - for ($i=1; $i<=50; $i++) { - if ($new_firstname{$i} ne '') { - my $sql = (qq{INSERT INTO agents (budget_id, firstname, lastname, fullname, codename) VALUES ($budget_id, '$new_firstname{$i}', '$new_lastname{$i}', '$new_firstname{$i} $new_lastname{$i} ','$new_codename{$i}')}); - # my $sql = (qq{INSERT INTO agents (budget_id, firstname, lastname, codename) VALUES ($budget_id, '$new_firstname{i}', '$new_lastname{i}', '$new_codename{i}')}); - my $sth = $dbh->prepare($sql); - $sth->execute; + for ($i=1; $i<=50; $i++) { + if ($new_firstname{$i} ne '') { + my $sql = (qq{INSERT INTO agents (budget_id, firstname, lastname, fullname, codename) VALUES ($budget_id, '$new_firstname{$i}', '$new_lastname{$i}', '$new_firstname{$i} $new_lastname{$i} ','$new_codename{$i}')}); + # my $sql = (qq{INSERT INTO agents (budget_id, firstname, lastname, codename) VALUES ($budget_id, '$new_firstname{i}', '$new_lastname{i}', '$new_codename{i}')}); + my $sth = $dbh->prepare($sql); + $sth->execute; + } } - } - # read back agent info + # read back agent info - &print_header; - print(qq(
\n)); - print(qq(
\n)); - print(qq(
\n)); - print(qq(\n)); + &print_header; + print(qq(
\n)); + print(qq(
feral budget generator
\n)); + print(qq(\n)); + #print(qq(\n)); + #print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); + print(qq(\n)); - print(qq(
feral budget generator
\n)); - print(qq(
\n)); + print(qq(\n)); + print(qq(
\n)); - print(qq(
\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); + print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - $dbh->disconnect; + $dbh->disconnect; } ############################################################################ @@ -1399,50 +1432,50 @@ sub input_agents { sub add_form { - &print_header; - print(qq(
\n)); - print(qq( $projectname: add a budget \n)); + &print_header; + print(qq(
\n)); + print(qq( $projectname: add a budget \n)); - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); + my $sth = $dbh->prepare($sql); + $sth->execute; - print(qq(

 

\n)); - print(qq(\n)); - print(qq(
\n)); - print(qq()); - while (my $record = $sth->fetchrow_hashref) { - print(qq()); - print(qq()); - print(qq()); - print(qq()); - } - print(qq(\n)); + print(qq(

 

\n)); + print(qq(\n)); + print(qq(
BudgetDate
)); - print(qq($record->{name} $record->{date}
 
\n)); + print(qq()); + while (my $record = $sth->fetchrow_hashref) { + print(qq()); + print(qq()); + print(qq()); + print(qq()); + } + print(qq(\n)); - $dbh->disconnect; + $dbh->disconnect; - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); - #print(qq(\n)); - #print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(
BudgetDate
)); + print(qq($record->{name} $record->{date}
 
add a new budget
\n)); - print(qq(
date
)); + print(qq(\n)); + print(qq(\n)); + print(qq(
add a new budget
\n)); + print(qq(
date
)); - print(qq(

\n)); + print(qq(

\n)); - print(qq(
 
password

\n)); + print(qq(
 
password

\n)); - &print_footer; + &print_footer; - $dbh->disconnect; + $dbh->disconnect; } @@ -1451,65 +1484,65 @@ sub add_form { sub add_budget { - #if ($password eq $admin_password) { + #if ($password eq $admin_password) { - ### test if workshop exists already in database - if ($new_name ne '') { + ### test if workshop exists already in database + if ($new_name ne '') { - $new_name_found='false'; - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + $new_name_found='false'; + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT DISTINCT name FROM budgets); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT DISTINCT name FROM budgets); + my $sth = $dbh->prepare($sql); + $sth->execute; - while (my $record = $sth->fetchrow_hashref) { - if ($record->{name} eq $new_name) { - $new_name_found='true'; - } - } + while (my $record = $sth->fetchrow_hashref) { + if ($record->{name} eq $new_name) { + $new_name_found='true'; + } + } - if ($new_name_found eq 'false') { + if ($new_name_found eq 'false') { - my $sql = (qq{INSERT INTO budgets (name) VALUES ('$new_name')}); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = (qq{INSERT INTO budgets (name) VALUES ('$new_name')}); + my $sth = $dbh->prepare($sql); + $sth->execute; - my $sql2 = (qq{ SELECT * from budgets where name='$new_name'}); - my $sth2 = $dbh->prepare($sql2); - $sth2->execute; + my $sql2 = (qq{ SELECT * from budgets where name='$new_name'}); + my $sth2 = $dbh->prepare($sql2); + $sth2->execute; - $dbh->disconnect; + $dbh->disconnect; - &print_header; + &print_header; - while (my $record2 = $sth2->fetchrow_hashref) { - print(qq(
\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(
budget added $new_name
\n)); - } - &print_footer; + while (my $record2 = $sth2->fetchrow_hashref) { + print(qq(
\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
budget added $new_name
\n)); + } + &print_footer; + } else { + &print_header; + print(qq(duplicate budget entry
\n)); + &print_footer; + } } else { - &print_header; - print(qq(duplicate budget entry
\n)); - &print_footer; + &print_header; + print(qq(no budget entered
\n)); + &print_footer; } - } else { - &print_header; - print(qq(no budget entered
\n)); - &print_footer; - } - #} else { + #} else { - #&print_header; - #print(qq(

Wrong password !

\n)); - #&print_footer; + #&print_header; + #print(qq(

Wrong password !

\n)); + #&print_footer; - # } + # } } @@ -1518,23 +1551,23 @@ sub add_budget { sub add_budget_information { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); - my $sql = (qq{UPDATE budgets SET location='$new_location', deliver_date='$new_deliver_date', remarks='$new_remarks', + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); + my $sql = (qq{UPDATE budgets SET location='$new_location', deliver_date='$new_deliver_date', remarks='$new_remarks', WHERE name='$new_name'}); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sth = $dbh->prepare($sql); + $sth->execute; - $dbh->disconnect; - &print_header; + $dbh->disconnect; + &print_header; - print(qq(

\n)); - print(qq( $projectname: $new_name added )); - #print(qq($add_information \n)); - print(qq(

view all budgets

\n)); - print(qq(

\n)); + print(qq(
\n)); + print(qq( $projectname: $new_name added )); + #print(qq($add_information \n)); + print(qq(

view all budgets

\n)); + print(qq(

\n)); - &print_footer; + &print_footer; } ############################################################################### @@ -1542,32 +1575,32 @@ sub add_budget_information { sub edit_select_form { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); + my $sth = $dbh->prepare($sql); + $sth->execute; - &print_header; + &print_header; - print(qq(
\n)); - print(qq( edit a budget
\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - while (my $record = $sth->fetchrow_hashref) { - print(qq(\n)); + print(qq(\n)); + print(qq(
\n)); - print(qq( $record->{name}\n)); - } + print(qq(
\n)); + print(qq( edit a budget
\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + while (my $record = $sth->fetchrow_hashref) { + print(qq(\n)); - print(qq(\n)); - print(qq(
\n)); + print(qq( $record->{name}\n)); + } - print(qq(
\n)); + print(qq(
\n)); - $dbh->disconnect; + $dbh->disconnect; - &print_footer; + &print_footer; } @@ -1576,44 +1609,44 @@ sub edit_select_form { sub edit_form { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT DISTINCT * FROM budgets WHERE id=$edit_id); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT DISTINCT * FROM budgets WHERE id=$edit_id); + my $sth = $dbh->prepare($sql); + $sth->execute; - &print_header; + &print_header; - print(qq(
\n)); + print(qq(
\n)); - print(qq(

$projectname: edit budget

\n)); - # print(qq(\n)); + print(qq(

$projectname: edit budget

\n)); + # print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(
 
\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - while (my $record = $sth->fetchrow_hashref) { + while (my $record = $sth->fetchrow_hashref) { - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); - print(qq(\n)); - # print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(
 
location
url
location
url
Remarks: When, where, who
Remarks: When, where, who
password
\n)); - print(qq(
\n)); + print(qq(
password
\n)); + print(qq(
\n)); - } - &print_footer; + } + &print_footer; } ############################################################################### @@ -1621,44 +1654,44 @@ sub edit_form { sub present_budget { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT DISTINCT * FROM budgets WHERE id=$edit_id); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT DISTINCT * FROM budgets WHERE id=$edit_id); + my $sth = $dbh->prepare($sql); + $sth->execute; - &print_header; + &print_header; - # print(qq(
\n)); + # print(qq(
\n)); - print(qq(

$projectname: budget notes

\n)); - # print(qq(\n)); + print(qq(

$projectname: budget notes

\n)); + # print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(
\n)); + print(qq(\n)); - while (my $record = $sth->fetchrow_hashref) { + while (my $record = $sth->fetchrow_hashref) { - $record->{remarks} =~ s/\n/\
/g; + $record->{remarks} =~ s/\n/\
/g; - print(qq(\n)); - print(qq(\n)); - # print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + # print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - # print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + # print(qq(\n)); - # print(qq(\n)); - print(qq(\n)); - print(qq(
$record->{name}, \n)); - print(qq($record->{location} 
$record->{url}
$record->{name}, \n)); + print(qq($record->{location} 
$record->{url}
Remarks: When, where, who
$record->{remarks}
Remarks: When, where, who
$record->{remarks}
password
\n)); - print(qq(
\n)); + # print(qq(
password
\n)); + print(qq(
\n)); - } - &print_footer; + } + &print_footer; } @@ -1667,38 +1700,38 @@ sub present_budget { sub edit_budget { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - #if ($password eq $admin_password) { + #if ($password eq $admin_password) { - &print_header; + &print_header; - ### update budgets table + ### update budgets table - my $sql_update = (qq{UPDATE budgets SET name='$new_name', location='$new_location', url='$new_url', remarks='$new_remarks', deliver_date="$new_deliver_date" WHERE id='$edit_id'}); - my $sth_update = $dbh->prepare($sql_update); - $sth_update->execute; + my $sql_update = (qq{UPDATE budgets SET name='$new_name', location='$new_location', url='$new_url', remarks='$new_remarks', deliver_date="$new_deliver_date" WHERE id='$edit_id'}); + my $sth_update = $dbh->prepare($sql_update); + $sth_update->execute; - ### display results + ### display results - my $sql = qq( SELECT * FROM budgets WHERE id = '$edit_id'); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = qq( SELECT * FROM budgets WHERE id = '$edit_id'); + my $sth = $dbh->prepare($sql); + $sth->execute; - while (my $record = $sth->fetchrow_hashref) { + while (my $record = $sth->fetchrow_hashref) { - print(qq(
\n)); - # print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(
updated
$record->{name}

)); - } + print(qq(
\n)); + # print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(
updated
$record->{name}

)); + } - $dbh->disconnect; - &print_footer; + $dbh->disconnect; + &print_footer; } @@ -1707,34 +1740,34 @@ sub edit_budget { sub delete_form { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); + my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); + my $sth = $dbh->prepare($sql); + $sth->execute; - &print_header; + &print_header; - print(qq(
\n)); - print(qq( delete a budget
\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); + print(qq(
\n)); + print(qq( delete a budget
\n)); + print(qq(
\n)); + print(qq(\n)); + print(qq(\n)); - while (my $record = $sth->fetchrow_hashref) { - # print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(
\n)); - print(qq( $record->{name}\n)); - print(qq($record->{location}\n)); - } + while (my $record = $sth->fetchrow_hashref) { + # print(qq(\n)); + print(qq(
\n)); + print(qq( $record->{name}\n)); + print(qq($record->{location}\n)); + } - print(qq(
password
\n)); + print(qq(
password
\n)); - $dbh->disconnect; - &print_footer; + $dbh->disconnect; + &print_footer; } ############################################################################### @@ -1742,27 +1775,27 @@ sub delete_form { sub delete_budget { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); - my $sql = (qq{SELECT * FROM budgets WHERE id = '$delete_id'}); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $sql = (qq{SELECT * FROM budgets WHERE id = '$delete_id'}); + my $sth = $dbh->prepare($sql); + $sth->execute; - my $sql2 = (qq{DELETE FROM budgets WHERE id = '$delete_id'}); - my $sth2 = $dbh->prepare($sql2); - $sth2->execute; + my $sql2 = (qq{DELETE FROM budgets WHERE id = '$delete_id'}); + my $sth2 = $dbh->prepare($sql2); + $sth2->execute; - while (my $record = $sth->fetchrow_hashref) { + while (my $record = $sth->fetchrow_hashref) { - &print_header; + &print_header; - print(qq($record->{name} deleted\n)); + print(qq($record->{name} deleted\n)); - } + } - &print_footer; - $dbh->disconnect; + &print_footer; + $dbh->disconnect; } @@ -1771,33 +1804,33 @@ sub delete_budget { sub display_budgets { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); + my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); + my $sth = $dbh->prepare($sql); + $sth->execute; - &print_header; + &print_header; - print(qq(
\n)); - print(qq(

$projectname: all budgets: edit mode

\n)); + print(qq(
\n)); + print(qq(

$projectname: all budgets: edit mode

\n)); - print(qq(\n)); - print(qq(\n)); - while (my $record = $sth->fetchrow_hashref) { - print(qq(\n)); - print(qq()); - print(qq()); - print(qq()); - print(qq()); - # print(qq()); - print(qq(\n)); - } + print(qq(
BudgetLocationDateURL
$record->{name}$record->{location}$record->{deliver_date}$record->{url}
\n)); + print(qq(\n)); + while (my $record = $sth->fetchrow_hashref) { + print(qq(\n)); + print(qq()); + print(qq()); + print(qq()); + print(qq()); + # print(qq()); + print(qq(\n)); + } - $dbh->disconnect; + $dbh->disconnect; - print(qq(
BudgetLocationDateURL
$record->{name}$record->{location}$record->{deliver_date}$record->{url}
\n)); - &print_footer; + print(qq(
\n)); + &print_footer; } @@ -1806,34 +1839,34 @@ sub display_budgets { sub list_budgets { - my $dbh = DBI->connect($db_conect,$db_user,$db_pass) - or die ("can't connect: $DBI::errstr"); - my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); - my $sth = $dbh->prepare($sql); - $sth->execute; + my $dbh = DBI->connect($db_conect,$db_user,$db_pass) + or die ("can't connect: $DBI::errstr"); + my $sql = qq( SELECT DISTINCT * FROM budgets ORDER BY id); + my $sth = $dbh->prepare($sql); + $sth->execute; - &print_header; + &print_header; - print(qq(
\n)); - print(qq(

$projectname: all budgets: read-only

\n)); + print(qq(
\n)); + print(qq(

$projectname: all budgets: read-only

\n)); - print(qq(\n)); - print(qq(\n)); - while (my $record = $sth->fetchrow_hashref) { - print(qq(\n)); - print(qq()); - print(qq()); - print(qq()); - print(qq()); - # print(qq()); - print(qq(\n)); - } + print(qq(
BudgetLocationDateURL
$record->{name}$record->{location}$record->{deliver_date}$record->{url}
\n)); + print(qq(\n)); + while (my $record = $sth->fetchrow_hashref) { + print(qq(\n)); + print(qq()); + print(qq()); + print(qq()); + print(qq()); + # print(qq()); + print(qq(\n)); + } - $dbh->disconnect; + $dbh->disconnect; - print(qq(
BudgetLocationDateURL
$record->{name}$record->{location}$record->{deliver_date}$record->{url}
\n)); + print(qq(
\n)); - &print_footer; + &print_footer; } ############################################################################################## @@ -1841,67 +1874,67 @@ sub list_budgets { sub select_start_date { - ### day - print(qq(
\n)); + for ( $i=1; $i<10; $i+=1) { + print(qq(0$i\n)); } - if (($new_start_day eq "") && ($currentdayofmonth eq $i)) { - print(qq( selected)); + for ( $i=10; $i<32; $i+=1) { + print(qq($i\n)); } - print(qq(>0$i\n)); - } - for ( $i=10; $i<32; $i+=1) { - print(qq($i\n)); - } - print(qq(\n)); + print(qq(\n)); - ### month - print(qq(\n)); + print(qq(\n)); - ### year - print(qq(

all budgets: edit

all budgets: list