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 (-36 / +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 90-97 Link Here
90
    </div>
125
    </div>
91
[% END %]
126
[% END %]
92
127
93
94
95
<script type="text/javascript">
128
<script type="text/javascript">
96
var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
129
var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
97
$(document).ready(function(){
130
$(document).ready(function(){
Lines 108-128 $(document).ready(function(){ Link Here
108
        });
141
        });
109
    });
142
    });
110
143
111
    $('#search_form').on( "submit", function(event) {
112
        event.preventDefault();
113
        mana_search($(this).children("#mana_search_field").val());
114
    });
115
116
    function mana_increment(mana_id, resourcename, fieldvalue, stepvalue = 1){
117
        $.ajax( {
118
            type: "POST",
119
            url: "/cgi-bin/koha/svc/mana/increment",
120
            data: {id: mana_id, field: fieldvalue, resource: resourcename, step: stepvalue},
121
            datatype: "json",
122
        }).done( function() {
123
        }).fail( function(){ alert("") });
124
    }
125
126
    function mana_use( mana_id ){
144
    function mana_use( mana_id ){
127
        $.ajax( {
145
        $.ajax( {
128
            type:"POST",
146
            type:"POST",
Lines 170-182 $(document).ready(function(){ Link Here
170
188
171
            $( "select[class='actionreport1']" ).show();
189
            $( "select[class='actionreport1']" ).show();
172
            $( "button[class='actionreport2']" ).hide();
190
            $( "button[class='actionreport2']" ).hide();
173
            $("#CommentButton").on("click", function(){
174
                var resource_type = "report";
175
                var target_id = $("#selected_id").val();
176
                var manamsg = $("#manamsg").val();
177
                mana_comment(target_id, manamsg, resource_type);
178
                $("#comment_box").modal("hide");
179
            });
180
191
181
            $(".showbutton").on("click", function(){
192
            $(".showbutton").on("click", function(){
182
                $(this).parent().hide();
193
                $(this).parent().hide();
Lines 206-221 $(document).ready(function(){ Link Here
206
        }).fail( function( result ){
217
        }).fail( function( result ){
207
        });
218
        });
208
    }
219
    }
209
210
    function mana_comment( target_id, manamsg, resource_type ){
211
        $.ajax( {
212
            type: "POST",
213
            url: "/cgi-bin/koha/svc/mana/share",
214
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
215
            datatype: "json",
216
        })
217
    }
218
219
220
221
</script>
220
</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 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 375-400 canned reports and writing custom SQL reports.</p> Link Here
375
    </div>
375
    </div>
376
[% END %]
376
[% END %]
377
377
378
<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;">
379
    <div class="modal-dialog modal-lg">
380
        <div class="modal-content">
381
            <div class="modal-header">
382
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
383
                <h3 id="mana_search_result_label"> Mana Search</h3>
384
            </div>
385
            <div>
386
                <form id="search_form" style="margin-left: 5%">
387
                    Please enter a few key words:
388
                    <input type=text id=mana_search_field>
389
                    <input type=button class="mana_search_button" value="Search">
390
                </form>
391
                <div class="modal-body">
392
                </div>
393
            </div>
394
        </div>
395
    </div>
396
</div>
397
398
[% IF report_converted %]
378
[% IF report_converted %]
399
    <div class="dialog message">
379
    <div class="dialog message">
400
        The report "[% report_converted %]" has been converted.
380
        The report "[% report_converted %]" has been converted.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-45 lines)
Lines 441-491 function mana_search() { Link Here
441
            $("#mana_search").html( result );
441
            $("#mana_search").html( result );
442
        }
442
        }
443
        $("#mana_search").show();
443
        $("#mana_search").show();
444
        $( "select[class='actionreport1']" ).show();
445
        $( "button[class='actionreport2']" ).hide();
446
447
        $("#CommentButton").on("click", function(){
448
            var resource_type = "subscription";
449
            var target_id = $("#selected_id").val();
450
            var manamsg = $("#manamsg").val();
451
            mana_comment(target_id, manamsg, resource_type);
452
            $("#comment_box").modal("hide");
453
        });
454
455
        $("#commentCloseButton").on("click", function(){
456
            $("#comment_box").modal("hide");
457
        });
458
459
        $(".actionreport1").on("click", function(){
460
            $("#selectedcomment").val($(this).val());
461
            $(this).parent("select").hide();
462
            $(this).parent("select").next().show();
463
        });
464
465
        $(".actionreport2").on("click", function(){
466
            $(this).hide();
467
            $(this).prev().show();
468
            mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
469
        });
470
471
    })
472
}
473
474
function mana_comment( target_id, manamsg, resource_type ){
475
    $.ajax( {
476
        type: "POST",
477
        url: "/cgi-bin/koha/svc/mana/share",
478
        data: {message: manamsg, resource: resource_type , resource_id: target_id},
479
        datatype: "json",
480
    })
481
}
482
483
function mana_increment(mana_id, resource, fieldvalue, stepvalue = 1){
484
    $.ajax( {
485
        type: "POST",
486
        url: "/cgi-bin/koha/svc/mana/increment",
487
        data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
488
        datatype: "json",
489
    })
444
    })
490
}
445
}
491
446
(-)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