[Koha-patches] [PATCH] Bug 5022 Supplements were not saved correctly

Colin Campbell colin.campbell at ptfs-europe.com
Wed Jul 21 11:29:49 CEST 2010


No subscription id was set
Also entered a default arrived date on the supplement
And removed errors due to bad dates returned from GetSerials
---
 C4/Serials.pm                                      |   19 +++++++++++++++----
 .../prog/en/modules/serials/serials-edit.tmpl      |    8 ++++++--
 serials/serials-edit.pl                            |   16 ++++++++++++----
 3 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/C4/Serials.pm b/C4/Serials.pm
index 032246c..55eb6f7 100644
--- a/C4/Serials.pm
+++ b/C4/Serials.pm
@@ -659,8 +659,13 @@ sub GetSerials {
 
     while ( my $line = $sth->fetchrow_hashref ) {
         $line->{ "status" . $line->{status} } = 1;                                         # fills a "statusX" value, used for template status select list
-        $line->{"publisheddate"}              = format_date( $line->{"publisheddate"} );
-        $line->{"planneddate"}                = format_date( $line->{"planneddate"} );
+        for my $datefield ( qw( planneddate publisheddate) ) {
+            if ($line->{$datefield} && $line->{$datefield}!~m/^00/) {
+                $line->{$datefield} = format_date( $line->{$datefield});
+            } else {
+                $line->{$datefield} = q{};
+            }
+        }
         push @serials, $line;
     }
 
@@ -676,8 +681,14 @@ sub GetSerials {
     while ( ( my $line = $sth->fetchrow_hashref ) && $counter < $count ) {
         $counter++;
         $line->{ "status" . $line->{status} } = 1;                                         # fills a "statusX" value, used for template status select list
-        $line->{"planneddate"}                = format_date( $line->{"planneddate"} );
-        $line->{"publisheddate"}              = format_date( $line->{"publisheddate"} );
+        for my $datefield ( qw( planneddate publisheddate) ) {
+            if ($line->{$datefield} && $line->{$datefield}!~m/^00/) {
+                $line->{$datefield} = format_date( $line->{$datefield});
+            } else {
+                $line->{$datefield} = q{};
+            }
+        }
+
         push @serials, $line;
     }
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl
index 8805654..c2b724b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl
@@ -88,6 +88,10 @@ function changeDate(adate) {
     var elem = document.getElementById("expecteddate");
     elem.value = adate;
 }
+function changeDate2(adate) {
+   var elem = document.getElementById("supexpecteddate");
+    elem.value = adate;
+}
 function CloneSubfield(index){
     var original = document.getElementById(index); //original <div>
     var clone = original.cloneNode(true);
@@ -331,10 +335,10 @@ function CloneSubfield(index){
             <input type="text" name="publisheddate" value="<!-- TMPL_VAR name="publisheddate" -->" size="10" maxlength="15" />
         </td>
         <td>
-            <input type="text" name="planneddate" value="<!-- TMPL_VAR name="planneddate" -->" size="10" maxlength="15" />
+            <input type="text" name="planneddate" id="supexpecteddate" value="<!-- TMPL_VAR name="planneddate" -->" size="10" maxlength="15" />
         </td>
         <td>
-            <select name="status" size="1" id="addstatus<!-- TMPL_VAR NAME="serialid" -->">
+            <select name="status" size="1" id="addstatus<!-- TMPL_VAR NAME="serialid" -->" onchange="if (this.value==2 || this.value==7){changeDate2('<!-- TMPL_VAR NAME="arriveddate" -->')} else {changeDate2('<!-- TMPL_VAR NAME="planneddate" -->')}" >
                     <option value="">----</option>
   <!--TMPL_IF name="status1" -->
                     <option value="1" selected="selected">Expected</option>
diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl
index dee624c..6357fc7 100755
--- a/serials/serials-edit.pl
+++ b/serials/serials-edit.pl
@@ -19,7 +19,7 @@
 
 =head1 NAME
 
-serials-recieve.pl
+serials-edit.pl
 
 =head1 Parameters
 
@@ -133,8 +133,14 @@ foreach my $tmpserialid (@serialids) {
         && !$processedserialid{$tmpserialid} )
     {
         my $data = GetSerialInformation($tmpserialid);
-        $data->{publisheddate} = format_date( $data->{publisheddate} );
-        $data->{planneddate}   = format_date( $data->{planneddate} );
+        for my $datefield ( qw( publisheddate planneddate) ) {
+            if ($data->{$datefield} && $data->{$datefield}!~m/^00/) {
+                $data->{$datefield} = format_date( $data->{$datefield} );
+            }
+            else {
+                $data->{$datefield} = q{};
+            }
+        }
         $data->{arriveddate}=$today->output('syspref');
         $data->{'editdisable'} = (
             (
@@ -173,6 +179,8 @@ foreach my $subscriptionid (@subscriptionids) {
         $cell->{'itemid'}         = "NNEW";
         $cell->{'serialid'}       = "NEW";
         $cell->{'issuesatonce'}   = 1;
+        $cell->{arriveddate}=$today->output('syspref');
+
         push @newserialloop, $cell;
         push @subscriptionloop,
           {
@@ -198,7 +206,7 @@ if ( $op and $op eq 'serialchangestatus' ) {
                 ### FIXME if NewIssue is modified to use subscription biblionumber, then biblionumber would not be useful.
                 $newserial = NewIssue(
                     $serialseqs[$i],
-                    $subscriptionids[$i],
+                    $subscriptionids[0],
                     $serialdatalist[0]->{'biblionumber'},
                     $status[$i],
                     format_date_in_iso( $planneddates[$i] ),
-- 
1.7.1.1



More information about the Koha-patches mailing list