From 1d1918067dd3302d1bce95cf25fef61ba5435851 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. Signed-off-by: Brendan A Gallagher Signed-off-by: Kyle M Hall Rebased-by: Alex Arnaud (2018-07-04) Signed-off-by: Michal Denar Signed-off-by: Michal Denar --- Koha/Report.pm | 54 ++++ Koha/Reports.pm | 6 + 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 + .../intranet-tmpl/prog/css/src/staff-global.scss | 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 | 287 ++++++++++++++++++++- .../serials/mana-subscription-search-result.tt | 1 - .../prog/en/modules/serials/subscription-add.tt | 20 +- .../intranet-tmpl/prog/js/subscription-add.js | 64 ++++- 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 +- 29 files changed, 823 insertions(+), 142 deletions(-) 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 index 3be4415..a1d9b56 100644 --- a/Koha/Report.pm +++ b/Koha/Report.pm @@ -20,6 +20,8 @@ use Modern::Perl; use Carp; use Koha::Database; +use JSON; +use Koha::Reports; use base qw(Koha::Object); @@ -33,6 +35,58 @@ Koha::Report - Koha Report Object class =cut +=head3 get_search_info + +Return search info + +=cut + +sub get_search_info { + my $self=shift; + my $sub_mana_info = { 'query' => shift }; + return $sub_mana_info; +} + +=head3 get_sharable_info + +Return properties that can be shared. + +=cut + +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; +} + +=head3 new_from_mana + +Clear a Mana report to be imported in Koha? + +=cut + +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; +} + =head3 _type Returns name of corresponding DBIC resultset diff --git a/Koha/Reports.pm b/Koha/Reports.pm index ca687a3..fc2be72 100644 --- a/Koha/Reports.pm +++ b/Koha/Reports.pm @@ -55,4 +55,10 @@ 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 5484596..197bfe3 100644 --- a/Koha/Subscription.pm +++ b/Koha/Subscription.pm @@ -116,6 +116,7 @@ sub remove_subscriber { =cut sub get_search_info { + my $self=shift; my $searched_sub_id = shift; my $biblio = Koha::Biblios->find( { 'biblionumber' => $searched_sub_id } ); my $biblioitem = @@ -131,6 +132,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 4af100e..6b13f4b 100644 --- a/etc/koha-conf.xml +++ b/etc/koha-conf.xml @@ -153,6 +153,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 b2b6900..8f69130 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -63,6 +63,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','0','','If ON, patron number is auto-calculated','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 8fc9058..84f798c 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -714,6 +714,12 @@ ol { 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) { 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 adcd376..1fd59c4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc @@ -7,11 +7,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 %] @@ -80,18 +80,16 @@ + + [% IF ( saved1 ) %] [% IF ( savedreports ) %]

Saved reports

@@ -169,6 +189,25 @@ canned reports and writing custom SQL reports.

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

[% savedreport.sql %]

@@ -204,23 +243,24 @@ canned reports and writing custom SQL reports.

[% FOREACH savedreport IN savedreports %] [% UNLESS ( loop.odd ) %][% ELSE %][% END %] - - - + - - + + - + @@ -267,6 +307,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
  • @@ -279,6 +322,7 @@ canned reports and writing custom SQL reports.

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

    [% END %] [% END %] + + [% IF ( build1 ) %] [% IF ( cache_error) %] @@ -1022,6 +1171,10 @@ canned reports and writing custom SQL reports.

    } } + function share() { + window.location="/cgi-bin/koha/reports/guided_reports.pl?phase=Save"; + } + $(document).ready(function(){ hide_bar_element(); @@ -1148,6 +1301,30 @@ canned reports and writing custom SQL reports.

    window.history.back(); }); + $(".mana_search_button").on("click",function(){ + mana_search($(this).prev().val()); + }); + + $(".ShareButton").on("click", function(){ + if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){ + $("#shared_infos").hide(); + $("#ManaShareButton").hide(); + $("#noterror").show(); + } + else{ + $("#shared_id").html($(this).closest("tr").find(".report_id").text()); + $("#shared_name").html($(this).closest("tr").find(".report_name").text()); + $("#shared_sql").html($(this).closest("tr").find(".report_sql").val()); + $("#shared_type").html($(this).closest("tr").find(".report_type").text()); + $("#shared_group").html($(this).closest("tr").find(".report_group").text()); + $("#shared_notes").html($(this).closest("tr").find(".report_notes").text()); + } + }); + + $('#search_form').submit(function () { + return false; + }); + $("#addColumn").on("click",function(){ addColumn(); }); @@ -1339,6 +1516,104 @@ canned reports and writing custom SQL reports.

    return confirmDelete(MSG_CONFIRM_DELETE); }); }); + function mana_increment(mana_id, resourcename, fieldvalue, stepvalue = 1){ + $.ajax( { + type: "POST", + url: "/cgi-bin/koha/svc/mana/addvaluetofield", + data: {id: mana_id, field: fieldvalue, resource: resourcename, step: stepvalue}, + datatype: "json", + }).done( function() { + }).fail( function(){ }); + } + + function mana_use( mana_id ){ + $.ajax( { + type:"POST", + url: "/cgi-bin/koha/svc/mana/use", + data: {id:mana_id, resource: 'report', saveinbase: 1}, + dataType: "json", + }) + .done( function (result){ + window.location = ("/cgi-bin/koha/reports/guided_reports.pl?reports=").concat(result.id).concat("&phase=Show%20SQL"); + }) + .fail( function ( foo, msg, longmsg){ + }); + } + + function mana_search( textquery ){ + $.ajax({ + type: "POST", + url: "/cgi-bin/koha/svc/mana/search", + data: {biblionumber: $("#biblionumber").val(), resource: 'report', id: textquery, usecomments: 1}, + dataType: "html", + }) + .done( function( result ) { + $("#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", + "autoWidth": false, + "columnDefs": [ + { "width": "35%", "targets": 1 } + ], + "aoColumnDefs": [ + { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, + { "sType": "title-string", "aTargets" : [ "title-string" ] }, + { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] } + ] + })); + if($("td.dataTables_empty").length == 0){ + $("#mana_search").show(); + } + + $( "select[class='actionreport1']" ).show(); + $( "button[class='actionreport2']" ).hide(); + $("#CommentButton").on("click", function(){ + var resource_type = "report"; + var target_id = $("#selected_id").val(); + var manamsg = $("#manamsg").val(); + mana_comment(target_id, manamsg, resource_type); + $("#comment_box").modal("hide"); + }); + + $(".showbutton").on("click", function(){ + $(this).parent().hide(); + $(this).parent().next().show(); + }); + + $("a[class='hidebutton']").on("click", function(){ + $(this).parent().hide(); + $(this).parent().prev().show(); + }); + + $("#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 addColumn() { $("#availableColumns option:selected").clone().appendTo("#selectedColumns").attr("selected", "selected"); } 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 3b3a32c..41a9f9c 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 @@ -10,7 +10,7 @@ @@ -214,8 +214,16 @@ fieldset.rows li.radio { width: 100%; } /* override staff-global.css */
    + [% IF ( Koha.Preference('Mana') == 2) %] +
    +

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

    +
    + [% END %] +
    @@ -500,18 +508,14 @@ fieldset.rows li.radio { width: 100%; } /* override staff-global.css */
    -