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

(-)a/Koha/MarcOrderAccount.pm (+63 lines)
Line 0 Link Here
1
package Koha::MarcOrderAccount;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
22
use base qw(Koha::Object);
23
24
=head1 NAME
25
26
Koha::MarcOrderAccount - Koha Marc Ordering Account Object class
27
28
=head1 API
29
30
=head2 Class Methods
31
32
=cut
33
34
=head3 vendor
35
36
=cut
37
38
sub vendor {
39
    my ( $self ) = @_;
40
    my $vendor_rs = $self->_result->vendor;
41
    return unless $vendor_rs;
42
    return Koha::Acquisition::Bookseller->_new_from_dbic($vendor_rs);
43
}
44
45
=head3 budget
46
47
=cut
48
49
sub budget {
50
    my ( $self )  = @_;
51
    my $budget_rs = $self->_result->budget;
52
    return Koha::Acquisition::Fund->_new_from_dbic( $budget_rs );
53
}
54
55
=head3 _type
56
57
=cut
58
59
sub _type {
60
    return 'MarcOrderAccount';
61
}
62
63
1;
(-)a/Koha/MarcOrderAccounts.pm (+51 lines)
Line 0 Link Here
1
package Koha::MarcOrderAccounts;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
use Koha::MarcOrderAccount;
22
23
use base qw(Koha::Objects);
24
25
=head1 NAME
26
27
Koha::MarcOrderAccount - Koha Marc Ordering Account Object class
28
29
=head1 API
30
31
=head2 Class Methods
32
33
=cut
34
35
=head3 type
36
37
=cut
38
39
sub _type {
40
    return 'MarcOrderAccount';
41
}
42
43
=head3 object_class
44
45
=cut
46
47
sub object_class {
48
    return 'Koha::MarcOrderAccount';
49
}
50
51
1;
(-)a/admin/marc_order_accounts.pl (+132 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# A script that allows the user to create an account and profile for auto-creating orders from imported marc files
4
# The script displays account details and allows account creation/editing in the first instance
5
# If the "run" operation is passed then the script will run the process of creating orders
6
7
# Copyright 2023 PTFS Europe Ltd
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it
12
# under the terms of the GNU General Public License as published by
13
# the Free Software Foundation; either version 3 of the License, or
14
# (at your option) any later version.
15
#
16
# Koha is distributed in the hope that it will be useful, but
17
# WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
20
#
21
# You should have received a copy of the GNU General Public License
22
# along with Koha; if not, see <http://www.gnu.org/licenses>.
23
24
use Modern::Perl;
25
use CGI qw ( -utf8 );
26
27
use C4::Context;
28
use C4::Auth qw( get_template_and_user );
29
use C4::Budgets qw( GetBudgets );
30
use C4::Output qw( output_html_with_http_headers );
31
use C4::Matcher;
32
33
use Koha::UploadedFiles;
34
use Koha::ImportBatchProfiles;
35
use Koha::MarcOrder;
36
use Koha::Acquisition::Booksellers;
37
use Koha::MarcOrderAccount;
38
use Koha::MarcOrderAccounts;
39
40
my $input = CGI->new;
41
42
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43
    {
44
        template_name   => "admin/marc_order_accounts.tt",
45
        query           => $input,
46
        type            => "intranet",
47
    }
48
);
49
50
my $crypt = Koha::Encryption->new;
51
52
my $op = $input->param('op');
53
$op ||= 'display';
54
55
if( $op eq 'acct_form') {
56
    $template->param( acct_form => 1 );
57
    my @vendors = Koha::Acquisition::Booksellers->search(
58
        undef,
59
        {
60
            columns => [ 'name', 'id' ],
61
            order_by => { -asc => 'name' }
62
        }
63
    )->as_list;
64
    my $budgets = GetBudgets();
65
    $template->param(
66
        vendors => \@vendors,
67
        budgets => $budgets
68
    );
69
    my @matchers = C4::Matcher::GetMatcherList();
70
    $template->param( available_matchers => \@matchers );
71
72
    show_account($input, $template);
73
} elsif ( $op eq 'delete_acct' ) {
74
    show_account($input, $template);
75
    $template->param( delete_acct => 1);
76
} else {
77
    if( $op eq 'save' ) {
78
79
        my $fields = {
80
            id                 => scalar $input->param('id'),
81
            description        => scalar $input->param('description'),
82
            vendor_id          => scalar $input->param('vendor_id'),
83
            budget_id          => scalar $input->param('budget_id'),
84
            download_directory => scalar $input->param('download_directory'),
85
            matcher_id         => scalar $input->param('matcher'),
86
            overlay_action     => scalar $input->param('overlay_action'),
87
            nomatch_action     => scalar $input->param('nomatch_action'),
88
            parse_items        => scalar $input->param('parse_items'),
89
            item_action        => scalar $input->param('item_action'),
90
            record_type        => scalar $input->param('record_type'),
91
            encoding           => scalar $input->param('encoding') || 'UTF-8',
92
        };
93
94
        if(scalar $input->param('id')) {
95
            # Update existing account
96
            my $account = Koha::MarcOrderAccounts->find(scalar $input->param('id'));
97
            $account->update($fields);
98
        } else {
99
            # Add new account
100
            my $new_account = Koha::MarcOrderAccount->new($fields);
101
            $new_account->store;
102
        }
103
    } elsif ($op eq 'delete_confirmed') {
104
        my $acct_id = $input->param('id');
105
        my $acct = Koha::MarcOrderAccounts->find($acct_id);
106
        $acct->delete;
107
    }
108
109
    $template->param( display => 1 );
110
    my @accounts = Koha::MarcOrderAccounts->search(
111
        {},
112
        {
113
            join => ['vendor', 'budget']
114
        }
115
    )->as_list;
116
    $template->param( accounts => \@accounts );
117
118
}
119
120
output_html_with_http_headers $input, $cookie, $template->output;
121
122
sub show_account {
123
    my ($input, $template) = @_;
124
    my $acct_id = $input->param('id');
125
    if ($acct_id) {
126
        my $acct = Koha::MarcOrderAccounts->find($acct_id);
127
        if ($acct) {
128
            $template->param( account => $acct );
129
        }
130
    }
131
    return;
132
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_order_accounts.tt (-1 / +246 lines)
Line 0 Link Here
0
- 
1
[% USE raw %]
2
[% USE Koha %]
3
[% USE Asset %]
4
[% PROCESS 'i18n.inc' %]
5
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
<title>
8
MARC Order Accounts
9
</title>
10
<style>
11
    #fileuploadstatus,#fileuploadfailed,#fileuploadcancel { display : none; }
12
</style>
13
[% INCLUDE 'doc-head-close.inc' %]
14
</head>
15
<body id="admin_marc_order_acct" class="admin">
16
[% WRAPPER 'header.inc' %]
17
    [% INCLUDE 'prefs-admin-search.inc' %]
18
[% END %]
19
20
[% WRAPPER 'sub-header.inc' %]
21
    [% WRAPPER breadcrumbs %]
22
        [% WRAPPER breadcrumb_item %]
23
            <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
24
        [% END %]
25
26
        [% IF acct_form || delete_confirm %]
27
            [% WRAPPER breadcrumb_item %]
28
                <a href="/cgi-bin/koha/admin/marc_order_accounts.pl">MARC Order Accounts</a>
29
            [% END %]
30
        [% ELSE %]
31
            [% WRAPPER breadcrumb_item bc_active= 1 %]
32
                <span>MARC Order Accounts</span>
33
            [% END %]
34
        [% END %]
35
    [% END #/ WRAPPER breadcrumbs %]
36
[% END #/ WRAPPER sub-header.inc %]
37
38
<div class="main container-fluid">
39
    <div class="row">
40
        <div class="col-sm-10 col-sm-push-2">
41
            <main>
42
                [% IF display %]
43
                    <div id="toolbar" class="btn-toolbar">
44
                    <a class="btn btn-default" id="newmarcorderacct" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=acct_form">
45
                        <i class="fa fa-plus"></i>
46
                        New account
47
                    </a>
48
                    </div>
49
                    [% IF ( accounts ) %]
50
                        <h1>Marc Ordering Accounts</h1>
51
                        <div class="page-section">
52
                            <table>
53
                                <tr>
54
                                    <th>ID</th>
55
                                    <th>Vendor</th>
56
                                    <th>Budget</th>
57
                                    <th>Description</th>
58
                                    <th>Download directory</th>
59
                                    <th>Actions</th>
60
                                </tr>
61
                                [% FOREACH account IN accounts %]
62
                                    <tr>
63
                                        <td>[% account.id | html %]</td>
64
                                        <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% account.vendor_id | uri %]">[% account.vendor.name | html %]</a></td>
65
                                        <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% account.budget.budget_period_id | uri %]">[% account.budget.budget_name | html %]</a></td>
66
                                        <td>[% account.description | html %]</td>
67
                                        <td>[% account.download_directory | html %]</td>
68
                                        <td class="actions">
69
                                            <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=acct_form&id=[% account.id | html %]"><i class="fa fa-pencil-alt"></i> Edit</a>
70
                                            <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=delete_acct&id=[% account.id | html %]"><i class="fa fa-trash-can"></i> Delete</a>
71
                                        </td>
72
                                    </tr>
73
                                [% END %]
74
                            </table>
75
                        </div>
76
                    [% ELSE %]
77
                        <div class="dialog message">
78
                            There are no MARC Order accounts.
79
                        </div>
80
                    [% END %]
81
                [% END %]
82
                [% IF acct_form %]
83
                    <h1>
84
                        [% IF account %]
85
                            Modify account
86
                        [% ELSE %]
87
                            New account
88
                        [% END %]
89
                    </h1>
90
                    <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" name="Actform" method="post">
91
                        <input type="hidden" name="op" value="save" />
92
                        [% IF account %]
93
                        <input type="hidden" name="id" value="[% account.id | html %]" />
94
                        [% END %]
95
                        <fieldset class="rows">
96
                            <legend>Account details</legend>
97
                            <ol>
98
                                <li>
99
                                    <label for="vendor_id">Vendor: </label>
100
                                    <select name="vendor_id" id="vendor_id">
101
                                        [% FOREACH vendor IN vendors %]
102
                                            [% IF account.vendor_id == vendor.id %]
103
                                                <option value="[% vendor.id | html %]" selected="selected">[% vendor.name | html %]</option>
104
                                            [% ELSE %]
105
                                                <option value="[% vendor.id | html %]">[% vendor.name | html %]</option>
106
                                            [% END %]
107
                                        [% END %]
108
                                    </select>
109
                                </li>
110
                                <li>
111
                                    <label for="budget_id">Budget: </label>
112
                                    <select name="budget_id" id="budget_id">
113
                                        [% FOREACH budget IN budgets %]
114
                                            [% IF account.budget_id == budget.budget_id %]
115
                                                <option value="[% budget.budget_id | html %]" selected="selected">[% budget.budget_name | html %]</option>
116
                                            [% ELSE %]
117
                                                <option value="[% budget.budget_id | html %]">[% budget.budget_name | html %]</option>
118
                                            [% END %]
119
                                        [% END %]
120
                                    </select>
121
                                    <div class="hint">This budget will be used as the fallback value if the MARC records do not contain a mapped value for a budget code.</div>
122
                                </li>
123
                                <li>
124
                                    <label for="description">Description: </label>
125
                                    <input type="text" name="description" id="description" size="20" value="[% account.description | html %]" />
126
                                </li>
127
                                <li>
128
                                    <label for="download_directory">Download directory: </label>
129
                                    <input type="text" name="download_directory" id="download_directory" size="20" value="[% account.download_directory | html %]" />
130
                                    <div class="hint">The download directory specifies the directory in your koha installation that should be searched for new files.</div>
131
                                </li>
132
                            </ol>
133
                        </fieldset>
134
                        <fieldset class="rows">
135
                            <legend>File import settings</legend>
136
                            <ol>
137
                                <li>
138
                                        <label for='record_type'>Record type:</label>
139
                                        <select name='record_type' id='record_type'>
140
                                            <option value='biblio' selected='selected'>Bibliographic</option>
141
                                            <option value='auth'>Authority</option>
142
                                        </select>
143
                                    </li>
144
                                    <li>
145
                                        <label for="encoding">Character encoding: </label>
146
                                        <select name="encoding" id="encoding">
147
                                            <option value="UTF-8" selected="selected">UTF-8 (Default)</option>
148
                                            <option value="MARC-8">MARC 8</option>
149
                                            <option value="ISO_5426">ISO 5426</option>
150
                                            <option value="ISO_6937">ISO 6937</option>
151
                                            <option value="ISO_8859-1">ISO 8859-1</option>
152
                                            <option value="EUC-KR">EUC-KR</option>
153
                                        </select>
154
                                    </li>
155
                            </ol>
156
                        </fieldset>
157
                        <fieldset class="rows">
158
                            <legend>Record matching settings</legend>
159
                            <ol>
160
                                <li>
161
                                    <label for="matcher">Record matching rule:</label>
162
                                    <select name="matcher" id="matcher">
163
                                        [% FOREACH available_matcher IN available_matchers %]
164
                                            [% IF available_matcher.id == account.matcher_id %]
165
                                                <option value="[% available_matcher.matcher_id | html %]" selected="selected">[% available_matcher.code | html %] ([% available_matcher.description | html %])</option>
166
                                            [% ELSE %]
167
                                                <option value="[% available_matcher.matcher_id | html %]">[% available_matcher.code | html %] ([% available_matcher.description | html %])</option>
168
                                            [% END %]
169
                                        [% END %]
170
                                    </select>
171
                                </li>
172
                                <li>
173
                                    <label for="overlay_action">Action if matching record found: </label>
174
                                    [% INCLUDE 'tools-overlay-action.inc' %]
175
                                </li>
176
                                <li>
177
                                    <label for="nomatch_action">Action if no match is found: </label>
178
                                    [% INCLUDE 'tools-nomatch-action.inc' %]
179
                                </li>
180
                            </ol>
181
                        </fieldset>
182
                        <fieldset class="rows" id="items">
183
                            <legend>Check for embedded item record data?</legend>
184
                            <ol>
185
                                <li class="radio">
186
                                    <input type="radio" id="parse_itemsyes" name="parse_items" value="1" checked="checked" />
187
                                    <label for="parse_itemsyes">Yes</label>
188
                                </li>
189
                                <li class="radio">
190
                                    <input type="radio" id="parse_itemsno" name="parse_items" value="0" />
191
                                    <label for="parse_itemsno">No</label>
192
                                </li>
193
                            </ol>
194
                            <ol>
195
                                <li><label for="item_action">How to process items: </label>
196
                                    [% INCLUDE 'tools-item-action.inc' %]
197
                                </li>
198
                            </ol>
199
                        </fieldset>
200
201
                        <fieldset class="action">
202
                            <input type="submit" class="btn btn-primary" value="Submit" />
203
                            <a href="/cgi-bin/koha/admin/marc_order_accounts.pl" class="cancel">Cancel</a>
204
                        </fieldset>
205
                    </form>
206
                [% END %]
207
                [% IF delete_acct %]
208
                    <div class="dialog alert">
209
                        <h1>Delete this account?</h1>
210
                        <table>
211
                            <tr>
212
                                <th>Vendor</th>
213
                                <th>Description</th>
214
                            </tr>
215
                            <tr>
216
                                <td>[% account.vendor.name | html %]</td>
217
                                <td>[% account.description | html %]</td>
218
                            </tr>
219
                            <tr>
220
                        </table>
221
                        <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" method="post">
222
                            <table>
223
                            </table>
224
                            <input type="hidden" name="op" value="delete_confirmed" />
225
                            <input type="hidden" name="id" value="[% account.id | html %]" />
226
                            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
227
                        </form>
228
                        <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" method="get">
229
                            <button type="submit" class="deny"><i class="fa fa-fw fa-times"></i> No, do not delete</button>
230
                        </form>
231
                    </div>
232
                [% END %]
233
            </main>
234
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
235
236
        <div class="col-sm-2 col-sm-pull-10">
237
            <aside>
238
                [% INCLUDE 'admin-menu.inc' %]
239
            </aside>
240
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
241
     </div> <!-- /.row -->
242
243
[% MACRO jsinclude BLOCK %]
244
    [% Asset.js("js/admin-menu.js") | $raw %]
245
[% END %]
246
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 34355