Bugzilla – Attachment 12462 Details for
Bug 5349
Moving an order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 5349: Order line transfers
Bug-5349-Order-line-transfers.patch (text/plain), 19.38 KB, created by
Julian Maurice
on 2012-09-24 07:01:54 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 5349: Order line transfers
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2012-09-24 07:01:54 UTC
Size:
19.38 KB
patch
obsolete
>From bee72a3206d2aaed222b9ce35f924480fb9409e7 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 6 Apr 2012 16:57:12 +0200 >Subject: [PATCH] Bug 5349: Order line transfers > >On basket.pl and parcel.pl there is a 'Transfer' link which allow you to >transfer order lines from a basket to another. >The link lead to a new page which allow you to search for a bookseller, >then display this bookseller's baskets. Then you can pickup a basket and >the transfer will be done. >This add a message in new column aqorders.internalnotes which is >displayed in basket.pl > >Signed-off-by: Marc Veron <veron@veron.ch> >--- > C4/Acquisition.pm | 73 +++++++++- > acqui/transferorder.pl | 145 ++++++++++++++++++++ > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/updatedatabase.pl | 11 +- > .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 6 + > .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 2 + > .../prog/en/modules/acqui/transferorder.tt | 121 ++++++++++++++++ > 7 files changed, 357 insertions(+), 2 deletions(-) > create mode 100755 acqui/transferorder.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/transferorder.tt > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 05cae14..9ad5f71 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -57,7 +57,7 @@ BEGIN { > &GetOrderNumber &GetLateOrders &GetOrderFromItemnumber > &SearchOrder &GetHistory &GetRecentAcqui > &ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber >- &GetCancelledOrders >+ &GetCancelledOrders &TransferOrder > > &NewOrderItem &ModOrderItem &ModItemOrder > >@@ -1558,6 +1558,77 @@ sub DelOrder { > > } > >+=head3 TransferOrder >+ >+ my $newordernumber = TransferOrder($ordernumber, $basketno); >+ >+Transfer an order line to a basket. >+Mark $ordernumber as cancelled with an internal note 'Cancelled and transfered >+to BOOKSELLER on DATE' and create new order with internal note >+'Transfered from BOOKSELLER on DATE'. >+Move all attached items to the new order. >+Received orders cannot be transfered. >+Return the ordernumber of created order. >+ >+=cut >+ >+sub TransferOrder { >+ my ($ordernumber, $basketno) = @_; >+ >+ return unless $ordernumber or $basketno; >+ >+ my $order = GetOrder( $ordernumber ); >+ return if $order->{datereceived}; >+ >+ my $today = C4::Dates->new()->output("iso"); >+ my $query = qq{ >+ SELECT aqbooksellers.name >+ FROM aqorders >+ LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno >+ LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id >+ WHERE aqorders.ordernumber = ? >+ }; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($ordernumber); >+ my ($booksellerfromname) = $sth->fetchrow_array; >+ >+ $query = qq{ >+ SELECT aqbooksellers.name >+ FROM aqbasket >+ LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id >+ WHERE aqbasket.basketno = ? >+ }; >+ $sth = $dbh->prepare($query); >+ $sth->execute($basketno); >+ my ($booksellertoname) = $sth->fetchrow_array; >+ >+ $query = qq{ >+ UPDATE aqorders >+ SET datecancellationprinted = CAST(NOW() AS date), >+ internalnotes = ? >+ WHERE ordernumber = ? >+ }; >+ $sth = $dbh->prepare($query); >+ $sth->execute("Cancelled and transfered to $booksellertoname on $today", $ordernumber); >+ >+ delete $order->{'ordernumber'}; >+ $order->{'basketno'} = $basketno; >+ $order->{'internalnotes'} = "Transfered from $booksellerfromname on $today"; >+ my $newordernumber; >+ (undef, $newordernumber) = NewOrder($order); >+ >+ $query = qq{ >+ UPDATE aqorders_items >+ SET ordernumber = ? >+ WHERE ordernumber = ? >+ }; >+ $sth = $dbh->prepare($query); >+ $sth->execute($newordernumber, $ordernumber); >+ >+ return $newordernumber; >+} >+ > =head2 FUNCTIONS ABOUT PARCELS > > =cut >diff --git a/acqui/transferorder.pl b/acqui/transferorder.pl >new file mode 100755 >index 0000000..27c4509 >--- /dev/null >+++ b/acqui/transferorder.pl >@@ -0,0 +1,145 @@ >+#!/usr/bin/perl >+ >+# Script to move an order from a bookseller to another >+ >+# Copyright 2011 BibLibre SARL >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+use CGI; >+ >+use C4::Auth; >+use C4::Output; >+use C4::Context; >+use C4::Acquisition; >+use C4::Bookseller qw/GetBookSellerFromId GetBookSeller/; >+use C4::Members; >+use C4::Dates qw/format_date_in_iso/; >+use Date::Calc qw/Today/; >+ >+my $input = new CGI; >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { template_name => "acqui/transferorder.tmpl", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 1, >+ flagsrequired => { acquisition => 'order_manage' }, >+ debug => 1, >+ } >+); >+ >+my $dbh = C4::Context->dbh; >+ >+my $bookselleridfrom = $input->param('bookselleridfrom'); >+my $ordernumber = $input->param('ordernumber'); >+my $bookselleridto = $input->param('bookselleridto'); >+my $basketno = $input->param('basketno'); >+my $op = $input->param('op'); >+my $query = $input->param('query'); >+ >+my $order = GetOrder($ordernumber); >+if($order) { >+ my $basket = GetBasket($order->{basketno}); >+ $bookselleridfrom = $basket->{booksellerid} if $basket; >+} >+ >+my $booksellerfrom = GetBookSellerFromId($bookselleridfrom); >+my $booksellerfromname; >+if($booksellerfrom){ >+ $booksellerfromname = $booksellerfrom->{name}; >+} >+my $booksellerto = GetBookSellerFromId($bookselleridto); >+my $booksellertoname; >+if($booksellerto){ >+ $booksellertoname = $booksellerto->{name}; >+} >+ >+if( $basketno && $ordernumber) { >+ # Transfer order and exit >+ my $order = GetOrder( $ordernumber ); >+ my $basket = GetBasket($order->{basketno}); >+ my $booksellerfrom = GetBookSellerFromId($basket->{booksellerid}); >+ my $bookselleridfrom = $booksellerfrom->{id}; >+ >+ TransferOrder($ordernumber, $basketno); >+ >+ my $referrer = $input->param('referrer'); >+ print $input->redirect($referrer); >+ exit; >+} elsif ( $bookselleridto && $ordernumber) { >+ # Show open baskets for this bookseller >+ my $order = GetOrder( $ordernumber ); >+ my $basketfrom = GetBasket( $order->{basketno} ); >+ my $booksellerfrom = GetBookSellerFromId( $basketfrom->{booksellerid} ); >+ $booksellerfromname = $booksellerfrom->{name}; >+ my $baskets = GetBasketsByBookseller( $bookselleridto ); >+ my $basketscount = scalar @$baskets; >+ my @basketsloop = (); >+ for( my $i = 0 ; $i < $basketscount ; $i++ ){ >+ my %line; >+ %line = %{ $baskets->[$i] }; >+ my $createdby = GetMember(borrowernumber => $line{authorisedby}); >+ $line{createdby} = "$createdby->{surname}, $createdby->{firstname}"; >+ push @basketsloop, \%line unless $line{closedate}; >+ } >+ $template->param( >+ show_baskets => 1, >+ basketsloop => \@basketsloop, >+ basketfromname => $basketfrom->{basketname}, >+ ); >+} elsif ( $bookselleridfrom && !defined $ordernumber) { >+ # Show pending orders >+ my $pendingorders = GetPendingOrders($bookselleridfrom); >+ my $orderscount = scalar @$pendingorders; >+ my @ordersloop = (); >+ for( my $i = 0 ; $i < $orderscount ; $i++ ){ >+ my %line; >+ %line = %{ $pendingorders->[$i] }; >+ push @ordersloop, \%line; >+ } >+ $template->param( >+ ordersloop => \@ordersloop, >+ ); >+} else { >+ # Search for booksellers to transfer from/to >+ $op = '' unless $op; >+ if( $op eq "do_search" ) { >+ my @booksellers = GetBookSeller($query); >+ $template->param( >+ query => $query, >+ do_search => 1, >+ booksellersloop => \@booksellers, >+ ); >+ } else { >+ $template->param( >+ search_form => 1, >+ ); >+ } >+} >+ >+$template->param( >+ bookselleridfrom => $bookselleridfrom, >+ booksellerfromname => $booksellerfromname, >+ bookselleridto => $bookselleridto, >+ booksellertoname => $booksellertoname, >+ ordernumber => $ordernumber, >+ basketno => $basketno, >+ referrer => $input->param('referrer') >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >+ >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 4f70587..bd7a274 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2777,6 +2777,7 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items > `cancelledby` varchar(10) default NULL, -- not used? always NULL > `datecancellationprinted` date default NULL, -- the date the line item was deleted > `notes` mediumtext, -- notes related to this order line >+ internalnotes mediumtext DEFAULT NULL, -- used by Koha to store some informations, not editable by librarians > `supplierreference` mediumtext, -- not used? always NULL > `purchaseordernumber` mediumtext, -- not used? always NULL > `subscription` tinyint(1) default NULL, -- not used? always NULL >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 4d47a59..8529f0b 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5768,7 +5768,6 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >- > $DBversion = '3.09.00.044'; > if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > $dbh->do("ALTER TABLE statistics ADD COLUMN ccode VARCHAR ( 10 ) NULL AFTER associatedborrower"); >@@ -5973,6 +5972,16 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do(qq{ >+ ALTER TABLE aqorders >+ ADD COLUMN internalnotes MEDIUMTEXT DEFAULT NULL AFTER notes >+ }); >+ print "Upgrade to $DBversion done (Add internalnotes field in aqorders table)\n"; >+ SetVersion($DBversion); >+} >+ > > =head1 FUNCTIONS > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index ca92fac..9dfd25c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -342,6 +342,7 @@ > [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber %]">Add note</a>] > [% END %] > </p> >+ <p>[% books_loo.internalnotes %]</p> > </td> > <td class="number gste [% IF books_loo.rrpgste.search('^0') %]error[% END %]">[% books_loo.rrpgste %]</td> > <td class="number gste [% IF books_loo.ecostgste.search('^0') %]error[% END %]">[% books_loo.ecostgste %]</td> >@@ -357,6 +358,10 @@ > [% UNLESS ( closedate ) %] > <td> > <a href="neworderempty.pl?ordernumber=[% books_loo.ordernumber %]&booksellerid=[% booksellerid %]&basketno=[% basketno %]">Modify</a> >+ [% UNLESS (books_loo.order_received) %] >+ <br /> >+ <a href="/cgi-bin/koha/acqui/transferorder.pl?ordernumber=[% books_loo.ordernumber %]&referrer=[% "/cgi-bin/koha/acqui/basket.pl?basketno=$basketno" | uri %]">Transfer</a> >+ [% END %] > </td> > <td> > [% IF ( books_loo.left_holds_on_order ) %] >@@ -433,6 +438,7 @@ > [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %] > [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %] > </p> >+ <p>[% order.internalnotes %]</p> > </td> > <td class="number gste">[% order.rrpgste %]</td> > <td class="number gste">[% order.ecostgste %]</td> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >index 6c8d087..e5b0575 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -247,6 +247,8 @@ > <td>[% loop_order.budget_name %]</td> > <td> > <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&invoiceid=[% invoiceid %]">Receive</a> >+ <br /> >+ <a href="/cgi-bin/koha/acqui/transferorder.pl?ordernumber=[% loop_order.ordernumber %]&referrer=[% "/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]" | uri %]">Transfer</a> > </td> > <td> > [% IF ( loop_order.left_holds_on_order ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/transferorder.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/transferorder.tt >new file mode 100644 >index 0000000..f694c1f >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/transferorder.tt >@@ -0,0 +1,121 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Acquisitions › Transfer order</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'acquisitions-search.inc' %] >+ >+<div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> >+ › <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> >+ › Transfer order >+</div> >+ >+<div id="doc3" class="yui-t2"> >+<div id="bd"> >+<div id="yui-main"> >+ <div class="yui-b"> >+ [% IF ( show_baskets ) %] >+ <h1>Baskets for [% booksellertoname %]</h1> >+ [% IF ( basketsloop ) %] >+ <table> >+ <thead> >+ <th>Basket (#)</th> >+ <th>Created by</th> >+ <th>Date</th> >+ <th> </th> >+ </thead> >+ <tbody> >+ [% FOREACH basket IN basketsloop %] >+ <tr> >+ <td>[% basket.basketname %] (#[% basket.basketno %])</td> >+ <td>[% basket.createdby %]</td> >+ <td>[% basket.creationdate %]</td> >+ <td><a href="transferorder.pl?basketno=[% basket.basketno %]&ordernumber=[% ordernumber %][% IF (referrer) %]&referrer=[% referrer | uri %][% END %]" onclick="return confirm('Do you want to transfer order [% ordernumber %] from basket [% basketfromname %] ([% booksellerfromname %]) to basket [% basket.basketname %] ([% booksellertoname %]) ?');">Choose</a> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% ELSE %] >+ <p>There is no open baskets for this supplier.</p> >+ [% END %] >+ [% END %] >+ [% IF ( ordersloop ) %] >+ <h1>Orders for [% booksellerfromname %]</h1> >+ <table> >+ <thead> >+ <th>Order</th> >+ <th>Summary</th> >+ <th> </th> >+ </thead> >+ <tbody> >+ [% FOREACH ordersloo IN ordersloop %] >+ <tr> >+ <td><a href="neworderempty.pl?ordernumber=[% ordersloo.ordernumber %]">[% ordersloo.ordernumber %]</a></td> >+ <td> >+ <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% ordersloo.biblionumber %]">[% ordersloo.title |html %]</a> >+ [% IF ( ordersloo.author ) %] by [% ordersloo.author %][% END %] >+ [% IF ( ordersloo.isbn ) %] – [% ordersloo.isbn %][% END %] >+ [% IF ( ordersloo.publishercode ) %]<br />Publisher :[% ordersloo.publishercode %][% END %] >+ </td> >+ <td><a href="transferorder.pl?bookselleridfrom=[% ordersloo.bookselleridfrom %]&ordernumber=[% ordersloo.ordernumber %][% IF (referrer) %]&referrer=[% referrer | uri %][% END %]">Transfer</a></td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% END %] >+ [% IF ( do_search ) %] >+ [% IF ( bookselleridfrom ) %] >+ <h1>Choose a vendor to transfer to</h1> >+ [% ELSE %] >+ <h1>Choose a vendor to transfer from</h1> >+ [% END %] >+ [% IF ( booksellersloop ) %] >+ <table> >+ <thead> >+ <th>Name</th> >+ <th> </th> >+ </thead> >+ <tbody> >+ [% FOREACH bookseller IN booksellersloop %] >+ <tr> >+ <td>[% bookseller.name %]</td> >+ <td><a href="transferorder.pl?[% IF (bookselleridfrom) %]bookselleridto[% ELSE %]bookselleridfrom[% END %]=[% bookseller.id %][% IF (ordernumber) %]&ordernumber=[% ordernumber %][% END %][% IF (referrer) %]&referrer=[% referrer | uri %][% END %]">Choose</a></td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% ELSE %] >+ <p>No results found.</p> >+ [% END %] >+ [% END %] >+ [% IF ( search_form ) %] >+ [% IF ( bookselleridfrom ) %] >+ <h1>Search for a vendor to transfer to</h1> >+ [% ELSE %] >+ <h1>Search for a vendor to transfer from</h1> >+ [% END %] >+ <form method="get" action="transferorder.pl"> >+ <input type="hidden" name="op" value="do_search" /> >+ <input type="hidden" name="referrer" value="[% referrer %]" /> >+ [% IF ( ordernumber ) %] >+ <input type="hidden" name="ordernumber" value="[% ordernumber %]" /> >+ [% END %] >+ [% IF ( bookselleridfrom ) %] >+ <input type="hidden" name="bookselleridfrom" value="[% bookselleridfrom %]" /> >+ [% END %] >+ <label for="query">Vendor:</label> >+ <input type="text" name="query" /> >+ <input type="submit" value="Search" /> >+ </form> >+ [% END %] >+ </div> >+</div> >+ >+<div class="yui-b"> >+ [% INCLUDE 'acquisitions-menu.inc' %] >+</div> >+</div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5349
:
8961
|
8962
|
9909
|
10032
|
10190
|
10375
|
10376
|
10441
|
10462
|
10463
|
10636
|
11117
|
11118
|
11385
|
11386
|
12236
|
12237
|
12238
|
12420
|
12421
|
12422
|
12462
|
12463
|
12464
|
14441
|
14442
|
14443
|
16499
|
16500
|
16501
|
18931
|
18933
|
18934
|
18935
|
19332
|
19333
|
19336
|
19917
|
19918
|
19919
|
19920
|
19921
|
19922
|
20476
|
20477
|
20478
|
20479
|
20480
|
20481
|
20691
|
20692
|
20693
|
20694
|
20695
|
20696