From 32ddbe1b8097a8e9adb1ae832f8e54a99a477e59 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 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 Signed-off-by: Delaye Stephane --- acqui/finishreceive.pl | 13 +++++++++++++ installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 13 +++++++++++++ .../en/modules/admin/preferences/acquisitions.pref | 3 +++ 4 files changed, 30 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 f5a18b2..c729dfc 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -374,3 +374,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( INSERT INTO systempreferences (variable,value,explanation,type) VALUES('EnableBorrowerFiles','0','If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IntranetSlipPrinterJS','','Use this JavaScript for printing slips. Define at least function printThenClose(). For use e.g. with Firefox PlugIn jsPrintSetup, see http://jsprintsetup.mozdev.org/','','Free'); +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 ed0c674..a730cf9 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5635,6 +5635,19 @@ 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.2.5