Bug 12944: Search orders by basket creator

This patch adds the ability to search orders using the basket creator.

Test plan:
- go on the order advanced search form (acqui/histsearch.pl)
- use the autocomplete input to search patrons
- launch the search and verify the results are consistent with the
  values you have filled.

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
Jonathan Druart 2014-09-17 17:13:00 +02:00 committed by Tomas Cohen Arazi
parent c8053f3c8d
commit ff7c87d345
3 changed files with 31 additions and 5 deletions

View File

@ -2179,6 +2179,7 @@ sub GetHistory {
my $get_canceled_order = $params{get_canceled_order} || 0;
my $ordernumber = $params{ordernumber};
my $search_children_too = $params{search_children_too} || 0;
my $created_by = $params{created_by} || [];
my @order_loop;
my $total_qty = 0;
@ -2195,6 +2196,8 @@ sub GetHistory {
aqorders.basketno,
aqbasket.basketname,
aqbasket.basketgroupid,
aqbasket.authorisedby,
concat( borrowers.firstname,' ',borrowers.surname) AS authorisedbyname,
aqbasketgroups.name as groupname,
aqbooksellers.name,
aqbasket.creationdate,
@ -2223,12 +2226,9 @@ sub GetHistory {
LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.biblionumber
LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=aqorders.biblionumber
LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
";
if ( C4::Context->preference("IndependentBranches") ) {
$query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber";
}
$query .= " WHERE 1 ";
unless ($get_canceled_order or (defined $orderstatus and $orderstatus eq 'cancelled')) {
@ -2316,6 +2316,11 @@ sub GetHistory {
$query .= ") ";
}
if ( @$created_by ) {
$query .= ' AND aqbasket.authorisedby IN ( ' . join( ',', ('?') x @$created_by ) . ')';
push @query_params, @$created_by;
}
if ( C4::Context->preference("IndependentBranches") ) {
unless ( C4::Context->IsSuperLibrarian() ) {

View File

@ -76,6 +76,7 @@ my $budget = $input->param( 'budget' );
my $orderstatus = $input->param( 'orderstatus' );
my $ordernumber = $input->param( 'ordernumber' );
my $search_children_too = $input->param( 'search_children_too' );
my @created_by = $input->param('created_by');
if ( not $input->param('from') ) {
# FIXME Dirty but we can't sent a Date::Calc to C4::Dates ?
@ -121,6 +122,7 @@ if ($do_search) {
orderstatus => $orderstatus,
ordernumber => $ordernumber,
search_children_too => $search_children_too,
created_by => \@created_by,
);
}

View File

@ -5,6 +5,8 @@
[% INCLUDE 'doc-head-close.inc' %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript" src="[% interface %]/js/autocomplete/patrons.pl"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
@ -15,7 +17,16 @@
],
"sPaginationType": "four_button"
} ) );
});
patron_autocomplete({
patron_container: $("#basket_creators"),
input_autocomplete: $("#find_patron"),
patron_input_name: 'created_by',
field_to_retrieve: 'borrowernumber'
});
});
//]]>
</script>
</head>
@ -43,6 +54,12 @@
[% END %]
<li><label for="name">Vendor: </label> <input type="text" name="name" id="name" value="[% name %]" /></li>
<li><label for="basket">Basket: </label> <input type="text" name="basket" id="basket" value="[% basket %]" /></li>
<li><label for="basket_creators">Basket created by: </label>
<input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
<div>
<div id="basket_creators" style="float:left;"></div>
</div>
</li>
<li><label for="booksellerinvoicenumber ">Bookseller invoice no: </label> <input type="text" name="booksellerinvoicenumber" id="booksellerinvoicenumber" value="[% booksellerinvoicenumber %]" /></li>
<li>
<label for="basketgroupname">Basket group:</label>
@ -135,6 +152,7 @@
<th>Order line (parent)</th>
<th>Status</th>
<th>Basket</th>
<th>Basket creator</th>
<th>Basket group</th>
<th>Invoice number</th>
<th class="anti-the">Summary</th>
@ -164,6 +182,7 @@
[% END %]
</td>
<td>[% order.basketname %] (<a href="basket.pl?basketno=[% order.basketno %]">[% order.basketno %]</a>)</td>
<td>[% order.authorisedbyname %]</td>
<td>
[% IF ( order.basketgroupid ) %]
[% order.groupname %] (<a href="basketgroup.pl?booksellerid=[% order.id %]">[% order.basketgroupid %]</a>)