|
Lines 22-59
Link Here
|
| 22 |
use Modern::Perl; |
22 |
use Modern::Perl; |
| 23 |
|
23 |
|
| 24 |
use CGI qw ( -utf8 ); |
24 |
use CGI qw ( -utf8 ); |
|
|
25 |
|
| 25 |
use C4::Auth qw( get_template_and_user haspermission ); |
26 |
use C4::Auth qw( get_template_and_user haspermission ); |
| 26 |
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); |
|
|
| 27 |
use C4::Biblio qw( |
| 28 |
GetFrameworkCode |
| 29 |
GetMarcFromKohaField |
| 30 |
GetMarcStructure |
| 31 |
IsMarcStructureInternal |
| 32 |
ModBiblio |
| 33 |
); |
| 34 |
use C4::Context; |
| 35 |
use C4::Circulation qw( barcodedecode LostItem ); |
| 36 |
use C4::Barcodes; |
| 37 |
use C4::Barcodes::ValueBuilder; |
27 |
use C4::Barcodes::ValueBuilder; |
|
|
28 |
use C4::Barcodes; |
| 29 |
use C4::Biblio qw( GetFrameworkCode GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal ModBiblio ); |
| 30 |
use C4::Circulation qw( barcodedecode LostItem ); |
| 31 |
use C4::Context; |
| 32 |
use C4::Members; |
| 33 |
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); |
| 34 |
use C4::Search qw( enabled_staff_search_views ); |
| 38 |
use Koha::Biblios; |
35 |
use Koha::Biblios; |
| 39 |
use Koha::Items; |
36 |
use Koha::Item::Templates; |
| 40 |
use Koha::ItemTypes; |
37 |
use Koha::ItemTypes; |
| 41 |
use Koha::Items; |
38 |
use Koha::Items; |
|
|
39 |
use Koha::Items; |
| 42 |
use Koha::Libraries; |
40 |
use Koha::Libraries; |
| 43 |
use Koha::Patrons; |
41 |
use Koha::Patrons; |
| 44 |
use Koha::SearchEngine::Indexer; |
42 |
use Koha::SearchEngine::Indexer; |
| 45 |
use C4::Search qw( enabled_staff_search_views ); |
|
|
| 46 |
use Storable qw( freeze thaw ); |
| 47 |
use URI::Escape qw( uri_escape_utf8 ); |
| 48 |
use C4::Members; |
| 49 |
use Koha::UI::Form::Builder::Item; |
43 |
use Koha::UI::Form::Builder::Item; |
| 50 |
|
44 |
|
| 51 |
use MARC::File::XML; |
|
|
| 52 |
use URI::Escape qw( uri_escape_utf8 ); |
| 53 |
use Encode qw( encode_utf8 ); |
45 |
use Encode qw( encode_utf8 ); |
| 54 |
use MIME::Base64 qw( decode_base64url encode_base64url ); |
|
|
| 55 |
use List::Util qw( first ); |
| 56 |
use List::MoreUtils qw( any uniq ); |
46 |
use List::MoreUtils qw( any uniq ); |
|
|
47 |
use List::Util qw( first ); |
| 48 |
use MARC::File::XML; |
| 49 |
use MIME::Base64 qw( decode_base64url encode_base64url ); |
| 50 |
use Storable qw( freeze thaw ); |
| 51 |
use URI::Escape qw( uri_escape_utf8 ); |
| 52 |
use URI::Escape qw( uri_escape_utf8 ); |
| 57 |
|
53 |
|
| 58 |
our $dbh = C4::Context->dbh; |
54 |
our $dbh = C4::Context->dbh; |
| 59 |
|
55 |
|
|
Lines 85-90
sub add_item_to_item_group {
Link Here
|
| 85 |
)->store(); |
81 |
)->store(); |
| 86 |
} |
82 |
} |
| 87 |
|
83 |
|
|
|
84 |
sub get_item_from_template { |
| 85 |
my ( $template_id ) = @_; |
| 86 |
|
| 87 |
my $template = Koha::Item::Templates->find($template_id); |
| 88 |
|
| 89 |
return $template->decoded_contents if $template; |
| 90 |
} |
| 91 |
|
| 88 |
sub get_item_from_cookie { |
92 |
sub get_item_from_cookie { |
| 89 |
my ( $input ) = @_; |
93 |
my ( $input ) = @_; |
| 90 |
|
94 |
|
|
Lines 174-185
my @errors; # store errors found while checking data BEFORE saving item.
Link Here
|
| 174 |
# Getting last created item cookie |
178 |
# Getting last created item cookie |
| 175 |
my $prefillitem = C4::Context->preference('PrefillItem'); |
179 |
my $prefillitem = C4::Context->preference('PrefillItem'); |
| 176 |
|
180 |
|
|
|
181 |
my $load_template_submit = $input->param('load_template_submit'); |
| 182 |
my $delete_template_submit = $input->param('delete_template_submit'); |
| 183 |
my $unload_template_submit = $input->param('unload_template_submit'); |
| 184 |
my $use_template_for_session = $input->param('use_template_for_session') || $input->cookie('ItemEditorSessionTemplateId'); |
| 185 |
my $template_id = $input->param('template_id') || $input->cookie('ItemEditorSessionTemplateId'); |
| 186 |
if ( $delete_template_submit ) { |
| 187 |
my $t = Koha::Item::Templates->find($template_id); |
| 188 |
$t->delete if $t && $t->borrowernumber eq $loggedinuser; |
| 189 |
$template_id = undef; |
| 190 |
$use_template_for_session = undef; |
| 191 |
} |
| 192 |
if ($load_template_submit || $unload_template_submit) { |
| 193 |
$op = q{} if $template_id; |
| 194 |
|
| 195 |
$template_id = undef if !$input->param('template_id'); |
| 196 |
$template_id = undef if $unload_template_submit; |
| 197 |
|
| 198 |
# Unset the cookie if either no template id as submitted, or "use for session" checkbox as unchecked |
| 199 |
my $cookie_value = $input->param('use_template_for_session') && $template_id ? $template_id : q{}; |
| 200 |
$use_template_for_session = $cookie_value; |
| 201 |
|
| 202 |
# Update the cookie |
| 203 |
my $template_cookie = $input->cookie( |
| 204 |
-name => 'ItemEditorSessionTemplateId', |
| 205 |
-value => $cookie_value, |
| 206 |
-HttpOnly => 1, |
| 207 |
-expires => '', |
| 208 |
-sameSite => 'Lax' |
| 209 |
); |
| 210 |
|
| 211 |
$cookie = [ $cookie, $template_cookie ]; |
| 212 |
} |
| 213 |
$template->param( |
| 214 |
template_id => $template_id, |
| 215 |
item_templates => Koha::Item::Templates->get_available($loggedinuser), |
| 216 |
use_template_for_session => $use_template_for_session, |
| 217 |
); |
| 218 |
|
| 177 |
#------------------------------------------------------------------------------- |
219 |
#------------------------------------------------------------------------------- |
| 178 |
if ($op eq "additem") { |
220 |
if ($op eq "additem") { |
| 179 |
|
221 |
|
| 180 |
my $add_submit = $input->param('add_submit'); |
222 |
my $add_submit = $input->param('add_submit'); |
| 181 |
my $add_duplicate_submit = $input->param('add_duplicate_submit'); |
223 |
my $add_duplicate_submit = $input->param('add_duplicate_submit'); |
| 182 |
my $add_multiple_copies_submit = $input->param('add_multiple_copies_submit'); |
224 |
my $add_multiple_copies_submit = $input->param('add_multiple_copies_submit'); |
|
|
225 |
my $save_as_template_submit = $input->param('save_as_template_submit'); |
| 183 |
my $number_of_copies = $input->param('number_of_copies'); |
226 |
my $number_of_copies = $input->param('number_of_copies'); |
| 184 |
|
227 |
|
| 185 |
my @columns = Koha::Items->columns; |
228 |
my @columns = Koha::Items->columns; |
|
Lines 225-232
if ($op eq "additem") {
Link Here
|
| 225 |
|
268 |
|
| 226 |
$item->barcode(barcodedecode($item->barcode)); |
269 |
$item->barcode(barcodedecode($item->barcode)); |
| 227 |
|
270 |
|
|
|
271 |
if ($save_as_template_submit) { |
| 272 |
my $template_name = $input->param('template_name'); |
| 273 |
my $template_is_shared = $input->param('template_is_shared'); |
| 274 |
my $replace_template_id = $input->param('replace_template_id'); |
| 275 |
|
| 276 |
if ($replace_template_id) { |
| 277 |
my $template = Koha::Item::Templates->find($replace_template_id); |
| 278 |
if ($template) { |
| 279 |
$template->update( |
| 280 |
{ |
| 281 |
id => $replace_template_id, |
| 282 |
is_shared => $template_is_shared ? 1 : 0, |
| 283 |
contents => $item->unblessed, |
| 284 |
} |
| 285 |
); |
| 286 |
} |
| 287 |
} |
| 288 |
else { |
| 289 |
my $template = Koha::Item::Template->new( |
| 290 |
{ |
| 291 |
name => $template_name, |
| 292 |
borrowernumber => $loggedinuser, |
| 293 |
is_shared => $template_is_shared ? 1 : 0, |
| 294 |
contents => $item->unblessed, |
| 295 |
} |
| 296 |
)->store(); |
| 297 |
} |
| 298 |
} |
| 228 |
# If we have to add or add & duplicate, we add the item |
299 |
# If we have to add or add & duplicate, we add the item |
| 229 |
if ( $add_submit || $add_duplicate_submit || $prefillitem) { |
300 |
elsif ( $add_submit || $add_duplicate_submit || $prefillitem) { |
| 230 |
|
301 |
|
| 231 |
# check for item barcode # being unique |
302 |
# check for item barcode # being unique |
| 232 |
if ( defined $item->barcode |
303 |
if ( defined $item->barcode |
|
Lines 585-597
my @header_value_loop = map {
Link Here
|
| 585 |
} sort keys %$subfieldcode_attribute_mappings; |
656 |
} sort keys %$subfieldcode_attribute_mappings; |
| 586 |
|
657 |
|
| 587 |
# Using last created item if it exists |
658 |
# Using last created item if it exists |
| 588 |
if ( $prefillitem |
659 |
if ( |
| 589 |
&& $op ne "additem" |
660 |
$op ne "additem" |
| 590 |
&& $op ne "edititem" |
661 |
&& $op ne "edititem" |
| 591 |
&& $op ne "dupeitem" ) |
662 |
&& $op ne "dupeitem" ) |
| 592 |
{ |
663 |
{ |
| 593 |
my $item_from_cookie = get_item_from_cookie($input); |
664 |
if ( $template_id ) { |
| 594 |
$current_item = $item_from_cookie if $item_from_cookie; |
665 |
my $item_from_template = get_item_from_template($template_id); |
|
|
666 |
$current_item = $item_from_template if $item_from_template; |
| 667 |
} |
| 668 |
elsif ( $prefillitem ) { |
| 669 |
my $item_from_cookie = get_item_from_cookie($input); |
| 670 |
$current_item = $item_from_cookie if $item_from_cookie; |
| 671 |
} |
| 595 |
} |
672 |
} |
| 596 |
|
673 |
|
| 597 |
if ( $current_item->{more_subfields_xml} ) { |
674 |
if ( $current_item->{more_subfields_xml} ) { |