@@ -, +, @@ filtered page --- C4/Acquisition.pm | 44 ++++++---- acqui/parcel.pl | 63 ++++---------- .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 86 +++----------------- 3 files changed, 56 insertions(+), 137 deletions(-) --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -748,41 +748,55 @@ Results are ordered from most to least recent. =cut sub GetPendingOrders { - my ($supplierid,$grouped,$owner,$basketno) = @_; + my ($supplierid,$ordernumber,$search,$ean,$basketno,$grouped,$owner) = @_; my $dbh = C4::Context->dbh; my $strsth = " - SELECT ".($grouped?"count(*),":"")."aqbasket.basketno, - surname,firstname,biblio.*,biblioitems.isbn, - aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname, - aqorders.* - FROM aqorders + SELECT ".($grouped?"count(*),":"")."aqbasket.basketno, + surname,firstname,biblio.*,biblioitems.isbn, + aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname, + aqorders.* + FROM aqorders LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber - WHERE booksellerid=? - AND (quantity > quantityreceived OR quantityreceived is NULL) - AND datecancellationprinted IS NULL"; - my @query_params = ( $supplierid ); + WHERE (quantity > quantityreceived OR quantityreceived is NULL) + AND datecancellationprinted IS NULL"; + my @query_params; my $userenv = C4::Context->userenv; if ( C4::Context->preference("IndependantBranches") ) { if ( ($userenv) && ( $userenv->{flags} != 1 ) ) { - $strsth .= " and (borrowers.branchcode = ? + $strsth .= " AND (borrowers.branchcode = ? or borrowers.branchcode = '')"; push @query_params, $userenv->{branch}; } } - if ($owner) { - $strsth .= " AND aqbasket.authorisedby=? "; - push @query_params, $userenv->{'number'}; + if ($supplierid) { + $strsth .= " AND aqbasket.booksellerid = ?"; + push @query_params, $supplierid; + } + if($ordernumber){ + $strsth .= " AND (aqorders.ordernumber=?)"; + push @query_params, $ordernumber; + } + if($search){ + $strsth .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)"; + push @query_params, ("%$search%","%$search%","%$search%"); + } + if ($ean) { + $strsth .= " AND biblioitems.ean = ?"; + push @query_params, $ean; } if ($basketno) { $strsth .= " AND aqbasket.basketno=? "; push @query_params, $basketno; } + if ($owner) { + $strsth .= " AND aqbasket.authorisedby=? "; + push @query_params, $userenv->{'number'}; + } $strsth .= " group by aqbasket.basketno" if $grouped; $strsth .= " order by aqbasket.basketno"; - my $sth = $dbh->prepare($strsth); $sth->execute( @query_params ); my $results = $sth->fetchall_arrayref({}); --- a/acqui/parcel.pl +++ a/acqui/parcel.pl @@ -78,61 +78,17 @@ my $invoice=$input->param('invoice') || ''; 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 $datereceived = ($input->param('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, @@ -196,7 +152,17 @@ for (my $i = 0 ; $i < $countlines ; $i++) { $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') || ''; + $pendingorders = GetPendingOrders($booksellerid,$orderno,$search,$ean,$basketno); +}else{ + $pendingorders = GetPendingOrders($booksellerid); +} my $countpendings = scalar @$pendingorders; # pending orders totals @@ -252,7 +218,7 @@ for (my $i = 0 ; $i < $countpendings ; $i++) { $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}; @@ -260,7 +226,6 @@ for (my $i = 0 ; $i < $countpendings ; $i++) { push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); } $freight = $totalfreight unless $freight; - my $count = $countpendings; if ($count>$resultsperpage){ --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -96,68 +96,6 @@ $("#receivedt").before("
" + _("All ") + rowCountReceived + _(" items are displayed.") + "" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>");
}
- // Launch filtering
- function filter() {
-
- var summaryStatus = jQuery.trim($("#summaryfilter").val());
- var basketStatus = $("#basketfilter").val();
- var orderStatus = $("#orderfilter").val();
- var eanStatus = $("#eanfilter").val() || '';
-
- if (summaryStatus == '' && basketStatus == '' && orderStatus == '' && eanStatus == '') { clearFilters(); return false; }
-
- var filtered = "table#pendingt tbody.filterclass tr";
-
- // We hide everything
- $("#nothingfoundrow").remove();
- $(filtered).hide();
-
- // Do the search
- var callback = {
- success: function(o) {
- var jsonString = o.responseText;
- var gst = "[% gst %]";
- try {
- var orders = YAHOO.lang.JSON.parse(jsonString);
- var foundCount = orders.length;
-
- for( i = 0 ; i < orders.length ; i++){
- order = orders[i];
- $(''
- + ' ').appendTo("table#pendingt");
- }
-
- // If nothing has been found, we tell the user so
- if (orders.length == 0) {
- $("' + order.basketno + ' '
- + ' ' + order.ordernumber + ' '
- + ''
- + '' + order.title + '' + _(" by ") + order.author + ' – ' + order.isbn + ' '
- + 'MARC | Card '
- + '' + order.quantity + ' '
- + '' + order.ecost + ' '
- + '' + order.ordertotal + ' '
- + ''
- + 'Receive /'
- + 'Cancel'
- + ' No items match your criteria.<\/tr>").appendTo("#pendingt");
- }
- }catch(e){alert(e);}
- }
- }
- var transaction = YAHOO.util.Connect.asyncRequest('GET', '/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% booksellerid %]&search='+summaryStatus+'&basketno='+basketStatus+'&orderno='+orderStatus+'&ean='+eanStatus+'&format=json', callback, null);
-
- return false;
- }
-
- // Clear already applied filters
- function clearFilters() {
- $("#nothingfoundrow").remove();
- $("#pendingt tbody.filterclass tr").show();
- //$("#pendingt tbody.filterclass tr.orderfound").remove();
- pendingExpand();
- }
-
//]]>
-
[% INCLUDE 'header.inc' %]
@@ -237,7 +173,7 @@
Basket
Order line
Summary
- View record
+ View record
Quantity
Unit cost
Order cost
@@ -421,7 +357,7 @@