my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} );
$item->{'itemnumber'} = $itemnumber;
- ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver", undef, undef );
+ ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" );
logaction("CATALOGUING", "ADD", $itemnumber, "item") if C4::Context->preference("CataloguingLog");
# request that bib be reindexed so that searching on current
# item status is possible
- ModZebra( $biblionumber, "specialUpdate", "biblioserver", undef, undef );
+ ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
logaction("CATALOGUING", "MODIFY", $itemnumber, Dumper($item)) if C4::Context->preference("CataloguingLog");
}
# get the MARC record
my $record = GetMarcBiblio($biblionumber);
- ModZebra( $biblionumber, "specialUpdate", "biblioserver", undef, undef );
+ ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
# backup the record
my $copy2deleted = $dbh->prepare("UPDATE deleteditems SET marc=? WHERE itemnumber=?");
$data->{firstname} = $idata->{firstname};
$data->{lastreneweddate} = $idata->{lastreneweddate};
$datedue = $idata->{'date_due'};
- if (C4::Context->preference("IndependantBranches")){
+ if (C4::Context->preference("IndependentBranches")){
my $userenv = C4::Context->userenv;
if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
$data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
# get restricted status and description if applicable
if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
- $data->{restricted} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted} );
$data->{restrictedopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted}, 1 );
+ $data->{restricted} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted} );
}
# my stack procedures
$sth = $dbh->prepare("UPDATE items SET biblioitemnumber = ?, biblionumber = ? WHERE itemnumber = ? AND biblionumber = ?");
my $return = $sth->execute($tobiblioitem, $tobiblio, $itemnumber, $frombiblio);
if ($return == 1) {
- ModZebra( $tobiblio, "specialUpdate", "biblioserver", undef, undef );
- ModZebra( $frombiblio, "specialUpdate", "biblioserver", undef, undef );
+ ModZebra( $tobiblio, "specialUpdate", "biblioserver" );
+ ModZebra( $frombiblio, "specialUpdate", "biblioserver" );
# Checking if the item we want to move is in an order
require C4::Acquisition;
my $order = C4::Acquisition::GetOrderFromItemnumber($itemnumber);
if ($onloan){
$error = "book_on_loan"
}
- elsif ( !(C4::Context->userenv->{flags} & 1) and
- C4::Context->preference("IndependantBranches") and
- (C4::Context->userenv->{branch} ne
- $item->{C4::Context->preference("HomeOrHoldingBranch")||'homebranch'}) )
+ elsif ( !( C4::Context->userenv->{flags} & 1 )
+ and C4::Context->preference("IndependentBranches")
+ and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
{
$error = "not_same_branch";
}
my $query = "UPDATE items SET ";
my @bind;
for my $key ( keys %$item ) {
+ next if ( $key eq 'itemnumber' );
$query.="$key=?,";
push @bind, $item->{$key};
}
sub GetAnalyticsCount {
my ($itemnumber) = @_;
require C4::Search;
- if (C4::Context->preference('NoZebra')) {
- # Read the index Koha-Auth-Number for this authid and count the lines
- my $result = C4::Search::NZanalyse("hi=$itemnumber");
- my @tab = split /;/,$result;
- return scalar @tab;
- } else {
- ### ZOOM search here
- my $query;
- $query= "hi=".$itemnumber;
- my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
- return ($result);
- }
+
+ ### ZOOM search here
+ my $query;
+ $query= "hi=".$itemnumber;
+ my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
+ return ($result);
}
=head2 GetItemHolds
$defaultvalue = $tagslib->{$tag}->{$subfield}->{defaultvalue} unless $defaultvalue;
if ( !defined $defaultvalue ) {
$defaultvalue = q||;
+ } else {
+ $defaultvalue =~ s/"/"/g;
}
- $defaultvalue =~ s/"/"/g;
# search for itemcallnumber if applicable
if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber'
&& C4::Context->preference('itemcallnumber') ) {
my $CNtag = substr( C4::Context->preference('itemcallnumber'), 0, 3 );
my $CNsubfield = substr( C4::Context->preference('itemcallnumber'), 3, 1 );
- if ($itemrecord) {
- my $temp = $itemrecord->field($CNtag);
- if ($temp) {
- $defaultvalue = $temp->subfield($CNsubfield);
- }
+ if ( $itemrecord and my $field = $itemrecord->field($CNtag) ) {
+ $defaultvalue = $field->subfield($CNsubfield);
}
}
if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber'
&& $defaultvalues
&& $defaultvalues->{'callnumber'} ) {
- my $temp;
- if ($itemrecord) {
- $temp = $itemrecord->field($subfield);
- }
- unless ($temp) {
- $defaultvalue = $defaultvalues->{'callnumber'} if $defaultvalues;
+ if( $itemrecord and $defaultvalues and not $itemrecord->field($subfield) ){
+ # if the item record exists, only use default value if the item has no callnumber
+ $defaultvalue = $defaultvalues->{callnumber};
+ } elsif ( !$itemrecord and $defaultvalues ) {
+ # if the item record *doesn't* exists, always use the default value
+ $defaultvalue = $defaultvalues->{callnumber};
}
}
if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.holdingbranch' || $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.homebranch' )
&& $defaultvalues
&& $defaultvalues->{'branchcode'} ) {
- my $temp;
- if ($itemrecord) {
- $temp = $itemrecord->field($subfield);
- }
- unless ($temp) {
- $defaultvalue = $defaultvalues->{branchcode} if $defaultvalues;
+ if ( $itemrecord and $defaultvalues and not $itemrecord->field($subfield) ) {
+ $defaultvalue = $defaultvalues->{branchcode};
}
}
if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.location' )
&& $defaultvalues
&& $defaultvalues->{'location'} ) {
- my $temp; # make perlcritic happy :)
- $temp = $itemrecord->field($subfield) if ($itemrecord);
-
- unless ($temp) {
- $defaultvalue = $defaultvalues->{location} if $defaultvalues;
+ if ( $itemrecord and $defaultvalues and not $itemrecord->field($subfield) ) {
+ # if the item record exists, only use default value if the item has no locationr
+ $defaultvalue = $defaultvalues->{location};
+ } elsif ( !$itemrecord and $defaultvalues ) {
+ # if the item record *doesn't* exists, always use the default value
+ $defaultvalue = $defaultvalues->{location};
}
}
if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
# builds list, depending on authorised value...
#---- branch
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
- if ( ( C4::Context->preference("IndependantBranches") )
+ if ( ( C4::Context->preference("IndependentBranches") )
&& ( C4::Context->userenv->{flags} % 2 != 1 ) ) {
my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" );
$sth->execute( C4::Context->userenv->{branch} );
$authorised_lib{$branchcode} = $branchname;
}
}
+
$defaultvalue = C4::Context->userenv->{branch};
+ if ( $defaultvalues and $defaultvalues->{branchcode} ) {
+ $defaultvalue = $defaultvalues->{branchcode};
+ }
#----- itemtypes
} elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
$authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'};
}
+ $defaultvalue = $default_source;
+
#---- "true" authorised value
} else {
$authorised_values_sth->execute(
# opening plugin
my $plugin = C4::Context->intranetdir . "/cataloguing/value_builder/" . $tagslib->{$tag}->{$subfield}->{'value_builder'};
if (do $plugin) {
- my $temp;
- my $extended_param = plugin_parameters( $dbh, $temp, $tagslib, $subfield_data{id}, undef );
- my ( $function_name, $javascript ) = plugin_javascript( $dbh, $temp, $tagslib, $subfield_data{id}, undef );
+ my $extended_param = plugin_parameters( $dbh, undef, $tagslib, $subfield_data{id}, undef );
+ my ( $function_name, $javascript ) = plugin_javascript( $dbh, undef, $tagslib, $subfield_data{id}, undef );
$subfield_data{random} = int(rand(1000000)); # why do we need 2 different randoms?
$subfield_data{marc_value} = qq[<input tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255"
onfocus="Focus$function_name($subfield_data{random}, '$subfield_data{id}');"