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

(-)a/Koha/SharedContent.pm (+56 lines)
Line 0 Link Here
1
package Koha::SharedContent;
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 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
use JSON;
22
use HTTP::Request;
23
use LWP::UserAgent;
24
25
our $MANA_IP = "http://10.25.159.107:5000";
26
27
sub manaRequest {
28
    my $mana_request = shift;
29
    my $result;
30
31
    $mana_request->content_type('application/json');
32
    my $userAgent = LWP::UserAgent->new;
33
    my $response  = $userAgent->request($mana_request);
34
35
    if ( $response->code ne "204" ) {
36
        $result = from_json( $response->decoded_content );
37
    }
38
    $result->{code} = $response->code;
39
40
    return $result if ( $response->code =~ /^2..$/ );
41
}
42
43
sub manaGetRequest {
44
    my $resource   = shift;
45
    my $parameters = shift;
46
47
    $parameters = join '&',
48
      map { defined $parameters->{$_} ? $_ . "=" . $parameters->{$_} : () }
49
      keys %$parameters;
50
    my $url = "$MANA_IP/$resource.json?$parameters";
51
    my $request = HTTP::Request->new( GET => $url );
52
53
    return manaRequest($request);
54
}
55
56
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc (+40 lines)
Line 0 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
            <th class="NoSort">Actions</th>
12
        </tr>
13
    </thead>
14
    <tfoot>
15
        <tr>
16
            <td><input type="text" class="dt-filter" data-column_num="0" placeholder="Search ISSN" /></td>
17
            <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search title" /></td>
18
            <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search frequency" /></td>
19
            <td><input type="text" class="dt-filter" data-column_num="3" placeholder="Search numbering pattern" /></td>
20
            <td></td>
21
            <td><input type="text" class="dt-filter" data-column_num="5" placeholder="Search last import" /></td>
22
            <td></td>
23
        </tr>
24
    </tfoot>
25
    <tbody>
26
        [% FOREACH subscription IN subscriptions %]
27
            [% UNLESS subscription.cannotdisplay %]
28
                <tr id="row[% subscription.subscriptionid %]">
29
                    <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td>
30
                    <td>[% subscription.title %]</a></td>
31
                    <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td>
32
                    <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td>
33
                    <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td>
34
                    <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td>
35
                    <td><a style="cursor:pointer" onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</a></td>
36
                </tr>
37
            [% END %]
38
        [% END %]
39
    </tbody>
40
</table>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc (+3 lines)
Lines 31-34 Link Here
31
        </a>
31
        </a>
32
    </li>
32
    </li>
33
    <li><a href="/cgi-bin/koha/serials/add_fields.pl">Add subscription fields</a></li>
33
    <li><a href="/cgi-bin/koha/serials/add_fields.pl">Add subscription fields</a></li>
34
    [% IF Koha.Preference('Mana') %]
35
        <li><a href="/cgi-bin/koha/serials/serials-search.pl?mana=1">Search on Mana</a></li>
36
    [% END %]
34
</ul>
37
</ul>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt (+1 lines)
Lines 1-5 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE Koha %]
3
<title>Koha &rsaquo; Serials [% biblionumber %]</title>
4
<title>Koha &rsaquo; Serials [% biblionumber %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
5
</head>
6
</head>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt (-7 / +42 lines)
Lines 1-6 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% USE Koha %]
4
[% USE AuthorisedValues %]
5
[% USE AuthorisedValues %]
5
<title>Koha &rsaquo; Serials [% biblionumber %]</title>
6
<title>Koha &rsaquo; Serials [% biblionumber %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
Lines 10-15 Link Here
10
<script type="text/javascript">
11
<script type="text/javascript">
11
//<![CDATA[
12
//<![CDATA[
12
 $(document).ready(function() {
13
 $(document).ready(function() {
14
    var manarlt = $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
15
        "sPaginationType": "four_button",
16
        "aoColumnDefs": [
17
            { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
18
            { "sType": "title-string", "aTargets" : [ "title-string" ] },
19
            { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
20
        ]
21
    } ) );
13
    var osrlt = $("#osrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
22
    var osrlt = $("#osrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
14
        "sPaginationType": "four_button",
23
        "sPaginationType": "four_button",
15
        "aoColumnDefs": [
24
        "aoColumnDefs": [
Lines 28-33 Link Here
28
        ]
37
        ]
29
    } ) );
38
    } ) );
30
39
40
    manarlt.fnAddFilters("dt-filter", 750);
31
    osrlt.fnAddFilters("dt-filter", 750);
41
    osrlt.fnAddFilters("dt-filter", 750);
32
    csrlt.fnAddFilters("dt-filter", 750);
42
    csrlt.fnAddFilters("dt-filter", 750);
33
43
Lines 35-40 Link Here
35
    $("#reopensub").click(function(){
45
    $("#reopensub").click(function(){
36
      return confirm(_("Are you sure you want to reopen this subscription?"));
46
      return confirm(_("Are you sure you want to reopen this subscription?"));
37
    });
47
    });
48
    [% IF ( mana ) %]
49
        $("label[for=callnumber], input#callnumber").hide();
50
        $("label[for=bookseller], input#bookseller").hide();
51
        $("label[for=branch], select#branch").hide();
52
        $("label[for=to], input#to").hide();
53
        $(".ui-datepicker-trigger").hide();
54
        $("label[for=location], select#location_filter").hide();
55
        [% FOR field IN additional_fields_for_subscription %]
56
              $("label[for=additional_field_[% field.id %]], input#additional_field_[% field.id %]").hide();
57
        [% END %]
58
    [% END %]
38
 });
59
 });
39
 //]]>
60
 //]]>
40
</script>
61
</script>
Lines 123-128 Link Here
123
                [% END %]
144
                [% END %]
124
              </ol>
145
              </ol>
125
              <input type="hidden" name="searched" value="1" />
146
              <input type="hidden" name="searched" value="1" />
147
              [% IF ( mana ) %]<input type="hidden" name="mana" value="1" />[% END %]
126
              <fieldset class="action">
148
              <fieldset class="action">
127
                <input type="submit" value="Search" />
149
                <input type="submit" value="Search" />
128
              </fieldset>
150
              </fieldset>
Lines 130-142 Link Here
130
        </form>
152
        </form>
131
      </div>
153
      </div>
132
      [% END %]
154
      [% END %]
133
      [% IF ( done_searched ) %]
155
            [% IF ( done_searched ) %]
134
        [% IF ( total ) %]
156
                [% IF ( total ) %]
135
          <div id="serialstabs" class="toptabs" style="clear:both;">
157
                    <div id="serialstabs" class="toptabs" style="clear:both;">
136
            <ul class="ui-tabs-nav">
158
                        <ul class="ui-tabs-nav">
137
              <li><a href="#opened">Open ([% openedsubscriptions.size || 0 %])</a></li>
159
                            [% IF mana %]
138
              <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 %])</a></li>
160
                                <li><a href="#mana">Mana ([% total || 0 %])</a></li>
139
            </ul>
161
                            [% ELSE %]
162
                                <li><a href="#opened">Open ([% openedsubscriptions.size || 0 %])</a></li>
163
                                <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 %])</a></li>
164
                            [% END %]
165
                        </ul>
166
                        [% IF mana %]
167
                            <div id="mana">
168
                                [% INCLUDE 'mana-subscription-search-result.inc' %]
169
                            </div>
170
                        [% ELSE %]
140
            <div id="opened">
171
            <div id="opened">
141
              [% IF openedsubscriptions %]
172
              [% IF openedsubscriptions %]
142
                <table id="osrlt">
173
                <table id="osrlt">
Lines 354-359 Link Here
354
                </div>
385
                </div>
355
              [% END %]
386
              [% END %]
356
            </div>
387
            </div>
388
            [% END %]
357
          </div>
389
          </div>
358
        [% ELSE %]
390
        [% ELSE %]
359
            <div class="dialog message">
391
            <div class="dialog message">
Lines 367-372 Link Here
367
  <div class="yui-b">
399
  <div class="yui-b">
368
    [% INCLUDE 'serials-menu.inc' %]
400
    [% INCLUDE 'serials-menu.inc' %]
369
    [% IF ( done_searched ) %]
401
    [% IF ( done_searched ) %]
402
    [% UNLESS ( mana ) %]
370
    <div id="advsearch">
403
    <div id="advsearch">
371
        <form action="/cgi-bin/koha/serials/serials-search.pl" method="get">
404
        <form action="/cgi-bin/koha/serials/serials-search.pl" method="get">
372
          <fieldset class="brief">
405
          <fieldset class="brief">
Lines 439-448 Link Here
439
              <fieldset class="action">
472
              <fieldset class="action">
440
                <input type="submit" value="Search" />
473
                <input type="submit" value="Search" />
441
              </fieldset>
474
              </fieldset>
475
442
            </div>
476
            </div>
443
          </fieldset>
477
          </fieldset>
444
        </form>
478
        </form>
445
      [% END %]
479
      [% END %]
480
    [% END %]
446
  </div>
481
  </div>
447
</div>
482
</div>
448
[% INCLUDE 'intranet-bottom.inc' %]
483
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/serials/serials-search.pl (-37 / +85 lines)
Lines 38-43 use C4::Serials; Link Here
38
use Koha::AdditionalField;
38
use Koha::AdditionalField;
39
39
40
use Koha::DateUtils;
40
use Koha::DateUtils;
41
use Koha::SharedContent;
41
42
42
my $query         = new CGI;
43
my $query         = new CGI;
43
my $title         = $query->param('title_filter') || '';
44
my $title         = $query->param('title_filter') || '';
Lines 52-57 my $location = $query->param('location_filter') || ''; Link Here
52
my $expiration_date = $query->param('expiration_date_filter') || '';
53
my $expiration_date = $query->param('expiration_date_filter') || '';
53
my $routing       = $query->param('routing') || C4::Context->preference("RoutingSerials");
54
my $routing       = $query->param('routing') || C4::Context->preference("RoutingSerials");
54
my $searched      = $query->param('searched') || 0;
55
my $searched      = $query->param('searched') || 0;
56
my $mana      = $query->param('mana') || 0;
55
my @subscriptionids = $query->multi_param('subscriptionid');
57
my @subscriptionids = $query->multi_param('subscriptionid');
56
my $op            = $query->param('op');
58
my $op            = $query->param('op');
57
59
Lines 95-101 for my $field ( @$additional_fields ) { Link Here
95
my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef;
97
my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef;
96
my @subscriptions;
98
my @subscriptions;
97
if ($searched){
99
if ($searched){
98
    @subscriptions = SearchSubscriptions(
100
    if ($mana) {
101
        my $result = Koha::SharedContent::manaGetRequest("subscription",{
102
            title        => $title,
103
            issn         => $ISSN,
104
            ean          => $EAN,
105
            publisher    => $publisher
106
        });
107
        @subscriptions = @{ $result->{data} };
108
    }
109
    else {
110
        @subscriptions = SearchSubscriptions(
99
        {
111
        {
100
            biblionumber => $biblionumber,
112
            biblionumber => $biblionumber,
101
            title        => $title,
113
            title        => $title,
Lines 108-153 if ($searched){ Link Here
108
            additional_fields => [ map{ { name => $_, value => $additional_field_filters->{$_}{value}, authorised_value_category => $additional_field_filters->{$_}{authorised_value_category} } } keys %$additional_field_filters ],
120
            additional_fields => [ map{ { name => $_, value => $additional_field_filters->{$_}{value}, authorised_value_category => $additional_field_filters->{$_}{authorised_value_category} } } keys %$additional_field_filters ],
109
            location     => $location,
121
            location     => $location,
110
            expiration_date => $expiration_date_dt,
122
            expiration_date => $expiration_date_dt,
111
        }
123
        });
112
    );
124
    }
113
}
125
}
114
126
115
# to toggle between create or edit routing list options
127
if ($mana) {
116
if ($routing) {
128
    $template->param(
117
    for my $subscription ( @subscriptions) {
129
        subscriptions => \@subscriptions,
118
        $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} );
130
        total         => scalar @subscriptions,
119
    }
131
        title_filter  => $title,
132
        ISSN_filter   => $ISSN,
133
        EAN_filter    => $EAN,
134
        callnumber_filter => $callnumber,
135
        publisher_filter => $publisher,
136
        bookseller_filter  => $bookseller,
137
        branch_filter => $branch,
138
        location_filter => $location,
139
        expiration_date_filter => $expiration_date_dt,
140
        done_searched => $searched,
141
        routing       => $routing,
142
        additional_field_filters => $additional_field_filters,
143
        additional_fields_for_subscription => $additional_fields,
144
        marcflavour   => (uc(C4::Context->preference("marcflavour"))),
145
        mana => $mana
146
    );
120
}
147
}
148
else
149
{
150
    # to toggle between create or edit routing list options
151
    if ($routing) {
152
        for my $subscription ( @subscriptions) {
153
            $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} );
154
        }
155
    }
121
156
122
my (@openedsubscriptions, @closedsubscriptions);
157
    my (@openedsubscriptions, @closedsubscriptions);
123
for my $sub ( @subscriptions ) {
158
    for my $sub ( @subscriptions ) {
124
    unless ( $sub->{closed} ) {
159
        unless ( $sub->{closed} ) {
125
        push @openedsubscriptions, $sub
160
            push @openedsubscriptions, $sub
126
            unless $sub->{cannotdisplay};
161
                unless $sub->{cannotdisplay};
127
    } else {
162
        } else {
128
        push @closedsubscriptions, $sub
163
            push @closedsubscriptions, $sub
129
            unless $sub->{cannotdisplay};
164
                unless $sub->{cannotdisplay};
165
        }
130
    }
166
    }
131
}
132
167
133
$template->param(
168
    my $branches = GetBranches();
134
    openedsubscriptions => \@openedsubscriptions,
169
    my @branches_loop;
135
    closedsubscriptions => \@closedsubscriptions,
170
    foreach (sort keys %$branches){
136
    total         => @openedsubscriptions + @closedsubscriptions,
171
        my $selected = 0;
137
    title_filter  => $title,
172
        $selected = 1 if( defined $branch and $branch eq $_ );
138
    ISSN_filter   => $ISSN,
173
        push @branches_loop, {
139
    EAN_filter    => $EAN,
174
            branchcode  => $_,
140
    callnumber_filter => $callnumber,
175
            branchname  => $branches->{$_}->{'branchname'},
141
    publisher_filter => $publisher,
176
            selected    => $selected,
142
    bookseller_filter  => $bookseller,
177
        };
143
    branch_filter => $branch,
178
    }
144
    location_filter => $location,
145
    expiration_date_filter => $expiration_date_dt,
146
    done_searched => $searched,
147
    routing       => $routing,
148
    additional_field_filters => $additional_field_filters,
149
    additional_fields_for_subscription => $additional_fields,
150
    marcflavour   => (uc(C4::Context->preference("marcflavour")))
151
);
152
179
180
    $template->param(
181
        openedsubscriptions => \@openedsubscriptions,
182
        closedsubscriptions => \@closedsubscriptions,
183
        total         => @openedsubscriptions + @closedsubscriptions,
184
        title_filter  => $title,
185
        ISSN_filter   => $ISSN,
186
        EAN_filter    => $EAN,
187
        callnumber_filter => $callnumber,
188
        publisher_filter => $publisher,
189
        bookseller_filter  => $bookseller,
190
        branch_filter => $branch,
191
        location_filter => $location,
192
        expiration_date_filter => $expiration_date_dt,
193
        branches_loop => \@branches_loop,
194
        done_searched => $searched,
195
        routing       => $routing,
196
        additional_field_filters => $additional_field_filters,
197
        additional_fields_for_subscription => $additional_fields,
198
        marcflavour   => (uc(C4::Context->preference("marcflavour"))),
199
        mana => $mana
200
    );
201
}
153
output_html_with_http_headers $query, $cookie, $template->output;
202
output_html_with_http_headers $query, $cookie, $template->output;
154
- 

Return to bug 17047