suggestion.pl has to be updated on C4/Budgets

This commit is contained in:
Henri-Damien LAURENT 2009-08-20 22:21:50 +02:00
parent 1737ec6a43
commit 3ab463fc34
5 changed files with 59 additions and 29 deletions

View File

@ -114,27 +114,30 @@ Note the status is stored twice :
sub SearchSuggestion {
my ($suggestion)=@_;
my $dbh = C4::Context->dbh;
my @sql_params;
my @query =(q{
SELECT suggestions.*,
U1.branchcode AS branchcodesuggestedby,
B1.branchname AS branchnamesuggestedby,
U1.surname AS surnamesuggestedby,
U1.firstname AS firstnamesuggestedby,
U1.borrowernumber AS borrnumsuggestedby,
my @sql_params;
my @query = (
q{ SELECT suggestions.*,
U1.branchcode AS branchcodesuggestedby,
B1.branchname AS branchnamesuggestedby,
U1.surname AS surnamesuggestedby,
U1.firstname AS firstnamesuggestedby,
U1.email AS emailsuggestedby,
U1.borrowernumber AS borrnumsuggestedby,
U1.categorycode AS categorycodesuggestedby,
C1.description AS categorydescriptionsuggestedby,
U2.branchcode AS branchcodemanagedby,
B2.branchname AS branchnamemanagedby,
U2.surname AS surnamemanagedby,
U2.firstname AS firstnamemanagedby,
U2.borrowernumber AS borrnummanagedby
FROM suggestions
LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber
U2.surname AS surnamemanagedby,
U2.firstname AS firstnamemanagedby,
B2.branchname AS branchnamesuggestedby,
U2.email AS emailmanagedby,
U2.branchcode AS branchcodemanagedby,
U2.borrowernumber AS borrnummanagedby
FROM suggestions
LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
LEFT JOIN branches AS B1 ON B1.branchcode=U1.branchcode
LEFT JOIN categories AS C1 ON C1.categorycode = U1.categorycode
LEFT JOIN branches AS B1 ON B1.branchcode = U1.branchcode
LEFT JOIN branches AS B2 ON B2.branchcode = U2.branchcode
LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber
LEFT JOIN branches AS B2 ON B2.branchcode=U2.branchcode
LEFT JOIN categories AS C2 ON C2.categorycode = U2.categorycode
WHERE STATUS NOT IN ('CLAIMED')
} , map {
if ( my $s = $$suggestion{$_} ) {
@ -172,7 +175,12 @@ sub SearchSuggestion {
$debug && warn "@query";
my $sth=$dbh->prepare("@query");
$sth->execute(@sql_params);
return ($sth->fetchall_arrayref({}));
my @results;
while ( my $data=$sth->fetchrow_hashref ){
$$data{$$data{STATUS}} = 1;
push(@results,$data);
}
return (\@results);
}
=head2 GetSuggestion

View File

@ -1699,7 +1699,9 @@ DROP TABLE IF EXISTS `suggestions`;
CREATE TABLE `suggestions` (
`suggestionid` int(8) NOT NULL auto_increment,
`suggestedby` int(11) NOT NULL default 0,
`suggesteddate` date NOT NULL default 0,
`managedby` int(11) default NULL,
`manageddate` date default NULL,
`STATUS` varchar(10) NOT NULL default '',
`note` mediumtext,
`author` varchar(80) default NULL,

View File

@ -2810,7 +2810,7 @@ ALTER TABLE aqbudget RENAME`aqbudgets`
BUDGETNAME
my $maxbudgetid=$dbh->selectcol_arrayref(<<IDsBUDGET);
SELECT MAX(aqbudgetid) from aqbudgets
BUDGETNAME
IDsBUDGET
$dbh->do(<<BUDGETAUTOINCREMENT);
ALTER TABLE `aqbudgets` AUTO_INCREMENT=$$maxbudgetid[0]
@ -2995,6 +2995,35 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
$DBversion = "3.01.00.114";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
$dbh->do(<<SUGGESTIONS);
ALTER table suggestions
ADD budgetid INT(11),
ADD branchcode VARCHAR(10) default NULL,
ADD acceptedby INT(11) default NULL,
ADD acceptedon date default NULL,
ADD suggestedby INT(11) default NULL,
ADD suggestedon date default NULL,
ADD managedby INT(11) default NULL,
ADD managedon date default NULL,
ADD rejectedby INT(11) default NULL,
ADD rejectedon date default NULL,
ADD collectiontitle text default NULL,
ADD itemtype VARCHAR(30) default NULL,
ADD biblionumber INT(11) default NULL,
ADD sort1 VARCHAR(80) default NULL,
ADD sort2 VARCHAR(80) default NULL
;
SUGGESTIONS
print <<COMMENT;
Upgrade to $DBversion done
Suggestions
COMMENT
SetVersion ($DBversion);
}
=item DropAllForeignKeys($table)

View File

@ -108,10 +108,6 @@ $template->param(
itemtypeloop=> $supportlist,
suggestions_loop => $suggestions_loop,
showall => $allsuggestions,
title => $title,
author => $author,
publishercode => $publishercode,
status => $status,
"op_$op" => 1,
suggestionsview => 1
);

View File

@ -207,11 +207,6 @@ $template->param(
####################
## Initializing selection lists
#branch display management
my @bookfunds = GetBudgets($branchfilter||'');
map{$_->{'selected'}=1 if ($$suggestion_ref{'bookfundid'} && $_->{'bookfundid'} eq $$suggestion_ref{'bookfundid'})} @bookfunds;
$template->param( bookfundsloop => \@bookfunds);
#branch display management
my $onlymine=C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&