From 4de95852c62b4df7337cfd14e1d1934775d4f2a4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 18 May 2012 13:42:36 +0200 Subject: [PATCH 1/1] Bug 8307: Set a value for items when ordering If items are created when ordering, this patch allows to add a value for a field. 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 AcqItemStatusWhenReceived : set "995$o=5" When ordering the item, default status will be 4 ; when receiving the item, status will be changed from 4 to 5 --- acqui/finishreceive.pl | 13 +++++++++++++ installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 14 ++++++++++++++ .../en/modules/admin/preferences/acquisitions.pref | 3 +++ 4 files changed, 31 insertions(+), 0 deletions(-) diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index 84391f5..9218278 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -98,6 +98,19 @@ if ($quantityrec > $origquantityrec ) { my @received_items = (); if(C4::Context->preference('AcqCreateItem') eq 'ordering') { @received_items = $input->param('items_to_receive'); + my ( $field, $value ) = split '=', C4::Context->preference("AcqItemStatusWhenReceived"); + my $frameworkcode = GetFrameworkCode($biblionumber); + my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $frameworkcode ); + if ( $field and $field =~ /^$itemfield\$/ and $value ) { + my ( $fv, $sfv ) = split '\$', $field; + for my $in ( @received_items ) { + my $item = C4::Items::GetMarcItem( $biblionumber, $in ); + foreach ( $item->field($itemfield) ) { + $_->update( $sfv => $value ); + } + C4::Items::ModItemFromMarc( $item, $biblionumber, $in ); + } + } } # save the quantity received. diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 6c6d91b..55c0ed3 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -371,3 +371,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsOpac', '1', NULL , 'Allow holds to be suspended from the OPAC.', 'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('DefaultLanguageField008','','Fill in the default language for field 008 Range 35-37 (e.g. eng, nor, ger, see MARC Code List for Languages)','','Free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACShowBarcode','0','Show items barcode in holding tab','','YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AcqItemStatusWhenReceived','0','This syspref set a status for item when items are created when receiving (e.g. 995\$o=5)','','Free'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d06a188..7b39caf 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5392,6 +5392,20 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } + + + + +$DBversion = "3.09.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AcqItemStatusWhenReceived','0','This syspref set a status for item when items are created when receiving (e.g. 995\$o=5)','','Free');"); + print "Upgrade to $DBversion done (Added AcqItemStatusWhenReceived 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 ebae997..cafdfd0 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 @@ -35,6 +35,9 @@ Acquisitions: - The default tax rate is - pref: gist - (enter in numeric form, 0.12 for 12%) + - + - pref: AcqItemStatusWhenReceived + - Set a status for item when items are created when receiving (e.g. 995$o=5) Printing: - -- 1.7.7.3