From de965feef2d7fbdd3bb31389b356978c08a554b1 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 9 Jun 2014 16:15:17 +0200 Subject: [PATCH] Bug 12395: Save order line's creator New MySQL column: aqorders.createdby Creator's name is displayed on order's receive pages (acqui/orderreceive.pl and acqui/parcel.pl) On acqui/orderreceive.pl it replace the name of basket's creator On acqui/parcel.pl, to avoid adding more data in the table of pending orders, it is shown in a popup like MARC and Card views Test plan: 1/ Run updatedatabase.pl 2/ Create a new order and go to the receipt page (acqui/parcel.pl) 3/ Click on "Order" link in column "More" (previously "View record") 4/ A javascript popup should appear with your name in it. Close the popup. 5/ Click on "Receive" link 6/ Your name should appear in front of "Created by" label, to the right of the page. --- C4/Acquisition.pm | 8 +++- acqui/orderreceive.pl | 6 +-- acqui/showorder.pl | 44 ++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 10 +++++ .../prog/en/modules/acqui/orderreceive.tt | 14 ++++++- .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 8 +++- .../prog/en/modules/acqui/showorder.tt | 39 +++++++++++++++++ 8 files changed, 122 insertions(+), 8 deletions(-) create mode 100755 acqui/showorder.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/showorder.tt diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 38646cb..4ea0349 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1265,12 +1265,18 @@ sub NewOrder { my $dbh = C4::Context->dbh; my @params; - # if these parameters are missing, we can't continue for my $key (qw/basketno quantity biblionumber budget_id/) { croak "Mandatory parameter $key missing" unless $orderinfo->{$key}; } + if (not defined $orderinfo->{createdby}) { + my $userenv = C4::Context->userenv; + if ($userenv) { + $orderinfo->{createdby} = $userenv->{number}; + } + } + if ( defined $orderinfo->{subscription} && $orderinfo->{'subscription'} eq 'yes' ) { $orderinfo->{'subscription'} = 1; } else { diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 50920e0..5262c15 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -190,8 +190,7 @@ if ( $bookseller->{listincgst} ) { my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber}); -my $authorisedby = $order->{authorisedby}; -my $member = GetMember( borrowernumber => $authorisedby ); +my $creator = GetMember( borrowernumber => $order->{createdby} ); my $budget = GetBudget( $order->{budget_id} ); @@ -216,8 +215,7 @@ $template->param( quantityreceived => $order->{'quantityreceived'}, rrp => sprintf( "%.2f", $rrp ), ecost => sprintf( "%.2f", $ecost ), - memberfirstname => $member->{firstname} || "", - membersurname => $member->{surname} || "", + creator => $creator, invoiceid => $invoice->{invoiceid}, invoice => $invoice->{invoicenumber}, datereceived => $datereceived->output(), diff --git a/acqui/showorder.pl b/acqui/showorder.pl new file mode 100755 index 0000000..048eb9f --- /dev/null +++ b/acqui/showorder.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +# 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::Acquisition; +use C4::Members; +use C4::Output; + +my $cgi = new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ + template_name => "acqui/showorder.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { acquisition => '*' }, +}); + +my $ordernumber = $cgi->param('ordernumber'); +my $order = GetOrder($ordernumber); +my $creator = GetMember(borrowernumber => $order->{createdby}); + +$template->param( + order => $order, + creator => $creator, +); + +output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index b46dc6a..dcfb895 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3002,6 +3002,7 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items `freight` decimal(28,6) default NULL, -- shipping costs (not used) `unitprice` decimal(28,6) default NULL, -- the actual cost entered when receiving this line item `quantityreceived` smallint(6) NOT NULL default 0, -- the quantity that have been received so far + createdby int(11) NULL DEFAULT NULL, -- the borrowernumber of order line's creator `cancelledby` varchar(10) default NULL, -- not used? always NULL `datecancellationprinted` date default NULL, -- the date the line item was deleted `order_internalnote` mediumtext, -- notes related to this order line, made for staff diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 01472d7..a071a8f 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8551,6 +8551,16 @@ if (CheckVersion($DBversion)) { SetVersion($DBversion); } +$DBversion = "XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + ALTER TABLE aqorders + ADD COLUMN createdby int(11) NULL DEFAULT NULL AFTER quantityreceived + }); + print "Upgrade to $DBversion done (Bug 12395: Add aqorders.createdby column)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 422a4a3..64a0873 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -279,7 +279,19 @@ [% END %]
  • (Current: [% budget_period_description %] - [% bookfund %])
  • -
  • [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]
  • +
  • + + + [% IF (creator && creator.firstname && creator.surname) %] + [% IF creator.firstname %] + [% creator.firstname %] + [% END %] + [% creator.surname %] + [% ELSE %] + No name + [% END %] + +
  • [% IF ( edit and not subscriptionid) %] 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 69c047d..019806e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -243,7 +243,7 @@ Basket group Order line Summary - View record + More Quantity Unit cost Order cost @@ -286,7 +286,11 @@ [Add vendor note] [% END %] - MARC | Card + + Order
    + MARC
    + Card + [% loop_order.quantity %] [% loop_order.ecost %] [% loop_order.ordertotal %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/showorder.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/showorder.tt new file mode 100644 index 0000000..6639dd4 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/showorder.tt @@ -0,0 +1,39 @@ +[% INCLUDE 'doc-head-open.inc' %] + + + + [% IF order %] + + + + + + + + + + + + + + + + + + + +
    Creation date[% order.entrydate %]
    Creator[% creator.firstname %] [% creator.surname %]
    Claims count[% order.claims_count %]
    Last claim date[% order.claimed_date %]
    + [% ELSE %] + No order found. + [% END %] + + + -- 1.7.10.4