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

(-)a/Koha/Patron.pm (+13 lines)
Lines 29-34 use Koha::DateUtils; Link Here
29
use Koha::Issues;
29
use Koha::Issues;
30
use Koha::OldIssues;
30
use Koha::OldIssues;
31
use Koha::Patron::Categories;
31
use Koha::Patron::Categories;
32
use Koha::Patron::HouseboundProfiles;
32
use Koha::Patron::Images;
33
use Koha::Patron::Images;
33
use Koha::Patrons;
34
use Koha::Patrons;
34
35
Lines 76-81 sub guarantees { Link Here
76
    return Koha::Patrons->search( { guarantorid => $self->borrowernumber } );
77
    return Koha::Patrons->search( { guarantorid => $self->borrowernumber } );
77
}
78
}
78
79
80
=head3 housebound_profile
81
82
Returns the HouseboundProfile associated with this patron.
83
84
=cut
85
86
sub housebound_profile {
87
    my ( $self ) = @_;
88
89
    return Koha::Patron::HouseboundProfiles->find($self->borrowernumber);
90
}
91
79
=head3 siblings
92
=head3 siblings
80
93
81
Returns the siblings of this patron.
94
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
        ->special_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 (+83 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 chooser
43
44
  my $chooser = Koha::Patron::HouseboundVisit->chooser;
45
46
Returns the prefetched chooser for this visit.
47
48
=cut
49
50
sub chooser {
51
    my ( $self ) = @_;
52
    return $self->_result->chooser_brwnumber;
53
}
54
55
=head3 deliverer
56
57
  my $deliverer = Koha::Patron::HouseboundVisit->deliverer;
58
59
Returns the prefetched deliverer for this visit.
60
61
=cut
62
63
sub deliverer {
64
    my ( $self ) = @_;
65
    return $self->_result->deliverer_brwnumber;
66
67
}
68
69
=head3 _type
70
71
=cut
72
73
sub _type {
74
    return 'HouseboundVisit';
75
}
76
77
1;
78
79
=head1 AUTHOR
80
81
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
82
83
=cut
(-)a/Koha/Patron/HouseboundVisits.pm (+102 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 special_search;
44
45
   my @houseboundVisits = Koha::HouseboundVisits->special_search($params, $attributes);
46
47
Perform a search for housebound visits.  This method overrides standard search
48
to prefetch deliverers and choosers as we always need them anyway.
49
50
If $attributes contains a prefetch entry, we defer to it, otherwise we add the
51
prefetch attribute and also augment $params with explicit 'me.' prefixes.
52
53
This is intended to make search behave as most people would expect it to
54
behave.
55
56
Should the user want to do complicated searches involving joins, without
57
specifying their own prefetch, the naive 'me.' augmentation will break in
58
hilarious ways.  In this case the user should supply their own prefetch
59
clause.
60
61
=cut
62
63
sub special_search {
64
    my ( $self, $params, $attributes ) = @_;
65
    unless (exists $attributes->{prefetch}) {
66
        # No explicit prefetch has been passed in -> automatic optimisation.
67
        $attributes->{prefetch} = [
68
            'chooser_brwnumber', 'deliverer_brwnumber'
69
        ];
70
        # So we must ensure our $params use the 'me.' prefix.
71
        my $oldparams = $params;
72
        $params = {};
73
        while (my ($k, $v) = each %{$oldparams}) {
74
            if ($k =~ /^me\..*/) {
75
                $params->{$k} = $v;
76
            } else {
77
                $params->{"me." . $k} = $v;
78
            }
79
        }
80
    }
81
    $self->SUPER::search($params, $attributes);
82
}
83
84
=head3 _type
85
86
=cut
87
88
sub _type {
89
    return 'HouseboundVisit';
90
}
91
92
sub object_class {
93
    return 'Koha::Patron::HouseboundVisit';
94
}
95
96
1;
97
98
=head1 AUTHOR
99
100
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
101
102
=cut
(-)a/Koha/Patrons.pm (+32 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
        })->search_related('borrowernumber');
53
    return Koha::Patrons->_new_from_dbic($cho);
54
}
55
56
=head3 housebound_deliverers
57
58
Returns all Patrons which are Housebound deliverers.
59
60
=cut
61
62
sub housebound_deliverers {
63
    my ( $self ) = @_;
64
    my $del = $self->_resultset->search
65
        ->search_related('borrower_attributes', {
66
            code => 'HSBND',
67
            attribute => 'DEL',
68
        })->search_related('borrowernumber');
69
    return Koha::Patrons->_new_from_dbic($del);
70
}
71
40
=head3 type
72
=head3 type
41
73
42
=cut
74
=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 IGNORE INTO systempreferences
40
       (variable,value,options,explanation,type) VALUES
41
       ('HouseboundModule',0,'',
42
       'If ON, enable housebound module functionality.','YesNo');
43
44
INSERT IGNORE 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 IGNORE 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/en/mandatory/auth_values.sql (+4 lines)
Lines 1-2 Link Here
1
INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','0','No','No');
1
INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','0','No','No');
2
INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','1','Yes','Yes');
2
INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','1','Yes','Yes');
3
INSERT INTO authorised_values (category, authorised_value, lib) VALUES
4
       ('HSBND_FREQ','EW','Every week'),
5
       ('HSBND_ROLE','CHO','Chooser'),
6
       ('HSBND_ROLE','DEL','Deliverer');
(-)a/installer/data/mysql/en/mandatory/patron_attributes.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO borrower_attribute_types
2
       (code, description, repeatable, opac_display, staff_searchable,
3
       authorised_value_category, display_checkout) values
4
       ('HSBND', 'Housebound role', 1, 1, 1, 'HSBND_ROLE', 1);
(-)a/installer/data/mysql/en/mandatory/patron_attributes.txt (+2 lines)
Line 0 Link Here
1
Default Koha system extended patron attributes:
2
* HSBND - Allow assignment of different housebound roles for volunteers
(-)a/installer/data/mysql/kohastructure.sql (+48 lines)
Lines 3810-3815 CREATE TABLE `hold_fill_targets` ( Link Here
3810
    REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3810
    REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3811
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3811
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3812
3812
3813
--
3814
-- Table structure for table `housebound_profile`
3815
--
3816
3817
DROP TABLE IF EXISTS `housebound_profile`;
3818
CREATE TABLE `housebound_profile` (
3819
  `borrowernumber` int(11) NOT NULL, -- Number of the borrower associated with this profile.
3820
  `day` text NOT NULL,  -- The preferred day of the week for delivery.
3821
  `frequency` text NOT NULL, -- The Authorised_Value definining the pattern for delivery.
3822
  `fav_itemtypes` text default NULL, -- Free text describing preferred itemtypes.
3823
  `fav_subjects` text default NULL, -- Free text describing preferred subjects.
3824
  `fav_authors` text default NULL, -- Free text describing preferred authors.
3825
  `referral` text default NULL, -- Free text indicating how the borrower was added to the service.
3826
  `notes` text default NULL, -- Free text for additional notes.
3827
  PRIMARY KEY  (`borrowernumber`),
3828
  CONSTRAINT `housebound_profile_bnfk`
3829
    FOREIGN KEY (`borrowernumber`)
3830
    REFERENCES `borrowers` (`borrowernumber`)
3831
    ON UPDATE CASCADE ON DELETE CASCADE
3832
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3833
3834
--
3835
-- Table structure for table `housebound_visit`
3836
--
3837
3838
DROP TABLE IF EXISTS `housebound_visit`;
3839
CREATE TABLE `housebound_visit` (
3840
  `id` int(11) NOT NULL auto_increment, -- ID of the visit.
3841
  `borrowernumber` int(11) NOT NULL, -- Number of the borrower, & the profile, linked to this visit.
3842
  `appointment_date` date default NULL, -- Date of visit.
3843
  `day_segment` varchar(10),  -- Rough time frame: 'morning', 'afternoon' 'evening'
3844
  `chooser_brwnumber` int(11) default NULL, -- Number of the borrower to choose items  for delivery.
3845
  `deliverer_brwnumber` int(11) default NULL, -- Number of the borrower to deliver items.
3846
  PRIMARY KEY  (`id`),
3847
  CONSTRAINT `houseboundvisit_bnfk`
3848
    FOREIGN KEY (`borrowernumber`)
3849
    REFERENCES `housebound_profile` (`borrowernumber`)
3850
    ON UPDATE CASCADE ON DELETE CASCADE,
3851
  CONSTRAINT `houseboundvisit_bnfk_1`
3852
    FOREIGN KEY (`chooser_brwnumber`)
3853
    REFERENCES `borrowers` (`borrowernumber`)
3854
    ON UPDATE CASCADE ON DELETE CASCADE,
3855
  CONSTRAINT `houseboundvisit_bnfk_2`
3856
    FOREIGN KEY (`deliverer_brwnumber`)
3857
    REFERENCES `borrowers` (`borrowernumber`)
3858
    ON UPDATE CASCADE ON DELETE CASCADE
3859
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3860
3813
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3861
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
3814
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3862
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3815
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
3863
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 172-177 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
172
('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
('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'),
173
('HoldsToPullStartDate','2',NULL,'Set the default start date for the Holds to pull list to this many days ago','Integer'),
173
('HoldsToPullStartDate','2',NULL,'Set the default start date for the Holds to pull list to this many days ago','Integer'),
174
('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
('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'),
175
('HouseboundModule',0,'','If ON, enable housebound module functionality.','YesNo'),
175
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
176
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
176
('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'),
177
('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'),
177
('HTML5MediaYouTube',0,'Embed|Don\'t embed','YouTube links as videos','YesNo'),
178
('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 %]">Discharges</a></li>
106
        [% IF dischargeview %]<li class="active">[% ELSE %]<li>[% END %]<a href="/cgi-bin/koha/members/discharge.pl?borrowernumber=[% borrowernumber %]">Discharges</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 769-771 Circulation: Link Here
769
            - "Patron categories allowed to checkout in a batch"
769
            - "Patron categories allowed to checkout in a batch"
770
            - pref: BatchCheckoutsValidCategories
770
            - pref: BatchCheckoutsValidCategories
771
            - "(list of patron categories separated with a pipe '|')"
771
            - "(list of patron categories separated with a pipe '|')"
772
    Housebound module:
773
        -
774
            - pref: HouseboundModule
775
              choices:
776
                  yes: Enable
777
                  no: Disable
778
            - "housebound module"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt (+434 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 == 'any' ) %]
71
                            <option value="any" selected='selected'>Any</option>
72
                          [% ELSE %]
73
                            <option value="any">Any</option>
74
                          [% END %]
75
                          [% IF ( housebound_profile.day == 'monday' ) %]
76
                            <option value="monday" selected='selected'>Monday</option>
77
                          [% ELSE %]
78
                            <option value="monday">Monday</option>
79
                          [% END %]
80
                          [% IF ( housebound_profile.day == 'tuesday' ) %]
81
                            <option value="tuesday" selected='selected'>Tuesday</option>
82
                          [% ELSE %]
83
                            <option value="tuesday">Tuesday</option>
84
                          [% END %]
85
                          [% IF ( housebound_profile.day == 'wednesday' ) %]
86
                            <option value="wednesday" selected='selected'>Wednesday</option>
87
                          [% ELSE %]
88
                            <option value="wednesday">Wednesday</option>
89
                          [% END %]
90
                          [% IF ( housebound_profile.day == 'thursday' ) %]
91
                            <option value="thursday" selected='selected'>Thursday</option>
92
                          [% ELSE %]
93
                            <option value="thursday">Thursday</option>
94
                          [% END %]
95
                          [% IF ( housebound_profile.day == 'friday' ) %]
96
                            <option value="friday" selected='selected'>Friday</option>
97
                          [% ELSE %]
98
                            <option value="friday">Friday</option>
99
                          [% END %]
100
                          [% IF ( housebound_profile.day == 'saturday' ) %]
101
                            <option value="saturday" selected='selected'>Saturday</option>
102
                          [% ELSE %]
103
                            <option value="saturday">Saturday</option>
104
                          [% END %]
105
                          [% IF ( housebound_profile.day == 'sunday' ) %]
106
                            <option value="sunday" selected='selected'>Sunday</option>
107
                          [% ELSE %]
108
                            <option value="sunday">Sunday</option>
109
                          [% END %]
110
                        [% ELSE %]
111
                          <option value="any">Any</option>
112
                          <option value="monday">Monday</option>
113
                          <option value="tuesday">Tuesday</option>
114
                          <option value="wednesday">Wednesday</option>
115
                          <option value="thursday">Thursday</option>
116
                          <option value="friday">Friday</option>
117
                          <option value="saturday">Saturday</option>
118
                          <option value="sunday">Sunday</option>
119
                        [% END %]
120
                      </select>
121
                    </li>
122
                    <li>
123
                      <label for="frequency">Frequency:</label>
124
                      <select id="frequency" name="frequency" required="required">
125
                        <option value="">Select a frequency</option>
126
                        [% FOREACH frequency IN AuthorisedValues.GetAuthValueDropbox('HSBND_FREQ') %]
127
                          [% IF housebound_profile.frequency == frequency.value %]
128
                            <option value="[% frequency.value %]" selected="selected">[% frequency.label %]</option>
129
                          [% ELSE %]
130
                            <option value="[% frequency.value %]">[% frequency.label %]</option>
131
                          [% END %]
132
                        [% END %]
133
                      </select>
134
                    </li>
135
                    <li>
136
                      <label for="fav_itemtypes">Preferred materials:</label>
137
                      [% IF ( housebound_profile ) %]
138
                        <input id="fav_itemtypes" type="text" size="50" name="fav_itemtypes"
139
                               value="[% housebound_profile.fav_itemtypes %]">
140
                      [% ELSE %]
141
                        <input id="fav_itemtypes" type="text" value="" size="50" name="fav_itemtypes">
142
                      [% END %]
143
                    </li>
144
                    <li>
145
                      <label for="fav_subjects">Subjects:</label>
146
                      [% IF ( housebound_profile ) %]
147
                        <input id="fav_subjects" type="text" size="50" name="fav_subjects"
148
                               value="[% housebound_profile.fav_subjects %]">
149
                      [% ELSE %]
150
                        <input id="fav_subjects" type="text" value="" size="50" name="fav_subjects">
151
                      [% END %]
152
                    </li>
153
                    <li>
154
                      <label for="fav_authors">Authors:</label>
155
                      [% IF ( housebound_profile ) %]
156
                        <input id="fav_authors" type="text" size="50" name="fav_authors"
157
                               value="[% housebound_profile.fav_authors %]">
158
                      [% ELSE %]
159
                        <input id="fav_authors" type="text" value="" size="50" name="fav_authors">
160
                      [% END %]
161
                    </li>
162
                    <li>
163
                      <label for="referral">Referral:</label>
164
                      [% IF ( housebound_profile ) %]
165
                        <input id="referral" type="text" size="50" name="referral"
166
                               value="[% housebound_profile.referral %]">
167
                      [% ELSE %]
168
                        <input id="referral" type="text" value="" size="50" name="referral">
169
                      [% END %]
170
                    </li>
171
                    <li>
172
                      <label for="notes">Notes:</label>
173
                      [% IF ( housebound_profile ) %]
174
                        <input id="notes" type="text" size="50" name="notes"
175
                               value="[% housebound_profile.notes %]">
176
                      [% ELSE %]
177
                        <input id="notes" type="text" value="" size="50" name="notes">
178
                      [% END %]
179
                    </li>
180
                  </ol>
181
                </fieldset>
182
                <fieldset class="action">
183
                  <input type="submit" value="Save changes" name="save"
184
                         onclick="console.log('Must validate form');" />
185
                  <a class="cancel"
186
                     href="/cgi-bin/koha/members/housebound.pl?borrowernumber=[% borrowernumber %]">
187
                    Cancel
188
                  </a>
189
                </fieldset>
190
              </form>
191
192
            <!-- Create or edit housebound_visit -->
193
            [% ELSIF ( method == 'visit_update_or_create' ) %]
194
              <h4>Manage housebound deliveries</h4>
195
              <form name="form" id="instance_form" method="post"
196
                    action="/cgi-bin/koha/members/housebound.pl">
197
                [% IF ( visit ) %]
198
                  <input type="hidden" name="method" value="editvisitconfirm" />
199
                  <input type="hidden" name="visit_id" value="[% visit.id %]" />
200
                [% ELSE %]
201
                  <input type="hidden" name="method" value="addvisitconfirm" />
202
                [% END %]
203
                <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
204
                <fieldset class="rows" id="instance">
205
                  <legend>Delivery details</legend>
206
                  <ol>
207
                    <li>
208
                      <label for="date">Date: </label>
209
                      [% IF ( visit ) %]
210
                        <input type="text" id="date" name="date" size="20"
211
                               value="[% visit.appointment_date %]"
212
                               required="required"/>
213
                      [% ELSE %]
214
                        <input type="text" id="date" name="date" size="20"
215
                               value="" required="required"/>
216
                      [% END %]
217
                    </li>
218
                    <li>
219
                      <label for="segment">Time:</label>
220
                      <select id="segment" name="segment" required="required">
221
                        <option value="">Select a time</option>
222
                        [% IF ( visit ) %]
223
                          [% IF ( visit.day_segment == 'morning' ) %]
224
                            <option value="morning" selected="selected">
225
                              Morning
226
                            </option>
227
                          [% ELSE %]
228
                            <option value="morning">Morning</option>
229
                          [% END %]
230
                          [% IF ( visit.day_segment == 'afternoon' ) %]
231
                            <option value="afternoon" selected="selected">
232
                              Afternoon
233
                            </option>
234
                          [% ELSE %]
235
                            <option value="afternoon">Afternoon</option>
236
                          [% END %]
237
                          [% IF ( visit.day_segment == 'evening' ) %]
238
                            <option value="evening" selected="selected">
239
                              Evening
240
                            </option>
241
                          [% ELSE %]
242
                            <option value="evening">Evening</option>
243
                          [% END %]
244
                        [% ELSE %]
245
                          <option value="morning">Morning</option>
246
                          <option value="afternoon">Afternoon</option>
247
                          <option value="evening">Evening</option>
248
                        [% END %]
249
                      </select>
250
                    </li>
251
                    <li>
252
                      <label for="chooser">Chooser:</label>
253
                      <select id="chooser" name="chooser" required="required">
254
                        <option value="">Select a chooser</option>
255
                        [% IF ( visit ) %]
256
                          [% FOREACH chooser IN choosers %]
257
                            [% IF ( visit.chooser_brwnumber == chooser.borrowernumber ) %]
258
                              <option value="[% chooser.borrowernumber %]" selected="selected">
259
                                [% INCLUDE 'patron-title.inc' borrowernumber = chooser.borrowernumber category_type = chooser.categorycode firstname = chooser.firstname surname = chooser.surname othernames = chooser.othernames cardnumber = chooser.cardnumber invert_name = 0 %]
260
                              </option>
261
                            [% ELSE %]
262
                              <option value="[% chooser.borrowernumber %]">
263
                                [% INCLUDE 'patron-title.inc' borrowernumber = chooser.borrowernumber category_type = chooser.categorycode firstname = chooser.firstname surname = chooser.surname othernames = chooser.othernames cardnumber = chooser.cardnumber invert_name = 0 %]
264
                              </option>
265
                            [% END %]
266
                          [% END %]
267
                        [% ELSE %]
268
                          [% FOREACH chooser IN choosers %]
269
                            <option value="[% chooser.borrowernumber %]">
270
                              [% INCLUDE 'patron-title.inc' borrowernumber = chooser.borrowernumber category_type = chooser.categorycode firstname = chooser.firstname surname = chooser.surname othernames = chooser.othernames cardnumber = chooser.cardnumber invert_name = 0 %]
271
                            </option>
272
                          [% END %]
273
                        [% END %]
274
                      </select>
275
                    </li>
276
                    <li>
277
                      <label for="deliverer">Deliverer:</label>
278
                      <select id="deliverer" name="deliverer" required="required">
279
                        <option value="">Select a deliverer</option>
280
                        [% IF ( visit ) %]
281
                          [% FOREACH deliverer IN deliverers %]
282
                            [% IF ( visit.deliverer_brwnumber == deliverer.borrowernumber ) %]
283
                              <option value="[% deliverer.borrowernumber %]" selected="selected">
284
                                [% INCLUDE 'patron-title.inc' borrowernumber = deliverer.borrowernumber category_type = deliverer.categorycode firstname = deliverer.firstname surname = deliverer.surname othernames = deliverer.othernames cardnumber = deliverer.cardnumber invert_name = 0 %]
285
                              </option>
286
                            [% ELSE %]
287
                              <option value="[% deliverer.borrowernumber %]">
288
                                [% INCLUDE 'patron-title.inc' borrowernumber = deliverer.borrowernumber category_type = deliverer.categorycode firstname = deliverer.firstname surname = deliverer.surname othernames = deliverer.othernames cardnumber = deliverer.cardnumber invert_name = 0 %]
289
                              </option>
290
                            [% END %]
291
                          [% END %]
292
                        [% ELSE %]
293
                          [% FOREACH deliverer IN deliverers %]
294
                            <option value="[% deliverer.borrowernumber %]">
295
                              [% INCLUDE 'patron-title.inc' borrowernumber = deliverer.borrowernumber category_type = deliverer.categorycode firstname = deliverer.firstname surname = deliverer.surname othernames = deliverer.othernames cardnumber = deliverer.cardnumber invert_name = 0 %]
296
                            </option>
297
                          [% END %]
298
                        [% END %]
299
                      </select>
300
                    </li>
301
                  </ol>
302
                </fieldset>
303
                <fieldset class="action">
304
                  <input type="submit" value="Save" name="save"
305
                         onclick="console.log('Must validate form');" />
306
                  <a class="cancel"
307
                     href="/cgi-bin/koha/members/housebound.pl?borrowernumber=[% borrowernumber %]">
308
                    Cancel
309
                  </a>
310
                </fieldset>
311
              </form>
312
313
            <!-- Display a housebound_profile -->
314
            [% ELSIF ( housebound_profile ) %]
315
              <div>
316
                <ul class="toolbar">
317
                  <li>
318
                    <span class="yui-button yui-link-button first-child">
319
                      <a href="/cgi-bin/koha/members/housebound.pl?borrowernumber=[% borrowernumber %]&method=update_or_create">
320
                        Edit
321
                      </a>
322
                    </span>
323
                  </li>
324
                </ul>
325
              </div>
326
              <div class="rows">
327
                <ol>
328
                  <li>
329
                    <span class="label">Delivery day:</span>
330
                    [% hpd = housebound_profile.day %]
331
                    [% IF hpd == 'any' %]
332
                      Any
333
                    [% ELSIF hpd == 'monday' %]
334
                      Monday
335
                    [% ELSIF hpd == 'tuesday' %]
336
                      Tuesday
337
                    [% ELSIF hpd == 'wednesday' %]
338
                      Wednesday
339
                    [% ELSIF hpd == 'thursday' %]
340
                      Thursday
341
                    [% ELSIF hpd == 'friday' %]
342
                      Friday
343
                    [% ELSIF hpd == 'saturday' %]
344
                      Saturday
345
                    [% ELSIF hpd == 'sunday' %]
346
                      Sunday
347
                    [% END %]
348
                  </li>
349
                  <li>
350
                    <span class="label">Frequency:</span>
351
                    [% AuthorisedValues.GetByCode( 'HSBND_FREQ', housebound_profile.frequency, 0 ) || housebound_profile.frequency %]
352
                  </li>
353
                  <li>
354
                    <span class="label">Material:</span>
355
                    [% housebound_profile.fav_itemtypes %]
356
                  </li>
357
                  <li>
358
                    <span class="label">Subjects:</span>
359
                    [% housebound_profile.fav_subjects %]
360
                  </li>
361
                  <li>
362
                    <span class="label">Authors:</span>
363
                    [% housebound_profile.fav_authors %]
364
                  </li>
365
                  <li>
366
                    <span class="label">Referral:</span>
367
                    [% housebound_profile.referral %]
368
                  </li>
369
                  <li>
370
                    <span class="label">Notes:</span>
371
                    [% housebound_profile.notes %]
372
                  </li>
373
                </ol>
374
              </div>
375
              <div>
376
                <h4>Deliveries</h4>
377
                <div>
378
                  <ul class="toolbar">
379
                    <li>
380
                      <span class="yui-button yui-link-button first-child">
381
                        <a href="/cgi-bin/koha/members/housebound.pl?method=visit_update_or_create&borrowernumber=[% borrowernumber %]">
382
                          Add a new delivery
383
                        </a>
384
                      </span>
385
                    </li>
386
                  </ul>
387
                </div>
388
                [% housebound_visits = housebound_profile.housebound_visits %]
389
                [% IF  housebound_visits.size > 0 %]
390
                <table border="0" width="100%" cellpadding="3" cellspacing="0">
391
                  <tr>
392
                    <th>ID</th><th>Date</th><th>Chooser</th><th>Deliverer</th><th>Actions</th>
393
                  </tr>
394
                    [% FOREACH entry IN housebound_visits %]
395
                    <tr>
396
                      <td>[% entry.id %]</td>
397
                      <td>[% entry.appointment_date %] ([% entry.day_segment %])</td>
398
                      <td>
399
                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% entry.chooser.borrowernumber %]">
400
                          [% INCLUDE 'patron-title.inc' borrowernumber = entry.chooser.borrowernumber category_type = entry.chooser.categorycode firstname = entry.chooser.firstname surname = entry.chooser.surname othernames = entry.chooser.othernames cardnumber = entry.chooser.cardnumber invert_name = 0 %]
401
                        </a>
402
                      </td>
403
                      <td>
404
                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% entry.deliverer.borrowernumber %]">
405
                          [% INCLUDE 'patron-title.inc' borrowernumber = entry.deliverer.borrowernumber category_type = entry.deliverer.categorycode firstname = entry.deliverer.firstname surname = entry.deliverer.surname othernames = entry.deliverer.othernames cardnumber = entry.deliverer.cardnumber invert_name = 0 %]
406
                        </a>
407
                      </td>
408
                      <td align="center">
409
                        <a href="/cgi-bin/koha/members/housebound.pl?method=visit_update_or_create&visit_id=[% entry.id %]&borrowernumber=[% borrowernumber %]">
410
                          Edit
411
                        </a>
412
                        |
413
                        <a href="/cgi-bin/koha/members/housebound.pl?method=visit_delete&visit_id=[% entry.id %]&borrowernumber=[% borrowernumber %]">
414
                          Delete
415
                        </a>
416
                      </td>
417
                    </tr>
418
                    [% END %]
419
                </table>
420
                [% END %]
421
              </div>
422
423
            [% END %]
424
425
          </div>  <!-- End yui-u first -->
426
        </div>    <!-- End yui-g -->
427
      </div>
428
    </div
429
  </div>
430
  <div class="yui-b">
431
    [% INCLUDE 'circ-menu.inc' %]
432
  </div>
433
</div>
434
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/members/housebound.pl (+150 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') // q{};
52
my $visit_id = $input->param('visit_id') // q{};
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')           // q{},
65
        frequency     => $input->param('frequency')     // q{},
66
        fav_itemtypes => $input->param('fav_itemtypes') // q{},
67
        fav_subjects  => $input->param('fav_subjects')  // q{},
68
        fav_authors   => $input->param('fav_authors')   // q{},
69
        referral      => $input->param('referral')      // q{},
70
        notes         => $input->param('notes')         // q{},
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')           // q{},
81
        frequency      => $input->param('frequency')     // q{},
82
        fav_itemtypes  => $input->param('fav_itemtypes') // q{},
83
        fav_subjects   => $input->param('fav_subjects')  // q{},
84
        fav_authors    => $input->param('fav_authors')   // q{},
85
        referral       => $input->param('referral')      // q{},
86
        notes          => $input->param('notes')         // q{},
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') // q{},
108
        appointment_date    => $input->param('date')           // q{},
109
        day_segment         => $input->param('segment')        // q{},
110
        chooser_brwnumber   => $input->param('chooser')        // q{},
111
        deliverer_brwnumber => $input->param('deliverer')      // q{},
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') // q{},
120
        appointment_date    => $input->param('date')           // q{},
121
        day_segment         => $input->param('segment')        // q{},
122
        chooser_brwnumber   => $input->param('chooser')        // q{},
123
        deliverer_brwnumber => $input->param('deliverer')      // q{},
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
$template->param(
133
    patron             => $patron,
134
    housebound_profile => $houseboundprofile,
135
    visit              => $houseboundvisit,
136
    branch             => $branch,
137
    category           => $category,
138
    method             => $method,
139
    choosers           => $choosers,
140
    deliverers         => $deliverers,
141
    houseboundview     => 'on',
142
);
143
144
output_html_with_http_headers $input, $cookie, $template->output;
145
146
=head1 AUTHOR
147
148
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
149
150
=cut
(-)a/t/db_dependent/Patron/Housebound.t (+75 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 => 6;
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
# Current Patron Chooser / Deliverer count
40
my $orig_del_count = Koha::Patrons->housebound_deliverers->count;
41
my $orig_cho_count = Koha::Patrons->housebound_choosers->count;
42
43
# We add one, just in case the above is 0, so we're guaranteed one of each.
44
my $patron_chooser = $builder->build({ source => 'Borrower' });
45
$builder->build({
46
    source => 'BorrowerAttribute',
47
    value  => {
48
        borrowernumber => $patron_chooser->{borrowernumber},
49
        code           => 'HSBND',
50
        attribute      => 'CHO',
51
        password       => undef,
52
    },
53
});
54
55
my $patron_deliverer = $builder->build({ source => 'Borrower' });
56
$builder->build({
57
    source => 'BorrowerAttribute',
58
    value  => {
59
        borrowernumber => $patron_deliverer->{borrowernumber},
60
        code           => 'HSBND',
61
        attribute      => 'DEL',
62
        password       => undef,
63
    },
64
});
65
66
# Test housebound_choosers
67
is(Koha::Patrons->housebound_choosers->count, $orig_cho_count + 1, "Correct count of choosers.");
68
is(Koha::Patrons->housebound_deliverers->count, $orig_del_count + 1, "Correct count of deliverers");
69
70
isa_ok(Koha::Patrons->housebound_choosers->next, "Koha::Patron");
71
isa_ok(Koha::Patrons->housebound_deliverers->next, "Koha::Patron");
72
73
$schema->storage->txn_rollback;
74
75
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 / +92 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 => 8;
21
22
use Koha::Database;
23
use Koha::Patron::HouseboundVisits;
24
use Koha::Patron::HouseboundVisit;
25
26
use t::lib::TestBuilder;
27
28
my $schema = Koha::Database->new->schema;
29
$schema->storage->txn_begin;
30
31
my $builder = t::lib::TestBuilder->new;
32
33
########### Test HouseboundVisits
34
35
my $visit = $builder->build({ source => 'HouseboundVisit' });
36
37
is(
38
    Koha::Patron::HouseboundVisits
39
          ->find($visit->{id})->id,
40
    $visit->{id},
41
    "Find created visit."
42
);
43
44
# Using our Prefetching search
45
46
# Does it work implicitly?
47
my @visits = Koha::Patron::HouseboundVisits
48
    ->special_search({ borrowernumber => $visit->{borrowernumber} });
49
my $found_visit = shift @visits;
50
is(
51
    $found_visit->borrowernumber,
52
    $visit->{borrowernumber},
53
    "Search for created visit."
54
);
55
56
# Does it work Explicitly?
57
@visits = Koha::Patron::HouseboundVisits
58
    ->special_search({ 'me.borrowernumber' => $visit->{borrowernumber} });
59
$found_visit = shift @visits;
60
is(
61
    $found_visit->borrowernumber,
62
    $visit->{borrowernumber},
63
    "Search for created visit."
64
);
65
66
# Does it work without prefetcing?
67
@visits = Koha::Patron::HouseboundVisits
68
    ->special_search({ borrowernumber => $visit->{borrowernumber} }, { prefetch => [] });
69
$found_visit = shift @visits;
70
is(
71
    $found_visit->borrowernumber,
72
    $visit->{borrowernumber},
73
    "Search for created visit."
74
);
75
76
########### Test HouseboundVisit
77
78
my $result = Koha::Patron::HouseboundVisits->find($visit->{id});
79
80
is( $result->deliverer->borrowernumber, $visit->{deliverer_brwnumber} );
81
82
is( $result->chooser->borrowernumber, $visit->{chooser_brwnumber} );
83
84
TODO: {
85
    local $TODO = "We want our results here to be Koha::Patron objects, but they by default return DBIC Schema objects.  The currently accepted solution to this (use the _from_dbic method), is defined for Koha::Objects, but not for Koha::Object.  We do not resolve this issue here";
86
    isa_ok( $result->deliverer, "Koha::Patron");
87
    isa_ok( $result->chooser, "Koha::Patron");
88
}
89
90
$schema->storage->txn_rollback;
91
92
1;

Return to bug 5670