my $freight=$input->param('freight');
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
-my $datereceived = ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived'))
- : C4::Dates->new($input->param('datereceived'), 'iso') ;
+my $op = $input->param('op') // '';
+my $datereceived = ( $op eq ('new' or 'search' ) )
+ ? C4::Dates->new($input->param('datereceived'))
+ : C4::Dates->new($input->param('datereceived'), 'iso');
$datereceived = C4::Dates->new() unless $datereceived;
my $code = $input->param('code');
my @rcv_err = $input->param('error');
my @rcv_err_barcode = $input->param('error_bc');
-
my $startfrom=$input->param('startfrom');
my $resultsperpage = $input->param('resultsperpage');
$resultsperpage = 20 unless ($resultsperpage);
$startfrom=0 unless ($startfrom);
-if($input->param('format') eq "json"){
- my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "acqui/ajax.tmpl",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {acquisition => 'order_receive'},
- debug => 1,
- });
-
- my @datas;
- my $search = $input->param('search') || '';
- my $ean = $input->param('ean') || '';
- my $supplier = $input->param('booksellerid') || '';
- my $basketno = $input->param('basketno') || '';
- my $orderno = $input->param('orderno') || '';
-
- my $orders = SearchOrder($orderno, $search, $ean, $supplier, $basketno);
- foreach my $order (@$orders) {
- if ( $order->{quantityreceived} < $order->{quantity} ) {
- my $data = {};
-
- $data->{basketno} = $order->{basketno};
- $data->{ordernumber} = $order->{ordernumber};
- $data->{title} = $order->{title};
- $data->{author} = $order->{author};
- $data->{isbn} = $order->{isbn};
- $data->{booksellerid} = $order->{booksellerid};
- $data->{biblionumber} = $order->{biblionumber};
- $data->{freight} = $order->{freight};
- $data->{quantity} = $order->{quantity};
- $data->{ecost} = $order->{ecost};
- $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
- push @datas, $data;
- }
- }
-
- my $json_text = to_json(\@datas);
- $template->param(return => $json_text);
- output_html_with_http_headers $input, $cookie, $template->output;
- exit;
-}
-
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "acqui/parcel.tmpl",
query => $input,
debug => 1,
});
+if($op eq 'cancelreceipt') {
+ my $ordernumber = $input->param('ordernumber');
+ my $parent_ordernumber = CancelReceipt($ordernumber);
+ unless($parent_ordernumber) {
+ $template->param(error_cancelling_receipt => 1);
+ }
+}
+
# If receiving error, report the error (coming from finishrecieve.pl(sic)).
if( scalar(@rcv_err) ) {
my $cnt=0;
$line{gst} = $gst;
$line{total} = sprintf($cfstr, $total);
$line{booksellerid} = $booksellerid;
- push @loop_received, \%line;
$totalprice += $parcelitems[$i]->{'unitprice'};
$line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
$line{surnamesuggestedby} = $suggestion->{surnamesuggestedby};
$line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
+ if ( $line{parent_ordernumber} != $line{ordernumber} ) {
+ if ( grep { $_->{ordernumber} == $line{parent_ordernumber} }
+ @parcelitems )
+ {
+ $line{cannot_cancel} = 1;
+ }
+ }
+
+ push @loop_received, \%line;
#double FIXME - totalfreight is redefined later.
# FIXME - each order in a parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget..
$tototal += $total;
}
-my $pendingorders = GetPendingOrders($booksellerid);
+# We get the pending orders either all or filtered
+my $pendingorders;
+if($input->param('op') eq "search"){
+ my $search = $input->param('summaryfilter') || '';
+ my $ean = $input->param('eanfilter') || '';
+ my $basketno = $input->param('basketfilter') || '';
+ my $orderno = $input->param('orderfilter') || '';
+ my $grouped;
+ my $owner;
+ $pendingorders = GetPendingOrders($booksellerid,$grouped,$owner,$basketno,$orderno,$search,$ean);
+}else{
+ $pendingorders = GetPendingOrders($booksellerid);
+}
my $countpendings = scalar @$pendingorders;
# pending orders totals
$line{left_subscription} = 1 if scalar @subscriptions >= 1;
$line{subscriptions} = scalar @subscriptions;
$line{left_holds} = 1 if $holds >= 1;
- $line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
+ $line{left_holds_on_order} = 1 if $line{left_holds} == 1 && ($line{items} == 0 || $itemholds );
$line{holds} = $holds;
$line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
}
$freight = $totalfreight unless $freight;
-
my $count = $countpendings;
if ($count>$resultsperpage){