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

(-)a/C4/Reports/Guided.pm (-1 / +10 lines)
Lines 33-38 use C4::Log; Link Here
33
33
34
use Koha::AuthorisedValues;
34
use Koha::AuthorisedValues;
35
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
use Koha::SharedContent;
36
37
37
BEGIN {
38
BEGIN {
38
    require Exporter;
39
    require Exporter;
Lines 715-721 sub get_saved_report { Link Here
715
    } else {
716
    } else {
716
        return;
717
        return;
717
    }
718
    }
718
    return $dbh->selectrow_hashref($query, undef, $report_arg);
719
    my $report = $dbh->selectrow_hashref($query, undef, $report_arg);
720
721
    if ( my $mana_id = $report->{mana_id} ) {
722
        my $mana_report = Koha::SharedContent::manaGetRequestWithId(
723
            'report', $mana_id, {usecomments => 1});
724
        $report->{comments} = $mana_report->{data}->{comments};
725
    }
726
727
    return $report;
719
}
728
}
720
729
721
=head2 create_compound($masterID,$subreportID)
730
=head2 create_compound($masterID,$subreportID)
(-)a/C4/Serials.pm (+6 lines)
Lines 300-305 sub GetSubscription { Link Here
300
    });
300
    });
301
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
301
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
302
302
303
    if ( my $mana_id = $subscription->{mana_id} ) {
304
        my $mana_subscription = Koha::SharedContent::manaGetRequestWithId(
305
            'subscription', $mana_id, {usecomments => 1});
306
        $subscription->{comments} = $mana_subscription->{data}->{comments};
307
    }
308
303
    return $subscription;
309
    return $subscription;
304
}
310
}
305
311
(-)a/Koha/SharedContent.pm (-3 / +9 lines)
Lines 78-86 sub manaIncrementRequest { Link Here
78
=cut
78
=cut
79
79
80
sub manaPostRequest {
80
sub manaPostRequest {
81
    my ($lang, $loggedinuser, $resourceid, $resourcetype) = @_;
81
    my ($lang, $loggedinuser, $resourceid, $resourcetype, $content) = @_;
82
82
83
    my $content = prepareSharedData($lang, $loggedinuser, $resourceid, $resourcetype);
83
    unless ( $content ) {
84
        $content = prepareSharedData($lang, $loggedinuser, $resourceid, $resourcetype);
85
    }
84
86
85
    my $result = manaRequest(buildRequest('post', $resourcetype, $content));
87
    my $result = manaRequest(buildRequest('post', $resourcetype, $content));
86
88
Lines 161-168 sub buildRequest { Link Here
161
163
162
    if ( $type eq 'getwithid' ) {
164
    if ( $type eq 'getwithid' ) {
163
        my $id = shift;
165
        my $id = shift;
166
        my $params = shift;
167
        $params = join '&',
168
            map { defined $params->{$_} ? $_ . "=" . $params->{$_} : () }
169
            keys %$params;
164
170
165
        my $url = "$MANA_IP/$resource/$id.json";
171
        my $url = "$MANA_IP/$resource/$id.json?$params";
166
        return HTTP::Request->new( GET => $url );
172
        return HTTP::Request->new( GET => $url );
167
    }
173
    }
168
174
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana.inc (+44 lines)
Line 0 Link Here
1
<script type="text/JavaScript">
2
//<![CDATA[
3
$(document).ready(function() {
4
    function mana_increment(mana_id, resource, fieldvalue, stepvalue = 1) {
5
        $.ajax( {
6
            type: "POST",
7
            url: "/cgi-bin/koha/svc/mana/increment",
8
            data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
9
            datatype: "json",
10
        })
11
    }
12
13
    function mana_comment( target_id, manamsg, resource_type ) {
14
        $.ajax( {
15
            type: "POST",
16
            url: "/cgi-bin/koha/svc/mana/share",
17
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
18
            datatype: "json",
19
        })
20
    }
21
22
    $(document).on('click', 'ul li.mana-comment', function() {
23
        id = $(this).attr('data-id');
24
        mana_increment(id, 'resource_comment', 'nb');
25
    });
26
27
    $(document).on('click', 'ul li.mana-other-comment', function() {
28
        $('#mana-comment-box').modal('show');
29
    });
30
31
    $(document).on('click', '#mana-send-comment', function() {
32
        var resource_type = $('#mana-resource').val();
33
        var resource_id = $('#mana-resource-id').val();
34
        var comment = $("#mana-comment").val();
35
        mana_comment(resource_id, comment, resource_type);
36
        $("#mana-comment-box").modal("hide");
37
    });
38
39
    $(document).on('click', '#mana-comment-close', function() {
40
        $("#mana-comment-box").modal("hide");
41
    });
42
});
43
//]]>
44
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc (-26 / +1 lines)
Lines 24-29 $(document).ready(function() { Link Here
24
});
24
});
25
//]]>
25
//]]>
26
</script>
26
</script>
27
[% INCLUDE 'mana.inc' %]
27
28
28
[% IF statuscode == "200" AND reports %]
29
[% IF statuscode == "200" AND reports %]
29
    <table id="mana_results_datatable" width=100%>
30
    <table id="mana_results_datatable" width=100%>
Lines 68-81 $(document).ready(function() { Link Here
68
                    [% UNLESS search_only %]
69
                    [% UNLESS search_only %]
69
                        <td>
70
                        <td>
70
                            <button class="mana-use" id="mana-use-[% report.id %]"><i class="fa fa-inbox"></i> Use</button>
71
                            <button class="mana-use" id="mana-use-[% report.id %]"><i class="fa fa-inbox"></i> Use</button>
71
                            <select class="mana-actions" id="mana-actions-[% report.id %]">
72
                                <option selected disabled>Report mistake</option>
73
                                [% FOREACH comment IN report.comments %]
74
                                    <option value="[% comment.id %]">[% comment.message %] ([% comment.nb %])</option>
75
                                [% END %]
76
                                    <option>other</option>
77
                            </select>
78
                            <button hidden class="actionreport2" hidden> Cancel</button>
79
                        </td>
72
                        </td>
80
                    [% END %]
73
                    [% END %]
81
                  </tr>
74
                  </tr>
Lines 86-106 $(document).ready(function() { Link Here
86
[% ELSE %]
79
[% ELSE %]
87
    <h4> [% msg %]  statuscode: [% statuscode %]</h4>
80
    <h4> [% msg %]  statuscode: [% statuscode %]</h4>
88
[% END %]
81
[% END %]
89
90
<div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
91
    <div class="modal-dialog modal-lg" style="width: 30%">
92
        <div class="modal-content" style="">
93
            <div class="modal-header">
94
                <button type="button" id="commentCloseButton" class="closebtn"  aria-hidden="true">×</button>
95
                <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
96
            </div>
97
            <div class="modal-body">
98
                <form>
99
                    <input hidden id="selected_id" value="">
100
                    <input type="text" id="manamsg">
101
                </form>
102
                <button id="CommentButton"> Comment </button>
103
            </div>
104
        </div>
105
    </div>
106
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc (-12 / +1 lines)
Lines 2-8 Link Here
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE AuthorisedValues %]
3
[% USE AuthorisedValues %]
4
[% USE Branches %]
4
[% USE Branches %]
5
5
[% INCLUDE 'mana.inc' %]
6
<script type="text/javascript">
6
<script type="text/javascript">
7
//<![CDATA[
7
//<![CDATA[
8
$(document).ready(function() {
8
$(document).ready(function() {
Lines 10-26 $(document).ready(function() { Link Here
10
        id = $(this).attr('id');
10
        id = $(this).attr('id');
11
        mana_use(id.substr(9));
11
        mana_use(id.substr(9));
12
    });
12
    });
13
14
    $(document).on('change', 'select.mana-actions', function() {
15
        report_id = $(this).attr('id').substr(13);
16
        if ($(this).val() == 'other') {
17
            $('input#selected_id').val(report_id);
18
            $('#comment_box').modal('show');
19
        } else {
20
            comment_id = $(this).val();
21
            mana_increment(comment_id, 'resource_comment', 'nb');
22
        }
23
    });
24
});
13
});
25
//]]>
14
//]]>
26
</script>
15
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc (-31 / +35 lines)
Lines 1-4 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
[% INCLUDE 'blocking_errors.inc' %]
2
[% INCLUDE 'mana.inc' %]
2
<div id="toolbar" class="btn-toolbar">
3
<div id="toolbar" class="btn-toolbar">
3
    [% IF ( CAN_user_reports_create_reports ) %]
4
    [% IF ( CAN_user_reports_create_reports ) %]
4
        <div class="btn-group">
5
        <div class="btn-group">
Lines 50-55 Link Here
50
            </div>
51
            </div>
51
        [% END %]
52
        [% END %]
52
53
54
        [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %]
55
            <div class="btn-group">
56
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
57
                <ul class="dropdown-menu">
58
                    [% FOREACH c IN mana_comments %]
59
                        <li class="mana-comment" data-id="[% c.id %]">
60
                            <a href="#">[% c.message %] ([% c.nb %])</a>
61
                        </li>
62
                    [% END %]
63
                    <li role="separator" class="divider"></li>
64
                    <li class="mana-other-comment"><a href="#">Other</a> </li>
65
                </ul>
66
            </div>
67
68
            <div id="mana-comment-box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
69
                <div class="modal-dialog modal-lg" style="width: 30%">
70
                    <div class="modal-content" style="">
71
                        <div class="modal-header">
72
                            <button type="button" id="mana-comment-close" class="closebtn"  aria-hidden="true">×</button>
73
                            <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
74
                        </div>
75
                        <div class="modal-body">
76
                            <input hidden id="mana-resource" value="report">
77
                            <input hidden id="mana-resource-id" value="[% mana_id %]">
78
                            <div>
79
                                <input type="text" maxlength="35" size="35" id="mana-comment">
80
                            </div>
81
                            <button id="mana-send-comment"> Comment </button>
82
                        </div>
83
                    </div>
84
                </div>
85
            </div>
86
        [% END %]
87
53
        [% IF ( execute ) %]
88
        [% IF ( execute ) %]
54
            [% BLOCK params %]
89
            [% BLOCK params %]
55
                [%- FOREACH param IN sql_params %]&amp;sql_params=[% param %][% END %]
90
                [%- FOREACH param IN sql_params %]&amp;sql_params=[% param %][% END %]
Lines 102-122 Link Here
102
        });
137
        });
103
    });
138
    });
104
139
105
    $('#search_form').on( "submit", function(event) {
106
        event.preventDefault();
107
        mana_search($(this).children("#mana_search_field").val());
108
    });
109
110
    function mana_increment(mana_id, resourcename, fieldvalue, stepvalue = 1){
111
        $.ajax( {
112
            type: "POST",
113
            url: "/cgi-bin/koha/svc/mana/increment",
114
            data: {id: mana_id, field: fieldvalue, resource: resourcename, step: stepvalue},
115
            datatype: "json",
116
        }).done( function() {
117
        }).fail( function(){ alert("") });
118
    }
119
120
    function mana_use( mana_id ){
140
    function mana_use( mana_id ){
121
        $.ajax( {
141
        $.ajax( {
122
            type:"POST",
142
            type:"POST",
Lines 164-176 Link Here
164
184
165
            $( "select[class='actionreport1']" ).show();
185
            $( "select[class='actionreport1']" ).show();
166
            $( "button[class='actionreport2']" ).hide();
186
            $( "button[class='actionreport2']" ).hide();
167
            $("#CommentButton").on("click", function(){
168
                var resource_type = "report";
169
                var target_id = $("#selected_id").val();
170
                var manamsg = $("#manamsg").val();
171
                mana_comment(target_id, manamsg, resource_type);
172
                $("#comment_box").modal("hide");
173
            });
174
187
175
            $(".showbutton").on("click", function(){
188
            $(".showbutton").on("click", function(){
176
                $(this).parent().hide();
189
                $(this).parent().hide();
Lines 200-212 Link Here
200
        }).fail( function( result ){
213
        }).fail( function( result ){
201
        });
214
        });
202
    }
215
    }
203
204
    function mana_comment( target_id, manamsg, resource_type ){
205
        $.ajax( {
206
            type: "POST",
207
            url: "/cgi-bin/koha/svc/mana/share",
208
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
209
            datatype: "json",
210
        })
211
    }
212
</script>
216
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc (+35 lines)
Lines 1-4 Link Here
1
[% INCLUDE 'blocking_errors.inc' %]
1
[% INCLUDE 'blocking_errors.inc' %]
2
[% INCLUDE 'mana.inc' %]
2
<script type="text/javascript">
3
<script type="text/javascript">
3
    //<![CDATA[
4
    //<![CDATA[
4
5
Lines 99-104 Link Here
99
                [% END %]
100
                [% END %]
100
            [% END %]
101
            [% END %]
101
        [% END %]
102
        [% END %]
103
104
        [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %]
105
            <div class="btn-group">
106
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
107
                <ul class="dropdown-menu">
108
                    [% FOREACH c IN mana_comments %]
109
                        <li class="mana-comment" data-id="[% c.id %]">
110
                            <a href="#">[% c.message %] ([% c.nb %])</a>
111
                        </li>
112
                    [% END %]
113
                    <li role="separator" class="divider"></li>
114
                    <li class="mana-other-comment"><a href="#">Other</a> </li>
115
                </ul>
116
            </div>
117
118
            <div id="mana-comment-box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
119
                <div class="modal-dialog modal-lg" style="width: 30%">
120
                    <div class="modal-content" style="">
121
                        <div class="modal-header">
122
                            <button type="button" id="mana-comment-close" class="closebtn"  aria-hidden="true">×</button>
123
                            <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
124
                        </div>
125
                        <div class="modal-body">
126
                            <input hidden id="mana-resource" value="subscription">
127
                            <input hidden id="mana-resource-id" value="[% mana_id %]">
128
                            <div>
129
                                <input type="text" maxlength="35" size="35" id="mana-comment">
130
                            </div>
131
                            <button id="mana-send-comment"> Comment </button>
132
                        </div>
133
                    </div>
134
                </div>
135
            </div>
136
        [% END %]
102
    </div>
137
    </div>
103
[% ELSIF CAN_user_serials_create_subscription %]
138
[% ELSIF CAN_user_serials_create_subscription %]
104
    <div id="toolbar" class="btn-toolbar">
139
    <div id="toolbar" class="btn-toolbar">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-20 lines)
Lines 141-166 canned reports and writing custom SQL reports.</p> Link Here
141
    </div>
141
    </div>
142
[% END %]
142
[% END %]
143
143
144
<div id="mana_search_result" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 100%; left:0%; margin-left: auto; display: none;">
145
    <div class="modal-dialog modal-lg">
146
        <div class="modal-content">
147
            <div class="modal-header">
148
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
149
                <h3 id="mana_search_result_label"> Mana Search</h3>
150
            </div>
151
            <div>
152
                <form id="search_form" style="margin-left: 5%">
153
                    Please enter a few key words:
154
                    <input type=text id=mana_search_field>
155
                    <input type=button class="mana_search_button" value="Search">
156
                </form>
157
                <div class="modal-body">
158
                </div>
159
            </div>
160
        </div>
161
    </div>
162
</div>
163
164
[% IF report_converted %]
144
[% IF report_converted %]
165
    <div class="dialog message">
145
    <div class="dialog message">
166
        The report "[% report_converted %]" has been converted.
146
        The report "[% report_converted %]" has been converted.
(-)a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js (-45 lines)
Lines 428-478 function mana_search() { Link Here
428
            $("#mana_search").html( result );
428
            $("#mana_search").html( result );
429
        }
429
        }
430
        $("#mana_search").show();
430
        $("#mana_search").show();
431
        $( "select[class='actionreport1']" ).show();
432
        $( "button[class='actionreport2']" ).hide();
433
434
        $("#CommentButton").on("click", function(){
435
            var resource_type = "subscription";
436
            var target_id = $("#selected_id").val();
437
            var manamsg = $("#manamsg").val();
438
            mana_comment(target_id, manamsg, resource_type);
439
            $("#comment_box").modal("hide");
440
        });
441
442
        $("#commentCloseButton").on("click", function(){
443
            $("#comment_box").modal("hide");
444
        });
445
446
        $(".actionreport1").on("click", function(){
447
            $("#selectedcomment").val($(this).val());
448
            $(this).parent("select").hide();
449
            $(this).parent("select").next().show();
450
        });
451
452
        $(".actionreport2").on("click", function(){
453
            $(this).hide();
454
            $(this).prev().show();
455
            mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
456
        });
457
458
    })
459
}
460
461
function mana_comment( target_id, manamsg, resource_type ){
462
    $.ajax( {
463
        type: "POST",
464
        url: "/cgi-bin/koha/svc/mana/share",
465
        data: {message: manamsg, resource: resource_type , resource_id: target_id},
466
        datatype: "json",
467
    })
468
}
469
470
function mana_increment(mana_id, resource, fieldvalue, stepvalue = 1){
471
    $.ajax( {
472
        type: "POST",
473
        url: "/cgi-bin/koha/svc/mana/increment",
474
        data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
475
        datatype: "json",
476
    })
431
    })
477
}
432
}
478
433
(-)a/reports/guided_reports.pl (+4 lines)
Lines 182-187 elsif ( $phase eq 'Show SQL'){ Link Here
182
	'sql'     => $report->{savedsql},
182
	'sql'     => $report->{savedsql},
183
	'showsql' => 1,
183
	'showsql' => 1,
184
        'mana_success' => scalar $input->param('mana_success'),
184
        'mana_success' => scalar $input->param('mana_success'),
185
        'mana_id' => $report->{mana_id},
186
        'mana_comments' => $report->{comments}
185
    );
187
    );
186
}
188
}
187
189
Lines 200-205 elsif ( $phase eq 'Edit SQL'){ Link Here
200
        'public' => $report->{public},
202
        'public' => $report->{public},
201
        'usecache' => $usecache,
203
        'usecache' => $usecache,
202
        'editsql'    => 1,
204
        'editsql'    => 1,
205
        'mana_id' => $report->{mana_id},
206
        'mana_comments' => $report->{comments}
203
    );
207
    );
204
}
208
}
205
209
(-)a/serials/subscription-detail.pl (+1 lines)
Lines 177-182 $template->param( Link Here
177
    (uc(C4::Context->preference("marcflavour"))) => 1,
177
    (uc(C4::Context->preference("marcflavour"))) => 1,
178
    show_acquisition_details => defined $tmpl_infos->{ordered_exists} || defined $tmpl_infos->{spent_exists} ? 1 : 0,
178
    show_acquisition_details => defined $tmpl_infos->{ordered_exists} || defined $tmpl_infos->{spent_exists} ? 1 : 0,
179
    basketno => $order->{basketno},
179
    basketno => $order->{basketno},
180
    mana_comments => $subs->{comments},
180
    %$tmpl_infos,
181
    %$tmpl_infos,
181
);
182
);
182
183
(-)a/svc/mana/share (-2 / +1 lines)
Lines 44-50 my $content; Link Here
44
$content->{resource_id} = $input->param("resource_id");
44
$content->{resource_id} = $input->param("resource_id");
45
$content->{resource_type} = $input->param("resource");
45
$content->{resource_type} = $input->param("resource");
46
$content->{message} = $input->param("message");
46
$content->{message} = $input->param("message");
47
Koha::SharedContent::manaPostRequest('resource_comment', $content);
47
Koha::SharedContent::manaPostRequest('', undef, undef, 'resource_comment', $content);
48
my $package = "Koha::".ucfirst($input->param('resource'));
48
my $package = "Koha::".ucfirst($input->param('resource'));
49
my $resource;
49
my $resource;
50
my $result;
50
my $result;
51
- 

Return to bug 17047