&HasSubscriptionStrictlyExpired &HasSubscriptionExpired &GetExpirationDate &abouttoexpire
&GetSubscriptionHistoryFromSubscriptionId
- &GetNextSeq &GetSeq &NewIssue &ItemizeSerials &GetSerials
+ &GetNextSeq &GetSeq &NewIssue &GetSerials
&GetLatestSerials &ModSerialStatus &GetNextDate &GetSerials2
&ReNewSubscription &GetLateOrMissingIssues
&GetSerialInformation &AddItem2Serial
return $serialid;
}
-=head2 ItemizeSerials
-
-ItemizeSerials($serialid, $info);
-$info is a hashref containing barcode branch, itemcallnumber, status, location
-$serialid the serialid
-return :
-1 if the itemize is a succes.
-0 and @error otherwise. @error containts the list of errors found.
-
-=cut
-
-sub ItemizeSerials {
- my ( $serialid, $info ) = @_;
-
- return unless ($serialid);
-
- my $now = POSIX::strftime( "%Y-%m-%d", localtime );
-
- my $dbh = C4::Context->dbh;
- my $query = qq|
- SELECT *
- FROM serial
- WHERE serialid=?
- |;
- my $sth = $dbh->prepare($query);
- $sth->execute($serialid);
- my $data = $sth->fetchrow_hashref;
- if ( C4::Context->preference("RoutingSerials") ) {
-
- # check for existing biblioitem relating to serial issue
- my ( $count, @results ) = GetBiblioItemByBiblioNumber( $data->{'biblionumber'} );
- my $bibitemno = 0;
- for ( my $i = 0 ; $i < $count ; $i++ ) {
- if ( $results[$i]->{'volumeddesc'} eq $data->{'serialseq'} . ' (' . $data->{'planneddate'} . ')' ) {
- $bibitemno = $results[$i]->{'biblioitemnumber'};
- last;
- }
- }
- if ( $bibitemno == 0 ) {
- my $sth = $dbh->prepare( "SELECT * FROM biblioitems WHERE biblionumber = ? ORDER BY biblioitemnumber DESC" );
- $sth->execute( $data->{'biblionumber'} );
- my $biblioitem = $sth->fetchrow_hashref;
- $biblioitem->{'volumedate'} = $data->{planneddate};
- $biblioitem->{'volumeddesc'} = $data->{serialseq} . ' (' . format_date( $data->{'planneddate'} ) . ')';
- $biblioitem->{'dewey'} = $info->{itemcallnumber};
- }
- }
-
- my $fwk = GetFrameworkCode( $data->{'biblionumber'} );
- if ( $info->{barcode} ) {
- my @errors;
- if ( is_barcode_in_use( $info->{barcode} ) ) {
- push @errors, 'barcode_not_unique';
- } else {
- my $marcrecord = MARC::Record->new();
- my ( $tag, $subfield ) = GetMarcFromKohaField( "items.barcode", $fwk );
- my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{barcode} );
- $marcrecord->insert_fields_ordered($newField);
- if ( $info->{branch} ) {
- my ( $tag, $subfield ) = GetMarcFromKohaField( "items.homebranch", $fwk );
-
- #warn "items.homebranch : $tag , $subfield";
- if ( $marcrecord->field($tag) ) {
- $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{branch} );
- } else {
- my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{branch} );
- $marcrecord->insert_fields_ordered($newField);
- }
- ( $tag, $subfield ) = GetMarcFromKohaField( "items.holdingbranch", $fwk );
-
- #warn "items.holdingbranch : $tag , $subfield";
- if ( $marcrecord->field($tag) ) {
- $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{branch} );
- } else {
- my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{branch} );
- $marcrecord->insert_fields_ordered($newField);
- }
- }
- if ( $info->{itemcallnumber} ) {
- my ( $tag, $subfield ) = GetMarcFromKohaField( "items.itemcallnumber", $fwk );
-
- if ( $marcrecord->field($tag) ) {
- $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{itemcallnumber} );
- } else {
- my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{itemcallnumber} );
- $marcrecord->insert_fields_ordered($newField);
- }
- }
- if ( $info->{notes} ) {
- my ( $tag, $subfield ) = GetMarcFromKohaField( "items.itemnotes", $fwk );
-
- if ( $marcrecord->field($tag) ) {
- $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{notes} );
- } else {
- my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{notes} );
- $marcrecord->insert_fields_ordered($newField);
- }
- }
- if ( $info->{location} ) {
- my ( $tag, $subfield ) = GetMarcFromKohaField( "items.location", $fwk );
-
- if ( $marcrecord->field($tag) ) {
- $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{location} );
- } else {
- my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{location} );
- $marcrecord->insert_fields_ordered($newField);
- }
- }
- if ( $info->{status} ) {
- my ( $tag, $subfield ) = GetMarcFromKohaField( "items.notforloan", $fwk );
-
- if ( $marcrecord->field($tag) ) {
- $marcrecord->field($tag)->add_subfields( "$subfield" => $info->{status} );
- } else {
- my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{status} );
- $marcrecord->insert_fields_ordered($newField);
- }
- }
- if ( C4::Context->preference("RoutingSerials") ) {
- my ( $tag, $subfield ) = GetMarcFromKohaField( "items.dateaccessioned", $fwk );
- if ( $marcrecord->field($tag) ) {
- $marcrecord->field($tag)->add_subfields( "$subfield" => $now );
- } else {
- my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $now );
- $marcrecord->insert_fields_ordered($newField);
- }
- }
- require C4::Items;
- C4::Items::AddItemFromMarc( $marcrecord, $data->{'biblionumber'} );
- return 1;
- }
- return ( 0, @errors );
- }
-}
-
=head2 HasSubscriptionStrictlyExpired
1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid)