Bug 5354: Partial duplication of a subscription
authorJonathan Druart <jonathan.druart@biblibre.com>
Thu, 8 Mar 2012 09:45:32 +0000 (10:45 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Wed, 28 Mar 2012 13:51:23 +0000 (15:51 +0200)
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 <kristina@catalyst.net.nz>
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/serials.pref
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
serials/subscription-add.pl

index 9225c32..f8ab4ad 100755 (executable)
@@ -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)
index 1950ba6..7de32d9 100644 (file)
@@ -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
index f083428..6474b16 100644 (file)
@@ -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 %]
 });
 //]]>
 </script>
@@ -1333,7 +1343,7 @@ $(document).ready(function() {
                                        [% IF ( subtype_numberlength ) %]<option value="numberlength" selected="selected">[% ELSE %]<option value="numberlength">[% END %] Number of issues</option>                                    
                                        [% IF ( subtype_weeklength ) %]<option value="weeklength" selected="selected">[% ELSE %]<option value="weeklength">[% END %] Number of weeks</option>                                   
                 </select>
-                <input type="text" name="sublength" value="[% sublength %]" size="3" onkeypress="return check_input(event)" /> (enter amount in numerals)
+                <input type="text" id="numberlength" name="sublength" value="[% sublength %]" size="3" onkeypress="return check_input(event)" /> (enter amount in numerals)
             <span class="required">Required</span>
         </li>
         <li>
index 4038e1a..e4a9f7d 100755 (executable)
@@ -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') &&