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

(-)a/C4/Members/Attributes.pm (-1 / +18 lines)
Lines 32-38 BEGIN { Link Here
32
    @EXPORT_OK = qw(GetBorrowerAttributes GetBorrowerAttributeValue CheckUniqueness SetBorrowerAttributes
32
    @EXPORT_OK = qw(GetBorrowerAttributes GetBorrowerAttributeValue CheckUniqueness SetBorrowerAttributes
33
                    DeleteBorrowerAttribute UpdateBorrowerAttribute
33
                    DeleteBorrowerAttribute UpdateBorrowerAttribute
34
                    extended_attributes_code_value_arrayref extended_attributes_merge
34
                    extended_attributes_code_value_arrayref extended_attributes_merge
35
                    SearchIdMatchingAttribute);
35
                    SearchIdMatchingAttribute get_guarantor_shared_attributes);
36
    %EXPORT_TAGS = ( all => \@EXPORT_OK );
36
    %EXPORT_TAGS = ( all => \@EXPORT_OK );
37
}
37
}
38
38
Lines 365-370 sub _sort_by_code { Link Here
365
    return $x->{code} cmp $y->{code} || $x->{value} cmp $y->{value};
365
    return $x->{code} cmp $y->{code} || $x->{value} cmp $y->{value};
366
}
366
}
367
367
368
=head2 get_guarantor_shared_attributes
369
370
    $guarantor_attributes = get_guarantor_attributes();
371
372
    returns an array reference containing attributes to be shared between guarantor and guarantee.
373
374
=cut
375
376
sub get_guarantor_shared_attributes{
377
    my @attributes    = qw( streetnumber address address2 city state zipcode country branchcode phone phonepro mobile email emailpro fax );
378
    if( my @additional = split(/\|/, C4::Context->preference("AdditionalGuarantorField")) ){
379
        $_ =~ s/(?:^\s+)|(?:\s+$)//g for (@additional); # Trim whitespaces
380
        @attributes = ( @attributes, @additional);
381
    }
382
    return \@attributes;
383
}
384
368
=head1 AUTHOR
385
=head1 AUTHOR
369
386
370
Koha Development Team <http://koha-community.org/>
387
Koha Development Team <http://koha-community.org/>
(-)a/C4/Utils/DataTables/Members.pm (-7 / +25 lines)
Lines 2-7 package C4::Utils::DataTables::Members; Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use C4::Context;
4
use C4::Context;
5
use C4::Members;
6
use C4::Members::Attributes qw/get_guarantor_shared_attributes/;
5
use C4::Utils::DataTables;
7
use C4::Utils::DataTables;
6
use Koha::DateUtils;
8
use Koha::DateUtils;
7
use C4::Members::Attributes qw(SearchIdMatchingAttribute );
9
use C4::Members::Attributes qw(SearchIdMatchingAttribute );
Lines 56-68 sub search { Link Here
56
        }
58
        }
57
    }
59
    }
58
60
59
    my $select = "SELECT
61
    # If branches are independent and user is not superlibrarian
60
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname,
62
    # The search has to be only on the user branch
61
        borrowers.streetnumber, borrowers.streettype, borrowers.address,
63
    if ( C4::Context::only_my_library ) {
62
        borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
64
        my $userenv = C4::Context->userenv;
63
        borrowers.country, cardnumber, borrowers.dateexpiry,
65
        $branchcode = $userenv->{'branch'};
64
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
66
65
        borrowers.userid, borrowers.dateofbirth, borrowers.categorycode,
67
    }
68
69
    $dbh = C4::Context->dbh;
70
    my @columns = qw( borrowernumber surname firstname streetnumber streettype address address2 city state zipcode country cardnumber dateexpiry borrowernotes branchcode email userid dateofbirth categorycode phone phonepro mobile fax email emailpro);
71
    if( my @guarantor_attributes = @{ get_guarantor_shared_attributes() }){
72
        foreach my $item (@guarantor_attributes) {
73
             if (! grep {$_ eq $item} @columns) {
74
                 push @columns, $item;
75
            }
76
        }
77
    };
78
    my $borrowers_columns = "";
79
    foreach my $item (@columns) {
80
        $borrowers_columns .= "borrowers." . $item . ", ";
81
    }
82
83
    my $select = "SELECT " . $borrowers_columns . "
66
        categories.description AS category_description, categories.category_type,
84
        categories.description AS category_description, categories.category_type,
67
        branches.branchname, borrowers.phone";
85
        branches.branchname, borrowers.phone";
68
    my $from = "FROM borrowers
86
    my $from = "FROM borrowers
(-)a/Koha/Schema/Result/Category.pm (+8 lines)
Lines 109-114 __PACKAGE__->table("categories"); Link Here
109
  default_value: -1
109
  default_value: -1
110
  is_nullable: 0
110
  is_nullable: 0
111
111
112
=head2 canbeguarantee
113
114
  data_type: 'tinyint'
115
  default_value: 0
116
  is_nullable: 0
117
112
=head2 default_privacy
118
=head2 default_privacy
113
119
114
  data_type: 'enum'
120
  data_type: 'enum'
Lines 171-176 __PACKAGE__->add_columns( Link Here
171
    default_value => -1,
177
    default_value => -1,
172
    is_nullable   => 0,
178
    is_nullable   => 0,
173
  },
179
  },
180
  "canbeguarantee",
181
  { data_type => "tinyint", default_value => 0, is_nullable => 0},
174
  "default_privacy",
182
  "default_privacy",
175
  {
183
  {
176
    data_type => "enum",
184
    data_type => "enum",
(-)a/admin/categories.pl (+3 lines)
Lines 95-100 elsif ( $op eq 'add_validate' ) { Link Here
95
    my $reset_password = $input->param('reset_password');
95
    my $reset_password = $input->param('reset_password');
96
    my $change_password = $input->param('change_password');
96
    my $change_password = $input->param('change_password');
97
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
97
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
98
    my $canbeguarantee = $input->param('canbeguarantee');
98
99
99
    $reset_password = undef if $reset_password eq -1;
100
    $reset_password = undef if $reset_password eq -1;
100
    $change_password = undef if $change_password eq -1;
101
    $change_password = undef if $change_password eq -1;
Lines 124-129 elsif ( $op eq 'add_validate' ) { Link Here
124
        $category->hidelostitems($hidelostitems);
125
        $category->hidelostitems($hidelostitems);
125
        $category->overduenoticerequired($overduenoticerequired);
126
        $category->overduenoticerequired($overduenoticerequired);
126
        $category->category_type($category_type);
127
        $category->category_type($category_type);
128
        $category->canbeguarantee($canbeguarantee);
127
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
129
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
128
        $category->checkprevcheckout($checkPrevCheckout);
130
        $category->checkprevcheckout($checkPrevCheckout);
129
        $category->default_privacy($default_privacy);
131
        $category->default_privacy($default_privacy);
Lines 152-157 elsif ( $op eq 'add_validate' ) { Link Here
152
            hidelostitems => $hidelostitems,
154
            hidelostitems => $hidelostitems,
153
            overduenoticerequired => $overduenoticerequired,
155
            overduenoticerequired => $overduenoticerequired,
154
            category_type => $category_type,
156
            category_type => $category_type,
157
            canbeguarantee => $canbeguarantee,
155
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
158
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
156
            checkprevcheckout => $checkPrevCheckout,
159
            checkprevcheckout => $checkPrevCheckout,
157
            default_privacy => $default_privacy,
160
            default_privacy => $default_privacy,
(-)a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql (+11 lines)
Line 0 Link Here
1
-- ******** --
2
-- SYSPREFS --
3
-- ******** --
4
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
5
VALUES ('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free');
6
7
-- ********* --
8
-- STRUCTURE --
9
-- ********* --
10
ALTER TABLE categories ADD COLUMN `canbeguarantee` tinyint(1) NOT NULL default '0';
11
UPDATE categories SET canbeguarantee = 1 WHERE category_type = 'P' OR category_type = 'C';
(-)a/installer/data/mysql/kohastructure.sql (-1 / +2 lines)
Lines 316-325 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
316
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
316
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
317
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
317
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
318
  `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions
318
  `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions
319
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
319
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category,
320
  `checkprevcheckout` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron category if this item has previously been checked out to this patron if 'yes', not if 'no', defer to syspref setting if 'inherit'.
320
  `checkprevcheckout` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron category if this item has previously been checked out to this patron if 'yes', not if 'no', defer to syspref setting if 'inherit'.
321
  `reset_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can do the password reset flow,
321
  `reset_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can do the password reset flow,
322
  `change_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can change their passwords in the OAPC
322
  `change_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can change their passwords in the OAPC
323
  `canbeguarantee` tinyint(1) NOT NULL default '0'
323
  PRIMARY KEY  (`categorycode`),
324
  PRIMARY KEY  (`categorycode`),
324
  UNIQUE KEY `categorycode` (`categorycode`)
325
  UNIQUE KEY `categorycode` (`categorycode`)
325
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
326
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/installer/data/mysql/sysprefs.sql (-1 / +3 lines)
Lines 8-14 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
8
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
8
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
9
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
9
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
10
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
10
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
11
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
11
('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free'),
12
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
13
('AddressFormat','us','','Choose format to display postal addresses', 'Choice'),
12
('AdlibrisCoversEnabled','0',NULL,'Display cover images in OPAC results and detail listing from Swedish retailer Adlibris.','YesNo'),
14
('AdlibrisCoversEnabled','0',NULL,'Display cover images in OPAC results and detail listing from Swedish retailer Adlibris.','YesNo'),
13
('AdlibrisCoversURL','http://www.adlibris.com/se/organisationer/showimagesafe.aspx',NULL,'Base URL for Adlibris cover image web service.','Free'),
15
('AdlibrisCoversURL','http://www.adlibris.com/se/organisationer/showimagesafe.aspx',NULL,'Base URL for Adlibris cover image web service.','Free'),
14
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
16
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-us.inc (-9 / +9 lines)
Lines 8-14 Link Here
8
      <label for="streetnumber">
8
      <label for="streetnumber">
9
      [% END %]
9
      [% END %]
10
      Street number: </label>
10
      Street number: </label>
11
        <input type="text" id="streetnumber" name="streetnumber" size="5" value="[% patron.streetnumber | html %]" />
11
        <input type="text" id="streetnumber" name="streetnumber" size="5" value="[% streetnumber | html %]" />
12
[% IF ( mandatorystreetnumber ) %]<span class="required">Required</span>[% END %]
12
[% IF ( mandatorystreetnumber ) %]<span class="required">Required</span>[% END %]
13
    </li>
13
    </li>
14
        [% END %]
14
        [% END %]
Lines 24-30 Link Here
24
      <select name="streettype">
24
      <select name="streettype">
25
        <option value=""></option>
25
        <option value=""></option>
26
        [% FOR roadtype IN roadtypes %]
26
        [% FOR roadtype IN roadtypes %]
27
          [% IF roadtype.authorised_value == patron.streettype %]
27
          [% IF roadtype.authorised_value == streettype %]
28
            <option value="[% roadtype.authorised_value | html %]" selected="selected">[% roadtype.lib | html %]</option>
28
            <option value="[% roadtype.authorised_value | html %]" selected="selected">[% roadtype.lib | html %]</option>
29
          [% ELSE %]
29
          [% ELSE %]
30
            <option value="[% roadtype.authorised_value | html %]">[% roadtype.lib | html %]</option>
30
            <option value="[% roadtype.authorised_value | html %]">[% roadtype.lib | html %]</option>
Lines 43-49 Link Here
43
      <label for="address">
43
      <label for="address">
44
      [% END %]
44
      [% END %]
45
      Address: </label>
45
      Address: </label>
46
            <input type="text" id="address" name="address" size="35" value="[% patron.address | html %]" />
46
            <input type="text" id="address" name="address" size="35" value="[% address | html %]" />
47
      [% IF ( mandatoryaddress ) %]<span class="required">Required</span>[% END %]
47
      [% IF ( mandatoryaddress ) %]<span class="required">Required</span>[% END %]
48
    </li>
48
    </li>
49
        [% END %]
49
        [% END %]
Lines 55-61 Link Here
55
      <label for="address2">
55
      <label for="address2">
56
      [% END %]
56
      [% END %]
57
      Address 2: </label>
57
      Address 2: </label>
58
            <input type="text" id="address2" name="address2" size="35" value="[% patron.address2 | html %]" />
58
            <input type="text" id="address2" name="address2" size="35" value="[% address2 | html %]" />
59
      [% IF ( mandatoryaddress2 ) %]<span class="required">Required</span>[% END %]
59
      [% IF ( mandatoryaddress2 ) %]<span class="required">Required</span>[% END %]
60
    </li>
60
    </li>
61
        [% END %]
61
        [% END %]
Lines 67-78 Link Here
67
        <label for="city">
67
        <label for="city">
68
      [% END %]
68
      [% END %]
69
      City: </label>
69
      City: </label>
70
        <input type="text" id="city" name="city" size="20" value="[% patron.city | html %]" />
70
        <input type="text" id="city" name="city" size="20" value="[% city | html %]" />
71
        [% IF cities.count %]or choose
71
        [% IF cities.count %]or choose
72
        <select class="select_city" data-addressfield="" name="select_city">
72
        <select class="select_city" data-addressfield="" name="select_city">
73
            <option value="|||"></option>
73
            <option value="|||"></option>
74
            [% FOREACH c IN cities %]
74
            [% FOREACH c IN cities %]
75
                [% IF c.city_name == patron.city && c.city_state == patron.state && c.city_zipcode == patron.zipcode %]
75
                [% IF c.city_name == city && c.city_state == state && c.city_zipcode == zipcode %]
76
                <option value="[% c.city_zipcode | html %]|[% c.city_name | html %]|[% c.city_state | html %]|[% c.city_country | html %]" selected="selected">
76
                <option value="[% c.city_zipcode | html %]|[% c.city_name | html %]|[% c.city_state | html %]|[% c.city_country | html %]" selected="selected">
77
                [% ELSE %]
77
                [% ELSE %]
78
                <option value="[% c.city_zipcode | html %]|[% c.city_name | html %]|[% c.city_state | html %]|[% c.city_country | html %]">
78
                <option value="[% c.city_zipcode | html %]|[% c.city_name | html %]|[% c.city_state | html %]|[% c.city_country | html %]">
Lines 93-99 Link Here
93
        <label for="state">
93
        <label for="state">
94
      [% END %]
94
      [% END %]
95
      State: </label>
95
      State: </label>
96
      <input type="text" name="state" id="state" size="20" value="[% patron.state | html %]" />
96
      <input type="text" name="state" id="state" size="20" value="[% state | html %]" />
97
      [% IF ( mandatorystate ) %]<span class="required">Required</span>[% END %]
97
      [% IF ( mandatorystate ) %]<span class="required">Required</span>[% END %]
98
    </li>
98
    </li>
99
        [% END %]
99
        [% END %]
Lines 105-111 Link Here
105
        <label for="zipcode">
105
        <label for="zipcode">
106
      [% END %]
106
      [% END %]
107
      ZIP/Postal code: </label>
107
      ZIP/Postal code: </label>
108
            <input type="text" name="zipcode" id="zipcode" size="10" value="[% patron.zipcode | html %]" />
108
            <input type="text" name="zipcode" id="zipcode" size="10" value="[% zipcode | html %]" />
109
      [% IF ( mandatoryzipcode ) %]<span class="required">Required</span>[% END %]
109
      [% IF ( mandatoryzipcode ) %]<span class="required">Required</span>[% END %]
110
    </li>
110
    </li>
111
        [% END %]
111
        [% END %]
Lines 117-123 Link Here
117
        <label for="country">
117
        <label for="country">
118
      [% END %]
118
      [% END %]
119
      Country: </label>
119
      Country: </label>
120
        <input type="text" name="country" id="country" size="20" value="[% patron.country | html %]" />
120
        <input type="text" name="country" id="country" size="20" value="[% country | html %]" />
121
      [% IF ( mandatorycountry ) %]<span class="required">Required</span>[% END %]
121
      [% IF ( mandatorycountry ) %]<span class="required">Required</span>[% END %]
122
    </li>
122
    </li>
123
        [% END %]
123
        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (-1 / +1 lines)
Lines 17-23 Link Here
17
17
18
    [% IF CAN_user_borrowers_edit_borrowers %]
18
    [% IF CAN_user_borrowers_edit_borrowers %]
19
        [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %]
19
        [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %]
20
            <a id="addchild" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> Add child</a>
20
            <a id="addchild" class="btn btn-default" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> Add guarantee</a>
21
        [% END %]
21
        [% END %]
22
        [% IF CAN_user_borrowers_edit_borrowers %]
22
        [% IF CAN_user_borrowers_edit_borrowers %]
23
            <a id="changepassword" class="btn btn-default" href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | html %]"><i class="fa fa-lock"></i> Change password</a>
23
            <a id="changepassword" class="btn btn-default" href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | html %]"><i class="fa fa-lock"></i> Change password</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt (+15 lines)
Lines 151-156 Link Here
151
                    </select>
151
                    </select>
152
                    <span class="required">Required</span>
152
                    <span class="required">Required</span>
153
                </li>
153
                </li>
154
                <li>
155
                    <label for="canbeguarantee">Can be guarantee</label>
156
                    <select name="canbeguarantee" id="canbeguarantee">
157
                        [% IF category.canbeguarantee %]
158
                            <option value="1" selected>Yes</option>
159
                            <option value="0">No</option>
160
                        [% ELSE %]
161
                            <option value="1">Yes</option>
162
                            <option value="0" selected>No</option>
163
                        [% END %]
164
                    <select>
165
                </li>
154
                <li><label for="branches">Branches limitation: </label>
166
                <li><label for="branches">Branches limitation: </label>
155
                    <select id="branches" name="branches" multiple size="10">
167
                    <select id="branches" name="branches" multiple size="10">
156
                        <option value="">All branches</option>
168
                        <option value="">All branches</option>
Lines 363-368 Link Here
363
                      </td>
375
                      </td>
364
                  </tr>
376
                  </tr>
365
                [% END %]
377
                [% END %]
378
                <tr><th scope="row">Can be guarantee</th><td>[% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %]</td></tr>
366
                <tr>
379
                <tr>
367
                    <th scope="row">Default privacy: </th>
380
                    <th scope="row">Default privacy: </th>
368
                    <td>
381
                    <td>
Lines 422-427 Link Here
422
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
435
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
423
                    <th scope="col">Check previous checkout?</th>
436
                    <th scope="col">Check previous checkout?</th>
424
                    [% END %]
437
                    [% END %]
438
                    <th scope="col">Can be guarantee</th>
425
                    <th scope="col">Default privacy</th>
439
                    <th scope="col">Default privacy</th>
426
                    <th scope="col">Actions</th>
440
                    <th scope="col">Actions</th>
427
                </tr>
441
                </tr>
Lines 526-531 Link Here
526
                              [% END %]
540
                              [% END %]
527
                          </td>
541
                          </td>
528
                        [% END %]
542
                        [% END %]
543
                        <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td>
529
                        <td>
544
                        <td>
530
                            [% SWITCH category.default_privacy %]
545
                            [% SWITCH category.default_privacy %]
531
                            [% CASE 'default' %]
546
                            [% CASE 'default' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+5 lines)
Lines 227-232 Patrons: Link Here
227
               no: Allow all permitted users
227
               no: Allow all permitted users
228
         - "to access/change superlibrarian privileges."
228
         - "to access/change superlibrarian privileges."
229
         - "<br><strong>NOTE:</strong> A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
229
         - "<br><strong>NOTE:</strong> A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
230
    -
231
         - "These additional following <a href='http://schema.koha-community.org/tables/borrowers.html' target='blank'>database columns</a> will be transferred from guarantor to guarantee:"
232
         - pref: AdditionalGuarantorField
233
           class: multi
234
         - (separate columns with |)
230
235
231
    Privacy:
236
    Privacy:
232
     -
237
     -
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt (-3 / +4 lines)
Lines 220-226 Link Here
220
                e.preventDefault();
220
                e.preventDefault();
221
                var borrowernumber = $(this).data("borrowernumber");
221
                var borrowernumber = $(this).data("borrowernumber");
222
                var borrower_data = $("#borrower_data"+borrowernumber).val();
222
                var borrower_data = $("#borrower_data"+borrowernumber).val();
223
                select_user( borrowernumber, JSON.parse(borrower_data) );
223
                var guarantor_attributes = $("#guarantor_attributes").val();
224
                select_user( borrowernumber, JSON.parse(borrower_data), JSON.parse(guarantor_attributes) );
224
            });
225
            });
225
226
226
            $("body").on("click",".patron_preview", function( e ){
227
            $("body").on("click",".patron_preview", function( e ){
Lines 278-286 Link Here
278
                wait_for_opener();
279
                wait_for_opener();
279
            }
280
            }
280
        [% ELSIF selection_type == 'select' %]
281
        [% ELSIF selection_type == 'select' %]
281
            function select_user(borrowernumber, data) {
282
            function select_user(borrowernumber, data, attributes) {
282
                var p = window.opener;
283
                var p = window.opener;
283
                p.select_user(borrowernumber, data);
284
                p.select_user(borrowernumber, data, attributes);
284
                window.close();
285
                window.close();
285
            }
286
            }
286
        [% END %]
287
        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-4 / +2 lines)
Lines 343-349 Link Here
343
	            [% END %]
343
	            [% END %]
344
	        </li>
344
	        </li>
345
[% ELSE %]
345
[% ELSE %]
346
 [% IF ( C ) %]
347
 [% IF ( guarantorid ) %]
346
 [% IF ( guarantorid ) %]
348
 <li id="contact-details">
347
 <li id="contact-details">
349
 [% ELSE %]
348
 [% ELSE %]
Lines 368-376 Link Here
368
        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
367
        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
369
     [% END %]
368
     [% END %]
370
 </li>
369
 </li>
371
        [% END %]
370
     [% UNLESS nocontactfirstname %]
372
        [% UNLESS nocontactfirstname %]
371
<li>
373
 <li>
374
     <label for="contactfirstname">First name: </label>
372
     <label for="contactfirstname">First name: </label>
375
     [% IF ( guarantorid ) %]
373
     [% IF ( guarantorid ) %]
376
     <span>[% contactfirstname | html %]</span>
374
     <span>[% contactfirstname | html %]</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-4 / +11 lines)
Lines 255-269 Link Here
255
                                        [% IF guarantees %]
255
                                        [% IF guarantees %]
256
                                            <li>
256
                                            <li>
257
                                                <span class="label">Guarantees:</span>
257
                                                <span class="label">Guarantees:</span>
258
                                                <ul>
258
                                                <table>
259
                                                    [% FOREACH guarantee IN guarantees %]
259
                                                    [% FOREACH guarantee IN guarantees %]
260
                                                    <tr>
260
                                                        [% IF logged_in_user.can_see_patron_infos( guarantee ) %]
261
                                                        [% IF logged_in_user.can_see_patron_infos( guarantee ) %]
261
                                                            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber | uri %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
262
                                                            <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber | uri %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></td>
263
                                                            <td style='text-align:right'>[% guarantee.account.balance %]</td>
262
                                                        [% ELSE %]
264
                                                        [% ELSE %]
263
                                                            <li>[% guarantee.firstname | html %] [% guarantee.surname | html %]</li>
265
                                                            <td>[% guarantee.firstname | html %] [% guarantee.surname | html %]</td>
264
                                                        [% END %]
266
                                                        [% END %]
267
                                                    </tr>
265
                                                    [% END %]
268
                                                    [% END %]
266
                                                </ul>
269
                                                    [% IF logged_in_user.can_see_patron_infos( guarantee ) %]
270
                                                       <td>Total</td>
271
                                                       <td style='text-align:right'>[% amounttot %]</td>
272
                                                    [% END %]
273
                                                </table>
267
                                            </li>
274
                                            </li>
268
                                        [% ELSIF guarantor %]
275
                                        [% ELSIF guarantor %]
269
                                            <li>
276
                                            <li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt (-1 / +1 lines)
Lines 18-24 Link Here
18
                "dt_address":
18
                "dt_address":
19
                    "[% INCLUDE escape_address data=data %]",
19
                    "[% INCLUDE escape_address data=data %]",
20
                "dt_action":
20
                "dt_action":
21
                    "<a href=\"#\" class=\"btn btn-default btn-xs select_user\" data-borrowernumber=\"[% data.borrowernumber | html %]\">Select</a><input type=\"hidden\" id=\"borrower_data[% data.borrowernumber | html %]\" name=\"borrower_data[% data.borrowernumber | html %]\" value=\"[% To.json(data) | html %]\" />"
21
                    "<a href=\"#\" class=\"btn btn-mini select_user\" data-borrowernumber=\"[% data.borrowernumber | html %]\">Select</a><input type=\"hidden\" id=\"borrower_data[% data.borrowernumber | html %]\" name=\"guarantor_data\" value=\"[% To.json(data) | html %]\" /><input type=\"hidden\" id=\"guarantor_attributes\" name=\"guarantor_attributes\" value=\"[% To.json(attributes) | html %]\" />"
22
            }[% UNLESS loop.last %],[% END %]
22
            }[% UNLESS loop.last %],[% END %]
23
        [% END %]
23
        [% END %]
24
    ]
24
    ]
(-)a/koha-tmpl/intranet-tmpl/prog/js/members.js (-12 / +8 lines)
Lines 169-175 function update_category_code(category_code) { Link Here
169
    $(mytables).find(" li[data-category_code='']").show();
169
    $(mytables).find(" li[data-category_code='']").show();
170
}
170
}
171
171
172
function select_user(borrowernumber, borrower) {
172
function select_user(borrowernumber, borrower, attributes) {
173
    var form = $('#entryform').get(0);
173
    var form = $('#entryform').get(0);
174
    if (form.guarantorid.value) {
174
    if (form.guarantorid.value) {
175
        $("#contact-details, #quick_add_form #contact-details").find('a').remove();
175
        $("#contact-details, #quick_add_form #contact-details").find('a').remove();
Lines 192-205 function select_user(borrowernumber, borrower) { Link Here
192
        .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
192
        .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
193
    $("#quick_add_form #contactfirstname").val(borrower.firstname).before('<span>'+borrower.firstname+'</span.').attr({type:"hidden"});
193
    $("#quick_add_form #contactfirstname").val(borrower.firstname).before('<span>'+borrower.firstname+'</span.').attr({type:"hidden"});
194
194
195
    form.streetnumber.value = borrower.streetnumber;
195
    form.guarantorsearch.value = LABEL_CHANGE;
196
    form.address.value = borrower.address;
196
    for (var i = 0; i < parseInt(attributes.length, 10); i++) {
197
    form.address2.value = borrower.address2;
197
        var attribute = attributes[i];
198
    form.city.value = borrower.city;
198
        if (borrower[attribute] != null){
199
    form.state.value = borrower.state;
199
            document.forms.entryform[attribute].value = borrower[attribute];
200
    form.zipcode.value = borrower.zipcode;
200
        }
201
    form.country.value = borrower.country;
201
    }
202
    form.branchcode.value = borrower.branchcode;
203
202
204
    $("#quick_add_form #streetnumber").val(borrower.streetnumber);
203
    $("#quick_add_form #streetnumber").val(borrower.streetnumber);
205
    $("#quick_add_form #address").val(borrower.address);
204
    $("#quick_add_form #address").val(borrower.address);
Lines 210-218 function select_user(borrowernumber, borrower) { Link Here
210
    $("#quick_add_form #country").val(borrower.country);
209
    $("#quick_add_form #country").val(borrower.country);
211
    $("#quick_add_form select[name='branchcode']").val(borrower.branchcode);
210
    $("#quick_add_form select[name='branchcode']").val(borrower.branchcode);
212
211
213
    form.guarantorsearch.value = LABEL_CHANGE;
214
    $("#quick_add_form #guarantorsearch").val(LABEL_CHANGE);
215
216
    return 0;
212
    return 0;
217
}
213
}
218
214
(-)a/members/memberentry.pl (-7 / +8 lines)
Lines 257-269 if ( $guarantorid ) { Link Here
257
        $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
257
        $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
258
        $newdata{'contactname'}     = $guarantordata->{'surname'};
258
        $newdata{'contactname'}     = $guarantordata->{'surname'};
259
        $newdata{'contacttitle'}    = $guarantordata->{'title'};
259
        $newdata{'contacttitle'}    = $guarantordata->{'title'};
260
260
        if ( $op eq 'add' ) {
261
        if ( $op eq 'add' ) {
261
	        foreach (qw(streetnumber address streettype address2
262
            my @attributes = @{C4::Members::Attributes::get_guarantor_shared_attributes()};
262
                        zipcode country city state phone phonepro mobile fax email emailpro branchcode
263
            foreach my $attribute (@attributes) {
263
                        B_streetnumber B_streettype B_address B_address2
264
                $newdata{$attribute} = $guarantordata->{$attribute};
264
                        B_city B_state B_zipcode B_country B_email B_phone)) {
265
            }
265
		        $newdata{$_} = $guarantordata->{$_};
266
	        }
267
        }
266
        }
268
    }
267
    }
269
}
268
}
Lines 761-767 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
761
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
760
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
762
}
761
}
763
762
764
$template->param( "showguarantor"  => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
763
$template->param( "showguarantor"  => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are
764
765
$template->param( "guarantor_attributes" => C4::Members::Attributes::get_guarantor_shared_attributes() );
765
$debug and warn "memberentry step: $step";
766
$debug and warn "memberentry step: $step";
766
$template->param(%data);
767
$template->param(%data);
767
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
768
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
(-)a/members/moremember.pl (-5 / +82 lines)
Lines 83-91 my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in" Link Here
83
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
83
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
84
84
85
my $category_type = $patron->category->category_type;
85
my $category_type = $patron->category->category_type;
86
my $data = $patron->unblessed;
86
87
87
for (qw(gonenoaddress lost borrowernotes is_debarred)) {
88
for (qw(gonenoaddress lost borrowernotes)) {
88
    $patron->$_ and $template->param(flagged => 1) and last;
89
        $data->{$_} and $template->param(flagged => 1) and last;
89
}
90
}
90
91
91
if ( $patron->is_debarred ) {
92
if ( $patron->is_debarred ) {
Lines 100-106 $template->param( flagged => 1 ) if $patron->account_locked; Link Here
100
101
101
my @relatives;
102
my @relatives;
102
if ( my $guarantor = $patron->guarantor ) {
103
if ( my $guarantor = $patron->guarantor ) {
103
    $template->param( guarantor => $guarantor );
104
    push @relatives, $guarantor->borrowernumber;
104
    push @relatives, $guarantor->borrowernumber;
105
    push @relatives, $_->borrowernumber for $patron->siblings;
105
    push @relatives, $_->borrowernumber for $patron->siblings;
106
} elsif ( $patron->contactname || $patron->contactfirstname ) {
106
} elsif ( $patron->contactname || $patron->contactfirstname ) {
Lines 112-123 if ( my $guarantor = $patron->guarantor ) { Link Here
112
    );
112
    );
113
} else {
113
} else {
114
    my @guarantees = $patron->guarantees;
114
    my @guarantees = $patron->guarantees;
115
    $template->param( guarantees => \@guarantees );
116
    push @relatives, $_->borrowernumber for @guarantees;
115
    push @relatives, $_->borrowernumber for @guarantees;
117
}
116
}
118
117
119
my $relatives_issues_count =
118
my $relatives_issues_count =
120
    Koha::Checkouts->count({ borrowernumber => \@relatives });
119
  Koha::Database->new()->schema()->resultset('Issue')
120
  ->count( { borrowernumber => \@relatives } );
121
my @guarantees = $patron->guarantees;
122
my $count = scalar @guarantees;
123
if ( $count ) {
124
    $template->param( isguarantee => 1 );
125
126
    my @guaranteedata;
127
    my $amount;
128
    my $totalmount = 0;
129
130
    foreach my $guarantee (@guarantees){
131
132
        $totalmount += $guarantee->account->balance;
133
134
    }
135
    $template->param( guarantees => @guarantees);
136
    $template->param( amounttot => sprintf("%.2f",$totalmount));
137
}
138
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' || $category_type eq 'I' );
139
140
if (my $guarantor = $patron->guarantor){
141
    $template->param(isguarantor => 1);
142
    $template->param(guarantor => $guarantor);
143
}
144
145
my %bor;
146
$bor{'borrowernumber'} = $borrowernumber;
147
148
# Converts the branchcode to the branch name
149
my $samebranch;
150
if ( C4::Context->preference("IndependentBranches") ) {
151
    if ( C4::Context->IsSuperLibrarian() ) {
152
        $samebranch = 1;
153
    }
154
    else {
155
        my $userenv = C4::Context->userenv;
156
        $samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
157
    }
158
}
159
else {
160
    $samebranch = 1;
161
}
162
my $library = Koha::Libraries->find( $data->{branchcode})->unblessed;
163
@{$data}{keys %$library} = values %$library; # merge in all branch columns # FIXME This is really ugly, we should pass the library instead
164
165
# If printing a page, send the account informations to the template
166
if (defined $print and $print eq "page") {
167
    my $accts = Koha::Account::Lines->search(
168
        { borrowernumber => $patron->borrowernumber, amountoutstanding => { '>' => 0 } },
169
        { order_by       => { -desc => 'accountlines_id' } }
170
    );
171
    $template->param( accounts => $accts );
172
}
173
174
# Show OPAC privacy preference is system preference is set
175
if ( C4::Context->preference('OPACPrivacy') ) { # FIXME Should be moved the the template
176
    $template->param( OPACPrivacy => 1);
177
    $template->param( "privacy".$data->{'privacy'} => 1);
178
}
179
180
my $today       = DateTime->now( time_zone => C4::Context->tz);
181
$today->truncate(to => 'day');
182
my $overdues_exist = 0;
183
my $totalprice = 0;
184
185
# Calculate and display patron's age
186
if ( $data->{dateofbirth} ) {
187
    $template->param( age => Koha::Patron->new({ dateofbirth => $data->{dateofbirth} })->get_age );
188
}
189
190
### ###############################################################################
191
# BUILD HTML
192
# show all reserves of this borrower, and the position of the reservation ....
193
if ($borrowernumber) {
194
    $template->param(
195
        holds_count => Koha::Database->new()->schema()->resultset('Reserve')
196
          ->count( { borrowernumber => $borrowernumber } ) );
197
}
121
198
122
# Generate CSRF token for upload and delete image buttons
199
# Generate CSRF token for upload and delete image buttons
123
$template->param(
200
$template->param(
(-)a/svc/members/search (-1 / +2 lines)
Lines 109-120 if ($has_permission) { Link Here
109
    $results->{iTotalDisplayRecords} = scalar( @patrons_with_permission );
109
    $results->{iTotalDisplayRecords} = scalar( @patrons_with_permission );
110
}
110
}
111
111
112
my @attributes = C4::Members::Attributes::get_guarantor_shared_attributes();
112
$template->param(
113
$template->param(
113
    sEcho => $sEcho,
114
    sEcho => $sEcho,
114
    iTotalRecords => $results->{iTotalRecords},
115
    iTotalRecords => $results->{iTotalRecords},
115
    iTotalDisplayRecords => $results->{iTotalDisplayRecords},
116
    iTotalDisplayRecords => $results->{iTotalDisplayRecords},
116
    aaData => $results->{patrons},
117
    aaData => $results->{patrons},
117
    selection_type => $selection_type,
118
    selection_type => $selection_type,
119
    attributes => @attributes
118
);
120
);
119
121
120
output_with_http_headers $input, $cookie, $template->output, 'json';
122
output_with_http_headers $input, $cookie, $template->output, 'json';
121
- 

Return to bug 12446