suggestions improvements and fixes

- reindenting Suggestions.pm
- removing useless code in acqui-home.pl & fixing # of pending suggestion display
- add suggestion to order : displaying for selection suggestions accepted by the librarian (and reindenting)
- XHTMLing acqui-home (& removed useless parts)


NOTE ABOUT XHTML (could be useful) : <tfoot> must be BEFORE <tbody> in a <table>, even if, of course, it is displayed after.
This commit is contained in:
Paul Poulain 2009-10-29 15:12:25 +01:00
parent cdcab6ba28
commit dc85da1830
5 changed files with 115 additions and 234 deletions

View File

@ -46,30 +46,29 @@ use C4::Dates qw(format_date_in_iso);
use vars qw($VERSION @ISA @EXPORT);
BEGIN {
# set the version for version checking
$VERSION = 3.01;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
&NewSuggestion
&SearchSuggestion
&GetSuggestion
&GetSuggestionByStatus
&DelSuggestion
&CountSuggestion
&ModSuggestion
&ConnectSuggestionAndBiblio
&GetSuggestionFromBiblionumber
&ConnectSuggestionAndBiblio
&CountSuggestion
&DelSuggestion
&GetSuggestion
&GetSuggestionByStatus
&GetSuggestionFromBiblionumber
&ModStatus
&ModSuggestion
&NewSuggestion
);
# set the version for version checking
$VERSION = 3.01;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
&NewSuggestion
&SearchSuggestion
&GetSuggestion
&GetSuggestionByStatus
&DelSuggestion
&CountSuggestion
&ModSuggestion
&ConnectSuggestionAndBiblio
&GetSuggestionFromBiblionumber
&ConnectSuggestionAndBiblio
&DelSuggestion
&GetSuggestion
&GetSuggestionByStatus
&GetSuggestionFromBiblionumber
&ModStatus
&ModSuggestion
&NewSuggestion
);
}
=head1 NAME
@ -116,63 +115,63 @@ sub SearchSuggestion {
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.email AS emailsuggestedby,
U1.borrowernumber AS borrnumsuggestedby,
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.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
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 borrowers AS U2 ON managedby=U2.borrowernumber
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{$_} ) {
push @sql_params,'%'.$s.'%';
" and suggestions.$_ like ? ";
} else { () }
} qw( title author isbn publishercode collectiontitle )
);
WHERE STATUS NOT IN ('CLAIMED')
} , map {
if ( my $s = $$suggestion{$_} ) {
push @sql_params,'%'.$s.'%';
" and suggestions.$_ like ? ";
} else { () }
} qw( title author isbn publishercode collectiontitle )
);
my $userenv = C4::Context->userenv;
my $userenv = C4::Context->userenv;
if (C4::Context->preference('IndependantBranches')) {
if ($userenv) {
if (($userenv->{flags} % 2) != 1 && !$$suggestion{branchcode}){
push @sql_params,$$userenv{branch};
push @query,q{ and (branchcode = ? or branchcode ='')};
}
}
if ($userenv) {
if (($userenv->{flags} % 2) != 1 && !$$suggestion{branchcode}){
push @sql_params,$$userenv{branch};
push @query,q{ and (branchcode = ? or branchcode ='')};
}
}
}
foreach my $field (grep { my $fieldname=$_;
any {$fieldname eq $_ } qw<
STATUS branchcode itemtype suggestedby managedby acceptedby
bookfundid biblionumber
>} keys %$suggestion
any {$fieldname eq $_ } qw<
STATUS branchcode itemtype suggestedby managedby acceptedby
bookfundid biblionumber
>} keys %$suggestion
) {
if ($$suggestion{$field}){
push @sql_params,$$suggestion{$field};
push @query, " and suggestions.$field=?";
}
else {
push @query, " and (suggestions.$field='' OR suggestions.$field IS NULL)";
}
if ($$suggestion{$field}){
push @sql_params,$$suggestion{$field};
push @query, " and suggestions.$field=?";
}
else {
push @query, " and (suggestions.$field='' OR suggestions.$field IS NULL)";
}
}
$debug && warn "@query";
$debug && warn "@query";
my $sth=$dbh->prepare("@query");
$sth->execute(@sql_params);
my @results;
@ -224,8 +223,8 @@ sub GetSuggestionFromBiblionumber {
SELECT suggestionid
FROM suggestions
WHERE biblionumber=?
};
my $dbh=C4::Context->dbh;
};
my $dbh=C4::Context->dbh;
my $sth = $dbh->prepare($query);
$sth->execute($biblionumber);
my ($ordernumber) = $sth->fetchrow;
@ -253,8 +252,8 @@ sub GetSuggestionByStatus {
U1.firstname AS firstnamesuggestedby,
U1.branchcode AS branchcodesuggestedby,
B1.branchname AS branchnamesuggestedby,
U1.borrowernumber AS borrnumsuggestedby,
U1.categorycode AS categorycodesuggestedby,
U1.borrowernumber AS borrnumsuggestedby,
U1.categorycode AS categorycodesuggestedby,
C1.description AS categorydescriptionsuggestedby,
U2.surname AS surnamemanagedby,
U2.firstname AS firstnamemanagedby,
@ -343,7 +342,7 @@ sub CountSuggestion {
FROM suggestions
WHERE STATUS=?
|;
$sth = $dbh->prepare($query);
$sth = $dbh->prepare($query);
$sth->execute($status);
}
my ($result) = $sth->fetchrow;
@ -361,8 +360,8 @@ Insert a new suggestion on database with value given on input arg.
sub NewSuggestion {
my ($suggestion) = @_;
$suggestion->{STATUS}="ASKED" unless $suggestion->{STATUS};
return InsertInTable("suggestions",$suggestion);
$suggestion->{STATUS}="ASKED" unless $suggestion->{STATUS};
return InsertInTable("suggestions",$suggestion);
}
=head2 ModSuggestion
@ -380,7 +379,7 @@ Note that there is no function to modify a suggestion.
sub ModSuggestion {
my ($suggestion)=@_;
my $status_update_table=UpdateInTable("suggestions", $suggestion);
my $status_update_table=UpdateInTable("suggestions", $suggestion);
# check mail sending.
if ($$suggestion{STATUS}){
my $letter=C4::Letters::getletter('suggestions',$$suggestion{STATUS});
@ -394,7 +393,7 @@ sub ModSuggestion {
if (!$enqueued){warn "can't enqueue letter $letter";}
}
}
return $status_update_table;
return $status_update_table;
}
=head2 ConnectSuggestionAndBiblio

View File

@ -169,76 +169,6 @@ foreach my $result (@results) {
push( @loop_budget, { %{$result}, toggle => $toggle++ % 2, } );
}
# ---------------------------------------------------
=c FIXME
### $cur
## suggestions
my $dbh = C4::Context->dbh;
## liste des domaines
my $sth=$dbh->prepare("
SELECT bookfundgroupnumber,bookfundgroupname
FROM `aq2bookfundgroups`
ORDER BY Bookfundgroupname
");
$sth->execute;
my @bookfundgroup_loop; ## liste des domaines
while (my $row=$sth->fetchrow_hashref) {
push @bookfundgroup_loop,$row;
}
$sth->finish;
## liste des BFG ayant des suggestions à traiter
## nowsuggestions = Number Of Waiting Suggestions
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("
SELECT bookfundgroupnumber, count(*) AS nowsuggestions
FROM `aq2orders`
WHERE step=2
AND STATUS='ASKED'
GROUP BY bookfundgroupnumber
");
$sth->execute;
my @nowsuggestionsneq0_loop; ## liste des BFG ayant des suggestions à traiter
while (my $row=$sth->fetchrow_hashref) {
push @nowsuggestionsneq0_loop,$row;
}
$sth->finish;
## liste des BFG avec l'effectif des suggestions à traiter (effectif éventuellement nul)
my @nowsuggestions_loop;
foreach my $data1 (@bookfundgroup_loop) {
$data1->{'nowsuggestions'}=0;
foreach my $data2 (@nowsuggestionsneq0_loop) {
if ($data1->{'bookfundgroupnumber'}==$data2->{'bookfundgroupnumber'}) {
$data1->{'nowsuggestions'}=$data2->{'nowsuggestions'};
}
}
}
=cut
$template->param(
classlist => $classlist,
type => 'intranet',
@ -251,13 +181,7 @@ $template->param(
totspent => $num->format_price($totspent ),
totcomtd => $num->format_price( $totcomtd ),
totavail => $num->format_price( $totavail ),
# nowsuggestions_loop => \@nowsuggestions_loop,
# bookfundgroup_loop => \@bookfundgroup_loop,
# numberofwaitingsuggestionsgpd => $numberofwaitingsuggestionsgpd,
# numberofwaitingsuggestionspd => $numberofwaitingsuggestionspd,
# suggestions_loop => $suggestions_loop,
suggestion => $suggestion,
);
output_html_with_http_headers $query, $cookie, $template->output;

View File

@ -127,18 +127,18 @@ if ( $op eq 'connectDuplicate' ) {
# getting all suggestions.
my $suggestions_loop =
&SearchSuggestion(
{ suggestedby => $borrowernumber,
author => $author,
title => $title,
publishercode => $publishercode,
status => 'ACCEPTED'});
&SearchSuggestion(
{ managedby => $borrowernumber,
author => $author,
title => $title,
publishercode => $publishercode,
status => 'ACCEPTED'});
my $vendor = GetBookSellerFromId($supplierid);
$template->param(
suggestions_loop => $suggestions_loop,
basketno => $basketno,
supplierid => $supplierid,
name => $vendor->{'name'},
name => $vendor->{'name'},
"op_$op" => 1,
);

View File

@ -10,9 +10,9 @@
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="acquisitions-toolbar.inc" -->
@ -23,11 +23,11 @@
<fieldset>
<legend>Manage orders</legend>
<!-- TMPL_IF name="nobudget" -->
<!-- TMPL_IF NAME="CAN_user_parameters" -->
<!-- TMPL_IF NAME="CAN_user_parameters" -->
<span class="problem">You must <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">define a budget</a> in Administration</span>
<!-- TMPL_ELSE -->
<span class="problem">Your administrator must define a budget in Administration</span>
<!-- /TMPL_IF -->
<!-- TMPL_ELSE -->
<span class="problem">Your administrator must define a budget in Administration</span>
<!-- /TMPL_IF -->
<form name="findsupplier" action="/cgi-bin/koha/acqui/booksellers.pl" method="post">
<p><label for="supplierpage">Vendor </label><input type="text" size="25" name="supplier" id="supplierpage" class="focus" />
<input type="submit" value="Search" />
@ -47,32 +47,10 @@
<fieldset>
<legend>Pending suggestions</legend>
<!-- TMPL_IF name="suggestion" -->
<!--TMPL_VAR NAME="suggestion" --> suggestions waiting <a href="/cgi-bin/koha/suggestion/acceptorreject.pl">Manage suggestions</a>
<!--TMPL_VAR NAME="suggestion" --> suggestions waiting <a href="/cgi-bin/koha/suggestion/suggestion.pl">Manage suggestions</a>
<!-- TMPL_ELSE -->
<p>No suggestions waiting</p>
<!-- /TMPL_IF -->
<br>
<br>
<table>
<thead>
<tr>
<th>Book fund group</th>
<th>number of <br>waiting sugg.</th>
<th></th>
</tr>
</thead>
<tbody>
<!-- TMPL_LOOP name="bookfundgroup_loop" -->
<tr>
<td><!-- TMPL_VAR name="bookfundgroupname" --></td>
<td><!-- TMPL_VAR name="nowsuggestions" --></td>
<td><a href="/cgi-bin/koha/suggestion/acceptorrejectpd.pl?bookfundgroupnumber=<!-- TMPL_VAR name="bookfundgroupnumber" -->">manage</a></td>
</tr>
<!-- /TMPL_LOOP -->
</tbody>
</table>
</fieldset>
</div>
</div>
@ -100,48 +78,36 @@
<th>Avail</th>
</tr>
</thead>
<tbody>
<!-- TMPL_LOOP name="loop_budget" -->
<!--TMPL_IF name="toggle"-->
<tr class="highlight">
<!--TMPL_ELSE-->
<tr>
<!--/TMPL_IF-->
<td align="center"><!-- TMPL_VAR name="budget_code" --></td>
<td align="center"><!-- TMPL_VAR name="budget_owner" --></td>
<td align="center"><!-- TMPL_VAR name="budget_branchname" --></td>
<td><p align="right" ><!-- TMPL_VAR name="budget_amount" --></p> </td>
<td><p align="right" ><!-- TMPL_VAR name="budget_spent" --></p> </td>
<td><p align="right" ><!-- TMPL_VAR name="budget_avail" --></p> </td>
</tr>
<!-- /TMPL_LOOP -->
</tbody>
<tfoot>
<tr>
<th>Total</th>
<td>
<td>
<th><p align="right" ><!-- TMPL_VAR name="total" --></p> </th>
<th><p align="right" ><!-- TMPL_VAR name="totspent" --></p> </th>
<th><p align="right" ><!-- TMPL_VAR name="totavail" --></p> </th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th align="right" ><!-- TMPL_VAR name="total" --></th>
<th align="right" ><!-- TMPL_VAR name="totspent" --></th>
<th align="right" ><!-- TMPL_VAR name="totavail" --></th>
</tr>
</tfoot>
<tbody>
<!-- TMPL_LOOP name="loop_budget" -->
<!--TMPL_IF name="toggle"-->
<tr class="highlight">
<!--TMPL_ELSE-->
<tr>
<!--/TMPL_IF-->
<td align="center"><!-- TMPL_VAR name="budget_code" --></td>
<td align="center"><!-- TMPL_VAR name="budget_owner" --></td>
<td align="center"><!-- TMPL_VAR name="budget_branchname" --></td>
<td align="right" ><!-- TMPL_VAR name="budget_amount" --></td>
<td align="right" ><!-- TMPL_VAR name="budget_spent" --></td>
<td align="right" ><!-- TMPL_VAR name="budget_avail" --></td>
</tr>
<!-- /TMPL_LOOP -->
</tbody>
</table>
</div>
<p>Use your reload button [ctrl + r] to get the most recent figures.
Committed figures are approximate only, as exchange rates will affect the amount actually paid.</p>
<!-- /TMPL_IF -->
<div id="acqui_acqui_home_currency">
<!-- TMPL_IF NAME="loop_currency" -->
<h3>Exchange rates</h3>
@ -180,14 +146,6 @@
</div>
</div>
<div id="acqui_acqui_home_hints">
<h2>Help</h2>
<p>To begin an order, local purchase or donation, search for the vendor or benefactor, and then you can create a new Basket.</p>
<p>A Basket is a collection of orders.</p>
<p>To order an item you need to establish whether a biblio already exists for it, and either add an item, or set up a new biblio and then add the item.</p>
</div>
</div>
</div>
<div class="yui-b">

View File

@ -71,7 +71,7 @@ my $tabcode = $input->param('tabcode');
# filter informations which are not suggestion related.
my $suggestion_ref = $input->Vars;
delete $$suggestion_ref{$_} foreach qw<suggestedbyme op displayby tabcode edit_field>;
delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field );
foreach (keys %$suggestion_ref){
delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' || $op eq 'change'));
}