From e8347ec03ae5b705845b7476257d57eadd9e07e8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 18 Jan 2012 16:05:40 +0100 Subject: [PATCH 1/1] Bug 5336:Order search (search and UI enhancements) You can now search orders by - order status - branchcode - budget New authorised value 'ORDRSTATUS' is created with following values: 0 => New 1 => Requested 2 => Partial 3 => Complete 4 => Deleted New field aqorders.parent_ordernumber is added (which is mainly used by others enhancement). It allows to know the main(=parent) order for an order (if an order is partially received, Koha creates another order. But it is the same order. We want to know this information). To test: Search and check if results are consistent in histsearch.pl --- C4/Acquisition.pm | 136 +++++++++++++++++--- acqui/histsearch.pl | 51 +++++++- installer/data/mysql/de-DE/optional/auth_val.sql | 7 + installer/data/mysql/en/optional/auth_val.sql | 7 + installer/data/mysql/es-ES/optional/auth_val.sql | 7 + .../fr-FR/1-Obligatoire/authorised_values.sql | 5 + installer/data/mysql/it-IT/necessari/auth_val.sql | 7 + installer/data/mysql/kohastructure.sql | 2 + .../data/mysql/nb-NO/2-Valgfritt/auth_val.sql | 7 + installer/data/mysql/pl-PL/optional/auth_val.sql | 7 + installer/data/mysql/updatedatabase.pl | 28 ++++ .../prog/en/modules/acqui/histsearch.tt | 86 ++++++++++--- 12 files changed, 309 insertions(+), 41 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 9678ffc..c8a045a 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -28,7 +28,7 @@ use MARC::Record; use C4::Suggestions; use C4::Biblio; use C4::Debug; -use C4::SQLHelper qw(InsertInTable); +use C4::SQLHelper qw(InsertInTable UpdateInTable); use C4::Bookseller qw(GetBookSellerFromId); use C4::Templates qw(gettemplate); @@ -67,6 +67,7 @@ BEGIN { &GetItemnumbersFromOrder &AddClaim + &GetBiblioCountByBasketno ); } @@ -219,6 +220,17 @@ sub CloseBasket { "; my $sth = $dbh->prepare($query); $sth->execute($basketno); + + my @orders = GetOrders($basketno); + foreach my $order (@orders) { + $query = qq{ + UPDATE aqorders + SET orderstatus = 1 + WHERE ordernumber = ?; + }; + $sth = $dbh->prepare($query); + $sth->execute($order->{'ordernumber'}); + } } #------------------------------------------------------------# @@ -453,6 +465,19 @@ sub ModBasket { my $dbh = C4::Context->dbh; my $sth = $dbh->prepare($query); $sth->execute(@params); + + # set orders status = new + my @orders = GetOrders($basketinfo->{'basketno'}); + foreach my $order (@orders) { + $query = qq{ + UPDATE aqorders + SET orderstatus = 0 + WHERE ordernumber = ?; + }; + $sth = $dbh->prepare($query); + $sth->execute($order->{'ordernumber'}); + } + $sth->finish; } @@ -1008,7 +1033,8 @@ The following keys are used: "biblionumber", "title", "basketno", "quantity", "n sub NewOrder { my $orderinfo = shift; -#### ------------------------------ + my $parent_ordernumber = shift; + my $dbh = C4::Context->dbh; my @params; @@ -1028,7 +1054,15 @@ sub NewOrder { $orderinfo->{quantityreceived} = 0; } - my $ordernumber=InsertInTable("aqorders",$orderinfo); + $orderinfo->{parent_ordernumber} = $parent_ordernumber if $parent_ordernumber; + + my $ordernumber = InsertInTable("aqorders",$orderinfo); + if ( not $parent_ordernumber ) { + $orderinfo->{parent_ordernumber} = $ordernumber; + $orderinfo->{ordernumber} = $ordernumber; + UpdateInTable( "aqorders", $orderinfo ); + } + return ( $orderinfo->{'basketno'}, $ordernumber ); } @@ -1274,6 +1308,7 @@ sub ModReceiveOrder { , freight=? , rrp=? , quantity=? + , orderstatus=3 WHERE biblionumber=? AND ordernumber=?"); $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordernumber); @@ -1285,7 +1320,8 @@ sub ModReceiveOrder { } $order->{'quantity'} -= $quantrec; $order->{'quantityreceived'} = 0; - my $newOrder = NewOrder($order); + $order->{orderstatus} = 2; + my $newOrder = NewOrder($order, $order->{parent_ordernumber}); # Change ordernumber in aqorders_items for items not received my @orderitems = GetItemnumbersFromOrder( $order->{'ordernumber'} ); my $count = scalar @orderitems; @@ -1301,7 +1337,7 @@ sub ModReceiveOrder { } else { $sth=$dbh->prepare("update aqorders set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?, - unitprice=?,freight=?,rrp=? + unitprice=?,freight=?,rrp=?,orderstatus=3 where biblionumber=? and ordernumber=?"); $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber); $sth->finish; @@ -1403,7 +1439,7 @@ sub DelOrder { my $dbh = C4::Context->dbh; my $query = " UPDATE aqorders - SET datecancellationprinted=now() + SET datecancellationprinted=now(), orderstatus=4 WHERE biblionumber=? AND ordernumber=? "; my $sth = $dbh->prepare($query); @@ -1756,6 +1792,10 @@ sub GetHistory { my $to_placed_on = $params{to_placed_on}; my $basket = $params{basket}; my $booksellerinvoicenumber = $params{booksellerinvoicenumber}; + my $budget = $params{budget}; + my $branchcode = $params{branchcode}; + my $orderstatus = $params{orderstatus}; + my @order_loop; my $total_qty = 0; my $total_qtyreceived = 0; @@ -1764,10 +1804,10 @@ sub GetHistory { my $dbh = C4::Context->dbh; my $query =" SELECT - biblio.title, - biblio.author, - biblioitems.isbn, - biblioitems.ean, + IFNULL(biblio.title, deletedbiblio.title) AS title, + IFNULL(biblio.author, deletedbiblio.author) AS author, + IFNULL(biblioitems.isbn, deletedbiblioitems.isbn) AS isbn, + IFNULL(biblioitems.ean, deletedbiblioitems.ean) AS ean, aqorders.basketno, aqbasket.basketname, aqbasket.basketgroupid, @@ -1781,18 +1821,34 @@ sub GetHistory { aqorders.ordernumber, aqorders.booksellerinvoicenumber as invoicenumber, aqbooksellers.id as id, - aqorders.biblionumber + aqorders.biblionumber, + aqorders.orderstatus, + aqorders.parent_ordernumber"; + $query .= ", aqbudgets.budget_id AS budget" if defined $budget; + $query .= ", aqorders.branchcode " if ( not C4::Context->preference("IndependantBranches") and defined $branchcode and $branchcode ); + $query .= " FROM aqorders LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id - LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber - LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber"; + LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber + LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber + LEFT JOIN deletedbiblio ON deletedbiblio.biblionumber=aqorders.biblionumber + LEFT JOIN deletedbiblioitems ON deletedbiblioitems.biblionumber=aqorders.biblionumber + "; + + $query .= " LEFT JOIN aqbudgets ON aqorders.budget_id=aqbudgets.budget_id" + if defined $budget; + + if ( C4::Context->preference("IndependantBranches") ) { + $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"; + } elsif ( defined $branchcode and $branchcode) { + $query .= " LEFT JOIN borrowers ON aqorders.branchcode=borrowers.branchcode" + } - $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber" - if ( C4::Context->preference("IndependantBranches") ); + $query .= " WHERE 1 "; - $query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') "; + $query .= " AND (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') " if $orderstatus ne '4'; my @query_params = (); @@ -1811,7 +1867,7 @@ sub GetHistory { $query .= " AND biblioitems.isbn LIKE ? "; push @query_params, "%$isbn%"; } - if ( defined $ean and $ean ) { + if ( $ean ) { $query .= " AND biblioitems.ean = ? "; push @query_params, "$ean"; } @@ -1820,6 +1876,11 @@ sub GetHistory { push @query_params, "%$name%"; } + if ( $budget ) { + $query .= " AND aqbudgets.budget_id = ? "; + push @query_params, "$budget"; + } + if ( $from_placed_on ) { $query .= " AND creationdate >= ? "; push @query_params, $from_placed_on; @@ -1830,6 +1891,11 @@ sub GetHistory { push @query_params, $to_placed_on; } + if ( defined $orderstatus and $orderstatus ne '') { + $query .= " AND aqorders.orderstatus = ? "; + push @query_params, "$orderstatus"; + } + if ($basket) { if ($basket =~ m/^\d+$/) { $query .= " AND aqorders.basketno = ? "; @@ -1851,6 +1917,9 @@ sub GetHistory { $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) "; push @query_params, $userenv->{branch}; } + } elsif ( defined $branchcode and $branchcode ) { + $query .= " AND aqorders.branchcode = ? "; + push @query_params, $branchcode; } $query .= " ORDER BY id"; my $sth = $dbh->prepare($query); @@ -1860,9 +1929,9 @@ sub GetHistory { $line->{count} = $cnt++; $line->{toggle} = 1 if $cnt % 2; push @order_loop, $line; - $total_qty += $line->{'quantity'}; - $total_qtyreceived += $line->{'quantityreceived'}; - $total_price += $line->{'quantity'} * $line->{'ecost'}; + $total_qty += ( $line->{quantity} ) ? $line->{quantity} : 0; + $total_qtyreceived += ( $line->{quantityreceived} ) ? $line->{quantityreceived} : 0; + $total_price += ( $line->{quantity} and $line->{ecost} ) ? $line->{quantity} * $line->{ecost} : 0; } return \@order_loop, $total_qty, $total_price, $total_qtyreceived; } @@ -1986,6 +2055,33 @@ sub AddClaim { } +=head3 GetBiblioCountByBasketno + +=over 4 + +$biblio_count = &GetBiblioCountByBasketno($basketno); + +Looks up the biblio's count that has basketno value $basketno + +Returns a quantity +=back + +=cut +sub GetBiblioCountByBasketno { + my ($basketno) = @_; + my $dbh = C4::Context->dbh; + my $query = " + SELECT COUNT( DISTINCT( biblionumber ) ) + FROM aqorders + WHERE basketno = ? + AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') + "; + + my $sth = $dbh->prepare($query); + $sth->execute($basketno); + return $sth->fetchrow; +} + 1; __END__ diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl index 7f799b5..0beeeb8 100755 --- a/acqui/histsearch.pl +++ b/acqui/histsearch.pl @@ -57,6 +57,8 @@ use C4::Output; use C4::Acquisition; use C4::Dates; use C4::Debug; +use C4::Branch; +use C4::Koha; my $input = new CGI; my $title = $input->param( 'title'); @@ -69,6 +71,10 @@ my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' ); my $do_search = $input->param('do_search') || 0; my $from_placed_on = C4::Dates->new($input->param('from')); my $to_placed_on = C4::Dates->new($input->param('to')); +my $budget = $input->param( 'budget' ); +my $branchcode = $input->param( 'branchcode' ); +my $orderstatus = $input->param( 'orderstatus' ); + if ( not $input->param('from') ) { # FIXME Dirty but we can't sent a Date::Calc to C4::Dates ? # We would use a function like Add_Delta_YM(-1, 0, 0); @@ -108,27 +114,68 @@ if ($do_search) { to_placed_on => $to_iso, basket => $basket, booksellerinvoicenumber => $booksellerinvoicenumber, + budget => $budget, + branchcode => $branchcode, + orderstatus => $orderstatus, ); } my $from_date = $from_placed_on ? $from_placed_on->output('syspref') : undef; my $to_date = $to_placed_on ? $to_placed_on->output('syspref') : undef; +my $budgetperiods = C4::Budgets::GetBudgetPeriods; +my $bp_loop = $budgetperiods; +for my $bp ( @{$budgetperiods} ) { + my $hierarchy = C4::Budgets::GetBudgetHierarchy( $$bp{budget_period_id} ); + for my $budget ( @{$hierarchy} ) { + #warn Data::Dumper::Dumper $budget; + $$budget{budget_display_name} = sprintf("%s", ">" x $$budget{depth} . $$budget{budget_name}); + } + $$bp{hierarchy} = $hierarchy; +} + +if ( not C4::Context->preference("IndependantBranches") ){ + my $branches = GetBranches(); + my @branchloop; + foreach my $thisbranch ( keys %$branches ) { + my %row = ( + value => $thisbranch, + branchname => $branches->{$thisbranch}->{'branchname'}, + ); + push @branchloop, \%row; + } + $template->param( + branchcode => $branchcode, + display_branchcode => !C4::Context->preference("IndependantBranches"), + branchloop => \@branchloop + ); +} + +my $orderstatusloop = GetAuthorisedValues( "ORDRSTATUS" ); +my %order_status = map { + $_->{authorised_value} => $_->{lib} +} @$orderstatusloop; + +$_->{lib_orderstatus} = $order_status{$_->{orderstatus}} + for @$order_loop; + $template->param( - suggestions_loop => $order_loop, + order_loop => $order_loop, total_qty => $total_qty, total_qtyreceived => $total_qtyreceived, total_price => sprintf( "%.2f", $total_price ), numresults => $order_loop ? scalar(@$order_loop) : undef, title => $title, author => $author, - isbn => $isbn, + isbn => $isbn, ean => $ean, name => $name, basket => $basket, booksellerinvoicenumber => $booksellerinvoicenumber, from_placed_on => $from_date, to_placed_on => $to_date, + bp_loop => $bp_loop, + orderstatusloop => $orderstatusloop, DHTMLcalendar_dateformat=> C4::Dates->DHTMLcalendar(), dateformat => C4::Dates->new()->format(), debug => $debug || $input->param('debug') || 0, diff --git a/installer/data/mysql/de-DE/optional/auth_val.sql b/installer/data/mysql/de-DE/optional/auth_val.sql index 5832f61..ddf41e8 100644 --- a/installer/data/mysql/de-DE/optional/auth_val.sql +++ b/installer/data/mysql/de-DE/optional/auth_val.sql @@ -46,3 +46,10 @@ INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('MANUA -- custom borrower notes INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('BOR_NOTES','ADDR','Adresse kontrollieren'); + +-- order status +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '0', 'New'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '1', 'Requested'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '2', 'Partial'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '3', 'Complete'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '4', 'Deleted'); diff --git a/installer/data/mysql/en/optional/auth_val.sql b/installer/data/mysql/en/optional/auth_val.sql index e1c7917..5e4f624 100644 --- a/installer/data/mysql/en/optional/auth_val.sql +++ b/installer/data/mysql/en/optional/auth_val.sql @@ -50,3 +50,10 @@ INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('BOR_N -- OPAC Suggestions reasons INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','damaged','The copy on the shelf is damaged','The copy on the shelf is damaged'); INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','bestseller','Upcoming title by popular author','Upcoming title by popular author'); + +-- order status +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '0', 'New'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '1', 'Requested'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '2', 'Partial'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '3', 'Complete'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '4', 'Deleted'); diff --git a/installer/data/mysql/es-ES/optional/auth_val.sql b/installer/data/mysql/es-ES/optional/auth_val.sql index e1c7917..5e4f624 100644 --- a/installer/data/mysql/es-ES/optional/auth_val.sql +++ b/installer/data/mysql/es-ES/optional/auth_val.sql @@ -50,3 +50,10 @@ INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('BOR_N -- OPAC Suggestions reasons INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','damaged','The copy on the shelf is damaged','The copy on the shelf is damaged'); INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','bestseller','Upcoming title by popular author','Upcoming title by popular author'); + +-- order status +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '0', 'New'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '1', 'Requested'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '2', 'Partial'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '3', 'Complete'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '4', 'Deleted'); diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/authorised_values.sql b/installer/data/mysql/fr-FR/1-Obligatoire/authorised_values.sql index 8c46b7b..a527dfd 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/authorised_values.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/authorised_values.sql @@ -351,3 +351,8 @@ INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'qualif', '295', 'Donneur de grades'); INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'qualif', '010', 'Adaptateur'); INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'LOC', 'En reliure', 'En reliure'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '0', 'Nouveau'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '1', 'Demandé'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '2', 'Partielle'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '3', 'Complète'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '4', 'Supprimée') diff --git a/installer/data/mysql/it-IT/necessari/auth_val.sql b/installer/data/mysql/it-IT/necessari/auth_val.sql index cd78c83..8ee718e 100644 --- a/installer/data/mysql/it-IT/necessari/auth_val.sql +++ b/installer/data/mysql/it-IT/necessari/auth_val.sql @@ -79,4 +79,11 @@ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('LANG', 'fre', 'francese'), ('LANG', 'lat', 'latino'); +-- order status +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '0', 'New'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '1', 'Requested'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '2', 'Partial'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '3', 'Complete'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '4', 'Deleted'); + SET FOREIGN_KEY_CHECKS=1; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 69304e1..45ce3ed 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2771,6 +2771,8 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items `uncertainprice` tinyint(1), -- was this price uncertain (1 for yes, 0 for no) `claims_count` int(11) default 0, -- count of claim letters generated `claimed_date` date default NULL, -- last date a claim was generated + `orderstatus` tinyint(2) default 0, -- the current status for this line item + `parent_ordernumber` int(11) default NULL, -- the ordernumber's parent PRIMARY KEY (`ordernumber`), KEY `basketno` (`basketno`), KEY `biblionumber` (`biblionumber`), diff --git a/installer/data/mysql/nb-NO/2-Valgfritt/auth_val.sql b/installer/data/mysql/nb-NO/2-Valgfritt/auth_val.sql index 3deeae2..d25be10 100644 --- a/installer/data/mysql/nb-NO/2-Valgfritt/auth_val.sql +++ b/installer/data/mysql/nb-NO/2-Valgfritt/auth_val.sql @@ -71,3 +71,10 @@ INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('BOR_N -- OPAC Suggestions reasons INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','damaged','Eksemplaret på hylla er skadet','Eksemplaret på hylla er skadet'); INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','bestseller','Kommende tittel av populær forfatter','Kommende tittel av populær forfatter'); + +-- order status +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '0', 'New'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '1', 'Requested'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '2', 'Partial'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '3', 'Complete'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '4', 'Deleted'); diff --git a/installer/data/mysql/pl-PL/optional/auth_val.sql b/installer/data/mysql/pl-PL/optional/auth_val.sql index 0bc10c9..0b95125 100644 --- a/installer/data/mysql/pl-PL/optional/auth_val.sql +++ b/installer/data/mysql/pl-PL/optional/auth_val.sql @@ -38,3 +38,10 @@ INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('NOT_L -- restricted status of an item, linked to items.restricted INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('RESTRICTED','1','Restricted Access'); + +-- order status +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '0', 'New'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '1', 'Requested'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '2', 'Partial'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '3', 'Complete'); +INSERT INTO `authorised_values` ( `category`, `authorised_value`, `lib`) VALUES ( 'ORDRSTATUS', '4', 'Deleted'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index ed0c674..4740bbd 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5635,6 +5635,34 @@ if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.09.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + my $return_count; + eval { $return_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='ORDRSTATUS'"); }; + if ( $return_count == 0 ) { + $dbh->do("INSERT IGNORE INTO authorised_values ( category, authorised_value, lib) VALUES ( 'ORDRSTATUS', '0', 'New')"); + $dbh->do("INSERT IGNORE INTO authorised_values ( category, authorised_value, lib) VALUES ( 'ORDRSTATUS', '1', 'Requested')"); + $dbh->do("INSERT IGNORE INTO authorised_values ( category, authorised_value, lib) VALUES ( 'ORDRSTATUS', '2', 'Partial')"); + $dbh->do("INSERT IGNORE INTO authorised_values ( category, authorised_value, lib) VALUES ( 'ORDRSTATUS', '3', 'Complete')"); + $dbh->do("INSERT IGNORE INTO authorised_values ( category, authorised_value, lib) VALUES ( 'ORDRSTATUS', '4', 'Deleted')"); + $dbh->do("ALTER TABLE aqorders ADD COLUMN orderstatus tinyint(2) DEFAULT 0"); + $dbh->do("UPDATE aqorders SET orderstatus=1 WHERE basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)"); + $dbh->do("UPDATE aqorders SET orderstatus=2 WHERE quantity > quantityreceived AND quantityreceived > 0"); + $dbh->do("UPDATE aqorders SET orderstatus=3 WHERE quantity=quantityreceived"); + $dbh->do("UPDATE aqorders SET orderstatus=4 WHERE datecancellationprinted IS NOT NULL"); + } + print "Upgrade to $DBversion done (Add category ORDRSTATUS values in authorised_values table)\n"; + SetVersion($DBversion); +} + +$DBversion = "3.09.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("ALTER TABLE aqorders ADD parent_ordernumber int(11) NULL"); + $dbh->do("UPDATE aqorders SET parent_ordernumber=ordernumber"); + print "Upgrade to $DBversion done (Add parent_ordernumber in aqorders)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt index b6875be..592c8db 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt @@ -1,6 +1,6 @@ [% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] -Koha › Acquisitions › [% IF ( suggestions_loop ) %]Orders search › Search results[% ELSE %]Order search[% END %] +Koha › Acquisitions › [% IF ( order_loop ) %]Orders search › Search results[% ELSE %]Order search[% END %] [% INCLUDE 'doc-head-close.inc' %] [% INCLUDE 'calendar.inc' %] @@ -21,7 +21,7 @@ [% INCLUDE 'header.inc' %] [% INCLUDE 'acquisitions-search.inc' %] - +
@@ -29,7 +29,7 @@
- [% UNLESS ( suggestions_loop ) %]
+ [% UNLESS ( order_loop ) %]
Search Orders
    @@ -42,6 +42,47 @@
  1. + +
  2. + + +
  3. + + [% IF ( display_branchcode ) %] +
  4. + + +
  5. + [% END %] + +
  6. + + +
  7. +
  8. [% INCLUDE 'date-format.inc' %]
    @@ -55,11 +96,12 @@
  9. [% END %] - [% IF ( suggestions_loop ) %]

    Search results

    + [% IF ( order_loop ) %]

    Search results

    + @@ -68,35 +110,41 @@ - + + + - [% FOREACH suggestions_loo IN suggestions_loop %] + [% FOREACH order IN order_loop %] - + + - - - - - - - - + + + + + + + + + [% END %] -- 1.7.7.3
    Order line Basket Basket group Invoice numberVendor Placed on Received onQuantity orderedStatusQuantity receivedPending order Unit cost
    [% suggestions_loo.basketname %] ([% suggestions_loo.basketno %])[% order.parent_ordernumber %][% order.basketname %] ([% order.basketno %]) - [% IF ( suggestions_loo.basketgroupid ) %] - [% suggestions_loo.groupname %] ([% suggestions_loo.basketgroupid %]) + [% IF ( order.basketgroupid ) %] + [% order.groupname %] ([% order.basketgroupid %]) [% ELSE %]   [% END %] [% IF ( suggestions_loo.invoicenumber ) %] - [% suggestions_loo.invoicenumber %] + [% IF ( order.invoicenumber ) %] + [% order.invoicenumber %] [% ELSE %]   [% END %] [% suggestions_loo.ordernumber %][% suggestions_loo.title |html %] -
    [% suggestions_loo.author %]
    [% suggestions_loo.isbn %]
    [% suggestions_loo.name %][% suggestions_loo.creationdate | $KohaDates %][% suggestions_loo.datereceived | $KohaDates %][% suggestions_loo.quantity %][% suggestions_loo.ecost %][% order.ordernumber %] + [% order.title |html %] +
    [% order.author %]
    [% IF ( order.internalnotes ) %][% order.internalnotes %]
    [% END %][% order.isbn %]
    [% order.name %][% order.creationdate | $KohaDates %][% order.datereceived | $KohaDates %][% order.lib_orderstatus %][% order.quantityreceived %][% order.quantity %][% order.ecost %]