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

(-)a/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql (-1 / +1 lines)
Lines 1-2 Link Here
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('AutoShareWithMana','subscription','','defines datas automatically shared with mana','multiple');
2
('AutoShareWithMana','','','defines datas automatically shared with mana','multiple');
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc (-1 / +1 lines)
Lines 30-36 Link Here
30
                    [% END %]
30
                    [% END %]
31
                    <input hidden class="rowid" value="[% report.id %]">
31
                    <input hidden class="rowid" value="[% report.id %]">
32
                    <td>[% IF ( report.report_name ) %][% report.report_name %][% END %]</td>
32
                    <td>[% IF ( report.report_name ) %][% report.report_name %][% END %]</td>
33
                    <td title="[% report.savedsql %]"><div>
33
                    <td title="[% report.savedsql |html %]"><div>
34
                        [% IF report.notes.length > 200 %]
34
                        [% IF report.notes.length > 200 %]
35
                            [% report.notes.substr(0,200) %]<a class="showbutton">Show More</a></div><div hidden>
35
                            [% report.notes.substr(0,200) %]<a class="showbutton">Show More</a></div><div hidden>
36
                        [% END %]
36
                        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc (-1 / +147 lines)
Lines 5-10 Link Here
5
            <ul class="dropdown-menu">
5
            <ul class="dropdown-menu">
6
                <li id="newmenuc"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">New guided report</a> </li>
6
                <li id="newmenuc"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">New guided report</a> </li>
7
                <li id="newsql"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">New SQL report</a> </li>
7
                <li id="newsql"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">New SQL report</a> </li>
8
                [% IF Koha.Preference('Mana')==1 %]
9
                <li id="newsql"><a href="" data-toggle="modal" data-target="#mana_search_result">New SQL from Mana</a> </li>
10
                [% END %]
8
            </ul>
11
            </ul>
9
        </div>
12
        </div>
10
    [% END %]
13
    [% END %]
Lines 60-71 Link Here
60
    [% END %]
63
    [% END %]
61
</div>
64
</div>
62
65
66
67
[% IF Koha.Preference('Mana')==1 %]
68
    <div id="mana_search_result" class="modal fade container-fluid" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 100%; left:0%; margin-left: auto; display: none;">
69
        <div class="modal-dialog modal-lg">
70
            <div class="modal-content">
71
                <div class="modal-header">
72
                    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
73
                    <h3 id="mana_search_result_label"> Mana Search</h3>
74
                </div>
75
                <div>
76
                    <form id="search_form" style="margin-left: 5%">
77
                        Please enter a few key words:
78
                        <input type=text id=mana_search_field>
79
                        <input type=button class="mana_search_button" value="Search">
80
                    </form>
81
                    <div class="modal-body">
82
                    </div>
83
                </div>
84
            </div>
85
        </div>
86
    </div>
87
[% END %]
88
89
90
63
<script type="text/javascript">
91
<script type="text/javascript">
64
var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
92
var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
65
66
$(document).ready(function(){
93
$(document).ready(function(){
67
    $(".delete").on("click",function(){
94
    $(".delete").on("click",function(){
68
        return confirmDelete(MSG_CONFIRM_DELETE);
95
        return confirmDelete(MSG_CONFIRM_DELETE);
69
    });
96
    });
70
});
97
});
71
</script>
98
</script>
99
100
<script type="text/javascript">
101
    $(document).ready( function(){
102
        $(".mana_search_button").on("click",function(){
103
            mana_search($("#mana_search_field").val());
104
        });
105
    });
106
107
    $('#search_form').on( "submit", function(event) {
108
        event.preventDefault();
109
        mana_search($(this).children("#mana_search_field").val());
110
    });
111
112
    function mana_increment(mana_id, resourcename, fieldvalue, stepvalue = 1){
113
        $.ajax( {
114
            type: "POST",
115
            url: "/cgi-bin/koha/svc/mana/addvaluetofield",
116
            data: {id: mana_id, field: fieldvalue, resource: resourcename, step: stepvalue},
117
            datatype: "json",
118
        }).done( function() {
119
        }).fail( function(){ alert("") });
120
    }
121
122
    function mana_use( mana_id ){
123
        $.ajax( {
124
            type:"POST",
125
            url: "/cgi-bin/koha/svc/mana/use",
126
            data: {id:mana_id, resource: 'report', saveinbase: 1},
127
            dataType: "json",
128
        })
129
        .done( function (result){
130
            if ( result.errmsg ){
131
                alert( result.errmsg );
132
            }
133
            else{
134
                window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&amp;phase=Show%20SQL&mana_success=1");
135
            }
136
        })
137
        .fail( function ( foo, msg, longmsg, bla ){
138
        });
139
    }
140
141
    function mana_search( textquery ){
142
        $.ajax({
143
            type: "POST",
144
            url: "/cgi-bin/koha/svc/mana/search",
145
            data: {biblionumber: $("#biblionumber").val(), resource: 'report', id: textquery, usecomments: 1},
146
            dataType: "html",
147
        })
148
        .done( function( result ) {
149
            $("#mana_search_result .modal-body").html(result);
150
            $("#mana_search_result_label").text("Results from Mana Knowledge Base");
151
            $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
152
                "sPaginationType":"four_button",
153
                "autoWidth": false,
154
                "columnDefs": [
155
                    { "width": "35%", "targets": 1 }
156
                ],
157
                "aoColumnDefs": [
158
                    { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
159
                    { "sType": "title-string", "aTargets" : [ "title-string" ] },
160
                    { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
161
                ]
162
            }));
163
            if($("td.dataTables_empty").length == 0){
164
                 $("#mana_search").show();
165
            }
166
167
            $( "select[class='actionreport1']" ).show();
168
            $( "button[class='actionreport2']" ).hide();
169
            $("#CommentButton").on("click", function(){
170
                var resource_type = "report";
171
                var target_id = $("#selected_id").val();
172
                var manamsg = $("#manamsg").val();
173
                mana_comment(target_id, manamsg, resource_type);
174
                $("#comment_box").modal("hide");
175
            });
176
177
            $(".showbutton").on("click", function(){
178
                $(this).parent().hide();
179
                $(this).parent().next().show();
180
            });
181
182
            $("a[class='hidebutton']").on("click", function(){
183
                $(this).parent().hide();
184
                $(this).parent().prev().show();
185
            });
186
187
            $("#commentCloseButton").on("click", function(){
188
                $("#comment_box").modal("hide");
189
            });
190
191
            $(".actionreport1").on("click", function(){
192
                $("#selectedcomment").val($(this).val());
193
                $(this).parent("select").hide();
194
                $(this).parent("select").next().show();
195
            });
196
197
            $(".actionreport2").on("click", function(){
198
                $(this).hide();
199
                $(this).prev().show();
200
                mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
201
            });
202
        }).fail( function( result ){
203
        });
204
    }
205
206
    function mana_comment( target_id, manamsg, resource_type ){
207
        $.ajax( {
208
            type: "POST",
209
            url: "/cgi-bin/koha/svc/mana/share",
210
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
211
            datatype: "json",
212
        })
213
    }
214
215
216
217
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-112 / +12 lines)
Lines 81-90 $(".goback").on("click",function(e){ Link Here
81
    window.history.back();
81
    window.history.back();
82
});
82
});
83
83
84
$(".mana_search_button").on("click",function(){
85
    mana_search($(this).prev().val());
86
});
87
88
$(".ShareButton").on("click", function(){
84
$(".ShareButton").on("click", function(){
89
    if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
85
    if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
90
        $("#shared_infos").hide();
86
        $("#shared_infos").hide();
Lines 101-109 $(".ShareButton").on("click", function(){ Link Here
101
    }
97
    }
102
});
98
});
103
99
104
$('#search_form').submit(function () {
105
    return false;
106
});
107
100
108
$("#addColumn").on("click",function(){
101
$("#addColumn").on("click",function(){
109
    addColumn();
102
    addColumn();
Lines 262-365 $("#delColumn").on("click",function(){ Link Here
262
[% END %]
255
[% END %]
263
});
256
});
264
257
265
function mana_increment(mana_id, resourcename, fieldvalue, stepvalue = 1){
266
    $.ajax( {
267
        type: "POST",
268
        url: "/cgi-bin/koha/svc/mana/addvaluetofield",
269
        data: {id: mana_id, field: fieldvalue, resource: resourcename, step: stepvalue},
270
        datatype: "json",
271
    }).done( function() {
272
    }).fail( function(){ });
273
}
274
275
function mana_use( mana_id ){
276
    $.ajax( {
277
        type:"POST",
278
        url: "/cgi-bin/koha/svc/mana/use",
279
        data: {id:mana_id, resource: 'report', saveinbase: 1},
280
        dataType: "json",
281
    })
282
    .done( function (result){
283
        window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&amp;phase=Show%20SQL");
284
    })
285
    .fail( function ( foo, msg, longmsg){
286
    });
287
}
288
289
function mana_search( textquery ){
290
    $.ajax({
291
        type: "POST",
292
        url: "/cgi-bin/koha/svc/mana/search",
293
        data: {biblionumber: $("#biblionumber").val(), resource: 'report', id: textquery, usecomments: 1},
294
        dataType: "html",
295
    })
296
    .done( function( result ) {
297
        $("#mana_search_result .modal-body").html(result);
298
        $("#mana_search_result_label").text("Results from Mana Knowledge Base");
299
        $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
300
            "sPaginationType":"four_button",
301
            "autoWidth": false,
302
            "columnDefs": [
303
                { "width": "35%", "targets": 1 }
304
            ],
305
            "aoColumnDefs": [
306
                { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
307
                { "sType": "title-string", "aTargets" : [ "title-string" ] },
308
                { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
309
            ]
310
        }));
311
        if($("td.dataTables_empty").length == 0){
312
             $("#mana_search").show();
313
        }
314
315
        $( "select[class='actionreport1']" ).show();
316
        $( "button[class='actionreport2']" ).hide();
317
        $("#CommentButton").on("click", function(){
318
            var resource_type = "report";
319
            var target_id = $("#selected_id").val();
320
            var manamsg = $("#manamsg").val();
321
            mana_comment(target_id, manamsg, resource_type);
322
            $("#comment_box").modal("hide");
323
        });
324
325
        $(".showbutton").on("click", function(){
326
            $(this).parent().hide();
327
            $(this).parent().next().show();
328
        });
329
330
        $("a[class='hidebutton']").on("click", function(){
331
            $(this).parent().hide();
332
            $(this).parent().prev().show();
333
        });
334
335
        $("#commentCloseButton").on("click", function(){
336
            $("#comment_box").modal("hide");
337
        });
338
339
        $(".actionreport1").on("click", function(){
340
            $("#selectedcomment").val($(this).val());
341
            $(this).parent("select").hide();
342
            $(this).parent("select").next().show();
343
        });
344
345
        $(".actionreport2").on("click", function(){
346
            $(this).hide();
347
            $(this).prev().show();
348
            mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
349
        });
350
    }).fail( function( result ){
351
    });
352
}
353
354
function mana_comment( target_id, manamsg, resource_type ){
355
    $.ajax( {
356
        type: "POST",
357
        url: "/cgi-bin/koha/svc/mana/share",
358
        data: {message: manamsg, resource: resource_type , resource_id: target_id},
359
        datatype: "json",
360
    })
361
}
362
363
258
364
259
365
</script>
260
</script>
Lines 447-452 canned reports and writing custom SQL reports.</p> Link Here
447
    </div>
342
    </div>
448
</div>
343
</div>
449
344
345
[% IF report_converted %]
346
    <div class="dialog message">
347
        The report "[% report_converted %]" has been converted.
348
    </div>
349
[% END %]
350
450
351
451
[% IF ( saved1 ) %]
352
[% IF ( saved1 ) %]
452
[% IF ( savedreports ) %]<h1>Saved reports</h1>
353
[% IF ( savedreports ) %]<h1>Saved reports</h1>
Lines 472-485 canned reports and writing custom SQL reports.</p> Link Here
472
    </div>
373
    </div>
473
    [% END %]
374
    [% END %]
474
375
475
   [% IF (Koha.Preference('Mana') == 1) %]
476
    <div id="mana_search" class="dialog message">
477
        <p> You want more reports? Check the Mana Knowledge Base <p> <a style="cursor:pointer" data-toggle="modal" data-target="#mana_search_result">Quick Search</a></p>
478
    </div>
479
    [% END %]
480
481
</script>
376
</script>
482
<h1> [% savedreport.sql %]</h1>
377
483
<form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
378
<form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
484
<input type="hidden" name="phase" value="Delete Multiple" />
379
<input type="hidden" name="phase" value="Delete Multiple" />
485
        <table id="table_reports">
380
        <table id="table_reports">
Lines 1218-1223 Sub report:<select name="subreport"> Link Here
1218
[% END %]
1113
[% END %]
1219
1114
1220
[% IF ( showsql ) %]
1115
[% IF ( showsql ) %]
1116
    [% IF mana_success %]
1117
        <fieldset>
1118
            Shared Successfully, thanks for your contribution!
1119
        </fieldset>
1120
    [% END %]
1221
<fieldset class="rows">
1121
<fieldset class="rows">
1222
    <legend>[% reportname %]</legend>
1122
    <legend>[% reportname %]</legend>
1223
    <ol>
1123
    <ol>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-6 / +15 lines)
Lines 406-411 function show_page_2() { Link Here
406
}
406
}
407
407
408
function mana_search() {
408
function mana_search() {
409
    $("#mana_search").html("<p>Mana kb is being asked for your subscription..</p>");
410
    $("#mana_search").show();
411
409
    $.ajax({
412
    $.ajax({
410
        type: "POST",
413
        type: "POST",
411
        url: "/cgi-bin/koha/svc/mana/search",
414
        url: "/cgi-bin/koha/svc/mana/search",
Lines 414-419 function mana_search() { Link Here
414
    })
417
    })
415
    .done( function( result ) {
418
    .done( function( result ) {
416
        $("#mana_search_result .modal-body").html(result);
419
        $("#mana_search_result .modal-body").html(result);
420
debugger;
417
        $("#mana_search_result_label").text("Results from Mana Knowledge Base");
421
        $("#mana_search_result_label").text("Results from Mana Knowledge Base");
418
        $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
422
        $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
419
            "sPaginationType": "four_button",
423
            "sPaginationType": "four_button",
Lines 429-436 function mana_search() { Link Here
429
            ]
433
            ]
430
        }));
434
        }));
431
        if( $("#mana_results_datatable").length && $("td.dataTables_empty").length == 0){
435
        if( $("#mana_results_datatable").length && $("td.dataTables_empty").length == 0){
432
            $("#mana_search").show();
436
            $("#mana_search").html("<p>Subscription found on Mana Knowledge Base:</p><p> <a style='cursor:pointer' data-toggle='modal' data-target='#mana_search_result'>Quick fill</a></p>");
437
        }
438
        else if ( $("#mana_results_datatable").length ){
439
            $("#mana_search").html("<p>No subscription found on Mana Knowledge Base :(</p><p> Please feel free to share you pattern with all others librarians once you are done</p>");
433
        }
440
        }
441
        else{
442
            $("#mana_search").html( result );
443
        }
444
        $("#mana_search").show();
434
        $( "select[class='actionreport1']" ).show();
445
        $( "select[class='actionreport1']" ).show();
435
        $( "button[class='actionreport2']" ).hide();
446
        $( "button[class='actionreport2']" ).hide();
436
447
Lines 458-464 function mana_search() { Link Here
458
            mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
469
            mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
459
        });
470
        });
460
471
461
    }).fail(function(result){
472
    }).fail(function(result, msg, longmsg){
473
        console.log( msg );
474
        console.log( longmsg );
462
    });
475
    });
463
}
476
}
464
477
Lines 566-574 $(document).ready(function() { Link Here
566
579
567
580
568
    mana_search();
581
    mana_search();
569
    $("#myid").on("click", function(){
570
        debugger;
571
    })
572
    $("#displayexample").hide();
582
    $("#displayexample").hide();
573
    $("#mana_search_result").modal("hide");
583
    $("#mana_search_result").modal("hide");
574
    $("#aqbooksellerid").on('keypress', function(e) {
584
    $("#aqbooksellerid").on('keypress', function(e) {
Lines 914-920 $(document).ready(function() { Link Here
914
                [% END %]
924
                [% END %]
915
925
916
                        <div hidden id="mana_search" class="dialog message">
926
                        <div hidden id="mana_search" class="dialog message">
917
                            <p>Subscription found on Mana Knowledge Base:</p><p> <a style="cursor:pointer" data-toggle="modal" data-target="#mana_search_result">Quick fill</a></p>
918
                        </div>
927
                        </div>
919
                        <div id="subscription_form_planning">
928
                        <div id="subscription_form_planning">
920
                            <fieldset class="rows">
929
                            <fieldset class="rows">
(-)a/reports/guided_reports.pl (+1 lines)
Lines 153-158 elsif ( $phase eq 'Show SQL'){ Link Here
153
        'notes'      => $report->{notes},
153
        'notes'      => $report->{notes},
154
	'sql'     => $report->{savedsql},
154
	'sql'     => $report->{savedsql},
155
	'showsql' => 1,
155
	'showsql' => 1,
156
        'mana_success' => $input->param('mana_success'),
156
    );
157
    );
157
}
158
}
158
159
(-)a/svc/mana/use (-8 / +15 lines)
Lines 40-53 if ( $auth_status ne "ok" ) { Link Here
40
    exit 0;
40
    exit 0;
41
}
41
}
42
42
43
my $result = Koha::SharedContent::manaGetRequestWithId($input->param('resource'), $input->param('id') );
43
    my $package = "Koha::".ucfirst($input->param('resource'));
44
my $package = "Koha::".ucfirst($input->param('resource'));
44
    my $resource;
45
my $resource;
45
    my $result;
46
46
eval{
47
if ( $input->param( 'saveinbase' )) {
47
    $result = Koha::SharedContent::manaGetRequestWithId($input->param('resource'), $input->param('id') );
48
    $resource = { id => $package->new_from_mana($result->{data})->id };
48
};
49
if ( $@ or $result->{code} == 500 ){
50
    $resource->{errmsg} =  "Error: mana access got broken, please try again later\n\n ( error: $@ )";
49
}
51
}
50
else{
52
else{
51
    $resource = $result->{data};
53
    if ( $input->param( 'saveinbase' )) {
54
        $resource = { id => $package->new_from_mana($result->{data})->id };
55
    }
56
    else{
57
        $resource = $result->{data};
58
    }
52
}
59
}
60
53
print(to_json($resource));
61
print(to_json($resource));
54
- 

Return to bug 17047