[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/admin aqbookfund.pl,1.21,1.22 aqbudget.pl,1.16,1.17
From: |
Henri-Damien LAURENT |
Subject: |
[Koha-cvs] CVS: koha/admin aqbookfund.pl,1.21,1.22 aqbudget.pl,1.16,1.17 |
Date: |
Wed, 06 Jul 2005 10:47:24 -0700 |
Update of /cvsroot/koha/koha/admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4747/admin
Modified Files:
aqbookfund.pl aqbudget.pl
Log Message:
Add branch selection and filter for budgets and funds.
May be too much... Funds could be enough....
It works provided you update your base adding branchcode both in aqbookfund AND
aqbudget.
If selection in budget is not needed, I shall remove.
Index: aqbookfund.pl
===================================================================
RCS file: /cvsroot/koha/koha/admin/aqbookfund.pl,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** aqbookfund.pl 4 May 2005 08:50:48 -0000 1.21
--- aqbookfund.pl 6 Jul 2005 17:47:22 -0000 1.22
***************
*** 42,45 ****
--- 42,46 ----
use C4::Auth;
use C4::Context;
+ use C4::Acquisition;
use C4::Output;
use C4::Interface::CGI::Output;
***************
*** 65,68 ****
--- 66,70 ----
}
+ my $dbh = C4::Context->dbh;
my $input = new CGI;
my $searchfield=$input->param('searchfield');
***************
*** 92,95 ****
--- 94,130 ----
$template->param(action => $script_name);
+ my @branches;
+ my @select_branch;
+ my %select_branches;
+ my ($count2,@branches)=branches();
+
+ push @select_branch,"";
+ $select_branches{""}="";
+
+ my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where
borrowernumber = ?");
+ $sthtemp->execute($borrowernumber);
+ my ($flags, $homebranch)=$sthtemp->fetchrow;
+ if ($flags>1){
+ if ($homebranch){
+ push @select_branch, $homebranch;#
+ for (my $i=0;$i<$count2;$i++){
+ $select_branches{$branches[$i]->{'branchcode'}} =
$branches[$i]->{'branchname'} if ($branches[$i]->{'branchcode'} eq $homebranch);
+ }
+ }
+ } else {
+ for (my $i=0;$i<$count2;$i++){
+ push @select_branch, $branches[$i]->{'branchcode'};#
+ $select_branches{$branches[$i]->{'branchcode'}} =
$branches[$i]->{'branchname'};
+ }
+ }
+ my $CGIbranch=CGI::scrolling_list( -name => 'branchcode',
+ -values => address@hidden,
+ -labels => \%select_branches,
+ -size => 1,
+ -multiple => 0 );
+ $template->param(CGIbranch => $CGIbranch);
+
+ warn "bornum=".$borrowernumber . "flags = ".$flags. " homebranch=
".$homebranch;
+ $sthtemp->finish;
################## ADD_FORM ##################################
***************
*** 100,104 ****
my $header;
if ($bookfundid) {
- my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select
bookfundid,bookfundname,bookfundgroup from aqbookfund where bookfundid=?");
$sth->execute($bookfundid);
--- 135,138 ----
***************
*** 127,131 ****
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
- my $dbh = C4::Context->dbh;
my $bookfundid=uc($input->param('bookfundid'));
my $sth=$dbh->prepare("delete from aqbookfund where bookfundid =?");
--- 161,164 ----
***************
*** 142,146 ****
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
- my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select bookfundid,bookfundname,bookfundgroup
from aqbookfund where bookfundid=?");
$sth->execute($bookfundid);
--- 175,178 ----
***************
*** 153,157 ****
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
- my $dbh = C4::Context->dbh;
my $bookfundid=uc($input->param('bookfundid'));
my $sth=$dbh->prepare("delete from aqbookfund where bookfundid=?");
--- 185,188 ----
***************
*** 173,185 ****
my $toggle="white";
my @loop_data =();
! my $dbh = C4::Context->dbh;
! my $sth2 = $dbh->prepare("Select
aqbudgetid,startdate,enddate,budgetamount from aqbudget where bookfundid = ?
order by bookfundid");
for (my $i=$offset; $i <
($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
my %row_data;
$row_data{bookfundid} =$results->[$i]{'bookfundid'};
$row_data{bookfundname} = $results->[$i]{'bookfundname'};
$sth2->execute($row_data{bookfundid});
my @budget_loop;
! while (my ($aqbudgetid,$startdate,$enddate,$budgetamount) =
$sth2->fetchrow) {
my %budgetrow_data;
$budgetrow_data{aqbudgetid} = $aqbudgetid;
--- 204,224 ----
my $toggle="white";
my @loop_data =();
! my $strsth2="Select
aqbudgetid,startdate,enddate,budgetamount,aqbudget.branchcode from aqbudget
where bookfundid = ? ";
! if ($homebranch){
! $strsth2 .= "AND ((aqbudget.branchcode='') OR
(aqbudget.branchcode= ".$dbh->quote($homebranch)."))" ;
! } else {
! $strsth2 .= "AND (aqbudget.branchcode='') " if ($flags>1);
! }
! $strsth2 .= "order by bookfundid";
! warn "".$strsth2;
! my $sth2 = $dbh->prepare($strsth2);
for (my $i=$offset; $i <
($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
my %row_data;
$row_data{bookfundid} =$results->[$i]{'bookfundid'};
$row_data{bookfundname} = $results->[$i]{'bookfundname'};
+ $row_data{branchname} =
$select_branches{$results->[$i]{'branchcode'}};
$sth2->execute($row_data{bookfundid});
my @budget_loop;
! while (my
($aqbudgetid,$startdate,$enddate,$budgetamount,$branchcode) = $sth2->fetchrow) {
my %budgetrow_data;
$budgetrow_data{aqbudgetid} = $aqbudgetid;
***************
*** 187,194 ****
$budgetrow_data{enddate} = format_date($enddate);
$budgetrow_data{budgetamount} = $budgetamount;
push @budget_loop,\%budgetrow_data;
}
! $row_data{budget} = address@hidden;
! push @loop_data,\%row_data;
}
$template->param(bookfund => address@hidden);
--- 226,236 ----
$budgetrow_data{enddate} = format_date($enddate);
$budgetrow_data{budgetamount} = $budgetamount;
+ $budgetrow_data{branchcode} = $branchcode;
push @budget_loop,\%budgetrow_data;
}
! if ($sth2->rows){
! $row_data{budget} = address@hidden;
! push @loop_data,\%row_data;
! }
}
$template->param(bookfund => address@hidden);
Index: aqbudget.pl
===================================================================
RCS file: /cvsroot/koha/koha/admin/aqbudget.pl,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** aqbudget.pl 22 Dec 2003 19:16:58 -0000 1.16
--- aqbudget.pl 6 Jul 2005 17:47:22 -0000 1.17
***************
*** 42,45 ****
--- 42,46 ----
use C4::Date;
use C4::Auth;
+ use C4::Acquisition;
use C4::Context;
use C4::Output;
***************
*** 54,58 ****
my @data=split(' ',$searchstring);
my address@hidden;
! my $sth=$dbh->prepare("Select
aqbudgetid,bookfundid,startdate,enddate,budgetamount from aqbudget where
(bookfundid like ?) order by bookfundid,aqbudgetid");
$sth->execute("$data[0]%");
my @results;
--- 55,59 ----
my @data=split(' ',$searchstring);
my address@hidden;
! my $sth=$dbh->prepare("Select
aqbudgetid,bookfundid,startdate,enddate,budgetamount,branchcode from aqbudget
where (bookfundid like ?) order by bookfundid,aqbudgetid");
$sth->execute("$data[0]%");
my @results;
***************
*** 95,98 ****
--- 96,105 ----
$template->param(action => $script_name);
+
+ my $dbh = C4::Context->dbh;
+ my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where
borrowernumber = ?");
+ $sthtemp->execute($borrowernumber);
+ my ($flags, $homebranch)=$sthtemp->fetchrow;
+
################## ADD_FORM ##################################
# called by default. Used to create form to add or modify a record
***************
*** 103,107 ****
if ($aqbudgetid) {
my $dbh = C4::Context->dbh;
! my $sth=$dbh->prepare("select
aqbudgetid,bookfundname,aqbookfund.bookfundid,startdate,enddate,budgetamount
from aqbudget,aqbookfund where aqbudgetid=? and
aqbudget.bookfundid=aqbookfund.bookfundid");
$sth->execute($aqbudgetid);
$dataaqbudget=$sth->fetchrow_hashref;
--- 110,114 ----
if ($aqbudgetid) {
my $dbh = C4::Context->dbh;
! my $sth=$dbh->prepare("select
aqbudgetid,bookfundname,aqbookfund.bookfundid,startdate,enddate,budgetamount,aqbudget.branchcode
from aqbudget,aqbookfund where aqbudgetid=? and
aqbudget.bookfundid=aqbookfund.bookfundid");
$sth->execute($aqbudgetid);
$dataaqbudget=$sth->fetchrow_hashref;
***************
*** 123,126 ****
--- 130,159 ----
adding => 1);
}
+ my @branches;
+ my @select_branch;
+ my %select_branches;
+ my ($count2,@branches)=branches();
+ push @select_branch,"";
+ $select_branches{""}="";
+ if ($flags>1){
+ if ($homebranch){
+ push @select_branch, $homebranch;#
+ for (my $i=0;$i<$count2;$i++){
+ $select_branches{$branches[$i]->{'branchcode'}}
= $branches[$i]->{'branchname'} if ($branches[$i]->{'branchcode'} eq
$homebranch);
+ }
+ }
+ } else {
+ for (my $i=0;$i<$count2;$i++){
+ push @select_branch, $branches[$i]->{'branchcode'};#
+ $select_branches{$branches[$i]->{'branchcode'}} =
$branches[$i]->{'branchname'};
+ }
+ }
+ my $CGIbranch=CGI::scrolling_list( -name => 'branchcode',
+ -values => address@hidden,
+ -labels => \%select_branches,
+ -default => $dataaqbudget->{branchcode},
+ -size => 1,
+ -multiple => 0 );
+ $template->param(CGIbranch => $CGIbranch);
$template->param(dateformat => display_date_format(),
aqbudgetid =>
$dataaqbudget->{'aqbudgetid'},
***************
*** 134,142 ****
} elsif ($op eq 'add_validate') {
my $dbh = C4::Context->dbh;
! my $sth=$dbh->prepare("replace aqbudget
(aqbudgetid,bookfundid,startdate,enddate,budgetamount) values (?,?,?,?,?)");
$sth->execute($input->param('aqbudgetid'),$input->param('bookfundid'),
format_date_in_iso($input->param('startdate')),
format_date_in_iso($input->param('enddate')),
! $input->param('budgetamount')
);
$sth->finish;
--- 167,176 ----
} elsif ($op eq 'add_validate') {
my $dbh = C4::Context->dbh;
! my $sth=$dbh->prepare("replace aqbudget
(aqbudgetid,bookfundid,startdate,enddate,budgetamount,branchcode) values
(?,?,?,?,?,?)");
$sth->execute($input->param('aqbudgetid'),$input->param('bookfundid'),
format_date_in_iso($input->param('startdate')),
format_date_in_iso($input->param('enddate')),
! $input->param('budgetamount'),
! $input->param('branchcode')
);
$sth->finish;
***************
*** 148,152 ****
} elsif ($op eq 'delete_confirm') {
my $dbh = C4::Context->dbh;
! my $sth=$dbh->prepare("select
aqbudgetid,bookfundid,startdate,enddate,budgetamount from aqbudget where
aqbudgetid=?");
$sth->execute($aqbudgetid);
my $data=$sth->fetchrow_hashref;
--- 182,186 ----
} elsif ($op eq 'delete_confirm') {
my $dbh = C4::Context->dbh;
! my $sth=$dbh->prepare("select
aqbudgetid,bookfundid,startdate,enddate,budgetamount,branchcode from aqbudget
where aqbudgetid=?");
$sth->execute($aqbudgetid);
my $data=$sth->fetchrow_hashref;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/admin aqbookfund.pl,1.21,1.22 aqbudget.pl,1.16,1.17,
Henri-Damien LAURENT <=
- Prev by Date:
[Koha-cvs] CVS: koha/updater updatedatabase,1.105,1.106
- Next by Date:
[Koha-cvs] CVS: koha/koha-tmpl/intranet-tmpl/default/en/parameters aqbookfund.tmpl,1.27,1.28 aqbudget.tmpl,1.25,1.26
- Previous by thread:
[Koha-cvs] CVS: koha/updater updatedatabase,1.105,1.106
- Next by thread:
[Koha-cvs] CVS: koha/koha-tmpl/intranet-tmpl/default/en/parameters aqbookfund.tmpl,1.27,1.28 aqbudget.tmpl,1.25,1.26
- Index(es):