Lines 29-81
use Koha::Patrons;
Link Here
|
29 |
use C4::Biblio qw( GetMarcFromKohaField ); |
29 |
use C4::Biblio qw( GetMarcFromKohaField ); |
30 |
|
30 |
|
31 |
{ |
31 |
{ |
32 |
my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }}); |
32 |
my $items = Koha::Items->search( { -or => { homebranch => undef, holdingbranch => undef } } ); |
33 |
if ( $items->count ) { new_section("Not defined items.homebranch and/or items.holdingbranch")} |
33 |
if ( $items->count ) { new_section("Not defined items.homebranch and/or items.holdingbranch") } |
34 |
while ( my $item = $items->next ) { |
34 |
while ( my $item = $items->next ) { |
35 |
if ( not $item->homebranch and not $item->holdingbranch ) { |
35 |
if ( not $item->homebranch and not $item->holdingbranch ) { |
36 |
new_item(sprintf "Item with itemnumber=%s does not have homebranch and holdingbranch defined", $item->itemnumber); |
36 |
new_item( |
|
|
37 |
sprintf "Item with itemnumber=%s does not have homebranch and holdingbranch defined", |
38 |
$item->itemnumber |
39 |
); |
37 |
} elsif ( not $item->homebranch ) { |
40 |
} elsif ( not $item->homebranch ) { |
38 |
new_item(sprintf "Item with itemnumber=%s does not have homebranch defined", $item->itemnumber); |
41 |
new_item( sprintf "Item with itemnumber=%s does not have homebranch defined", $item->itemnumber ); |
39 |
} else { |
42 |
} else { |
40 |
new_item(sprintf "Item with itemnumber=%s does not have holdingbranch defined", $item->itemnumber); |
43 |
new_item( sprintf "Item with itemnumber=%s does not have holdingbranch defined", $item->itemnumber ); |
41 |
} |
44 |
} |
42 |
} |
45 |
} |
43 |
if ( $items->count ) { new_hint("Edit these items and set valid homebranch and/or holdingbranch")} |
46 |
if ( $items->count ) { new_hint("Edit these items and set valid homebranch and/or holdingbranch") } |
44 |
} |
47 |
} |
45 |
|
48 |
|
46 |
{ |
49 |
{ |
47 |
# No join possible, FK is missing at DB level |
50 |
# No join possible, FK is missing at DB level |
48 |
my @auth_types = Koha::Authority::Types->search->get_column('authtypecode'); |
51 |
my @auth_types = Koha::Authority::Types->search->get_column('authtypecode'); |
49 |
my $authorities = Koha::Authorities->search({authtypecode => { 'not in' => \@auth_types } }); |
52 |
my $authorities = Koha::Authorities->search( { authtypecode => { 'not in' => \@auth_types } } ); |
50 |
if ( $authorities->count ) {new_section("Invalid auth_header.authtypecode")} |
53 |
if ( $authorities->count ) { new_section("Invalid auth_header.authtypecode") } |
51 |
while ( my $authority = $authorities->next ) { |
54 |
while ( my $authority = $authorities->next ) { |
52 |
new_item(sprintf "Authority with authid=%s does not have a code defined (%s)", $authority->authid, $authority->authtypecode); |
55 |
new_item( |
|
|
56 |
sprintf "Authority with authid=%s does not have a code defined (%s)", $authority->authid, |
57 |
$authority->authtypecode |
58 |
); |
53 |
} |
59 |
} |
54 |
if ( $authorities->count ) {new_hint("Go to 'Home › Administration › Authority types' to define them")} |
60 |
if ( $authorities->count ) { new_hint("Go to 'Home › Administration › Authority types' to define them") } |
55 |
} |
61 |
} |
56 |
|
62 |
|
57 |
{ |
63 |
{ |
58 |
if ( C4::Context->preference('item-level_itypes') ) { |
64 |
if ( C4::Context->preference('item-level_itypes') ) { |
59 |
my $items_without_itype = Koha::Items->search( { -or => [itype => undef,itype => ''] } ); |
65 |
my $items_without_itype = Koha::Items->search( { -or => [ itype => undef, itype => '' ] } ); |
60 |
if ( $items_without_itype->count ) { |
66 |
if ( $items_without_itype->count ) { |
61 |
new_section("Items do not have itype defined"); |
67 |
new_section("Items do not have itype defined"); |
62 |
while ( my $item = $items_without_itype->next ) { |
68 |
while ( my $item = $items_without_itype->next ) { |
63 |
if (defined $item->biblioitem->itemtype && $item->biblioitem->itemtype ne '' ) { |
69 |
if ( defined $item->biblioitem->itemtype && $item->biblioitem->itemtype ne '' ) { |
64 |
new_item( |
70 |
new_item( |
65 |
sprintf "Item with itemnumber=%s does not have a itype value, biblio's item type will be used (%s)", |
71 |
sprintf |
|
|
72 |
"Item with itemnumber=%s does not have a itype value, biblio's item type will be used (%s)", |
66 |
$item->itemnumber, $item->biblioitem->itemtype |
73 |
$item->itemnumber, $item->biblioitem->itemtype |
67 |
); |
74 |
); |
68 |
} else { |
75 |
} else { |
69 |
new_item( |
76 |
new_item( |
70 |
sprintf "Item with itemnumber=%s does not have a itype value, additionally no item type defined for biblionumber=%s", |
77 |
sprintf |
|
|
78 |
"Item with itemnumber=%s does not have a itype value, additionally no item type defined for biblionumber=%s", |
71 |
$item->itemnumber, $item->biblioitem->biblionumber |
79 |
$item->itemnumber, $item->biblioitem->biblionumber |
72 |
); |
80 |
); |
73 |
} |
81 |
} |
74 |
} |
82 |
} |
75 |
new_hint("The system preference item-level_itypes expects item types to be defined at item level"); |
83 |
new_hint("The system preference item-level_itypes expects item types to be defined at item level"); |
76 |
} |
84 |
} |
77 |
} |
85 |
} else { |
78 |
else { |
|
|
79 |
my $biblioitems_without_itemtype = Koha::Biblioitems->search( { itemtype => undef } ); |
86 |
my $biblioitems_without_itemtype = Koha::Biblioitems->search( { itemtype => undef } ); |
80 |
if ( $biblioitems_without_itemtype->count ) { |
87 |
if ( $biblioitems_without_itemtype->count ) { |
81 |
new_section("Biblioitems do not have itemtype defined"); |
88 |
new_section("Biblioitems do not have itemtype defined"); |
Lines 91-97
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
91 |
|
98 |
|
92 |
my @itemtypes = Koha::ItemTypes->search->get_column('itemtype'); |
99 |
my @itemtypes = Koha::ItemTypes->search->get_column('itemtype'); |
93 |
if ( C4::Context->preference('item-level_itypes') ) { |
100 |
if ( C4::Context->preference('item-level_itypes') ) { |
94 |
my $items_with_invalid_itype = Koha::Items->search( { -and => [itype => { not_in => \@itemtypes }, itype => { '!=' => '' }] } ); |
101 |
my $items_with_invalid_itype = |
|
|
102 |
Koha::Items->search( { -and => [ itype => { not_in => \@itemtypes }, itype => { '!=' => '' } ] } ); |
95 |
if ( $items_with_invalid_itype->count ) { |
103 |
if ( $items_with_invalid_itype->count ) { |
96 |
new_section("Items have invalid itype defined"); |
104 |
new_section("Items have invalid itype defined"); |
97 |
while ( my $item = $items_with_invalid_itype->next ) { |
105 |
while ( my $item = $items_with_invalid_itype->next ) { |
Lines 100-112
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
100 |
$item->itemnumber, $item->biblionumber, $item->itype |
108 |
$item->itemnumber, $item->biblionumber, $item->itype |
101 |
); |
109 |
); |
102 |
} |
110 |
} |
103 |
new_hint("The items must have a itype value that is defined in the item types of Koha (Home › Administration › Item types administration)"); |
111 |
new_hint( |
|
|
112 |
"The items must have a itype value that is defined in the item types of Koha (Home › Administration › Item types administration)" |
113 |
); |
104 |
} |
114 |
} |
105 |
} |
115 |
} else { |
106 |
else { |
116 |
my $biblioitems_with_invalid_itemtype = Koha::Biblioitems->search( { itemtype => { not_in => \@itemtypes } } ); |
107 |
my $biblioitems_with_invalid_itemtype = Koha::Biblioitems->search( |
|
|
108 |
{ itemtype => { not_in => \@itemtypes } } |
109 |
); |
110 |
if ( $biblioitems_with_invalid_itemtype->count ) { |
117 |
if ( $biblioitems_with_invalid_itemtype->count ) { |
111 |
new_section("Biblioitems do not have itemtype defined"); |
118 |
new_section("Biblioitems do not have itemtype defined"); |
112 |
while ( my $biblioitem = $biblioitems_with_invalid_itemtype->next ) { |
119 |
while ( my $biblioitem = $biblioitems_with_invalid_itemtype->next ) { |
Lines 115-130
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
115 |
$biblioitem->biblioitemnumber |
122 |
$biblioitem->biblioitemnumber |
116 |
); |
123 |
); |
117 |
} |
124 |
} |
118 |
new_hint("The biblioitems must have a itemtype value that is defined in the item types of Koha (Home › Administration › Item types administration)"); |
125 |
new_hint( |
|
|
126 |
"The biblioitems must have a itemtype value that is defined in the item types of Koha (Home › Administration › Item types administration)" |
127 |
); |
119 |
} |
128 |
} |
120 |
} |
129 |
} |
121 |
|
130 |
|
122 |
my ( @decoding_errors, @ids_not_in_marc ); |
131 |
my ( @decoding_errors, @ids_not_in_marc ); |
123 |
my $biblios = Koha::Biblios->search; |
132 |
my $biblios = Koha::Biblios->search; |
124 |
my ( $biblio_tag, $biblio_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblio.biblionumber" ); |
133 |
my ( $biblio_tag, $biblio_subfield ) = C4::Biblio::GetMarcFromKohaField("biblio.biblionumber"); |
125 |
my ( $biblioitem_tag, $biblioitem_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblioitems.biblioitemnumber" ); |
134 |
my ( $biblioitem_tag, $biblioitem_subfield ) = C4::Biblio::GetMarcFromKohaField("biblioitems.biblioitemnumber"); |
126 |
while ( my $biblio = $biblios->next ) { |
135 |
while ( my $biblio = $biblios->next ) { |
127 |
my $record = eval{$biblio->metadata->record;}; |
136 |
my $record = eval { $biblio->metadata->record; }; |
128 |
if ($@) { |
137 |
if ($@) { |
129 |
push @decoding_errors, $@; |
138 |
push @decoding_errors, $@; |
130 |
next; |
139 |
next; |
Lines 144-174
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
144 |
} |
153 |
} |
145 |
if ( $biblionumber != $biblio->biblionumber ) { |
154 |
if ( $biblionumber != $biblio->biblionumber ) { |
146 |
push @ids_not_in_marc, |
155 |
push @ids_not_in_marc, |
147 |
{ |
156 |
{ |
148 |
biblionumber => $biblio->biblionumber, |
157 |
biblionumber => $biblio->biblionumber, |
149 |
biblionumber_in_marc => $biblionumber, |
158 |
biblionumber_in_marc => $biblionumber, |
150 |
}; |
159 |
}; |
151 |
} |
160 |
} |
152 |
if ( $biblioitemnumber != $biblio->biblioitem->biblioitemnumber ) { |
161 |
if ( $biblioitemnumber != $biblio->biblioitem->biblioitemnumber ) { |
153 |
push @ids_not_in_marc, |
162 |
push @ids_not_in_marc, |
154 |
{ |
163 |
{ |
155 |
biblionumber => $biblio->biblionumber, |
164 |
biblionumber => $biblio->biblionumber, |
156 |
biblioitemnumber => $biblio->biblioitem->biblioitemnumber, |
165 |
biblioitemnumber => $biblio->biblioitem->biblioitemnumber, |
157 |
biblioitemnumber_in_marc => $biblionumber, |
166 |
biblioitemnumber_in_marc => $biblionumber, |
158 |
}; |
167 |
}; |
159 |
} |
168 |
} |
160 |
} |
169 |
} |
161 |
if ( @decoding_errors ) { |
170 |
if (@decoding_errors) { |
162 |
new_section("Bibliographic records have invalid MARCXML"); |
171 |
new_section("Bibliographic records have invalid MARCXML"); |
163 |
new_item($_) for @decoding_errors; |
172 |
new_item($_) for @decoding_errors; |
164 |
new_hint("The bibliographic records must have a valid MARCXML or you will face encoding issues or wrong displays"); |
173 |
new_hint( |
|
|
174 |
"The bibliographic records must have a valid MARCXML or you will face encoding issues or wrong displays"); |
165 |
} |
175 |
} |
166 |
if (@ids_not_in_marc) { |
176 |
if (@ids_not_in_marc) { |
167 |
new_section("Bibliographic records have MARCXML without biblionumber or biblioitemnumber"); |
177 |
new_section("Bibliographic records have MARCXML without biblionumber or biblioitemnumber"); |
168 |
for my $id (@ids_not_in_marc) { |
178 |
for my $id (@ids_not_in_marc) { |
169 |
if ( exists $id->{biblioitemnumber} ) { |
179 |
if ( exists $id->{biblioitemnumber} ) { |
170 |
new_item( |
180 |
new_item( |
171 |
sprintf(q{Biblionumber %s has biblioitemnumber '%s' but should be '%s' in %s$%s}, |
181 |
sprintf( |
|
|
182 |
q{Biblionumber %s has biblioitemnumber '%s' but should be '%s' in %s$%s}, |
172 |
$id->{biblionumber}, |
183 |
$id->{biblionumber}, |
173 |
$id->{biblioitemnumber}, |
184 |
$id->{biblioitemnumber}, |
174 |
$id->{biblioitemnumber_in_marc}, |
185 |
$id->{biblioitemnumber_in_marc}, |
Lines 176-185
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
176 |
$biblioitem_subfield, |
187 |
$biblioitem_subfield, |
177 |
) |
188 |
) |
178 |
); |
189 |
); |
179 |
} |
190 |
} else { |
180 |
else { |
|
|
181 |
new_item( |
191 |
new_item( |
182 |
sprintf(q{Biblionumber %s has '%s' in %s$%s}, |
192 |
sprintf( |
|
|
193 |
q{Biblionumber %s has '%s' in %s$%s}, |
183 |
$id->{biblionumber}, |
194 |
$id->{biblionumber}, |
184 |
$id->{biblionumber_in_marc}, |
195 |
$id->{biblionumber_in_marc}, |
185 |
$biblio_tag, |
196 |
$biblio_tag, |
Lines 194-217
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
194 |
|
205 |
|
195 |
{ |
206 |
{ |
196 |
my @framework_codes = Koha::BiblioFrameworks->search()->get_column('frameworkcode'); |
207 |
my @framework_codes = Koha::BiblioFrameworks->search()->get_column('frameworkcode'); |
197 |
push @framework_codes,""; # The default is not stored in frameworks, we need to force it |
208 |
push @framework_codes, ""; # The default is not stored in frameworks, we need to force it |
198 |
|
209 |
|
199 |
my $invalid_av_per_framework = {}; |
210 |
my $invalid_av_per_framework = {}; |
200 |
foreach my $frameworkcode ( @framework_codes ) { |
211 |
foreach my $frameworkcode (@framework_codes) { |
|
|
212 |
|
201 |
# We are only checking fields that are mapped to DB fields |
213 |
# We are only checking fields that are mapped to DB fields |
202 |
my $msss = Koha::MarcSubfieldStructures->search({ |
214 |
my $msss = Koha::MarcSubfieldStructures->search( |
203 |
frameworkcode => $frameworkcode, |
215 |
{ |
204 |
authorised_value => { |
216 |
frameworkcode => $frameworkcode, |
205 |
'!=' => [ -and => ( undef, '' ) ] |
217 |
authorised_value => { '!=' => [ -and => ( undef, '' ) ] }, |
206 |
}, |
218 |
kohafield => { '!=' => [ -and => ( undef, '' ) ] } |
207 |
kohafield => { |
|
|
208 |
'!=' => [ -and => ( undef, '' ) ] |
209 |
} |
219 |
} |
210 |
}); |
220 |
); |
211 |
while ( my $mss = $msss->next ) { |
221 |
while ( my $mss = $msss->next ) { |
212 |
my $kohafield = $mss->kohafield; |
222 |
my $kohafield = $mss->kohafield; |
213 |
my $av = $mss->authorised_value; |
223 |
my $av = $mss->authorised_value; |
214 |
next if grep {$_ eq $av} qw( branches itemtypes cn_source ); # internal categories |
224 |
next if grep { $_ eq $av } qw( branches itemtypes cn_source ); # internal categories |
215 |
|
225 |
|
216 |
my $avs = Koha::AuthorisedValues->search_by_koha_field( |
226 |
my $avs = Koha::AuthorisedValues->search_by_koha_field( |
217 |
{ |
227 |
{ |
Lines 225-270
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
225 |
} else { |
235 |
} else { |
226 |
$tmp_kohafield =~ s|items|me|; |
236 |
$tmp_kohafield =~ s|items|me|; |
227 |
} |
237 |
} |
|
|
238 |
|
228 |
# replace items.attr with me.attr |
239 |
# replace items.attr with me.attr |
229 |
|
240 |
|
230 |
# We are only checking biblios with items |
241 |
# We are only checking biblios with items |
231 |
my $items = Koha::Items->search( |
242 |
my $items = Koha::Items->search( |
232 |
{ |
243 |
{ |
233 |
$tmp_kohafield => |
244 |
$tmp_kohafield => { |
234 |
{ |
245 |
-not_in => [ $avs->get_column('authorised_value'), '' ], |
235 |
-not_in => [ $avs->get_column('authorised_value'), '' ], |
246 |
'!=' => undef, |
236 |
'!=' => undef, |
247 |
}, |
237 |
}, |
|
|
238 |
'biblio.frameworkcode' => $frameworkcode |
248 |
'biblio.frameworkcode' => $frameworkcode |
239 |
}, |
249 |
}, |
240 |
{ join => [ 'biblioitem', 'biblio' ] } |
250 |
{ join => [ 'biblioitem', 'biblio' ] } |
241 |
); |
251 |
); |
242 |
if ( $items->count ) { |
252 |
if ( $items->count ) { |
243 |
$invalid_av_per_framework->{ $frameworkcode }->{$av} = |
253 |
$invalid_av_per_framework->{$frameworkcode}->{$av} = |
244 |
{ items => $items, kohafield => $kohafield }; |
254 |
{ items => $items, kohafield => $kohafield }; |
245 |
} |
255 |
} |
246 |
} |
256 |
} |
247 |
} |
257 |
} |
248 |
if (%$invalid_av_per_framework) { |
258 |
if (%$invalid_av_per_framework) { |
249 |
new_section('Wrong values linked to authorised values'); |
259 |
new_section('Wrong values linked to authorised values'); |
250 |
for my $frameworkcode ( keys %$invalid_av_per_framework ) { |
260 |
for my $frameworkcode ( keys %$invalid_av_per_framework ) { |
251 |
while ( my ( $av_category, $v ) = each %{$invalid_av_per_framework->{$frameworkcode}} ) { |
261 |
while ( my ( $av_category, $v ) = each %{ $invalid_av_per_framework->{$frameworkcode} } ) { |
252 |
my $items = $v->{items}; |
262 |
my $items = $v->{items}; |
253 |
my $kohafield = $v->{kohafield}; |
263 |
my $kohafield = $v->{kohafield}; |
254 |
my ( $table, $column ) = split '\.', $kohafield; |
264 |
my ( $table, $column ) = split '\.', $kohafield; |
255 |
my $output; |
265 |
my $output; |
256 |
while ( my $i = $items->next ) { |
266 |
while ( my $i = $items->next ) { |
257 |
my $value = $table eq 'items' |
267 |
my $value = |
258 |
? $i->$column |
268 |
$table eq 'items' ? $i->$column |
259 |
: $table eq 'biblio' |
269 |
: $table eq 'biblio' ? $i->biblio->$column |
260 |
? $i->biblio->$column |
270 |
: $i->biblioitem->$column; |
261 |
: $i->biblioitem->$column; |
|
|
262 |
$output .= " {" . $i->itemnumber . " => " . $value . "}\n"; |
271 |
$output .= " {" . $i->itemnumber . " => " . $value . "}\n"; |
263 |
} |
272 |
} |
264 |
new_item( |
273 |
new_item( |
265 |
sprintf( |
274 |
sprintf( |
266 |
"The Framework *%s* is using the authorised value's category *%s*, " |
275 |
"The Framework *%s* is using the authorised value's category *%s*, " |
267 |
. "but the following %s do not have a value defined ({itemnumber => value }):\n%s", |
276 |
. "but the following %s do not have a value defined ({itemnumber => value }):\n%s", |
268 |
$frameworkcode, $av_category, $kohafield, $output |
277 |
$frameworkcode, $av_category, $kohafield, $output |
269 |
) |
278 |
) |
270 |
); |
279 |
); |
Lines 274-292
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
274 |
} |
283 |
} |
275 |
|
284 |
|
276 |
{ |
285 |
{ |
277 |
my $biblios = Koha::Biblios->search({ |
286 |
my $biblios = Koha::Biblios->search( |
278 |
-or => [ |
287 |
{ |
279 |
title => '', |
288 |
-or => [ |
280 |
title => undef, |
289 |
title => '', |
281 |
] |
290 |
title => undef, |
282 |
}); |
291 |
] |
|
|
292 |
} |
293 |
); |
283 |
if ( $biblios->count ) { |
294 |
if ( $biblios->count ) { |
284 |
my ( $title_tag, $title_subtag ) = C4::Biblio::GetMarcFromKohaField( 'biblio.title' ); |
295 |
my ( $title_tag, $title_subtag ) = C4::Biblio::GetMarcFromKohaField('biblio.title'); |
285 |
my $title_field = $title_tag // ''; |
296 |
my $title_field = $title_tag // ''; |
286 |
$title_field .= '$'.$title_subtag if $title_subtag; |
297 |
$title_field .= '$' . $title_subtag if $title_subtag; |
287 |
new_section("Biblio without title $title_field"); |
298 |
new_section("Biblio without title $title_field"); |
288 |
while ( my $biblio = $biblios->next ) { |
299 |
while ( my $biblio = $biblios->next ) { |
289 |
new_item(sprintf "Biblio with biblionumber=%s does not have title defined", $biblio->biblionumber); |
300 |
new_item( sprintf "Biblio with biblionumber=%s does not have title defined", $biblio->biblionumber ); |
290 |
} |
301 |
} |
291 |
new_hint("Edit these bibliographic records to define a title"); |
302 |
new_hint("Edit these bibliographic records to define a title"); |
292 |
} |
303 |
} |
Lines 298-304
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
298 |
-not => { |
309 |
-not => { |
299 |
-or => { |
310 |
-or => { |
300 |
'me.dateofbirth' => undef, |
311 |
'me.dateofbirth' => undef, |
301 |
-and => { |
312 |
-and => { |
302 |
'categorycode.dateofbirthrequired' => undef, |
313 |
'categorycode.dateofbirthrequired' => undef, |
303 |
'categorycode.upperagelimit' => undef, |
314 |
'categorycode.upperagelimit' => undef, |
304 |
} |
315 |
} |
Lines 318-342
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
318 |
my $category = $invalid_patron->category; |
329 |
my $category = $invalid_patron->category; |
319 |
new_item( |
330 |
new_item( |
320 |
sprintf "Patron borrowernumber=%s has an invalid age of %s for their category '%s' (%s to %s)", |
331 |
sprintf "Patron borrowernumber=%s has an invalid age of %s for their category '%s' (%s to %s)", |
321 |
$invalid_patron->borrowernumber, $invalid_patron->get_age, $category->categorycode, |
332 |
$invalid_patron->borrowernumber, $invalid_patron->get_age, $category->categorycode, |
322 |
$category->dateofbirthrequired // '0', $category->upperagelimit // 'unlimited' |
333 |
$category->dateofbirthrequired // '0', $category->upperagelimit // 'unlimited' |
323 |
); |
334 |
); |
324 |
} |
335 |
} |
325 |
new_hint("You may change the patron's category automatically with misc/cronjobs/update_patrons_category.pl"); |
336 |
new_hint("You may change the patron's category automatically with misc/cronjobs/update_patrons_category.pl"); |
326 |
} |
337 |
} |
327 |
} |
338 |
} |
328 |
|
339 |
|
|
|
340 |
{ |
341 |
my @loop_borrowers_relationships; |
342 |
my @relationships = Koha::Patron::Relationships->search(); |
343 |
my @patrons_guarantors = Koha::Patron::Relationships::guarantors(@relationships)->as_list; |
344 |
my @patrons_guarantees = Koha::Patron::Relationships::guarantees(@relationships)->as_list; |
345 |
|
346 |
foreach my $patron_guarantor (@patrons_guarantors) { |
347 |
foreach my $patron_guarantee (@patrons_guarantees) { |
348 |
if ( $patron_guarantor->borrowernumber == $patron_guarantee->borrowernumber ) { |
349 |
|
350 |
my $relationship_id; |
351 |
my $guarantee_id; |
352 |
my $size_list; |
353 |
my $tmp_garantor_id = $patron_guarantor->borrowernumber; |
354 |
my @relationship_ids; |
355 |
my @guarantor_to_find; |
356 |
|
357 |
push @guarantor_to_find, $patron_guarantor->borrowernumber; |
358 |
|
359 |
do { |
360 |
my @relationship_for_go = Koha::Patron::Relationships->search( |
361 |
{ |
362 |
-or => [ |
363 |
'guarantor_id' => { '=', $tmp_garantor_id }, |
364 |
] |
365 |
}, |
366 |
)->as_list; |
367 |
$size_list = scalar @relationship_for_go; |
368 |
|
369 |
foreach my $relation (@relationship_for_go) { |
370 |
$relationship_id = $relation->id; |
371 |
unless ( grep { $_ == $relationship_id } @relationship_ids ) { |
372 |
push @relationship_ids, $relationship_id; |
373 |
} |
374 |
$guarantee_id = $relation->guarantee_id; |
375 |
|
376 |
if ( grep { $_ eq $guarantee_id } @guarantor_to_find ) { |
377 |
last; |
378 |
} |
379 |
|
380 |
my @relationship_for_go = Koha::Patron::Relationships->search( |
381 |
{ |
382 |
-or => [ |
383 |
'guarantor_id' => { '=', $guarantee_id }, |
384 |
] |
385 |
}, |
386 |
)->as_list; |
387 |
$size_list = scalar @relationship_for_go; |
388 |
|
389 |
push @guarantor_to_find, $guarantee_id; |
390 |
|
391 |
foreach my $relation (@relationship_for_go) { |
392 |
$relationship_id = $relation->id; |
393 |
unless ( grep { $_ == $relationship_id } @relationship_ids ) { |
394 |
push @relationship_ids, $relationship_id; |
395 |
} |
396 |
$guarantee_id = $relation->guarantee_id; |
397 |
|
398 |
if ( grep { $_ eq $guarantee_id } @guarantor_to_find ) { |
399 |
last; |
400 |
} |
401 |
} |
402 |
if ( grep { $_ eq $guarantee_id } @guarantor_to_find ) { |
403 |
last; |
404 |
} |
405 |
} |
406 |
|
407 |
$tmp_garantor_id = $guarantee_id; |
408 |
} while ( ( !grep { $_ eq $guarantee_id } @guarantor_to_find ) && $size_list > 0 ); |
409 |
|
410 |
if ( $patron_guarantor->borrowernumber == $guarantee_id ) { |
411 |
unless ( grep { join( "", sort @$_ ) eq join( "", sort @relationship_ids ) } |
412 |
@loop_borrowers_relationships ) |
413 |
{ |
414 |
push @loop_borrowers_relationships, \@relationship_ids; |
415 |
} |
416 |
} |
417 |
} |
418 |
} |
419 |
} |
420 |
|
421 |
if ( scalar @loop_borrowers_relationships > 0 ) { |
422 |
new_section("The list of relationships id with guarantors who are also guarantee."); |
423 |
foreach my $table (@loop_borrowers_relationships) { |
424 |
new_item( |
425 |
sprintf "Relationships connected : %s |", |
426 |
join( " | ", @$table ) |
427 |
); |
428 |
} |
429 |
new_hint("Relationships that form guarantor loops must be deleted"); |
430 |
} |
431 |
} |
432 |
|
329 |
sub new_section { |
433 |
sub new_section { |
330 |
my ( $name ) = @_; |
434 |
my ($name) = @_; |
331 |
say "\n== $name =="; |
435 |
say "\n== $name =="; |
332 |
} |
436 |
} |
333 |
|
437 |
|
334 |
sub new_item { |
438 |
sub new_item { |
335 |
my ( $name ) = @_; |
439 |
my ($name) = @_; |
336 |
say "\t* $name"; |
440 |
say "\t* $name"; |
337 |
} |
441 |
} |
|
|
442 |
|
338 |
sub new_hint { |
443 |
sub new_hint { |
339 |
my ( $name ) = @_; |
444 |
my ($name) = @_; |
340 |
say "=> $name"; |
445 |
say "=> $name"; |
341 |
} |
446 |
} |
342 |
|
447 |
|
343 |
- |
|
|