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
177
(-)a/Koha/Schema/Result/MarcOrderAccount.pm (+9 lines)
Lines 227-231 __PACKAGE__->add_columns( Link Here
227
    '+parse_items' => { is_boolean => 1 },
227
    '+parse_items' => { is_boolean => 1 },
228
);
228
);
229
229
230
sub koha_object_class {
231
    'Koha::Acquisition::MarcOrderAccount';
232
}
233
234
sub koha_objects_class {
235
    'Koha::Acquisition::MarcOrderAccounts';
236
}
237
238
230
# You can replace this text with custom code or comments, and it will be preserved on regeneration
239
# You can replace this text with custom code or comments, and it will be preserved on regeneration
231
1;
240
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 86-107 if ( $op eq 'acct_form' ) { Link Here
86
        if ( scalar $input->param('id') ) {
85
        if ( scalar $input->param('id') ) {
87
86
88
            # Update existing account
87
            # Update existing account
89
            my $account = Koha::MarcOrderAccounts->find( scalar $input->param('id') );
88
            my $account = Koha::Acquisition::MarcOrderAccounts->find( scalar $input->param('id') );
90
            $account->update($fields);
89
            eval { $account->update($fields); };
90
            if ($@) {
91
                push @messages, { type => 'error', code => 'error_on_update' };
92
            } else {
93
                push @messages, { type => 'message', code => 'success_on_update' };
94
            }
95
91
        } else {
96
        } else {
92
97
93
            # Add new account
98
            # Add new account
94
            my $new_account = Koha::MarcOrderAccount->new($fields);
99
            my $new_account = Koha::Acquisition::MarcOrderAccount->new($fields);
95
            $new_account->store;
100
            eval { $new_account->store; };
101
            if ($@) {
102
                push @messages, { type => 'error', code => 'error_on_insert' };
103
            } else {
104
                push @messages, { type => 'message', code => 'success_on_insert' };
105
            }
106
96
        }
107
        }
97
    } elsif ( $op eq 'cud-delete_acct' ) {
108
        $op = 'list';
109
    } elsif ( $op eq 'cud-delete_confirmed' ) {
98
        my $acct_id = $input->param('id');
110
        my $acct_id = $input->param('id');
99
        my $acct    = Koha::MarcOrderAccounts->find($acct_id);
111
        my $acct    = Koha::Acquisition::MarcOrderAccounts->find($acct_id);
100
        $acct->delete;
112
        my $deleted = eval { $acct->delete; };
113
114
        if ( $@ or not $deleted ) {
115
            push @messages, { type => 'error', code => 'error_on_delete' };
116
        } else {
117
            push @messages, { type => 'message', code => 'success_on_delete' };
118
        }
119
        $op = 'list';
101
    }
120
    }
102
121
103
    $template->param( display => 1 );
122
    my @accounts = Koha::Acquisition::MarcOrderAccounts->search(
104
    my @accounts = Koha::MarcOrderAccounts->search(
105
        {},
123
        {},
106
        { join => [ 'vendor', 'budget' ] }
124
        { join => [ 'vendor', 'budget' ] }
107
    )->as_list;
125
    )->as_list;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_order_accounts.tt (-11 / +50 lines)
Lines 24-38 MARC order accounts Link Here
24
            [% END %]
24
            [% END %]
25
        [% END %]
25
        [% END %]
26
26
27
        [% IF acct_form || delete_confirm %]
27
        [% IF op == 'add_form' %]
28
            [% WRAPPER breadcrumb_item %]
28
            [% WRAPPER breadcrumb_item %]
29
                <a href="/cgi-bin/koha/admin/marc_order_accounts.pl">MARC order accounts</a>
29
                <a href="/cgi-bin/koha/admin/marc_order_accounts.pl">MARC order accounts</a>
30
            [% END %]
30
            [% END %]
31
            [% WRAPPER breadcrumb_item bc_active = 1 %]
32
                [% IF account.id %]
33
                    [% tx("Modify account '{account}'", { account = account.id }) | html %]
34
                [% ELSE %]
35
                    <span>New account</span>
36
                [% END %]
37
            [% END %]
38
39
        [% ELSIF op == 'delete_confirm' %]
40
            [% WRAPPER breadcrumb_item %]
41
                <a href="/cgi-bin/koha/admin/marc_order_accounts.pl">MARC order accounts</a>
42
            [% END %]
43
            [% WRAPPER breadcrumb_item bc_active = 1 %]
44
                [% tx("Confirm deletion of account '{account}'", { account = account.id }) | html %]
45
            [% END %]
46
31
        [% ELSE %]
47
        [% ELSE %]
32
            [% WRAPPER breadcrumb_item bc_active= 1 %]
48
            [% WRAPPER breadcrumb_item bc_active = 1 %]
33
                <span>MARC order accounts</span>
49
                <span>MARC order accounts</span>
34
            [% END %]
50
            [% END %]
35
        [% END %]
51
        [% END #/IF op = add_form %]
36
    [% END #/ WRAPPER breadcrumbs %]
52
    [% END #/ WRAPPER breadcrumbs %]
37
[% END #/ WRAPPER sub-header.inc %]
53
[% END #/ WRAPPER sub-header.inc %]
38
54
Lines 41-49 MARC order accounts Link Here
41
        <div class="col-md-10 order-md-2 order-sm-1">
57
        <div class="col-md-10 order-md-2 order-sm-1">
42
            <main>
58
            <main>
43
                [% INCLUDE 'messages.inc' %]
59
                [% INCLUDE 'messages.inc' %]
44
                [% IF display %]
60
61
                [% FOR m IN messages %]
62
                    <div class="alert alert-[% m.type | html %]">
63
                        [% SWITCH m.code %]
64
                        [% CASE 'error_on_update' %]
65
                            <span>An error occurred when updating this account. Perhaps it already exists.</span>
66
                        [% CASE 'error_on_insert' %]
67
                            <span>An error occurred when adding this account. The account ID might already exist.</span>
68
                        [% CASE 'error_on_delete' %]
69
                            <span>An error occurred when deleting this account. Check the logs for details.</span>
70
                        [% CASE 'success_on_update' %]
71
                            <span>Account updated successfully.</span>
72
                        [% CASE 'success_on_insert' %]
73
                            <span>Account added successfully.</span>
74
                        [% CASE 'success_on_delete' %]
75
                            <span>Account deleted successfully.</span>
76
                        [% CASE 'already_exists' %]
77
                            <span>This account already exists.</span>
78
                        [% CASE %]
79
                            <span>[% m.code | html %]</span>
80
                        [% END %]
81
                    </div>
82
                [% END %]
83
84
                [% IF op == 'list' %]
45
                    <div id="toolbar" class="btn-toolbar">
85
                    <div id="toolbar" class="btn-toolbar">
46
                    <a class="btn btn-default" id="newmarcorderacct" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=acct_form">
86
                    <a class="btn btn-default" id="newmarcorderacct" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=add_form">
47
                        <i class="fa fa-plus"></i>
87
                        <i class="fa fa-plus"></i>
48
                        New account
88
                        New account
49
                    </a>
89
                    </a>
Lines 68-75 MARC order accounts Link Here
68
                                        <td>[% account.description | html %]</td>
108
                                        <td>[% account.description | html %]</td>
69
                                        <td>[% account.download_directory | html %]</td>
109
                                        <td>[% account.download_directory | html %]</td>
70
                                        <td class="actions">
110
                                        <td class="actions">
71
                                            <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>
111
                                            <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>
72
                                            <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>
112
                                            <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>
73
                                        </td>
113
                                        </td>
74
                                    </tr>
114
                                    </tr>
75
                                [% END %]
115
                                [% END %]
Lines 81-87 MARC order accounts Link Here
81
                        </div>
121
                        </div>
82
                    [% END %]
122
                    [% END %]
83
                [% END %]
123
                [% END %]
84
                [% IF acct_form %]
124
                [% IF op == 'add_form' %]
85
                    <h1>
125
                    <h1>
86
                        [% IF account %]
126
                        [% IF account %]
87
                            Modify account
127
                            Modify account
Lines 261-267 MARC order accounts Link Here
261
                        </fieldset>
301
                        </fieldset>
262
                    </form>
302
                    </form>
263
                [% END %]
303
                [% END %]
264
                [% IF delete_acct %]
304
                [% IF op == 'delete_confirm' %]
265
                    <div class="dialog alert">
305
                    <div class="dialog alert">
266
                        <h1>Delete this account?</h1>
306
                        <h1>Delete this account?</h1>
267
                        <table>
307
                        <table>
Lines 277-283 MARC order accounts Link Here
277
                        </table>
317
                        </table>
278
                        <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" method="post">
318
                        <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" method="post">
279
                            [% INCLUDE 'csrf-token.inc' %]
319
                            [% INCLUDE 'csrf-token.inc' %]
280
                            <input type="hidden" name="op" value="cud-delete_acct" />
320
                            <input type="hidden" name="op" value="cud-delete_confirmed" />
281
                            <input type="hidden" name="id" value="[% account.id | html %]" />
321
                            <input type="hidden" name="id" value="[% account.id | html %]" />
282
                            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
322
                            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
283
                        </form>
323
                        </form>
284
- 

Return to bug 38547