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

(-)a/acqui/vendor_issues.pl (+113 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2023 Koha Development Team
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
use CGI qw ( -utf8 );
22
use Try::Tiny;
23
use C4::Context;
24
use C4::Auth qw( get_template_and_user );
25
use C4::Output qw( output_html_with_http_headers );
26
27
use Koha::Acquisition::Booksellers;
28
29
my $input        = CGI->new;
30
my $booksellerid = $input->param('booksellerid');
31
my $issue_id     = $input->param('issue_id');
32
my $op           = $input->param('op') || 'list';
33
my @messages;
34
35
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
36
    {
37
        template_name => "acqui/vendor_issues.tt",
38
        query         => $input,
39
        type          => "intranet",
40
        flagsrequired => { acquisition => 'issues_manage' },
41
    }
42
);
43
44
my $issue;
45
if ( $issue_id ) {
46
    $issue = Koha::Acquisition::Bookseller::Issues->find($issue_id);
47
    $booksellerid = $issue->vendor_id;
48
}
49
my $vendor = Koha::Acquisition::Booksellers->find($booksellerid);
50
51
if ( $op eq 'add_form' || $op eq 'show' ) {
52
    $template->param( issue => $issue );
53
} elsif ( $op eq 'add_validate' ) {
54
    my $type       = $input->param('type');
55
    my $started_on = $input->param('started_on');
56
    my $ended_on   = $input->param('ended_on');
57
    my $notes      = $input->param('notes');
58
59
    if ($issue_id) {
60
        try {
61
            $issue->set(
62
                {
63
                    type       => $type,
64
                    started_on => $started_on,
65
                    ended_on   => $ended_on,
66
                    notes      => $notes
67
                }
68
            )->store;
69
            push @messages, { type => 'message', code => 'success_on_update' };
70
        } catch {
71
            push @messages, { type => 'error', code => 'error_on_update' };
72
        };
73
    } else {
74
        try {
75
            Koha::Acquisition::Bookseller::Issue->new(
76
                {
77
                    vendor_id  => $booksellerid,
78
                    type       => $type,
79
                    started_on => $started_on,
80
                    ended_on   => $ended_on,
81
                    notes      => $notes,
82
                }
83
            )->store;
84
            push @messages, { type => 'message', code => 'success_on_insert' };
85
        } catch {
86
            push @messages, { type => 'error', code => 'error_on_insert' };
87
        };
88
    }
89
    $op = 'list';
90
} elsif ( $op eq 'delete_confirm' ) {
91
    $template->param( issue => $issue );
92
} elsif ( $op eq 'delete_confirmed' ) {
93
    try {
94
        $issue->delete;
95
        push @messages, { type => 'message', code => 'success_on_delete' };
96
    } catch {
97
        push @messages, { type => 'error', code => 'error_on_delete' };
98
    };
99
    $op = 'list';
100
}
101
102
if ( $op eq 'list' ) {
103
    $template->param( issues_count => $vendor->issues->search->count );
104
}
105
106
$template->param(
107
    messages     => \@messages,
108
    op           => $op,
109
    vendor       => $vendor,
110
    booksellerid => $vendor->id,    # Used by vendor-menu.inc
111
);
112
113
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+5 lines)
Lines 454-459 Link Here
454
            Manage all baskets and order lines, regardless of restrictions on them
454
            Manage all baskets and order lines, regardless of restrictions on them
455
        </span>
455
        </span>
456
        <span class="permissioncode">([% name | html %])</span>
456
        <span class="permissioncode">([% name | html %])</span>
457
    [%- CASE 'issue_manage' -%]
458
        <span class="sub_permission issues_manage_subpermission">
459
            Manage issues
460
        </span>
461
        <span class="permissioncode">([% name | html %])</span>
457
    [%- CASE 'order_receive' -%]
462
    [%- CASE 'order_receive' -%]
458
        <span class="sub_permission order_receive_subpermission">
463
        <span class="sub_permission order_receive_subpermission">
459
            Receive orders and manage shipments
464
            Receive orders and manage shipments
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc (+1 lines)
Lines 4-9 Link Here
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid | uri %]">Baskets</a></li>[% END %]
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid | uri %]">Baskets</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | uri %]">Basket groups</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | uri %]">Basket groups</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | uri %]">Contracts</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | uri %]">Contracts</a></li>[% END %]
7
        [% IF ( CAN_user_acquisition_issue_manage ) %]<li><a href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% booksellerid | uri %]">Issues</a></li>[% END %]
7
        <li><a href="/cgi-bin/koha/acqui/invoices.pl?supplierid=[% booksellerid | uri %]&amp;op=do_search">Invoices</a></li>
8
        <li><a href="/cgi-bin/koha/acqui/invoices.pl?supplierid=[% booksellerid | uri %]&amp;op=do_search">Invoices</a></li>
8
        [% IF ( CAN_user_acquisition_order_manage ) %][% IF ( basketno ) %]
9
        [% IF ( CAN_user_acquisition_order_manage ) %][% IF ( basketno ) %]
9
        <li><a href="/cgi-bin/koha/acqui/uncertainprice.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]&amp;owner=1">Uncertain prices</a></li>
10
        <li><a href="/cgi-bin/koha/acqui/uncertainprice.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]&amp;owner=1">Uncertain prices</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendor_issues.tt (+282 lines)
Line 0 Link Here
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE AuthorisedValues %]
4
[% USE KohaDates %]
5
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
<title>
8
    [% IF op =='add_form' %]
9
        [% IF issue.issue_id %]
10
            Modify vendor issue
11
        [% ELSE %]
12
            New vendor issue
13
        [% END %] &rsaquo; [% ELSE %]
14
        [% IF op == 'delete_confirm' %]
15
            Confirm deletion of vendor issue &rsaquo; [% END %]
16
    [% END %]
17
    Vendor issue &rsaquo; Acquisition &rsaquo; Koha
18
</title>
19
[% INCLUDE 'doc-head-close.inc' %]
20
</head>
21
22
<body id="acq_supplier_issues" class="acq">
23
[% WRAPPER 'header.inc' %]
24
    [% INCLUDE 'acquisitions-search.inc' %]
25
[% END %]
26
27
[% WRAPPER 'sub-header.inc' %]
28
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
29
    <ol>
30
        <li>
31
            <a href="/cgi-bin/koha/mainpage.pl">Home</a>
32
        </li>
33
        <li>
34
            <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
35
        </li>
36
        <li>
37
            <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% vendor.id | uri %]">[% vendor.name | html %]</a>
38
        </li>
39
        [% IF op == 'list' %]
40
            <li>
41
                <a href="#" aria-current="page">Issues</a>
42
            </li>
43
        [% ELSE %]
44
            <li>
45
                <a href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% vendor.id | uri %]">Issues</a>
46
            </li>
47
            <li>
48
                <a href="#" aria-current="page">
49
                    [% IF issue %]
50
                        Issue #[% issue.issue_id| html %]
51
                    [% ELSE %]
52
                        New issue
53
                    [% END %]
54
                </a>
55
            </li>
56
        [% END %]
57
    </ol>
58
</nav>
59
[% END %]
60
61
<div class="main container-fluid">
62
    <div class="row">
63
        <div class="col-sm-10 col-sm-push-2">
64
            <main>
65
66
[% FOR m IN messages %]
67
    <div class="dialog [% m.type | html %]">
68
        [% SWITCH m.code %]
69
        [% CASE 'error_on_update' %]
70
            <span>An error occurred when updating this issue.</span>
71
        [% CASE 'error_on_insert' %]
72
            <span>An error occurred when adding this issue</span>
73
        [% CASE 'error_on_delete' %]
74
            <span>An error occurred when deleting this issue. Check the logs.</span>
75
        [% CASE 'success_on_update' %]
76
            <span>Issue updated successfully.</span>
77
        [% CASE 'success_on_insert' %]
78
            <span>Issue created successfully.</span>
79
        [% CASE 'success_on_delete' %]
80
            <span>Issue deleted successfully.</span>
81
        [% CASE %]
82
            <span>[% m.code | html %]</span>
83
        [% END %]
84
    </div>
85
[% END %]
86
87
[% IF op == 'add_form' %]
88
    [% IF issue %]
89
        <h1>Modify a vendor issue</h1>
90
    [% ELSE %]
91
        <h1>New vendor issue</h1>
92
    [% END %]
93
94
    <form action="/cgi-bin/koha/acqui/vendor_issues.pl" name="Aform" method="post" class="validated">
95
        <input type="hidden" name="op" value="add_validate" />
96
        <input type="hidden" name="booksellerid" value="[% vendor.id | html %]" />
97
        <input type="hidden" name="issue_id" value="[% issue.issue_id| html %]" />
98
99
        <fieldset class="rows">
100
            <ol>
101
                [% IF issue %]
102
                    <li><span class="label">Issue ID: </span>[% issue.issue_id | html %]</li>
103
                [% END %]
104
                <li>
105
                    <label for="issue_type">Type: </label>
106
                    [% PROCESS 'av-build-dropbox.inc' name="type", category="VENDOR_ISSUE_TYPE", default=issue.type, empty=1, size = 20 %]
107
                </li>
108
                <li>
109
                    <label for="started_on">Started on: </label>
110
                    <input type="text" size="10" id="from" name="started_on" value="[% issue.started_on| html %]" class="flatpickr" data-date_to="to" />
111
                    <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
112
                </li>
113
                <li>
114
                    <label for="ended_on">Ended on: </label>
115
                    <input type="text" size="10" id="to" name="ended_on" value="[% issue.ended_on | html %]" class="flatpickr" />
116
                    <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
117
                </li>
118
                <li>
119
                    <label for="notes">Notes: </label>
120
                    <textarea name="notes" id="notes" rows="3" cols="50">[% issue.notes | html %]</textarea>
121
                </li>
122
            </ol>
123
        </fieldset>
124
125
        <fieldset class="action">
126
            <input type="submit" class="btn btn-primary" value="Submit" />
127
            <a class="cancel" href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% vendor.id | uri %]">Cancel</a>
128
        </fieldset>
129
    </form>
130
[% END %]
131
132
[% IF op == 'delete_confirm' %]
133
    <div class="dialog alert">
134
        <h1>Delete issue #[% issue.issue_id | html %]?<h1>
135
        <form action="/cgi-bin/koha/acqui/vendor_issues.pl" method="post">
136
            <input type="hidden" name="op" value="delete_confirmed" />
137
            <input type="hidden" name="issue_id" value="[% issue.issue_id | html %]" />
138
            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
139
        </form>
140
        <form action="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% vendor.id | uri %]" method="get">
141
            <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
142
        </form>
143
    </div>
144
[% END %]
145
146
[% IF op == 'show' %]
147
    <h1>Vendor issue #[% issue.issue_id | html %]</h1>
148
149
        <fieldset class="rows">
150
            <ol>
151
                [% IF issue %]
152
                    <li><span class="label">Issue ID: </span>[% issue.issue_id | html %]</li>
153
                [% END %]
154
                <li>
155
                    <label for="issue_type">Type: </label>
156
                    [% AuthorisedValues.GetByCode( 'VENDOR_ISSUE_TYPE', issue.type, 0 ) | html %]
157
                </li>
158
                <li>
159
                    <label for="started_on">Started on: </label>
160
                    [% issue.started_on | $KohaDates %]
161
                </li>
162
                <li>
163
                    <label for="ended_on">Ended on: </label>
164
                    [% issue.ended_on | $KohaDates %]
165
                </li>
166
                <li>
167
                    <label for="notes">Notes: </label>
168
                    [% issue.notes | html %]
169
                </li>
170
            </ol>
171
        </fieldset>
172
173
        <fieldset class="action">
174
            <a href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% vendor.id | uri %]">Back</a>
175
        </fieldset>
176
    </form>
177
[% END %]
178
[% IF op == 'list' %]
179
180
    <div id="toolbar" class="btn-toolbar">
181
        <a class="btn btn-default" id="new_issue" href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% vendor.id | uri %]&op=add_form"><i class="fa fa-plus"></i> New issue</a>
182
    </div>
183
184
    <h1>Vendor issues</h1>
185
186
    [% IF issues_count > 0 %]
187
        <div class="page-section">
188
            <div class="table_vendor_issues_table_controls"></div>
189
            <table id="vendor_issues">
190
                <thead>
191
                    <tr>
192
                        <th>Issue ID</th>
193
                        <th>Type</th>
194
                        <th>Started on</th>
195
                        <th>Ended on</th>
196
                        <th data-class-name="actions noExport">Actions</th>
197
                    </tr>
198
                </thead>
199
            </table>
200
        </div><!-- /.page-section -->
201
    [% ELSE %]
202
        <div class="dialog message">
203
            There are no issues defined. <a href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% vendor.id | uri %]&op=add_form">Create a new issue</a>.
204
        </div>
205
    [% END %]
206
[% END %]
207
208
            </main>
209
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
210
211
        <div class="col-sm-2 col-sm-pull-10">
212
            <aside>
213
                [% INCLUDE 'vendor-menu.inc' %]
214
            </aside>
215
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
216
     </div> <!-- /.row -->
217
218
[% MACRO jsinclude BLOCK %]
219
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
220
    [% INCLUDE 'calendar.inc' %]
221
    [% INCLUDE 'datatables.inc' %]
222
    <script>
223
224
        $(document).ready(function() {
225
            var issues_table_url = '/api/v1/acquisitions/vendors/[% vendor.id | uri %]/issues?';
226
227
            var issues_table = $("#vendor_issues").kohaTable({
228
                ajax: {
229
                    url: issues_table_url
230
                },
231
                embed: ["+strings"],
232
                order: [[ 0, "desc" ]],
233
                columns: [
234
                    {
235
                        data: "issue_id",
236
                        searchable: true,
237
                        orderable: true,
238
                        render: function(data, type, row, meta) {
239
                            return '<a href="/cgi-bin/koha/acqui/vendor_issues.pl?op=show&amp;issue_id=' + encodeURIComponent(row.issue_id) +'">' + escape_str(row.issue_id) + '</a>';
240
                        },
241
                    },
242
                    {
243
                        data: "type",
244
                        searchable: true,
245
                        orderable: true,
246
                        render: function(data, type, row, meta) {
247
                            return row._strings.type ? escape_str(row._strings.type.str) : "";
248
                        }
249
                    },
250
                    {
251
                        data: "started_on",
252
                        searchable: true,
253
                        orderable: true,
254
                        render: function(data, type, row, meta) {
255
                            return $date(row.started_on);
256
                        }
257
                    },
258
                    {
259
                        data: "ended_on",
260
                        searchable: true,
261
                        orderable: true,
262
                        render: function(data, type, row, meta) {
263
                            return $date(row.ended_on);
264
                        }
265
                    },
266
                    {
267
                        data: function( row, type, val, meta ) {
268
269
                            var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/acqui/vendor_issues.pl?op=add_form&amp;issue_id='+ encodeURIComponent(row.issue_id) +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n";
270
                            result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/acqui/vendor_iddues.pl?op=delete_confirm&amp;issue_id='+ encodeURIComponent(row.issue_id) +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</a>';
271
                            return result;
272
                        },
273
                        searchable: false,
274
                        orderable: false
275
                    }
276
                ]
277
            }, null, 1);
278
279
        });
280
    </script>
281
[% END %]
282
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-1 / +2 lines)
Lines 589-594 Link Here
589
            <p>Values that can be entered to fill in the 'Vendor type' field in the acquisitions module, that can be used for statistical purposes</p>
589
            <p>Values that can be entered to fill in the 'Vendor type' field in the acquisitions module, that can be used for statistical purposes</p>
590
        [% CASE 'VENDOR_INTERFACE_TYPE' %]
590
        [% CASE 'VENDOR_INTERFACE_TYPE' %]
591
            <p>Values that can be entered to fill in the 'Vendor interface type' field in the acquisitions module</p>
591
            <p>Values that can be entered to fill in the 'Vendor interface type' field in the acquisitions module</p>
592
        [% CASE 'VENDOR_ISSUE_TYPE' %]
593
            <p>Values that can be entered to fill in the 'Vendor issue type' field in the acquisitions module</p>
592
        [% CASE 'WITHDRAWN' %]
594
        [% CASE 'WITHDRAWN' %]
593
            <p>Description of a withdrawn item (appears when adding or editing an item)</p>
595
            <p>Description of a withdrawn item (appears when adding or editing an item)</p>
594
        [% CASE 'YES_NO' %]
596
        [% CASE 'YES_NO' %]
595
- 

Return to bug 33105