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

(-)a/Koha/ImportBatch.pm (-2 / +1 lines)
Lines 75-81 sub new_from_file { Link Here
75
    my $basket_id                  = $args->{basket_id};
75
    my $basket_id                  = $args->{basket_id};
76
    my $profile_id                 = $args->{profile_id};
76
    my $profile_id                 = $args->{profile_id};
77
77
78
    my @messages;
79
    my ( $batch_id, $num_valid, $num_items, @import_errors );
78
    my ( $batch_id, $num_valid, $num_items, @import_errors );
80
    my $num_with_matches = 0;
79
    my $num_with_matches = 0;
81
    my $checked_matches  = 0;
80
    my $checked_matches  = 0;
Lines 172-178 sub new_from_file { Link Here
172
        basket_id       => $basket_id,
171
        basket_id       => $basket_id,
173
    };
172
    };
174
173
175
    return { report => $report, messages => \@messages };
174
    return { report => $report };
176
}
175
}
177
176
178
=head3 _type
177
=head3 _type
(-)a/Koha/Schema/Result/MarcOrderAccount.pm (+9 lines)
Lines 237-241 __PACKAGE__->add_columns( Link Here
237
    '+parse_items' => { is_boolean => 1 },
237
    '+parse_items' => { is_boolean => 1 },
238
);
238
);
239
239
240
sub koha_object_class {
241
    'Koha::Acquisition::MarcOrderAccount';
242
}
243
244
sub koha_objects_class {
245
    'Koha::Acquisition::MarcOrderAccounts';
246
}
247
248
240
# You can replace this text with custom code or comments, and it will be preserved on regeneration
249
# You can replace this text with custom code or comments, and it will be preserved on regeneration
241
1;
250
1;
(-)a/admin/marc_order_accounts.pl (-16 / +34 lines)
Lines 48-69 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
48
    }
48
    }
49
);
49
);
50
50
51
my $crypt = Koha::Encryption->new;
52
53
my $op = $input->param('op');
51
my $op = $input->param('op');
54
$op ||= 'display';
52
$op ||= 'list';
53
my @messages;
55
54
56
if ( $op eq 'acct_form' ) {
55
if ( $op eq 'add_form' ) {
57
    $template->param( acct_form => 1 );
56
    $op = 'add_form';
58
    my $budgets = GetBudgets();
57
    my $budgets = GetBudgets();
59
    $template->param( budgets => $budgets );
58
    $template->param( budgets => $budgets );
60
    my @matchers = C4::Matcher::GetMatcherList();
59
    my @matchers = C4::Matcher::GetMatcherList();
61
    $template->param( available_matchers => \@matchers );
60
    $template->param( available_matchers => \@matchers );
62
61
63
    show_account( $input, $template );
62
    show_account( $input, $template );
64
} elsif ( $op eq 'delete_acct' ) {
63
} elsif ( $op eq 'delete_confirm' ) {
65
    show_account( $input, $template );
64
    show_account( $input, $template );
66
    $template->param( delete_acct => 1 );
65
    $op = 'delete_confirm';
67
} else {
66
} else {
68
    if ( $op eq 'cud-save' ) {
67
    if ( $op eq 'cud-save' ) {
69
        my $fields = {
68
        my $fields = {
Lines 87-108 if ( $op eq 'acct_form' ) { Link Here
87
        if ( scalar $input->param('id') ) {
86
        if ( scalar $input->param('id') ) {
88
87
89
            # Update existing account
88
            # Update existing account
90
            my $account = Koha::MarcOrderAccounts->find( scalar $input->param('id') );
89
            my $account = Koha::Acquisition::MarcOrderAccounts->find( scalar $input->param('id') );
91
            $account->update($fields);
90
            eval { $account->update($fields); };
91
            if ($@) {
92
                push @messages, { type => 'error', code => 'error_on_update' };
93
            } else {
94
                push @messages, { type => 'message', code => 'success_on_update' };
95
            }
96
92
        } else {
97
        } else {
93
98
94
            # Add new account
99
            # Add new account
95
            my $new_account = Koha::MarcOrderAccount->new($fields);
100
            my $new_account = Koha::Acquisition::MarcOrderAccount->new($fields);
96
            $new_account->store;
101
            eval { $new_account->store; };
102
            if ($@) {
103
                push @messages, { type => 'error', code => 'error_on_insert' };
104
            } else {
105
                push @messages, { type => 'message', code => 'success_on_insert' };
106
            }
107
97
        }
108
        }
98
    } elsif ( $op eq 'cud-delete_acct' ) {
109
        $op = 'list';
110
    } elsif ( $op eq 'cud-delete_confirmed' ) {
99
        my $acct_id = $input->param('id');
111
        my $acct_id = $input->param('id');
100
        my $acct    = Koha::MarcOrderAccounts->find($acct_id);
112
        my $acct    = Koha::Acquisition::MarcOrderAccounts->find($acct_id);
101
        $acct->delete;
113
        my $deleted = eval { $acct->delete; };
114
115
        if ( $@ or not $deleted ) {
116
            push @messages, { type => 'error', code => 'error_on_delete' };
117
        } else {
118
            push @messages, { type => 'message', code => 'success_on_delete' };
119
        }
120
        $op = 'list';
102
    }
121
    }
103
122
104
    $template->param( display => 1 );
123
    my @accounts = Koha::Acquisition::MarcOrderAccounts->search(
105
    my @accounts = Koha::MarcOrderAccounts->search(
106
        {},
124
        {},
107
        { join => [ 'vendor', 'budget' ] }
125
        { join => [ 'vendor', 'budget' ] }
108
    )->as_list;
126
    )->as_list;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_order_accounts.tt (-12 / +47 lines)
Lines 22-44 Link Here
22
            [% END %]
22
            [% END %]
23
        [% END %]
23
        [% END %]
24
24
25
        [% IF acct_form || delete_confirm %]
25
        [% IF op == 'add_form' %]
26
            [% WRAPPER breadcrumb_item %]
26
            [% WRAPPER breadcrumb_item %]
27
                <a href="/cgi-bin/koha/admin/marc_order_accounts.pl">MARC order accounts</a>
27
                <a href="/cgi-bin/koha/admin/marc_order_accounts.pl">MARC order accounts</a>
28
            [% END %]
28
            [% END %]
29
            [% WRAPPER breadcrumb_item bc_active = 1 %]
30
                [% IF account.id %]
31
                    [% tx("Modify account '{account}'", { account = account.id }) | html %]
32
                [% ELSE %]
33
                    <span>New account</span>
34
                [% END %]
35
            [% END %]
36
        [% ELSIF op == 'delete_confirm' %]
37
            [% WRAPPER breadcrumb_item %]
38
                <a href="/cgi-bin/koha/admin/marc_order_accounts.pl">MARC order accounts</a>
39
            [% END %]
40
            [% WRAPPER breadcrumb_item bc_active = 1 %]
41
                [% tx("Confirm deletion of account '{account}'", { account = account.id }) | html %]
42
            [% END %]
29
        [% ELSE %]
43
        [% ELSE %]
30
            [% WRAPPER breadcrumb_item bc_active= 1 %]
44
            [% WRAPPER breadcrumb_item bc_active = 1 %]
31
                <span>MARC order accounts</span>
45
                <span>MARC order accounts</span>
32
            [% END %]
46
            [% END %]
33
        [% END %]
47
        [% END #/IF op = add_form %]
34
    [% END #/ WRAPPER breadcrumbs %]
48
    [% END #/ WRAPPER breadcrumbs %]
35
[% END #/ WRAPPER sub-header.inc %]
49
[% END #/ WRAPPER sub-header.inc %]
36
50
37
[% WRAPPER 'main-container.inc' aside='admin-menu' %]
51
[% WRAPPER 'main-container.inc' aside='admin-menu' %]
52
    [% FOR m IN messages %]
53
        <div class="alert alert-[% m.type | html %]">
54
            [% SWITCH m.code %]
55
            [% CASE 'error_on_update' %]
56
                <span>An error occurred when updating this account. Perhaps it already exists.</span>
57
            [% CASE 'error_on_insert' %]
58
                <span>An error occurred when adding this account. The account ID might already exist.</span>
59
            [% CASE 'error_on_delete' %]
60
                <span>An error occurred when deleting this account. Check the logs for details.</span>
61
            [% CASE 'success_on_update' %]
62
                <span>Account updated successfully.</span>
63
            [% CASE 'success_on_insert' %]
64
                <span>Account added successfully.</span>
65
            [% CASE 'success_on_delete' %]
66
                <span>Account deleted successfully.</span>
67
            [% CASE 'already_exists' %]
68
                <span>This account already exists.</span>
69
            [% CASE %]
70
                <span>[% m.code | html %]</span>
71
            [% END %]
72
        </div>
73
    [% END %]
38
74
39
    [% IF display %]
75
    [% IF op == 'list' %]
40
        <div id="toolbar" class="btn-toolbar">
76
        <div id="toolbar" class="btn-toolbar">
41
            <a class="btn btn-default" id="newmarcorderacct" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=acct_form">
77
            <a class="btn btn-default" id="newmarcorderacct" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=add_form">
42
                <i class="fa fa-plus"></i>
78
                <i class="fa fa-plus"></i>
43
                New account
79
                New account
44
            </a>
80
            </a>
Lines 63-70 Link Here
63
                            <td>[% account.description | html %]</td>
99
                            <td>[% account.description | html %]</td>
64
                            <td>[% account.download_directory | html %]</td>
100
                            <td>[% account.download_directory | html %]</td>
65
                            <td class="actions">
101
                            <td class="actions">
66
                                <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>
102
                                <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=add_form&id=[% account.id | html %]"><i class="fa fa-pencil-alt"></i> Edit</a>
67
                                <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>
103
                                <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=delete_confirm&id=[% account.id | html %]"><i class="fa fa-trash-can"></i> Delete</a>
68
                            </td>
104
                            </td>
69
                        </tr>
105
                        </tr>
70
                    [% END %]
106
                    [% END %]
Lines 74-80 Link Here
74
            <div class="dialog message"> There are no MARC order accounts. </div>
110
            <div class="dialog message"> There are no MARC order accounts. </div>
75
        [% END %]
111
        [% END %]
76
    [% END %]
112
    [% END %]
77
    [% IF acct_form %]
113
    [% IF op == 'add_form' %]
78
        <h1>
114
        <h1>
79
            [% IF account %]
115
            [% IF account %]
80
                Modify account
116
                Modify account
Lines 257-264 Link Here
257
            </fieldset>
293
            </fieldset>
258
        </form>
294
        </form>
259
    [% END %]
295
    [% END %]
260
    [% IF delete_acct %]
296
    [% IF op == 'delete_confirm' %]
261
        <div class="dialog alert">
297
        <div class="alert alert-warning">
262
            <h1>Delete this account?</h1>
298
            <h1>Delete this account?</h1>
263
            <table>
299
            <table>
264
                <tr>
300
                <tr>
Lines 272-278 Link Here
272
            </table>
308
            </table>
273
            <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" method="post">
309
            <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" method="post">
274
                [% INCLUDE 'csrf-token.inc' %]
310
                [% INCLUDE 'csrf-token.inc' %]
275
                <input type="hidden" name="op" value="cud-delete_acct" />
311
                <input type="hidden" name="op" value="cud-delete_confirmed" />
276
                <input type="hidden" name="id" value="[% account.id | html %]" />
312
                <input type="hidden" name="id" value="[% account.id | html %]" />
277
                <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
313
                <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
278
            </form>
314
            </form>
279
- 

Return to bug 38547