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-3 Link Here
1
[% INCLUDE 'mana.inc' %]
1
<div id="toolbar" class="btn-toolbar">
2
<div id="toolbar" class="btn-toolbar">
2
    [% IF ( CAN_user_reports_create_reports ) %]
3
    [% IF ( CAN_user_reports_create_reports ) %]
3
        <div class="btn-group">
4
        <div class="btn-group">
Lines 49-54 Link Here
49
            </div>
50
            </div>
50
        [% END %]
51
        [% END %]
51
52
53
        [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %]
54
            <div class="btn-group">
55
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
56
                <ul class="dropdown-menu">
57
                    [% FOREACH c IN mana_comments %]
58
                        <li class="mana-comment" data-id="[% c.id %]">
59
                            <a href="#">[% c.message %] ([% c.nb %])</a>
60
                        </li>
61
                    [% END %]
62
                    <li role="separator" class="divider"></li>
63
                    <li class="mana-other-comment"><a href="#">Other</a> </li>
64
                </ul>
65
            </div>
66
67
            <div id="mana-comment-box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
68
                <div class="modal-dialog modal-lg" style="width: 30%">
69
                    <div class="modal-content" style="">
70
                        <div class="modal-header">
71
                            <button type="button" id="mana-comment-close" class="closebtn"  aria-hidden="true">×</button>
72
                            <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
73
                        </div>
74
                        <div class="modal-body">
75
                            <input hidden id="mana-resource" value="report">
76
                            <input hidden id="mana-resource-id" value="[% mana_id %]">
77
                            <div>
78
                                <input type="text" maxlength="35" size="35" id="mana-comment">
79
                            </div>
80
                            <button id="mana-send-comment"> Comment </button>
81
                        </div>
82
                    </div>
83
                </div>
84
            </div>
85
        [% END %]
86
52
        [% IF ( execute ) %]
87
        [% IF ( execute ) %]
53
            <div class="btn-group">
88
            <div class="btn-group">
54
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" id="format"><i class="fa fa-upload"></i> Download <span class="caret"></span></button>
89
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" id="format"><i class="fa fa-upload"></i> Download <span class="caret"></span></button>
Lines 96-116 Link Here
96
        });
131
        });
97
    });
132
    });
98
133
99
    $('#search_form').on( "submit", function(event) {
100
        event.preventDefault();
101
        mana_search($(this).children("#mana_search_field").val());
102
    });
103
104
    function mana_increment(mana_id, resourcename, fieldvalue, stepvalue = 1){
105
        $.ajax( {
106
            type: "POST",
107
            url: "/cgi-bin/koha/svc/mana/increment",
108
            data: {id: mana_id, field: fieldvalue, resource: resourcename, step: stepvalue},
109
            datatype: "json",
110
        }).done( function() {
111
        }).fail( function(){ alert("") });
112
    }
113
114
    function mana_use( mana_id ){
134
    function mana_use( mana_id ){
115
        $.ajax( {
135
        $.ajax( {
116
            type:"POST",
136
            type:"POST",
Lines 158-170 Link Here
158
178
159
            $( "select[class='actionreport1']" ).show();
179
            $( "select[class='actionreport1']" ).show();
160
            $( "button[class='actionreport2']" ).hide();
180
            $( "button[class='actionreport2']" ).hide();
161
            $("#CommentButton").on("click", function(){
162
                var resource_type = "report";
163
                var target_id = $("#selected_id").val();
164
                var manamsg = $("#manamsg").val();
165
                mana_comment(target_id, manamsg, resource_type);
166
                $("#comment_box").modal("hide");
167
            });
168
181
169
            $(".showbutton").on("click", function(){
182
            $(".showbutton").on("click", function(){
170
                $(this).parent().hide();
183
                $(this).parent().hide();
Lines 194-206 Link Here
194
        }).fail( function( result ){
207
        }).fail( function( result ){
195
        });
208
        });
196
    }
209
    }
197
198
    function mana_comment( target_id, manamsg, resource_type ){
199
        $.ajax( {
200
            type: "POST",
201
            url: "/cgi-bin/koha/svc/mana/share",
202
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
203
            datatype: "json",
204
        })
205
    }
206
</script>
210
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc (+35 lines)
Lines 1-3 Link Here
1
[% INCLUDE 'mana.inc' %]
1
<script type="text/javascript">
2
<script type="text/javascript">
2
    //<![CDATA[
3
    //<![CDATA[
3
4
Lines 98-103 Link Here
98
                [% END %]
99
                [% END %]
99
            [% END %]
100
            [% END %]
100
        [% END %]
101
        [% END %]
102
103
        [% IF ( mana_id && Koha.Preference('Mana') == 1 ) %]
104
            <div class="btn-group">
105
                <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
106
                <ul class="dropdown-menu">
107
                    [% FOREACH c IN mana_comments %]
108
                        <li class="mana-comment" data-id="[% c.id %]">
109
                            <a href="#">[% c.message %] ([% c.nb %])</a>
110
                        </li>
111
                    [% END %]
112
                    <li role="separator" class="divider"></li>
113
                    <li class="mana-other-comment"><a href="#">Other</a> </li>
114
                </ul>
115
            </div>
116
117
            <div id="mana-comment-box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
118
                <div class="modal-dialog modal-lg" style="width: 30%">
119
                    <div class="modal-content" style="">
120
                        <div class="modal-header">
121
                            <button type="button" id="mana-comment-close" class="closebtn"  aria-hidden="true">×</button>
122
                            <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
123
                        </div>
124
                        <div class="modal-body">
125
                            <input hidden id="mana-resource" value="subscription">
126
                            <input hidden id="mana-resource-id" value="[% mana_id %]">
127
                            <div>
128
                                <input type="text" maxlength="35" size="35" id="mana-comment">
129
                            </div>
130
                            <button id="mana-send-comment"> Comment </button>
131
                        </div>
132
                    </div>
133
                </div>
134
            </div>
135
        [% END %]
101
    </div>
136
    </div>
102
[% ELSIF CAN_user_serials_create_subscription %]
137
[% ELSIF CAN_user_serials_create_subscription %]
103
    <div id="toolbar" class="btn-toolbar">
138
    <div id="toolbar" class="btn-toolbar">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-20 lines)
Lines 130-155 canned reports and writing custom SQL reports.</p> Link Here
130
    </div>
130
    </div>
131
[% END %]
131
[% END %]
132
132
133
<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;">
134
    <div class="modal-dialog modal-lg">
135
        <div class="modal-content">
136
            <div class="modal-header">
137
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
138
                <h3 id="mana_search_result_label"> Mana Search</h3>
139
            </div>
140
            <div>
141
                <form id="search_form" style="margin-left: 5%">
142
                    Please enter a few key words:
143
                    <input type=text id=mana_search_field>
144
                    <input type=button class="mana_search_button" value="Search">
145
                </form>
146
                <div class="modal-body">
147
                </div>
148
            </div>
149
        </div>
150
    </div>
151
</div>
152
153
[% IF report_converted %]
133
[% IF report_converted %]
154
    <div class="dialog message">
134
    <div class="dialog message">
155
        The report "[% report_converted %]" has been converted.
135
        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