From 7e9e4574794a60833b2d984c30ab6b2e7ceccac1 Mon Sep 17 00:00:00 2001 From: Alex Arnaud <alex.arnaud@biblibre.com> Date: Tue, 16 Jan 2018 10:41:51 +0000 Subject: [PATCH] Bug 17047 - Fix template code in subscription-add.js Fix errors when saving a serial Provide a more visible message when sharing a report without note Fix Internal server error when trying to share a new report Make update DB idempotent Rebased-by: Alex Arnaud <alex.arnaud@biblibre.com> (2018-07-04) Signed-off-by: Michal Denar <black23@gmail.com> Signed-off-by: Michal Denar <black23@gmail.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> --- Koha/SharedContent.pm | 1 - .../atomicupdate/mana_01-add_mana_id.perl | 13 +++++++++ .../mana_01-add_mana_id_in_subscription.sql | 2 -- .../mana_03-add_mana_autoshare.sql | 2 +- .../atomicupdate/mana_04-add_mana_token.sql | 2 +- .../data/mysql/atomicupdate/skeleton.perl | 2 +- .../prog/en/includes/reports-toolbar.inc | 6 ---- .../prog/en/includes/serials-toolbar.inc | 2 +- .../modules/reports/guided_reports_start.tt | 29 +++++++++++++------ .../prog/en/modules/serials/serials-search.tt | 1 + .../en/modules/serials/subscription-add.tt | 2 ++ .../intranet-tmpl/prog/js/serials-toolbar.js | 3 ++ .../intranet-tmpl/prog/js/subscription-add.js | 4 +-- serials/subscription-add.pl | 4 +-- 14 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/mana_01-add_mana_id.perl delete mode 100644 installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm index ca484c1eac..a6b8584822 100644 --- a/Koha/SharedContent.pm +++ b/Koha/SharedContent.pm @@ -178,7 +178,6 @@ sub buildRequest { my $url = "$MANA_IP/$resource.json"; my $request = HTTP::Request->new( POST => $url ); - $content->{bulk_import} = 0; my $json = to_json( $content, { utf8 => 1 } ); $request->content($json); diff --git a/installer/data/mysql/atomicupdate/mana_01-add_mana_id.perl b/installer/data/mysql/atomicupdate/mana_01-add_mana_id.perl new file mode 100644 index 0000000000..1e5fdbd2b3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/mana_01-add_mana_id.perl @@ -0,0 +1,13 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + if( !column_exists( 'subscription', 'mana_id' ) ) { + $dbh->do( "ALTER TABLE subscription ADD mana_id int(11) NULL DEFAULT NULL" ); + } + + if( !column_exists( 'saved_sql', 'mana_id' ) ) { + $dbh->do( "ALTER TABLE saved_sql ADD mana_id int(11) NULL DEFAULT NULL" ); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 17047 - Add column mana_id in subscription and saved_sql tables)\n"; +} 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 deleted file mode 100644 index a7443dbb3e..0000000000 --- a/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE subscription ADD mana_id int(11) NULL DEFAULT NULL; -ALTER TABLE saved_sql ADD mana_id int(11) NULL DEFAULT NULL; diff --git a/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql b/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql index f5cc363b2a..a8b3519bcc 100644 --- a/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql +++ b/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql @@ -1,2 +1,2 @@ -INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('AutoShareWithMana','','','defines datas automatically shared with mana','multiple'); diff --git a/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql b/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql index 200f3e5e1b..3c94ccddd7 100644 --- a/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql +++ b/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql @@ -1,2 +1,2 @@ -INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('ManaToken','',NULL,'Security token used for authentication on Mana KB service (anti spam)','Textarea'); diff --git a/installer/data/mysql/atomicupdate/skeleton.perl b/installer/data/mysql/atomicupdate/skeleton.perl index 66e599c421..c63e6ebca7 100644 --- a/installer/data/mysql/atomicupdate/skeleton.perl +++ b/installer/data/mysql/atomicupdate/skeleton.perl @@ -1,4 +1,4 @@ -$DBversion = 'XXX'; # will be replaced by the RM +$DBversion = 'XXX'; if( CheckVersion( $DBversion ) ) { # you can use $dbh here like: # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc index bfb1e0fff8..41cdcbcab1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc @@ -139,12 +139,6 @@ [% END %] <script type="text/javascript"> - $(document).ready( function(){ - $(".mana_search_button").on("click",function(){ - mana_search($("#mana_search_field").val()); - }); - }); - function mana_use( mana_id ){ $.ajax( { type:"POST", 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 768fee390a..9d7fb0890e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc @@ -38,7 +38,7 @@ }); }); //]]> - </script> +</script> [% IF subscriptionid and ( CAN_user_serials_edit_subscription || CAN_user_serials_create_subscription || CAN_user_serials_delete_subscription || CAN_user_serials_receive_serials ) %] <div id="toolbar" class="btn-toolbar"> [% IF CAN_user_serials_create_subscription %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index d42eeab8e9..17d3ccba15 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -352,10 +352,12 @@ canned reports and writing custom SQL reports.</p> <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwise it will do nothing.</p> </div> [% END %] + <div id="note-error" class="alert alert-danger" role="alert"> + Please enter a report name and descriptive note before sharing (minimum 20 characters) + </div> [% IF ( languages_loop ) %] [% UNLESS ( one_language_enabled ) %] - <label id="noteerror" type="hidden">Please enter a report name and descriptive note before sharing (minimum 20 characters)</label> - <div id="shared_infos" class="rows"> + <div class="shared_infos rows"> <li> <span class="label">Id: </span><div id="shared_id"></div> </li> <li> <span class="label">Name: </span><div id="shared_name"></div> @@ -374,7 +376,7 @@ canned reports and writing custom SQL reports.</p> <form method="post" id="mana_share_form" action="/cgi-bin/koha/reports/guided_reports.pl?phase=Share" class="validated" > <input type="hidden" name="phase" value="Share"> - <fieldset> + <fieldset class="shared_infos"> <label for="mana_language">Language:</label> <select id="mana_language" name="mana_language"> [% FOREACH languages_loo IN languages_loop %] @@ -434,11 +436,11 @@ canned reports and writing custom SQL reports.</p> [% END %] </div> <div class="modal-footer"> - <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> + <button class="btn" id="ManaCloseButton" data-dismiss="modal" aria-hidden="true">Close</button> [% IF one_language_enabled==0 %] - <button id="ManaShareButton" type="submit" form="mana_share_form" class="btn btn-primary">Share</button> + <button id="ManaShareButton" type="submit" form="mana_share_form" class="btn btn-primary shared_infos">Share</button> [% ELSE %] - <div id="ManaShareButton" class="btn-group"><a class="btn btn-primary">Share</a></div> + <div id="ManaShareButton" class="btn-group"><a class="btn btn-primary shared_infos">Share</a></div> [% END %] </div> </div> @@ -1070,6 +1072,7 @@ canned reports and writing custom SQL reports.</p> [% Asset.js("lib/d3c3/d3.min.js") | $raw %] [% Asset.js("lib/d3c3/c3.min.js") | $raw %] [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'mana.inc' %] [% IF ( saved1 ) %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] @@ -1277,11 +1280,15 @@ canned reports and writing custom SQL reports.</p> window.history.back(); }); + $(".mana_search_button").on("click",function(){ + mana_search($("#mana_search_field").val()); + }); + $(".ShareButton").on("click", function(){ + $("#note-error").hide(); 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(); + $(".shared_infos").hide(); + $("#note-error").show(); } else{ $("#shared_id").html($(this).closest("tr").find(".report_id").text()); @@ -1293,6 +1300,10 @@ canned reports and writing custom SQL reports.</p> } }); + $("#ManaCloseButton").on("click", function() { + $(".shared_infos").show(); + }); + $("#addColumn").on("click",function(){ addColumn(); }); 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 00dd5420b1..adc7428749 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 @@ -421,6 +421,7 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'mana.inc' %] <script> var subscriptionid = "[% subscriptionid | html %]"; var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?"); 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 20740f57ec..a7bb4710ec 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 @@ -520,6 +520,7 @@ width: 300px; /* not enough for IE7 apparently */ [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'datatables.inc' %] <script type="text/javascript"> var subscriptionid = "[% subscriptionid | html %]"; var irregularity = "[% irregularity | html %]"; @@ -528,6 +529,7 @@ width: 300px; /* not enough for IE7 apparently */ [% FOREACH field IN dont_export_field_loop %] tags.push("[% field.fieldid | html %]"); [% END %] + var mana_enabled = [% Koha.Preference('Mana') %] var MSG_LINK_TO_VENDOR = _("If you wish to claim late or missing issues you must link this subscription to a vendor. Click OK to ignore or Cancel to return and enter a vendor"); var MSG_LINK_BIBLIO = _("You must choose or create a bibliographic record"); var MSG_REQUIRED_SUB_LENGTH = _("You must choose a subscription length or an end date."); diff --git a/koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js b/koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js index 1f181c2332..fe575d0071 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js +++ b/koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js @@ -40,4 +40,7 @@ function popup(subscriptionid) { popup( subscriptionid ); return false; }); + $("#mana-subscription-share").click(function() { + window.location="subscription-detail.pl?subscriptionid=[% subscriptionid %]&op=share"; + }); }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js index 0eb311b73f..39819952d5 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js +++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js @@ -617,9 +617,9 @@ $(document).ready(function() { }); $("#subscription_add_next").on("click",function(){ if ( Check_page1() ){ - [% IF Koha.Preference('Mana') == 1 %] + if ( mana_enabled ) { mana_search(); - [% END %] + } show_page_2(); } }); diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index a626863d67..1c5688c71e 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -305,7 +305,7 @@ sub redirect_add_subscription { )->store(); $periodicity = $subscription_freq->id; } - my $numberpattern = Koha::Subscription::Numberpatterns->new_or_existing($query->Vars); + my $numberpattern = Koha::Subscription::Numberpatterns->new_or_existing({ $query->Vars }); my $auser = $query->param('user'); my $branchcode = $query->param('branchcode'); @@ -412,7 +412,7 @@ sub redirect_mod_subscription { )->store(); $periodicity = $subscription_freq->id; } - my $numberpattern = Koha::Subscription::Numberpatterns->new_or_existing($query->Vars); + my $numberpattern = Koha::Subscription::Numberpatterns->new_or_existing({ $query->Vars }); my $subtype = $query->param('subtype'); my $sublength = $query->param('sublength'); -- 2.17.2 (Apple Git-113)