Browse Source

code cleaning

* removed unused sub in Budgets.pm
* lot of cleaning in aqplan.pl
* typo changes in aqplan.tmpl
3.2.x
Paul Poulain 15 years ago
committed by Henri-Damien LAURENT
parent
commit
521bb9654d
  1. 32
      C4/Budgets.pm
  2. 155
      admin/aqplan.pl
  3. 4
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqplan.tmpl

32
C4/Budgets.pm

@ -47,7 +47,6 @@ BEGIN {
&GetBudgetPeriodsDropbox
&GetBudgetSortDropbox
&GetAuthcatDropbox
&GetAuthvalueDropbox
&GetBudgetPermDropbox
@ -332,37 +331,6 @@ sub GetBudgetPermDropbox {
return $radio;
}
# -------------------------------------------------------------------
sub GetAuthcatDropbox {
my ($name, $default ) = @_;
my @authorised_values;
my $value;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare(qq|
SELECT distinct(category)
FROM authorised_values WHERE category LIKE 'Asort%'
ORDER BY lib |
);
$sth->execute();
push @authorised_values, '';
while (my $value = $sth->fetchrow_array) {
push @authorised_values, $value;
}
my $budget_authcat_dropbox = CGI::scrolling_list(
-name => $name,
-values => \@authorised_values,
-override => 1,
-size => 1,
-default => $default,
-multiple => 0,
-tabindex => 1,
-id => $name,
);
return $budget_authcat_dropbox;
}
# -------------------------------------------------------------------
sub GetBudgetAuthCats {
my ($budget_period_id) = shift;

155
admin/aqplan.pl

@ -100,15 +100,6 @@ my $del = $input->param("sep");
my $show_mine = $input->param('show_mine') ;
my @hide_cols = $input->param('hide_cols');
#### @hide_cols
=c
my $show_mine = 1; #SHOW BY DEFAULT
my $show = $input->param('show'); # SET TO 1, BY A FORM SUMBIT
$show_mine = $input->param('show_mine') if $show == 1;
=cut
my $cur_format = C4::Context->preference("CurrencyFormat");
my $num;
@ -141,10 +132,6 @@ my $op = $input->param("op");
my $budget_branchcode;
#my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $budget_branchcode );
## ## $budgets_ref
my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{param_map}->{'USER_INFO'}[0]->{'branchcode'}:'', $show_mine?$template->{param_map}->{'USER_INFO'}[0]->{'borrowernumber'}:'' );
# build categories list
@ -161,12 +148,11 @@ while ( my ($category) = $sth->fetchrow_array ) {
$categories{$category} = 1;
}
# push koha system categories
push( @category_list, 'MONTHS' );
push( @category_list, 'ITEMTYPES' );
push( @category_list, 'BRANCHES' );
# push koha system categories
#reorder the list
@category_list = sort { $a cmp $b } @category_list;
my $tab_list = CGI::scrolling_list(
@ -191,13 +177,6 @@ my %labels;
# ------------------------------------------------------------
if ( $op eq 'save' ) {
### --------------------- save
#### @names
#get budgets
my ( @buds, @auth_values );
foreach my $n (@names) {
@ -241,67 +220,25 @@ if ( $op eq 'save' ) {
my $plan = \@budget_lines;
ModBudgetPlan( $plan, $budget_period_id, $authcat );
#### iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
HideCols($authcat, @hide_cols);
}
# ------------------------------------------------------------
if ( $authcat =~ m/^Asort/ ) {
#### eeeee
# ----------- copied from C4::Input::buildCGIsort()
my $query = qq{ SELECT * FROM authorised_values WHERE category=? order by lib };
my $sth = $dbh->prepare($query);
#### $query
# $sth->{TraceLevel} = 2;
$sth->execute($authcat );
=c
my $query = qq{
SELECT * FROM authorised_values
JOIN aqbudgets_planning ON
(aqbudgets_planning.authvalue = authorised_values.authorised_value )
WHERE (authcat = ?
AND category = ?
AND budget_period_id = ?
AND display = 1 )
ORDER BY lib };
my $sth = $dbh->prepare($query);
#### $query
$sth->{TraceLevel} = 2;
$sth->execute($authcat, $authcat, $budget_period_id );
=cut
#### qq
if ( $sth->rows > 0 ) {
for ( my $i = 0 ; $i < $sth->rows ; $i++ ) {
my $results = $sth->fetchrow_hashref;
push @authvals, $results->{authorised_value};
$labels{ $results->{authorised_value} } = $results->{lib};
# $labels{ $results->{display} } = 1 ;
}
}
$sth->finish;
@authvals = sort { $a <=> $b } @authvals;
#### @authvals
}
elsif ( $authcat eq 'MONTHS' ) {
@ -327,22 +264,8 @@ elsif ( $authcat eq 'MONTHS' ) {
}
elsif ( $authcat eq 'ITEMTYPES' ) {
#### aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
my $query = qq| SELECT itemtype, description FROM itemtypes |;
=c
my $query = qq| SELECT * FROM aqbudgets_planning
JOIN itemtypes ON (aqbudgets_planning.authvalue = itemtypes.itemtype)
WHERE (authcat = 'itemtypes'
AND budget_period_id = ? ) |;
=cut
my $sth = $dbh->prepare($query);
$sth->{TraceLevel} = 3;
#$sth->execute( $budget_period_id );
$sth->execute( );
if ( $sth->rows > 0 ) {
@ -354,14 +277,6 @@ elsif ( $authcat eq 'ITEMTYPES' ) {
}
$sth->finish;
#### @authvals
} elsif ( $authcat eq 'BRANCHES' ) {
my $query = qq| SELECT branchcode, branchname FROM branches |;
@ -378,11 +293,6 @@ elsif ( $authcat eq 'ITEMTYPES' ) {
$sth->finish;
}
#### @authvals
#### %labels
my @authvals_row;
my $i=1;
foreach my $val (@authvals) {
@ -396,36 +306,21 @@ foreach my $val (@authvals) {
push( @authvals_row, \%auth_hash );
}
#### ddddddddddddd
#### @authvals_row
#get budgets
my ( @buds, @auth_values );
foreach my $n (@names) {
next if $n =~ m/^[^0-9]/;
$n =~ m/(\d*),(.*)/;
push @buds, $1;
push @auth_values, $2;
}
#get budgets
my ( @buds, @auth_values );
foreach my $n (@names) {
next if $n =~ m/^[^0-9]/;
$n =~ m/(\d*),(.*)/;
push @buds, $1;
push @auth_values, $2;
}
# ------------------------------------------------------------
# DEFAULT DISPLAY BEGINS
my @mime = ( C4::Context->preference("MIME") );
foreach my $mime (@mime) {
# warn "".$mime;
}
my $CGIextChoice = CGI::scrolling_list(
-name => 'MIME',
-id => 'MIME',
@ -446,9 +341,6 @@ my $CGIsepChoice = CGI::scrolling_list(
my ( @budget_lines, %cell_hash );
foreach my $budget (@budgets) {
my $budget_lock;
@ -504,9 +396,6 @@ foreach my $budget (@budgets) {
$i++;
}
# lines => \@cells_line,
my $budget_act_remain = $budget->{budget_amount} - $actual_spent;
my $budget_est_remain = $budget->{budget_amount} - $estimated_spent;
@ -532,9 +421,6 @@ foreach my $budget (@budgets) {
# skip if active set , and spent == 0
next if ( $show_active == '1' && ( $actual_spent == 0 ) );
### %budget_lin
push( @budget_lines, \%budget_line );
}
@ -543,8 +429,6 @@ if ( $output eq "file" ) {
exit(1);
}
## ## @budget_lines
$template->param(
authvals_row => \@authvals_row,
budget_lines => \@budget_lines,
@ -564,27 +448,9 @@ $template->param(
authvals => \@authvals_row,
hide_cols_loop => \@hide_cols
);
#### uuuuuuuuuuu
output_html_with_http_headers $input, $cookie, $template->output;
sub _print_to_csv {
my ( $header, $results ) = @_;
@ -620,5 +486,4 @@ sub _print_to_csv {
my $str = $csv->string;
print "$str\n";
}
}
}

4
koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqplan.tmpl

@ -211,7 +211,7 @@ YAHOO.util.Event.onAvailable("popmenu", function () {
<td align="right">
<!--TMPL_IF Name="budget_lock" -->
<!-- TMPL_VAR NAME="estimated_amount" -->uu&nbsp;
<!-- TMPL_VAR NAME="estimated_amount" -->&nbsp;
<input type="hidden" style="text-align: right;" name='<!-- TMPL_VAR NAME="cell_name"-->' value="<!-- TMPL_VAR NAME="estimated_amount" -->" >
<!--TMPL_ELSE -->
<input type="text" style="text-align: right; width:90%; " size='6' name='<!-- TMPL_VAR NAME="cell_name"-->' value="<!-- TMPL_VAR NAME="estimated_amount" -->" id='<!-- TMPL_VAR NAME="budget_id"-->' class='<!-- TMPL_VAR NAME="budget_id"-->' onchange="calcTotalRow(this);" >
@ -246,7 +246,7 @@ YAHOO.util.Event.onAvailable("popmenu", function () {
<!-- TMPL_UNLESS Name="budget_lock" -->
<input type="button" onclick="autoFillRow('<!-- TMPL_VAR NAME="budget_id"-->')" value="Auto-fill row"/>
<!-- TMPL_ELSE -->
<div style="color:red;">LOCKED</div>
<div style="color:red;">not owned</div>
<!-- /TMPL_UNLESS -->
</td>
</tr>

Loading…
Cancel
Save