Bugzilla – Attachment 62593 Details for
Bug 17047
Mana Knowledge Base : Data sharing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17047 ability to search subscription model on mana
Bug-17047-ability-to-search-subscription-model-on-.patch (text/plain), 17.12 KB, created by
Paul Poulain
on 2017-04-24 13:15:35 UTC
(
hide
)
Description:
Bug 17047 ability to search subscription model on mana
Filename:
MIME Type:
Creator:
Paul Poulain
Created:
2017-04-24 13:15:35 UTC
Size:
17.12 KB
patch
obsolete
>From 15ccfea8370c62749350f18549a73c0f4a0470dd Mon Sep 17 00:00:00 2001 >From: morgane alonso <morgane.alonso@biblibre.com> >Date: Thu, 25 Aug 2016 10:06:12 +0000 >Subject: [PATCH] Bug 17047 ability to search subscription model on mana > >- add a class SharedContent.pm to communicate with mana server >- add a link in serials-menu.inc to serials_search.pl to open >a mana-subscription research form >- modify the research form in serials-search.tt to show the right fields >for mana >- create datatable in mana-subscription-search-result.inc to show >results from a research on mana >- modify serials-search.pl to manage research on mana >--- > Koha/SharedContent.pm | 56 ++++++++++ > .../includes/mana-subscription-search-result.inc | 46 ++++++++ > .../prog/en/includes/serials-menu.inc | 3 + > .../prog/en/modules/serials/serials-home.tt | 1 + > .../prog/en/modules/serials/serials-search.tt | 49 +++++++-- > serials/serials-search.pl | 122 +++++++++++++++------ > 6 files changed, 234 insertions(+), 43 deletions(-) > create mode 100644 Koha/SharedContent.pm > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc > >diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm >new file mode 100644 >index 0000000..ced0e6c >--- /dev/null >+++ b/Koha/SharedContent.pm >@@ -0,0 +1,56 @@ >+package Koha::SharedContent; >+ >+# Copyright 2016 BibLibre Morgane Alonso >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+use JSON; >+use HTTP::Request; >+use LWP::UserAgent; >+ >+our $MANA_IP = "http://10.25.159.107:5000"; >+ >+sub manaRequest { >+ my $mana_request = shift; >+ my $result; >+ >+ $mana_request->content_type('application/json'); >+ my $userAgent = LWP::UserAgent->new; >+ my $response = $userAgent->request($mana_request); >+ >+ if ( $response->code ne "204" ) { >+ $result = from_json( $response->decoded_content ); >+ } >+ $result->{code} = $response->code; >+ >+ return $result if ( $response->code =~ /^2..$/ ); >+} >+ >+sub manaGetRequest { >+ my $resource = shift; >+ my $parameters = shift; >+ >+ $parameters = join '&', >+ map { defined $parameters->{$_} ? $_ . "=" . $parameters->{$_} : () } >+ keys %$parameters; >+ my $url = "$MANA_IP/$resource.json?$parameters"; >+ my $request = HTTP::Request->new( GET => $url ); >+ >+ return manaRequest($request); >+} >+ >+1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc >new file mode 100644 >index 0000000..4ce9b9b >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc >@@ -0,0 +1,46 @@ >+[% USE KohaDates %] >+<table id="mana_results_datatable"> >+ <thead> >+ <tr> >+ <th>ISSN</th> >+ <th class="anti-the">Title</th> >+ <th>Frequency</th> >+ <th>Numbering pattern</th> >+ <th class="NoSort">Number of users</th> >+ <th class="title-string">Last Import</th> >+ [% UNLESS search_only %] >+ <th class="NoSort">Actions</th> >+ [% END %] >+ </tr> >+ </thead> >+ <tfoot> >+ <tr> >+ <td><input type="text" class="dt-filter" data-column_num="0" placeholder="Search ISSN" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search title" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search frequency" /></td> >+ <td><input type="text" class="dt-filter" data-column_num="3" placeholder="Search numbering pattern" /></td> >+ <td></td> >+ <td><input type="text" class="dt-filter" data-column_num="5" placeholder="Search last import" /></td> >+ [% UNLESS search_only %] >+ <td></td> >+ [% END %] >+ </tr> >+ </tfoot> >+ <tbody> >+ [% FOREACH subscription IN subscriptions %] >+ [% UNLESS subscription.cannotdisplay %] >+ <tr id="row[% subscription.subscriptionid %]"> >+ <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td> >+ <td>[% subscription.title %]</a></td> >+ <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td> >+ <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td> >+ <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td> >+ <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td> >+ [% UNLESS search_only %] >+ <td><a style="cursor:pointer" onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</a></td> >+ [% END %] >+ </tr> >+ [% END %] >+ [% END %] >+ </tbody> >+</table> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >index 21dff3a..ee66508 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc >@@ -31,4 +31,7 @@ > </a> > </li> > <li><a href="/cgi-bin/koha/serials/add_fields.pl">Add subscription fields</a></li> >+ [% IF Koha.Preference('Mana') %] >+ <li><a href="/cgi-bin/koha/serials/serials-search.pl?mana=1">Search on Mana</a></li> >+ [% END %] > </ul> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt >index eaafc94..f587b28 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt >@@ -1,5 +1,6 @@ > [% INCLUDE 'doc-head-open.inc' %] > [% USE KohaDates %] >+[% USE Koha %] > <title>Koha › Serials [% biblionumber %]</title> > [% INCLUDE 'doc-head-close.inc' %] > </head> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >index 1728fb0..6131ed1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >@@ -1,6 +1,7 @@ > [% USE Branches %] > [% INCLUDE 'doc-head-open.inc' %] > [% USE KohaDates %] >+[% USE Koha %] > [% USE AuthorisedValues %] > <title>Koha › Serials [% biblionumber %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -10,6 +11,14 @@ > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function() { >+ var manarlt = $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sPaginationType": "four_button", >+ "aoColumnDefs": [ >+ { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, >+ { "sType": "title-string", "aTargets" : [ "title-string" ] }, >+ { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] } >+ ] >+ } ) ); > var osrlt = $("#osrlt").dataTable($.extend(true, {}, dataTablesDefaults, { > "sPaginationType": "four_button", > "aoColumnDefs": [ >@@ -28,6 +37,7 @@ > ] > } ) ); > >+ manarlt.fnAddFilters("dt-filter", 750); > osrlt.fnAddFilters("dt-filter", 750); > csrlt.fnAddFilters("dt-filter", 750); > >@@ -35,6 +45,17 @@ > $("#reopensub").click(function(){ > return confirm(_("Are you sure you want to reopen this subscription?")); > }); >+ [% IF ( mana ) %] >+ $("label[for=callnumber], input#callnumber").hide(); >+ $("label[for=bookseller], input#bookseller").hide(); >+ $("label[for=branch], select#branch").hide(); >+ $("label[for=to], input#to").hide(); >+ $(".ui-datepicker-trigger").hide(); >+ $("label[for=location], select#location_filter").hide(); >+ [% FOR field IN additional_fields_for_subscription %] >+ $("label[for=additional_field_[% field.id %]], input#additional_field_[% field.id %]").hide(); >+ [% END %] >+ [% END %] > }); > //]]> > </script> >@@ -123,6 +144,7 @@ > [% END %] > </ol> > <input type="hidden" name="searched" value="1" /> >+ [% IF ( mana ) %]<input type="hidden" name="mana" value="1" />[% END %] > <fieldset class="action"> > <input type="submit" value="Search" /> > </fieldset> >@@ -130,13 +152,22 @@ > </form> > </div> > [% END %] >- [% IF ( done_searched ) %] >- [% IF ( total ) %] >- <div id="serialstabs" class="toptabs" style="clear:both;"> >- <ul class="ui-tabs-nav"> >- <li><a href="#opened">Open ([% openedsubscriptions.size || 0 %])</a></li> >- <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 %])</a></li> >- </ul> >+ [% IF ( done_searched ) %] >+ [% IF ( total ) %] >+ <div id="serialstabs" class="toptabs" style="clear:both;"> >+ <ul class="ui-tabs-nav"> >+ [% IF mana %] >+ <li><a href="#mana">Mana ([% total || 0 %])</a></li> >+ [% ELSE %] >+ <li><a href="#opened">Open ([% openedsubscriptions.size || 0 %])</a></li> >+ <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 %])</a></li> >+ [% END %] >+ </ul> >+ [% IF mana %] >+ <div id="mana"> >+ [% INCLUDE 'mana-subscription-search-result.inc' %] >+ </div> >+ [% ELSE %] > <div id="opened"> > [% IF openedsubscriptions %] > <table id="osrlt"> >@@ -354,6 +385,7 @@ > </div> > [% END %] > </div> >+ [% END %] > </div> > [% ELSE %] > <div class="dialog message"> >@@ -367,6 +399,7 @@ > <div class="yui-b"> > [% INCLUDE 'serials-menu.inc' %] > [% IF ( done_searched ) %] >+ [% UNLESS ( mana ) %] > <div id="advsearch"> > <form action="/cgi-bin/koha/serials/serials-search.pl" method="get"> > <fieldset class="brief"> >@@ -439,10 +472,12 @@ > <fieldset class="action"> > <input type="submit" value="Search" /> > </fieldset> >+ > </div> > </fieldset> > </form> > [% END %] >+ [% END %] > </div> > </div> > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/serials/serials-search.pl b/serials/serials-search.pl >index 30bf7db..d6cb85c 100755 >--- a/serials/serials-search.pl >+++ b/serials/serials-search.pl >@@ -38,6 +38,7 @@ use C4::Serials; > use Koha::AdditionalField; > > use Koha::DateUtils; >+use Koha::SharedContent; > > my $query = new CGI; > my $title = $query->param('title_filter') || ''; >@@ -52,6 +53,7 @@ my $location = $query->param('location_filter') || ''; > my $expiration_date = $query->param('expiration_date_filter') || ''; > my $routing = $query->param('routing') || C4::Context->preference("RoutingSerials"); > my $searched = $query->param('searched') || 0; >+my $mana = $query->param('mana') || 0; > my @subscriptionids = $query->multi_param('subscriptionid'); > my $op = $query->param('op'); > >@@ -95,7 +97,17 @@ for my $field ( @$additional_fields ) { > my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef; > my @subscriptions; > if ($searched){ >- @subscriptions = SearchSubscriptions( >+ if ($mana) { >+ my $result = Koha::SharedContent::manaGetRequest("subscription",{ >+ title => $title, >+ issn => $ISSN, >+ ean => $EAN, >+ publisher => $publisher >+ }); >+ @subscriptions = @{ $result->{data} }; >+ } >+ else { >+ @subscriptions = SearchSubscriptions( > { > biblionumber => $biblionumber, > title => $title, >@@ -108,46 +120,84 @@ if ($searched){ > additional_fields => [ map{ { name => $_, value => $additional_field_filters->{$_}{value}, authorised_value_category => $additional_field_filters->{$_}{authorised_value_category} } } keys %$additional_field_filters ], > location => $location, > expiration_date => $expiration_date_dt, >- } >- ); >+ }); >+ } > } > >-# to toggle between create or edit routing list options >-if ($routing) { >- for my $subscription ( @subscriptions) { >- $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} ); >- } >+if ($mana) { >+ $template->param( >+ subscriptions => \@subscriptions, >+ total => scalar @subscriptions, >+ title_filter => $title, >+ ISSN_filter => $ISSN, >+ EAN_filter => $EAN, >+ callnumber_filter => $callnumber, >+ publisher_filter => $publisher, >+ bookseller_filter => $bookseller, >+ branch_filter => $branch, >+ location_filter => $location, >+ expiration_date_filter => $expiration_date_dt, >+ done_searched => $searched, >+ routing => $routing, >+ additional_field_filters => $additional_field_filters, >+ additional_fields_for_subscription => $additional_fields, >+ marcflavour => (uc(C4::Context->preference("marcflavour"))), >+ mana => $mana, >+ search_only => 1 >+ ); > } >+else >+{ >+ # to toggle between create or edit routing list options >+ if ($routing) { >+ for my $subscription ( @subscriptions) { >+ $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} ); >+ } >+ } > >-my (@openedsubscriptions, @closedsubscriptions); >-for my $sub ( @subscriptions ) { >- unless ( $sub->{closed} ) { >- push @openedsubscriptions, $sub >- unless $sub->{cannotdisplay}; >- } else { >- push @closedsubscriptions, $sub >- unless $sub->{cannotdisplay}; >+ my (@openedsubscriptions, @closedsubscriptions); >+ for my $sub ( @subscriptions ) { >+ unless ( $sub->{closed} ) { >+ push @openedsubscriptions, $sub >+ unless $sub->{cannotdisplay}; >+ } else { >+ push @closedsubscriptions, $sub >+ unless $sub->{cannotdisplay}; >+ } > } >-} > >-$template->param( >- openedsubscriptions => \@openedsubscriptions, >- closedsubscriptions => \@closedsubscriptions, >- total => @openedsubscriptions + @closedsubscriptions, >- title_filter => $title, >- ISSN_filter => $ISSN, >- EAN_filter => $EAN, >- callnumber_filter => $callnumber, >- publisher_filter => $publisher, >- bookseller_filter => $bookseller, >- branch_filter => $branch, >- location_filter => $location, >- expiration_date_filter => $expiration_date_dt, >- done_searched => $searched, >- routing => $routing, >- additional_field_filters => $additional_field_filters, >- additional_fields_for_subscription => $additional_fields, >- marcflavour => (uc(C4::Context->preference("marcflavour"))) >-); >+ my @branches = Koha::Libraries->search( {}, { order_by => ['branchcode'] } ); >+ my @branches_loop; >+ foreach my $b ( @branches ) { >+ my $selected = 0; >+ $selected = 1 if( defined $branch and $branch eq $b->branchcode ); >+ push @branches_loop, { >+ branchcode => $b->branchcode, >+ branchname => $b->branchname, >+ selected => $selected, >+ }; >+ } > >+ $template->param( >+ openedsubscriptions => \@openedsubscriptions, >+ closedsubscriptions => \@closedsubscriptions, >+ total => @openedsubscriptions + @closedsubscriptions, >+ title_filter => $title, >+ ISSN_filter => $ISSN, >+ EAN_filter => $EAN, >+ callnumber_filter => $callnumber, >+ publisher_filter => $publisher, >+ bookseller_filter => $bookseller, >+ branch_filter => $branch, >+ location_filter => $location, >+ expiration_date_filter => $expiration_date_dt, >+ branches_loop => \@branches_loop, >+ done_searched => $searched, >+ routing => $routing, >+ additional_field_filters => $additional_field_filters, >+ additional_fields_for_subscription => $additional_fields, >+ marcflavour => (uc(C4::Context->preference("marcflavour"))), >+ mana => $mana >+ ); >+} > output_html_with_http_headers $query, $cookie, $template->output; >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17047
:
56175
|
56176
|
56177
|
56178
|
56179
|
56180
|
56181
|
59728
|
59729
|
59931
|
61905
|
62045
|
62046
|
62047
|
62048
|
62049
|
62050
|
62051
|
62052
|
62053
|
62054
|
62075
|
62465
|
62475
|
62485
|
62540
|
62542
|
62543
|
62544
|
62545
|
62546
|
62547
|
62548
|
62549
|
62550
|
62551
|
62552
|
62553
|
62589
|
62591
|
62592
|
62593
|
62594
|
62595
|
62596
|
62597
|
62598
|
62599
|
62603
|
62604
|
62605
|
62606
|
62607
|
62768
|
63476
|
63601
|
63618
|
63619
|
63620
|
63621
|
63622
|
63623
|
64484
|
64530
|
64618
|
64619
|
64620
|
64621
|
64622
|
64623
|
64624
|
64625
|
64626
|
64627
|
64628
|
64629
|
64630
|
64631
|
64632
|
64633
|
64634
|
64635
|
64636
|
64637
|
64638
|
64639
|
64640
|
64641
|
64642
|
64643
|
64648
|
64649
|
64650
|
64651
|
64652
|
64653
|
64654
|
64706
|
64962
|
65058
|
65059
|
65060
|
65061
|
65062
|
65063
|
65064
|
65065
|
65773
|
66667
|
66668
|
66987
|
67003
|
67004
|
67005
|
67006
|
67009
|
67010
|
67011
|
67012
|
67013
|
67014
|
67015
|
67016
|
67017
|
67018
|
67019
|
67020
|
67021
|
67022
|
67023
|
69034
|
69035
|
69036
|
69037
|
69038
|
69039
|
69040
|
69041
|
69091
|
70203
|
70204
|
70205
|
70206
|
70208
|
70209
|
70210
|
70211
|
70561
|
70874
|
72660
|
72661
|
72662
|
72663
|
72664
|
72665
|
72666
|
72667
|
72668
|
72669
|
72670
|
73699
|
73737
|
73738
|
73739
|
73740
|
73741
|
73742
|
73743
|
73744
|
73745
|
73746
|
73747
|
73748
|
73975
|
73976
|
73977
|
73978
|
73979
|
73980
|
73981
|
73982
|
73983
|
73984
|
73985
|
73986
|
76673
|
76674
|
76675
|
76676
|
76677
|
76678
|
76679
|
76680
|
76681
|
76682
|
76683
|
76684
|
78215
|
78216
|
78217
|
78218
|
78219
|
78220
|
78221
|
78222
|
78223
|
78224
|
78225
|
78226
|
78227
|
78228
|
78229
|
79868
|
79869
|
79870
|
79871
|
79872
|
79874
|
79877
|
79878
|
79879
|
79880
|
79881
|
79882
|
79883
|
79884
|
79885
|
79886
|
79887
|
79888
|
79922
|
79923
|
79924
|
79925
|
79926
|
79927
|
79928
|
79929
|
79930
|
79931
|
79932
|
79933
|
79934
|
79935
|
79936
|
79937
|
79938
|
79939
|
80183
|
80184
|
80185
|
80186
|
80187
|
80188
|
80189
|
80190
|
80191
|
80192
|
80193
|
80194
|
80195
|
80196
|
80197
|
80198
|
80199
|
80200
|
80471
|
80472
|
80473
|
80907
|
80908
|
80909
|
80910
|
80911
|
80912
|
80913
|
80914
|
80915
|
80916
|
80917
|
80918
|
80919
|
80920
|
80921
|
80922
|
80923
|
80924
|
81935
|
81936
|
81937
|
81938
|
81939
|
81940
|
81941
|
81942
|
81943
|
81944
|
81945
|
81946
|
81947
|
81948
|
81949
|
81950
|
81951
|
81952
|
81968
|
83863
|
83864
|
83865
|
83866
|
83867
|
83868
|
83869
|
83870
|
83871
|
83872
|
83873
|
83874
|
83875
|
83876
|
83877
|
83878
|
83879
|
83880
|
83881
|
83892
|
83893
|
83894
|
83895
|
83896
|
83897
|
83898
|
83899
|
83900
|
83901
|
83902
|
83903
|
83904
|
83905
|
83906
|
83907
|
83908
|
83909
|
83910
|
83911
|
83912
|
84142
|
84145
|
84210
|
84260
|
84261
|
84262
|
84263
|
84264
|
84265
|
84323
|
84324
|
84325
|
84326
|
84327
|
84328
|
84329
|
84332