Accept or reject : Bug Fix and improvements.
Improving workflow : A suggestion can be edited and status can be changed if mistaken as soon as it is not deleted or acquired. Adding dates display. Adding deletion of suggestions. Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
e7bf746d6c
commit
5e9465a14a
|
|
@ -72,7 +72,7 @@ Suggestions done by other borrowers can be seen when not "AVAILABLE"
|
|||
|
||||
=head2 SearchSuggestion
|
||||
|
||||
(\@array) = &SearchSuggestion($user,$author,$title,$publishercode,$status,$suggestedbyme)
|
||||
(\@array) = &SearchSuggestion($user,$author,$title,$publishercode,$status,$suggestedbyme,$branchcode)
|
||||
|
||||
searches for a suggestion
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ Note the status is stored twice :
|
|||
=cut
|
||||
|
||||
sub SearchSuggestion {
|
||||
my ($user,$author,$title,$publishercode,$status,$suggestedbyme)=@_;
|
||||
my ($user,$author,$title,$publishercode,$status,$suggestedbyme,$branchcode)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "
|
||||
SELECT suggestions.*,
|
||||
|
|
@ -113,7 +113,7 @@ sub SearchSuggestion {
|
|||
push @sql_params,"%".$publishercode."%";
|
||||
$query .= " and publishercode like ?";
|
||||
}
|
||||
if (C4::Context->preference("IndependantBranches")) {
|
||||
if (C4::Context->preference("IndependantBranches") || $branchcode) {
|
||||
my $userenv = C4::Context->userenv;
|
||||
if ($userenv) {
|
||||
unless ($userenv->{flags} == 1){
|
||||
|
|
@ -121,6 +121,10 @@ sub SearchSuggestion {
|
|||
$query .= " and (U1.branchcode = ? or U1.branchcode ='')";
|
||||
}
|
||||
}
|
||||
if ($branchcode) {
|
||||
push @sql_params,$branchcode;
|
||||
$query .= " and (U1.branchcode = ? or U1.branchcode ='')";
|
||||
}
|
||||
}
|
||||
if ($status) {
|
||||
push @sql_params,$status;
|
||||
|
|
@ -146,6 +150,7 @@ sub SearchSuggestion {
|
|||
} else {
|
||||
$even=1;
|
||||
}
|
||||
# $data->{date} = format_date($data->{date});
|
||||
push(@results,$data);
|
||||
}
|
||||
return (\@results);
|
||||
|
|
@ -201,7 +206,7 @@ sub GetSuggestionFromBiblionumber {
|
|||
|
||||
=head2 GetSuggestionByStatus
|
||||
|
||||
$suggestions = &GetSuggestionByStatus($status)
|
||||
$suggestions = &GetSuggestionByStatus($status,[$branchcode])
|
||||
|
||||
Get a suggestion from it's status
|
||||
|
||||
|
|
@ -212,8 +217,10 @@ all the suggestion with C<$status>
|
|||
|
||||
sub GetSuggestionByStatus {
|
||||
my $status = shift;
|
||||
my $branchcode = shift;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "SELECT suggestions.*,
|
||||
my @sql_params=($status);
|
||||
my $query = qq(SELECT suggestions.*,
|
||||
U1.surname AS surnamesuggestedby,
|
||||
U1.firstname AS firstnamesuggestedby,
|
||||
U1.borrowernumber AS borrnumsuggestedby,
|
||||
|
|
@ -223,17 +230,28 @@ sub GetSuggestionByStatus {
|
|||
FROM suggestions
|
||||
LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
|
||||
LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber
|
||||
WHERE status = ?
|
||||
";
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($status);
|
||||
|
||||
my @results;
|
||||
while(my $data = $sth->fetchrow_hashref){
|
||||
$data->{date} = format_date($data->{date});
|
||||
push @results,$data;
|
||||
WHERE status = ?);
|
||||
if (C4::Context->preference("IndependantBranches") || $branchcode) {
|
||||
my $userenv = C4::Context->userenv;
|
||||
if ($userenv) {
|
||||
unless ($userenv->{flags} == 1){
|
||||
push @sql_params,$userenv->{branch};
|
||||
$query .= " and (U1.branchcode = ? or U1.branchcode ='')";
|
||||
}
|
||||
}
|
||||
if ($branchcode) {
|
||||
push @sql_params,$branchcode;
|
||||
$query .= " and (U1.branchcode = ? or U1.branchcode ='')";
|
||||
}
|
||||
}
|
||||
return \@results;
|
||||
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute(@sql_params);
|
||||
|
||||
my $results;
|
||||
$results= $sth->fetchall_arrayref({});
|
||||
# map{$_->{date} = format_date($_->{date})} @$results;
|
||||
return $results;
|
||||
}
|
||||
|
||||
=head2 CountSuggestion
|
||||
|
|
@ -443,7 +461,7 @@ Delete a suggestion. A borrower can delete a suggestion only if he is its owner.
|
|||
=cut
|
||||
|
||||
sub DelSuggestion {
|
||||
my ($borrowernumber,$suggestionid) = @_;
|
||||
my ($borrowernumber,$suggestionid,$type) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
# check that the suggestion comes from the suggestor
|
||||
my $query = "
|
||||
|
|
@ -454,13 +472,14 @@ sub DelSuggestion {
|
|||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($suggestionid);
|
||||
my ($suggestedby) = $sth->fetchrow;
|
||||
if ($suggestedby eq $borrowernumber) {
|
||||
if ($type eq "intranet" || $suggestedby eq $borrowernumber ) {
|
||||
my $queryDelete = "
|
||||
DELETE FROM suggestions
|
||||
WHERE suggestionid=?
|
||||
";
|
||||
$sth = $dbh->prepare($queryDelete);
|
||||
$sth->execute($suggestionid);
|
||||
my $suggestiondeleted=$sth->execute($suggestionid);
|
||||
return $suggestiondeleted;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
|
||||
<title>Koha › Acquisitions &rasquo; Suggestions Management</title>
|
||||
<title>Koha › Acquisitions › Suggestions Management</title>
|
||||
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
|
||||
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.pack.js"></script>
|
||||
<script type="text/JavaScript">
|
||||
// <![CDATA[
|
||||
|
||||
$.tablesorter.addParser({
|
||||
id: 'articles',
|
||||
is: function(s) {return false; },
|
||||
format: function(s) { return s.toLowerCase().replace(/^(the|an|a) /,''); },
|
||||
type: 'text'
|
||||
});
|
||||
/**
|
||||
* displayOther.
|
||||
* This function display the select or an textaera to write a reason.
|
||||
|
|
@ -13,6 +19,38 @@
|
|||
$("#"+show+id).show();
|
||||
}
|
||||
$(document).ready(function() {
|
||||
$('#suggestiontabs > ul').tabs({
|
||||
select: function(ui) {
|
||||
$("#loadingtab").show();
|
||||
},
|
||||
show: function(ui) {
|
||||
$("#loadingtab").hide();
|
||||
}
|
||||
});
|
||||
$("#acceptedt").tablesorter({
|
||||
headers: { 0: { sorter: 'articles' },3:{sorter: false},4:{sorter: false},5:{sorter: false},6:{sorter: false},7:{sorter: false}}
|
||||
});
|
||||
$("#acceptedt").bind("sortStart",function() {
|
||||
$("#sorting").show();
|
||||
}).bind("sortEnd",function() {
|
||||
$("#sorting").hide();
|
||||
});
|
||||
$("#pendingt").tablesorter({
|
||||
headers: { 0: { sorter: 'articles' },3:{sorter: false},4:{sorter: false},5:{sorter: false},6:{sorter: false},7:{sorter: false}}
|
||||
});
|
||||
$("#pendingt").bind("sortStart",function() {
|
||||
$("#sorting").show();
|
||||
}).bind("sortEnd",function() {
|
||||
$("#sorting").hide();
|
||||
});
|
||||
$("#rejectedt").tablesorter({
|
||||
headers: { 0: { sorter: 'articles' },3:{sorter: false},4:{sorter: false},5:{sorter: false},6:{sorter: false},7:{sorter: false}}
|
||||
});
|
||||
$("#rejectedt").bind("sortStart",function() {
|
||||
$("#sorting").show();
|
||||
}).bind("sortEnd",function() {
|
||||
$("#sorting").hide();
|
||||
});
|
||||
$("div[id*=other-reason]").hide();
|
||||
$("input[name*=other-reason]").focus(function(){ $(this).val(""); });
|
||||
$("select[name*=reason]").change(function(){
|
||||
|
|
@ -28,6 +66,21 @@
|
|||
});
|
||||
// ]]>
|
||||
</script>
|
||||
<style>
|
||||
.overlay {
|
||||
top: 180px;
|
||||
left: 50%;
|
||||
position: absolute;
|
||||
margin-left: -100px;
|
||||
width: 200px;
|
||||
text-align: center;
|
||||
display: none;
|
||||
margin-top: -10px;
|
||||
background: #eeffd4;
|
||||
padding : .5em;
|
||||
color: #000;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- TMPL_INCLUDE NAME="header.inc" -->
|
||||
|
|
@ -42,39 +95,69 @@
|
|||
<div class="yui-b">
|
||||
|
||||
<h1>Suggestions</h1>
|
||||
|
||||
<div class="toptabs">
|
||||
<div id="sorting" class="overlay">Sorting...</div>
|
||||
<div id="loadingtab" class="overlay">Loading tab...</div>
|
||||
<div id="suggestiontabs" class="toptabs">
|
||||
<ul class="ui-tabs-nav">
|
||||
<!-- TMPL_IF NAME="op_accepted"--><li class="ui-tabs-selected"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/suggestion/acceptorreject.pl?op=accepted">Accepted</a></li>
|
||||
<!-- TMPL_IF NAME="op_else" --><li class="ui-tabs-selected"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/suggestion/acceptorreject.pl?op=aorr_confirm">Pending</a></li>
|
||||
<!-- TMPL_IF NAME="op_rejected"--><li class="ui-tabs-selected"><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><a href="/cgi-bin/koha/suggestion/acceptorreject.pl?op=rejected">Rejected</a></li>
|
||||
<li><a href="/cgi-bin/koha/suggestion/acceptorreject.pl#accepted">Accepted</a></li>
|
||||
<li class="ui-tabs-selected"><a href="/cgi-bin/koha/suggestion/acceptorreject.pl#pending">Pending</a></li>
|
||||
<li><a href="/cgi-bin/koha/suggestion/acceptorreject.pl#rejected">Rejected</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tabs-container">
|
||||
<!--TMPL_LOOP Name="suggestions"-->
|
||||
<div id="<!--TMPL_VAR Name="suggestiontype"-->">
|
||||
<form name="f<!--TMPL_VAR Name="suggestiontype"-->" method="post" action="/cgi-bin/koha/suggestion/acceptorreject.pl">
|
||||
<input type="hidden" name="op" value="aorr_confirm" />
|
||||
<input type="hidden" name="suggestiontype" value="<!--TMPL_VAR Name="suggestiontype"-->" >
|
||||
|
||||
<!-- TMPL_IF name="op_else" -->
|
||||
<!-- TMPL_IF NAME="suggestions_loop" -->
|
||||
<form name="f" method="post" action="/cgi-bin/koha/suggestion/acceptorreject.pl">
|
||||
<input type="hidden" name="op" value="aorr_confirm" />
|
||||
<table>
|
||||
<tr>
|
||||
<th>Status</th>
|
||||
<th>Reason</th>
|
||||
<!--TMPL_IF EXPR="suggestiontype eq 'accepted'"-->
|
||||
<table id="acceptedt">
|
||||
<!-- TMPL_ELSIF EXPR="suggestiontype eq 'pending'" -->
|
||||
<table id="pendingt">
|
||||
<!-- TMPL_ELSE -->
|
||||
<table id="rejectedt">
|
||||
<!-- /TMPL_IF -->
|
||||
<thead><tr>
|
||||
<th>Suggestion</th>
|
||||
<th>Suggested by</th>
|
||||
</tr>
|
||||
<!-- TMPL_LOOP NAME="suggestions_loop" -->
|
||||
<th>Date</th>
|
||||
<!--TMPL_IF EXPR="suggestiontype ne 'pending'"-->
|
||||
<th>Reason</th>
|
||||
<th>Reason Update</th>
|
||||
<!--TMPL_ELSE-->
|
||||
<th>Reason</th>
|
||||
<!--/TMPL_IF -->
|
||||
<th>Accept</th>
|
||||
<th>Reject</th>
|
||||
<th>Delete</th>
|
||||
</tr></thead>
|
||||
<tbody><!-- TMPL_LOOP NAME="suggestions_loop" -->
|
||||
<!-- TMPL_IF name="even" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
|
||||
<td>
|
||||
<select name="aorr">
|
||||
<option value=""> -- Choose Action -- </option>
|
||||
<option value="R<!--TMPL_VAR name="suggestionid" -->">Reject</option>
|
||||
<option value="A<!--TMPL_VAR name="suggestionid" -->">Accept</option>
|
||||
</select>
|
||||
<!-- 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 EXPR="suggestiontype ne 'pending'"-->
|
||||
<td>
|
||||
<!--TMPL_VAR Name="reason"-->
|
||||
|
||||
</td>
|
||||
<!--/TMPL_IF -->
|
||||
<td>
|
||||
<div id="select-reason<!-- TMPL_VAR NAME="suggestionid" -->">
|
||||
<!-- TMPL_IF NAME="reasonsloop" --><select id="reason<!-- TMPL_VAR name="suggestionid" -->" name="reason<!-- TMPL_VAR name="suggestionid" -->">
|
||||
<!-- TMPL_IF NAME="reasonsloop" --><select id="reason<!-- TMPL_VAR NAME="suggestionid" -->" name="reason<!-- TMPL_VAR NAME="suggestionid" -->">
|
||||
<option value=""> -- Choose a reason -- </option>
|
||||
<!-- TMPL_LOOP NAME="reasonsloop" -->
|
||||
<option value="<!-- TMPL_VAR NAME="lib" -->"><!-- TMPL_VAR NAME="lib" --></option>
|
||||
|
|
@ -89,87 +172,64 @@
|
|||
|
||||
</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><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrnumsuggestedby" -->"><!-- TMPL_VAR name="surnamesuggestedby" --><!-- TMPL_IF name="firstnamesuggestedby" -->, <!-- TMPL_VAR name="firstnamesuggestedby" --><!-- /TMPL_IF --></a></td>
|
||||
</tr>
|
||||
<!-- /TMPL_LOOP -->
|
||||
</table>
|
||||
<!--TMPL_IF EXPR="suggestiontype eq 'accepted'"-->
|
||||
<input id="a<!--TMPL_VAR name="suggestionid" -->" name="<!--TMPL_VAR name="suggestionid" -->" type="radio" value="ACCEPTED" disabled="disabled" />
|
||||
|
||||
<!--TMPL_ELSE-->
|
||||
<input id="a<!--TMPL_VAR name="suggestionid" -->" name="<!--TMPL_VAR name="suggestionid" -->" type="radio" value="ACCEPTED" />
|
||||
<!--/TMPL_IF-->
|
||||
</td>
|
||||
<td>
|
||||
<!--TMPL_IF EXPR="suggestiontype eq 'rejected'"-->
|
||||
<input id="r<!--TMPL_VAR name="suggestionid" -->" name="<!--TMPL_VAR name="suggestionid" -->" type="radio" value="REJECTED" disabled="disabled" />
|
||||
|
||||
<!--TMPL_ELSE-->
|
||||
<input id="r<!--TMPL_VAR name="suggestionid" -->" name="<!--TMPL_VAR name="suggestionid" -->" type="radio" value="REJECTED" />
|
||||
<!--/TMPL_IF-->
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<input id="d<!--TMPL_VAR name="suggestionid" -->" name="<!--TMPL_VAR name="suggestionid" -->" type="radio" value="delete" />
|
||||
</td>
|
||||
</tr>
|
||||
<!-- /TMPL_LOOP --></tbody>
|
||||
</table> <fieldset>
|
||||
<div id="select-reason<!-- TMPL_VAR NAME="suggestiontype" -->all">
|
||||
<label for="reason<!-- TMPL_VAR NAME="suggestiontype" -->all">Choose a reason for all marked entries:</label> <select id="reason<!-- TMPL_VAR NAME="suggestiontype" -->all" name="reason<!-- TMPL_VAR NAME="suggestiontype" -->all">
|
||||
<option value=""> -- Choose a reason -- </option>
|
||||
<!--TMPL_LOOP Name="reasonsloop"-->
|
||||
<option value="<!--TMPL_VAR Name="lib" -->"><!--TMPL_VAR Name="lib" --></option>
|
||||
<!--/TMPL_LOOP-->
|
||||
<option value="other">Others...</option>
|
||||
</select> <a href="#markall" id="markallop<!-- TMPL_VAR NAME="suggestiontype" -->">Mark all with this reason</a>
|
||||
</div>
|
||||
|
||||
<div id="other-reason<!-- TMPL_VAR NAME="suggestiontype" -->all">
|
||||
<label for="other-reason<!-- TMPL_VAR NAME="suggestiontype" -->all">Enter a reason for all marked entries:</label>
|
||||
<input type="text" size="31" id="other-reason<!-- TMPL_VAR NAME="suggestiontype" -->all" name="other-reason<!-- TMPL_VAR NAME="suggestiontype" -->all" value="please note your reason here..." />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="action"><input type="submit" value="Change Status" /></fieldset>
|
||||
</form>
|
||||
<!-- TMPL_ELSE -->
|
||||
<b>No waiting suggestions to accept or reject.</b>
|
||||
<!-- /TMPL_IF -->
|
||||
<!--TMPL_IF EXPR="suggestiontype eq 'pending'"-->
|
||||
<b>No pending suggestions.</b>
|
||||
<!--/TMPL_IF-->
|
||||
<!--TMPL_IF EXPR="suggestiontype eq 'accepted'"-->
|
||||
<b>No accepted suggestions.</b>
|
||||
<!--/TMPL_IF-->
|
||||
<!--TMPL_IF EXPR="suggestiontype eq 'rejected'"-->
|
||||
<b>No rejected suggestions.</b>
|
||||
<!--/TMPL_IF-->
|
||||
<!-- /TMPL_IF -->
|
||||
|
||||
<!-- TMPL_IF NAME="done" -->
|
||||
|
||||
<!-- TMPL_IF NAME="suggestions_loop" -->
|
||||
<table>
|
||||
<tr>
|
||||
<th>Reason</th>
|
||||
<th>Suggestion</th>
|
||||
<th>Suggested by</th>
|
||||
<th>Date</th>
|
||||
</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>
|
||||
<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrnumsuggestedby" -->"><!-- TMPL_VAR name="surnamesuggestedby" --><!-- TMPL_IF name="firstnamesuggestedby" -->, <!-- TMPL_VAR name="firstnamesuggestedby" --><!-- /TMPL_IF --></a>
|
||||
</td>
|
||||
<td>
|
||||
<!-- TMPL_VAR NAME="date" -->
|
||||
</td>
|
||||
</tr>
|
||||
<!-- /TMPL_LOOP -->
|
||||
</table>
|
||||
<!-- TMPL_ELSE -->
|
||||
|
||||
<h4>No suggestions have been
|
||||
<!-- TMPL_IF NAME="op_accepted"-->
|
||||
accepted.
|
||||
<!-- TMPL_ELSE -->
|
||||
rejected.
|
||||
<!-- /TMPL_IF --></h4>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_IF -->
|
||||
</div>
|
||||
<!--/TMPL_LOOP-->
|
||||
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
|
||||
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
|
||||
|
|
@ -72,6 +72,8 @@ use C4::Auth; # get_template_and_user
|
|||
use C4::Output;
|
||||
use C4::Suggestions;
|
||||
use C4::Koha; # GetAuthorisedValue
|
||||
use C4::Dates qw(format_date);
|
||||
|
||||
|
||||
my $input = new CGI;
|
||||
my $title = $input->param('title');
|
||||
|
|
@ -100,53 +102,77 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
|||
|
||||
my $suggestions;
|
||||
|
||||
if ( $op eq "aorr_confirm" ) {
|
||||
my @suggestionlist = $input->param("aorr");
|
||||
my $branchcode;
|
||||
my $userenv = C4::Context->userenv;
|
||||
if ($userenv) {
|
||||
unless ($userenv->{flags} == 1){
|
||||
$branchcode=$userenv->{branch};
|
||||
}
|
||||
}
|
||||
|
||||
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 ( $op eq "aorr_confirm" ) {
|
||||
my $parameters=$input->Vars;
|
||||
my @deletelist;
|
||||
my $suggestiontype=$parameters->{suggestiontype};
|
||||
foreach my $suggestionid (keys %$parameters){
|
||||
next unless $suggestionid=~/^\d+$/;
|
||||
## it is a suggestion
|
||||
if ($parameters->{$suggestionid}=~/delete/i){
|
||||
push @deletelist,$suggestionid;
|
||||
}
|
||||
else {
|
||||
## it is not a deletion
|
||||
## Get the Reason
|
||||
my $reason = $parameters->{"reason$suggestionid"};
|
||||
if ( $reason eq "other" ) {
|
||||
$reason = $input->param( "other-reason" . $suggestionid );
|
||||
$reason = $parameters->{"other-reason$suggestionid"};
|
||||
}
|
||||
ModStatus( $suggestionid, $newstatus, $loggedinuser, '', $reason );
|
||||
unless ($reason){
|
||||
$reason= $parameters->{"reason".$suggestiontype."all"};
|
||||
if ( $reason eq "other" ) {
|
||||
$reason = $parameters->{"other-reason".$suggestiontype."all"};
|
||||
}
|
||||
}
|
||||
ModStatus( $suggestionid, $parameters->{$suggestionid}, $loggedinuser, '', $reason );
|
||||
}
|
||||
}
|
||||
$op = "else";
|
||||
$suggestions = &SearchSuggestion( "", "", "", "", 'ASKED', "" );
|
||||
if (scalar(@deletelist)>0){
|
||||
my $params = "&delete_field=".join ("&delete_field=",@deletelist);
|
||||
warn $params;
|
||||
print $input->redirect("/cgi-bin/koha/suggestion/acceptorreject.pl?op=delete_confirm$params");
|
||||
}
|
||||
}
|
||||
|
||||
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,"intranet" );
|
||||
}
|
||||
$op = 'else';
|
||||
$suggestions = &SearchSuggestion( "", "", "", "", 'ASKED', "" );
|
||||
}
|
||||
|
||||
if ( $op eq "accepted" ) {
|
||||
$suggestions = &GetSuggestionByStatus('ACCEPTED');
|
||||
$template->param(done => 1);
|
||||
}
|
||||
|
||||
if ( $op eq "rejected" ) {
|
||||
$suggestions = &GetSuggestionByStatus('REJECTED');
|
||||
$template->param(done => 1);
|
||||
}
|
||||
|
||||
my $reasonsloop = GetAuthorisedValues("SUGGEST");
|
||||
my @suggestions_loop;
|
||||
foreach my $suggestion (@$suggestions) {
|
||||
$suggestion->{'reasonsloop'} = $reasonsloop;
|
||||
push @suggestions_loop, $suggestion;
|
||||
}
|
||||
my $pending_suggestions = &SearchSuggestion( "", "", "", "", 'ASKED', "",$branchcode );
|
||||
map{$_->{'reasonsloop'}=$reasonsloop;$_->{'date'}=format_date($_->{'date'})} @$pending_suggestions;
|
||||
my $accepted_suggestions = &GetSuggestionByStatus('ACCEPTED',$branchcode);
|
||||
map{$_->{'reasonsloop'}=$reasonsloop;$_->{'date'}=format_date($_->{'date'})} @$accepted_suggestions;
|
||||
my $rejected_suggestions = &GetSuggestionByStatus('REJECTED',$branchcode);
|
||||
map{$_->{'reasonsloop'}=$reasonsloop;$_->{'date'}=format_date($_->{'date'})} @$rejected_suggestions;
|
||||
|
||||
my @allsuggestions;
|
||||
push @allsuggestions,{"suggestiontype"=>"accepted",
|
||||
'suggestions_loop'=>$accepted_suggestions,
|
||||
'reasonsloop' => $reasonsloop};
|
||||
push @allsuggestions,{"suggestiontype"=>"pending",
|
||||
'suggestions_loop'=>$pending_suggestions,
|
||||
'reasonsloop' => $reasonsloop};
|
||||
push @allsuggestions,{"suggestiontype"=>"rejected",
|
||||
'suggestions_loop'=>$rejected_suggestions,
|
||||
'reasonsloop' => $reasonsloop};
|
||||
|
||||
$template->param(
|
||||
suggestions_loop => \@suggestions_loop,
|
||||
suggestions => \@allsuggestions,
|
||||
"op_$op" => 1,
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue