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

(-)a/C4/Circulation.pm (-17 / +13 lines)
Lines 1474-1497 sub AddIssue { Link Here
1474
            }
1474
            }
1475
1475
1476
            # Check if we need to use an exact due date set by the ILL module
1476
            # Check if we need to use an exact due date set by the ILL module
1477
            if ( C4::Context->preference('ILLUseExactDueDate') ) {
1477
            if ( C4::Context->preference('ILLModule') ) {
1478
                # Check if there is an ILL connected with the biblio of the item we are issuing
1478
                # Check if there is an ILL connected with the biblio of the item we are issuing
1479
                my $biblionumber = $item_object->biblionumber;
1479
                my $ill_request = Koha::Illrequests->search({
1480
                my @illrequests = Koha::Illrequests->search({ biblio_id => $biblionumber });
1480
                    biblio_id => $item_object->biblionumber,
1481
                if ( @illrequests ) {
1481
                    borrowernumber => $borrower->{'borrowernumber'},
1482
                    # There could be more than one ILL request connected with a
1482
                    completed => undef,
1483
                    # given biblio, so we need to make sure we find the right one
1483
                    date_due => { '!=', undef },
1484
                    foreach my $req ( @illrequests ) {
1484
                })->next;
1485
                        if ( $borrower->{ 'borrowernumber' } == $req->borrowernumber ) {
1485
1486
                            # We found the right request, now get the proper attribute
1486
                if ( $ill_request and length( $ill_request->date_due ) > 0 ) {
1487
                            my $ill_date_string = $req->illrequestattributes->find({ type => C4::Context->preference('ILLUseExactDueDate') })->value;
1487
                    my $ill_dt = dt_from_string( $ill_request->date_due );
1488
                            warn $ill_date_string;
1488
                    $ill_dt->set_hour(23);
1489
                            my $ill_dt = dt_from_string( $ill_date_string );
1489
                    $ill_dt->set_minute(59);
1490
                            $ill_dt->set_hour(23);
1490
                    $datedue = $ill_dt;
1491
                            $ill_dt->set_minute(59);
1492
                            $datedue = $ill_dt;
1493
                        }
1494
                    }
1495
                }
1491
                }
1496
            }
1492
            }
1497
1493
(-)a/Koha/Schema/Result/Illrequest.pm (+14 lines)
Lines 47-52 Patron associated with request Link Here
47
47
48
Potential bib linked to request
48
Potential bib linked to request
49
49
50
=head2 date_due
51
52
  data_type: 'datetime'
53
  datetime_undef_if_invalid: 1
54
  is_nullable: 1
55
56
Custom date due specified by backend, leave NULL for default date_due calculation
57
50
=head2 branchcode
58
=head2 branchcode
51
59
52
  data_type: 'varchar'
60
  data_type: 'varchar'
Lines 180-185 __PACKAGE__->add_columns( Link Here
180
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
188
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
181
  "biblio_id",
189
  "biblio_id",
182
  { data_type => "integer", is_nullable => 1 },
190
  { data_type => "integer", is_nullable => 1 },
191
  "date_due",
192
  {
193
    data_type => "datetime",
194
    datetime_undef_if_invalid => 1,
195
    is_nullable => 1,
196
  },
183
  "branchcode",
197
  "branchcode",
184
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 50 },
198
  { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 50 },
185
  "status",
199
  "status",
(-)a/installer/data/mysql/atomicupdate/bug_24239-add_date_due_to_illrequests.pl (+15 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "24239",
5
    description => "Add date_due to illrequests",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        # Do you stuffs here
10
        $dbh->do(q{
11
            ALTER TABLE `illrequests`
12
            ADD `date_due` datetime DEFAULT NULL AFTER `biblio_id`
13
        });
14
    },
15
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2775-2780 CREATE TABLE `illrequests` ( Link Here
2775
  `illrequest_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ILL request number',
2775
  `illrequest_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ILL request number',
2776
  `borrowernumber` int(11) DEFAULT NULL COMMENT 'Patron associated with request',
2776
  `borrowernumber` int(11) DEFAULT NULL COMMENT 'Patron associated with request',
2777
  `biblio_id` int(11) DEFAULT NULL COMMENT 'Potential bib linked to request',
2777
  `biblio_id` int(11) DEFAULT NULL COMMENT 'Potential bib linked to request',
2778
  `date_due` datetime DEFAULT NULL COMMENT 'Custom date due specified by backend, leave NULL for default date_due calculation',
2778
  `branchcode` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The branch associated with the request',
2779
  `branchcode` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The branch associated with the request',
2779
  `status` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Current Koha status of request',
2780
  `status` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Current Koha status of request',
2780
  `status_alias` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Foreign key to relevant authorised_values.authorised_value',
2781
  `status_alias` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Foreign key to relevant authorised_values.authorised_value',
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 lines)
Lines 260-266 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
260
('ILLModuleUnmediated','0','','If enabled, try to immediately progress newly placed ILL requests.','YesNo'),
260
('ILLModuleUnmediated','0','','If enabled, try to immediately progress newly placed ILL requests.','YesNo'),
261
('ILLOpacbackends',NULL,NULL,'ILL backends to enabled for OPAC initiated requests','multiple'),
261
('ILLOpacbackends',NULL,NULL,'ILL backends to enabled for OPAC initiated requests','multiple'),
262
('ILLSendStaffNotices', NULL, NULL, 'Send these ILL notices to staff', 'multiple'),
262
('ILLSendStaffNotices', NULL, NULL, 'Send these ILL notices to staff', 'multiple'),
263
('ILLUseExactDueDate',NULL,NULL,'Use this ILL request attribute to set a specific due date when a document on ILL loan is issued.','multiple'),
264
('ILS-DI','0','','Enables ILS-DI services at OPAC.','YesNo'),
263
('ILS-DI','0','','Enables ILS-DI services at OPAC.','YesNo'),
265
('ILS-DI:AuthorizedIPs','','Restricts usage of ILS-DI to some IPs','.','Free'),
264
('ILS-DI:AuthorizedIPs','','Restricts usage of ILS-DI to some IPs','.','Free'),
266
('ImageLimit','5','','Limit images stored in the database by the Patron Card image manager to this number.','Integer'),
265
('ImageLimit','5','','Limit images stored in the database by the Patron Card image manager to this number.','Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-4 lines)
Lines 940-949 Circulation: Link Here
940
                  1: Enable
940
                  1: Enable
941
                  0: Disable
941
                  0: Disable
942
            - unmediated interlibrary loan requests. If enabled and the ILL backend supports it, the newly created requests are immediately requested by backend.
942
            - unmediated interlibrary loan requests. If enabled and the ILL backend supports it, the newly created requests are immediately requested by backend.
943
        -
944
            - Use the ILL request attribute
945
            - pref: ILLUseExactDueDate
946
            - to set an exact due date for an ILL loan, from the ILL module. Leave empty to calculate due dates the standard way.
947
        -
943
        -
948
            - pref: CirculateILL
944
            - pref: CirculateILL
949
              default: 0
945
              default: 0
(-)a/t/db_dependent/Circulation.t (-2 / +38 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use utf8;
19
use utf8;
20
20
21
use Test::More tests => 57;
21
use Test::More tests => 58;
22
use Test::Exception;
22
use Test::Exception;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Deep qw( cmp_deeply );
24
use Test::Deep qw( cmp_deeply );
Lines 1909-1914 subtest 'AddIssue & AllowReturnToBranch' => sub { Link Here
1909
    # TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch');
1909
    # TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch');
1910
};
1910
};
1911
1911
1912
subtest 'AddIssue & illrequests.date_due' => sub {
1913
    plan tests => 2;
1914
1915
    t::lib::Mocks::mock_preference( 'ILLModule', 1 );
1916
    my $library = $builder->build( { source => 'Branch' } );
1917
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
1918
    my $item = $builder->build_sample_item();
1919
1920
    set_userenv($library);
1921
1922
    my $custom_date_due = '9999-12-18 12:34:56';
1923
    my $expected_date_due = '9999-12-18 23:59:00';
1924
    my $illrequest = Koha::Illrequest->new({
1925
        borrowernumber => $patron->borrowernumber,
1926
        biblio_id => $item->biblionumber,
1927
        branchcode => $library->{'branchcode'},
1928
        date_due => $custom_date_due,
1929
    })->store;
1930
1931
    my $issue = AddIssue( $patron->unblessed, $item->barcode );
1932
    is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue');
1933
1934
    $patron = $builder->build_object( { class => 'Koha::Patrons' } );
1935
    $item = $builder->build_sample_item();
1936
    $custom_date_due = '9999-12-19';
1937
    $expected_date_due = '9999-12-19 23:59:00';
1938
    $illrequest = Koha::Illrequest->new({
1939
        borrowernumber => $patron->borrowernumber,
1940
        biblio_id => $item->biblionumber,
1941
        branchcode => $library->{'branchcode'},
1942
        date_due => $custom_date_due,
1943
    })->store;
1944
1945
    $issue = AddIssue( $patron->unblessed, $item->barcode );
1946
    is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue');
1947
};
1948
1912
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
1949
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
1913
    plan tests => 8;
1950
    plan tests => 8;
1914
1951
1915
- 

Return to bug 24239