my ( $itemtagfield, $itemtagsubfield ) =
&GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
my $tagslib = &GetMarcStructure( 1, $frameworkcode );
- my $itemrecord = GetMarcItem( $bibnum, $itemnum) if ($itemnum);
+ my $itemrecord = C4::Items::GetMarcItem( $bibnum, $itemnum) if ($itemnum);
my @loop_data;
my $authorised_values_sth =
$dbh->prepare(
=over 4
-$item = GetItem($itemnumber,$barcode);
+$item = GetItem($itemnumber,$barcode,$serial);
=back
Return item information, for a given itemnumber or barcode.
The return value is a hashref mapping item column
-names to values.
+names to values. If C<$serial> is true, include serial publication data.
=cut
sub GetItem {
- my ($itemnumber,$barcode) = @_;
+ my ($itemnumber,$barcode, $serial) = @_;
my $dbh = C4::Context->dbh;
+ my $data;
if ($itemnumber) {
my $sth = $dbh->prepare("
SELECT * FROM items
WHERE itemnumber = ?");
$sth->execute($itemnumber);
- my $data = $sth->fetchrow_hashref;
- return $data;
+ $data = $sth->fetchrow_hashref;
} else {
my $sth = $dbh->prepare("
SELECT * FROM items
WHERE barcode = ?"
);
- $sth->execute($barcode);
- my $data = $sth->fetchrow_hashref;
- return $data;
+ $sth->execute($barcode);
+ $data = $sth->fetchrow_hashref;
}
+ if ( $serial) {
+ my $ssth = $dbh->prepare("SELECT serialseq,publisheddate from serial where itemnumber=?");
+ $ssth->execute($data->{'itemnumber'}) ;
+ ($data->{'serialseq'} , $data->{'publisheddate'}) = $ssth->fetchrow_array();
+ }
+ return $data;
} # sub GetItem
=head2 AddItemFromMarc
# parse item hash from MARC
my $frameworkcode = GetFrameworkCode( $biblionumber );
my $item = &TransformMarcToKoha( $dbh, $source_item_marc, $frameworkcode );
-
return AddItem($item, $biblionumber, $dbh, $frameworkcode);
}
_set_defaults_for_add($item);
_set_derived_columns_for_add($item);
# FIXME - checks here
- my ( $itemnumber, $error ) = _koha_new_item( $dbh, $item, $item->{barcode} );
+ my ( $itemnumber, $error ) = _koha_new_item( $dbh, $item, $item->{barcode} );
$item->{'itemnumber'} = $itemnumber;
# create MARC tag representing item and add to bib
$sth->execute($biblionumber);
my $i = 0;
my @results;
- my ( $date_due, $count_reserves );
+ my ( $date_due, $count_reserves, $serial );
my $isth = $dbh->prepare(
"SELECT issues.*,borrowers.cardnumber,borrowers.surname,borrowers.firstname,borrowers.branchcode as bcode
WHERE itemnumber = ?
AND returndate IS NULL"
);
- while ( my $data = $sth->fetchrow_hashref ) {
+ my $ssth = $dbh->prepare("SELECT serialseq,publisheddate from serial where itemnumber=?");
+ while ( my $data = $sth->fetchrow_hashref ) {
my $datedue = '';
$isth->execute( $data->{'itemnumber'} );
if ( my $idata = $isth->fetchrow_hashref ) {
}
}
}
- if ( $datedue eq '' ) {
+ if ( $data->{'serial'}) {
+ $ssth->execute($data->{'itemnumber'}) ;
+ ($data->{'serialseq'} , $data->{'publisheddate'}) = $ssth->fetchrow_array();
+ $serial = 1;
+ }
+ if ( $datedue eq '' ) {
my ( $restype, $reserves ) =
C4::Reserves::CheckReserves( $data->{'itemnumber'} );
if ($restype) {
}
}
$isth->finish;
-
+ $ssth->finish;
#get branch information.....
my $bsth = $dbh->prepare(
"SELECT * FROM branches WHERE branchcode = ?
$i++;
}
$sth->finish;
-
- return (@results);
+ if($serial) {
+ return( sort { $b->{'publisheddate'} cmp $a->{'publisheddate'} } @results );
+ } else {
+ return (@results);
+ }
}
=head2 get_itemnumbers_of
my ( $dbh, $item, $barcode ) = @_;
my $error;
- my $query =
+ my $query =
"INSERT INTO items SET
biblionumber = ?,
biblioitemnumber = ?,
ccode = ?,
itype = ?,
materials = ?,
- uri = ?
+ uri = ?,
";
my $sth = $dbh->prepare($query);
- $sth->execute(
+ $sth->execute(
$item->{'biblionumber'},
$item->{'biblioitemnumber'},
$barcode,
&logaction(C4::Context->userenv->{'number'},"SERIAL","ADD",$subscriptionid,"")
if C4::Context->preference("SubscriptionLog");
+#set serial flag on biblio if not already set.
+ my ($null, ($bib)) = GetBiblio($biblionumber);
+ if( ! $bib->{'serial'} ) {
+ my $record = GetMarcBiblio($biblionumber);
+ my ($tag,$subf) = GetMarcFromKohaField('biblio.serial',$bib->{'frameworkcode'});
+ if($tag) {
+ $record->field($tag)->update( $subf => 1 );
+ }
+ ModBiblio($record,$biblionumber,$bib->{'frameworkcode'});
+ }
return $subscriptionid;
}
('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, '', '', '', NULL),
('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, '', '', '', NULL),
('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, '', '', '', NULL),
- ('942', 'c', 'Koha item type', 'Koha item type', 0, 1, 'biblioitems.itemtype', 9, 'itemtypes', '', '', NULL, 0, '', '', '', NULL),
+ ('942', 'c', 'Koha (default) item type', 'Koha item type', 0, 1, 'biblioitems.itemtype', 9, 'itemtypes', '', '', NULL, 0, '', '', '', NULL),
('942', 'e', 'Edition', 'Edition', 0, 0, 'biblioitems.cn_edition', 9, 'CN_EDITION', '', '', NULL, 0, '', '', '', NULL),
('942', 'h', 'Classification part', 'Classification part', 0, 0, 'biblioitems.cn_class', 9, '', '', '', NULL, 0, '', '', '', NULL),
('942', 'i', 'Item part', 'Item part', 1, 0, 'biblioitems.cn_item', 9, '', '', '', NULL, 9, '', '', '', NULL),
('942', 'k', 'Call number prefix', 'Call number prefix', 0, 0, 'biblioitems.cn_prefix', 9, '', '', '', NULL, 0, '', '', '', NULL),
('942', 'm', 'Call number suffix', 'Call number suffix', 0, 0, 'biblioitems.cn_suffix', 9, '', '', '', 0, 0, '', '', '', NULL),
- ('942', 'n', 'Suppress in OPAC', 'Suppress in OPAC', 0, 0, NULL, 9, '', '', '', 0, 0, '', '', '', NULL);
+ ('942', 'n', 'Suppress in OPAC', 'Suppress in OPAC', 0, 0, NULL, 9, '', '', '', 0, 0, '', '', '', NULL),
+ ('942', 's', 'Serial record flag', 'Serial record', 0, 0, 'biblio.serial', 9, '', '', '', NULL, -5, '', '', '', NULL),;
-- ******************************************************
('990', 'i', 'Item part', 'Item part', 1, 0, 'biblioitems.cn_item', 9, '', '', '', NULL, 9, '', '', '', NULL),
('990', 'k', 'Call number prefix', 'Call number prefix', 0, 0, 'biblioitems.cn_prefix', 9, '', '', '', NULL, 0, '', '', '', NULL),
('990', 'm', 'Call number suffix', 'Call number suffix', 0, 0, 'biblioitems.cn_suffix', 9, '', '', '', 0, 0, '', '', '', NULL),
- ('990', 'n', 'Suppress in OPAC', 'Suppress in OPAC', 0, 0, NULL, 9, '', '', '', 0, 0, '', '', '', NULL);
+ ('990', 'n', 'Suppress in OPAC', 'Suppress in OPAC', 0, 0, NULL, 9, '', '', '', 0, 0, '', '', '', NULL),
+ ('990', 's', 'Serial record flag', 'Serial record', 0, 0, 'biblio.serial', 9, '', '', '', NULL, -5, '', '', '', NULL);
-- ******************************************************
`planneddate` date default NULL,
`notes` text,
`publisheddate` date default NULL,
- `itemnumber` text,
+ `itemnumber` int(11) default NULL,
`claimdate` date default NULL,
`routingnotes` text,
- PRIMARY KEY (`serialid`)
+ PRIMARY KEY (`serialid`),
+ KEY serialitem (`itemnumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
`aqbooksellerid` int(11) default 0,
`cost` int(11) default 0,
`aqbudgetid` int(11) default 0,
- `weeklength` tinyint(4) default 0,
- `monthlength` tinyint(4) default 0,
- `numberlength` tinyint(4) default 0,
+ `weeklength` int(11) default 0,
+ `monthlength` int(11) default 0,
+ `numberlength` int(11) default 0,
`periodicity` tinyint(4) default 0,
`dow` varchar(100) default '',
`numberingmethod` varchar(100) default '',
SetVersion ($DBversion);
}
+$DBversion = "3.00.00.046";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `serial` CHANGE `itemnumber` `itemnumber` int(11) default NULL");
+ $dbh->do("ALTER TABLE `subscription` CHANGE `numberlength` `numberlength` int(11) default NULL ,
+ CHANGE `weeklength` `weeklength` int(11) default NULL");
+ $dbh->do("ALTER TABLE `serial` ADD UNIQUE KEY `serialitemidx` (`itemnumber`)");
+ print "Upgrade to $DBversion done (Update serial table, add index on itemnumber. )\n";
+ SetVersion ($DBversion);
+}
+
=item DropAllForeignKeys($table)
Drop all foreign keys of the table $table
<tr>
<th>Numbered</th>
<th>Published on</th>
- <th>planned for</th>
+ <th>Planned for</th>
<th>Status</th>
<th>Notes</th>
</tr>
<!-- TMPL_LOOP NAME="items" -->
<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='visibility' -->;" id="subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
+ <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="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
<input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
<input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
- <!-- TMPL_IF NAME="repeatable" -->
+ <!-- TMPL_IF NAME="ITEM_SUBFIELDS_ARE_NOT_REPEATABLE" -->
<span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
<!-- /TMPL_IF -->
</div>
- <!-- /tmpl_loop -->
+ <!-- /tmpl_loop --><!-- /iteminformation -->
<input type="hidden" name="moditem" value="" />
<input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="itemtagfield" -->" />
<input type="hidden" name="itemid" value="<!-- TMPL_VAR NAME="itemid" -->" />
<input type="hidden" name="field_value" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
</div>
- <!--/TMPL_LOOP-->
+ <!--/TMPL_LOOP--> <!-- /items -->
</div>
</fieldset>
</td>
<div id="cataloguing_additem_itemlist">
<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='visibility' -->;" id="subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
+ <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="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
<input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
<input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
- <!-- TMPL_IF NAME="repeatable" -->
+ <!-- TMPL_IF NAME="ITEM_SUBFIELDS_ARE_NOT_REPEATABLE" -->
<span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
<!-- /TMPL_IF -->
</div>
<th>Status</th>
<th>Date Due</th>
<th>Last Seen</th>
- <th>Volume</th>
+ <!-- TMPL_IF NAME="serial" --><th>Copy / Vol</th>
+ <th>Published</th><!-- /TMPL_IF -->
</tr>
<!-- TMPL_LOOP NAME="ITEM_RESULTS" -->
<tr>
<!-- /TMPL_IF --></td>
<td><!-- TMPL_VAR NAME="datedue" --></td>
<td><!-- TMPL_VAR NAME="datelastseen" --></td>
- <td><!-- TMPL_VAR NAME="volumeddesc" --></td>
+ <!-- TMPL_IF NAME="serial" --><td><!-- TMPL_VAR NAME="serialseq" --> </td>
+ <td><!-- TMPL_VAR NAME="publisheddate" --> </td><!-- /TMPL_IF -->
<!-- TMPL_IF NAME="type" -->
<td><a href="/cgi-bin/koha/maint/catmaintain.pl?type=fixitemtype&bi=<!-- TMPL_VAR NAME="biblioitemnumber" -->&item=<!-- TMPL_VAR NAME="itemtype" -->">Fix Itemtype</a></td>
<!-- /TMPL_IF -->
use strict;
sub kohaversion {
- our $VERSION = "3.00.00.044";
+ our $VERSION = "3.00.00.046";
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install
my @subscriptions =
GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
my @subs;
+$dat->{'serial'}=1 if $subscriptionsnumber;
foreach my $subscription (@subscriptions) {
my %cell;
$cell{subscriptionid} = $subscription->{subscriptionid};
push @subs, \%cell;
}
-$dat->{'count'} = @items;
+$dat->{'count'} = scalar(@items);
#adding RequestOnOpac filter to allow or not the display of plce reserve button
# FIXME - use me or delete me.
my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
if ($item=~/^N/){
#New Item
+ # add serialid to item record
+ my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.itemnumber");
+ my $field = $record->field($tagfield);
+ my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.serialid");
+ if ($tagsubfield ) {
+ $field->update($tagsubfield => $itemhash{$item}->{'serial'});
+ }
+
# if autoBarcode is ON, calculate barcode...
my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode");
if (C4::Context->preference("autoBarcode") ne 'OFF' ) {
my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items");
$sth_barcode->execute;
my ($newbarcode) = $sth_barcode->fetchrow;
- $newbarcode++;
- # OK, we have the new barcode, now create the entry in MARC record
- $record->add_fields( $tagfield, "1", "0",
- $tagsubfield => $newbarcode );
+ # OK, we have the new barcode, add the entry in MARC record # FIXME -> should be using barcode plugin here.
+ $field->update( $tagsubfield => ++$newbarcode );
}
}
# check for item barcode # being unique
# push @errors,"barcode_not_unique" if($exists);
$template->param("barcode_not_unique" => 1,'errserialseq'=>$serialseqs[$index]);
# if barcode exists, don't create, but report The problem.
- unless ($exists){
+ unless ($exists){
my ($biblionumber,$bibitemnum,$itemnumber) = AddItemFromMarc($record,$itemhash{$item}->{'bibnum'});
AddItem2Serial($itemhash{$item}->{'serial'},$itemnumber);
}
use CGI;
use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days);
use C4::Koha;
+use C4::Biblio;
use C4::Auth;
use C4::Dates qw/format_date format_date_in_iso/;
use C4::Acquisition;
}
if ($op eq 'addsubscription') {
-
my $auser = $query->param('user');
my $branchcode = $query->param('branchcode');
my $aqbooksellerid = $query->param('aqbooksellerid');