From 555a7fb6d180c642ce9fd94673c7e53b6235a630 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 7 Oct 2013 09:37:26 +0200 Subject: [PATCH] Bug 11001: aqorders.branchcode is missing Some BibLibre developments have been taken into account a aqorders.branchcode field but not one adds it (cf bug 5335, 5339, etc.). This patch adds this new field in the DB and the ability to fill it from the new order empty form. Test plan: - execute the DB entry. - add a new order to a basket. - the select "library" value should be the library of the connected librarian. - save. - close the basket. - edit/show the order and verify the library value is the same as selected before. - receive the order. - search invoices by library and verify results are consistent. --- acqui/neworderempty.pl | 8 +++++++- installer/data/mysql/kohastructure.sql | 4 +++- installer/data/mysql/updatedatabase.pl | 17 ++++++++++++++++ .../prog/en/modules/acqui/neworderempty.tt | 21 ++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 9c9eed3..a5e56ae 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -240,7 +240,13 @@ foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$ value => $thisbranch, branchname => $branches->{$thisbranch}->{'branchname'}, ); - $row{'selected'} = 1 if( $thisbranch && $data->{branchcode} && $thisbranch eq $data->{branchcode}) ; + if ( $data->{branchcode} ) { + $row{'selected'} = 1 + if $thisbranch && $thisbranch eq $data->{branchcode}; + } else { + $row{selected} = 1 + if $thisbranch && $thisbranch eq C4::Context->userenv->{branch}; + } push @branchloop, \%row; } $template->param( branchloop => \@branchloop ); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 3b21470..339f9a2 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2933,6 +2933,7 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items `claimed_date` date default NULL, -- last date a claim was generated `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid) parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent + branchcode varchar(10) default NULL, -- library where the order will be sent PRIMARY KEY (`ordernumber`), KEY `basketno` (`basketno`), KEY `biblionumber` (`biblionumber`), @@ -2940,7 +2941,8 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `aqorders_subscriptionid` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `aqorders_subscriptionid` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `aqorders_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d88b258..322dc42 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7162,6 +7162,23 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } + + + +$DBversion = "3.13.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q| + ALTER TABLE aqorders ADD COLUMN branchcode VARCHAR(10) + |); + $dbh->do(q| + ALTER TABLE aqorders ADD CONSTRAINT aqorders_branchcode FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE + |); + print "Upgrade to $DBversion done (Bug XXXXX - Add column aqorders.branchcode)\n"; + SetVersion($DBversion); +} + + + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index c261530..64ad216 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -1,4 +1,5 @@ [% USE KohaDates %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Acquisitions › Basket [% basketno %] › [% IF ( ordernumber ) %]Modify order details (line #[% ordernumber %])[% ELSE %]New order[% END %] [% INCLUDE 'doc-head-close.inc' %] @@ -430,6 +431,26 @@ $(document).ready(function() [% END %] + +
  • + [% IF close %] + Library: + [% Branches.GetName( branchcode ) %] + [% ELSE %] + + + [% END %] +
  • +
  • [% IF ( close ) %] Currency: -- 1.7.10.4