|
Lines 69-75
BEGIN {
Link Here
|
| 69 |
&HasSubscriptionStrictlyExpired &HasSubscriptionExpired &GetExpirationDate &abouttoexpire |
69 |
&HasSubscriptionStrictlyExpired &HasSubscriptionExpired &GetExpirationDate &abouttoexpire |
| 70 |
&GetSubscriptionHistoryFromSubscriptionId |
70 |
&GetSubscriptionHistoryFromSubscriptionId |
| 71 |
|
71 |
|
| 72 |
&GetNextSeq &GetSeq &NewIssue &ItemizeSerials &GetSerials |
72 |
&GetNextSeq &GetSeq &NewIssue &GetSerials |
| 73 |
&GetLatestSerials &ModSerialStatus &GetNextDate &GetSerials2 |
73 |
&GetLatestSerials &ModSerialStatus &GetNextDate &GetSerials2 |
| 74 |
&ReNewSubscription &GetLateOrMissingIssues |
74 |
&ReNewSubscription &GetLateOrMissingIssues |
| 75 |
&GetSerialInformation &AddItem2Serial |
75 |
&GetSerialInformation &AddItem2Serial |
|
Lines 1588-1728
sub NewIssue {
Link Here
|
| 1588 |
return $serialid; |
1588 |
return $serialid; |
| 1589 |
} |
1589 |
} |
| 1590 |
|
1590 |
|
| 1591 |
=head2 ItemizeSerials |
|
|
| 1592 |
|
| 1593 |
ItemizeSerials($serialid, $info); |
| 1594 |
$info is a hashref containing barcode branch, itemcallnumber, status, location |
| 1595 |
$serialid the serialid |
| 1596 |
return : |
| 1597 |
1 if the itemize is a succes. |
| 1598 |
0 and @error otherwise. @error containts the list of errors found. |
| 1599 |
|
| 1600 |
=cut |
| 1601 |
|
| 1602 |
sub ItemizeSerials { |
| 1603 |
my ( $serialid, $info ) = @_; |
| 1604 |
|
| 1605 |
return unless ($serialid); |
| 1606 |
|
| 1607 |
my $now = POSIX::strftime( "%Y-%m-%d", localtime ); |
| 1608 |
|
| 1609 |
my $dbh = C4::Context->dbh; |
| 1610 |
my $query = qq| |
| 1611 |
SELECT * |
| 1612 |
FROM serial |
| 1613 |
WHERE serialid=? |
| 1614 |
|; |
| 1615 |
my $sth = $dbh->prepare($query); |
| 1616 |
$sth->execute($serialid); |
| 1617 |
my $data = $sth->fetchrow_hashref; |
| 1618 |
if ( C4::Context->preference("RoutingSerials") ) { |
| 1619 |
|
| 1620 |
# check for existing biblioitem relating to serial issue |
| 1621 |
my ( $count, @results ) = GetBiblioItemByBiblioNumber( $data->{'biblionumber'} ); |
| 1622 |
my $bibitemno = 0; |
| 1623 |
for ( my $i = 0 ; $i < $count ; $i++ ) { |
| 1624 |
if ( $results[$i]->{'volumeddesc'} eq $data->{'serialseq'} . ' (' . $data->{'planneddate'} . ')' ) { |
| 1625 |
$bibitemno = $results[$i]->{'biblioitemnumber'}; |
| 1626 |
last; |
| 1627 |
} |
| 1628 |
} |
| 1629 |
if ( $bibitemno == 0 ) { |
| 1630 |
my $sth = $dbh->prepare( "SELECT * FROM biblioitems WHERE biblionumber = ? ORDER BY biblioitemnumber DESC" ); |
| 1631 |
$sth->execute( $data->{'biblionumber'} ); |
| 1632 |
my $biblioitem = $sth->fetchrow_hashref; |
| 1633 |
$biblioitem->{'volumedate'} = $data->{planneddate}; |
| 1634 |
$biblioitem->{'volumeddesc'} = $data->{serialseq} . ' (' . format_date( $data->{'planneddate'} ) . ')'; |
| 1635 |
$biblioitem->{'dewey'} = $info->{itemcallnumber}; |
| 1636 |
} |
| 1637 |
} |
| 1638 |
|
| 1639 |
my $fwk = GetFrameworkCode( $data->{'biblionumber'} ); |
| 1640 |
if ( $info->{barcode} ) { |
| 1641 |
my @errors; |
| 1642 |
if ( is_barcode_in_use( $info->{barcode} ) ) { |
| 1643 |
push @errors, 'barcode_not_unique'; |
| 1644 |
} else { |
| 1645 |
my $marcrecord = MARC::Record->new(); |
| 1646 |
my ( $tag, $subfield ) = GetMarcFromKohaField( "items.barcode", $fwk ); |
| 1647 |
my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{barcode} ); |
| 1648 |
$marcrecord->insert_fields_ordered($newField); |
| 1649 |
if ( $info->{branch} ) { |
| 1650 |
my ( $tag, $subfield ) = GetMarcFromKohaField( "items.homebranch", $fwk ); |
| 1651 |
|
| 1652 |
#warn "items.homebranch : $tag , $subfield"; |
| 1653 |
if ( $marcrecord->field($tag) ) { |
| 1654 |
$marcrecord->field($tag)->add_subfields( "$subfield" => $info->{branch} ); |
| 1655 |
} else { |
| 1656 |
my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{branch} ); |
| 1657 |
$marcrecord->insert_fields_ordered($newField); |
| 1658 |
} |
| 1659 |
( $tag, $subfield ) = GetMarcFromKohaField( "items.holdingbranch", $fwk ); |
| 1660 |
|
| 1661 |
#warn "items.holdingbranch : $tag , $subfield"; |
| 1662 |
if ( $marcrecord->field($tag) ) { |
| 1663 |
$marcrecord->field($tag)->add_subfields( "$subfield" => $info->{branch} ); |
| 1664 |
} else { |
| 1665 |
my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{branch} ); |
| 1666 |
$marcrecord->insert_fields_ordered($newField); |
| 1667 |
} |
| 1668 |
} |
| 1669 |
if ( $info->{itemcallnumber} ) { |
| 1670 |
my ( $tag, $subfield ) = GetMarcFromKohaField( "items.itemcallnumber", $fwk ); |
| 1671 |
|
| 1672 |
if ( $marcrecord->field($tag) ) { |
| 1673 |
$marcrecord->field($tag)->add_subfields( "$subfield" => $info->{itemcallnumber} ); |
| 1674 |
} else { |
| 1675 |
my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{itemcallnumber} ); |
| 1676 |
$marcrecord->insert_fields_ordered($newField); |
| 1677 |
} |
| 1678 |
} |
| 1679 |
if ( $info->{notes} ) { |
| 1680 |
my ( $tag, $subfield ) = GetMarcFromKohaField( "items.itemnotes", $fwk ); |
| 1681 |
|
| 1682 |
if ( $marcrecord->field($tag) ) { |
| 1683 |
$marcrecord->field($tag)->add_subfields( "$subfield" => $info->{notes} ); |
| 1684 |
} else { |
| 1685 |
my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{notes} ); |
| 1686 |
$marcrecord->insert_fields_ordered($newField); |
| 1687 |
} |
| 1688 |
} |
| 1689 |
if ( $info->{location} ) { |
| 1690 |
my ( $tag, $subfield ) = GetMarcFromKohaField( "items.location", $fwk ); |
| 1691 |
|
| 1692 |
if ( $marcrecord->field($tag) ) { |
| 1693 |
$marcrecord->field($tag)->add_subfields( "$subfield" => $info->{location} ); |
| 1694 |
} else { |
| 1695 |
my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{location} ); |
| 1696 |
$marcrecord->insert_fields_ordered($newField); |
| 1697 |
} |
| 1698 |
} |
| 1699 |
if ( $info->{status} ) { |
| 1700 |
my ( $tag, $subfield ) = GetMarcFromKohaField( "items.notforloan", $fwk ); |
| 1701 |
|
| 1702 |
if ( $marcrecord->field($tag) ) { |
| 1703 |
$marcrecord->field($tag)->add_subfields( "$subfield" => $info->{status} ); |
| 1704 |
} else { |
| 1705 |
my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{status} ); |
| 1706 |
$marcrecord->insert_fields_ordered($newField); |
| 1707 |
} |
| 1708 |
} |
| 1709 |
if ( C4::Context->preference("RoutingSerials") ) { |
| 1710 |
my ( $tag, $subfield ) = GetMarcFromKohaField( "items.dateaccessioned", $fwk ); |
| 1711 |
if ( $marcrecord->field($tag) ) { |
| 1712 |
$marcrecord->field($tag)->add_subfields( "$subfield" => $now ); |
| 1713 |
} else { |
| 1714 |
my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $now ); |
| 1715 |
$marcrecord->insert_fields_ordered($newField); |
| 1716 |
} |
| 1717 |
} |
| 1718 |
require C4::Items; |
| 1719 |
C4::Items::AddItemFromMarc( $marcrecord, $data->{'biblionumber'} ); |
| 1720 |
return 1; |
| 1721 |
} |
| 1722 |
return ( 0, @errors ); |
| 1723 |
} |
| 1724 |
} |
| 1725 |
|
| 1726 |
=head2 HasSubscriptionStrictlyExpired |
1591 |
=head2 HasSubscriptionStrictlyExpired |
| 1727 |
|
1592 |
|
| 1728 |
1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid) |
1593 |
1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid) |