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

(-)a/Koha/ArticleRequest.pm (+48 lines)
Lines 26-31 use Koha::Biblios; Link Here
26
use Koha::Items;
26
use Koha::Items;
27
use Koha::Libraries;
27
use Koha::Libraries;
28
use Koha::DateUtils qw( dt_from_string );
28
use Koha::DateUtils qw( dt_from_string );
29
use C4::Context;
30
use Koha::Account::Lines;
29
31
30
use base qw(Koha::Object);
32
use base qw(Koha::Object);
31
33
Lines 47-52 sub open { Link Here
47
    my ($self) = @_;
49
    my ($self) = @_;
48
50
49
    $self->status(Koha::ArticleRequest::Status::Pending);
51
    $self->status(Koha::ArticleRequest::Status::Pending);
52
    if(C4::Context->preference('ArticleRequests') && $self->borrower->category->article_request_fee) {
53
      my $debit_line = $self->borrower->account->add_debit(
54
        {
55
          amount     => $self->borrower->category->article_request_fee,
56
          user_id    => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
57
          interface  => C4::Context->interface,
58
          library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
59
          type       => 'ARTICLE_REQUEST',
60
          item_id    => $self->itemnumber
61
        }
62
      );
63
      $self->debit_line_id($debit_line->id);
64
    }
50
    $self->SUPER::store();
65
    $self->SUPER::store();
51
    $self->notify();
66
    $self->notify();
52
    return $self;
67
    return $self;
Lines 87-92 sub cancel { Link Here
87
102
88
    $self->status(Koha::ArticleRequest::Status::Canceled);
103
    $self->status(Koha::ArticleRequest::Status::Canceled);
89
    $self->notes($notes) if $notes;
104
    $self->notes($notes) if $notes;
105
    if ( $self->debit_line_id ) {
106
        my $line = Koha::Account::Lines->find( $self->debit_line_id );
107
        if ( $line->amount != $line->amountoutstanding ) {
108
            $self->borrower->account->add_credit(
109
                {
110
                    amount  => $line->amount,
111
                    user_id => C4::Context->userenv
112
                    ? C4::Context->userenv->{'number'}
113
                    : undef,
114
                    interface  => C4::Context->interface,
115
                    library_id => C4::Context->userenv
116
                    ? C4::Context->userenv->{'branch'}
117
                    : undef,
118
                    type        => 'CREDIT',
119
                    description => 'Article request cancelled',
120
                    item_id     => $self->itemnumber
121
                }
122
            );
123
        }
124
        else {
125
            $line->cancel(
126
                {
127
                    branch => C4::Context->userenv
128
                    ? C4::Context->userenv->{'branch'}
129
                    : undef,
130
                    staff_id => C4::Context->userenv
131
                    ? C4::Context->userenv->{'number'}
132
                    : undef,
133
                }
134
            ) unless $line->status && $line->status eq 'CANCELLED';
135
        }
136
    }
137
90
    $self->store();
138
    $self->store();
91
    $self->notify();
139
    $self->notify();
92
    return $self;
140
    return $self;
(-)a/admin/categories.pl (-89 / +98 lines)
Lines 46-63 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
46
    }
46
    }
47
);
47
);
48
48
49
if ( $op eq 'add_form' ) {
49
if ( $op eq 'add_validate' ) {
50
51
    $template->param(
52
        category => scalar Koha::Patron::Categories->find($categorycode),
53
    );
54
55
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
56
        C4::Form::MessagingPreferences::set_form_values(
57
            { categorycode => $categorycode }, $template );
58
    }
59
}
60
elsif ( $op eq 'add_validate' ) {
61
50
62
    my $categorycode = $input->param('categorycode');
51
    my $categorycode = $input->param('categorycode');
63
    my $description = $input->param('description');
52
    my $description = $input->param('description');
Lines 78-83 elsif ( $op eq 'add_validate' ) { Link Here
78
    my $exclude_from_local_holds_priority = $input->param('exclude_from_local_holds_priority');
67
    my $exclude_from_local_holds_priority = $input->param('exclude_from_local_holds_priority');
79
    my $min_password_length = $input->param('min_password_length');
68
    my $min_password_length = $input->param('min_password_length');
80
    my $require_strong_password = $input->param('require_strong_password');
69
    my $require_strong_password = $input->param('require_strong_password');
70
    my $article_request_fee = $input->param('article_request_fee');
81
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
71
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
82
72
83
    $reset_password = undef if $reset_password eq -1;
73
    $reset_password = undef if $reset_password eq -1;
Lines 87-174 elsif ( $op eq 'add_validate' ) { Link Here
87
77
88
    my $is_a_modif = $input->param("is_a_modif");
78
    my $is_a_modif = $input->param("is_a_modif");
89
79
90
    if ($enrolmentperioddate) {
80
    if ($article_request_fee < 0) {
91
        $enrolmentperioddate = output_pref(
81
        push @messages, {type => 'error', code => 'article_request_negative_fee' };
92
            {
82
        $op = 'add_form';
93
                dt         => dt_from_string($enrolmentperioddate),
83
    } else {
94
                dateformat => 'iso',
84
        if ($enrolmentperioddate) {
95
                dateonly   => 1,
85
            $enrolmentperioddate = output_pref(
96
            }
86
                {
97
        );
87
                    dt         => dt_from_string($enrolmentperioddate),
98
    }
88
                    dateformat => 'iso',
89
                    dateonly   => 1,
90
                }
91
            );
92
        }
99
93
100
    if ($is_a_modif) {
94
        if ($is_a_modif) {
101
        my $category = Koha::Patron::Categories->find( $categorycode );
95
            my $category = Koha::Patron::Categories->find( $categorycode );
102
        $category->categorycode($categorycode);
96
            $category->categorycode($categorycode);
103
        $category->description($description);
97
            $category->description($description);
104
        $category->enrolmentperiod($enrolmentperiod);
98
            $category->enrolmentperiod($enrolmentperiod);
105
        $category->enrolmentperioddate($enrolmentperioddate);
99
            $category->enrolmentperioddate($enrolmentperioddate);
106
        $category->upperagelimit($upperagelimit);
100
            $category->upperagelimit($upperagelimit);
107
        $category->dateofbirthrequired($dateofbirthrequired);
101
            $category->dateofbirthrequired($dateofbirthrequired);
108
        $category->enrolmentfee($enrolmentfee);
102
            $category->enrolmentfee($enrolmentfee);
109
        $category->reservefee($reservefee);
103
            $category->reservefee($reservefee);
110
        $category->hidelostitems($hidelostitems);
104
            $category->hidelostitems($hidelostitems);
111
        $category->overduenoticerequired($overduenoticerequired);
105
            $category->overduenoticerequired($overduenoticerequired);
112
        $category->category_type($category_type);
106
            $category->category_type($category_type);
113
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
107
            $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
114
        $category->checkprevcheckout($checkPrevCheckout);
108
            $category->checkprevcheckout($checkPrevCheckout);
115
        $category->default_privacy($default_privacy);
109
            $category->default_privacy($default_privacy);
116
        $category->reset_password($reset_password);
110
            $category->reset_password($reset_password);
117
        $category->change_password($change_password);
111
            $category->change_password($change_password);
118
        $category->exclude_from_local_holds_priority($exclude_from_local_holds_priority);
112
            $category->exclude_from_local_holds_priority($exclude_from_local_holds_priority);
119
        $category->min_password_length($min_password_length);
113
            $category->min_password_length($min_password_length);
120
        $category->require_strong_password($require_strong_password);
114
            $category->require_strong_password($require_strong_password);
121
        eval {
115
            $category->article_request_fee($article_request_fee);
122
            $category->store;
116
            eval {
123
            $category->replace_library_limits( \@branches );
117
                $category->store;
124
        };
118
                $category->replace_library_limits( \@branches );
125
        if ( $@ ) {
119
            };
126
            push @messages, {type => 'error', code => 'error_on_update' };
120
            if ( $@ ) {
127
        } else {
121
                push @messages, {type => 'error', code => 'error_on_update' };
128
            push @messages, { type => 'message', code => 'success_on_update' };
122
            } else {
123
                push @messages, { type => 'message', code => 'success_on_update' };
124
            }
129
        }
125
        }
130
    }
126
        else {
131
    else {
127
            my $category = Koha::Patron::Category->new({
132
        my $category = Koha::Patron::Category->new({
128
                categorycode => $categorycode,
133
            categorycode => $categorycode,
129
                description => $description,
134
            description => $description,
130
                enrolmentperiod => $enrolmentperiod,
135
            enrolmentperiod => $enrolmentperiod,
131
                enrolmentperioddate => $enrolmentperioddate,
136
            enrolmentperioddate => $enrolmentperioddate,
132
                upperagelimit => $upperagelimit,
137
            upperagelimit => $upperagelimit,
133
                dateofbirthrequired => $dateofbirthrequired,
138
            dateofbirthrequired => $dateofbirthrequired,
134
                enrolmentfee => $enrolmentfee,
139
            enrolmentfee => $enrolmentfee,
135
                reservefee => $reservefee,
140
            reservefee => $reservefee,
136
                hidelostitems => $hidelostitems,
141
            hidelostitems => $hidelostitems,
137
                overduenoticerequired => $overduenoticerequired,
142
            overduenoticerequired => $overduenoticerequired,
138
                category_type => $category_type,
143
            category_type => $category_type,
139
                BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
144
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
140
                checkprevcheckout => $checkPrevCheckout,
145
            checkprevcheckout => $checkPrevCheckout,
141
                default_privacy => $default_privacy,
146
            default_privacy => $default_privacy,
142
                reset_password => $reset_password,
147
            reset_password => $reset_password,
143
                change_password => $change_password,
148
            change_password => $change_password,
144
                exclude_from_local_holds_priority => $exclude_from_local_holds_priority,
149
            exclude_from_local_holds_priority => $exclude_from_local_holds_priority,
145
                min_password_length => $min_password_length,
150
            min_password_length => $min_password_length,
146
                require_strong_password => $require_strong_password,
151
            require_strong_password => $require_strong_password,
147
                article_request_fee => $article_request_fee,
152
        });
148
            });
153
        eval {
149
            eval {
154
            $category->store;
150
                $category->store;
155
            $category->replace_library_limits( \@branches );
151
                $category->replace_library_limits( \@branches );
156
        };
152
            };
157
153
158
        if ( $@ ) {
154
            if ( $@ ) {
159
            push @messages, { type => 'error', code => 'error_on_insert' };
155
                push @messages, { type => 'error', code => 'error_on_insert' };
160
        } else {
156
            } else {
161
            push @messages, { type => 'message', code => 'success_on_insert' };
157
                push @messages, { type => 'message', code => 'success_on_insert' };
158
            }
162
        }
159
        }
163
    }
164
160
165
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
161
        if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
166
        C4::Form::MessagingPreferences::handle_form_action( $input,
162
            C4::Form::MessagingPreferences::handle_form_action( $input,
167
            { categorycode => scalar $input->param('categorycode') }, $template );
163
                { categorycode => scalar $input->param('categorycode') }, $template );
168
    }
164
        }
169
165
170
    $searchfield = q||;
166
        $searchfield = q||;
171
    $op = 'list';
167
        $op = 'list';
168
    }
172
}
169
}
173
elsif ( $op eq 'delete_confirm' ) {
170
elsif ( $op eq 'delete_confirm' ) {
174
171
Lines 199-204 elsif ( $op eq 'delete_confirmed' ) { Link Here
199
    $op = 'list';
196
    $op = 'list';
200
}
197
}
201
198
199
if ( $op eq 'add_form' ) {
200
201
    $template->param(
202
        category => scalar Koha::Patron::Categories->find($categorycode),
203
    );
204
205
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
206
        C4::Form::MessagingPreferences::set_form_values(
207
            { categorycode => $categorycode }, $template );
208
    }
209
}
210
202
if ( $op eq 'list' ) {
211
if ( $op eq 'list' ) {
203
    my $categories = Koha::Patron::Categories->search(
212
    my $categories = Koha::Patron::Categories->search(
204
        {
213
        {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt (-1 / +21 lines)
Lines 108-113 Link Here
108
            Patron category deleted successfully.
108
            Patron category deleted successfully.
109
        [% CASE 'already_exists' %]
109
        [% CASE 'already_exists' %]
110
            This patron category already exists.
110
            This patron category already exists.
111
        [% CASE 'article_request_negative_fee' %]
112
            Article request fee cannot be negative.
111
        [% CASE %]
113
        [% CASE %]
112
            [% m.code | html %]
114
            [% m.code | html %]
113
        [% END %]
115
        [% END %]
Lines 202-207 Link Here
202
                    <label for="reservefee">Hold fee: </label>
204
                    <label for="reservefee">Hold fee: </label>
203
                    <input type="text" name="reservefee" id="reservefee" size="6" value="[% category.reservefee | $Price on_editing => 1 %]" />
205
                    <input type="text" name="reservefee" id="reservefee" size="6" value="[% category.reservefee | $Price on_editing => 1 %]" />
204
                </li>
206
                </li>
207
                [% IF Koha.Preference('ArticleRequests') %]
208
                <li>
209
                    <label for="article_request_fee">Cost for article scan request</label>
210
                    <input type="text" name="article_request_fee" id="article_request_fee" size="6" value="[% category.article_request_fee | $Price on_editing => 1 %]" />
211
                </li>
212
                [% END %]
205
                <li>
213
                <li>
206
                    <label for="category_type" class="required">Category type: </label>
214
                    <label for="category_type" class="required">Category type: </label>
207
                    <select name="category_type" id="category_type">
215
                    <select name="category_type" id="category_type">
Lines 455-461 Link Here
455
                <tr><th scope="row">Receives overdue notices: </th><td>[% IF category. overduenoticerequired %]Yes[% ELSE %]No[% END %]</td></tr>
463
                <tr><th scope="row">Receives overdue notices: </th><td>[% IF category. overduenoticerequired %]Yes[% ELSE %]No[% END %]</td></tr>
456
                <tr><th scope="row">Lost items in staff interface</th><td>[% IF category.hidelostitems %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
464
                <tr><th scope="row">Lost items in staff interface</th><td>[% IF category.hidelostitems %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
457
                <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | $Price %]</td></tr>
465
                <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | $Price %]</td></tr>
458
466
                [% IF Koha.Preference('ArticleRequests') %]
467
                    <tr><th scope="row">Article request fee: </th><td>[% category.article_request_fee | $Price %]</td></tr>
468
                [% END %]
459
                [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
469
                [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
460
                  <tr>
470
                  <tr>
461
                      <th scope="row">Check previous checkouts: </th>
471
                      <th scope="row">Check previous checkouts: </th>
Lines 523-528 Link Here
523
                    <th scope="col">Overdue</th>
533
                    <th scope="col">Overdue</th>
524
                    <th scope="col">Lost items</th>
534
                    <th scope="col">Lost items</th>
525
                    <th scope="col">Hold fee</th>
535
                    <th scope="col">Hold fee</th>
536
                    [% IF Koha.Preference('ArticleRequests') %]
537
                    <th scope="col">Article request fee</th>
538
                    [% END %]
526
                    [% IF ( EnhancedMessagingPreferences ) %]
539
                    [% IF ( EnhancedMessagingPreferences ) %]
527
                    <th scope="col">Messaging</th>
540
                    <th scope="col">Messaging</th>
528
                    [% END %]
541
                    [% END %]
Lines 581-586 Link Here
581
                        [% ELSE %]
594
                        [% ELSE %]
582
                            <td>-</td>
595
                            <td>-</td>
583
                        [% END %]
596
                        [% END %]
597
                        [% IF Koha.Preference('ArticleRequests') %]
598
                            [% IF (category.article_request_fee > 0) %]
599
                                <td>[% category.article_request_fee | $Price %]</td>
600
                            [% ELSE %]
601
                                <td>-</td>
602
                            [% END %]
603
                        [% END %]
584
                        [% IF Koha.Preference('EnhancedMessagingPreferences') %]
604
                        [% IF Koha.Preference('EnhancedMessagingPreferences') %]
585
                            <td style="white-space: nowrap; font-size:80%;">
605
                            <td style="white-space: nowrap; font-size:80%;">
586
                                [% SET default_messaging = category.default_messaging %]
606
                                [% SET default_messaging = category.default_messaging %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt (-1 / +6 lines)
Lines 3-8 Link Here
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% USE Branches %]
4
[% USE Branches %]
5
[% USE ItemTypes %]
5
[% USE ItemTypes %]
6
[% USE Price %]
6
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
7
[% SET article_requests_view = 1 %]
8
[% SET article_requests_view = 1 %]
8
[% SET biblionumber = biblio.biblionumber %]
9
[% SET biblionumber = biblio.biblionumber %]
Lines 94-100 Link Here
94
                        </form>
95
                        </form>
95
                    [% ELSE %]
96
                    [% ELSE %]
96
                        [% IF biblio.can_article_request( patron ) %]
97
                        [% IF biblio.can_article_request( patron ) %]
97
98
                            [% IF patron.category.article_request_fee > 0  %]
99
                                <div class="dialog alert">
100
                                    Patron will be charged with <strong>[% patron.category.article_request_fee | $Price %]</strong> for every request
101
                                </div>
102
                            [% END %]
98
                            <form id="place-article-request" method="post" action="/cgi-bin/koha/circ/request-article.pl">
103
                            <form id="place-article-request" method="post" action="/cgi-bin/koha/circ/request-article.pl">
99
                                <input type="hidden" name="action" value="create" />
104
                                <input type="hidden" name="action" value="create" />
100
                                <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
105
                                <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt (-1 / +7 lines)
Lines 2-7 Link Here
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE ItemTypes %]
3
[% USE ItemTypes %]
4
[% USE KohaNews %]
4
[% USE KohaNews %]
5
[% USE Price %]
5
[% USE raw %]
6
[% USE raw %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
7
8
Lines 49-54 Link Here
49
                        [% IF article_request_type == 'item_only' %] [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsItemOnly') %]   [% END %]
50
                        [% IF article_request_type == 'item_only' %] [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsItemOnly') %]   [% END %]
50
51
51
52
53
                    [% IF patron.category.article_request_fee > 0  %]
54
                        <div class="alert alert-warning">
55
                            You will be charged with <strong>[% patron.category.article_request_fee | $Price %]</strong> for every request
56
                        </div>
57
                    [% END %]
58
52
                        <form id="place-article-request" method="post" action="/cgi-bin/koha/opac-request-article.pl">
59
                        <form id="place-article-request" method="post" action="/cgi-bin/koha/opac-request-article.pl">
53
                            <legend class="sr-only">Place article request</legend>
60
                            <legend class="sr-only">Place article request</legend>
54
                            <input type="hidden" name="action" value="create" />
61
                            <input type="hidden" name="action" value="create" />
55
- 

Return to bug 27946