From 4b36244c7398c3af9a83293b848b71bbce5cc499 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 18 May 2012 13:42:36 +0200 Subject: [PATCH] Bug 8307: Set a value for subfields when receiving If items are created when ordering, this patch allows to add a value for some items subfields. Test plan: Define status for items.notforloan (mapping 995$o in unimarc), for example 4:On order, 5:On treatment Set the Syspref AcqCreateItem on "ordering". ACQ framework : set default value = 4 for 995$o (in unimarc) Syspref AcqItemSetSubfieldsWhenReceived : set "o=5|b='foo bar'" When ordering the item, default status will be 4 ; when receiving the item, status will be changed from 4 to 5. The subfield b have to contain 'foo bar' Signed-off-by: Frederic Durand Signed-off-by: Marcel de Rooy --- acqui/finishreceive.pl | 16 +++++++++++++++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 9 +++++++++ .../modules/admin/preferences/acquisitions.pref | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index 4196b52815..0c62f2407c 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -62,6 +62,21 @@ if ($quantityrec > $origquantityrec ) { my @received_items = (); if(C4::Context->preference('AcqCreateItem') eq 'ordering') { @received_items = $input->param('items_to_receive'); + my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceived"); + if ( @affects ) { + my $frameworkcode = GetFrameworkCode($biblionumber); + my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $frameworkcode ); + for my $in ( @received_items ) { + my $item = C4::Items::GetMarcItem( $biblionumber, $in ); + for my $affect ( @affects ) { + my ( $sf, $v ) = split q{=}, $affect; + foreach ( $item->field($itemfield) ) { + $_->update( $sf => $v ); + } + } + C4::Items::ModItemFromMarc( $item, $biblionumber, $in ); + } + } } $order->{rrp} = $rrp; @@ -136,7 +151,6 @@ if ($quantityrec > $origquantityrec ) { NewOrderItem($itemnumber, $new_ordernumber); } } - } update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber ); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 07e9c0a826..dac25950fd 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -1,5 +1,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('AcqCreateItem','ordering','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice'), +('AcqItemStatusWhenReceived','0','','This syspref set a status for item when items are created when receiving (e.g. 995\$o=5)','Free'), ('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'), ('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'), ('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index c511773fe4..e8acfb87e8 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7728,6 +7728,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion($DBversion); } +$DBversion = "3.13.00.XXX"; +if(CheckVersion($DBversion)) { + $dbh->do(q{ + INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AcqItemSetSubfieldsWhenReceived','','Set subfields for item when items are created when receiving (e.g. o=5|a="foo bar")','','Free'); + }); + print "Upgrade to $DBversion done (Added AcqItemSetSubfieldsWhenReceived syspref)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref index 3e64d10852..5eba790a44 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -42,6 +42,9 @@ Acquisitions: yes: Warn no: "Do not warn" - when the librarian tries to create an invoice with a duplicate number. + - + - pref: AcqItemSetSubfieldsWhenReceived + - Set subfields for item when items are created when receiving (e.g. o=5|a="foo bar") Printing: - -- 2.39.5