From 5167e8034d45c5cded23812c8c7669889e3e952f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 8 Mar 2012 10:45:32 +0100 Subject: [PATCH] Bug 5354: Partial duplication of a subscription A new syspref (SubscriptionDuplicateDroppedInput) contains the list of fields to duplicate when duplicating a subscription. The library will be able to define that, for example, the internal note should not be duplicated Test plan: On the detail subscription page, click Edit > Edit as New (Duplicate): All the information must be copied from the original subscription. Fill the syspref SubscriptionDuplicateDroppedInput with a list of fields you don't want to be duplicated (e.g. location;notes;branchcode). Repeat the duplicate action. Normally, information for these fields are not copied. Signed-off-by: Kristina D.C. Hoeppner --- installer/data/mysql/updatedatabase.pl | 9 +++++++++ .../prog/en/modules/admin/preferences/serials.pref | 3 +++ .../prog/en/modules/serials/subscription-add.tt | 12 +++++++++++- serials/subscription-add.pl | 6 ++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 9225c32a3e..f8ab4ad443 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5086,6 +5086,15 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } + + +$DBversion = "3.07.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by semicolon)','Free')"); + print "Upgrade to $DBversion done (Add System Preferences SubscriptionDuplicateDroppedInput)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref index 1950ba6161..7de32d99fc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref @@ -47,3 +47,6 @@ Serials: simplified: a summary full: a full list - of the serial issues. + - + - List of fields which must not be rewritten when a subscription is duplicated (Separated by semicolon) + - pref: SubscriptionDuplicateDroppedInput 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 f0834284c4..6474b165ad 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 @@ -944,6 +944,16 @@ $(document).ready(function() { $('#numberpattern').change( function() { reset_num_pattern(); }); + + var node; + [% FOREACH field IN dont_export_field_loop %] + node = $("#[% field.fieldid %]"); + if ( $(node).is('input') || $(node).is('textarea') ) { + $(node).val(""); + } else if ( $(node).is('select') ) { + $(node).find("option:first").attr('selected','selected'); + } + [% END %] }); //]]> @@ -1333,7 +1343,7 @@ $(document).ready(function() { [% IF ( subtype_numberlength ) %] [% IF ( subtype_weeklength ) %] - (enter amount in numerals) + (enter amount in numerals) Required
  • diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 4038e1a2cf..e4a9f7df2b 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -112,6 +112,12 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { firstacquiyear => substr($firstissuedate,0,4), ); } + + if ( $op eq 'dup' ) { + my $dont_copy_fields = C4::Context->preference('SubscriptionDuplicateDroppedInput'); + my @fields_id = map { fieldid => $_ }, split ';', $dont_copy_fields; + $template->param( dont_export_field_loop => \@fields_id ); + } } my $onlymine=C4::Context->preference('IndependantBranches') && -- 2.39.5