Lines 58-63
undef($sip_media_type) if defined($sip_media_type) and $sip_media_type =~ /^\s*$
Link Here
|
58 |
|
58 |
|
59 |
if ( $op eq 'add_form' ) { |
59 |
if ( $op eq 'add_form' ) { |
60 |
my $itemtype = Koha::ItemTypes->find($itemtype_code); |
60 |
my $itemtype = Koha::ItemTypes->find($itemtype_code); |
|
|
61 |
|
62 |
my $selected_branches = $itemtype->get_library_limits; |
63 |
my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed; |
64 |
my @branches_loop; |
65 |
foreach my $branch ( @$branches ) { |
66 |
my $selected = ($selected_branches && grep {$_->branchcode eq $branch->{branchcode}} @{ $selected_branches->as_list } ) ? 1 : 0; |
67 |
push @branches_loop, { |
68 |
branchcode => $branch->{branchcode}, |
69 |
branchname => $branch->{branchname}, |
70 |
selected => $selected, |
71 |
}; |
72 |
} |
73 |
|
61 |
my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) ); |
74 |
my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) ); |
62 |
my $searchcategory = GetAuthorisedValues("ITEMTYPECAT"); |
75 |
my $searchcategory = GetAuthorisedValues("ITEMTYPECAT"); |
63 |
my $translated_languages = C4::Languages::getTranslatedLanguages( undef , C4::Context->preference('template') ); |
76 |
my $translated_languages = C4::Languages::getTranslatedLanguages( undef , C4::Context->preference('template') ); |
Lines 66-71
if ( $op eq 'add_form' ) {
Link Here
|
66 |
imagesets => $imagesets, |
79 |
imagesets => $imagesets, |
67 |
searchcategory => $searchcategory, |
80 |
searchcategory => $searchcategory, |
68 |
can_be_translated => ( scalar(@$translated_languages) > 1 ? 1 : 0 ), |
81 |
can_be_translated => ( scalar(@$translated_languages) > 1 ? 1 : 0 ), |
|
|
82 |
branches_loop => \@branches_loop, |
69 |
); |
83 |
); |
70 |
} elsif ( $op eq 'add_validate' ) { |
84 |
} elsif ( $op eq 'add_validate' ) { |
71 |
my $is_a_modif = $input->param('is_a_modif'); |
85 |
my $is_a_modif = $input->param('is_a_modif'); |
Lines 77-82
if ( $op eq 'add_form' ) {
Link Here
|
77 |
my $defaultreplacecost = $input->param('defaultreplacecost'); |
91 |
my $defaultreplacecost = $input->param('defaultreplacecost'); |
78 |
my $processfee = $input->param('processfee'); |
92 |
my $processfee = $input->param('processfee'); |
79 |
my $image = $input->param('image') || q||; |
93 |
my $image = $input->param('image') || q||; |
|
|
94 |
my @branches = grep { $_ ne q{} } $input->multi_param('branches'); |
80 |
|
95 |
|
81 |
my $notforloan = $input->param('notforloan') ? 1 : 0; |
96 |
my $notforloan = $input->param('notforloan') ? 1 : 0; |
82 |
my $imageurl = |
97 |
my $imageurl = |
Lines 107-113
if ( $op eq 'add_form' ) {
Link Here
|
107 |
$itemtype->hideinopac($hideinopac); |
122 |
$itemtype->hideinopac($hideinopac); |
108 |
$itemtype->searchcategory($searchcategory); |
123 |
$itemtype->searchcategory($searchcategory); |
109 |
|
124 |
|
110 |
eval { $itemtype->store; }; |
125 |
eval { |
|
|
126 |
$itemtype->store; |
127 |
$itemtype->replace_library_limits( \@branches ); |
128 |
}; |
111 |
|
129 |
|
112 |
if ($@) { |
130 |
if ($@) { |
113 |
push @messages, { type => 'alert', code => 'error_on_update' }; |
131 |
push @messages, { type => 'alert', code => 'error_on_update' }; |
Lines 134-140
if ( $op eq 'add_form' ) {
Link Here
|
134 |
searchcategory => $searchcategory, |
152 |
searchcategory => $searchcategory, |
135 |
} |
153 |
} |
136 |
); |
154 |
); |
137 |
eval { $itemtype->store; }; |
155 |
eval { |
|
|
156 |
$itemtype->store; |
157 |
$itemtype->replace_library_limits( \@branches ); |
158 |
}; |
138 |
|
159 |
|
139 |
if ($@) { |
160 |
if ($@) { |
140 |
push @messages, { type => 'alert', code => 'error_on_insert' }; |
161 |
push @messages, { type => 'alert', code => 'error_on_insert' }; |
Lines 176-181
if ( $op eq 'add_form' ) {
Link Here
|
176 |
|
197 |
|
177 |
if ( $op eq 'list' ) { |
198 |
if ( $op eq 'list' ) { |
178 |
my $itemtypes = Koha::ItemTypes->search; |
199 |
my $itemtypes = Koha::ItemTypes->search; |
|
|
200 |
foreach my $type ( @{$itemtypes->as_list}) { |
201 |
use Data::Printer colored => 1; |
202 |
p($type->get_library_limits); |
203 |
if($type->get_library_limits) { |
204 |
p($type->get_library_limits->as_list); |
205 |
} |
206 |
} |
179 |
$template->param( |
207 |
$template->param( |
180 |
itemtypes => $itemtypes, |
208 |
itemtypes => $itemtypes, |
181 |
messages => \@messages, |
209 |
messages => \@messages, |