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

(-)a/acqui/edifactmsgs.pl (-2 / +25 lines)
Lines 19-28 Link Here
19
use Modern::Perl;
19
use Modern::Perl;
20
20
21
use CGI;
21
use CGI;
22
use Koha::Database;
22
23
use C4::Koha;
24
use C4::Auth;
23
use C4::Auth;
24
use C4::Koha;
25
use C4::Output;
25
use C4::Output;
26
use Koha::Database;
27
use Koha::Plugins::Handler;
26
28
27
my $q = CGI->new;
29
my $q = CGI->new;
28
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
30
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
Lines 45-50 if ( $cmd && $cmd eq 'delete' ) { Link Here
45
    $msg->update;
47
    $msg->update;
46
}
48
}
47
49
50
if ( $cmd && $cmd eq 'import' ) {
51
    my $id  = $q->param('message_id');
52
    my $invoice = $schema->resultset('EdifactMessage')->find($id);
53
54
    my $plugin_used = 0;
55
    if ( my $plugin_class = $invoice->edi_acct->plugin ) {
56
        $plugin_used = 1;
57
        Koha::Plugins::Handler->run(
58
            {
59
                class  => $plugin_class,
60
                method => 'edifact_process_invoice',
61
                params => {
62
                    invoice => $invoice,
63
                }
64
            }
65
        );
66
    }
67
68
    process_invoice($invoice) unless $plugin_used;
69
}
70
48
my @msgs = $schema->resultset('EdifactMessage')->search(
71
my @msgs = $schema->resultset('EdifactMessage')->search(
49
    {
72
    {
50
        deleted => 0,
73
        deleted => 0,
(-)a/installer/data/mysql/atomicupdate/bug_23682.perl (+10 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if ( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{
4
        INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
5
        ('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice')
6
    });
7
8
    SetVersion( $DBversion );
9
    print "Upgrade to $DBversion done (Bug XXXXX - description)\n";
10
}
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 171-176 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
171
('DumpTemplateVarsIntranet',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',  'YesNo'),
171
('DumpTemplateVarsIntranet',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',  'YesNo'),
172
('DumpTemplateVarsOpac',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',  'YesNo'),
172
('DumpTemplateVarsOpac',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',  'YesNo'),
173
('EasyAnalyticalRecords','0','','If on, display in the catalogue screens tools to easily setup analytical record relationships','YesNo'),
173
('EasyAnalyticalRecords','0','','If on, display in the catalogue screens tools to easily setup analytical record relationships','YesNo'),
174
('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice'),
174
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
175
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
175
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
176
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
176
('ElasticsearchMARCFormat', 'ISO2709', 'ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'),
177
('ElasticsearchMARCFormat', 'ISO2709', 'ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt (+3 lines)
Lines 71-76 Link Here
71
<td class="actions">
71
<td class="actions">
72
    <a class="btn btn-default btn-xs view_message" target="_blank" href="/cgi-bin/koha/acqui/edimsg.pl?id=[% msg.id | html %]"><i class="fa fa-search"></i> View message</a>
72
    <a class="btn btn-default btn-xs view_message" target="_blank" href="/cgi-bin/koha/acqui/edimsg.pl?id=[% msg.id | html %]"><i class="fa fa-search"></i> View message</a>
73
    <a class="btn btn-default btn-xs delete_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=delete&amp;message_id=[% msg.id | html %]"><i class="fa fa-trash"></i> Delete</a>
73
    <a class="btn btn-default btn-xs delete_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=delete&amp;message_id=[% msg.id | html %]"><i class="fa fa-trash"></i> Delete</a>
74
    [% IF msg.status == 'new' %]
75
        <a class="btn btn-default btn-xs import_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=import&amp;message_id=[% msg.id | html %]"><i class="fa fa-cog"></i> Import</a>
76
    [% END %]
74
</td>
77
</td>
75
</tr>
78
</tr>
76
[% END %]
79
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref (+8 lines)
Lines 122-124 Acquisitions: Link Here
122
                  "pdfformat::layout3pagesfr": French 3-page
122
                  "pdfformat::layout3pagesfr": French 3-page
123
                  "pdfformat::layout2pagesde": German 2-page
123
                  "pdfformat::layout2pagesde": German 2-page
124
            - layout when printing basket groups.
124
            - layout when printing basket groups.
125
    EDIFACT:
126
        -
127
            - pref: EdifactInvoiceImport
128
              default: no
129
              choices:
130
                automatic: "Do"
131
                manual: "Don't"
132
            - " automatically import EDIFACT invoice message file when they are downloaded."
(-)a/misc/cronjobs/edi_cron.pl (-28 / +28 lines)
Lines 121-156 foreach my $quote_file (@downloaded_quotes) { Link Here
121
}
121
}
122
122
123
# process any downloaded invoices
123
# process any downloaded invoices
124
124
if ( C4::Context->preference('EdifactInvoiceImport') eq 'automatic' ) {
125
my @downloaded_invoices = $schema->resultset('EdifactMessage')->search(
125
    my @downloaded_invoices = $schema->resultset('EdifactMessage')->search(
126
    {
126
        {
127
        message_type => 'INVOICE',
127
            message_type => 'INVOICE',
128
        status       => 'new',
128
            status       => 'new',
129
    }
129
        }
130
)->all;
130
    )->all;
131
131
132
foreach my $invoice (@downloaded_invoices) {
132
    foreach my $invoice (@downloaded_invoices) {
133
    my $filename = $invoice->filename();
133
        my $filename = $invoice->filename();
134
    $logger->trace("Processing invoice $filename");
134
        $logger->trace("Processing invoice $filename");
135
135
136
    my $plugin_used = 0;
136
        my $plugin_used = 0;
137
    if ( my $plugin_class = $invoice->edi_acct->plugin ) {
137
        if ( my $plugin_class = $invoice->edi_acct->plugin ) {
138
        my $plugin = $plugin_class->new();
138
            my $plugin = $plugin_class->new();
139
        if ( $plugin->can('edifact_process_invoice') ) {
139
            if ( $plugin->can('edifact_process_invoice') ) {
140
            $plugin_used = 1;
140
                $plugin_used = 1;
141
            Koha::Plugins::Handler->run(
141
                Koha::Plugins::Handler->run(
142
                {
142
                    {
143
                    class  => $plugin_class,
143
                        class  => $plugin_class,
144
                    method => 'edifact_process_invoice',
144
                        method => 'edifact_process_invoice',
145
                    params => {
145
                        params => {
146
                        invoice => $invoice,
146
                            invoice => $invoice,
147
                        }
147
                    }
148
                    }
148
                }
149
                );
149
            );
150
            }
150
        }
151
        }
151
    }
152
152
153
    process_invoice($invoice) unless $plugin_used;
153
        process_invoice($invoice) unless $plugin_used;
154
    }
154
}
155
}
155
156
156
my @downloaded_responses = $schema->resultset('EdifactMessage')->search(
157
my @downloaded_responses = $schema->resultset('EdifactMessage')->search(
157
- 

Return to bug 23682