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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt (-1 / +28 lines)
Lines 1-6 Link Here
1
[% USE Asset %]
1
[% USE Asset %]
2
[% USE AuthorisedValues %]
2
[% USE AuthorisedValues %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE CGI %]
4
[% USE KohaDates %]
5
[% USE KohaDates %]
5
[% SET footerjs = 1 %]
6
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
Lines 18-26 Link Here
18
19
19
20
20
[% BLOCK subscriptions_table %]
21
[% BLOCK subscriptions_table %]
21
    <table id="osrlt">
22
  <form method="post">
23
24
    [% url_params = [] %]
25
    [% FOREACH param IN CGI.params.pairs %]
26
        [% escaped_value = BLOCK %][% param.value | uri %][% END %]
27
        [% url_params.push(param.key _ '=' _ escaped_value) %]
28
    [% END %]
29
    <input type="hidden" name="referrer" value="/cgi-bin/koha/serials/serials-search.pl?[% url_params.join('&') %]"/>
30
31
    <div class="actions">
32
        <a class="select-all" href="#"><i class="fa fa-check"></i> Select all</a>
33
        |
34
        <a class="clear-all" href="#"><i class="fa fa-remove"></i> Clear all</a>
35
        |
36
        <button class="btn btn-default btn-xs" type="submit" formaction="/cgi-bin/koha/serials/subscription-batchedit.pl"><i class="fa fa-pencil"></i> Edit</button>
37
    </div>
38
    <table>
22
      <thead>
39
      <thead>
23
        <tr>
40
        <tr>
41
            <th></th>
24
            <th>ISSN</th>
42
            <th>ISSN</th>
25
            <th class="anti-the">Title</th>
43
            <th class="anti-the">Title</th>
26
            <th>Notes</th>
44
            <th>Notes</th>
Lines 38-43 Link Here
38
      </thead>
56
      </thead>
39
      <tfoot>
57
      <tfoot>
40
        <tr>
58
        <tr>
59
          <td></td>
41
          <td><input type="text" class="dt-filter" data-column_num="0" placeholder="Search ISSN" /></td>
60
          <td><input type="text" class="dt-filter" data-column_num="0" placeholder="Search ISSN" /></td>
42
          <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search title" /></td>
61
          <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search title" /></td>
43
          <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search notes" /></td>
62
          <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search notes" /></td>
Lines 57-62 Link Here
57
        [% FOREACH subscription IN subscriptions %]
76
        [% FOREACH subscription IN subscriptions %]
58
        [% UNLESS subscription.cannotdisplay %]
77
        [% UNLESS subscription.cannotdisplay %]
59
          <tr>
78
          <tr>
79
            <td><input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid %]"/></td>
60
            <td>
80
            <td>
61
            [% IF ( subscription.issn ) %][% subscription.issn %]
81
            [% IF ( subscription.issn ) %][% subscription.issn %]
62
            [% END %]
82
            [% END %]
Lines 157-162 Link Here
157
        [% END %]
177
        [% END %]
158
      </tbody>
178
      </tbody>
159
    </table>
179
    </table>
180
  </form>
160
[% END %]
181
[% END %]
161
182
162
<div id="doc3" class="yui-t2">
183
<div id="doc3" class="yui-t2">
Lines 397-402 Link Here
397
            $("#reopensub").click(function(){
418
            $("#reopensub").click(function(){
398
                return confirm(_("Are you sure you want to reopen this subscription?"));
419
                return confirm(_("Are you sure you want to reopen this subscription?"));
399
            });
420
            });
421
422
            $('.select-all, .clear-all').on('click', function(e) {
423
                e.preventDefault();
424
                var checkboxes = $(this).parents('form').find('input[type="checkbox"]');
425
                checkboxes.prop('checked', $(this).hasClass('select-all'));
426
            });
400
        });
427
        });
401
    </script>
428
    </script>
402
[% END %]
429
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-batchedit.tt (+153 lines)
Line 0 Link Here
1
[% USE AuthorisedValues %]
2
[% USE Branches %]
3
[% USE ItemTypes %]
4
[% USE KohaDates %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
    <title>Koha &rsaquo; Serials &rsaquo; Batch edit</title>
7
    [% INCLUDE 'doc-head-close.inc' %]
8
    [% INCLUDE 'calendar.inc' %]
9
</head>
10
<body id="ser_subscription-batchedit" class="ser">
11
    [% INCLUDE 'header.inc' %]
12
    [% INCLUDE 'serials-search.inc' %]
13
14
    <div id="breadcrumbs">
15
        <a href="/cgi-bin/koha/mainpage.pl">Home</a>
16
        &rsaquo;
17
        <a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a>
18
        &rsaquo;
19
        Batch edit
20
    </div>
21
22
    <div id="doc3" class="yui-t2">
23
        <div id="bd">
24
            <div id="yui-main">
25
                <div class="yui-b">
26
                    <h1>Subscription batch edit</h1>
27
28
                    <div>
29
                        <p>You are about to edit the following subscriptions:</p>
30
                        <table>
31
                            <thead>
32
                                <tr>
33
                                    <th>ISSN</th>
34
                                    <th>Title</th>
35
                                    <th>Notes</th>
36
                                    <th>Library</th>
37
                                    <th>Location</th>
38
                                    <th>Call number</th>
39
                                    <th>Expiration date</th>
40
                                </tr>
41
                            </thead>
42
                            <tbody>
43
                                [% FOREACH subscription IN subscriptions %]
44
                                    <tr>
45
                                        <td>[% subscription.biblio.biblioitem.issn %]</td>
46
                                        <td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid %]">[% subscription.biblio.title %] (#[% subscription.subscriptionid %])</a></td>
47
                                        <td>[% subscription.notes %] [% IF subscription.internalnotes %]([% subscription.internalnotes %])[% END %]</td>
48
                                        <td>[% Branches.GetName(subscription.branchcode) %]</td>
49
                                        <td>[% AuthorisedValues.GetByCode('LOC', subscription.location) %]</td>
50
                                        <td>[% subscription.callnumber %]</td>
51
                                        <td>[% subscription.enddate | $KohaDates %]</td>
52
                                    </tr>
53
                                [% END %]
54
                            </tbody>
55
                        </table>
56
                    </div>
57
58
                    <form method="post">
59
                        [% FOREACH subscription IN subscriptions %]
60
                            <input type="hidden" name="subscriptionid" value="[% subscription.subscriptionid %]"/>
61
                        [% END %]
62
                        [% IF referrer %]
63
                            <input type="hidden" name="referrer" value="[% referrer %]"/>
64
                        [% END %]
65
                        <fieldset class="rows">
66
                            <ol>
67
                                <li>
68
                                    <label for="booksellerid">Bookseller</label>
69
                                    <select id="booksellerid" name="booksellerid">
70
                                        <option value="">No change</option>
71
                                        [% FOREACH bookseller IN booksellers %]
72
                                            <option value="[% bookseller.id %]">[% bookseller.name %]</option>
73
                                        [% END %]
74
                                    </select>
75
                                </li>
76
                                <li>
77
                                    <label for="location">Location</label>
78
                                    <select id="location" name="location">
79
                                        <option value="">No change</option>
80
                                        [% FOREACH av IN AuthorisedValues.Get('LOC') %]
81
                                            <option value="[% av.authorised_value | html %]">[% av.lib %]</option>
82
                                        [% END %]
83
                                    </select>
84
                                </li>
85
                                <li>
86
                                    <label for="branchcode">Library</label>
87
                                    <select id="branchcode" name="branchcode">
88
                                        <option value="">No change</option>
89
                                        [% FOREACH branch IN Branches.all %]
90
                                            <option value="[% branch.branchcode | html %]">[% branch.branchname %]</option>
91
                                        [% END %]
92
                                    </select>
93
                                </li>
94
                                <li>
95
                                    <label for="itemtype">Item type</label>
96
                                    <select id="itemtype" name="itemtype">
97
                                        <option value="">No change</option>
98
                                        [% FOREACH itemtype IN ItemTypes.Get() %]
99
                                            <option value="[% itemtype.itemtype %]">[% itemtype.description %]</option>
100
                                        [% END %]
101
                                    </select>
102
                                </li>
103
                                <li>
104
                                    <label for="notes">Public note</label>
105
                                    <textarea id="notes" name="notes" placeholder="No change"></textarea>
106
                                </li>
107
                                <li>
108
                                    <label for="internalnotes">Nonpublic note</label>
109
                                    <textarea id="internalnotes" name="internalnotes" placeholder="No change"></textarea>
110
                                </li>
111
                                <li>
112
                                    <label for="serialsadditems">Create item when receiving</label>
113
                                    <select id="serialsadditems" name="serialsadditems">
114
                                        <option value="">No change</option>
115
                                        <option value="0">No</option>
116
                                        <option value="1">Yes</option>
117
                                    </select>
118
119
                                </li>
120
                                <li>
121
                                    <label for="enddate">Expiration date</label>
122
                                    <input type="date" class="datepicker" id="enddate" name="enddate" placeholder="No change"/>
123
                                </li>
124
                                [% FOREACH field IN additional_fields %]
125
                                    <li>
126
                                        <label for="field_[% field.id %]">[% field.name %]</label>
127
                                        [% IF field.authorised_value_category %]
128
                                            <select id="field_[% field.id %]" name="field_[% field.id %]">
129
                                                <option value="">No change</option>
130
                                                [% FOREACH av IN AuthorisedValues.Get(field.authorised_value_category) %]
131
                                                    <option value="[% av.authorised_value %]">[% av.lib %]</option>
132
                                                [% END %]
133
                                            </select>
134
                                        [% ELSE %]
135
                                            <input id="field_[% field.id %]" name="field_[% field.id %]" placeholder="No change"/>
136
                                        [% END %]
137
                                    </li>
138
                                [% END %]
139
                            </ol>
140
                        </fieldset>
141
142
                        <fieldset class="action">
143
                            <button type="submit" name="batchedit" value="1">Start batch edit</button>
144
                        </fieldset>
145
                    </form>
146
                </div>
147
            </div>
148
            <div class="yui-b">
149
                [% INCLUDE 'serials-menu.inc' %]
150
            </div>
151
        </div>
152
153
    [% INCLUDE 'intranet-bottom.inc' %]
(-)a/serials/subscription-batchedit.pl (-1 / +107 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2017 BibLibre
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI qw( -utf8 );
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Subscriptions;
27
use Koha::Acquisition::Booksellers;
28
use Koha::AdditionalField;
29
use Koha::DateUtils;
30
31
my $cgi = new CGI;
32
33
my ($template, $loggedinuser, $cookie) = get_template_and_user({
34
    template_name => 'serials/subscription-batchedit.tt',
35
    query => $cgi,
36
    type => 'intranet',
37
    authnotrequired => 0,
38
    flagsrequired => {serials => 'edit_subscription'},
39
});
40
41
my @subscriptionids = $cgi->multi_param('subscriptionid');
42
43
my @subscriptions;
44
foreach my $subscriptionid (@subscriptionids) {
45
    my $subscription = Koha::Subscriptions->find($subscriptionid);
46
47
    push @subscriptions, $subscription if $subscription;
48
}
49
50
my $additional_fields = Koha::AdditionalField->all({tablename => 'subscription'});
51
52
my $batchedit = $cgi->param('batchedit');
53
if ($batchedit) {
54
    my %params = (
55
        aqbooksellerid => scalar $cgi->param('booksellerid'),
56
        location => scalar $cgi->param('location'),
57
        branchcode => scalar $cgi->param('branchcode'),
58
        itemtype => scalar $cgi->param('itemtype'),
59
        notes => scalar $cgi->param('notes'),
60
        internalnotes => scalar $cgi->param('internalnotes'),
61
        serialsadditems => scalar $cgi->param('serialsadditems'),
62
        enddate => dt_from_string(scalar $cgi->param('enddate')),
63
    );
64
65
    my $field_values = {};
66
    foreach my $field (@$additional_fields) {
67
        my $value = $cgi->param('field_' . $field->{id});
68
        $field_values->{$field->{id}} = $value;
69
    }
70
71
    foreach my $subscription (@subscriptions) {
72
        while (my ($key, $value) = each %params) {
73
            if (defined $value and $value ne '') {
74
                $subscription->$key($value);
75
            }
76
        }
77
78
        foreach my $field (@$additional_fields) {
79
            my $value = $field_values->{$field->{id}};
80
            if (defined $value and $value ne '') {
81
                $field->{values} //= {};
82
                $field->{values}->{$subscription->subscriptionid} = $value;
83
            }
84
        }
85
86
        $subscription->store;
87
    }
88
89
    foreach my $field (@$additional_fields) {
90
        if (defined $field->{values}) {
91
            $field->insert_values();
92
        }
93
    }
94
95
    my $redirect_url = $cgi->param('referrer') // '/cgi-bin/koha/serials/serials-home.pl';
96
    print $cgi->redirect($redirect_url);
97
    exit;
98
}
99
100
$template->param(
101
    subscriptions => \@subscriptions,
102
    booksellers => [ Koha::Acquisition::Booksellers->search() ],
103
    additional_fields => $additional_fields,
104
    referrer => scalar $cgi->param('referrer'),
105
);
106
107
output_html_with_http_headers $cgi, $cookie, $template->output;

Return to bug 18426