<div id="toolbar" class="btn-toolbar">
<a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit&suggestionid=[% suggestionid | html %]"><i class="fa fa-pencil"></i> Edit</a>
- <a class="btn btn-default deletesuggestion" href="suggestion.pl?op=delete&edit_field=[% suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
+ <a class="btn btn-default deletesuggestion" href="suggestion.pl?op=delete&suggestionid=[% suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
</div>
<fieldset class="rows">
<ul class="ui-tabs-nav">
[% FOREACH suggestion IN suggestions %]
<li>
- <a href="#[% suggestion.suggestiontype | uri %]">
+ <a href="#tab_[% loop.count %]">
[% IF ( suggestion.suggestiontypelabel ) %]
[% IF (suggestion.suggestiontypelabel == "Pending") %]Pending
[% ELSIF (suggestion.suggestiontypelabel == "Accepted") %]Accepted
[% END %]
[% FOREACH suggestion IN suggestions %]
-<div id="[% suggestion.suggestiontype | html %]">
-<form class="update_suggestions" name="f[% suggestion.suggestiontype | html %]" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#[% suggestion.suggestiontype | html %]">
+<div id="tab_[% loop.count %]">
+<form class="update_suggestions" name="f" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#tab_[% loop.count %]">
[% IF ( suggestion.suggestions_loop ) %]
-<p><a id="CheckAll[% suggestion.suggestiontype | html %]" href="#">Check all</a> | <a id="UncheckAll[% suggestion.suggestiontype | html %]" href="#">Uncheck all</a></p>
- <table id="[% suggestion.suggestiontype | html %]t" class="sorted">
+<p><a class="checkall" href="#">Check all</a> | <a name="uncheckall" href="#">Uncheck all</a></p>
+ <table id="table_[% loop.count %]" class="sorted">
<thead>
<tr>
<th class="NoSort noExport"> </th>
[% FOREACH suggestions_loo IN suggestion.suggestions_loop %]
<tr>
<td>
- <input type="checkbox" name="edit_field" value="[% suggestions_loo.suggestionid | html %]" />
+ <input type="checkbox" name="suggestionid" value="[% suggestions_loo.suggestionid | html %]" />
</td>
<td>
<a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | uri %]&op=show" title="suggestion" >
</td>
<td class="actions">
<a class="btn btn-xs btn-default" href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | html %]&op=edit"><i class="fa fa-pencil"></i> Edit</a>
- <a class="btn btn-default btn-xs deletesuggestion" href="suggestion.pl?op=delete&edit_field=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
+ <a class="btn btn-default btn-xs deletesuggestion" href="suggestion.pl?op=delete&suggestionid=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
</td>
</tr>
[% END %]</tbody>
- </table> <fieldset>
- <div id="select-reason[% suggestion.suggestiontype | html %]">
- <div id="status[% suggestion.suggestiontype | html %]">
- <label for="STATUS[% suggestion.suggestiontype | html %]">Mark selected as: </label>
- <select name="STATUS" id="STATUS[% suggestion.suggestiontype | html %]">
- <option value=""> -- Choose a status --</option>
-
- [% IF (statusselected_ASKED ) %]
- <option value="ASKED" selected="selected">Pending</option>
- [% ELSE %]
- <option value="ASKED">Pending</option>
- [% END %]
-
- [% IF (statusselected_ACCEPTED ) %]
- <option value="ACCEPTED" selected="selected">Accepted</option>
- [% ELSE %]
- <option value="ACCEPTED">Accepted</option>
- [% END %]
+ </table>
- [% IF (statusselected_CHECKED ) %]
- <option value="CHECKED" selected="selected">Checked</option>
- [% ELSE %]
- <option value="CHECKED">Checked</option>
- [% END %]
-
- [% IF ( statusselected_REJECTED ) %]
- <option value="REJECTED" selected="selected">Rejected</option>
- [% ELSE %]
- <option value="REJECTED">Rejected</option>
- [% END %]
-
- [% FOREACH s IN SuggestionStatuses %]
- <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
- [% END %]
- </select>
-
- <label for="reason[% suggestion.suggestiontype | html %]">with this reason:</label>
- <select id="reason[% suggestion.suggestiontype | html %]" name="reason[% suggestion.suggestiontype | html %]">
- <option value=""> -- Choose a reason -- </option>
- [% FOREACH reasonsloo IN suggestion.reasonsloop %]
- <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
- [% END %]
- <option value="other">Others...</option>
- </select>
-
- <span id="other_reason[% suggestion.suggestiontype | html %]">
- <input type="text" size="31" id="select-other_reason[% suggestion.suggestiontype | html %]" name="other_reason[% suggestion.suggestiontype | html %]" placeholder="please note your reason here..." />
- <a href="#back[% suggestion.suggestiontype | uri %]">Cancel</a>
- </span>
-
- <strong style="padding: 0 1em;">OR:</strong>
+ <div class="row">
+ <h2 style="padding-left:1em;">Change selected suggestions</h3>
+ <div class="col-sm-4">
+ <fieldset>
+ <div id="select-reason">
+ <label for="STATUS">Mark selected as: </label>
+ <select name="STATUS" id="STATUS">
+ <option value=""> -- Choose a status --</option>
+
+ [% IF (statusselected_ASKED ) %]
+ <option value="ASKED" selected="selected">Pending</option>
+ [% ELSE %]
+ <option value="ASKED">Pending</option>
+ [% END %]
+
+ [% IF (statusselected_ACCEPTED ) %]
+ <option value="ACCEPTED" selected="selected">Accepted</option>
+ [% ELSE %]
+ <option value="ACCEPTED">Accepted</option>
+ [% END %]
+
+ [% IF (statusselected_CHECKED ) %]
+ <option value="CHECKED" selected="selected">Checked</option>
+ [% ELSE %]
+ <option value="CHECKED">Checked</option>
+ [% END %]
+
+ [% IF ( statusselected_REJECTED ) %]
+ <option value="REJECTED" selected="selected">Rejected</option>
+ [% ELSE %]
+ <option value="REJECTED">Rejected</option>
+ [% END %]
+
+ [% FOREACH s IN SuggestionStatuses %]
+ <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
+ [% END %]
+ </select>
+
+ <label for="reason">with this reason:</label>
+ <select name="reason">
+ <option value=""> -- Choose a reason -- </option>
+ [% FOREACH reasonsloo IN suggestion.reasonsloop %]
+ <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
+ [% END %]
+ <option value="other">Others...</option>
+ </select>
+
+ <span class="other_reason">
+ <input type="text" size="31" name="other_reason" placeholder="please note your reason here..." />
+ <a href="#" class="cancel_note">Cancel</a>
+ </span>
+ </div>
+
+ <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
+ <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="update_status"/>Submit</button></fieldset>
+ </fieldset>
+ </div>
+ <div class="col-sm-4">
+ <fieldset>
+ <label for="itemtype">Update item types with: </label>
+ [% PROCESS 'av-build-dropbox.inc' name="suggestion_itemtype", category="SUGGEST_FORMAT", size = 20 %]
+ <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
+ <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="update_itemtype"/>Submit</button></fieldset>
+ </fieldset>
+ </div>
- <label for="[% suggestion.suggestiontype | html %]delete">Delete selected</label>
- <input type="checkbox" name="op" id="[% suggestion.suggestiontype | html %]delete" />
+ <div class="col-sm-4">
+ <fieldset>
+ <label for="delete_[% loop.count %]">Delete selected</label>
+ <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
+ <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="delete"/>Delete</button></fieldset>
+ </fieldset>
+ </div>
</div>
- </div>
- <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
- <input type="hidden" name="tabcode" value="[% suggestion.suggestiontype | html %]" />
- <input type="hidden" name="op" value="change" />
-</fieldset>
- <fieldset class="action">
- <input type="submit" value="Submit" /></fieldset>
-</form>
[% ELSE %]
<b>No results.</b>
[% END %]
+</form>
</div>
[% END %]
- </div>
[% END %]
[% UNLESS ( op_save ) %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
- <script>
- /**
- * displayOther.
- * This function display the select or an textaera to write a reason.
- */
- function displayOther(id,show,hide){
- $("#"+hide+id).hide();
- $("#"+show+id).show();
- }
+
+ <script type="text/javascript">
$(document).ready(function() {
$('#suggestiontabs').tabs();
[% END %]
[% END %]
- [% FOREACH suggestion IN suggestions %]
- // functions for [% suggestion.suggestiontype | html %] interactions
- $("#CheckAll[% suggestion.suggestiontype | html %]").click(function(e){
- $("#[% suggestion.suggestiontype | html %]t").checkCheckboxes();
- e.preventDefault();
+ $(".checkall").click(function(e){
+ $(this).parent(form).checkCheckboxes();
+ return false;
});
- $("#UncheckAll[% suggestion.suggestiontype | html %]").click(function(e){
- $("#[% suggestion.suggestiontype | html %]t").unCheckCheckboxes();
- e.preventDefault();
+ $(".uncheckall").click(function(e){
+ $(this).parent(form).unCheckCheckboxes();
+ return false;
});
- $("#other_reason[% suggestion.suggestiontype | html %]").hide();
- $("#reason[% suggestion.suggestiontype | html %]").change(function(){
+ $(".other_reason").hide();
+ $("select[name='reason']").change(function(){
if($(this).val() == "other"){
$(this).hide();
- $("#other_reason[% suggestion.suggestiontype | html %]").show();
- }
- });
- $("#[% suggestion.suggestiontype | html %]delete").change(function(){
- if(this.checked){
- $("form[name='f[% suggestion.suggestiontype | html %]'] input[name=op]").attr("value","delete");
- } else {
- $("form[name='f[% suggestion.suggestiontype | html %]'] input[name=op]").attr("value","change");
+ $(this).siblings(".other_reason").show();
}
});
- [% END %]
- $("a[href*=back]").click(function(){
- var sid = $(this).attr("href").replace(/#back/,"");
- $("#reason"+sid).show().find("option[value='']").attr("selected","selected");
- $("#other_reason"+sid).hide();
+ $("a.cancel_note").click(function(e) {
+ $(this).parent().siblings("select").show().find("option[value='']").attr("selected","selected");
+ $(this).siblings("input[name='other_reason']").hide();
+ e.preventDefault();
});
$("h4.local_collapse a").click(function(){
$(this).parent().parent().find("ol").toggle();
}
});
- $("form.update_suggestions").on("submit", function(e){
- var form = this;
- var action_delete_selected = $(this).find("input[value='delete']").is(":checked");
- if ( action_delete_selected ) {
- var suggestions_to_delete = $(this).find("input[name='edit_field']:checked");
- if ( suggestions_to_delete.length == 0 ) {
- alert(_("Please select at least one suggestion to delete"));
- e.preventDefault();
- return false;
- } else if ( suggestions_to_delete.length == 1 ) {
+ $("button[type='submit']").on("click", function(e) {
+ var form = $(this).parents("form");
+ var action = $(this).val();
+ var selected_suggestions = $(form).find("input[name='suggestionid']:checked");
+ if ( selected_suggestions.length == 0 ) {
+ alert(_("Please select at least one suggestion"));
+ e.preventDefault();
+ return false;
+ }
+ if ( action == "delete" ) {
+ if ( selected_suggestions.length == 1 ) {
if ( ! confirm(_("Are you sure you want to delete this suggestion?")) ) {
e.preventDefault();
return false;
}
- } else if ( suggestions_to_delete.length > 1 ) {
+ } else if ( selected_suggestions.length > 1 ) {
if ( ! confirm(_("Are you sure you want to delete these suggestions?")) ) {
e.preventDefault();
return false;
}
}
}
+
+ $('<input />').attr('type', 'hidden')
+ .attr('name', "op")
+ .attr('value', action)
+ .appendTo(form);
return true;
});
});
my $redirect = $input->param('redirect');
my $suggestedbyme = (defined $input->param('suggestedbyme')? $input->param('suggestedbyme'):1);
my $op = $input->param('op')||'else';
-my @editsuggestions = $input->multi_param('edit_field');
+my @editsuggestions = $input->multi_param('suggestionid');
my $suggestedby = $input->param('suggestedby');
my $returnsuggestedby = $input->param('returnsuggestedby');
my $returnsuggested = $input->param('returnsuggested');
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'));
+ delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' ));
}
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
{
Init($suggestion_ref);
$op ='save';
}
-elsif ($op eq "change" ) {
+elsif ($op eq "update_status" ) {
my $suggestion;
# set accepted/rejected/managed informations if applicable
$suggestion->{managedby} = C4::Context->userenv->{number};
$suggestion->{STATUS} = $STATUS;
}
- if ( my $reason = $input->param("reason$tabcode") ) {
+ if ( my $reason = $input->param("reason") ) {
if ( $reason eq "other" ) {
- $reason = $input->param("other_reason$tabcode");
+ $reason = $input->param("other_reason");
}
$suggestion->{reason} = $reason;
}
}
$op = 'else';
}
+elsif ( $op eq 'update_itemtype' ) {
+ my $new_itemtype = $input->param('suggestion_itemtype');
+ foreach my $suggestionid (@editsuggestions) {
+ next unless $suggestionid;
+ &ModSuggestion({ suggestionid => $suggestionid, itemtype => $new_itemtype });
+ }
+}
elsif ( $op eq 'show' ) {
$suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
my $budget = GetBudget $$suggestion_ref{budgetid};