From 3a1ab4a7c34039f36ec3639510102a43d5549759 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Mon, 12 Oct 2020 10:28:33 +0100 Subject: [PATCH] Bug 23916: (follow-up) Fix terminology, use patron-title and make column consistent in issues and old_issues This commit makes the changes suggested by Katrin in comment #50: - Changed syspref from RecordIssuer to RecordStaffUserOnCheckout - Changed terminology from "issue" to "check out" and variations - Fixed name display to use patron-title.inc - Made issuer column DEFAULT NULL consistently between issues and old_issues and between the DB update and kohastructure.sql --- C4/Circulation.pm | 2 +- .../bug_23916_add_RecordIssuer_syspref.perl | 4 ++-- .../atomicupdate/bug_23916_add_issues_issuer.perl | 4 ++-- installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/mandatory/sysprefs.sql | 2 +- .../en/modules/admin/preferences/circulation.pref | 6 +++--- .../prog/en/modules/catalogue/issuehistory.tt | 6 +++--- .../prog/en/modules/members/readingrec.tt | 4 ++-- t/db_dependent/Circulation.t | 12 ++++++------ 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 00dc83bf9f..97308660ed 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1509,7 +1509,7 @@ sub AddIssue { # Get ID of logged in user. if called from a batch job, # no user session exists and C4::Context->userenv() returns # the scalar '0'. Only do this is the syspref says so - if ( C4::Context->preference('RecordIssuer') ) { + if ( C4::Context->preference('RecordStaffUserOnCheckout') ) { my $userenv = C4::Context->userenv(); my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef; if ($usernumber) { diff --git a/installer/data/mysql/atomicupdate/bug_23916_add_RecordIssuer_syspref.perl b/installer/data/mysql/atomicupdate/bug_23916_add_RecordIssuer_syspref.perl index ad3dca7b18..aa1dc6960e 100644 --- a/installer/data/mysql/atomicupdate/bug_23916_add_RecordIssuer_syspref.perl +++ b/installer/data/mysql/atomicupdate/bug_23916_add_RecordIssuer_syspref.perl @@ -1,8 +1,8 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { - $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RecordIssuer', '0', 'If enabled, when an item is issued, the user who issued the item is recorded', '', 'YesNo'); | ); + $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RecordStaffUserOnCheckout', '0', 'If enabled, when an item is checked out, the user who checked out the item is recorded', '', 'YesNo'); | ); SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 23916 - Add RecordIssuer syspref)\n"; + print "Upgrade to $DBversion done (Bug 23916 - Add RecordStaffUserOnCheckout syspref)\n"; } diff --git a/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl b/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl index 589d3a91a8..08ede0aa74 100644 --- a/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl +++ b/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl @@ -1,13 +1,13 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { if( !column_exists( 'issues', 'issuer' ) ) { - $dbh->do( q| ALTER TABLE issues ADD issuer INT(11) AFTER borrowernumber | ); + $dbh->do( q| ALTER TABLE issues ADD issuer INT(11) DEFAULT NULL AFTER borrowernumber | ); } if (!foreign_key_exists( 'issues', 'issues_ibfk_borrowers_borrowernumber' )) { $dbh->do( q| ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE | ); } if( !column_exists( 'old_issues', 'issuer' ) ) { - $dbh->do( q| ALTER TABLE old_issues ADD issuer INT(11) AFTER borrowernumber | ); + $dbh->do( q| ALTER TABLE old_issues ADD issuer INT(11) DEFAULT NULL AFTER borrowernumber | ); } if (!foreign_key_exists( 'old_issues', 'old_issues_ibfk_borrowers_borrowernumber' )) { $dbh->do( q| ALTER TABLE old_issues ADD CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE | ); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 6321e17644..1dac492cad 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1618,7 +1618,7 @@ DROP TABLE IF EXISTS `issues`; CREATE TABLE `issues` ( -- information related to check outs or issues `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to - `issuer` int(11), -- foreign key, linking this to the borrowers table for the user who checked out this item + `issuer` int(11) default NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss) `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 06ca7a02b4..7e2cd5e6d2 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -535,7 +535,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'), ('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'), ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'), -('RecordIssuer','0',NULL,'If ON, when an item is issued, the user who issued the item is recorded','YesNo'), +('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'), ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'), ('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'), ('RenewAccruingItemWhenPaid','0','','If enabled, when the fines on an item accruing is paid off, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 8446f4e8a0..f28be34768 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -446,12 +446,12 @@ Circulation: nothing : "do nothing" - . - - - "When issuing an item, " - - pref: RecordIssuer + - "When checking out an item, " + - pref: RecordStaffUserOnCheckout choices: yes: "record" no: "don't record" - - "the user who issued the item." + - "the user who checked out the item." - - "Mark items as returned when flagged as lost " - pref: MarkLostItemsAsReturned diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt index a79feb04de..796c5e62e6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt @@ -37,7 +37,7 @@ [% END %] Barcode Checked out from - [% IF Koha.Preference('RecordIssuer') %] + [% IF Koha.Preference('RecordStaffUserOnCheckout') %] Checked out by [% END %] Renewed @@ -66,10 +66,10 @@ [% ELSE %]   [% END %] - [% IF Koha.Preference('RecordIssuer') %] + [% IF Koha.Preference('RecordStaffUserOnCheckout') %] [% IF checkout.issuer %] - [% checkout.issued_by.firstname | html %] [% checkout.issued_by.surname | html %] + [% INCLUDE 'patron-title.inc' patron=checkout.issued_by %] [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt index 59e84be4d0..019e3b78cb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt @@ -58,7 +58,7 @@ Number of renewals Checked out on Checked out from - [% IF Koha.Preference('RecordIssuer') %] + [% IF Koha.Preference('RecordStaffUserOnCheckout') %] Checked out by [% END %] Date due @@ -97,7 +97,7 @@ [% issue.issuedate |$KohaDates with_hours => 1 %] [% Branches.GetName( issue.branchcode ) | html %] - [% IF Koha.Preference('RecordIssuer') %] + [% IF Koha.Preference('RecordStaffUserOnCheckout') %] [% issue.firstname | html %] [% issue.surname | html %] [% END %] diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index f95b288e50..5e3da283d6 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -121,8 +121,8 @@ for my $branch ( $branches->next ) { $dbh->do('DELETE FROM issues'); $dbh->do('DELETE FROM borrowers'); -# Disable recording of issuer until we're ready for it -t::lib::Mocks::mock_preference('RecordIssuer', 0); +# Disable recording of the staff who checked out an item until we're ready for it +t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 0); my $module = new Test::MockModule('C4::Context'); @@ -4153,7 +4153,7 @@ subtest 'Checkout should correctly terminate a transfer' => sub { is( $hold->priority, 1, ); } -subtest 'AddIssue records issuer if appropriate' => sub { +subtest 'AddIssue records staff who checked out item if appropriate' => sub { plan tests => 2; $module->mock( 'userenv', sub { { branch => $library->{id} } } ); @@ -4186,14 +4186,14 @@ subtest 'AddIssue records issuer if appropriate' => sub { my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); - is( $issue->issuer, undef, "Issuer not recorded when RecordIssuer turned off" ); + is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); - t::lib::Mocks::mock_preference('RecordIssuer', 1); + t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); my $issue2 = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); - is( $issue->issuer, $issuer->{borrowernumber}, "Issuer recorded when RecordIssuer turned on" ); + is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); }; $schema->storage->txn_rollback; -- 2.20.1