=item supplierid
to know on what supplier this script has to display receive order.
-=item recieve
+=item receive
=item invoice
the number of this invoice.
=item biblio
The biblionumber of this order.
-=item daterecieved
+=item datereceived
=item catview
my $supplierid = $input->param('supplierid');
my $dbh = C4::Context->dbh;
-my $search = $input->param('recieve');
+my $search = $input->param('receive');
my $invoice = $input->param('invoice');
my $freight = $input->param('freight');
my $biblionumber = $input->param('biblionumber');
-my $daterecieved = $input->param('daterecieved') || format_date(join "-",Date::Calc::Today());
+my $datereceived = C4::Dates->new($input->param('datereceived'),'iso') || C4::Dates->new();
my $catview = $input->param('catview');
my $gst = $input->param('gst');
my @results = SearchOrder( $search, $supplierid, $biblionumber, $catview );
my $count = scalar @results;
+my $order = GetOrder($search);
-my @booksellers = GetBookSeller( $results[0]->{'booksellerid'} );
+my $bookseller = GetBookSellerFromId( $results[0]->{'booksellerid'} );
my $date = $results[0]->{'entrydate'};
if ( $count == 1 ) {
+ my (@itemtypesloop,@locationloop,@ccodeloop);
my $itemtypes = GetItemTypes;
- my @itemtypesloop;
foreach my $thisitemtype (sort keys %$itemtypes) {
- my %row = (
+ my %row = (
value => $thisitemtype,
description => $itemtypes->{$thisitemtype}->{'description'},
+ selected => ($thisitemtype eq $results[0]->{itemtype}), # ifdef itemtype @ bibliolevel, use it as default for item level.
);
push @itemtypesloop, \%row;
}
-
- $template->param(itemtypeloop => \@itemtypesloop);
-
-
- my $locations = GetKohaAuthorisedValues( 'items.location' );
- if ($locations) {
- my @location_codes = keys %$locations;
- my $CGIlocation = CGI::scrolling_list(
- -name => 'location',
- -id => 'location',
- -values => \@location_codes,
- -default => $results[0]->{'itemtype'},
- -labels => $locations,
- -size => 1,
- -tabindex => '',
- -multiple => 0
- );
- $template->param( CGIlocation => $CGIlocation );
+
+ my $locs = GetKohaAuthorisedValues( 'items.location' );
+ foreach my $thisloc (sort keys %$locs) {
+ my $row = {
+ value => $thisloc,
+ description => $locs->{$thisloc},
+ };
+ push @locationloop, $row;
+ }
+ my $ccodes= GetKohaAuthorisedValues( 'items.ccode' );
+ foreach my $thisccode (sort keys %$ccodes) {
+ push @ccodeloop, {
+ value => $thisccode,
+ description => $ccodes->{$thisccode},
+ };
}
- my $onlymine=C4::Context->preference('IndependantBranches') &&
+ $template->param(itemtypeloop => \@itemtypesloop ,
+ locationloop => \@locationloop,
+ ccodeloop => \@ccodeloop,
+ itype => C4::Context->preference('item-level_itypes'),
+ );
+
+ my $onlymine=C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
C4::Context->userenv->{flags} !=1 &&
C4::Context->userenv->{branch};
foreach my $thisbranch ( sort keys %$branches ) {
my %row = (
value => $thisbranch,
- branchname => $branches->{$thisbranch}->{'branchname'},
+ description => $branches->{$thisbranch}->{'branchname'},
);
+ $row{'selected'} = 1 if( $thisbranch eq $order->{branchcode}) ;
push @branchloop, \%row;
}
- my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
-
- # See whether barcodes should be automatically allocated.
- # Defaults to 0, meaning "no".
my $barcode;
- if ( $auto_barcode ) {
+ # See whether barcodes should be automatically allocated.
+ # FIXME : only incremental is implemented here, and it creates a race condition.
+ #
+ if ( C4::Context->preference('autoBarcode') eq 'incremental' ) {
my $sth = $dbh->prepare("Select max(barcode) from items");
$sth->execute;
my $data = $sth->fetchrow_hashref;
if ( $results[0]->{'unitprice'} == 0 ) {
$results[0]->{'unitprice'} = '';
}
- $results[0]->{'copyrightdate'} =
- format_date( $results[0]->{'copyrightdate'} );
+# $results[0]->{'copyrightdate'} = format_date( $results[0]->{'copyrightdate'} ); # this usu fails.
$template->param(
branchloop => \@branchloop,
count => 1,
freight => $freight,
gst => $gst,
catview => ( $catview ne 'yes' ? 1 : 0 ),
- name => $booksellers[0]->{'name'},
+ name => $bookseller->{'name'},
date => format_date($date),
title => $results[0]->{'title'},
author => $results[0]->{'author'},
- copyrightdate => format_date( $results[0]->{'copyrightdate'} ),
+ copyrightdate => $results[0]->{'copyrightdate'},
itemtype => $results[0]->{'itemtype'},
isbn => $results[0]->{'isbn'},
seriestitle => $results[0]->{'seriestitle'},
ecost => $results[0]->{'ecost'},
unitprice => $results[0]->{'unitprice'},
invoice => $invoice,
- daterecieved => $daterecieved,
+ datereceived => $datereceived->output(),
+ datereceived_iso => $datereceived->output('iso'),
);
}
else {
my %line = %{ $results[$i] };
$line{invoice} = $invoice;
- $line{daterecieved} = $daterecieved;
+ $line{datereceived} = $datereceived->output();
$line{freight} = $freight;
$line{gst} = $gst;
$line{title} = $results[$i]->{'title'};
$template->param(
loop => \@loop,
date => format_date($date),
- daterecieved => $daterecieved,
- name => $booksellers[0]->{'name'},
+ datereceived => $datereceived->output(),
+ name => $bookseller->{'name'},
supplierid => $supplierid,
invoice => $invoice,
- daterecieved => $daterecieved,
);
}