diff --git a/f20-budget.pl b/f20-budget.pl index b11d242..07e2898 100644 --- a/f20-budget.pl +++ b/f20-budget.pl @@ -82,24 +82,24 @@ $new_rstatus = sanitise($q->param("new_rstatus")); $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 +120,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 +181,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 +206,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 +230,8 @@ END
END - &print_footer; - $dbh->disconnect; + &print_footer; + $dbh->disconnect; } @@ -244,28 +244,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,140 +303,172 @@ 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()); - } + @cats = ('select category', 'fee', 'materials', 'misc'); + foreach $cat(@cats) { + print(qq({type}) { + print(qq( selected)); } + print(qq(>$cat)); + } + 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
\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; - - for ($i=1;$i<=8;$i++) { - while (my $record5 = $sth5->fetchrow_hashref) { - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - $i++ - } - if ($i<=5) { - print(qq(\n)); - print(qq(\n)); - print(qq(\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; - - for ($i=1;$i<=8;$i++) { - while (my $record5 = $sth5->fetchrow_hashref) { - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - $i++ - } - if ($i<=5) { - 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(
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(qq(CHECKED)); - } - ; - print(qq(>
$i.{status} eq 'delivered') { - print(qq(CHECKED)); - } - ; - print(qq(>
 
input resourcesmaterials, spaces, tools, previous work etc (check the box if your resource has already been deployed)
$i.{status} eq 'delivered') { - print(qq(CHECKED)); - } - ; - print(qq(>
$i.{status} eq 'delivered') { - print(qq(CHECKED)); - } - print(qq(>
Notes:
\n)); - - } else { - & print_header; - print(qq(codename not recognised. please retry\n)); + print(qq(item )); } + } + + 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++ + } + } + + print < + +END + } + + print < + + + + + + + +END + + # print ""; + + # $sthCL->execute; + # while (my $recordCL = $sthCL->fetchrow_hashref) { + # print " + +
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(qq(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(qq(CHECKED)); + } + ; + print(qq(>
+ + enter a number to add budget lines
OR add budget linesfor labour &/or resources
"; + # print " add this many budget lines for labour [after $recordCL->{count}]\n"; + # } + # $sthCR->execute; + # whle (my $recordCR = $sthCR->fetchrow_hashref) { + # print "
"; + # print " add this many budget lines for resources [after $recordCR->{count}]\n"; + # } + + print <Notes:
+ +END + + } else { + & print_header; + print(qq(codename not recognised. please retry\n)); } - &print_footer; - $dbh->disconnect; + } + &print_footer; + $dbh->disconnect; } @@ -448,174 +480,112 @@ 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; + ## 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; } - 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 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; } + } - ## 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; - } - } + ## read back in to get these values from the db, not from the cgi - ## 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 + 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( )); + 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)); + $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(
feral budget generator: $record->{name}
feral budget generator: $record->{name}
$projectname: $recordn->{fullname}
$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}
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)); + if (($new_start_year eq "") && ($currentyear eq $j)) { + print(qq( selected)); + } + print(qq(>$j\n)); + } + print(qq(\n)); } @@ -1904,53 +1936,57 @@ 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)); @@ -1991,4 +2027,4 @@ sub adminfooter { 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)); + 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)); @@ -627,8 +597,70 @@ sub input_money { 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; +############################################################################### +# 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; } @@ -640,10 +672,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 @@ -651,10 +683,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 @@ -663,10 +695,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 @@ -675,10 +707,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 @@ -687,10 +719,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 @@ -699,105 +731,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 @@ -810,22 +842,22 @@ sub compile_budget {
END - if ($agent_id ne "") { - while (my $recordfc = $sthfc->fetchrow_hashref) { - print <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. END - } } - print <
END - # CGI parameter forms - $sthr->execute; - while (my $recordr = $sthr->fetchrow_hashref) { - print<execute; + while (my $recordr = $sthr->fetchrow_hashref) { + print< @@ -836,10 +868,10 @@ END END - } + } - if ($agent_id eq "") { - print< @@ -847,8 +879,8 @@ END END - } else { - print< @@ -856,146 +888,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 $recordem = $sthem->fetchrow_hashref) { - my $cost = $recordem->{cost}; - $display_cost = sprintf "%.2f",$cost; - $display_cost =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma + 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_item("$recordem->{item}","$recordem->{currency}$display_cost"); - } + print_subtotal("RUNNING total OUT:","€$display_runningex"); + print_subtotal(" "); # spacing between running & balance lines + print_subtotal("BALANCE OF FINANCIAL TRADE:"," €$display_surplus"); + } - 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"); - } - } - - 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" } @@ -1004,85 +1036,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++ + # @currencies = ('€', '£', '$'); + @currencies = ('€'); + foreach $currency(@currencies) { + print(qq({currency}) { + print(qq( selected)); } - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - print(qq(\n)); - # @currencies = ('€', '£', '$'); - @currencies = ('€'); - foreach $currency(@currencies) { - print(qq({currency}) { - print(qq( selected)); - } - print(qq(>$currency\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)); + } + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); } @@ -1091,88 +1123,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; } @@ -1181,71 +1213,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()); + 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++ } + } - print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); + 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 $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)); - 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)); + } + print(qq(\n)); + print(qq(\n)); + print(qq(\n)); } @@ -1254,50 +1286,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}
Agents: $recordn->{name}
firstnamelastnamecodename
$record->{firstname}$record->{lastname}$record->{codename}
firstnamelastnamecodename
$record->{firstname}$record->{lastname}$record->{codename}
$i.
$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; } ############################################################################ @@ -1305,37 +1337,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; } @@ -1344,43 +1376,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; } ############################################################################ @@ -1388,50 +1420,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; } @@ -1440,65 +1472,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'; - } - } - - if ($new_name_found eq 'false') { - - 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; - - $dbh->disconnect; - - &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; - - } else { - &print_header; - print(qq(duplicate budget entry
\n)); - &print_footer; - } - } else { - &print_header; - print(qq(no budget entered
\n)); - &print_footer; + while (my $record = $sth->fetchrow_hashref) { + if ($record->{name} eq $new_name) { + $new_name_found='true'; + } } - #} else { + if ($new_name_found eq 'false') { - #&print_header; - #print(qq(

Wrong password !

\n)); - #&print_footer; + 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; + + $dbh->disconnect; + + &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; + + } else { + &print_header; + print(qq(duplicate budget entry
\n)); + &print_footer; + } + } else { + &print_header; + print(qq(no budget entered
\n)); + &print_footer; + } + + #} else { + + #&print_header; + #print(qq(

Wrong password !

\n)); + #&print_footer; + + # } } @@ -1507,23 +1539,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; } ############################################################################### @@ -1531,32 +1563,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; } @@ -1565,44 +1597,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; } ############################################################################### @@ -1610,44 +1642,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; } @@ -1656,38 +1688,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; } @@ -1696,34 +1728,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; } ############################################################################### @@ -1731,27 +1763,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; } @@ -1760,33 +1792,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; } @@ -1795,34 +1827,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; } ############################################################################################## @@ -1830,67 +1862,67 @@ sub list_budgets { sub select_start_date { - ### day - print(qq(
\n)); + print(qq(>0$i\n)); + } + for ( $i=10; $i<32; $i+=1) { + print(qq($i\n)); + } + print(qq(\n)); - ### month - print(qq(\n)); + for ( $j=1; $j<10; $j+=1) { + print(qq($j\n)); + if (($new_start_month eq "") && ($currentmonth eq $j)) { + print(qq( selected)); } - print(qq(\n)); + print(qq(>0$j\n)); + } + for ( $j=10; $j<13; $j+=1) { + print(qq($j\n)); + } + print(qq(\n)); - ### year - print(qq(\n)); + for ( $j=2003; $j<2022; $j+=1) { + print(qq(

all budgets: edit

all budgets: list