View | Details | Raw Unified | Return to bug 23916
Collapse All | Expand All

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 1515-1521 sub AddIssue { Link Here
1515
            # Get ID of logged in user.  if called from a batch job,
1515
            # Get ID of logged in user.  if called from a batch job,
1516
            # no user session exists and C4::Context->userenv() returns
1516
            # no user session exists and C4::Context->userenv() returns
1517
            # the scalar '0'. Only do this is the syspref says so
1517
            # the scalar '0'. Only do this is the syspref says so
1518
            if ( C4::Context->preference('RecordIssuer') ) {
1518
            if ( C4::Context->preference('RecordStaffUserOnCheckout') ) {
1519
                my $userenv = C4::Context->userenv();
1519
                my $userenv = C4::Context->userenv();
1520
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1520
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1521
                if ($usernumber) {
1521
                if ($usernumber) {
(-)a/installer/data/mysql/atomicupdate/bug_23916_add_RecordIssuer_syspref.perl (-2 / +2 lines)
Lines 1-8 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
3
4
    $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'); | );
4
    $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'); | );
5
5
6
    SetVersion( $DBversion );
6
    SetVersion( $DBversion );
7
    print "Upgrade to $DBversion done (Bug 23916 - Add RecordIssuer syspref)\n";
7
    print "Upgrade to $DBversion done (Bug 23916 - Add RecordStaffUserOnCheckout syspref)\n";
8
}
8
}
(-)a/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl (-2 / +2 lines)
Lines 1-13 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
    if( !column_exists( 'issues', 'issuer' ) ) {
3
    if( !column_exists( 'issues', 'issuer' ) ) {
4
        $dbh->do( q| ALTER TABLE issues ADD issuer INT(11) AFTER borrowernumber | );
4
        $dbh->do( q| ALTER TABLE issues ADD issuer INT(11) DEFAULT NULL AFTER borrowernumber | );
5
    }
5
    }
6
    if (!foreign_key_exists( 'issues', 'issues_ibfk_borrowers_borrowernumber' )) {
6
    if (!foreign_key_exists( 'issues', 'issues_ibfk_borrowers_borrowernumber' )) {
7
        $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 | );
7
        $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 | );
8
    }
8
    }
9
    if( !column_exists( 'old_issues', 'issuer' ) ) {
9
    if( !column_exists( 'old_issues', 'issuer' ) ) {
10
        $dbh->do( q| ALTER TABLE old_issues ADD issuer INT(11) AFTER borrowernumber | );
10
        $dbh->do( q| ALTER TABLE old_issues ADD issuer INT(11) DEFAULT NULL AFTER borrowernumber | );
11
    }
11
    }
12
    if (!foreign_key_exists( 'old_issues', 'old_issues_ibfk_borrowers_borrowernumber' )) {
12
    if (!foreign_key_exists( 'old_issues', 'old_issues_ibfk_borrowers_borrowernumber' )) {
13
        $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 | );
13
        $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 | );
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 1617-1623 DROP TABLE IF EXISTS `issues`; Link Here
1617
CREATE TABLE `issues` ( -- information related to check outs or issues
1617
CREATE TABLE `issues` ( -- information related to check outs or issues
1618
  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
1618
  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
1619
  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1619
  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1620
  `issuer` int(11), -- foreign key, linking this to the borrowers table for the user who checked out this item
1620
  `issuer` int(11) default NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
1621
  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
1621
  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
1622
  `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
1622
  `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
1623
  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1623
  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 534-540 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
534
('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'),
534
('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'),
535
('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'),
535
('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'),
536
('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'),
536
('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'),
537
('RecordIssuer','0',NULL,'If ON, when an item is issued, the user who issued the item is recorded','YesNo'),
537
('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'),
538
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
538
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
539
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
539
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
540
('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'),
540
('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'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-3 / +3 lines)
Lines 446-457 Circulation: Link Here
446
                  nothing : "do nothing"
446
                  nothing : "do nothing"
447
            - .
447
            - .
448
        -
448
        -
449
            - "When issuing an item, "
449
            - "When checking out an item, "
450
            - pref: RecordIssuer
450
            - pref: RecordStaffUserOnCheckout
451
              choices:
451
              choices:
452
                  yes: "record"
452
                  yes: "record"
453
                  no: "don't record"
453
                  no: "don't record"
454
            - "the user who issued the item."
454
            - "the user who checked out the item."
455
        -
455
        -
456
            - "Mark items as returned when flagged as lost "
456
            - "Mark items as returned when flagged as lost "
457
            - pref: MarkLostItemsAsReturned
457
            - pref: MarkLostItemsAsReturned
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt (-3 / +3 lines)
Lines 37-43 Link Here
37
            [% END %]
37
            [% END %]
38
            <th>Barcode</th>
38
            <th>Barcode</th>
39
            <th>Checked out from</th>
39
            <th>Checked out from</th>
40
            [% IF Koha.Preference('RecordIssuer') %]
40
            [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
41
            <th>Checked out by</th>
41
            <th>Checked out by</th>
42
            [% END %]
42
            [% END %]
43
            <th>Renewed</th>
43
            <th>Renewed</th>
Lines 66-75 Link Here
66
                    [% ELSE %]
66
                    [% ELSE %]
67
                        &nbsp;
67
                        &nbsp;
68
                    [% END %]</td>
68
                    [% END %]</td>
69
                [% IF Koha.Preference('RecordIssuer') %]
69
                [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
70
                <td>[% IF checkout.issuer %]
70
                <td>[% IF checkout.issuer %]
71
                    <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% checkout.issuer | uri %]">
71
                    <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% checkout.issuer | uri %]">
72
                    [% checkout.issued_by.firstname | html %] [% checkout.issued_by.surname | html %]
72
                    [% INCLUDE 'patron-title.inc' patron=checkout.issued_by %]
73
                    </a>
73
                    </a>
74
                    [% END %]</td>
74
                    [% END %]</td>
75
                [% END %]
75
                [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt (-2 / +2 lines)
Lines 58-64 Link Here
58
        <th>Number of renewals</th>
58
        <th>Number of renewals</th>
59
        <th class="title-string">Checked out on</th>
59
        <th class="title-string">Checked out on</th>
60
        <th>Checked out from</th>
60
        <th>Checked out from</th>
61
        [% IF Koha.Preference('RecordIssuer') %]
61
        [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
62
        <th>Checked out by</th>
62
        <th>Checked out by</th>
63
        [% END %]
63
        [% END %]
64
        <th class="title-string">Date due</th>
64
        <th class="title-string">Date due</th>
Lines 97-103 Link Here
97
            <span title="[% issue.issuedate | html %]">[% issue.issuedate |$KohaDates  with_hours => 1 %]</span>
97
            <span title="[% issue.issuedate | html %]">[% issue.issuedate |$KohaDates  with_hours => 1 %]</span>
98
          </td>
98
          </td>
99
          <td>[% Branches.GetName( issue.branchcode ) | html %]</td>
99
          <td>[% Branches.GetName( issue.branchcode ) | html %]</td>
100
          [% IF Koha.Preference('RecordIssuer') %]
100
          [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
101
          <td><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% issue.issuer | uri %]">[% issue.firstname | html %] [% issue.surname | html %]</a></td>
101
          <td><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% issue.issuer | uri %]">[% issue.firstname | html %] [% issue.surname | html %]</a></td>
102
          [% END %]
102
          [% END %]
103
          <td>
103
          <td>
(-)a/t/db_dependent/Circulation.t (-7 / +6 lines)
Lines 121-128 for my $branch ( $branches->next ) { Link Here
121
$dbh->do('DELETE FROM issues');
121
$dbh->do('DELETE FROM issues');
122
$dbh->do('DELETE FROM borrowers');
122
$dbh->do('DELETE FROM borrowers');
123
123
124
# Disable recording of issuer until we're ready for it
124
# Disable recording of the staff who checked out an item until we're ready for it
125
t::lib::Mocks::mock_preference('RecordIssuer', 0);
125
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 0);
126
126
127
my $module = new Test::MockModule('C4::Context');
127
my $module = new Test::MockModule('C4::Context');
128
128
Lines 4121-4127 subtest 'Checkout should correctly terminate a transfer' => sub { Link Here
4121
    is( $hold->priority, 1, );
4121
    is( $hold->priority, 1, );
4122
}
4122
}
4123
4123
4124
subtest 'AddIssue records issuer if appropriate' => sub  {
4124
subtest 'AddIssue records staff who checked out item if appropriate' => sub  {
4125
    plan tests => 2;
4125
    plan tests => 2;
4126
4126
4127
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
4127
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
Lines 4154-4167 subtest 'AddIssue records issuer if appropriate' => sub { Link Here
4154
    my $issue =
4154
    my $issue =
4155
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4155
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4156
4156
4157
    is( $issue->issuer, undef, "Issuer not recorded when RecordIssuer turned off" );
4157
    is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
4158
4158
4159
    t::lib::Mocks::mock_preference('RecordIssuer', 1);
4159
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
4160
4160
4161
    my $issue2 =
4161
    my $issue2 =
4162
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4162
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4163
4163
4164
    is( $issue->issuer, $issuer->{borrowernumber}, "Issuer recorded when RecordIssuer turned on" );
4164
    is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
4165
};
4165
};
4166
4166
4167
$schema->storage->txn_rollback;
4167
$schema->storage->txn_rollback;
4168
- 

Return to bug 23916