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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 1509-1515 sub AddIssue { Link Here
1509
            # Get ID of logged in user.  if called from a batch job,
1509
            # Get ID of logged in user.  if called from a batch job,
1510
            # no user session exists and C4::Context->userenv() returns
1510
            # no user session exists and C4::Context->userenv() returns
1511
            # the scalar '0'. Only do this is the syspref says so
1511
            # the scalar '0'. Only do this is the syspref says so
1512
            if ( C4::Context->preference('RecordIssuer') ) {
1512
            if ( C4::Context->preference('RecordStaffUserOnCheckout') ) {
1513
                my $userenv = C4::Context->userenv();
1513
                my $userenv = C4::Context->userenv();
1514
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1514
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1515
                if ($usernumber) {
1515
                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 1618-1624 DROP TABLE IF EXISTS `issues`; Link Here
1618
CREATE TABLE `issues` ( -- information related to check outs or issues
1618
CREATE TABLE `issues` ( -- information related to check outs or issues
1619
  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
1619
  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
1620
  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1620
  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1621
  `issuer` int(11), -- foreign key, linking this to the borrowers table for the user who checked out this item
1621
  `issuer` int(11) default NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
1622
  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
1622
  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
1623
  `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
1623
  `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
1624
  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1624
  `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 535-541 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
535
('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'),
535
('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'),
536
('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'),
536
('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'),
537
('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
('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'),
538
('RecordIssuer','0',NULL,'If ON, when an item is issued, the user who issued the item is recorded','YesNo'),
538
('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'),
539
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
539
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
540
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
540
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
541
('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'),
541
('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 4153-4159 subtest 'Checkout should correctly terminate a transfer' => sub { Link Here
4153
    is( $hold->priority, 1, );
4153
    is( $hold->priority, 1, );
4154
}
4154
}
4155
4155
4156
subtest 'AddIssue records issuer if appropriate' => sub  {
4156
subtest 'AddIssue records staff who checked out item if appropriate' => sub  {
4157
    plan tests => 2;
4157
    plan tests => 2;
4158
4158
4159
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
4159
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
Lines 4186-4199 subtest 'AddIssue records issuer if appropriate' => sub { Link Here
4186
    my $issue =
4186
    my $issue =
4187
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4187
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4188
4188
4189
    is( $issue->issuer, undef, "Issuer not recorded when RecordIssuer turned off" );
4189
    is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
4190
4190
4191
    t::lib::Mocks::mock_preference('RecordIssuer', 1);
4191
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
4192
4192
4193
    my $issue2 =
4193
    my $issue2 =
4194
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4194
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4195
4195
4196
    is( $issue->issuer, $issuer->{borrowernumber}, "Issuer recorded when RecordIssuer turned on" );
4196
    is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
4197
};
4197
};
4198
4198
4199
$schema->storage->txn_rollback;
4199
$schema->storage->txn_rollback;
4200
- 

Return to bug 23916