[Koha-cvs] koha C4/Suggestions.pm koha-tmpl/intranet-tmpl/... [rel_3_0]
Antoine Farnault
antoine at koha-fr.org
Tue Dec 19 16:03:38 CET 2006
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/12/19 15:03:38
Modified files:
C4 : Suggestions.pm
koha-tmpl/intranet-tmpl/prog/en/includes: menu-acqui.inc
koha-tmpl/intranet-tmpl/prog/en/suggestion: acceptorreject.tmpl
suggestion : acceptorreject.pl
Log message:
Display accepted/rejected suggestion and add a link to order an accepted one.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Suggestions.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.12.2.1&r2=1.12.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/includes/menu-acqui.inc?cvsroot=koha&only_with_tag=rel_3_0&r1=1.3.2.2&r2=1.3.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/suggestion/acceptorreject.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.3&r2=1.1.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/suggestion/acceptorreject.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.4.2.3&r2=1.4.2.4
Patches:
Index: C4/Suggestions.pm
===================================================================
RCS file: /sources/koha/koha/C4/Suggestions.pm,v
retrieving revision 1.12.2.1
retrieving revision 1.12.2.2
diff -u -b -r1.12.2.1 -r1.12.2.2
--- C4/Suggestions.pm 14 Nov 2006 14:49:59 -0000 1.12.2.1
+++ C4/Suggestions.pm 19 Dec 2006 15:03:38 -0000 1.12.2.2
@@ -17,18 +17,17 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: Suggestions.pm,v 1.12.2.1 2006/11/14 14:49:59 toins Exp $
+# $Id: Suggestions.pm,v 1.12.2.2 2006/12/19 15:03:38 toins Exp $
use strict;
require Exporter;
-use DBI;
use C4::Context;
use C4::Output;
use Mail::Sendmail;
use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.12.2.1 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.12.2.2 $' =~ /\d+/g;
shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
=head1 NAME
@@ -67,6 +66,7 @@
&NewSuggestion
&SearchSuggestion
&GetSuggestion
+ &GetSuggestionByStatus
&DelSuggestion
&CountSuggestion
&ModStatus
@@ -95,7 +95,7 @@
sub SearchSuggestion {
my ($user,$author,$title,$publishercode,$status,$suggestedbyme)=@_;
my $dbh = C4::Context->dbh;
- my $query = qq|
+ my $query = "
SELECT suggestions.*,
U1.surname AS surnamesuggestedby,
U1.firstname AS firstnamesuggestedby,
@@ -104,7 +104,7 @@
FROM suggestions
LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber
- WHERE 1=1 |;
+ WHERE 1=1 ";
my @sql_params;
if ($author) {
@@ -141,6 +141,7 @@
} else {
$query .= " and managedby is NULL";
}
+ warn $query;
my $sth=$dbh->prepare($query);
$sth->execute(@sql_params);
my @results;
@@ -176,11 +177,11 @@
sub GetSuggestion {
my ($suggestionid) = @_;
my $dbh = C4::Context->dbh;
- my $query = qq|
+ my $query = "
SELECT *
FROM suggestions
WHERE suggestionid=?
- |;
+ ";
my $sth = $dbh->prepare($query);
$sth->execute($suggestionid);
return($sth->fetchrow_hashref);
@@ -214,6 +215,38 @@
return $suggestionid;
}
+=head2 GetSuggestionByStatus
+
+=over 4
+
+$suggestions = &GetSuggestionByStatus($status)
+
+Get a suggestion from it's status
+
+return :
+all the suggestion with C<$status>
+
+=back
+
+=cut
+
+sub GetSuggestionByStatus {
+ my $status = shift;
+ my $dbh = C4::Context->dbh;
+ my $query = "
+ SELECT *
+ FROM suggestions
+ WHERE status = ?
+ ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($status);
+
+ my @results;
+ while(my $data = $sth->fetchrow_hashref){
+ push @results,$data;
+ }
+ return \@results;
+}
=head2 CountSuggestion
Index: koha-tmpl/intranet-tmpl/prog/en/includes/menu-acqui.inc
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/includes/menu-acqui.inc,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -u -b -r1.3.2.2 -r1.3.2.3
--- koha-tmpl/intranet-tmpl/prog/en/includes/menu-acqui.inc 21 Nov 2006 15:11:13 -0000 1.3.2.2
+++ koha-tmpl/intranet-tmpl/prog/en/includes/menu-acqui.inc 19 Dec 2006 15:03:38 -0000 1.3.2.3
@@ -3,7 +3,7 @@
<a href="/cgi-bin/koha/acqui/supplier.pl?op=enter">Add supplier</a>
<a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a>
<a href="/cgi-bin/koha/acqui/histsearch.pl">History search</a>
- <a href="/cgi-bin/koha/suggestion/acceptorreject.pl">Manage suggestions</a>
+ <a href="/cgi-bin/koha/suggestion/acceptorreject.pl?op=aorr_confirm">Manage suggestions</a>
<a href="/cgi-bin/koha/admin/aqbookfund.pl">Parameters</a>
</div>
Index: koha-tmpl/intranet-tmpl/prog/en/suggestion/acceptorreject.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/suggestion/acceptorreject.tmpl,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- koha-tmpl/intranet-tmpl/prog/en/suggestion/acceptorreject.tmpl 15 Nov 2006 11:36:46 -0000 1.1.2.3
+++ koha-tmpl/intranet-tmpl/prog/en/suggestion/acceptorreject.tmpl 19 Dec 2006 15:03:38 -0000 1.1.2.4
@@ -3,8 +3,17 @@
<!--TMPL_INCLUDE NAME="menus.inc" -->
<!-- TMPL_INCLUDE NAME="menu-acqui.inc" -->
-<!-- TMPL_IF name="op_else" -->
<h1>Suggestions Management</h1>
+
+ <div id="action">
+ <a href="/cgi-bin/koha/suggestion/acceptorreject.pl?op=accepted">Accepted</a>
+ <a href="/cgi-bin/koha/suggestion/acceptorreject.pl?op=aorr_confirm">Waiting</a>
+ <a href="/cgi-bin/koha/suggestion/acceptorreject.pl?op=rejected">Rejected</a>
+ </div>
+
+<!-- TMPL_IF name="op_else" -->
+ <br />
+ <b>Waiting suggestion,</b> accept or reject these suggestions with a reason.
<form name="f" method="post" action="/cgi-bin/koha/suggestion/acceptorreject.pl">
<input type="hidden" name="op" value="aorr_confirm">
<table>
@@ -49,7 +58,9 @@
<!-- TMPL_IF name="isbn" -->; ISBN :<i><!-- TMPL_VAR name="isbn" --></i> <!-- /TMPL_IF --><!-- TMPL_IF name="publishercode" -->; Published by <!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF --><!-- TMPL_IF name="publicationyear" --> in <i><!-- TMPL_VAR name="publicationyear" --></i> <!-- /TMPL_IF --><!-- TMPL_IF name="place" --> in <i><!-- TMPL_VAR name="place" --></i> <!-- /TMPL_IF --><br><!-- TMPL_IF name="note" --><!-- TMPL VAR NAME="note" --><!-- /TMPL_IF -->
</td>
<td>
- <!-- TMPL_VAR name="surnamesuggestedby" --><!-- TMPL_IF name="firstnamesuggestedby" -->,<!-- /TMPL_IF --> <!-- TMPL_VAR name="firstnamesuggestedby" -->
+ <!-- TMPL_VAR name="surnamesuggestedby" -->
+ <!-- TMPL_IF name="firstnamesuggestedby" -->,<!-- /TMPL_IF -->
+ <!-- TMPL_VAR name="firstnamesuggestedby" -->
</td>
</tr>
<!-- /TMPL_LOOP -->
@@ -58,6 +69,86 @@
</form>
<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="done" -->
+ <br />
+ <!-- TMPL_IF NAME="op_accepted"-->
+ <b>Accepted suggestion</b>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="op_rejected"-->
+ <b>Rejected suggestion</b>
+ <!-- /TMPL_IF -->
+
+ <!-- TMPL_IF NAME="suggestions_loop" -->
+ <table>
+ <tr>
+ <th>Reason</th>
+ <th>Suggestion</th>
+ <th>Suggested by</th>
+ <th>Date</th>
+ <!-- TMPL_IF NAME="op_accepted"-->
+ <th> </th>
+ <!-- /TMPL_IF -->
+ </tr>
+ <!-- TMPL_LOOP NAME="suggestions_loop" -->
+ <td>
+ <!-- TMPL_VAR NAME="reason" -->
+ </td>
+ <td>
+ <!-- TMPL_VAR NAME="title" -->
+ <!-- TMPL_IF NAME="author" -->
+ , by <!-- TMPL_VAR NAME="author" -->
+ <!-- /TMPL_IF -->
+ <br>
+ <!-- TMPL_IF name="copyrightdate" -->
+ © <!-- TMPL_VAR name="copyrightdate" -->
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="volumedesc" -->
+ ; Volume:<i><!-- TMPL_VAR name="volumedesc" --></i>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="isbn" -->
+ ; ISBN :<i><!-- TMPL_VAR name="isbn" --></i>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="publishercode" -->
+ ; Published by <!-- TMPL_VAR name="publishercode" -->
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="publicationyear" -->
+ in <i><!-- TMPL_VAR name="publicationyear" --></i>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="place" -->
+ in <i><!-- TMPL_VAR name="place" --></i>
+ <!-- /TMPL_IF -->
+ <br>
+ <!-- TMPL_IF name="note" -->
+ <!-- TMPL VAR NAME="note" -->
+ <!-- /TMPL_IF -->
+ </td>
+ <td>
+ <!-- TMPL_VAR name="surnamesuggestedby" -->
+ <!-- TMPL_IF name="firstnamesuggestedby" -->,<!-- /TMPL_IF -->
+ <!-- TMPL_VAR name="firstnamesuggestedby" -->
+ </td>
+ <td>
+ <!-- TMPL_VAR NAME="date" -->
+ </td>
+ <!-- TMPL_IF NAME="op_accepted"-->
+ <td>
+ <a href="/cgi-bin/koha/acqui/neworderempty.pl?suggestionid=<!--TMPL_VAR NAME="suggestionid"-->">Order it</a>
+ </td>
+ <!-- /TMPL_IF -->
+ </tr>
+ <!-- /TMPL_LOOP -->
+ </table>
+ <!-- TMPL_ELSE -->
+ <br /><br />
+ No suggestion has already been
+ <!-- TMPL_IF NAME="op_accepted"-->
+ accepted.
+ <!-- TMPL_ELSE -->
+ rejected.
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
+
<script type="text/JavaScript" language="JavaScript">
// <![CDATA[
/**
Index: suggestion/acceptorreject.pl
===================================================================
RCS file: /sources/koha/koha/suggestion/acceptorreject.pl,v
retrieving revision 1.4.2.3
retrieving revision 1.4.2.4
diff -u -b -r1.4.2.3 -r1.4.2.4
--- suggestion/acceptorreject.pl 18 Dec 2006 16:35:19 -0000 1.4.2.3
+++ suggestion/acceptorreject.pl 19 Dec 2006 15:03:38 -0000 1.4.2.4
@@ -17,7 +17,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: acceptorreject.pl,v 1.4.2.3 2006/12/18 16:35:19 toins Exp $
+# $Id: acceptorreject.pl,v 1.4.2.4 2006/12/19 15:03:38 toins Exp $
=head1 NAME
@@ -58,13 +58,13 @@
op can be :
* aorr_confirm : to confirm accept or reject
* delete_confirm : to confirm the deletion
+ * accepted : to display only accepted.
=back
=cut
-
use strict;
require Exporter;
use CGI;
@@ -78,7 +78,7 @@
my $title = $input->param('title');
my $author = $input->param('author');
my $note = $input->param('note');
-my $copyrightdate =$input->param('copyrightdate');
+my $copyrightdate = $input->param('copyrightdate');
my $publishercode = $input->param('publishercode');
my $volumedesc = $input->param('volumedesc');
my $publicationyear = $input->param('publicationyear');
@@ -87,53 +87,73 @@
my $status = $input->param('status');
my $suggestedbyme = $input->param('suggestedbyme');
my $op = $input->param('op');
-$op = 'else' unless $op;
+#$op = 'else' unless $op;
+warn "op is =>" . $op;
my $dbh = C4::Context->dbh;
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "suggestion/acceptorreject.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "suggestion/acceptorreject.tmpl",
type => "intranet",
query => $input,
authnotrequired => 1,
- flagsrequired => {catalogue => 1},
- });
-if ($op eq "aorr_confirm") {
+ flagsrequired => { catalogue => 1 },
+ }
+);
+
+my $suggestions;
+
+if ( $op eq "aorr_confirm" ) {
my @suggestionlist = $input->param("aorr");
foreach my $suggestion (@suggestionlist) {
- if ($suggestion =~ /(A|R)(.*)/) {
- my ($newstatus,$suggestionid) = ($1,$2);
- $newstatus="REJECTED" if $newstatus eq "R";
- $newstatus="ACCEPTED" if $newstatus eq "A";
- my $reason = $input->param("reason".$suggestionid);
- if($reason eq "other"){
- $reason = $input->param("other-reason".$suggestionid);
+ if ( $suggestion =~ /(A|R)(.*)/ ) {
+ my ( $newstatus, $suggestionid ) = ( $1, $2 );
+ $newstatus = "REJECTED" if $newstatus eq "R";
+ $newstatus = "ACCEPTED" if $newstatus eq "A";
+ my $reason = $input->param( "reason" . $suggestionid );
+ if ( $reason eq "other" ) {
+ $reason = $input->param( "other-reason" . $suggestionid );
}
- ModStatus($suggestionid,$newstatus,$loggedinuser,'',$reason);
+ ModStatus( $suggestionid, $newstatus, $loggedinuser, '', $reason );
}
}
- $op="else";
+ $op = "else";
+ $suggestions = &SearchSuggestion( "", "", "", "", 'ASKED', "" );
}
-if ($op eq "delete_confirm") {
+if ( $op eq "delete_confirm" ) {
my @delete_field = $input->param("delete_field");
foreach my $delete_field (@delete_field) {
- &DelSuggestion($loggedinuser,$delete_field);
+ &DelSuggestion( $loggedinuser, $delete_field );
}
- $op='else';
+ $op = 'else';
+ $suggestions = &SearchSuggestion( "", "", "", "", 'ASKED', "" );
}
-my $suggestions= &SearchSuggestion("","","","",'ASKED',"");
-my $reasonsloop = GetAuthorisedValues("SUGGEST");
+if ( $op eq "accepted" ) {
+ $suggestions = &GetSuggestionByStatus('ACCEPTED');
+ $template->param(done => 1);
+}
+if ( $op eq "rejected" ) {
+ $suggestions = &GetSuggestionByStatus('REJECTED');
+ $template->param(done => 1);
+}
-my @suggestions_loop;
+if (not defined $op) {
+ $suggestions = &SearchSuggestion( "", "", "", "", 'ASKED', "" );
+}
-foreach my $suggestion (@$suggestions){
- $suggestion->{'reasonsloop'}= $reasonsloop;
+my $reasonsloop = GetAuthorisedValues("SUGGEST");
+my @suggestions_loop;
+foreach my $suggestion (@$suggestions) {
+ $suggestion->{'reasonsloop'} = $reasonsloop;
push @suggestions_loop, $suggestion;
}
+warn "suggestion=>" . Data::Dumper::Dumper(\@suggestions_loop);
+
$template->param(
suggestions_loop => \@suggestions_loop,
"op_$op" => 1,
More information about the Koha-cvs
mailing list