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

(-)a/C4/Reports/Guided.pm (-1 lines)
Lines 849-855 sub get_sql { Link Here
849
sub get_results {
849
sub get_results {
850
    my ( $report_id ) = @_;
850
    my ( $report_id ) = @_;
851
    my $dbh = C4::Context->dbh;
851
    my $dbh = C4::Context->dbh;
852
    warn $report_id;
853
    return $dbh->selectall_arrayref(q|
852
    return $dbh->selectall_arrayref(q|
854
        SELECT id, report, date_run
853
        SELECT id, report, date_run
855
        FROM saved_reports
854
        FROM saved_reports
(-)a/Koha/Report.pm (+81 lines)
Line 0 Link Here
1
package Koha::Report;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
use JSON;
26
use Koha::Reports;
27
28
use base qw(Koha::Object);
29
30
=head1 NAME
31
32
Koha::Report - Koha Report Object Class
33
34
=head1 Ap
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub get_search_info {
45
    my $self=shift;
46
    my $sub_mana_info = { 'query' => shift };
47
    return $sub_mana_info;
48
}
49
50
sub get_sharable_info{
51
    my $self=shift;
52
    my $shared_report_id=shift;
53
    my $report = Koha::Reports->find($shared_report_id);
54
    my $sub_mana_info = {
55
        'savedsql' => $report->savedsql,
56
        'report_name' => $report->report_name,
57
        'notes' => $report->notes,
58
        'type' => $report->type,
59
    };
60
    return $sub_mana_info;
61
}
62
63
sub new_from_mana{
64
    my $self = shift;
65
    my $data = shift;
66
    delete $data->{exportemail};
67
    delete $data->{kohaversion};
68
    delete $data->{creationdate};
69
    delete $data->{lastimport};
70
    $data->{mana_id} = $data->{id};
71
    delete $data->{id};
72
    delete $data->{nbofusers};
73
    delete $data->{language};
74
    Koha::Report->new($data)->store;
75
}
76
77
sub _type {
78
    return 'SavedSql';
79
}
80
81
1;
(-)a/Koha/Reports.pm (+58 lines)
Line 0 Link Here
1
package Koha::Reports;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use Koha::Report;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::Serial - Koha Serial Object class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub _type {
45
    return 'SavedSql';
46
}
47
48
sub object_class {
49
    return 'Koha::Report';
50
}
51
52
=head1 AUTHOR
53
54
Kyle M Hall <kyle@bywatersolutions.com>
55
56
=cut
57
58
1;
(-)a/Koha/Schema/Result/SavedSql.pm (-2 / +9 lines)
Lines 105-110 __PACKAGE__->table("saved_sql"); Link Here
105
  is_nullable: 1
105
  is_nullable: 1
106
  size: 80
106
  size: 80
107
107
108
=head2 mana_id
109
110
  data_type: 'integer'
111
  is_nullable: 1
112
108
=cut
113
=cut
109
114
110
__PACKAGE__->add_columns(
115
__PACKAGE__->add_columns(
Lines 148-153 __PACKAGE__->add_columns( Link Here
148
  { data_type => "varchar", is_nullable => 1, size => 80 },
153
  { data_type => "varchar", is_nullable => 1, size => 80 },
149
  "report_subgroup",
154
  "report_subgroup",
150
  { data_type => "varchar", is_nullable => 1, size => 80 },
155
  { data_type => "varchar", is_nullable => 1, size => 80 },
156
  "mana_id",
157
  { data_type => "integer", is_nullable => 1 },
151
);
158
);
152
159
153
=head1 PRIMARY KEY
160
=head1 PRIMARY KEY
Lines 163-170 __PACKAGE__->add_columns( Link Here
163
__PACKAGE__->set_primary_key("id");
170
__PACKAGE__->set_primary_key("id");
164
171
165
172
166
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-10-24 09:58:16
173
# Created by DBIx::Class::Schema::Loader v0.07045 @ 2017-03-17 11:12:03
167
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eGWRRzpe1+EBialePAIhMQ
174
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BC+FEuFzk/wdhJTIVQdQHw
168
175
169
176
170
# You can replace this text with custom content, and it will be preserved on regeneration
177
# You can replace this text with custom content, and it will be preserved on regeneration
(-)a/Koha/SharedContent.pm (-5 / +61 lines)
Lines 22-28 use JSON; Link Here
22
use HTTP::Request;
22
use HTTP::Request;
23
use LWP::UserAgent;
23
use LWP::UserAgent;
24
24
25
our $MANA_IP = "http://10.25.159.107:5000";
25
use Koha::Serials;
26
use Koha::Reports;
27
28
our $MANA_IP = C4::Context->config('mana_config');
26
29
27
sub manaRequest {
30
sub manaRequest {
28
    my $mana_request = shift;
31
    my $mana_request = shift;
Lines 40-51 sub manaRequest { Link Here
40
    return $result if ( $response->code =~ /^2..$/ );
43
    return $result if ( $response->code =~ /^2..$/ );
41
}
44
}
42
45
43
sub manaNewUserPatchRequest {
46
sub manaIncrementRequest {
44
    my $resource = shift;
47
    my $resource = shift;
45
    my $id       = shift;
48
    my $id       = shift;
46
49
    my $field    = shift;
47
    my $url = "$MANA_IP/$resource/$id.json/newUser";
50
    my $step     = shift;
48
    my $request = HTTP::Request->new( PATCH => $url );
51
    my $param;
52
    $param->{step} = $step || 1;
53
    $param->{id} = $id;
54
    $param->{resource} = $resource;
55
    $param = join '&',
56
       map { defined $param->{$_} ? $_ . "=" . $param->{$_} : () }
57
           keys %$param;
58
    my $url = "$MANA_IP/$resource/$id.json/increment/$field?$param";
59
    my $request = HTTP::Request->new( POST => $url );
49
60
50
    return manaRequest($request);
61
    return manaRequest($request);
51
}
62
}
Lines 64-69 sub manaPostRequest { Link Here
64
    return manaRequest($request);
75
    return manaRequest($request);
65
}
76
}
66
77
78
sub manaShareInfos{
79
    my ($query, $loggedinuser, $ressourceid, $ressourcetype) = @_;
80
    my $mana_language;
81
    if ( $query->param('mana_language') ) {
82
        $mana_language = $query->param('mana_language');
83
    }
84
    else {
85
        my $result = $mana_language = C4::Context->preference('language');
86
    }
87
88
    my $mana_email;
89
    if ( $loggedinuser ne 0 ) {
90
        my $borrower = Koha::Patrons->find($loggedinuser);
91
        $mana_email = $borrower->email
92
          if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
93
        $mana_email = $borrower->emailpro
94
          if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
95
        $mana_email =
96
          Koha::Libraries->find( C4::Context->userenv->{'branch'} )->branchemail
97
          if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
98
    }
99
    $mana_email = C4::Context->preference('KohaAdminEmailAddress')
100
      if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
101
    my %versions = C4::Context::get_versions();
102
103
    my $mana_info = {
104
        language    => $mana_language,
105
        kohaversion => $versions{'kohaVersion'},
106
        exportemail => $mana_email
107
    };
108
    my ($ressource, $ressource_mana_info);
109
    my $packages = "Koha::".ucfirst($ressourcetype)."s";
110
    my $package = "Koha::".ucfirst($ressourcetype);
111
    $ressource_mana_info = $package->get_sharable_info($ressourceid);
112
    $ressource_mana_info = { %$ressource_mana_info, %$mana_info };
113
    $ressource = $packages->find($ressourceid);
114
115
    my $result = Koha::SharedContent::manaPostRequest( $ressourcetype,
116
        $ressource_mana_info );
117
    if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) {
118
        $ressource->set( { mana_id => $result->{id} } )->store;
119
    }
120
    return $result;
121
}
122
67
sub manaGetRequestWithId {
123
sub manaGetRequestWithId {
68
    my $resource = shift;
124
    my $resource = shift;
69
    my $id       = shift;
125
    my $id       = shift;
(-)a/Koha/Subscription.pm (+2 lines)
Lines 46-51 Koha::Subscription - Koha Subscription Object class Link Here
46
=cut
46
=cut
47
47
48
sub get_search_info {
48
sub get_search_info {
49
    my $self=shift;
49
    my $searched_sub_id = shift;
50
    my $searched_sub_id = shift;
50
    my $biblio = Koha::Biblios->find( { 'biblionumber' => $searched_sub_id } );
51
    my $biblio = Koha::Biblios->find( { 'biblionumber' => $searched_sub_id } );
51
    my $biblioitem =
52
    my $biblioitem =
Lines 61-66 sub get_search_info { Link Here
61
}
62
}
62
63
63
sub get_sharable_info {
64
sub get_sharable_info {
65
    my $self = shift;
64
    my $shared_sub_id = shift;
66
    my $shared_sub_id = shift;
65
    my $subscription  = Koha::Subscriptions->find($shared_sub_id);
67
    my $subscription  = Koha::Subscriptions->find($shared_sub_id);
66
    my $biblio        = Koha::Biblios->find( $subscription->biblionumber );
68
    my $biblio        = Koha::Biblios->find( $subscription->biblionumber );
(-)a/etc/koha-conf.xml (+4 lines)
Lines 145-150 __PAZPAR2_TOGGLE_XML_POST__ Link Here
145
 <!-- Path to the config file for SMS::Send -->
145
 <!-- Path to the config file for SMS::Send -->
146
 <sms_send_config>__KOHA_CONF_DIR__/sms_send/</sms_send_config>
146
 <sms_send_config>__KOHA_CONF_DIR__/sms_send/</sms_send_config>
147
147
148
 <!-- URL of the mana KB server -->
149
 <!-- alternative value http://mana-test.koha-community.org to query the test server -->
150
 <mana_config>http://mana-kb.koha-community.org</mana_config>
151
148
 <!-- Configuration for Plack -->
152
 <!-- Configuration for Plack -->
149
 <plack_max_requests>50</plack_max_requests>
153
 <plack_max_requests>50</plack_max_requests>
150
 <plack_workers>2</plack_workers>
154
 <plack_workers>2</plack_workers>
(-)a/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql (+1 lines)
Line 1 Link Here
1
ALTER TABLE subscription ADD mana_id int(11);
1
ALTER TABLE subscription ADD mana_id int(11);
2
ALTER TABLE saved_sql ADD mana_id int(11);
(-)a/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql (-1 / +1 lines)
Line 1 Link Here
1
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('Mana', '1', 'request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.', NULL, 'YesNo');
1
INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('Mana','2', 0|1|2,'request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','Choice');
(-)a/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql (+2 lines)
Line 0 Link Here
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('AutoShareWithMana','subscription','','defines datas automatically shared with mana','multiple');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 58-63 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
58
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
58
('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'),
59
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
59
('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'),
60
('AutoEmailPrimaryAddress','OFF','email|emailpro|B_email|cardnumber|OFF','Defines the default email address where \'Account Details\' emails are sent.','Choice'),
60
('AutoEmailPrimaryAddress','OFF','email|emailpro|B_email|cardnumber|OFF','Defines the default email address where \'Account Details\' emails are sent.','Choice'),
61
('AutoShareWithMana','subscription','','defines datas automatically shared with mana','multiple'),
61
('AutoLocation','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff client from unauthorized IP addresses','YesNo'),
62
('AutoLocation','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff client from unauthorized IP addresses','YesNo'),
62
('AutomaticItemReturn','1',NULL,'If ON, Koha will automatically set up a transfer of this item to its homebranch','YesNo'),
63
('AutomaticItemReturn','1',NULL,'If ON, Koha will automatically set up a transfer of this item to its homebranch','YesNo'),
63
('autoMemberNum','1','','If ON, patron number is auto-calculated','YesNo'),
64
('autoMemberNum','1','','If ON, patron number is auto-calculated','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css (+6 lines)
Lines 287-292 table+table { Link Here
287
.highlighted-row,
287
.highlighted-row,
288
.highlighted-row td { background-color: #FFD000 !important }
288
.highlighted-row td { background-color: #FFD000 !important }
289
289
290
.warned-row,
291
.warned-row td { background-color: #FF9000 !important }
292
293
.high-warned-row,
294
.high-warned-row td { background-color: #FF0000 !important }
295
290
tbody tr:nth-child(odd) td {
296
tbody tr:nth-child(odd) td {
291
	background-color : #F3F3F3;
297
	background-color : #F3F3F3;
292
    border : 1px solid #BCBCBC;
298
    border : 1px solid #BCBCBC;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc (-46 lines)
Lines 1-46 Link Here
1
[% USE KohaDates %]
2
<table id="mana_results_datatable">
3
    <thead>
4
        <tr>
5
            <th>ISSN</th>
6
            <th class="anti-the">Title</th>
7
            <th>Frequency</th>
8
            <th>Numbering pattern</th>
9
            <th class="NoSort">Number of users</th>
10
            <th class="title-string">Last Import</th>
11
            [% UNLESS search_only %]
12
              <th class="NoSort">Actions</th>
13
            [% END %]
14
        </tr>
15
    </thead>
16
    <tfoot>
17
        <tr>
18
            <td><input type="text" class="dt-filter" data-column_num="0" placeholder="Search ISSN" /></td>
19
            <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search title" /></td>
20
            <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search frequency" /></td>
21
            <td><input type="text" class="dt-filter" data-column_num="3" placeholder="Search numbering pattern" /></td>
22
            <td></td>
23
            <td><input type="text" class="dt-filter" data-column_num="5" placeholder="Search last import" /></td>
24
            [% UNLESS search_only %]
25
              <td></td>
26
            [% END %]
27
        </tr>
28
    </tfoot>
29
    <tbody>
30
        [% FOREACH subscription IN subscriptions %]
31
            [% UNLESS subscription.cannotdisplay %]
32
                <tr id="row[% subscription.subscriptionid %]">
33
                    <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td>
34
                    <td>[% subscription.title %]</a></td>
35
                    <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td>
36
                    <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td>
37
                    <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td>
38
                    <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td>
39
                    [% UNLESS search_only %]
40
                      <td><a style="cursor:pointer" onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</a></td>
41
                    [% END %]
42
                </tr>
43
            [% END %]
44
        [% END %]
45
    </tbody>
46
</table>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc (+83 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE Koha %]
3
[% USE AuthorisedValues %]
4
[% USE Branches %]
5
6
<table id="mana_results_datatable" width=100%>
7
    <thead>
8
        <tr>
9
            <th>Report Name</th>
10
            <th class="anti-the" width=35%>Notes</th>
11
            <th>Type</th>
12
            <th title="number of libraries using this pattern"># of users</th>
13
            <th class="title-string" title="last time a library used this pattern">Last import</th>
14
            <th> Comments </th>
15
            [% UNLESS search_only %]
16
              <th class="NoSort">Actions</th>
17
            [% END %]
18
        </tr>
19
    </thead>
20
    <tbody>
21
        [% FOREACH report IN reports %]
22
            [% UNLESS report.cannotdisplay %]
23
                <tr id="row[% report.id %]"
24
                     [% IF report.nbofcomment > highWarned  %]
25
                        class = "high-warned-row"
26
                     [% ELSIF report.nbofcomment > warned  %]
27
                        class = "warned-row"
28
                     [% ELSIF report.nbofcomment > lowWarned  %]
29
                        class = "highlighted-row"
30
                     [% END %]
31
                >
32
                    <input hidden class="rowid" value="[% report.id %]">
33
                    <td>[% IF ( report.report_name ) %][% report.report_name %][% END %]</td>
34
                    <td title="[% report.savedsql %]"><div>
35
                        [% IF report.notes.length > 200 %]
36
                            [% report.notes.substr(0,200) %]<a class="showbutton">Show More</a></div><div hidden>
37
                        [% END %]
38
                            [% report.notes %]
39
                        [% IF report.notes.length > 200 %]
40
                            <a class="hidebutton">Show Less</a></div> </td>
41
                        [% END %]
42
                    <td> [% report.type %] </td>
43
                    <td>[% IF ( report.nbofusers ) %][% report.nbofusers %][% END %]</td>
44
                    <td><span title="[% report.lastimport %]">[% report.lastimport | $KohaDates %]</span></td>
45
		    <td>[% FOREACH comment IN report.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
46
47
                    [% UNLESS search_only %]
48
                      <td>
49
                          <button onclick="mana_use([% report.id %])"> <i class="fa fa-inbox"></i> Use</button>
50
                          <input hidden type="text" id="selectedcomment">
51
                          <select>
52
                              <option selected disabled>Report mistake</option>
53
                              [% FOREACH comment IN report.comments %]
54
                                  <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %])
55
                              [% END %]
56
                                  <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other
57
                          </select>
58
                          <button hidden class="actionreport2" hidden> Cancel</button>
59
                      </td>
60
                    [% END %]
61
                </tr>
62
            [% END %]
63
        [% END %]
64
    </tbody>
65
</table>
66
67
<div id="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="commentCloseButton" 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
                <form>
76
                    <input hidden id="selected_id" value="">
77
                    <input type="text" id="manamsg">
78
                </form>
79
                <button id="CommentButton"> Comment </button>
80
            </div>
81
        </div>
82
    </div>
83
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc (+82 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE Koha %]
3
[% USE AuthorisedValues %]
4
[% USE Branches %]
5
6
7
8
<table id="mana_results_datatable" width=100%>
9
    <thead>
10
        <tr>
11
            <th>ISSN</th>
12
            <th class="anti-the" width=50%>Title</th>
13
            <th> Published by </th>
14
            <th>Frequency</th>
15
            <th>Numbering pattern</th>
16
            <th title="number of libraries using this pattern"># of users</th>
17
            <th class="title-string" title="last time a library used this pattern">Last import</th>
18
            <th> Comments </th>
19
            [% UNLESS search_only %]
20
              <th class="NoSort">Actions</th>
21
            [% END %]
22
        </tr>
23
    </thead>
24
    <tbody>
25
        [% FOREACH subscription IN subscriptions %]
26
            [% UNLESS subscription.cannotdisplay %]
27
                <tr id="row[% subscription.subscriptionid %]"
28
                     [% IF subscription.nbofcomment > highWarned  %]
29
                        class = "high-warned-row" title="this resource has been reported more than [% highWarned %] times, take care!"
30
                     [% ELSIF subscription.nbofcomment > warned  %]
31
                        class = "warned-row" title="this resource has been reported more than [% warned %] times, take care!"
32
                     [% ELSIF subscription.nbofcomment > lowWarned  %]
33
                        class = "highlighted-row" title="this resource has been reported more than [% lowWarned %] times, take care!"
34
                     [% END %]
35
                >
36
                <input hidden class="rowid" value="[% subscription.id %]">
37
                    <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td>
38
                    <td>[% subscription.title %]</a></td>
39
                    <td>[% IF ( subscription.publishercode ) %][% subscription.publishercode %][% END %]</td>
40
                    <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td>
41
                    <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td>
42
                    <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td>
43
                    <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td>
44
		    <td>[% FOREACH comment IN subscription.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
45
46
                    [% UNLESS search_only %]
47
                      <td>
48
                          <button onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</button>
49
                          <input hidden type="text" id="selectedcomment">
50
                          <select>
51
                              <option selected disabled>Report mistake</option>
52
                              [% FOREACH comment IN subscription.comments %]
53
                                  <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %])
54
                              [% END %]
55
                                  <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other
56
                          </select>
57
                          <button hidden class="actionreport2" hidden> Cancel</button>
58
                      </td>
59
                    [% END %]
60
                </tr>
61
            [% END %]
62
        [% END %]
63
    </tbody>
64
</table>
65
66
<div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
67
    <div class="modal-dialog modal-lg" style="width: 30%">
68
        <div class="modal-content" style="">
69
            <div class="modal-header">
70
                <button type="button" id="commentCloseButton" class="closebtn" aria-hidden="true">×</button>
71
                <h3 id="mana_submit_comment"> Please enter a new commment (max 35 caracters)</h3>
72
            </div>
73
            <div class="modal-body">
74
                <form>
75
                    <input hidden id="selected_id" value="">
76
                    <input type="text" id="manamsg"> Comment:
77
                </form>
78
                <button id="CommentButton"> Comment </button>
79
            </div>
80
        </div>
81
    </div>
82
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc (-9 / +7 lines)
Lines 46-56 Link Here
46
            [% ELSE %]
46
            [% ELSE %]
47
                <div class="btn-group"><a id="newsubscription" class="btn btn-default btn-sm" href="/cgi-bin/koha/serials/subscription-add.pl"><i class="fa fa-plus"></i> New subscription</a></div>
47
                <div class="btn-group"><a id="newsubscription" class="btn btn-default btn-sm" href="/cgi-bin/koha/serials/subscription-add.pl"><i class="fa fa-plus"></i> New subscription</a></div>
48
            [% END %]
48
            [% END %]
49
            [% IF Koha.Preference('Mana') %]
49
            [% IF Koha.Preference('Mana') and Koha.Preference('AutoShareWithMana').grep('subscription').size == 0 %]
50
                [% IF one_language_enabled==0 or mana_id %]
50
                [% IF one_language_enabled==0 or mana_id %]
51
                    <div class="btn-group"><a data-toggle="modal" data-toggle="tooltip" title="Your email address will be associated to your sharing." data-target="#mana_share_modal" class="btn btn-small"><i class="fa fa-share-alt"></i> Share</a></div>
51
                    <div class="btn-group"><a data-toggle="modal" data-toggle="tooltip" title="Share the subscription with other librairies. Your email address will be associated to your sharing." data-target="#mana_share_modal" class="btn btn-default btn-sm"><i class="fa fa-share-alt"></i> Share</a></div>
52
                [% ELSE %]
52
                [% ELSE %]
53
                    <div class="btn-group" data-toggle="tooltip" title="Your email address will be associated to your sharing."><a class="btn btn-small" onclick="share()"><i class="fa fa-share-alt"></i> Share</a></div>
53
                    <div class="btn-group" data-toggle="tooltip" title="Share the subscription with other libraries. Your email address will be associated to your sharing."><a class="btn btn-default btn-sm" onclick="share()"><i class="fa fa-share-alt"></i> Share</a></div>
54
                [% END %]
54
                [% END %]
55
            [% END %]
55
            [% END %]
56
        [% END %]
56
        [% END %]
Lines 119-136 Link Here
119
            <div class="modal-body">
119
            <div class="modal-body">
120
                [% IF (mana_id) %]
120
                [% IF (mana_id) %]
121
                    <div class="alert">
121
                    <div class="alert">
122
                        <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwide it will do nothing.</p>
122
                        <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwise it will do nothing.</p>
123
                    </div>
123
                    </div>
124
                [% END %]
124
                [% END %]
125
                [% IF ( languages_loop ) %]
125
                [% IF ( languages_loop ) %]
126
                    [% UNLESS ( one_language_enabled ) %]
126
                    [% UNLESS ( one_language_enabled ) %]
127
                        <div class="rows">
127
                        <div class="rows">
128
                            <p>The frequency and the numberpattern of [% bibliotitle %] are :</p>
128
                                <li><span class="label">Frequency: </span>
129
                            <ol>
130
                                <li><span class="label">Frequency : </span>
131
                                        [% frequency.description %]
129
                                        [% frequency.description %]
132
                                </li>
130
                                </li>
133
                                <li><span class="label">Number pattern : </span>
131
                                <li><span class="label">Number pattern: </span>
134
                                    [% numberpattern.label %]
132
                                    [% numberpattern.label %]
135
                                </li>
133
                                </li>
136
                            </ol>
134
                            </ol>
Lines 138-144 Link Here
138
                        <div class="rows">
136
                        <div class="rows">
139
                            <form method="get" id="mana_share_form" action="/cgi-bin/koha/serials/subscription-detail.pl" class="validated" >
137
                            <form method="get" id="mana_share_form" action="/cgi-bin/koha/serials/subscription-detail.pl" class="validated" >
140
                                <fieldset>
138
                                <fieldset>
141
                                    <label for="mana_language">Language of your sharing :</label>
139
                                    <label for="mana_language">Language:</label>
142
                                    <select id="mana_language" name="mana_language">
140
                                    <select id="mana_language" name="mana_language">
143
                                        [% FOREACH languages_loo IN languages_loop %]
141
                                        [% FOREACH languages_loo IN languages_loop %]
144
                                            [% IF ( languages_loo.group_enabled ) %]
142
                                            [% IF ( languages_loo.group_enabled ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (+8 lines)
Lines 12-17 Link Here
12
<div id="doc" class="yui-t7">
12
<div id="doc" class="yui-t7">
13
    <div id="bd">
13
    <div id="bd">
14
        <div id="yui-main" class="sysprefs">
14
        <div id="yui-main" class="sysprefs">
15
            [% IF ( Koha.Preference('Mana') == 2) %]
16
                <fieldset>
17
                    <p><center> You haven't decided if you want to activate Mana Knowlede Base, please let us know by clicking<center></p>
18
                    <a href=/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=request+to+mana+webservice><center>Here</center></a>
19
                </fieldset>
20
           [% END %]
21
22
15
            <div class="yui-g"><h1>Koha administration</h1></div>
23
            <div class="yui-g"><h1>Koha administration</h1></div>
16
            <div class="yui-g">
24
            <div class="yui-g">
17
25
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref (-3 / +9 lines)
Lines 51-59 Web services: Link Here
51
        -
51
        -
52
            - pref: Mana
52
            - pref: Mana
53
              choices:
53
              choices:
54
                  yes: Enable
54
                  0: Disable
55
                  no: Disable
55
                  1: Enable
56
            - request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.
56
                  2: No, let me think about it
57
            - request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana. The informations shared with Mana KB are shared under the CC-0 license. More infos about CC-0 license on https://creativecommons.org/choose/zero/
58
        -
59
            - 'Fields automatically shared with mana'
60
            - pref: AutoShareWithMana
61
              multiple:
62
                subscription: Subscriptions
57
    Reporting:
63
    Reporting:
58
        -
64
        -
59
            - Only return
65
            - Only return
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-search-result.tt (+1 lines)
Line 0 Link Here
1
[% INCLUDE 'mana/mana-report-search-result.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-subscription-search-result.tt (+1 lines)
Line 0 Link Here
1
[% INCLUDE 'mana/mana-subscription-search-result.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-7 / +281 lines)
Lines 1-4 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% USE Koha %]
2
3
3
[%- BLOCK area_name -%]
4
[%- BLOCK area_name -%]
4
    [%- SWITCH area -%]
5
    [%- SWITCH area -%]
Lines 66-71 function load_group_subgroups () { Link Here
66
    }
67
    }
67
}
68
}
68
69
70
function share() {
71
    window.location="/cgi-bin/koha/reports/guided_reports.pl?phase=Save";
72
}
73
69
$(document).ready(function(){
74
$(document).ready(function(){
70
    $('#limit').change(function() {
75
    $('#limit').change(function() {
71
        $('#limitselect').submit();
76
        $('#limitselect').submit();
Lines 76-81 $(".goback").on("click",function(e){ Link Here
76
    window.history.back();
81
    window.history.back();
77
});
82
});
78
83
84
$(".mana_search_button").on("click",function(){
85
    mana_search($(this).prev().val());
86
});
87
88
$(".ShareButton").on("click", function(){
89
    if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
90
        $("#shared_infos").hide();
91
        $("#ManaShareButton").hide();
92
        $("#noterror").show();
93
    }
94
    else{
95
        $("#shared_id").html($(this).closest("tr").find(".report_id").text());
96
        $("#shared_name").html($(this).closest("tr").find(".report_name").text());
97
        $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
98
        $("#shared_type").html($(this).closest("tr").find(".report_type").text());
99
        $("#shared_group").html($(this).closest("tr").find(".report_group").text());
100
        $("#shared_notes").html($(this).closest("tr").find(".report_notes").text());
101
    }
102
});
103
104
$('#search_form').submit(function () {
105
    return false;
106
});
107
79
$("#addColumn").on("click",function(){
108
$("#addColumn").on("click",function(){
80
    addColumn();
109
    addColumn();
81
});
110
});
Lines 232-238 $("#delColumn").on("click",function(){ Link Here
232
    });
261
    });
233
[% END %]
262
[% END %]
234
});
263
});
235
//]]>
264
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
}
283
284
function mana_search( textquery ){
285
    $.ajax({
286
        type: "POST",
287
        url: "/cgi-bin/koha/svc/mana/search",
288
        data: {biblionumber: $("#biblionumber").val(), resource: 'report', id: textquery, usecomments: 1},
289
        dataType: "html",
290
    })
291
    .done( function( result ) {
292
        $("#mana_search_result .modal-body").html(result);
293
        $("#mana_search_result_label").text("Results from Mana Knowledge Base");
294
        $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
295
            "sPaginationType":"four_button",
296
            "autoWidth": false,
297
            "columnDefs": [
298
                { "width": "35%", "targets": 1 }
299
            ],
300
            "aoColumnDefs": [
301
                { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
302
                { "sType": "title-string", "aTargets" : [ "title-string" ] },
303
                { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
304
            ]
305
        }));
306
        if($("td.dataTables_empty").length == 0){
307
             $("#mana_search").show();
308
        }
309
310
        $( "select[class='actionreport1']" ).show();
311
        $( "button[class='actionreport2']" ).hide();
312
        $("#CommentButton").on("click", function(){
313
            var resource_type = "report";
314
            var target_id = $("#selected_id").val();
315
            var manamsg = $("#manamsg").val();
316
            mana_comment(target_id, manamsg, resource_type);
317
            $("#comment_box").modal("hide");
318
        });
319
320
        $(".showbutton").on("click", function(){
321
            $(this).parent().hide();
322
            $(this).parent().next().show();
323
        });
324
325
        $("a[class='hidebutton']").on("click", function(){
326
            $(this).parent().hide();
327
            $(this).parent().prev().show();
328
        });
329
330
        $("#commentCloseButton").on("click", function(){
331
            $("#comment_box").modal("hide");
332
        });
333
334
        $(".actionreport1").on("click", function(){
335
            $("#selectedcomment").val($(this).val());
336
            $(this).parent("select").hide();
337
            $(this).parent("select").next().show();
338
        });
339
340
        $(".actionreport2").on("click", function(){
341
            $(this).hide();
342
            $(this).prev().show();
343
            mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
344
        });
345
    }).fail( function( result ){
346
    });
347
}
348
349
function mana_comment( target_id, manamsg, resource_type ){
350
    $.ajax( {
351
        type: "POST",
352
        url: "/cgi-bin/koha/svc/mana/share",
353
        data: {message: manamsg, resource: resource_type , resource_id: target_id},
354
        datatype: "json",
355
    })
356
}
357
358
359
236
</script>
360
</script>
237
</head>
361
</head>
238
<body id="rep_guided_reports_start" class="rep">
362
<body id="rep_guided_reports_start" class="rep">
Lines 298-303 canned reports and writing custom SQL reports.</p> Link Here
298
</form>
422
</form>
299
[% END %]
423
[% END %]
300
424
425
<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;">
426
    <div class="modal-dialog modal-lg">
427
        <div class="modal-content">
428
            <div class="modal-header">
429
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
430
                <h3 id="mana_search_result_label"> Mana Search</h3>
431
            </div>
432
            <div>
433
                <form id="search_form" style="margin-left: 5%">
434
                    Please enter a few key words:
435
                    <input type=text id=mana_search_field>
436
                    <input type=button class="mana_search_button" value="Search">
437
                </form>
438
                <div class="modal-body">
439
                </div>
440
            </div>
441
        </div>
442
    </div>
443
</div>
444
445
301
[% IF ( saved1 ) %]
446
[% IF ( saved1 ) %]
302
[% IF ( savedreports ) %]<h1>Saved reports</h1>
447
[% IF ( savedreports ) %]<h1>Saved reports</h1>
303
448
Lines 315-320 canned reports and writing custom SQL reports.</p> Link Here
315
                <option value="">All</option>
460
                <option value="">All</option>
316
            </select>
461
            </select>
317
        </div>
462
        </div>
463
<div style="display:inline-block">
464
    [% IF (manamsg == 'success') %]
465
     <div id="mana_search" class="dialog message">
466
        <p> Shared successfully! Thanks for your help.</p>
467
    </div>
468
    [% ELSIF (manamsg == 'fail') %]
469
     <div id="mana_search" class="dialog message">
470
        <p> An error occured while sharing, please try again later.</p>
471
    </div>
472
    [% END %]
473
474
   [% IF (Koha.Preference('Mana') == 1) %]
475
    <div id="mana_search" class="dialog message">
476
        <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>
477
    </div>
478
    [% END %]
479
480
</script>
481
<h1> [% savedreport.sql %]</h1>
318
<form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
482
<form action="/cgi-bin/koha/reports/guided_reports.pl" id="reports_form" method="post">
319
<input type="hidden" name="phase" value="Delete Multiple" />
483
<input type="hidden" name="phase" value="Delete Multiple" />
320
        <table id="table_reports">
484
        <table id="table_reports">
Lines 338-360 canned reports and writing custom SQL reports.</p> Link Here
338
            <tbody>
502
            <tbody>
339
                [% FOREACH savedreport IN savedreports %]
503
                [% FOREACH savedreport IN savedreports %]
340
                    [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
504
                    [% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %]
341
                        <td>
505
                        <td class="report_checkbox">
342
                            [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
506
                            [% IF ( CAN_user_reports_delete_reports ) %] <!-- not break CSS -->
343
                                <input type="checkbox" name="ids" value="[% savedreport.id %]" />
507
                                <input type="checkbox" name="ids" value="[% savedreport.id %]" />
344
                            [% END %]
508
                            [% END %]
509
                        <input hidden class="report_sql" value="[% savedreport.savedsql %]">
345
                        </td>
510
                        </td>
346
                        <td><label for="ids">[% savedreport.id %]</label></td>
511
                        <td class="report_id"><label for="ids">[% savedreport.id %]</label></td>
347
                        <td>
512
                        <td class="report_name">
348
                            [% IF ( savedreport.report_name ) %]
513
                            [% IF ( savedreport.report_name ) %]
349
                                [% savedreport.report_name %]
514
                                [% savedreport.report_name %]
350
                            [% ELSE %]
515
                            [% ELSE %]
351
                                [ no name ]
516
                                [ no name ]
352
                            [% END %]
517
                            [% END %]
353
                        </td>
518
                        </td>
354
                        <td>[% savedreport.type %]</td>
519
                        <td class="report_type">[% savedreport.type %]</td>
355
                        <td>[% savedreport.groupname %]</td>
520
                        <td class="report_group">[% savedreport.groupname %]</td>
356
                        <td>[% savedreport.subgroupname %]</td>
521
                        <td>[% savedreport.subgroupname %]</td>
357
                        <td>[% savedreport.notes %]</td>
522
                        <td class="report_notes">[% savedreport.notes %]</td>
358
                        <td>[% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %])</td>
523
                        <td>[% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %])</td>
359
                        <td><span title="[% savedreport.date_created %]">[% savedreport.date_created | $KohaDates %]</span></td>
524
                        <td><span title="[% savedreport.date_created %]">[% savedreport.date_created | $KohaDates %]</span></td>
360
                        [% IF (savedreport.public) %]
525
                        [% IF (savedreport.public) %]
Lines 384-389 canned reports and writing custom SQL reports.</p> Link Here
384
                                            <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a></li>
549
                                            <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a></li>
385
                                            <li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from SQL&amp;sql=[% savedreport.savedsql |uri %]&amp;reportname=[% savedreport.report_name |uri %]&amp;notes=[% savedreport.notes |uri %]"><i class="fa fa-copy"></i> Duplicate</a></li>
550
                                            <li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from SQL&amp;sql=[% savedreport.savedsql |uri %]&amp;reportname=[% savedreport.report_name |uri %]&amp;notes=[% savedreport.notes |uri %]"><i class="fa fa-copy"></i> Duplicate</a></li>
386
                                        [% END %]
551
                                        [% END %]
552
                                        [% IF (Koha.Preference('Mana') == 1) %]
553
                                            <li><a class="ShareButton" data-toggle="modal" href="#mana_share_report" title="Share your report with Mana Knowledge Base"><i class="fa fa-share-alt"></i> Share</a></li>
554
                                        [% END %]
387
                                        <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
555
                                        <li><a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id %]"><i class="fa fa-clock-o"></i> Schedule</a></li>
388
                                        [% IF ( CAN_user_reports_delete_reports ) %]
556
                                        [% IF ( CAN_user_reports_delete_reports ) %]
389
                                            <li><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a></li>
557
                                            <li><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&amp;phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a></li>
Lines 396-401 canned reports and writing custom SQL reports.</p> Link Here
396
                [% END %]
564
                [% END %]
397
            </tbody>
565
            </tbody>
398
        </table>
566
        </table>
567
</div>
399
        [% IF ( CAN_user_reports_delete_reports ) %]
568
        [% IF ( CAN_user_reports_delete_reports ) %]
400
        <fieldset class="action">
569
        <fieldset class="action">
401
            <input type="submit" value="Delete selected" />
570
            <input type="submit" value="Delete selected" />
Lines 436-441 canned reports and writing custom SQL reports.</p> Link Here
436
[% END %]
605
[% END %]
437
[% END %]
606
[% END %]
438
607
608
<div id="mana_share_report" class="modal fade" tabindex="-1" role="dialog" arialabelledby="mana_share_modal_label" style="display: none;">
609
    <div class="modal-dialog">
610
        <div class="modal-content">
611
            <div class="modal-header">
612
                <h3 id="mana_share_modal_label">Share with Mana</h3>
613
            </div>
614
            <div class="modal-body">
615
                [% IF (mana_id) %]
616
                    <div class="alert">
617
                        <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwise it will do nothing.</p>
618
                    </div>
619
                [% END %]
620
                [% IF ( languages_loop ) %]
621
                    [% UNLESS ( one_language_enabled ) %]
622
                        <label id="noteerror" type="hidden">Please enter a report name and descriptive note before sharing (minimum 20 characters)</label>
623
                        <div id="shared_infos" class="rows">
624
                                <li> <span class="label">Id: </span><div id="shared_id"></div>
625
                                </li>
626
                                <li> <span class="label">Name: </span><div id="shared_name"></div>
627
                                </li>
628
                                <li> <span class="label">SQL: </span><div id="shared_sql"></div>
629
                                </li>
630
                                <li> <span class="label">Group: </span><div id="shared_group"></div>
631
                                </li>
632
                                <li> <span class="label">Type: </span><div id="shared_type"></div>
633
                                </li>
634
                                <li> <span class="label">Notes: </span><div id="shared_notes"></div>
635
                                </li>
636
637
                        </div>
638
                        <div class="rows">
639
                            <form method="post" id="mana_share_form" action="/cgi-bin/koha/reports/guided_reports.pl?phase=Share" class="validated" >
640
                                <input type="hidden" name="phase" value="Share">
641
642
                                <fieldset>
643
                                    <label for="mana_language">Language:</label>
644
                                    <select id="mana_language" name="mana_language">
645
                                        [% FOREACH languages_loo IN languages_loop %]
646
                                            [% IF ( languages_loo.group_enabled ) %]
647
                                                [% IF ( languages_loo.plural ) %]
648
                                                    [% FOREACH sublanguages_loo IN languages_loo.sublanguages_loop %]
649
                                                        [% IF ( sublanguages_loo.enabled ) %]
650
                                                            [% IF ( sublanguages_loo.sublanguage_current ) %]
651
                                                                <option value="[% languages_loo.rfc4646_subtag %]" selected>
652
                                                                    [% sublanguages_loo.native_description %]
653
                                                                    [% sublanguages_loo.script_description %]
654
                                                                    [% sublanguages_loo.region_description %]
655
656
                                                                    [% sublanguages_loo.variant_description %]
657
                                                                    ([% sublanguages_loo.rfc4646_subtag %])
658
                                                                </option>
659
                                                            [% ELSE %]
660
                                                                <option value="[% languages_loo.rfc4646_subtag %]">
661
                                                                    [% sublanguages_loo.native_description %]
662
                                                                    [% sublanguages_loo.script_description %]
663
                                                                    [% sublanguages_loo.region_description %]
664
                                                                    [% sublanguages_loo.variant_description %]
665
                                                                    ([% sublanguages_loo.rfc4646_subtag %])
666
                                                                </option>
667
                                                            [% END %]
668
                                                        [% END %]
669
                                                    [% END %]
670
                                                [% ELSE %]
671
                                                    [% IF ( languages_loo.group_enabled ) %]
672
                                                        [% IF ( languages_loo.current ) %]
673
                                                            <option value="[% languages_loo.rfc4646_subtag %]" selected>
674
                                                                [% IF ( languages_loo.native_description ) %]
675
                                                                    [% languages_loo.native_description %]
676
                                                                [% ELSE %]
677
                                                                    [% languages_loo.rfc4646_subtag %]
678
                                                                [% END %]
679
                                                            </option>
680
                                                        [% ELSE %]
681
                                                            <option value="[% languages_loo.rfc4646_subtag %]">
682
                                                                [% IF ( languages_loo.native_description ) %]
683
                                                                    [% languages_loo.native_description %]
684
                                                                [% ELSE %]
685
                                                                    [% languages_loo.rfc4646_subtag %]
686
                                                                [% END %]
687
                                                            </option>
688
                                                        [% END %]
689
                                                    [% END %]
690
                                                [% END %]
691
                                            [% END %]
692
                                        [% END %]
693
                                    </select>
694
                                    <input type="hidden" id="reportid" name="reportid" value="[% savedreport.id %]"/>
695
                                </fieldset>
696
                            </form>
697
                        </div>
698
                    [% END %]
699
                [% END %]
700
            </div>
701
            <div class="modal-footer">
702
                <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
703
                [% IF one_language_enabled==0 %]
704
                    <button id="ManaShareButton" type="submit" form="mana_share_form" class="btn btn-primary">Share</button>
705
                [% ELSE %]
706
                    <div id="ManaShareButton" class="btn-group"><a class="btn btn-primary"'onclick="share()">Share</a></div>
707
                [% END %]
708
            </div>
709
        </div>
710
    </div>
711
</div>
712
439
713
440
[% IF ( build1 ) %]
714
[% IF ( build1 ) %]
441
[% IF ( cache_error) %]
715
[% IF ( cache_error) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt (-1 lines)
Line 1 Link Here
1
[% INCLUDE 'mana-subscription-search-result.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-9 / +75 lines)
Lines 409-422 function mana_search() { Link Here
409
    $.ajax({
409
    $.ajax({
410
        type: "POST",
410
        type: "POST",
411
        url: "/cgi-bin/koha/svc/mana/search",
411
        url: "/cgi-bin/koha/svc/mana/search",
412
        data: {biblionumber : $("#biblionumber").val()},
412
        data: {id: $("#biblionumber").val(), resource: 'subscription', usecomments: 1},
413
        dataType: "html",
413
        dataType: "html",
414
    })
414
    })
415
    .done( function( result ) {
415
    .done( function( result ) {
416
    $("#mana_search_result .modal-body").html(result);
416
        $("#mana_search_result .modal-body").html(result);
417
        $("#mana_search_result_label").text("Results from Mana");
417
        $("#mana_search_result_label").text("Results from Mana Knowledge Base");
418
        $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
418
        $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
419
            "sPaginationType": "four_button",
419
            "sPaginationType": "four_button",
420
            "order":[[4, "desc"], [5, "desc"]],
421
            "autoWidth": false,
422
            "columnDefs": [
423
                { "width": "35%", "targets": 1 }
424
            ],
420
            "aoColumnDefs": [
425
            "aoColumnDefs": [
421
                { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
426
                { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
422
                { "sType": "title-string", "aTargets" : [ "title-string" ] },
427
                { "sType": "title-string", "aTargets" : [ "title-string" ] },
Lines 426-442 function mana_search() { Link Here
426
        if($("td.dataTables_empty").length == 0){
431
        if($("td.dataTables_empty").length == 0){
427
            $("#mana_search").show();
432
            $("#mana_search").show();
428
        }
433
        }
434
        $( "select[class='actionreport1']" ).show();
435
        $( "button[class='actionreport2']" ).hide();
436
437
        $("#CommentButton").on("click", function(){
438
            var resource_type = "subscription";
439
            var target_id = $("#selected_id").val();
440
            var manamsg = $("#manamsg").val();
441
            mana_comment(target_id, manamsg, resource_type);
442
            $("#comment_box").modal("hide");
443
        });
444
445
        $("#commentCloseButton").on("click", function(){
446
            $("#comment_box").modal("hide");
447
        });
448
449
        $(".actionreport1").on("click", function(){
450
            $("#selectedcomment").val($(this).val());
451
            $(this).parent("select").hide();
452
            $(this).parent("select").next().show();
453
        });
454
455
        $(".actionreport2").on("click", function(){
456
            $(this).hide();
457
            $(this).prev().show();
458
            mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1);
459
        });
460
429
    }).fail(function(result){
461
    }).fail(function(result){
430
    });
462
    });
431
}
463
}
432
464
465
function mana_comment( target_id, manamsg, resource_type ){
466
    $.ajax( {
467
        type: "POST",
468
        url: "/cgi-bin/koha/svc/mana/share",
469
        data: {message: manamsg, resource: resource_type , resource_id: target_id},
470
        datatype: "json",
471
    })
472
}
473
474
function mana_increment(mana_id, resource, fieldvalue, stepvalue = 1){
475
    $.ajax( {
476
        type: "POST",
477
        url: "/cgi-bin/koha/svc/mana/addvaluetofield",
478
        data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
479
        datatype: "json",
480
    })
481
}
482
433
function mana_use(mana_id){
483
function mana_use(mana_id){
434
    $("tr").removeClass("selected");
484
    $("tr").removeClass("selected");
435
    $("#row"+mana_id).addClass("selected");
485
    $("#row"+mana_id).addClass("selected");
436
    $.ajax( {
486
    $.ajax( {
437
        type: "POST",
487
        type: "POST",
438
        url: "/cgi-bin/koha/svc/mana/use",
488
        url: "/cgi-bin/koha/svc/mana/use",
439
        data: {id : mana_id},
489
        data: {id: mana_id, resource: 'subscription'},
440
        dataType: "json",
490
        dataType: "json",
441
    })
491
    })
442
    .done(function(result){
492
    .done(function(result){
Lines 511-516 function removeDisabledAttr() { Link Here
511
561
512
562
513
$(document).ready(function() {
563
$(document).ready(function() {
564
565
566
567
568
    mana_search();
569
    $("#myid").on("click", function(){
570
        debugger;
571
    })
514
    $("#displayexample").hide();
572
    $("#displayexample").hide();
515
    $("#mana_search_result").modal("hide");
573
    $("#mana_search_result").modal("hide");
516
    $("#aqbooksellerid").on('keypress', function(e) {
574
    $("#aqbooksellerid").on('keypress', function(e) {
Lines 649-654 $(document).ready(function() { Link Here
649
        e.preventDefault();
707
        e.preventDefault();
650
        testPredictionPattern();
708
        testPredictionPattern();
651
    });
709
    });
710
711
652
});
712
});
653
//]]>
713
//]]>
654
</script>
714
</script>
Lines 845-852 $(document).ready(function() { Link Here
845
905
846
                <div id="page_2">
906
                <div id="page_2">
847
                    <div class="yui-u first">
907
                    <div class="yui-u first">
908
                [% IF ( Koha.Preference('Mana') == 2) %]
909
                    <fieldset>
910
                        <p><center>You haven't activated the Mana Knowledge Base, click
911
                        <a href=/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=request+to+mana+webservice>here</a>
912
                         to configure.</center></p>
913
                    </fieldset>
914
                [% END %]
915
848
                        <div id="mana_search" class="dialog message">
916
                        <div id="mana_search" class="dialog message">
849
                            <p>Frequency and Numbering pattern have been already proposed for this subscription on Mana. To show results, click <a style="cursor:pointer" data-toggle="modal" data-target="#mana_search_result">Here</a></p>
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>
850
                        </div>
918
                        </div>
851
                        <div id="subscription_form_planning">
919
                        <div id="subscription_form_planning">
852
                            <fieldset class="rows">
920
                            <fieldset class="rows">
Lines 1134-1150 $(document).ready(function() { Link Here
1134
    </div>
1202
    </div>
1135
</div>
1203
</div>
1136
1204
1137
<div id="mana_search_result" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="width: 90%; left:5%; margin-left: auto; display: none;">
1205
<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;">
1138
    <div class="modal-dialog modal-lg">
1206
    <div class="modal-dialog modal-lg">
1139
        <div class="modal-content">
1207
        <div class="modal-content">
1140
            <div class="modal-header">
1208
            <div class="modal-header">
1209
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1141
                <h3 id="mana_search_result_label"></h3>
1210
                <h3 id="mana_search_result_label"></h3>
1142
            </div>
1211
            </div>
1143
            <div class="modal-body">
1212
            <div class="modal-body">
1144
            </div>
1213
            </div>
1145
            <div class="modal-footer">
1146
                <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
1147
            </div>
1148
        </div>
1214
        </div>
1149
    </div>
1215
    </div>
1150
</div>
1216
</div>
(-)a/misc/devel/update_dbix_class_files.pl (-3 / +8 lines)
Lines 32-37 my $db_port = '3306'; Link Here
32
my $db_name;
32
my $db_name;
33
my $db_user;
33
my $db_user;
34
my $db_passwd;
34
my $db_passwd;
35
my $tablename;
35
my $help;
36
my $help;
36
37
37
GetOptions(
38
GetOptions(
Lines 41-46 GetOptions( Link Here
41
    "db_port=s"   => \$db_port,
42
    "db_port=s"   => \$db_port,
42
    "db_name=s"   => \$db_name,
43
    "db_name=s"   => \$db_name,
43
    "db_user=s"   => \$db_user,
44
    "db_user=s"   => \$db_user,
45
    "tablename=s"  => \$tablename,
44
    "db_passwd=s" => \$db_passwd,
46
    "db_passwd=s" => \$db_passwd,
45
    "h|help"      => \$help
47
    "h|help"      => \$help
46
);
48
);
Lines 52-61 if (! defined $db_name ) { Link Here
52
    print "Error: \'db_name\' parameter is mandatory.\n";
54
    print "Error: \'db_name\' parameter is mandatory.\n";
53
    pod2usage(1);
55
    pod2usage(1);
54
} else {
56
} else {
55
57
    my $options = { debug => 1, dump_directory => $path, preserve_case => 1 };
58
    if ($tablename) {
59
        $options->{constraint} = qr/\A$tablename\z/
60
    }
56
    make_schema_at(
61
    make_schema_at(
57
        "Koha::Schema",
62
        "Koha::Schema",
58
        { debug => 1, dump_directory => $path, preserve_case => 1 },
63
        $options,
59
        ["DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",$db_user, $db_passwd ]
64
        ["DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",$db_user, $db_passwd ]
60
    );
65
    );
61
}
66
}
Lines 111-114 path into which create the schema files. (defaults to './') Link Here
111
116
112
prints this help text
117
prints this help text
113
118
114
=back
119
=back
(-)a/reports/guided_reports.pl (-1 / +12 lines)
Lines 37-42 use Koha::AuthorisedValues; Link Here
37
use Koha::BiblioFrameworks;
37
use Koha::BiblioFrameworks;
38
use Koha::Libraries;
38
use Koha::Libraries;
39
use Koha::Patron::Categories;
39
use Koha::Patron::Categories;
40
use Koha::SharedContent;
40
41
41
=head1 NAME
42
=head1 NAME
42
43
Lines 117-122 elsif ( $phase eq 'Build new' ) { Link Here
117
        $report->{results} = C4::Reports::Guided::get_results( $report->{id} );
118
        $report->{results} = C4::Reports::Guided::get_results( $report->{id} );
118
    }
119
    }
119
    $template->param(
120
    $template->param(
121
        'manamsg' => $input->param('manamsg')||'',
120
        'saved1' => 1,
122
        'saved1' => 1,
121
        'savedreports' => $reports,
123
        'savedreports' => $reports,
122
        'usecache' => $usecache,
124
        'usecache' => $usecache,
Lines 511-517 elsif ( $phase eq 'Build report' ) { Link Here
511
513
512
elsif ( $phase eq 'Save' ) {
514
elsif ( $phase eq 'Save' ) {
513
    # Save the report that has just been built
515
    # Save the report that has just been built
514
    my $area           = $input->param('area');
516
    my $area = $input->param('area');
515
    my $sql  = $input->param('sql');
517
    my $sql  = $input->param('sql');
516
    my $type = $input->param('type');
518
    my $type = $input->param('type');
517
    $template->param(
519
    $template->param(
Lines 615-620 elsif ( $phase eq 'Save Report' ) { Link Here
615
                    cache_expiry   => $cache_expiry,
617
                    cache_expiry   => $cache_expiry,
616
                    public         => $public,
618
                    public         => $public,
617
                } );
619
                } );
620
618
                logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog");
621
                logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog");
619
            $template->param(
622
            $template->param(
620
                'save_successful' => 1,
623
                'save_successful' => 1,
Lines 625-630 elsif ( $phase eq 'Save Report' ) { Link Here
625
    }
628
    }
626
}
629
}
627
630
631
elsif ($phase eq 'Share'){
632
    my $result = Koha::SharedContent::manaShareInfos($input, $borrowernumber, $input->param('reportid'), 'report');
633
    if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) {
634
        print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=success");
635
    }else{
636
        print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=fail");
637
    }
638
}
628
elsif ($phase eq 'Run this report'){
639
elsif ($phase eq 'Run this report'){
629
    # execute a saved report
640
    # execute a saved report
630
    my $limit      = $input->param('limit') || 20;
641
    my $limit      = $input->param('limit') || 20;
(-)a/serials/subscription-add.pl (-3 / +6 lines)
Lines 373-379 sub redirect_add_subscription { Link Here
373
    my $mana_id;
373
    my $mana_id;
374
    if ( $query->param('mana_id') ne "" ) {
374
    if ( $query->param('mana_id') ne "" ) {
375
        $mana_id = $query->param('mana_id');
375
        $mana_id = $query->param('mana_id');
376
        Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id);
376
        Koha::SharedContent::manaIncrementRequest("subscription",$mana_id, "nbofusers");
377
    }
377
    }
378
    else {
378
    else {
379
        $mana_id = undef;
379
        $mana_id = undef;
Lines 400-406 sub redirect_add_subscription { Link Here
400
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
400
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
401
        $skip_serialseq, $mana_id
401
        $skip_serialseq, $mana_id
402
    );
402
    );
403
403
    if ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana')) ){
404
        my $result = Koha::SharedContent::manaShareInfos( $query, $loggedinuser, $subscriptionid, 'subscription');
405
        $template->param( mana_code => $result->{code} );
406
    }
404
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
407
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
405
    insert_additional_fields( $additional_fields, $biblionumber, $subscriptionid );
408
    insert_additional_fields( $additional_fields, $biblionumber, $subscriptionid );
406
409
Lines 460-466 sub redirect_mod_subscription { Link Here
460
    my $mana_id;
463
    my $mana_id;
461
    if ( defined( $query->param('mana_id') ) ) {
464
    if ( defined( $query->param('mana_id') ) ) {
462
        $mana_id = $query->param('mana_id');
465
        $mana_id = $query->param('mana_id');
463
        Koha::SharedContent::manaNewUserPatchRequest("subscription",$mana_id);
466
        Koha::SharedContent::manaIncrementRequest("subscription",$mana_id, "nbofusers");
464
    }
467
    }
465
    else {
468
    else {
466
        $mana_id = undef;
469
        $mana_id = undef;
(-)a/serials/subscription-detail.pl (-37 / +2 lines)
Lines 100-143 if ($op eq 'del') { Link Here
100
    }
100
    }
101
}
101
}
102
elsif ( $op and $op eq "share" ) {
102
elsif ( $op and $op eq "share" ) {
103
    my $mana_language;
103
    my $result = Koha::SharedContent::manaShareInfos($query, $loggedinuser, $subscriptionid, 'subscription');
104
    if ( $query->param('mana_language') ) {
105
        $mana_language = $query->param('mana_language');
106
    }
107
    else {
108
        $mana_language = C4::Context->preference('language');
109
    }
110
111
    my $mana_email;
112
    if ( $loggedinuser ne 0 ) {
113
        my $borrower = Koha::Patrons->find($loggedinuser);
114
        $mana_email = $borrower->email
115
          if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
116
        $mana_email = $borrower->emailpro
117
          if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
118
        $mana_email =
119
          Koha::Libraries->find( C4::Context->userenv->{'branch'} )->branchemail
120
          if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
121
    }
122
    $mana_email = C4::Context->preference('KohaAdminEmailAddress')
123
      if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) );
124
    my %versions = C4::Context::get_versions();
125
126
    my $mana_info = {
127
        language    => $mana_language,
128
        kohaversion => $versions{'kohaVersion'},
129
        exportemail => $mana_email
130
    };
131
    my $sub_mana_info = Koha::Subscription::get_sharable_info($subscriptionid);
132
    $sub_mana_info = { %$sub_mana_info, %$mana_info };
133
    my $result = Koha::SharedContent::manaPostRequest( "subscription",
134
        $sub_mana_info );
135
    if ( $result->{code} eq "200" and $result->{code} eq "201" ) {
136
        my $subscription = Koha::Subscriptions->find($subscriptionid);
137
        $subscription->set( { mana_id => $result->{id} } )->store;
138
        $subs->{mana_id} = $result->{id};
139
    }
140
    $template->param( mana_code => $result->{code} );
104
    $template->param( mana_code => $result->{code} );
105
    $subs->{mana_id} = $result->{id};
141
}
106
}
142
107
143
my $hasRouting = check_routing($subscriptionid);
108
my $hasRouting = check_routing($subscriptionid);
(-)a/svc/mana/addvaluetofield (+42 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2016 BibLibre Morgane Alonso
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
20
21
use Modern::Perl;
22
23
use Koha::SharedContent;
24
use C4::Auth qw(check_cookie_auth);
25
26
use CGI;
27
use JSON;
28
29
30
my $input = new CGI;
31
binmode STDOUT, ":encoding(UTF-8)";
32
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
33
34
my ( $auth_status, $sessionID ) =
35
  check_cookie_auth( $input->cookie('CGISESSID'),
36
    { serials => 'create_subscription' } );
37
38
if ( $auth_status ne "ok" ) {
39
    exit 0;
40
}
41
my $result = Koha::SharedContent::manaIncrementRequest($input->param('resource'), $input->param('id'), $input->param('field'), $input->param('step') );
42
return $result;
(-)a/svc/mana/search (-8 / +23 lines)
Lines 18-25 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
19
#
20
20
21
use strict;
21
use Modern::Perl;
22
use warnings;
23
22
24
use Koha::SharedContent;
23
use Koha::SharedContent;
25
use Koha::Subscription;
24
use Koha::Subscription;
Lines 39-47 if ( $auth_status ne "ok" ) { Link Here
39
    exit 0;
38
    exit 0;
40
}
39
}
41
40
41
my $templatename;
42
$templatename = "mana/mana-".$input->param( "resource" )."-search-result.tt";
43
42
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
44
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43
    {
45
    {
44
        template_name   => "serials/mana-subscription-search-result.tt",
46
        template_name   => $templatename,
45
        query           => $input,
47
        query           => $input,
46
        type            => "intranet",
48
        type            => "intranet",
47
        authnotrequired => 0,
49
        authnotrequired => 0,
Lines 52-62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
52
    }
54
    }
53
);
55
);
54
56
55
my $biblionumber = $input->param('biblionumber');
57
my ($identifier, $sub_mana_info);
58
$identifier = $input->param('id');
59
$template->param( lowWarned => 5, warned => 10, highWarned => 20);
60
my $package = "Koha::".ucfirst($input->param( 'resource' ));
61
$sub_mana_info = $package->get_search_info($identifier);
62
63
$sub_mana_info->{ usecomments } = $input->param('usecomments');
64
my $resourcename = $input->param('resource');
65
my $result = Koha::SharedContent::manaGetRequest( $resourcename, $sub_mana_info);
66
my $nbofcomment;
67
foreach my $resource (@{ $result->{data} }){
68
    $nbofcomment = 0;
69
    foreach my $comment (@{ $resource->{comments} }){
70
        $nbofcomment += $comment->{nb};
71
    }
72
    $resource->{nbofcomment} = $nbofcomment;
73
}
56
74
57
my $sub_mana_info = Koha::Subscription::get_search_info($biblionumber);
75
$template->param( $input->param('resource')."s" => $result->{data} );
58
my $result =
59
  Koha::SharedContent::manaGetRequest( "subscription", $sub_mana_info );
60
$template->param( subscriptions => $result->{data} );
61
76
62
output_with_http_headers $input, $cookie, $template->output, 'json';
77
output_with_http_headers $input, $cookie, $template->output, 'json';
(-)a/svc/mana/share (+47 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2016 BibLibre Morgane Alonso
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
20
21
use Modern::Perl;
22
23
use Koha::SharedContent;
24
use C4::Auth qw(check_cookie_auth);
25
26
use CGI;
27
use JSON;
28
29
30
my $input = new CGI;
31
binmode STDOUT, ":encoding(UTF-8)";
32
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
33
34
my ( $auth_status, $sessionID ) =
35
  check_cookie_auth( $input->cookie('CGISESSID'),
36
    { serials => 'create_subscription' } );
37
38
if ( $auth_status ne "ok" ) {
39
    exit 0;
40
}
41
42
43
my $content;
44
$content->{resource_id} = $input->param("resource_id");
45
$content->{resource_type} = $input->param("resource");
46
$content->{message} = $input->param("message");
47
Koha::SharedContent::manaPostRequest('resource_comment', $content);
(-)a/svc/mana/use (-4 / +8 lines)
Lines 18-28 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
19
#
20
20
21
use strict;
21
use Modern::Perl;
22
use warnings;
23
22
24
use Koha::SharedContent;
23
use Koha::SharedContent;
25
use C4::Auth qw(check_cookie_auth);
24
use C4::Auth qw(check_cookie_auth);
25
use Koha::Report;
26
26
27
use CGI;
27
use CGI;
28
use JSON;
28
use JSON;
Lines 40-46 if ( $auth_status ne "ok" ) { Link Here
40
    exit 0;
40
    exit 0;
41
}
41
}
42
42
43
my $result = Koha::SharedContent::manaGetRequestWithId("subscription", $input->param('id') );
43
my $result = Koha::SharedContent::manaGetRequestWithId($input->param('resource'), $input->param('id') );
44
my $package = "Koha::".ucfirst($input->param('resource'));
45
46
if ( $input->param( 'saveinbase' )) {
47
    $package->new_from_mana($result->{data});
48
}
44
49
45
my $subscription;
50
my $subscription;
46
$subscription = $result->{data};
51
$subscription = $result->{data};
47
- 

Return to bug 17047