From 7be6d1f12bd765b669e9cc0ac73793ded4cf56c5 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 17 Apr 2008 19:52:56 +0200 Subject: [PATCH] IMPROVEMENT : serialsadditems at subscription level (bump 071) The patch update the DB by adding a row in the subscription table (serialsadditems), that is filled with the value of the syspref. then, the syspref is deleted. Signed-off-by: Joshua Ferraro --- C4/Items.pm | 3 ++- C4/Serials.pm | 22 +++++++++---------- admin/systempreferences.pl | 1 - installer/data/mysql/updatedatabase.pl | 13 +++++++++++ .../prog/en/modules/serials/serials-edit.tmpl | 4 +--- .../en/modules/serials/subscription-add.tmpl | 13 +++++++++-- .../modules/serials/subscription-detail.tmpl | 5 +++++ kohaversion.pl | 2 +- serials/serials-edit.pl | 12 +++++----- serials/subscription-add.pl | 11 ++++++---- 10 files changed, 58 insertions(+), 28 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 427e21f08a..1721eb89f6 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -229,6 +229,8 @@ sub AddItem { # create MARC tag representing item and add to bib my $new_item_marc = _marc_from_item_hash($item, $frameworkcode, $unlinked_item_subfields); + warn "HERE : ".$item->{'biblionumber'}; + warn "HERE 2 : ".$new_item_marc->as_formatted; _add_item_field_to_biblio($new_item_marc, $item->{'biblionumber'}, $frameworkcode ); logaction("CATALOGUING", "ADD", $itemnumber, "item") if C4::Context->preference("CataloguingLog"); @@ -1866,7 +1868,6 @@ sub _add_item_field_to_biblio { my ($item_marc, $biblionumber, $frameworkcode) = @_; my $biblio_marc = GetMarcBiblio($biblionumber); - foreach my $field ($item_marc->fields()) { $biblio_marc->append_fields($field); } diff --git a/C4/Serials.pm b/C4/Serials.pm index e2865caf2c..78d7e4313d 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -239,7 +239,7 @@ sub GetSerialInformation { my ($serialid) = @_; my $dbh = C4::Context->dbh; my $query = qq| - SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid|; + SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid |; if (C4::Context->preference('IndependantBranches') && C4::Context->userenv && C4::Context->userenv->{'flags'} != 1 && C4::Context->userenv->{'branch'}){ @@ -253,8 +253,8 @@ sub GetSerialInformation { my $rq = $dbh->prepare($query); $rq->execute($serialid); my $data = $rq->fetchrow_hashref; - - if ( C4::Context->preference("serialsadditems") ) { + # create item information if we have serialsadditems for this subscription + if ( $data->{'serialsadditems'} ) { if ( $data->{'itemnumber'} ) { my @itemnumbers = split /,/, $data->{'itemnumber'}; foreach my $itemnum (@itemnumbers) { @@ -1239,7 +1239,7 @@ sub ModSubscription { $whenmorethan3, $setto3, $lastvalue3, $innerloop3, $numberingmethod, $status, $biblionumber, $callnumber, $notes, $letter, $hemisphere, $manualhistory, - $internalnotes, + $internalnotes, $serialsadditems, $subscriptionid ) = @_; # warn $irregularity; @@ -1250,7 +1250,7 @@ sub ModSubscription { add1=?,every1=?,whenmorethan1=?,setto1=?,lastvalue1=?,innerloop1=?, add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?,innerloop2=?, add3=?,every3=?,whenmorethan3=?,setto3=?,lastvalue3=?,innerloop3=?, - numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, letter=?, hemisphere=?,manualhistory=?,internalnotes=? + numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, letter=?, hemisphere=?,manualhistory=?,internalnotes=?,serialsadditems=? WHERE subscriptionid = ?"; # warn "query :".$query; my $sth = $dbh->prepare($query); @@ -1265,7 +1265,7 @@ sub ModSubscription { $whenmorethan3, $setto3, $lastvalue3, $innerloop3, $numberingmethod, $status, $biblionumber, $callnumber, $notes, $letter, $hemisphere, ($manualhistory?$manualhistory:0), - $internalnotes, + $internalnotes, $serialsadditems, $subscriptionid ); my $rows=$sth->rows; @@ -1284,7 +1284,7 @@ $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, - $numberingmethod, $status, $notes) + $numberingmethod, $status, $notes, $serialsadditems) Create a new subscription with value given on input args. @@ -1307,7 +1307,7 @@ sub NewSubscription { $lastvalue3, $innerloop3, $numberingmethod, $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern, $callnumber, $hemisphere, $manualhistory, - $internalnotes + $internalnotes, $serialsadditems, ) = @_; my $dbh = C4::Context->dbh; @@ -1320,8 +1320,8 @@ sub NewSubscription { add2,every2,whenmorethan2,setto2,lastvalue2,innerloop2, add3,every3,whenmorethan3,setto3,lastvalue3,innerloop3, numberingmethod, status, notes, letter,firstacquidate,irregularity, - numberpattern, callnumber, hemisphere,manualhistory,internalnotes) - VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + numberpattern, callnumber, hemisphere,manualhistory,internalnotes,serialsadditems) + VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |; my $sth = $dbh->prepare($query); $sth->execute( @@ -1345,7 +1345,7 @@ sub NewSubscription { format_date_in_iso($firstacquidate), $irregularity, $numberpattern, $callnumber, $hemisphere, $manualhistory, - $internalnotes + $internalnotes, $serialsadditems, ); #then create the 1st waited number diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index 58a2cb27bc..558d6feddb 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -99,7 +99,6 @@ my %tabsysprefs; $tabsysprefs{LabelMARCView}="Cataloguing"; $tabsysprefs{marc}="Cataloguing"; $tabsysprefs{marcflavour}="Cataloguing"; - $tabsysprefs{serialsadditems}="Cataloguing"; $tabsysprefs{MARCOrgCode}="Cataloguing"; $tabsysprefs{z3950AuthorAuthFields}="Cataloguing"; $tabsysprefs{z3950NormalizeAuthor}="Cataloguing"; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index e227701694..c9fddefa70 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -1292,6 +1292,19 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.00.071"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do(" ALTER TABLE `subscription` ADD `serialsadditems` TINYINT( 1 ) NOT NULL DEFAULT '0';"); + # fill the new field with the previous systempreference value, then drop the syspref + my $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='serialsadditems'"); + $sth->execute; + my ($serialsadditems) = $sth->fetchrow(); + $dbh->do("UPDATE subscription SET serialsadditems=$serialsadditems"); + $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'"); + print "Upgrade to $DBversion done ( moving serialsadditems from syspref to subscription )\n"; + SetVersion ($DBversion); +} + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl index 6eeb3ca753..126fb2c306 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl @@ -60,7 +60,6 @@ function Check(f) { alert(alertString2); } } - function unHideItems(index,labelindex) { subfield = document.getElementById(index); subfield.style.display = 'block'; @@ -137,7 +136,6 @@ function CloneSubfield(index){ // insert this line on the page original.parentNode.insertBefore(clone,original.nextSibling); } -
" class="items">
"> - + " /> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl index 5c7198f62f..93e2219aa2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl @@ -820,7 +820,7 @@ window.onload = irregular_order();
Subscription details
    -
  1. Subscription #
  2. +
  3. Subscription #
  4. Librarian:
  5. @@ -837,6 +837,15 @@ window.onload = irregular_order(); Create Biblio
+
  • + + + + + + + +
  • " size="20" /> @@ -890,7 +899,7 @@ window.onload = irregular_order();
  • You must select a vendor if you wish to generate claims.
  • - + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl index 0950afdd97..df83ea7376 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl @@ -116,6 +116,11 @@ function popup(subscriptionid) {
  • Vendor: "> 
  • Biblio: () ">

  • Library:  
  • + +
  • Serial recieve create an item
  • + +
  • Serial recieve don't create an item
  • +
  • Call Number:  
  • Patron alert with:  
  • Notes:
  • diff --git a/kohaversion.pl b/kohaversion.pl index 938e935d7d..c92a670549 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = "3.00.00.070"; + our $VERSION = "3.00.00.071"; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 93cf630463..a7b01b68e6 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -130,12 +130,14 @@ my $bibdata=GetBiblioData($serialdatalist[0]->{'biblionumber'}); my @newserialloop; my @subscriptionloop; +# check, for each subscription edited, that we have an empty item line if applicable for the subscription foreach my $subscriptionid (@subscriptionids){ my $cell; - if (C4::Context->preference("serialsadditems")){ + if ($serialdatalist[0]->{'serialsadditems'}){ #Create New empty item $cell = - PrepareItemrecordDisplay( $serialdatalist[0]->{'biblionumber'} ); + PrepareItemrecordDisplay( $serialdatalist[0]->{'biblionumber'} ); + $cell->{serialsadditems} = 1; } $cell->{'subscriptionid'}=$subscriptionid; $cell->{'itemid'} = "NNEW"; @@ -175,8 +177,8 @@ if ($op eq 'serialchangestatus') { $notes[$i]); } } - if (C4::Context->preference("serialsadditems")){ - my @moditems = $query->param('moditem'); + my @moditems = $query->param('moditem'); + if (scalar(@moditems)){ my @tags = $query->param('tag'); my @subfields = $query->param('subfield'); my @field_values = $query->param('field_value'); @@ -227,7 +229,7 @@ if ($op eq 'serialchangestatus') { my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode"); if (C4::Context->preference("autoBarcode") ne 'OFF' ) { eval { $record->field($tagfield)->subfield($tagsubfield) }; - if ($@) { + if ($@) { my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items"); $sth_barcode->execute; my ($newbarcode) = $sth_barcode->fetchrow; diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index a4b48d1104..d7cd4fff79 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -40,7 +40,7 @@ my ($subscriptionid,$auser,$branchcode,$librarian,$cost,$aqbooksellerid, $aqbook $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, $numberingmethod, $status, $biblionumber, - $bibliotitle, $callnumber, $notes, $hemisphere, $letter, $manualhistory); + $bibliotitle, $callnumber, $notes, $hemisphere, $letter, $manualhistory,$serialsadditems); my @budgets; my ($template, $loggedinuser, $cookie) @@ -220,13 +220,15 @@ if ($op eq 'addsubscription') { my $letter = $query->param('letter'); # ## BugFIX : hdl doesnot know what innerloops or letter stand for but it seems necessary. So he adds them. my $manualhistory = $query->param('manualhist'); + my $serialsadditems = $query->param('serialsadditems'); my $subscriptionid = NewSubscription($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, $numberingmethod, $status, $notes,$letter,$firstacquidate,join(",",@irregularity), - $numberpattern, $callnumber, $hemisphere,($manualhistory?$manualhistory:0),$internalnotes + $numberpattern, $callnumber, $hemisphere,($manualhistory?$manualhistory:0),$internalnotes, + $serialsadditems, ); print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); @@ -289,9 +291,9 @@ if ($op eq 'addsubscription') { my $letter = $query->param('letter'); my $manualhistory = $query->param('manualhist'); my $enddate = $query->param('enddate'); + my $serialsadditems = $query->param('serialsadditems'); # subscription history my $histenddate = format_date_in_iso($query->param('histenddate')); - warn "HIST END : $histenddate"; my $histstartdate = format_date_in_iso($query->param('histstartdate')); my $recievedlist = $query->param('recievedlist'); my $missinglist = $query->param('missinglist'); @@ -312,7 +314,8 @@ if ($op eq 'addsubscription') { $whenmorethan3, $setto3, $lastvalue3, $innerloop3, $numberingmethod, $status, $biblionumber, $callnumber, $notes, $letter, $hemisphere, $manualhistory,$internalnotes, - $subscriptionid); + $serialsadditems, $subscriptionid, + ); } print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); } else { -- 2.39.5