From f0dd950281de449daf3fd4e99c74672d25683c1f Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Wed, 8 Mar 2017 15:46:24 +0000 Subject: [PATCH] Bug 17047 SQL reports management with Mana-KB Includes: * code factorization Some code from subscription & Mana-KB has been factorized in order to speed-up next developments * SytemPreferences: Mana Activation: - add a value "no, let me think about it", that is the default value. - as long as this value is selected, messages ask if user want to activate it ( in Administration and Add-subscription(page 2) ) AutoShareWithMana - Add the syspref AutoShareWithMana: user can automatically share infos with Mana-KB (not set by default) * Interface : - On mana-search, rows are now sorted by date of last import, then by number of users - Windows redesigned to improve the user experience * New Feature : report a mistake. - people can now report an invalid data (wrong, obsolete,...) - if a data is reported as invalid many time, it will appear differently - Added few tooltip (to explain the fields last import, nb of users, to explain the new feature) - When reporting a data as invalid, a comment can also be added. Koha will then display comments related to data in result lists * API (svc/mana) - add svc/mana/addvaluetofield: allows to ask mana incrementing a field of a resource - no hardcoding for resources in the code of api (api needs to be called with a ressourcename) * New feature : SQL report sharing - Create Koha::Report.pm and Koha::Reports.pm, objects class for Reports - New feature: share reports with Mana-KB - New feature: search report in Mana-KB with keywords - New feature: load reports from Mana-KB ========= Test plan ========= (see BibLibre complete documentation, attached to this patch) 1 - Apply Patch + update database 2 - Copy the three lines about mana config in etc/koha-conf.xml in ../etc/koha-conf.xml 3 - Check Mana syspref and AutoShareWithMana syspref are not activated 4 - subscriptions - Try create a new subscription for a first serial => Koha shouldn't show you anything (except if the base hase been filled) - Share this serial on Mana-KB (on the subscription detail page there must be a Share button) - Try to create a new subscription for serial #1 => a message should appear when you click on "next", click on "use", the fields should automaticaly appear - Activate AutoShareWithMana => Subscriptions - Create a new subscription for a second serial - There shouldn't be any Share button - Create a second subscription => the message should appear, click again on use 5 - SQL Report - Create a new report, without notes. - On the table with all report (reports > use saved), there should be the action "Share" - If you click on share, you have an error message - Create a new report, with a title and notes longer than 20 characters - You can share it on Mana-KB => you will have a success message - On (report > use saved), there must be a message inviting you to search on mana-KB for more results, enter a few word from title, notes, type of the report you shared, it should appear. You can use it, it will load it into your report list. 6 - Comments. - On any table containing mana search results, you can report a mistake & comment why you report: click on report mistake. You only can chose "other" because there's no comment in Mana-KB [if there are comments, you'll get other values]. - If you click other, a new textbox appears. Enter a short comment. - Reload the whole page, the comment should appear in the menu and in the comment column. - If you select a comment and reload the whole page, there should be one more comment with this name - If you select a comment and click on cancel just after, there shouldn't be any change when you reload. --- Koha/Report.pm | 82 ++++++ Koha/Reports.pm | 58 ++++ Koha/SharedContent.pm | 66 ++++- Koha/Subscription.pm | 2 + etc/koha-conf.xml | 4 + .../mana_01-add_mana_id_in_subscription.sql | 1 + .../atomicupdate/mana_02-add_Mana_syspref.sql | 2 +- .../atomicupdate/mana_03-add_mana_autoshare.sql | 2 + installer/data/mysql/sysprefs.sql | 1 + koha-tmpl/intranet-tmpl/prog/css/staff-global.css | 6 + .../includes/mana-subscription-search-result.inc | 46 ---- .../en/includes/mana/mana-report-search-result.inc | 83 ++++++ .../mana/mana-subscription-search-result.inc | 82 ++++++ .../prog/en/includes/serials-toolbar.inc | 16 +- .../prog/en/modules/admin/admin-home.tt | 8 + .../en/modules/admin/preferences/web_services.pref | 12 +- .../en/modules/mana/mana-report-search-result.tt | 1 + .../mana/mana-subscription-search-result.tt | 1 + .../en/modules/reports/guided_reports_start.tt | 291 ++++++++++++++++++++- .../serials/mana-subscription-search-result.tt | 1 - .../prog/en/modules/serials/subscription-add.tt | 86 +++++- reports/guided_reports.pl | 13 +- serials/subscription-add.pl | 9 +- serials/subscription-detail.pl | 39 +-- svc/mana/addvaluetofield | 42 +++ svc/mana/search | 31 ++- svc/mana/share | 47 ++++ svc/mana/use | 19 +- 28 files changed, 913 insertions(+), 138 deletions(-) create mode 100644 Koha/Report.pm create mode 100644 Koha/Reports.pm create mode 100644 installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-search-result.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-subscription-search-result.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt create mode 100755 svc/mana/addvaluetofield create mode 100755 svc/mana/share diff --git a/Koha/Report.pm b/Koha/Report.pm new file mode 100644 index 0000000..b0197fb --- /dev/null +++ b/Koha/Report.pm @@ -0,0 +1,82 @@ +package Koha::Report; + +# Copyright 2017 Biblibre Baptiste Wojtkowski +# +# 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 Carp; + +use Koha::Database; +use JSON; +use Koha::Reports; + +use base qw(Koha::Object); + +=head1 NAME + +Koha::Report - Koha Report Object Class + +=head1 Ap + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub get_search_info { + my $self=shift; + my $sub_mana_info = { 'query' => shift }; + return $sub_mana_info; +} + +sub get_sharable_info{ + my $self=shift; + my $shared_report_id=shift; + my $report = Koha::Reports->find($shared_report_id); + my $sub_mana_info = { + 'savedsql' => $report->savedsql, + 'report_name' => $report->report_name, + 'notes' => $report->notes, + 'report_group' => $report->report_group, + 'type' => $report->type, + }; + return $sub_mana_info; +} + +sub new_from_mana{ + my $self = shift; + my $data = shift; + delete $data->{exportemail}; + delete $data->{kohaversion}; + delete $data->{creationdate}; + delete $data->{lastimport}; + $data->{mana_id} = $data->{id}; + delete $data->{id}; + delete $data->{nbofusers}; + delete $data->{language}; + Koha::Report->new($data)->store; +} + +sub _type { + return 'SavedSql'; +} + +1; diff --git a/Koha/Reports.pm b/Koha/Reports.pm new file mode 100644 index 0000000..dca236c --- /dev/null +++ b/Koha/Reports.pm @@ -0,0 +1,58 @@ +package Koha::Reports; + +# Copyright 2017 Biblibre Baptiste Wojtkowski +# +# 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 Carp; + +use Koha::Database; + +use Koha::Report; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Serial - Koha Serial Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'SavedSql'; +} + +sub object_class { + return 'Koha::Report'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm index e0c512b..7ac12f4 100644 --- a/Koha/SharedContent.pm +++ b/Koha/SharedContent.pm @@ -22,7 +22,10 @@ use JSON; use HTTP::Request; use LWP::UserAgent; -our $MANA_IP = "http://10.25.159.107:5000"; +use Koha::Serials; +use Koha::Reports; + +our $MANA_IP = C4::Context->config('mana_config'); sub manaRequest { my $mana_request = shift; @@ -40,12 +43,20 @@ sub manaRequest { return $result if ( $response->code =~ /^2..$/ ); } -sub manaNewUserPatchRequest { +sub manaIncrementRequest { my $resource = shift; my $id = shift; - - my $url = "$MANA_IP/$resource/$id.json/newUser"; - my $request = HTTP::Request->new( PATCH => $url ); + my $field = shift; + my $step = shift; + my $param; + $param->{step} = $step || 1; + $param->{id} = $id; + $param->{resource} = $resource; + $param = join '&', + map { defined $param->{$_} ? $_ . "=" . $param->{$_} : () } + keys %$param; + my $url = "$MANA_IP/$resource/$id.json/increment/$field?$param"; + my $request = HTTP::Request->new( POST => $url ); return manaRequest($request); } @@ -64,6 +75,51 @@ sub manaPostRequest { return manaRequest($request); } +sub manaShareInfos{ + my ($query, $loggedinuser, $ressourceid, $ressourcetype) = @_; + my $mana_language; + if ( $query->param('mana_language') ) { + $mana_language = $query->param('mana_language'); + } + else { + my $result = $mana_language = C4::Context->preference('language'); + } + + my $mana_email; + if ( $loggedinuser ne 0 ) { + my $borrower = Koha::Patrons->find($loggedinuser); + $mana_email = $borrower->email + if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); + $mana_email = $borrower->emailpro + if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); + $mana_email = + Koha::Libraries->find( C4::Context->userenv->{'branch'} )->branchemail + if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); + } + $mana_email = C4::Context->preference('KohaAdminEmailAddress') + if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); + my %versions = C4::Context::get_versions(); + + my $mana_info = { + language => $mana_language, + kohaversion => $versions{'kohaVersion'}, + exportemail => $mana_email + }; + my ($ressource, $ressource_mana_info); + my $packages = "Koha::".ucfirst($ressourcetype)."s"; + my $package = "Koha::".ucfirst($ressourcetype); + $ressource_mana_info = $package->get_sharable_info($ressourceid); + $ressource_mana_info = { %$ressource_mana_info, %$mana_info }; + $ressource = $packages->find($ressourceid); + + my $result = Koha::SharedContent::manaPostRequest( $ressourcetype, + $ressource_mana_info ); + if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) { + $ressource->set( { mana_id => $result->{id} } )->store; + } + return $result; +} + sub manaGetRequestWithId { my $resource = shift; my $id = shift; diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm index 40943dd..a6bdbae 100644 --- a/Koha/Subscription.pm +++ b/Koha/Subscription.pm @@ -46,6 +46,7 @@ Koha::Subscription - Koha Subscription Object class =cut sub get_search_info { + my $self=shift; my $searched_sub_id = shift; my $biblio = Koha::Biblios->find( { 'biblionumber' => $searched_sub_id } ); my $biblioitem = @@ -61,6 +62,7 @@ sub get_search_info { } sub get_sharable_info { + my $self = shift; my $shared_sub_id = shift; my $subscription = Koha::Subscriptions->find($shared_sub_id); my $biblio = Koha::Biblios->find( $subscription->biblionumber ); diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml index 4ccee3a..258d5d1 100644 --- a/etc/koha-conf.xml +++ b/etc/koha-conf.xml @@ -149,6 +149,10 @@ __PAZPAR2_TOGGLE_XML_POST__ __KOHA_CONF_DIR__/sms_send/ + + + http://mana-kb.koha-community.org + 50 2 diff --git a/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql b/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql index 5c590d1..66c23ac 100644 --- a/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql +++ b/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql @@ -1 +1,2 @@ ALTER TABLE subscription ADD mana_id int(11); +ALTER TABLE saved_sql ADD mana_id int(11); diff --git a/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql b/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql index 38d7ffb..dda85a5 100644 --- a/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql +++ b/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql @@ -1 +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'); +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'); diff --git a/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql b/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql new file mode 100644 index 0000000..353ffc1 --- /dev/null +++ b/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql @@ -0,0 +1,2 @@ +INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES +('AutoShareWithMana','subscription','','defines datas automatically shared with mana','multiple'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index f055f57..46093e8 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -60,6 +60,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AutoCreateAuthorities','0',NULL,'Automatically create authorities that do not exist when cataloging records.','YesNo'), ('AutoEmailOpacUser','0',NULL,'Sends notification emails containing new account details to patrons - when account is created.','YesNo'), ('AutoEmailPrimaryAddress','OFF','email|emailpro|B_email|cardnumber|OFF','Defines the default email address where \'Account Details\' emails are sent.','Choice'), +('AutoShareWithMana','subscription','','defines datas automatically shared with mana','multiple'), ('AutoLocation','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff client from unauthorized IP addresses','YesNo'), ('AutomaticItemReturn','1',NULL,'If ON, Koha will automatically set up a transfer of this item to its homebranch','YesNo'), ('autoMemberNum','1','','If ON, patron number is auto-calculated','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css index fb09d51..358d566 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css @@ -291,6 +291,12 @@ table+table { .highlighted-row, .highlighted-row td { background-color: #FFD000 !important } +.warned-row, +.warned-row td { background-color: #FF9000 !important } + +.high-warned-row, +.high-warned-row td { background-color: #FF0000 !important } + tbody tr:nth-child(odd) td { background-color : #F3F3F3; border : 1px solid #BCBCBC; 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 deleted file mode 100644 index 4ce9b9b..0000000 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/mana-subscription-search-result.inc +++ /dev/null @@ -1,46 +0,0 @@ -[% USE KohaDates %] - - - - - - - - - - [% UNLESS search_only %] - - [% END %] - - - - - - - - - - - [% UNLESS search_only %] - - [% END %] - - - - [% FOREACH subscription IN subscriptions %] - [% UNLESS subscription.cannotdisplay %] - - - - - - - - [% UNLESS search_only %] - - [% END %] - - [% END %] - [% END %] - -
ISSNTitleFrequencyNumbering patternNumber of usersLast ImportActions
[% IF ( subscription.issn ) %][% subscription.issn %][% END %][% subscription.title %][% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %][% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %][% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %][% subscription.lastimport | $KohaDates %] Use
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc new file mode 100644 index 0000000..7f74257 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc @@ -0,0 +1,83 @@ +[% USE KohaDates %] +[% USE Koha %] +[% USE AuthorisedValues %] +[% USE Branches %] + + + + + + + + + + + [% UNLESS search_only %] + + [% END %] + + + + [% FOREACH report IN reports %] + [% UNLESS report.cannotdisplay %] + highWarned %] + class = "high-warned-row" + [% ELSIF report.nbofcomment > warned %] + class = "warned-row" + [% ELSIF report.nbofcomment > lowWarned %] + class = "highlighted-row" + [% END %] + > + + + + [% END %] + + + + + + [% UNLESS search_only %] + + [% END %] + + [% END %] + [% END %] + +
Report NameNotesType# of usersLast import Comments Actions
[% IF ( report.report_name ) %][% report.report_name %][% END %]
+ [% IF report.notes.length > 200 %] + [% report.notes.substr(0,200) %]Show More
[% report.type %] [% IF ( report.nbofusers ) %][% report.nbofusers %][% END %][% report.lastimport | $KohaDates %][% FOREACH comment IN report.comments %][% comment.message %] ([% comment.nb %])
[% END %]
+ + + + +
+ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc new file mode 100644 index 0000000..447ab50 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc @@ -0,0 +1,82 @@ +[% USE KohaDates %] +[% USE Koha %] +[% USE AuthorisedValues %] +[% USE Branches %] + + + + + + + + + + + + + + + [% UNLESS search_only %] + + [% END %] + + + + [% FOREACH subscription IN subscriptions %] + [% UNLESS subscription.cannotdisplay %] + highWarned %] + class = "high-warned-row" title="this resource has been reported more than [% highWarned %] times, take care!" + [% ELSIF subscription.nbofcomment > warned %] + class = "warned-row" title="this resource has been reported more than [% warned %] times, take care!" + [% ELSIF subscription.nbofcomment > lowWarned %] + class = "highlighted-row" title="this resource has been reported more than [% lowWarned %] times, take care!" + [% END %] + > + + + + + + + + + + + [% UNLESS search_only %] + + [% END %] + + [% END %] + [% END %] + +
ISSNTitle Published by FrequencyNumbering pattern# of usersLast import Comments Actions
[% IF ( subscription.issn ) %][% subscription.issn %][% END %][% subscription.title %][% IF ( subscription.publishercode ) %][% subscription.publishercode %][% END %][% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %][% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %][% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %][% subscription.lastimport | $KohaDates %][% FOREACH comment IN subscription.comments %][% comment.message %] ([% comment.nb %])
[% END %]
+ + + + +
+ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc index 2cebb6d..3032b6e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc @@ -46,11 +46,11 @@ [% ELSE %] [% END %] - [% IF Koha.Preference('Mana') %] + [% IF Koha.Preference('Mana') and Koha.Preference('AutoShareWithMana').grep('subscription').size == 0 %] [% IF one_language_enabled==0 or mana_id %] - + [% ELSE %] - + [% END %] [% END %] [% END %] @@ -119,18 +119,16 @@ + + [% IF ( saved1 ) %] [% IF ( savedreports ) %]

Saved reports

@@ -361,6 +509,25 @@ canned reports and writing custom SQL reports.

+
+ [% IF (manamsg == 'success') %] + + [% ELSIF (manamsg == 'fail') %] + + [% END %] + + [% IF (Koha.Preference('Mana') == 1) %] + + [% END %] + + +

[% savedreport.sql %]

@@ -387,23 +554,24 @@ canned reports and writing custom SQL reports.

[% FOREACH savedreport IN savedreports %] [% UNLESS ( loop.odd ) %][% ELSE %][% END %] - - - + - - + + - + @@ -443,6 +611,9 @@ canned reports and writing custom SQL reports.

  • Edit
  • Duplicate
  • [% END %] + [% IF (Koha.Preference('Mana') == 1) %] +
  • + [% END %]
  • Schedule
  • [% IF ( CAN_user_reports_delete_reports ) %]
  • Delete
  • @@ -455,6 +626,7 @@ canned reports and writing custom SQL reports.

    [% END %]
    + [% IF ( CAN_user_reports_delete_reports ) %] [% END %] + + [% IF ( savedreport.report_name ) %] [% savedreport.report_name %] [% ELSE %] [ no name ] [% END %] [% savedreport.type %][% savedreport.groupname %][% savedreport.type %][% savedreport.groupname %] [% savedreport.subgroupname %][% savedreport.notes %][% savedreport.notes %] [% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %]) [% savedreport.date_created | $KohaDates %] [% savedreport.last_modified | $KohaDates with_hours => 1 %]
    +
    [% IF ( CAN_user_reports_delete_reports ) %]
    @@ -495,6 +667,111 @@ canned reports and writing custom SQL reports.

    [% END %] [% END %] + + [% IF ( build1 ) %] [% IF ( cache_error) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt deleted file mode 100644 index 0afe02c..0000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/mana-subscription-search-result.tt +++ /dev/null @@ -1 +0,0 @@ -[% INCLUDE 'mana-subscription-search-result.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index 46c732e..5cba09a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -409,14 +409,19 @@ function mana_search() { $.ajax({ type: "POST", url: "/cgi-bin/koha/svc/mana/search", - data: {biblionumber : $("#biblionumber").val()}, + data: {id: $("#biblionumber").val(), resource: 'subscription', usecomments: 1}, dataType: "html", }) .done( function( result ) { - $("#mana_search_result .modal-body").html(result); - $("#mana_search_result_label").text("Results from Mana"); + $("#mana_search_result .modal-body").html(result); + $("#mana_search_result_label").text("Results from Mana Knowledge Base"); $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, { "sPaginationType": "four_button", + "order":[[4, "desc"], [5, "desc"]], + "autoWidth": false, + "columnDefs": [ + { "width": "35%", "targets": 1 } + ], "aoColumnDefs": [ { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, { "sType": "title-string", "aTargets" : [ "title-string" ] }, @@ -426,17 +431,62 @@ function mana_search() { if($("td.dataTables_empty").length == 0){ $("#mana_search").show(); } + $( "select[class='actionreport1']" ).show(); + $( "button[class='actionreport2']" ).hide(); + + $("#CommentButton").on("click", function(){ + var resource_type = "subscription"; + var target_id = $("#selected_id").val(); + var manamsg = $("#manamsg").val(); + mana_comment(target_id, manamsg, resource_type); + $("#comment_box").modal("hide"); + }); + + $("#commentCloseButton").on("click", function(){ + $("#comment_box").modal("hide"); + }); + + $(".actionreport1").on("click", function(){ + $("#selectedcomment").val($(this).val()); + $(this).parent("select").hide(); + $(this).parent("select").next().show(); + }); + + $(".actionreport2").on("click", function(){ + $(this).hide(); + $(this).prev().show(); + mana_increment($("#selectedcomment").val(), 'resource_comment', 'nb', -1); + }); + }).fail(function(result){ }); } +function mana_comment( target_id, manamsg, resource_type ){ + $.ajax( { + type: "POST", + url: "/cgi-bin/koha/svc/mana/share", + data: {message: manamsg, resource: resource_type , resource_id: target_id}, + datatype: "json", + }) +} + +function mana_increment(mana_id, resource, fieldvalue, stepvalue = 1){ + $.ajax( { + type: "POST", + url: "/cgi-bin/koha/svc/mana/addvaluetofield", + data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue}, + datatype: "json", + }) +} + function mana_use(mana_id){ $("tr").removeClass("selected"); $("#row"+mana_id).addClass("selected"); $.ajax( { type: "POST", url: "/cgi-bin/koha/svc/mana/use", - data: {id : mana_id}, + data: {id: mana_id, resource: 'subscription'}, dataType: "json", }) .done(function(result){ @@ -511,6 +561,14 @@ function removeDisabledAttr() { $(document).ready(function() { + + + + + mana_search(); + $("#myid").on("click", function(){ + debugger; + }) $("#displayexample").hide(); $("#mana_search_result").modal("hide"); $("#aqbooksellerid").on('keypress', function(e) { @@ -619,7 +677,7 @@ $(document).ready(function() { }); $("#subscription_add_next").on("click",function(){ if ( Check_page1() ) { - [% IF Koha.Preference('Mana') %] + [% IF Koha.Preference('Mana')== 1 %] mana_search(); [% END %] show_page_2(); @@ -649,6 +707,8 @@ $(document).ready(function() { e.preventDefault(); testPredictionPattern(); }); + + }); //]]> @@ -845,8 +905,16 @@ $(document).ready(function() {
    + [% IF ( Koha.Preference('Mana') == 2) %] +
    +

    You haven't activated the Mana Knowledge Base, click + here + to configure.

    +
    + [% END %] +
    @@ -1134,17 +1202,15 @@ $(document).ready(function() {
    -