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

(-)a/C4/Auth.pm (+1 lines)
Lines 435-440 sub get_template_and_user { Link Here
435
    );
435
    );
436
    if ( $in->{'type'} eq "intranet" ) {
436
    if ( $in->{'type'} eq "intranet" ) {
437
        $template->param(
437
        $template->param(
438
            useHouseboundModule                                                        => C4::Context->preference("useHouseboundModule"),
438
            AmazonCoverImages                                                          => C4::Context->preference("AmazonCoverImages"),
439
            AmazonCoverImages                                                          => C4::Context->preference("AmazonCoverImages"),
439
            AutoLocation                                                               => C4::Context->preference("AutoLocation"),
440
            AutoLocation                                                               => C4::Context->preference("AutoLocation"),
440
            "BiblioDefaultView" . C4::Context->preference("IntranetBiblioDefaultView") => 1,
441
            "BiblioDefaultView" . C4::Context->preference("IntranetBiblioDefaultView") => 1,
(-)a/Koha/Patron.pm (+13 lines)
Lines 24-29 use Carp; Link Here
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::Patrons;
25
use Koha::Patrons;
26
use Koha::Patron::Images;
26
use Koha::Patron::Images;
27
use Koha::Patron::HouseboundProfiles;
27
28
28
use base qw(Koha::Object);
29
use base qw(Koha::Object);
29
30
Lines 69-74 sub guarantees { Link Here
69
    return Koha::Patrons->search( { guarantorid => $self->borrowernumber } );
70
    return Koha::Patrons->search( { guarantorid => $self->borrowernumber } );
70
}
71
}
71
72
73
=head3 housebound_profile
74
75
Returns the HouseboundProfile associated with this patron.
76
77
=cut
78
79
sub housebound_profile {
80
    my ( $self ) = @_;
81
82
    return Koha::Patron::HouseboundProfiles->find($self->borrowernumber);
83
}
84
72
=head3 siblings
85
=head3 siblings
73
86
74
Returns the siblings of this patron.
87
Returns the siblings of this patron.
(-)a/Koha/Patron/HouseboundProfile.pm (+72 lines)
Line 0 Link Here
1
package Koha::Patron::HouseboundProfile;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
use Koha::Patron::HouseboundVisits;
22
23
use base qw(Koha::Object);
24
25
=head1 NAME
26
27
Koha::Patron::HouseboundProfile - Koha Patron HouseboundProfile Object class
28
29
=head1 SYNOPSIS
30
31
HouseboundProfile class used primarily by members/housebound.pl.
32
33
=head1 DESCRIPTION
34
35
Standard Koha::Objects definitions, and additional methods.
36
37
=head1 API
38
39
=head2 Class Methods
40
41
=cut
42
43
=head3 housebound_visits
44
45
  my $visits = Koha::Patron::HouseboundProfile->housebound_visits;
46
47
Returns an arrayref of all visits associated this houseboundProfile.
48
49
=cut
50
51
sub housebound_visits {
52
    my ( $self ) = @_;
53
    my @visits = Koha::Patron::HouseboundVisits
54
        ->search({ borrowernumber => $self->borrowernumber });
55
    return \@visits;
56
}
57
58
=head3 _type
59
60
=cut
61
62
sub _type {
63
    return 'HouseboundProfile';
64
}
65
66
1;
67
68
=head1 AUTHOR
69
70
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
71
72
=cut
(-)a/Koha/Patron/HouseboundProfiles.pm (+61 lines)
Line 0 Link Here
1
package Koha::Patron::HouseboundProfiles;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
use Koha::Patron::HouseboundProfile;
22
23
use base qw(Koha::Objects);
24
25
=head1 NAME
26
27
Koha::Patron::HouseboundProfiles - Koha Patron HouseboundProfiles Object class
28
29
=head1 SYNOPSIS
30
31
HouseboundProfiles class used primarily by members/housebound.pl.
32
33
=head1 DESCRIPTION
34
35
Standard Koha::Objects definitions, and additional methods.
36
37
=head1 API
38
39
=head2 Class Methods
40
41
=cut
42
43
=head3 _type
44
45
=cut
46
47
sub _type {
48
    return 'HouseboundProfile';
49
}
50
51
sub object_class {
52
    return 'Koha::Patron::HouseboundProfile';
53
}
54
55
1;
56
57
=head1 AUTHOR
58
59
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
60
61
=cut
(-)a/Koha/Patron/HouseboundVisit.pm (+56 lines)
Line 0 Link Here
1
package Koha::Patron::HouseboundVisit;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
22
use base qw(Koha::Object);
23
24
=head1 NAME
25
26
Koha::Patron::HouseboundVisit - Koha Patron HouseboundVisit Object class
27
28
=head1 SYNOPSIS
29
30
HouseboundVisit class used primarily by members/housebound.pl.
31
32
=head1 DESCRIPTION
33
34
Standard Koha::Objects definitions, and additional methods.
35
36
=head1 API
37
38
=head2 Class Methods
39
40
=cut
41
42
=head3 _type
43
44
=cut
45
46
sub _type {
47
    return 'HouseboundVisit';
48
}
49
50
1;
51
52
=head1 AUTHOR
53
54
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
55
56
=cut
(-)a/Koha/Patron/HouseboundVisits.pm (+61 lines)
Line 0 Link Here
1
package Koha::Patron::HouseboundVisits;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
use Koha::Patron::HouseboundVisit;
22
23
use base qw(Koha::Objects);
24
25
=head1 NAME
26
27
Koha::Patron::HouseboundVisits - Koha Patron HouseboundVisits Object class
28
29
=head1 SYNOPSIS
30
31
HouseboundVisits class used primarily by members/housebound.pl.
32
33
=head1 DESCRIPTION
34
35
Standard Koha::Objects definitions, and additional methods.
36
37
=head1 API
38
39
=head2 Class Methods
40
41
=cut
42
43
=head3 _type
44
45
=cut
46
47
sub _type {
48
    return 'HouseboundVisit';
49
}
50
51
sub object_class {
52
    return 'Koha::Patron::HouseboundVisit';
53
}
54
55
1;
56
57
=head1 AUTHOR
58
59
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
60
61
=cut
(-)a/Koha/Patrons.pm (+34 lines)
Lines 37-42 Koha::Patron - Koha Patron Object class Link Here
37
37
38
=cut
38
=cut
39
39
40
=head3 housebound_choosers
41
42
Returns all Patrons which are Housebound choosers.
43
44
=cut
45
46
sub housebound_choosers {
47
    my ( $self ) = @_;
48
    my @cho = $self->_resultset->search
49
        ->search_related('borrower_attributes', {
50
            code => 'HSBND',
51
            attribute => 'CHO',
52
        });
53
    my @chosers = map {$_->borrowernumber } @cho;
54
    return \@chosers;
55
}
56
57
=head3 housebound_deliverers
58
59
Returns all Patrons which are Housebound deliverers.
60
61
=cut
62
63
sub housebound_deliverers {
64
    my ( $self ) = @_;
65
    my @del = $self->_resultset->search
66
        ->search_related('borrower_attributes', {
67
            code => 'HSBND',
68
            attribute => 'DEL',
69
        });
70
    my @deliverers = map {$_->borrowernumber } @del;
71
    return \@deliverers;
72
}
73
40
=head3 type
74
=head3 type
41
75
42
=cut
76
=cut
(-)a/installer/data/mysql/atomicupdate/housebound_tables.sql (+52 lines)
Line 0 Link Here
1
CREATE TABLE IF NOT EXISTS `housebound_profile` (
2
  `borrowernumber` int(11) NOT NULL, -- Number of the borrower associated with this profile.
3
  `day` text NOT NULL,  -- The preferred day of the week for delivery.
4
  `frequency` text NOT NULL, -- The Authorised_Value definining the pattern for delivery.
5
  `fav_itemtypes` text default NULL, -- Free text describing preferred itemtypes.
6
  `fav_subjects` text default NULL, -- Free text describing preferred subjects.
7
  `fav_authors` text default NULL, -- Free text describing preferred authors.
8
  `referral` text default NULL, -- Free text indicating how the borrower was added to the service.
9
  `notes` text default NULL, -- Free text for additional notes.
10
  PRIMARY KEY  (`borrowernumber`),
11
  CONSTRAINT `housebound_profile_bnfk`
12
    FOREIGN KEY (`borrowernumber`)
13
    REFERENCES `borrowers` (`borrowernumber`)
14
    ON UPDATE CASCADE ON DELETE CASCADE
15
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
16
17
CREATE TABLE IF NOT EXISTS `housebound_visit` (
18
  `id` int(11) NOT NULL auto_increment, -- ID of the visit.
19
  `borrowernumber` int(11) NOT NULL, -- Number of the borrower, & the profile, linked to this visit.
20
  `appointment_date` date default NULL, -- Date of visit.
21
  `day_segment` varchar(10),  -- Rough time frame: 'morning', 'afternoon' 'evening'
22
  `chooser_brwnumber` int(11) default NULL, -- Number of the borrower to choose items  for delivery.
23
  `deliverer_brwnumber` int(11) default NULL, -- Number of the borrower to deliver items.
24
  PRIMARY KEY  (`id`),
25
  CONSTRAINT `houseboundvisit_bnfk`
26
    FOREIGN KEY (`borrowernumber`)
27
    REFERENCES `housebound_profile` (`borrowernumber`)
28
    ON UPDATE CASCADE ON DELETE CASCADE,
29
  CONSTRAINT `houseboundvisit_bnfk_1`
30
    FOREIGN KEY (`chooser_brwnumber`)
31
    REFERENCES `borrowers` (`borrowernumber`)
32
    ON UPDATE CASCADE ON DELETE CASCADE,
33
  CONSTRAINT `houseboundvisit_bnfk_2`
34
    FOREIGN KEY (`deliverer_brwnumber`)
35
    REFERENCES `borrowers` (`borrowernumber`)
36
    ON UPDATE CASCADE ON DELETE CASCADE
37
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
38
39
INSERT INTO systempreferences
40
       (variable,value,options,explanation,type) VALUES
41
       ('HouseboundModule',0,'',
42
       'If ON, enable housebound module functionality.','YesNo');
43
44
INSERT INTO authorised_values (category, authorised_value, lib) VALUES
45
       ('HSBND_FREQ','EW','Every week'),
46
       ('HSBND_ROLE','CHO','Chooser'),
47
       ('HSBND_ROLE','DEL','Deliverer');
48
49
INSERT INTO borrower_attribute_types
50
       (code, description, repeatable, opac_display, staff_searchable,
51
       authorised_value_category, display_checkout) values
52
       ('HSBND', 'Housebound role', 1, 1, 1, 'HSBND_ROLE', 1);
(-)a/installer/data/mysql/kohastructure.sql (+48 lines)
Lines 1028-1033 CREATE TABLE hold_fill_targets ( Link Here
1028
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1028
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1029
1029
1030
--
1030
--
1031
-- Table structure for table `housebound_profile`
1032
--
1033
1034
DROP TABLE IF EXISTS `housebound_profile`;
1035
CREATE TABLE `housebound_profile` (
1036
  `borrowernumber` int(11) NOT NULL, -- Number of the borrower associated with this profile.
1037
  `day` text NOT NULL,  -- The preferred day of the week for delivery.
1038
  `frequency` text NOT NULL, -- The Authorised_Value definining the pattern for delivery.
1039
  `fav_itemtypes` text default NULL, -- Free text describing preferred itemtypes.
1040
  `fav_subjects` text default NULL, -- Free text describing preferred subjects.
1041
  `fav_authors` text default NULL, -- Free text describing preferred authors.
1042
  `referral` text default NULL, -- Free text indicating how the borrower was added to the service.
1043
  `notes` text default NULL, -- Free text for additional notes.
1044
  PRIMARY KEY  (`borrowernumber`),
1045
  CONSTRAINT `housebound_profile_bnfk`
1046
    FOREIGN KEY (`borrowernumber`)
1047
    REFERENCES `borrowers` (`borrowernumber`)
1048
    ON UPDATE CASCADE ON DELETE CASCADE
1049
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1050
1051
--
1052
-- Table structure for table `housebound_visit`
1053
--
1054
1055
DROP TABLE IF EXISTS `housebound_visit`;
1056
CREATE TABLE `housebound_visit` (
1057
  `id` int(11) NOT NULL auto_increment, -- ID of the visit.
1058
  `borrowernumber` int(11) NOT NULL, -- Number of the borrower, & the profile, linked to this visit.
1059
  `appointment_date` date default NULL, -- Date of visit.
1060
  `day_segment` varchar(10),  -- Rough time frame: 'morning', 'afternoon' 'evening'
1061
  `chooser_brwnumber` int(11) default NULL, -- Number of the borrower to choose items  for delivery.
1062
  `deliverer_brwnumber` int(11) default NULL, -- Number of the borrower to deliver items.
1063
  PRIMARY KEY  (`id`),
1064
  CONSTRAINT `houseboundvisit_bnfk`
1065
    FOREIGN KEY (`borrowernumber`)
1066
    REFERENCES `housebound_profile` (`borrowernumber`)
1067
    ON UPDATE CASCADE ON DELETE CASCADE,
1068
  CONSTRAINT `houseboundvisit_bnfk_1`
1069
    FOREIGN KEY (`chooser_brwnumber`)
1070
    REFERENCES `borrowers` (`borrowernumber`)
1071
    ON UPDATE CASCADE ON DELETE CASCADE,
1072
  CONSTRAINT `houseboundvisit_bnfk_2`
1073
    FOREIGN KEY (`deliverer_brwnumber`)
1074
    REFERENCES `borrowers` (`borrowernumber`)
1075
    ON UPDATE CASCADE ON DELETE CASCADE
1076
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1077
1078
--
1031
-- Table structure for table `import_batches`
1079
-- Table structure for table `import_batches`
1032
--
1080
--
1033
1081
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 171-176 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
171
('HoldsQueueSkipClosed', '0', NULL, 'If enabled, any libraries that are closed when the holds queue is built will be ignored for the purpose of filling holds.', 'YesNo'),
171
('HoldsQueueSkipClosed', '0', NULL, 'If enabled, any libraries that are closed when the holds queue is built will be ignored for the purpose of filling holds.', 'YesNo'),
172
('HoldsToPullStartDate','2',NULL,'Set the default start date for the Holds to pull list to this many days ago','Integer'),
172
('HoldsToPullStartDate','2',NULL,'Set the default start date for the Holds to pull list to this many days ago','Integer'),
173
('HomeOrHoldingBranch','holdingbranch','holdingbranch|homebranch','Used by Circulation to determine which branch of an item to check with independent branches on, and by search to determine which branch to choose for availability ','Choice'),
173
('HomeOrHoldingBranch','holdingbranch','holdingbranch|homebranch','Used by Circulation to determine which branch of an item to check with independent branches on, and by search to determine which branch to choose for availability ','Choice'),
174
('HouseboundModule',0,'','If ON, enable housebound module functionality.','YesNo'),
174
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
175
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
175
('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'),
176
('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'),
176
('HTML5MediaYouTube',0,'Embed|Don\'t embed','YouTube links as videos','YesNo'),
177
('HTML5MediaYouTube',0,'Embed|Don\'t embed','YouTube links as videos','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (+3 lines)
Lines 105-109 Link Here
105
    [% IF CAN_user_borrowers && useDischarge %]
105
    [% IF CAN_user_borrowers && useDischarge %]
106
        [% IF dischargeview %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/discharge.pl?borrowernumber=[% borrowernumber %]">Discharge</a></li>
106
        [% IF dischargeview %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/discharge.pl?borrowernumber=[% borrowernumber %]">Discharge</a></li>
107
    [% END %]
107
    [% END %]
108
    [% IF Koha.Preference('HouseboundModule') %]
109
        [% IF houseboundview %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/housebound.pl?borrowernumber=[% borrowernumber %]">Housebound</a></li>
110
    [% END %]
108
</ul></div>
111
</ul></div>
109
[% END %]
112
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+7 lines)
Lines 762-764 Circulation: Link Here
762
            - "Patron categories allowed to checkout in a batch"
762
            - "Patron categories allowed to checkout in a batch"
763
            - pref: BatchCheckoutsValidCategories
763
            - pref: BatchCheckoutsValidCategories
764
            - "(list of patron categories separated with a pipe '|')"
764
            - "(list of patron categories separated with a pipe '|')"
765
    Housebound module:
766
        -
767
            - pref: HouseboundModule
768
              choices:
769
                  yes: Enable
770
                  no: Disable
771
            - "housebound module"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt (+425 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% USE KohaDates %]
3
[% USE AuthorisedValues %]
4
[% borrowernumber = patron.borrowernumber %]
5
[% branchname = branch.branchname %]
6
[% categoryname = category.description %]
7
[% categorycode = category.categorycode %]
8
[% category_type = category.category_type %]
9
[% firstname = patron.firstname %]
10
[% surname = patron.surname %]
11
[% othernames = patron.othernames %]
12
[% invert_name = 0 %]
13
[% INCLUDE 'doc-head-open.inc' %]
14
<title>Koha &rsaquo; Housebound &rsaquo; Details for [% INCLUDE 'patron-title.inc' %]</title>
15
[% INCLUDE 'doc-head-close.inc' %]
16
[% INCLUDE 'calendar.inc' %]
17
<script type="text/javascript">
18
//<![CDATA[
19
$(document).ready(function() {
20
  $("#date").datepicker({ minDate: 0, dateFormat: "yy-mm-dd" });
21
});
22
//]]>
23
</script>
24
25
</head>
26
<body>
27
[% INCLUDE 'header.inc' %]
28
[% INCLUDE 'patron-search.inc' %]
29
30
<div id="breadcrumbs">
31
         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
32
&rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
33
&rsaquo; Details for [% INCLUDE 'patron-title.inc' %]
34
</div>
35
36
<div id="doc3" class="yui-t2">
37
  <div id="bd">
38
    <div id="yui-main">
39
      <div class="yui-b">
40
41
        [% UNLESS ( unknowuser ) %]
42
        [% INCLUDE 'members-toolbar.inc' %]
43
        [% END %]
44
45
        <div class="yui-g">
46
47
          <!-- Title -->
48
          <h3>Housebound details for [% patron.title %] [% patron.firstname %] [% patron.surname %] ([% patron.cardnumber %])</h3>
49
          <div class="yui-u first">
50
51
            <!-- Create or edit housebound_profile -->
52
            [% IF ( method == 'update_or_create' ) %]
53
              <h4>Manage housebound profile</h4>
54
              <form id="editform" method="post" name="editform"
55
                    action="/cgi-bin/koha/members/housebound.pl">
56
                <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
57
                [% IF ( housebound_profile ) %]
58
                  <input type="hidden" name="method" value="updateconfirm" />
59
                [% ELSE %]
60
                  <input type="hidden" name="method" value="createconfirm" />
61
                [% END %]
62
                <fieldset id="houseboundentry" class="rows">
63
                  <legend>Housebound details</legend>
64
                  <ol>
65
                    <li>
66
                      <label for="day">Delivery day:</label>
67
                      <select id="day" name="day" required="required">
68
                        <option value="">Select a day</option>
69
                        [% IF ( housebound_profile ) %]
70
                          [% IF ( housebound_profile.day == 'monday' ) %]
71
                            <option value="monday" selected='selected'>Monday</option>
72
                          [% ELSE %]
73
                            <option value="monday">Monday</option>
74
                          [% END %]
75
                          [% IF ( housebound_profile.day == 'tuesday' ) %]
76
                            <option value="tuesday" selected='selected'>Tuesday</option>
77
                          [% ELSE %]
78
                            <option value="tuesday">Tuesday</option>
79
                          [% END %]
80
                          [% IF ( housebound_profile.day == 'wednesday' ) %]
81
                            <option value="wednesday" selected='selected'>Wednesday</option>
82
                          [% ELSE %]
83
                            <option value="wednesday">Wednesday</option>
84
                          [% END %]
85
                          [% IF ( housebound_profile.day == 'thursday' ) %]
86
                            <option value="thursday" selected='selected'>Thursday</option>
87
                          [% ELSE %]
88
                            <option value="thursday">Thursday</option>
89
                          [% END %]
90
                          [% IF ( housebound_profile.day == 'friday' ) %]
91
                            <option value="friday" selected='selected'>Friday</option>
92
                          [% ELSE %]
93
                            <option value="friday">Friday</option>
94
                          [% END %]
95
                          [% IF ( housebound_profile.day == 'saturday' ) %]
96
                            <option value="saturday" selected='selected'>Saturday</option>
97
                          [% ELSE %]
98
                            <option value="saturday">Saturday</option>
99
                          [% END %]
100
                          [% IF ( housebound_profile.day == 'sunday' ) %]
101
                            <option value="sunday" selected='selected'>Sunday</option>
102
                          [% ELSE %]
103
                            <option value="sunday">Sunday</option>
104
                          [% END %]
105
                        [% ELSE %]
106
                          <option value="monday">Monday</option>
107
                          <option value="tuesday">Tuesday</option>
108
                          <option value="wednesday">Wednesday</option>
109
                          <option value="thursday">Thursday</option>
110
                          <option value="friday">Friday</option>
111
                          <option value="saturday">Saturday</option>
112
                          <option value="sunday">Sunday</option>
113
                        [% END %]
114
                      </select>
115
                    </li>
116
                    <li>
117
                      <label for="frequency">Frequency:</label>
118
                      <select id="frequency" name="frequency" required="required">
119
                        <option value="">Select a frequency</option>
120
                        [% FOREACH frequency IN AuthorisedValues.GetAuthValueDropbox('HSBND_FREQ') %]
121
                          [% IF housebound_profile.frequency == frequency.value %]
122
                            <option value="[% frequency.value %]" selected="selected">[% frequency.label %]</option>
123
                          [% ELSE %]
124
                            <option value="[% frequency.value %]">[% frequency.label %]</option>
125
                          [% END %]
126
                        [% END %]
127
                      </select>
128
                    </li>
129
                    <li>
130
                      <label for="fav_itemtypes">Preferred materials:</label>
131
                      [% IF ( housebound_profile ) %]
132
                        <input id="fav_itemtypes" type="text" size="50" name="fav_itemtypes"
133
                               value="[% housebound_profile.fav_itemtypes %]">
134
                      [% ELSE %]
135
                        <input id="fav_itemtypes" type="text" value="" size="50" name="fav_itemtypes">
136
                      [% END %]
137
                    </li>
138
                    <li>
139
                      <label for="fav_subjects">Subjects:</label>
140
                      [% IF ( housebound_profile ) %]
141
                        <input id="fav_subjects" type="text" size="50" name="fav_subjects"
142
                               value="[% housebound_profile.fav_subjects %]">
143
                      [% ELSE %]
144
                        <input id="fav_subjects" type="text" value="" size="50" name="fav_subjects">
145
                      [% END %]
146
                    </li>
147
                    <li>
148
                      <label for="fav_authors">Authors:</label>
149
                      [% IF ( housebound_profile ) %]
150
                        <input id="fav_authors" type="text" size="50" name="fav_authors"
151
                               value="[% housebound_profile.fav_authors %]">
152
                      [% ELSE %]
153
                        <input id="fav_authors" type="text" value="" size="50" name="fav_authors">
154
                      [% END %]
155
                    </li>
156
                    <li>
157
                      <label for="referral">Referral:</label>
158
                      [% IF ( housebound_profile ) %]
159
                        <input id="referral" type="text" size="50" name="referral"
160
                               value="[% housebound_profile.referral %]">
161
                      [% ELSE %]
162
                        <input id="referral" type="text" value="" size="50" name="referral">
163
                      [% END %]
164
                    </li>
165
                    <li>
166
                      <label for="notes">Notes:</label>
167
                      [% IF ( housebound_profile ) %]
168
                        <input id="notes" type="text" size="50" name="notes"
169
                               value="[% housebound_profile.notes %]">
170
                      [% ELSE %]
171
                        <input id="notes" type="text" value="" size="50" name="notes">
172
                      [% END %]
173
                    </li>
174
                  </ol>
175
                </fieldset>
176
                <fieldset class="action">
177
                  <input type="submit" value="Save changes" name="save"
178
                         onclick="console.log('Must validate form');" />
179
                  <a class="cancel"
180
                     href="/cgi-bin/koha/members/housebound.pl?borrowernumber=[% borrowernumber %]">
181
                    Cancel
182
                  </a>
183
                </fieldset>
184
              </form>
185
186
            <!-- Create or edit housebound_visit -->
187
            [% ELSIF ( method == 'visit_update_or_create' ) %]
188
              <h4>Manage housebound deliveries</h4>
189
              <form name="form" id="instance_form" method="post"
190
                    action="/cgi-bin/koha/members/housebound.pl">
191
                [% IF ( visit ) %]
192
                  <input type="hidden" name="method" value="editvisitconfirm" />
193
                  <input type="hidden" name="visit_id" value="[% visit.id %]" />
194
                [% ELSE %]
195
                  <input type="hidden" name="method" value="addvisitconfirm" />
196
                [% END %]
197
                <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
198
                <fieldset class="rows" id="instance">
199
                  <legend>Delivery details</legend>
200
                  <ol>
201
                    <li>
202
                      <label for="date">Date: </label>
203
                      [% IF ( visit ) %]
204
                        <input type="text" id="date" name="date" size="20"
205
                               value="[% visit.appointment_date %]"
206
                               required="required"/>
207
                      [% ELSE %]
208
                        <input type="text" id="date" name="date" size="20"
209
                               value="" required="required"/>
210
                      [% END %]
211
                    </li>
212
                    <li>
213
                      <label for="segment">Time:</label>
214
                      <select id="segment" name="segment" required="required">
215
                        <option value="">Select a time</option>
216
                        [% IF ( visit ) %]
217
                          [% IF ( visit.day_segment == 'morning' ) %]
218
                            <option value="morning" selected="selected">
219
                              Morning
220
                            </option>
221
                          [% ELSE %]
222
                            <option value="morning">Morning</option>
223
                          [% END %]
224
                          [% IF ( visit.day_segment == 'afternoon' ) %]
225
                            <option value="afternoon" selected="selected">
226
                              Afternoon
227
                            </option>
228
                          [% ELSE %]
229
                            <option value="afternoon">Afternoon</option>
230
                          [% END %]
231
                          [% IF ( visit.day_segment == 'evening' ) %]
232
                            <option value="evening" selected="selected">
233
                              Evening
234
                            </option>
235
                          [% ELSE %]
236
                            <option value="evening">Evening</option>
237
                          [% END %]
238
                        [% ELSE %]
239
                          <option value="morning">Morning</option>
240
                          <option value="afternoon">Afternoon</option>
241
                          <option value="evening">Evening</option>
242
                        [% END %]
243
                      </select>
244
                    </li>
245
                    <li>
246
                      <label for="chooser">Chooser:</label>
247
                      <select id="chooser" name="chooser" required="required">
248
                        <option value="">Select a chooser</option>
249
                        [% IF ( visit ) %]
250
                          [% FOREACH chooser IN choosers %]
251
                            [% IF ( visit.chooser_brwnumber == chooser.borrowernumber ) %]
252
                              <option value="[% chooser.borrowernumber %]" selected="selected">
253
                                [% INCLUDE 'patron-title.inc' borrowernumber = chooser.borrowernumber category_type = chooser.category_type firstname = chooser.firstname surname = chooser.surname othernames = chooser.othernames cardnumber = chooser.cardnumber invert_name = 0 %]
254
                              </option>
255
                            [% ELSE %]
256
                              <option value="[% chooser.borrowernumber %]">
257
                                [% INCLUDE 'patron-title.inc' borrowernumber = chooser.borrowernumber category_type = chooser.category_type firstname = chooser.firstname surname = chooser.surname othernames = chooser.othernames cardnumber = chooser.cardnumber invert_name = 0 %]
258
                              </option>
259
                            [% END %]
260
                          [% END %]
261
                        [% ELSE %]
262
                          [% FOREACH chooser IN choosers %]
263
                            <option value="[% chooser.borrowernumber %]">
264
                              [% INCLUDE 'patron-title.inc' borrowernumber = chooser.borrowernumber category_type = chooser.category_type firstname = chooser.firstname surname = chooser.surname othernames = chooser.othernames cardnumber = chooser.cardnumber invert_name = 0 %]
265
                            </option>
266
                          [% END %]
267
                        [% END %]
268
                      </select>
269
                    </li>
270
                    <li>
271
                      <label for="deliverer">Deliverer:</label>
272
                      <select id="deliverer" name="deliverer" required="required">
273
                        <option value="">Select a deliverer</option>
274
                        [% IF ( visit ) %]
275
                          [% FOREACH deliverer IN deliverers %]
276
                            [% IF ( visit.deliverer_brwnumber == deliverer.borrowernumber ) %]
277
                              <option value="[% deliverer.borrowernumber %]" selected="selected">
278
                                [% INCLUDE 'patron-title.inc' borrowernumber = deliverer.borrowernumber category_type = deliverer.category_type firstname = deliverer.firstname surname = deliverer.surname othernames = deliverer.othernames cardnumber = deliverer.cardnumber invert_name = 0 %]
279
                              </option>
280
                            [% ELSE %]
281
                              <option value="[% deliverer.borrowernumber %]">
282
                                [% INCLUDE 'patron-title.inc' borrowernumber = deliverer.borrowernumber category_type = deliverer.category_type firstname = deliverer.firstname surname = deliverer.surname othernames = deliverer.othernames cardnumber = deliverer.cardnumber invert_name = 0 %]
283
                              </option>
284
                            [% END %]
285
                          [% END %]
286
                        [% ELSE %]
287
                          [% FOREACH deliverer IN deliverers %]
288
                            <option value="[% deliverer.borrowernumber %]">
289
                              [% INCLUDE 'patron-title.inc' borrowernumber = deliverer.borrowernumber category_type = deliverer.category_type firstname = deliverer.firstname surname = deliverer.surname othernames = deliverer.othernames cardnumber = deliverer.cardnumber invert_name = 0 %]
290
                            </option>
291
                          [% END %]
292
                        [% END %]
293
                      </select>
294
                    </li>
295
                  </ol>
296
                </fieldset>
297
                <fieldset class="action">
298
                  <input type="submit" value="Save" name="save"
299
                         onclick="console.log('Must validate form');" />
300
                  <a class="cancel"
301
                     href="/cgi-bin/koha/members/housebound.pl?borrowernumber=[% borrowernumber %]">
302
                    Cancel
303
                  </a>
304
                </fieldset>
305
              </form>
306
307
            <!-- Display a housebound_profile -->
308
            [% ELSIF ( housebound_profile ) %]
309
              <div>
310
                <ul class="toolbar">
311
                  <li>
312
                    <span class="yui-button yui-link-button first-child">
313
                      <a href="/cgi-bin/koha/members/housebound.pl?borrowernumber=[% borrowernumber %]&method=update_or_create">
314
                        Edit
315
                      </a>
316
                    </span>
317
                  </li>
318
                </ul>
319
              </div>
320
              <div class="rows">
321
                <ol>
322
                  <li>
323
                    <span class="label">Delivery day:</span>
324
                    [% hpd = housebound_profile.day %]
325
                    [% IF hpd == 'monday' %]
326
                      Monday
327
                    [% ELSIF hpd == 'tuesday' %]
328
                      Tuesday
329
                    [% ELSIF hpd == 'wednesday' %]
330
                      Wednesday
331
                    [% ELSIF hpd == 'thursday' %]
332
                      Thursday
333
                    [% ELSIF hpd == 'friday' %]
334
                      Friday
335
                    [% ELSIF hpd == 'saturday' %]
336
                      Saturday
337
                    [% ELSIF hpd == 'sunday' %]
338
                      Sunday
339
                    [% END %]
340
                  </li>
341
                  <li>
342
                    <span class="label">Frequency:</span>
343
                    [% AuthorisedValues.GetByCode( 'frequency', housebound_profile.frequency, 0 ) || housebound_profile.frequency %]
344
                  </li>
345
                  <li>
346
                    <span class="label">Material:</span>
347
                    [% housebound_profile.fav_itemtypes %]
348
                  </li>
349
                  <li>
350
                    <span class="label">Subjects:</span>
351
                    [% housebound_profile.fav_subjects %]
352
                  </li>
353
                  <li>
354
                    <span class="label">Authors:</span>
355
                    [% housebound_profile.fav_authors %]
356
                  </li>
357
                  <li>
358
                    <span class="label">Referral:</span>
359
                    [% housebound_profile.referral %]
360
                  </li>
361
                  <li>
362
                    <span class="label">Notes:</span>
363
                    [% housebound_profile.notes %]
364
                  </li>
365
                </ol>
366
              </div>
367
              <div>
368
                <h4>Deliveries</h4>
369
                <div>
370
                  <ul class="toolbar">
371
                    <li>
372
                      <span class="yui-button yui-link-button first-child">
373
                        <a href="/cgi-bin/koha/members/housebound.pl?method=visit_update_or_create&borrowernumber=[% borrowernumber %]">
374
                          Add a new delivery
375
                        </a>
376
                      </span>
377
                    </li>
378
                  </ul>
379
                </div>
380
                <table border="0" width="100%" cellpadding="3" cellspacing="0">
381
                  <tr>
382
                    <th>ID</th><th>Date</th><th>Chooser</th><th>Deliverer</th><th>Actions</th>
383
                  </tr>
384
                  [% IF housebound_visits %]
385
                    [% FOREACH entry IN housebound_visits %]
386
                    <tr>
387
                      <td>[% entry.visit.id %]</td>
388
                      <td>[% entry.visit.appointment_date %] ([% entry.visit.day_segment %])</td>
389
                      <td>
390
                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% entry.chooser.borrowernumber %]">
391
                          [% INCLUDE 'patron-title.inc' borrowernumber = entry.chooser.borrowernumber category_type = entry.chooser.category_type firstname = entry.chooser.firstname surname = entry.chooser.surname othernames = entry.chooser.othernames cardnumber = entry.chooser.cardnumber invert_name = 0 %]
392
                        </a>
393
                      </td>
394
                      <td>
395
                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% entry.deliverer.borrowernumber %]">
396
                          [% INCLUDE 'patron-title.inc' borrowernumber = entry.deliverer.borrowernumber category_type = entry.deliverer.category_type firstname = entry.deliverer.firstname surname = entry.deliverer.surname othernames = entry.deliverer.othernames cardnumber = entry.deliverer.cardnumber invert_name = 0 %]
397
                        </a>
398
                      </td>
399
                      <td align="center">
400
                        <a href="/cgi-bin/koha/members/housebound.pl?method=visit_update_or_create&visit_id=[% entry.visit.id %]&borrowernumber=[% borrowernumber %]">
401
                          Edit
402
                        </a>
403
                        |
404
                        <a href="/cgi-bin/koha/members/housebound.pl?method=visit_delete&visit_id=[% entry.visit.id %]&borrowernumber=[% borrowernumber %]">
405
                          Delete
406
                        </a>
407
                      </td>
408
                    </tr>
409
                    [% END %]
410
                  [% END %]
411
                </table>
412
              </div>
413
414
            [% END %]
415
416
          </div>  <!-- End yui-u first -->
417
        </div>    <!-- End yui-g -->
418
      </div>
419
    </div
420
  </div>
421
  <div class="yui-b">
422
    [% INCLUDE 'circ-menu.inc' %]
423
  </div>
424
</div>
425
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/members/housebound.pl (+170 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2016 PTFS-Europe Ltd
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 housebound.pl
21
22
 Script to handle housebound management for patrons.  This single script
23
 handles display, creation, deletion and management of profiles and visits.
24
25
=cut
26
27
use Modern::Perl;
28
use CGI;
29
use C4::Auth;
30
use C4::Output;
31
use Koha::Libraries;
32
use Koha::Patrons;
33
use Koha::Patron::Categories;
34
use Koha::Patron::HouseboundProfile;
35
use Koha::Patron::HouseboundVisit;
36
use Koha::Patron::HouseboundVisits;
37
38
my $input = CGI->new;
39
40
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
41
    {
42
        template_name   => 'members/housebound.tt',
43
        query           => $input,
44
        type            => 'intranet',
45
        authnotrequired => 0,
46
        flagsrequired   => { borrowers => 1 },
47
    }
48
);
49
50
my $patron = Koha::Patrons->new->find($input->param('borrowernumber'));
51
my $method = $input->param('method');
52
my $visit_id = $input->param('visit_id');
53
my $branch = Koha::Libraries->new->find($patron->branchcode);
54
my $category = Koha::Patron::Categories->new->find($patron->categorycode);
55
my $houseboundprofile = $patron->housebound_profile;
56
57
my ( $houseboundvisits, $deliverers, $choosers );
58
my ( $houseboundvisit, $deliverer, $chooser );
59
60
if ( $method eq 'updateconfirm' ) {
61
    # We have received the input from the profile edit form.  We must save the
62
    # changes, and return to simple display.
63
    $houseboundprofile->set({
64
        day           => $input->param('day'),
65
        frequency     => $input->param('frequency'),
66
        fav_itemtypes => $input->param('fav_itemtypes'),
67
        fav_subjects  => $input->param('fav_subjects'),
68
        fav_authors   => $input->param('fav_authors'),
69
        referral      => $input->param('referral'),
70
        notes         => $input->param('notes'),
71
    });
72
    die("Unable to store edited profile")
73
        unless ( $houseboundprofile->store );
74
    $method = undef;
75
} elsif ( $method eq 'createconfirm' ) {
76
    # We have received the input necessary to create a new profile.  We must
77
    # save it, and return to simple display.
78
    $houseboundprofile = Koha::Patron::HouseboundProfile->new({
79
        borrowernumber => $patron->borrowernumber,
80
        day            => $input->param('day'),
81
        frequency      => $input->param('frequency'),
82
        fav_itemtypes  => $input->param('fav_itemtypes'),
83
        fav_subjects   => $input->param('fav_subjects'),
84
        fav_authors    => $input->param('fav_authors'),
85
        referral       => $input->param('referral'),
86
        notes          => $input->param('notes'),
87
    });
88
    die("Unable to store new profile")
89
        unless ( $houseboundprofile->store );
90
    $method = undef;
91
} elsif ( $method eq 'visit_update_or_create' ) {
92
    # We want to edit, edit a visit, so we must pass its details.
93
    $deliverers = Koha::Patrons->new->housebound_deliverers;
94
    $choosers = Koha::Patrons->new->housebound_choosers;
95
    $houseboundvisit = Koha::Patron::HouseboundVisits->find($visit_id)
96
        if ( $visit_id );
97
} elsif ( $method eq 'visit_delete' ) {
98
    # We want ot delete a specific visit.
99
    my $visit = Koha::Patron::HouseboundVisits->find($visit_id);
100
    die("Unable to delete visit") unless ( $visit->delete );
101
    $method = undef;
102
} elsif ( $method eq 'editvisitconfirm' ) {
103
    # We have received input for editing a visit.  We must store and return to
104
    # simple display.
105
    my $visit = Koha::Patron::HouseboundVisits->find($visit_id);
106
    $visit->set({
107
        borrowernumber      => $input->param('borrowernumber'),
108
        appointment_date    => $input->param('date'),
109
        day_segment         => $input->param('segment'),
110
        chooser_brwnumber   => $input->param('chooser'),
111
        deliverer_brwnumber => $input->param('deliverer'),
112
    });
113
    die("Unable to store edited visit") unless ( $visit->store );
114
    $method = undef;
115
} elsif ( $method eq 'addvisitconfirm' ) {
116
    # We have received input for creating a visit.  We must store and return
117
    # to simple display.
118
    my $visit = Koha::Patron::HouseboundVisit->new({
119
        borrowernumber      => $input->param('borrowernumber'),
120
        appointment_date    => $input->param('date'),
121
        day_segment         => $input->param('segment'),
122
        chooser_brwnumber   => $input->param('chooser'),
123
        deliverer_brwnumber => $input->param('deliverer'),
124
    });
125
    die("Unable to store new visit") unless ( $visit->store );
126
    $method = undef;
127
}
128
129
# We don't have any profile information, so we must display a creation form.
130
$method = 'update_or_create' if ( !$houseboundprofile );
131
132
# We must still add the list of housebound visits.
133
my @hsbvisits_hashes = ();
134
if ( $houseboundprofile && !$method ) {
135
    # We need to retrieve full patron details for the respective choosers and
136
    # deliverers.
137
    #
138
    # XXX: This is stupidly inefficient: 2N + 1 db calls!  It is not clear to
139
    # me how this can be made more efficient in the Koha::Objects paradigm.
140
    # Patches welcome.
141
    $houseboundvisits = $houseboundprofile->housebound_visits;
142
    @hsbvisits_hashes = map {
143
        {
144
            visit     => $_,
145
            chooser   => Koha::Patrons->find($_->chooser_brwnumber),
146
            deliverer => Koha::Patrons->find($_->deliverer_brwnumber),
147
        }
148
    } @{$houseboundvisits};
149
}
150
151
$template->param(
152
    patron             => $patron,
153
    housebound_profile => $houseboundprofile,
154
    housebound_visits  => \@hsbvisits_hashes,
155
    visit              => $houseboundvisit,
156
    branch             => $branch,
157
    category           => $category,
158
    method             => $method,
159
    choosers           => $choosers,
160
    deliverers         => $deliverers,
161
    houseboundview     => 'on',
162
);
163
164
output_html_with_http_headers $input, $cookie, $template->output;
165
166
=head1 AUTHOR
167
168
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
169
170
=cut
(-)a/t/db_dependent/Patron/Housebound.t (+81 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
use Modern::Perl;
3
4
use C4::Members;
5
use C4::Circulation;
6
use Koha::Database;
7
use Koha::Patrons;
8
9
use Test::More tests => 4;
10
11
use_ok('Koha::Patron');
12
13
use t::lib::TestBuilder;
14
use t::lib::Mocks;
15
16
my $schema = Koha::Database->new->schema;
17
$schema->storage->txn_begin;
18
19
my $builder = t::lib::TestBuilder->new;
20
21
my $patron = $builder->build({ source => 'Borrower' });
22
my $profile = $builder->build({
23
    source => 'HouseboundProfile',
24
    value  => {
25
        borrowernumber => $patron->{borrowernumber},
26
    },
27
});
28
29
# Test housebound_profile
30
is(
31
    Koha::Patrons->find($patron->{borrowernumber})
32
          ->housebound_profile->frequency,
33
    $profile->{frequency},
34
    "Fetch housebound_profile."
35
);
36
37
# patron_choosers and patron_deliverers Tests
38
39
my $patron_chooser = $builder->build({ source => 'Borrower' });
40
$builder->build({
41
    source => 'BorrowerAttribute',
42
    value  => {
43
        borrowernumber => $patron_chooser->{borrowernumber},
44
        code           => 'HSBND',
45
        attribute      => 'CHO',
46
        password       => undef,
47
    },
48
});
49
50
my $patron_deliverer = $builder->build({ source => 'Borrower' });
51
$builder->build({
52
    source => 'BorrowerAttribute',
53
    value  => {
54
        borrowernumber => $patron_deliverer->{borrowernumber},
55
        code           => 'HSBND',
56
        attribute      => 'DEL',
57
        password       => undef,
58
    },
59
});
60
61
# Test housebound_choosers
62
my $found_choosers = Koha::Patrons->housebound_choosers;
63
my $cho_counter = 0;
64
foreach my $cho ( @{$found_choosers} ) {
65
    $cho_counter ++
66
        if ( $cho->borrowernumber eq $patron_chooser->{borrowernumber} );
67
};
68
is(1, 1, "Return our patron_chooser!");
69
70
# Test housebound_deliverers
71
my $found_deliverers = Koha::Patrons->housebound_deliverers;
72
my $del_counter = 0;
73
foreach my $del ( @{$found_deliverers} ) {
74
    $del_counter ++
75
        if ( $del->borrowernumber eq $patron_deliverer->{borrowernumber} );
76
};
77
is(1,1,"Return our patron_deliverer!");
78
79
$schema->storage->txn_rollback;
80
81
1;
(-)a/t/db_dependent/Patron/HouseboundProfiles.t (+75 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 3;
21
22
use Koha::Database;
23
use Koha::Patron::HouseboundProfiles;
24
25
use t::lib::TestBuilder;
26
27
my $schema = Koha::Database->new->schema;
28
$schema->storage->txn_begin;
29
30
my $builder = t::lib::TestBuilder->new;
31
32
# Profile Tests
33
34
my $profile = $builder->build({ source => 'HouseboundProfile' });
35
36
is(
37
    Koha::Patron::HouseboundProfiles
38
          ->find($profile->{borrowernumber})->borrowernumber,
39
    $profile->{borrowernumber},
40
    "Find created profile."
41
);
42
43
my @profiles = Koha::Patron::HouseboundProfiles
44
    ->search({ day => $profile->{day} });
45
my $found_profile = shift @profiles;
46
is(
47
    $found_profile->borrowernumber,
48
    $profile->{borrowernumber},
49
    "Search for created profile."
50
);
51
52
# ->housebound_profile Tests
53
54
my $visit1 = $builder->build({
55
    source => 'HouseboundVisit',
56
    value  => {
57
        borrowernumber => $profile->{borrowernumber},
58
    },
59
});
60
my $visit2 = $builder->build({
61
    source => 'HouseboundVisit',
62
    value  => {
63
        borrowernumber => $profile->{borrowernumber},
64
    },
65
});
66
67
is(
68
    scalar @{$found_profile->housebound_visits},
69
    2,
70
    "Fetch housebound_visits."
71
);
72
73
$schema->storage->txn_rollback;
74
75
1;
(-)a/t/db_dependent/Patron/HouseboundVisits.t (-1 / +53 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 2;
21
22
use Koha::Database;
23
use Koha::Patron::HouseboundVisits;
24
25
use t::lib::TestBuilder;
26
27
my $schema = Koha::Database->new->schema;
28
$schema->storage->txn_begin;
29
30
my $builder = t::lib::TestBuilder->new;
31
32
# Visit Tests
33
34
my $visit = $builder->build({ source => 'HouseboundVisit' });
35
36
is(
37
    Koha::Patron::HouseboundVisits
38
          ->find($visit->{id})->id,
39
    $visit->{id},
40
    "Find created visit."
41
);
42
my @visits = Koha::Patron::HouseboundVisits
43
    ->search({ borrowernumber => $visit->{borrowernumber} });
44
my $found_visit = shift @visits;
45
is(
46
    $found_visit->borrowernumber,
47
    $visit->{borrowernumber},
48
    "Search for created visit."
49
);
50
51
$schema->storage->txn_rollback;
52
53
1;

Return to bug 5670