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 <jmf@liblime.com>
# 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");
my ($item_marc, $biblionumber, $frameworkcode) = @_;
my $biblio_marc = GetMarcBiblio($biblionumber);
-
foreach my $field ($item_marc->fields()) {
$biblio_marc->append_fields($field);
}
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'}){
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) {
$whenmorethan3, $setto3, $lastvalue3, $innerloop3,
$numberingmethod, $status, $biblionumber, $callnumber,
$notes, $letter, $hemisphere, $manualhistory,
- $internalnotes,
+ $internalnotes, $serialsadditems,
$subscriptionid
) = @_;
# warn $irregularity;
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);
$whenmorethan3, $setto3, $lastvalue3, $innerloop3,
$numberingmethod, $status, $biblionumber, $callnumber,
$notes, $letter, $hemisphere, ($manualhistory?$manualhistory:0),
- $internalnotes,
+ $internalnotes, $serialsadditems,
$subscriptionid
);
my $rows=$sth->rows;
$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.
$lastvalue3, $innerloop3, $numberingmethod, $status,
$notes, $letter, $firstacquidate, $irregularity,
$numberpattern, $callnumber, $hemisphere, $manualhistory,
- $internalnotes
+ $internalnotes, $serialsadditems,
) = @_;
my $dbh = C4::Context->dbh;
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(
format_date_in_iso($firstacquidate), $irregularity,
$numberpattern, $callnumber,
$hemisphere, $manualhistory,
- $internalnotes
+ $internalnotes, $serialsadditems,
);
#then create the 1st waited number
$tabsysprefs{LabelMARCView}="Cataloguing";
$tabsysprefs{marc}="Cataloguing";
$tabsysprefs{marcflavour}="Cataloguing";
- $tabsysprefs{serialsadditems}="Cataloguing";
$tabsysprefs{MARCOrgCode}="Cataloguing";
$tabsysprefs{z3950AuthorAuthFields}="Cataloguing";
$tabsysprefs{z3950NormalizeAuthor}="Cataloguing";
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
alert(alertString2);
}
}
-<!--TMPL_IF Name="serialsadditems"-->
function unHideItems(index,labelindex) {
subfield = document.getElementById(index);
subfield.style.display = 'block';
// insert this line on the page
original.parentNode.insertBefore(clone,original.nextSibling);
}
-<!--/TMPL_IF>
//]]>
</script>
</head>
<div id="item<!-- TMPL_VAR NAME="serialid" --><!-- TMPL_VAR NAME="countitems" -->" class="items">
<!-- TMPL_LOOP NAME="iteminformation" -->
<div name="line" class="subfield_line" style="<!-- TMPL_VAR NAME='hidden' -->;" id="subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
-
+
<label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
<!-- TMPL_VAR NAME="marc_value" -->
<input type="hidden" name="itemid" value="<!-- TMPL_VAR NAME="itemid" -->" />
<fieldset id="subscription_add_information" class="rows">
<legend>Subscription details</legend>
<ol>
- <li><span class="label">Subscription #</span> <!--TMPL_VAR name="subscriptionid"--></li>
+ <li><span class="label">Subscription #</span> <!--TMPL_VAR name="subscriptionid"--></li>
<li>
<span class="label">Librarian: </span> <!-- TMPL_VAR name="loggedinusername" -->
</li>
<a href="#" onclick="addbiblioPopup(); return false;">Create Biblio</a><!--/TMPL_IF--></div>
</li>
+ <li class="radio">
+ <!-- TMPL_IF name="serialsadditems" -->
+ <label for="serialsadditems-yes">serial recieve create an item </label><input type="radio" id="serialsadditems-yes" name="serialsadditems" value="1" checked="checked" />
+ <label for="serialsadditems-no">serial recieve don't create an item </label><input type="radio" id="serialsadditems-no" name="serialsadditems" value="0" />
+ <!-- TMPL_ELSE -->
+ <label for="serialsadditems-yes">serial recieve create an item </label><input type="radio" id="serialsadditems-yes" name="serialsadditems" value="1"/>
+ <label for="serialsadditems-no">serial recieve don't create an item </label><input type="radio" id="serialsadditems-no" name="serialsadditems" value="0" checked="checked" />
+ <!-- /TMPL_IF -->
+ </li>
<li>
<label for="callnumber">Call Number</label>
<input type="text" name="callnumber" id="callnumber" value="<!-- TMPL_VAR name="callnumber" -->" size="20" />
<li>You <b>must</b> select a vendor if you wish to generate claims.</li>
</ul></div>
-
+
</fieldset>
</div>
<li><span class="label">Vendor:</span> <a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!-- TMPL_VAR name="aqbooksellerid"-->"><!-- TMPL_VAR name="aqbooksellername" --> </a></li>
<li><span class="label">Biblio:</span> <i>(<!-- TMPL_VAR name="bibnum" -->)</i> <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR name="bibnum" -->"><!-- TMPL_VAR name="bibliotitle" --></a></li><br />
<!-- TMPL_IF name="branchcode" --><li><span class="label">Library:</span> <!-- TMPL_VAR name="branchcode" --> </li><!-- /TMPL_IF -->
+ <!-- TMPL_IF name="serialsadditems" -->
+ <li>Serial recieve create an item</li>
+ <!-- TMPL_ELSE -->
+ <li>Serial recieve don't create an item</li>
+ <!-- /TMPL_IF -->
<!-- TMPL_IF name="callnumber" --><li><span class="label">Call Number:</span> <!-- TMPL_VAR name="callnumber" --> </li><!-- /TMPL_IF -->
<!-- TMPL_IF name="letter" --><li><span class="label">Patron alert with:</span> <!-- TMPL_VAR name="letter" --> </li><!-- /TMPL_IF -->
<!-- TMPL_IF name="notes" --><li><span class="label">Notes:</span> <!-- TMPL_VAR name="notes" --></li><!-- /TMPL_IF -->
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
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";
$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');
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;
$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)
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");
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');
$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 {