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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 1496-1502 sub AddIssue { Link Here
1496
            # Get ID of logged in user.  if called from a batch job,
1496
            # Get ID of logged in user.  if called from a batch job,
1497
            # no user session exists and C4::Context->userenv() returns
1497
            # no user session exists and C4::Context->userenv() returns
1498
            # the scalar '0'. Only do this is the syspref says so
1498
            # the scalar '0'. Only do this is the syspref says so
1499
            if ( C4::Context->preference('RecordIssuer') ) {
1499
            if ( C4::Context->preference('RecordStaffUserOnCheckout') ) {
1500
                my $userenv = C4::Context->userenv();
1500
                my $userenv = C4::Context->userenv();
1501
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1501
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1502
                if ($usernumber) {
1502
                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/sysprefs.sql (-1 / +1 lines)
Lines 532-538 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
532
('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'),
532
('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'),
533
('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'),
533
('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'),
534
('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'),
534
('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'),
535
('RecordIssuer','0',NULL,'If ON, when an item is issued, the user who issued the item is recorded','YesNo'),
535
('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'),
536
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
536
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
537
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
537
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
538
('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'),
538
('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 441-452 Circulation: Link Here
441
                  nothing : "do nothing"
441
                  nothing : "do nothing"
442
            - .
442
            - .
443
        -
443
        -
444
            - "When issuing an item, "
444
            - "When checking out an item, "
445
            - pref: RecordIssuer
445
            - pref: RecordStaffUserOnCheckout
446
              choices:
446
              choices:
447
                  yes: "record"
447
                  yes: "record"
448
                  no: "don't record"
448
                  no: "don't record"
449
            - "the user who issued the item."
449
            - "the user who checked out the item."
450
        -
450
        -
451
            - "Mark items as returned when flagged as lost "
451
            - "Mark items as returned when flagged as lost "
452
            - pref: MarkLostItemsAsReturned
452
            - 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 95-101 Link Here
95
            <span title="[% issue.issuedate | html %]">[% issue.issuedate |$KohaDates  with_hours => 1 %]</span>
95
            <span title="[% issue.issuedate | html %]">[% issue.issuedate |$KohaDates  with_hours => 1 %]</span>
96
          </td>
96
          </td>
97
          <td>[% Branches.GetName( issue.branchcode ) | html %]</td>
97
          <td>[% Branches.GetName( issue.branchcode ) | html %]</td>
98
          [% IF Koha.Preference('RecordIssuer') %]
98
          [% IF Koha.Preference('RecordStaffUserOnCheckout') %]
99
          <td><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% issue.issuer | uri %]">[% issue.firstname | html %] [% issue.surname | html %]</a></td>
99
          <td><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% issue.issuer | uri %]">[% issue.firstname | html %] [% issue.surname | html %]</a></td>
100
          [% END %]
100
          [% END %]
101
          <td>
101
          <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 4064-4070 subtest 'transferbook tests' => sub { Link Here
4064
4064
4065
};
4065
};
4066
4066
4067
subtest 'AddIssue records issuer if appropriate' => sub  {
4067
subtest 'AddIssue records staff who checked out item if appropriate' => sub  {
4068
    plan tests => 2;
4068
    plan tests => 2;
4069
4069
4070
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
4070
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
Lines 4097-4110 subtest 'AddIssue records issuer if appropriate' => sub { Link Here
4097
    my $issue =
4097
    my $issue =
4098
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4098
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4099
4099
4100
    is( $issue->issuer, undef, "Issuer not recorded when RecordIssuer turned off" );
4100
    is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
4101
4101
4102
    t::lib::Mocks::mock_preference('RecordIssuer', 1);
4102
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
4103
4103
4104
    my $issue2 =
4104
    my $issue2 =
4105
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4105
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4106
4106
4107
    is( $issue->issuer, $issuer->{borrowernumber}, "Issuer recorded when RecordIssuer turned on" );
4107
    is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
4108
};
4108
};
4109
4109
4110
$schema->storage->txn_rollback;
4110
$schema->storage->txn_rollback;
4111
- 

Return to bug 23916