View | Details | Raw Unified | Return to bug 23594
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-112 / +114 lines)
Lines 56-62 Link Here
56
56
57
    <div id="toolbar" class="btn-toolbar">
57
    <div id="toolbar" class="btn-toolbar">
58
        <a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-pencil"></i> Edit</a>
58
        <a class="btn btn-default" id="editsuggestion" href="suggestion.pl?op=edit&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-pencil"></i> Edit</a>
59
        <a class="btn btn-default deletesuggestion" href="suggestion.pl?op=delete&amp;edit_field=[% suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
59
        <a class="btn btn-default deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
60
    </div>
60
    </div>
61
61
62
    <fieldset class="rows">
62
    <fieldset class="rows">
Lines 470-476 Link Here
470
    <ul class="ui-tabs-nav">
470
    <ul class="ui-tabs-nav">
471
        [% FOREACH suggestion IN suggestions %]
471
        [% FOREACH suggestion IN suggestions %]
472
                <li>
472
                <li>
473
            <a href="#[% suggestion.suggestiontype | uri %]">
473
            <a href="#tab_[% loop.count %]">
474
            [% IF ( suggestion.suggestiontypelabel ) %]
474
            [% IF ( suggestion.suggestiontypelabel ) %]
475
                [% IF (suggestion.suggestiontypelabel == "Pending") %]Pending
475
                [% IF (suggestion.suggestiontypelabel == "Pending") %]Pending
476
                [% ELSIF (suggestion.suggestiontypelabel == "Accepted") %]Accepted
476
                [% ELSIF (suggestion.suggestiontypelabel == "Accepted") %]Accepted
Lines 494-505 Link Here
494
[% END %]
494
[% END %]
495
495
496
[% FOREACH suggestion IN suggestions %]
496
[% FOREACH suggestion IN suggestions %]
497
<div id="[% suggestion.suggestiontype | html %]">
497
<div id="tab_[% loop.count %]">
498
<form class="update_suggestions" name="f[% suggestion.suggestiontype | html %]" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#[% suggestion.suggestiontype | html %]">
498
<form class="update_suggestions" name="f" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#tab_[% loop.count %]">
499
499
500
[% IF ( suggestion.suggestions_loop ) %]
500
[% IF ( suggestion.suggestions_loop ) %]
501
<p><a id="CheckAll[% suggestion.suggestiontype | html %]" href="#">Check all</a> | <a id="UncheckAll[% suggestion.suggestiontype | html %]" href="#">Uncheck all</a></p>
501
<p><a class="checkall" href="#">Check all</a> | <a name="uncheckall" href="#">Uncheck all</a></p>
502
    <table id="[% suggestion.suggestiontype | html %]t" class="sorted">
502
    <table id="table_[% loop.count %]" class="sorted">
503
        <thead>
503
        <thead>
504
            <tr>
504
            <tr>
505
                <th class="NoSort noExport">&nbsp;</th>
505
                <th class="NoSort noExport">&nbsp;</th>
Lines 518-524 Link Here
518
            [% FOREACH suggestions_loo IN suggestion.suggestions_loop %]
518
            [% FOREACH suggestions_loo IN suggestion.suggestions_loop %]
519
                <tr>
519
                <tr>
520
                <td>
520
                <td>
521
                    <input type="checkbox" name="edit_field" value="[% suggestions_loo.suggestionid | html %]" />
521
                    <input type="checkbox" name="suggestionid" value="[% suggestions_loo.suggestionid | html %]" />
522
                </td>
522
                </td>
523
                <td>
523
                <td>
524
                    <a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | uri %]&amp;op=show" title="suggestion" >
524
                    <a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | uri %]&amp;op=show" title="suggestion" >
Lines 571-650 Link Here
571
                </td>
571
                </td>
572
                <td class="actions">
572
                <td class="actions">
573
                    <a class="btn btn-xs btn-default" href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | html %]&amp;op=edit"><i class="fa fa-pencil"></i> Edit</a>
573
                    <a class="btn btn-xs btn-default" href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | html %]&amp;op=edit"><i class="fa fa-pencil"></i> Edit</a>
574
                    <a class="btn btn-default btn-xs deletesuggestion" href="suggestion.pl?op=delete&amp;edit_field=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
574
                    <a class="btn btn-default btn-xs deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a>
575
                </td>
575
                </td>
576
        </tr>
576
        </tr>
577
        [% END %]</tbody>
577
        [% END %]</tbody>
578
        </table>  <fieldset>
578
        </table>
579
    <div id="select-reason[% suggestion.suggestiontype | html %]">
580
        <div id="status[% suggestion.suggestiontype | html %]">
581
            <label for="STATUS[% suggestion.suggestiontype | html %]">Mark selected as: </label>
582
            <select name="STATUS" id="STATUS[% suggestion.suggestiontype | html %]">
583
                <option value=""> -- Choose a status --</option>
584
585
                [% IF (statusselected_ASKED ) %]
586
                    <option value="ASKED" selected="selected">Pending</option>
587
                [% ELSE %]
588
                    <option value="ASKED">Pending</option>
589
                [% END %]
590
591
                [% IF (statusselected_ACCEPTED ) %]
592
                    <option value="ACCEPTED" selected="selected">Accepted</option>
593
                [% ELSE %]
594
                    <option value="ACCEPTED">Accepted</option>
595
                [% END %]
596
579
597
                [% IF (statusselected_CHECKED ) %]
580
        <div class="row">
598
                    <option value="CHECKED" selected="selected">Checked</option>
581
            <h2 style="padding-left:1em;">Change selected suggestions</h3>
599
                [% ELSE %]
582
            <div class="col-sm-4">
600
                    <option value="CHECKED">Checked</option>
583
                <fieldset>
601
                [% END %]
584
                    <div id="select-reason">
602
585
                       <label for="STATUS">Mark selected as: </label>
603
                [% IF ( statusselected_REJECTED ) %]
586
                       <select name="STATUS" id="STATUS">
604
                    <option value="REJECTED" selected="selected">Rejected</option>
587
                           <option value=""> -- Choose a status --</option>
605
                [% ELSE %]
588
606
                    <option value="REJECTED">Rejected</option>
589
                           [% IF (statusselected_ASKED ) %]
607
                [% END %]
590
                               <option value="ASKED" selected="selected">Pending</option>
608
591
                           [% ELSE %]
609
                [% FOREACH s IN SuggestionStatuses %]
592
                               <option value="ASKED">Pending</option>
610
                    <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
593
                           [% END %]
611
                [% END %]
594
612
            </select>
595
                           [% IF (statusselected_ACCEPTED ) %]
613
596
                               <option value="ACCEPTED" selected="selected">Accepted</option>
614
            <label for="reason[% suggestion.suggestiontype | html %]">with this reason:</label>
597
                           [% ELSE %]
615
            <select id="reason[% suggestion.suggestiontype | html %]" name="reason[% suggestion.suggestiontype | html %]">
598
                               <option value="ACCEPTED">Accepted</option>
616
                <option value=""> -- Choose a reason -- </option>
599
                           [% END %]
617
                [% FOREACH reasonsloo IN suggestion.reasonsloop %]
600
618
                    <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
601
                           [% IF (statusselected_CHECKED ) %]
619
                [% END %]
602
                               <option value="CHECKED" selected="selected">Checked</option>
620
                <option value="other">Others...</option>
603
                           [% ELSE %]
621
            </select>
604
                               <option value="CHECKED">Checked</option>
622
605
                           [% END %]
623
            <span id="other_reason[% suggestion.suggestiontype | html %]">
606
624
                <input type="text" size="31" id="select-other_reason[% suggestion.suggestiontype | html %]" name="other_reason[% suggestion.suggestiontype | html %]" placeholder="please note your reason here..." />
607
                           [% IF ( statusselected_REJECTED ) %]
625
                <a href="#back[% suggestion.suggestiontype | uri %]">Cancel</a>
608
                               <option value="REJECTED" selected="selected">Rejected</option>
626
            </span>
609
                           [% ELSE %]
627
610
                               <option value="REJECTED">Rejected</option>
628
            <strong style="padding: 0 1em;">OR:</strong>
611
                           [% END %]
612
613
                           [% FOREACH s IN SuggestionStatuses %]
614
                               <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
615
                           [% END %]
616
                       </select>
617
618
                       <label for="reason">with this reason:</label>
619
                       <select name="reason">
620
                           <option value=""> -- Choose a reason -- </option>
621
                           [% FOREACH reasonsloo IN suggestion.reasonsloop %]
622
                               <option value="[% reasonsloo.lib | html %]">[% reasonsloo.lib | html %]</option>
623
                           [% END %]
624
                           <option value="other">Others...</option>
625
                       </select>
626
627
                       <span class="other_reason">
628
                           <input type="text" size="31" name="other_reason" placeholder="please note your reason here..." />
629
                           <a href="#" class="cancel_note">Cancel</a>
630
                       </span>
631
                    </div>
632
633
                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
634
                    <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="update_status"/>Submit</button></fieldset>
635
                </fieldset>
636
            </div>
637
            <div class="col-sm-4">
638
                <fieldset>
639
                    <label for="itemtype">Update item types with: </label>
640
                    [% PROCESS 'av-build-dropbox.inc' name="suggestion_itemtype", category="SUGGEST_FORMAT", size = 20  %]
641
                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
642
                    <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="update_itemtype"/>Submit</button></fieldset>
643
                </fieldset>
644
            </div>
629
645
630
            <label for="[% suggestion.suggestiontype | html %]delete">Delete selected</label>
646
            <div class="col-sm-4">
631
            <input type="checkbox" name="op" id="[% suggestion.suggestiontype | html %]delete" />
647
                <fieldset>
648
                    <label for="delete_[% loop.count %]">Delete selected</label>
649
                    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
650
                    <fieldset class="action"><button type="submit" class="btn btn-default btn-xs" value="delete"/>Delete</button></fieldset>
651
                </fieldset>
652
            </div>
632
        </div>
653
        </div>
633
    </div>
634
654
635
    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
636
    <input type="hidden" name="tabcode" value="[% suggestion.suggestiontype | html %]" />
637
    <input type="hidden" name="op" value="change" />
638
</fieldset>
639
        <fieldset class="action">
640
    <input type="submit" value="Submit" /></fieldset>
641
</form>
642
[% ELSE %]
655
[% ELSE %]
643
    <b>No results.</b>
656
    <b>No results.</b>
644
[% END %]
657
[% END %]
658
</form>
645
</div>
659
</div>
646
[% END %]
660
[% END %]
647
    </div>
648
[% END %]
661
[% END %]
649
662
650
[% UNLESS ( op_save ) %]
663
[% UNLESS ( op_save ) %]
Lines 823-837 Link Here
823
        [% INCLUDE 'datatables.inc' %]
836
        [% INCLUDE 'datatables.inc' %]
824
        [% INCLUDE 'columns_settings.inc' %]
837
        [% INCLUDE 'columns_settings.inc' %]
825
        [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
838
        [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
826
        <script>
839
827
            /**
840
        <script type="text/javascript">
828
            *  displayOther.
829
            *  This function display the select or an textaera to write a reason.
830
            */
831
            function displayOther(id,show,hide){
832
                $("#"+hide+id).hide();
833
                $("#"+show+id).show();
834
            }
835
            $(document).ready(function() {
841
            $(document).ready(function() {
836
                $('#suggestiontabs').tabs();
842
                $('#suggestiontabs').tabs();
837
843
Lines 849-884 Link Here
849
                    [% END %]
855
                    [% END %]
850
                [% END %]
856
                [% END %]
851
857
852
            [% FOREACH suggestion IN suggestions %]
858
                $(".checkall").click(function(e){
853
                // functions for [% suggestion.suggestiontype | html %] interactions
859
                    $(this).parent(form).checkCheckboxes();
854
                $("#CheckAll[% suggestion.suggestiontype | html %]").click(function(e){
860
                    return false;
855
                    $("#[% suggestion.suggestiontype | html %]t").checkCheckboxes();
856
                    e.preventDefault();
857
                });
861
                });
858
                $("#UncheckAll[% suggestion.suggestiontype | html %]").click(function(e){
862
                $(".uncheckall").click(function(e){
859
                    $("#[% suggestion.suggestiontype | html %]t").unCheckCheckboxes();
863
                    $(this).parent(form).unCheckCheckboxes();
860
                    e.preventDefault();
864
                    return false;
861
                });
865
                });
862
                $("#other_reason[% suggestion.suggestiontype | html %]").hide();
866
                $(".other_reason").hide();
863
                $("#reason[% suggestion.suggestiontype | html %]").change(function(){
867
                $("select[name='reason']").change(function(){
864
                    if($(this).val() == "other"){
868
                    if($(this).val() == "other"){
865
                        $(this).hide();
869
                        $(this).hide();
866
                        $("#other_reason[% suggestion.suggestiontype | html %]").show();
870
                        $(this).siblings(".other_reason").show();
867
                }
868
                });
869
                $("#[% suggestion.suggestiontype | html %]delete").change(function(){
870
                    if(this.checked){
871
                        $("form[name='f[% suggestion.suggestiontype | html %]'] input[name=op]").attr("value","delete");
872
                    } else {
873
                        $("form[name='f[% suggestion.suggestiontype | html %]'] input[name=op]").attr("value","change");
874
                    }
871
                    }
875
                });
872
                });
876
873
877
            [% END %]
874
                $("a.cancel_note").click(function(e) {
878
                $("a[href*=back]").click(function(){
875
                    $(this).parent().siblings("select").show().find("option[value='']").attr("selected","selected");
879
                var sid = $(this).attr("href").replace(/#back/,"");
876
                    $(this).siblings("input[name='other_reason']").hide();
880
                    $("#reason"+sid).show().find("option[value='']").attr("selected","selected");
877
                    e.preventDefault();
881
                    $("#other_reason"+sid).hide();
882
                });
878
                });
883
                $("h4.local_collapse a").click(function(){
879
                $("h4.local_collapse a").click(function(){
884
                    $(this).parent().parent().find("ol").toggle();
880
                    $(this).parent().parent().find("ol").toggle();
Lines 925-951 Link Here
925
                    }
921
                    }
926
                });
922
                });
927
923
928
                $("form.update_suggestions").on("submit", function(e){
924
                $("button[type='submit']").on("click", function(e) {
929
                    var form = this;
925
                    var form = $(this).parents("form");
930
                    var action_delete_selected = $(this).find("input[value='delete']").is(":checked");
926
                    var action = $(this).val();
931
                    if ( action_delete_selected ) {
927
                    var selected_suggestions = $(form).find("input[name='suggestionid']:checked");
932
                        var suggestions_to_delete = $(this).find("input[name='edit_field']:checked");
928
                    if ( selected_suggestions.length == 0 ) {
933
                        if ( suggestions_to_delete.length == 0 ) {
929
                        alert(_("Please select at least one suggestion"));
934
                            alert(_("Please select at least one suggestion to delete"));
930
                        e.preventDefault();
935
                            e.preventDefault();
931
                        return false;
936
                            return false;
932
                    }
937
                        } else if ( suggestions_to_delete.length == 1 ) {
933
                    if ( action == "delete" ) {
934
                        if ( selected_suggestions.length == 1 ) {
938
                            if ( ! confirm(_("Are you sure you want to delete this suggestion?")) ) {
935
                            if ( ! confirm(_("Are you sure you want to delete this suggestion?")) ) {
939
                                e.preventDefault();
936
                                e.preventDefault();
940
                                return false;
937
                                return false;
941
                            }
938
                            }
942
                        } else if ( suggestions_to_delete.length > 1 ) {
939
                        } else if ( selected_suggestions.length > 1 ) {
943
                            if ( ! confirm(_("Are you sure you want to delete these suggestions?")) ) {
940
                            if ( ! confirm(_("Are you sure you want to delete these suggestions?")) ) {
944
                                e.preventDefault();
941
                                e.preventDefault();
945
                                return false;
942
                                return false;
946
                            }
943
                            }
947
                        }
944
                        }
948
                    }
945
                    }
946
947
                    $('<input />').attr('type', 'hidden')
948
                                  .attr('name', "op")
949
                                  .attr('value', action)
950
                                  .appendTo(form);
949
                    return true;
951
                    return true;
950
                });
952
                });
951
            });
953
            });
(-)a/suggestion/suggestion.pl (-6 / +12 lines)
Lines 83-89 my $input = CGI->new; Link Here
83
my $redirect  = $input->param('redirect');
83
my $redirect  = $input->param('redirect');
84
my $suggestedbyme   = (defined $input->param('suggestedbyme')? $input->param('suggestedbyme'):1);
84
my $suggestedbyme   = (defined $input->param('suggestedbyme')? $input->param('suggestedbyme'):1);
85
my $op              = $input->param('op')||'else';
85
my $op              = $input->param('op')||'else';
86
my @editsuggestions = $input->multi_param('edit_field');
86
my @editsuggestions = $input->multi_param('suggestionid');
87
my $suggestedby     = $input->param('suggestedby');
87
my $suggestedby     = $input->param('suggestedby');
88
my $returnsuggestedby = $input->param('returnsuggestedby');
88
my $returnsuggestedby = $input->param('returnsuggestedby');
89
my $returnsuggested = $input->param('returnsuggested');
89
my $returnsuggested = $input->param('returnsuggested');
Lines 105-111 $suggestion_only->{STATUS} = $suggestion_ref->{STATUS}; Link Here
105
105
106
delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field );
106
delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field );
107
foreach (keys %$suggestion_ref){
107
foreach (keys %$suggestion_ref){
108
    delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' || $op eq 'change'));
108
    delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' ));
109
}
109
}
110
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
110
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
111
        {
111
        {
Lines 210-216 elsif ($op=~/edit/) { Link Here
210
    Init($suggestion_ref);
210
    Init($suggestion_ref);
211
    $op ='save';
211
    $op ='save';
212
}  
212
}  
213
elsif ($op eq "change" ) {
213
elsif ($op eq "update_status" ) {
214
214
215
    my $suggestion;
215
    my $suggestion;
216
    # set accepted/rejected/managed informations if applicable
216
    # set accepted/rejected/managed informations if applicable
Lines 234-242 elsif ($op eq "change" ) { Link Here
234
        $suggestion->{managedby}   = C4::Context->userenv->{number};
234
        $suggestion->{managedby}   = C4::Context->userenv->{number};
235
        $suggestion->{STATUS}      = $STATUS;
235
        $suggestion->{STATUS}      = $STATUS;
236
    }
236
    }
237
    if ( my $reason = $input->param("reason$tabcode") ) {
237
    if ( my $reason = $input->param("reason") ) {
238
        if ( $reason eq "other" ) {
238
        if ( $reason eq "other" ) {
239
            $reason = $input->param("other_reason$tabcode");
239
            $reason = $input->param("other_reason");
240
        }
240
        }
241
        $suggestion->{reason} = $reason;
241
        $suggestion->{reason} = $reason;
242
    }
242
    }
Lines 266-271 elsif ($op eq "change" ) { Link Here
266
    }
266
    }
267
    $op = 'else';
267
    $op = 'else';
268
}
268
}
269
elsif ( $op eq 'update_itemtype' ) {
270
    my $new_itemtype = $input->param('suggestion_itemtype');
271
    foreach my $suggestionid (@editsuggestions) {
272
        next unless $suggestionid;
273
        &ModSuggestion({ suggestionid => $suggestionid, itemtype => $new_itemtype });
274
    }
275
}
269
elsif ( $op eq 'show' ) {
276
elsif ( $op eq 'show' ) {
270
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
277
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
271
    my $budget = GetBudget $$suggestion_ref{budgetid};
278
    my $budget = GetBudget $$suggestion_ref{budgetid};
272
- 

Return to bug 23594