From 3ae6ac37204dd4fb575aea189f7c2e80e46ab70c 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. Signed-off-by: Paola Rossi --- acqui/neworderempty.pl | 8 +++++++- installer/data/mysql/kohastructure.sql | 4 +++- installer/data/mysql/updatedatabase.pl | 18 +++++++++++++++++ .../prog/en/modules/acqui/neworderempty.tt | 21 ++++++++++++++++++++ 4 files changed, 49 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 e2ee43b..19c4338 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2934,6 +2934,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`), @@ -2941,7 +2942,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 9871cfd..e22901a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7169,6 +7169,24 @@ 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 11001 - Add column aqorders.branchcode)\n"; + SetVersion($DBversion); +} + + + +>>>>>>> Bug 11001: aqorders.branchcode is missing =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