@@ -, +, @@ fixes --- C4/Serials.pm | 70 +++++++++++++++------- Koha/Schema/Result/Subscription.pm | 12 +++- ...8_-_add_pubdatepatternformat_column_serial.perl | 8 +++ .../prog/en/modules/serials/subscription-add.tt | 37 +++++++++++- .../prog/en/modules/serials/subscription-detail.tt | 2 +- .../intranet-tmpl/prog/js/subscription-add.js | 12 +++- serials/serials-collection.pl | 17 ++++-- serials/showpredictionpattern.pl | 22 ++++++- serials/subscription-add.pl | 7 ++- serials/subscription-detail.pl | 2 + 10 files changed, 151 insertions(+), 38 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_22188_-_add_pubdatepatternformat_column_serial.perl --- a/C4/Serials.pm +++ a/C4/Serials.pm @@ -865,8 +865,17 @@ sub GetNextSeq { my $calculated = ""; my $numberingmethod = ""; + my $dateformat = $subscription->{pubdatepatternformat}; if ($pattern eq "pubdate"){ - $calculated = dt_from_string( $planneddate )->strftime( '%Y %B %d' ); + if ( $dateformat eq 'dmy' ){ + $calculated = dt_from_string( $planneddate )->strftime( '%d %B %Y' ); + } elsif ( $dateformat eq 'mdy' ){ + $calculated = dt_from_string( $planneddate )->strftime( '%B %d %Y' ); + } elsif ( $dateformat eq 'ydm' ){ + $calculated = dt_from_string( $planneddate )->strftime( '%Y %d %B' ); + } else { + $calculated = dt_from_string( $planneddate )->strftime( '%Y %B %d' ); + } } else { $numberingmethod = $pattern->{numberingmethod}; } @@ -1161,26 +1170,19 @@ sub ModSerialStatus { my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern}); my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity}); - my $nextpublisheddate = GetNextDate($subscription, $publisheddate, 1); + my $nextpublisheddate = GetNextDate($subscription, $publisheddate, $frequency); my ( $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3 ); + # next issue number if (!defined $pattern){ $pattern = "pubdate"; - ( $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, - $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $nextpublisheddate ); + $newserialseq = "pubdate"; } else { ( $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, $newinnerloop1, $newinnerloop2, $newinnerloop3 ) = GetNextSeq( $subscription, $pattern, $publisheddate ); } - # next issue number - my ( - $newserialseq, $newlastvalue1, $newlastvalue2, $newlastvalue3, - $newinnerloop1, $newinnerloop2, $newinnerloop3 - ) - = GetNextSeq( $subscription, $pattern, $frequency, $publisheddate ); - # next date (calculated from actual date & frequency parameters) my $nextpubdate = $nextpublisheddate; $query = "UPDATE subscription SET lastvalue1=?, lastvalue2=?, lastvalue3=?, innerloop1=?, innerloop2=?, innerloop3=? @@ -1329,7 +1331,7 @@ sub ModSubscription { $biblionumber, $callnumber, $notes, $letter, $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, - $itemtype, $previousitemtype, $mana_id + $itemtype, $previousitemtype, $mana_id, $dateformat ) = @_; my $dbh = C4::Context->dbh; @@ -1342,9 +1344,9 @@ sub ModSubscription { callnumber=?, notes=?, letter=?, manualhistory=?, internalnotes=?, serialsadditems=?, staffdisplaycount=?, opacdisplaycount=?, graceperiod=?, location = ?, enddate=?, - skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=? + skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=?, + pubdatepatternformat=? WHERE subscriptionid = ?"; - my $sth = $dbh->prepare($query); $sth->execute( $auser, $branchcode, $aqbooksellerid, $cost, @@ -1356,7 +1358,7 @@ sub ModSubscription { $letter, ($manualhistory ? $manualhistory : 0), $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq, - $itemtype, $previousitemtype, $mana_id, + $itemtype, $previousitemtype, $mana_id, $dateformat, $subscriptionid ); my $rows = $sth->rows; @@ -1373,7 +1375,7 @@ $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, - $skip_serialseq, $itemtype, $previousitemtype); + $skip_serialseq, $itemtype, $previousitemtype, $dateformat); Create a new subscription with value given on input args. @@ -1390,7 +1392,8 @@ sub NewSubscription { $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, - $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id + $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, + $dateformat ) = @_; my $dbh = C4::Context->dbh; @@ -1404,8 +1407,8 @@ sub NewSubscription { irregularity, numberpattern, locale, callnumber, manualhistory, internalnotes, serialsadditems, staffdisplaycount, opacdisplaycount, graceperiod, location, enddate, skip_serialseq, - itemtype, previousitemtype, mana_id) - VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?) + itemtype, previousitemtype, mana_id, pubdatepatternformat) + VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |; my $sth = $dbh->prepare($query); $sth->execute( @@ -1416,7 +1419,7 @@ sub NewSubscription { $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq, - $itemtype, $previousitemtype, $mana_id + $itemtype, $previousitemtype, $mana_id, $dateformat ); my $subscriptionid = $dbh->{'mysql_insertid'}; @@ -1447,8 +1450,17 @@ sub NewSubscription { # calculate issue number my $serialseq = GetSeq($subscription, $pattern) || q{}; + $dateformat //= ''; if ($serialseq eq "pubdate"){ - $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d'); + if ( $dateformat eq 'dmy' ){ + $serialseq = dt_from_string( $firstacquidate )->strftime('%d %B %Y'); + } elsif ( $dateformat eq 'mdy' ){ + $serialseq = dt_from_string( $firstacquidate )->strftime('%B %d %Y'); + } elsif ( $dateformat eq 'ydm' ){ + $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %d %B'); + } else { + $serialseq = dt_from_string( $firstacquidate )->strftime('%Y %B %d'); + } } Koha::Serial->new( @@ -1542,7 +1554,7 @@ sub ReNewSubscription { =head2 NewIssue -NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes) +NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $planneddate, $publisheddate, $notes) Create a new issue stored on the database. Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription. @@ -1561,6 +1573,19 @@ sub NewIssue { my $subscription = Koha::Subscriptions->find( $subscriptionid ); + my $dateformat = $subscription->pubdatepatternformat; + if ($serialseq eq "pubdate"){ + if ( $dateformat eq 'dmy' ){ + $serialseq = dt_from_string( $publisheddate )->strftime('%d %B %Y'); + } elsif ( $dateformat eq 'mdy' ){ + $serialseq = dt_from_string( $publisheddate )->strftime('%B %d %Y'); + } elsif ( $dateformat eq 'ydm' ){ + $serialseq = dt_from_string( $publisheddate )->strftime('%Y %d %B'); + } else { + $serialseq = dt_from_string( $publisheddate )->strftime('%Y %B %d'); + } + } + my $serial = Koha::Serial->new( { serialseq => $serialseq, @@ -2340,7 +2365,6 @@ sub GetNextDate { return unless $subscription and $publisheddate; - if ($freqdata->{'unit'}) { my ( $year, $month, $day ) = split /-/, $publisheddate; --- a/Koha/Schema/Result/Subscription.pm +++ a/Koha/Schema/Result/Subscription.pm @@ -276,6 +276,12 @@ __PACKAGE__->table("subscription"); data_type: 'integer' is_nullable: 1 +=head2 pubdatepatternformat + + data_type: 'varchar' + is_nullable: 1 + size: 3 + =cut __PACKAGE__->add_columns( @@ -365,6 +371,8 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 10 }, "mana_id", { data_type => "integer", is_nullable => 1 }, + "pubdatepatternformat", + { data_type => "varchar", is_nullable => 1, size => 3 }, ); =head1 PRIMARY KEY @@ -452,8 +460,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-01-23 12:56:39 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dTb/JOO3KQ3NZGypFbRiEw +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2019-02-28 22:06:40 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xfL68dHECH0R31U1uCTJtA __PACKAGE__->has_many( "additional_field_values", --- a/installer/data/mysql/atomicupdate/bug_22188_-_add_pubdatepatternformat_column_serial.perl +++ a/installer/data/mysql/atomicupdate/bug_22188_-_add_pubdatepatternformat_column_serial.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + unless( column_exists( 'subscription', 'pubdatepatternformat' ) ) { + $dbh->do(q|ALTER TABLE subscription ADD pubdatepatternformat varchar(3) default NULL AFTER mana_id|); + } + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 22188: Add column subscription.pubdatepatternformat)\n"; +} --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -304,9 +304,15 @@ fieldset.rows li.radio { width: 100%; } /* override staff-global.css */