View | Details | Raw Unified | Return to bug 19687
Collapse All | Expand All

(-)a/C4/Biblio.pm (-87 / +60 lines)
Lines 20-25 package C4::Biblio; Link Here
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
21
22
use Modern::Perl;
22
use Modern::Perl;
23
24
use vars qw(@ISA @EXPORT);
25
BEGIN {
26
    require Exporter;
27
    @ISA = qw(Exporter);
28
29
    @EXPORT = qw(
30
        AddBiblio
31
        GetBiblioData
32
        GetMarcBiblio
33
        GetRecordValue
34
        GetISBDView
35
        GetMarcControlnumber
36
        GetMarcNotes
37
        GetMarcISBN
38
        GetMarcISSN
39
        GetMarcSubjects
40
        GetMarcAuthors
41
        GetMarcSeries
42
        GetMarcHosts
43
        GetMarcUrls
44
        GetUsedMarcStructure
45
        GetXmlBiblio
46
        GetCOinSBiblio
47
        GetMarcPrice
48
        MungeMarcPrice
49
        GetMarcQuantity
50
        GetAuthorisedValueDesc
51
        GetMarcStructure
52
        IsMarcStructureInternal
53
        GetMarcFromKohaField
54
        GetMarcSubfieldStructureFromKohaField
55
        GetFrameworkCode
56
        TransformKohaToMarc
57
        PrepHostMarcField
58
        CountItemsIssued
59
        CountBiblioInOrders
60
        ModBiblio
61
        ModZebra
62
        UpdateTotalIssues
63
        RemoveAllNsb
64
        DelBiblio
65
        BiblioAutoLink
66
        LinkBibHeadingsToAuthorities
67
        TransformMarcToKoha
68
        TransformHtmlToMarc
69
        TransformHtmlToXml
70
        prepare_host_field
71
    );
72
73
    # Internal functions
74
    # those functions are exported but should not be used
75
    # they are useful in a few circumstances, so they are exported,
76
    # but don't use them unless you are a core developer ;-)
77
    push @EXPORT, qw(
78
      ModBiblioMarc
79
    );
80
}
81
23
use Carp;
82
use Carp;
24
83
25
use Encode qw( decode is_utf8 );
84
use Encode qw( decode is_utf8 );
Lines 49-142 use Koha::ItemTypes; Link Here
49
use Koha::SearchEngine;
108
use Koha::SearchEngine;
50
use Koha::Libraries;
109
use Koha::Libraries;
51
110
52
use vars qw(@ISA @EXPORT);
53
use vars qw($debug $cgi_debug);
111
use vars qw($debug $cgi_debug);
54
112
55
BEGIN {
56
57
    require Exporter;
58
    @ISA = qw( Exporter );
59
60
    # to add biblios
61
    # EXPORTED FUNCTIONS.
62
    push @EXPORT, qw(
63
      &AddBiblio
64
    );
65
66
    # to get something
67
    push @EXPORT, qw(
68
      GetBiblioData
69
      GetMarcBiblio
70
71
      &GetRecordValue
72
73
      &GetISBDView
74
75
      &GetMarcControlnumber
76
      &GetMarcNotes
77
      &GetMarcISBN
78
      &GetMarcISSN
79
      &GetMarcSubjects
80
      &GetMarcAuthors
81
      &GetMarcSeries
82
      &GetMarcHosts
83
      GetMarcUrls
84
      &GetUsedMarcStructure
85
      &GetXmlBiblio
86
      &GetCOinSBiblio
87
      &GetMarcPrice
88
      &MungeMarcPrice
89
      &GetMarcQuantity
90
91
      &GetAuthorisedValueDesc
92
      &GetMarcStructure
93
      &IsMarcStructureInternal
94
      &GetMarcFromKohaField
95
      &GetMarcSubfieldStructureFromKohaField
96
      &GetFrameworkCode
97
      &TransformKohaToMarc
98
      &PrepHostMarcField
99
100
      &CountItemsIssued
101
      &CountBiblioInOrders
102
    );
103
104
    # To modify something
105
    push @EXPORT, qw(
106
      &ModBiblio
107
      &ModZebra
108
      &UpdateTotalIssues
109
      &RemoveAllNsb
110
    );
111
112
    # To delete something
113
    push @EXPORT, qw(
114
      &DelBiblio
115
    );
116
117
    # To link headings in a bib record
118
    # to authority records.
119
    push @EXPORT, qw(
120
      &BiblioAutoLink
121
      &LinkBibHeadingsToAuthorities
122
    );
123
124
    # Internal functions
125
    # those functions are exported but should not be used
126
    # they are useful in a few circumstances, so they are exported,
127
    # but don't use them unless you are a core developer ;-)
128
    push @EXPORT, qw(
129
      &ModBiblioMarc
130
    );
131
132
    # Others functions
133
    push @EXPORT, qw(
134
      &TransformMarcToKoha
135
      &TransformHtmlToMarc
136
      &TransformHtmlToXml
137
      prepare_host_field
138
    );
139
}
140
113
141
=head1 NAME
114
=head1 NAME
142
115
Lines 743-749 sub GetISBDView { Link Here
743
    my $framework = $params->{framework};
716
    my $framework = $params->{framework};
744
    my $itemtype  = $framework;
717
    my $itemtype  = $framework;
745
    my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype );
718
    my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype );
746
    my $tagslib = &GetMarcStructure( 1, $itemtype, { unsafe => 1 } );
719
    my $tagslib = GetMarcStructure( 1, $itemtype, { unsafe => 1 } );
747
720
748
    my $ISBD = C4::Context->preference($sysprefname);
721
    my $ISBD = C4::Context->preference($sysprefname);
749
    my $bloc = $ISBD;
722
    my $bloc = $ISBD;
(-)a/C4/Items.pm (-51 / +40 lines)
Lines 21-97 package C4::Items; Link Here
21
use strict;
21
use strict;
22
#use warnings; FIXME - Bug 2505
22
#use warnings; FIXME - Bug 2505
23
23
24
use Carp;
25
use C4::Context;
26
use C4::Koha;
27
use C4::Biblio;
28
use Koha::DateUtils;
29
use MARC::Record;
30
use C4::ClassSource;
31
use C4::Log;
32
use List::MoreUtils qw/any/;
33
use YAML qw/Load/;
34
use DateTime::Format::MySQL;
35
use Data::Dumper; # used as part of logging item record changes, not just for
36
                  # debugging; so please don't remove this
37
38
use Koha::AuthorisedValues;
39
use Koha::DateUtils qw/dt_from_string/;
40
use Koha::Database;
41
42
use Koha::Biblioitems;
43
use Koha::Items;
44
use Koha::ItemTypes;
45
use Koha::SearchEngine;
46
use Koha::SearchEngine::Search;
47
use Koha::Libraries;
48
49
use vars qw(@ISA @EXPORT);
24
use vars qw(@ISA @EXPORT);
50
51
BEGIN {
25
BEGIN {
26
    require Exporter;
27
    @ISA = qw(Exporter);
52
28
53
	require Exporter;
54
    @ISA = qw( Exporter );
55
56
    # function exports
57
    @EXPORT = qw(
29
    @EXPORT = qw(
58
        GetItem
30
        GetItem
59
        AddItemFromMarc
31
        AddItemFromMarc
60
        AddItem
32
        AddItem
61
        AddItemBatchFromMarc
33
        AddItemBatchFromMarc
62
        ModItemFromMarc
34
        ModItemFromMarc
63
    Item2Marc
35
        Item2Marc
64
        ModItem
36
        ModItem
65
        ModDateLastSeen
37
        ModDateLastSeen
66
        ModItemTransfer
38
        ModItemTransfer
67
        DelItem
39
        DelItem
68
    
69
        CheckItemPreSave
40
        CheckItemPreSave
70
    
71
        GetItemsForInventory
41
        GetItemsForInventory
72
        GetItemsInfo
42
        GetItemsInfo
73
	GetItemsLocationInfo
43
        GetItemsLocationInfo
74
	GetHostItemsInfo
44
        GetHostItemsInfo
75
	get_hostitemnumbers_of
45
        get_hostitemnumbers_of
76
        GetHiddenItemnumbers
46
        GetHiddenItemnumbers
77
        ItemSafeToDelete
47
        ItemSafeToDelete
78
        DelItemCheck
48
        DelItemCheck
79
    MoveItemFromBiblio
49
        MoveItemFromBiblio
80
    GetLatestAcquisitions
50
        GetLatestAcquisitions
81
82
        CartToShelf
51
        CartToShelf
83
        ShelfToCart
52
        ShelfToCart
84
53
        GetAnalyticsCount
85
	GetAnalyticsCount
86
87
        SearchItemsByField
54
        SearchItemsByField
88
        SearchItems
55
        SearchItems
89
90
        PrepareItemrecordDisplay
56
        PrepareItemrecordDisplay
91
92
    );
57
    );
93
}
58
}
94
59
60
use Carp;
61
use C4::Context;
62
use C4::Koha;
63
use C4::Biblio;
64
use Koha::DateUtils;
65
use MARC::Record;
66
use C4::ClassSource;
67
use C4::Log;
68
use List::MoreUtils qw(any);
69
use YAML qw(Load);
70
use DateTime::Format::MySQL;
71
use Data::Dumper; # used as part of logging item record changes, not just for
72
                  # debugging; so please don't remove this
73
74
use Koha::AuthorisedValues;
75
use Koha::DateUtils qw(dt_from_string);
76
use Koha::Database;
77
78
use Koha::Biblioitems;
79
use Koha::Items;
80
use Koha::ItemTypes;
81
use Koha::SearchEngine;
82
use Koha::SearchEngine::Search;
83
use Koha::Libraries;
84
95
=head1 NAME
85
=head1 NAME
96
86
97
C4::Items - item management functions
87
C4::Items - item management functions
Lines 233-242 sub AddItemFromMarc { Link Here
233
    # parse item hash from MARC
223
    # parse item hash from MARC
234
    my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber );
224
    my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber );
235
    my ($itemtag,$itemsubfield)=C4::Biblio::GetMarcFromKohaField("items.itemnumber",$frameworkcode);
225
    my ($itemtag,$itemsubfield)=C4::Biblio::GetMarcFromKohaField("items.itemnumber",$frameworkcode);
236
	
226
237
	my $localitemmarc=MARC::Record->new;
227
    my $localitemmarc=MARC::Record->new;
238
	$localitemmarc->append_fields($source_item_marc->field($itemtag));
228
    $localitemmarc->append_fields($source_item_marc->field($itemtag));
239
    my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items');
229
    my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items');
240
    my $unlinked_item_subfields = _get_unlinked_item_subfields($localitemmarc, $frameworkcode);
230
    my $unlinked_item_subfields = _get_unlinked_item_subfields($localitemmarc, $frameworkcode);
241
    return AddItem($item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields);
231
    return AddItem($item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields);
242
}
232
}
Lines 498-504 sub ModItemFromMarc { Link Here
498
488
499
    my $localitemmarc = MARC::Record->new;
489
    my $localitemmarc = MARC::Record->new;
500
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
490
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
501
    my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
491
    my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
502
    my $default_values = _build_default_values_for_mod_marc();
492
    my $default_values = _build_default_values_for_mod_marc();
503
    foreach my $item_field ( keys %$default_values ) {
493
    foreach my $item_field ( keys %$default_values ) {
504
        $item->{$item_field} = $default_values->{$item_field}
494
        $item->{$item_field} = $default_values->{$item_field}
Lines 2452-2458 sub PrepareItemrecordDisplay { Link Here
2452
    # Note: $tagslib obtained from GetMarcStructure() in 'unsafe' mode is
2442
    # Note: $tagslib obtained from GetMarcStructure() in 'unsafe' mode is
2453
    # a shared data structure. No plugin (including custom ones) should change
2443
    # a shared data structure. No plugin (including custom ones) should change
2454
    # its contents. See also GetMarcStructure.
2444
    # its contents. See also GetMarcStructure.
2455
    my $tagslib = &GetMarcStructure( 1, $frameworkcode, { unsafe => 1 } );
2445
    my $tagslib = GetMarcStructure( 1, $frameworkcode, { unsafe => 1 } );
2456
2446
2457
    # return nothing if we don't have found an existing framework.
2447
    # return nothing if we don't have found an existing framework.
2458
    return q{} unless $tagslib;
2448
    return q{} unless $tagslib;
2459
- 

Return to bug 19687