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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 1523-1529 sub AddIssue { Link Here
1523
            # Get ID of logged in user.  if called from a batch job,
1523
            # Get ID of logged in user.  if called from a batch job,
1524
            # no user session exists and C4::Context->userenv() returns
1524
            # no user session exists and C4::Context->userenv() returns
1525
            # the scalar '0'. Only do this is the syspref says so
1525
            # the scalar '0'. Only do this is the syspref says so
1526
            if ( C4::Context->preference('RecordIssuer') ) {
1526
            if ( C4::Context->preference('RecordStaffUserOnCheckout') ) {
1527
                my $userenv = C4::Context->userenv();
1527
                my $userenv = C4::Context->userenv();
1528
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1528
                my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
1529
                if ($usernumber) {
1529
                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 536-542 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
536
('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'),
536
('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'),
537
('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'),
537
('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'),
538
('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
('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'),
539
('RecordIssuer','0',NULL,'If ON, when an item is issued, the user who issued the item is recorded','YesNo'),
539
('RecordStaffUserOnCheckout','0',NULL,'If ON, when an item is checked out, the user who checked out the item is recorded','YesNo'),
540
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
540
('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
541
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
541
('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
542
('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'),
542
('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 122-129 for my $branch ( $branches->next ) { Link Here
122
$dbh->do('DELETE FROM issues');
122
$dbh->do('DELETE FROM issues');
123
$dbh->do('DELETE FROM borrowers');
123
$dbh->do('DELETE FROM borrowers');
124
124
125
# Disable recording of issuer until we're ready for it
125
# Disable recording of the staff who checked out an item until we're ready for it
126
t::lib::Mocks::mock_preference('RecordIssuer', 0);
126
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 0);
127
127
128
my $module = new Test::MockModule('C4::Context');
128
my $module = new Test::MockModule('C4::Context');
129
129
Lines 4605-4611 subtest 'Checkout should correctly terminate a transfer' => sub { Link Here
4605
    is( $hold->priority, 1, );
4605
    is( $hold->priority, 1, );
4606
}
4606
}
4607
4607
4608
subtest 'AddIssue records issuer if appropriate' => sub  {
4608
subtest 'AddIssue records staff who checked out item if appropriate' => sub  {
4609
    plan tests => 2;
4609
    plan tests => 2;
4610
4610
4611
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
4611
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
Lines 4638-4651 subtest 'AddIssue records issuer if appropriate' => sub { Link Here
4638
    my $issue =
4638
    my $issue =
4639
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4639
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4640
4640
4641
    is( $issue->issuer, undef, "Issuer not recorded when RecordIssuer turned off" );
4641
    is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
4642
4642
4643
    t::lib::Mocks::mock_preference('RecordIssuer', 1);
4643
    t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1);
4644
4644
4645
    my $issue2 =
4645
    my $issue2 =
4646
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4646
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4647
4647
4648
    is( $issue->issuer, $issuer->{borrowernumber}, "Issuer recorded when RecordIssuer turned on" );
4648
    is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" );
4649
};
4649
};
4650
4650
4651
$schema->storage->txn_rollback;
4651
$schema->storage->txn_rollback;
4652
- 

Return to bug 23916