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

(-)a/misc/migration_tools/create_analytical_rel.pl (-32 / +26 lines)
Lines 12-17 BEGIN { Link Here
12
use C4::Context;
12
use C4::Context;
13
use C4::Biblio;
13
use C4::Biblio;
14
use C4::Items;
14
use C4::Items;
15
use Koha::Items;
15
use Getopt::Long;
16
use Getopt::Long;
16
17
17
$| = 1;
18
$| = 1;
Lines 34-40 if (not $result or $want_help or not $do_update) { Link Here
34
35
35
my $num_bibs_processed     = 0;
36
my $num_bibs_processed     = 0;
36
my $num_bibs_modified      = 0;
37
my $num_bibs_modified      = 0;
37
my $num_nobib_foritemnumber = 0;
38
my $num_noitem_forbarcode = 0;
38
my $num_noitem_forbarcode = 0;
39
my $num_nobarcode_inhostfield =0;
39
my $num_nobarcode_inhostfield =0;
40
my $num_hostfields_unabletomodify =0;
40
my $num_hostfields_unabletomodify =0;
Lines 91-126 sub process_bib { Link Here
91
    my $analyticfield = '773';
91
    my $analyticfield = '773';
92
	foreach my $hostfield ( $bib->field($analyticfield) ) {
92
	foreach my $hostfield ( $bib->field($analyticfield) ) {
93
		if(my $barcode = $hostfield->subfield('o')){
93
		if(my $barcode = $hostfield->subfield('o')){
94
			my $itemnumber = GetItemnumberFromBarcode($barcode);
94
            my $item = Koha::Items->find({ barcode => $barcode });
95
			if ($itemnumber ne undef){
95
            if ($item) {
96
				my $bibnumber = GetBiblionumberFromItemnumber($itemnumber);
96
                my $modif;
97
				if ($bibnumber ne undef){
97
                if ( $hostfield->subfield('0') ne $biblionumber ) {
98
					my $modif;
98
                    $hostfield->update( '0', $biblionumber );
99
					if ($hostfield->subfield('0') ne $bibnumber){
99
                    $modif = 1;
100
						$hostfield->update('0', $bibnumber);
100
                }
101
						$modif = 1;
101
                if ( $hostfield->subfield('9') ne $item->itemnumber ) {
102
					}
102
                    $hostfield->update( '9', $item->itemnumber );
103
					if ($hostfield->subfield('9') ne $itemnumber){
103
                    $modif = 1;
104
						$hostfield->update('9', $itemnumber);
104
                }
105
						$modif=1;
105
                if ($modif) {
106
					}
106
                    $num_bibs_modified++;
107
					if ($modif){
107
                    my $modresult = ModBiblio( $bib, $biblionumber, '' );
108
						$num_bibs_modified++;
108
                    warn "Modifying biblio $biblionumber";
109
						my $modresult = ModBiblio($bib, $biblionumber, '');
109
                    if ( !$modresult ) {
110
						warn "Modifying biblio $biblionumber";
110
                        warn "Unable to modify biblio $biblionumber with update host field";
111
						if (!$modresult){
111
                        $num_hostfields_unabletomodify++;
112
							warn "Unable to modify biblio $biblionumber with update host field";
112
                    }
113
							$num_hostfields_unabletomodify++;
113
                }
114
						}
114
            }
115
					}
115
            else {
116
				} else {
116
                warn "No item record found for barcode $barcode";
117
					warn "No biblio record found corressponding to itemnumber $itemnumber";
117
                $num_noitem_forbarcode++;
118
					$num_nobib_foritemnumber++;
118
            }
119
				}
120
			} else {
121
				warn "No item record found for barcode $barcode";
122
				$num_noitem_forbarcode++;
123
			}
124
		} else{
119
		} else{
125
			warn "No barcode in host field for biblionumber $biblionumber";
120
			warn "No barcode in host field for biblionumber $biblionumber";
126
			$num_nobarcode_inhostfield++;
121
			$num_nobarcode_inhostfield++;
127
- 

Return to bug 18277