From dc57df3a29935b30aaf21a3425ca8a3783aa573d Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 1 Jul 2013 13:43:08 +0000 Subject: [PATCH] Bug 7162; Factorize code for order cancellation (QA fixes) * Remove tab characters in acqui/addorder.pl * Remove FIXME in acqui/cancelorder.pl * Fix typos: "canceled" -> "cancelled", "occured" -> "occurred" * Replace "Click here" link by "OK" * Add a column to aqorders to store cancellation reason instead of having it in aqorders.notes, to avoid having untranslatable strings in database --- C4/Acquisition.pm | 9 ++------- acqui/addorder.pl | 8 ++++---- acqui/cancelorder.pl | 5 ----- installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 11 +++++++++++ koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt | 4 ++++ .../intranet-tmpl/prog/en/modules/acqui/cancelorder.tt | 10 +++++----- 7 files changed, 27 insertions(+), 21 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index e3f0076..520661a 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1598,19 +1598,14 @@ sub DelOrder { SET datecancellationprinted=now() "; if($reason) { - $query .= " - , notes = IF(notes IS NULL, - CONCAT('Cancellation reason: ', ?), - CONCAT(notes, ' - Cancellation reason: ', ?) - ) - "; + $query .= ", cancellationreason = ? "; } $query .= " WHERE biblionumber=? AND ordernumber=? "; my $sth = $dbh->prepare($query); if($reason) { - $sth->execute($reason, $reason, $bibnum, $ordernumber); + $sth->execute($reason, $bibnum, $ordernumber); } else { $sth->execute( $bibnum, $ordernumber ); } diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 13c44ee..1fb5bbf 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -122,10 +122,10 @@ if it is an order from an existing suggestion : the id of this suggestion. use strict; use warnings; use CGI; -use C4::Auth; # get_template_and_user -use C4::Acquisition; # NewOrder ModOrder -use C4::Suggestions; # ModStatus -use C4::Biblio; # AddBiblio TransformKohaToMarc +use C4::Auth; # get_template_and_user +use C4::Acquisition; # NewOrder ModOrder +use C4::Suggestions; # ModStatus +use C4::Biblio; # AddBiblio TransformKohaToMarc use C4::Items; use C4::Output; diff --git a/acqui/cancelorder.pl b/acqui/cancelorder.pl index 0c24893..c45b8da 100755 --- a/acqui/cancelorder.pl +++ b/acqui/cancelorder.pl @@ -33,11 +33,6 @@ use Modern::Perl; use CGI; use C4::Auth; use C4::Output; -# FIXME: C4::Search is needed by C4::Items::GetAnalyticsCount, which is called -# by C4::Acquisition::DelOrder. But C4::Search is not imported by C4::Items. -# Once this problem is resolved, the following line can be removed. -# See Bug 7847. -use C4::Search; use C4::Acquisition; my $input = new CGI; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index fdab879..75df280 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2912,6 +2912,7 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items `quantityreceived` smallint(6) NOT NULL default 0, -- the quantity that have been received so far `cancelledby` varchar(10) default NULL, -- not used? always NULL `datecancellationprinted` date default NULL, -- the date the line item was deleted + cancellationreason text default NULL, -- reason of cancellation `notes` mediumtext, -- notes related to this order line `supplierreference` mediumtext, -- not used? always NULL `purchaseordernumber` mediumtext, -- not used? always NULL diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 31f494a..a44d568 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7139,6 +7139,17 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(" + ALTER TABLE aqorders + ADD COLUMN cancellationreason TEXT DEFAULT NULL AFTER datecancellationprinted + "); + print "Upgrade to $DBversion done (Bug 7162: Add aqorders.cancellationreason)\n"; + SetVersion($DBversion); +} + + =head1 FUNCTIONS =head2 TableExists($table) 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 2ff23d5..907bf98 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -443,6 +443,10 @@ [% IF ( order.publishercode ) %], [% order.publishercode %][% END %] [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %] [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %] + [% IF ( order.cancellationreason ) %] +
+ Cancellation reason: [% order.cancellationreason %] + [% END %]

[% IF order.transferred_to %] [% basket = order.transferred_to.basket %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/cancelorder.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/cancelorder.tt index 4ac1f82..8df5f2c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/cancelorder.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/cancelorder.tt @@ -41,18 +41,18 @@ [% ELSE %] [% IF ( success_cancelorder ) %]
- The order has been successfully canceled + The order has been successfully cancelled [% ELSE %]
- An error has occured. + An error has occurred. [% IF ( error_delitem ) %] -

The order has been canceled, although one or more items could not have been deleted.

+

The order has been cancelled, although one or more items could not have been deleted.

[% END %] [% IF ( error_delbiblio ) %] -

The order has been canceled, although the record has not been deleted.

+

The order has been cancelled, although the record has not been deleted.

[% END %] [% END %] -

Click here to return to previous page

+

OK

[% END %] -- 1.7.10.4