3 # Copyright 2023 Koha Development Team
5 # This file is part of Koha.
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.
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.
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>.
24 use C4::Auth qw( get_template_and_user );
25 use C4::Output qw( output_html_with_http_headers );
27 use Koha::Acquisition::Booksellers;
30 my $booksellerid = $input->param('booksellerid');
31 my $issue_id = $input->param('issue_id');
32 my $op = $input->param('op') || 'list';
35 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37 template_name => "acqui/vendor_issues.tt",
40 flagsrequired => { acquisition => 'issues_manage' },
46 $issue = Koha::Acquisition::Bookseller::Issues->find($issue_id);
47 $booksellerid = $issue->vendor_id;
49 my $vendor = Koha::Acquisition::Booksellers->find($booksellerid);
52 print $input->redirect("/cgi-bin/koha/errors/404.pl");
56 if ( $op eq 'add_form' || $op eq 'show' ) {
57 $template->param( issue => $issue );
58 } elsif ( $op eq 'add_validate' ) {
59 my $type = $input->param('type');
60 my $started_on = $input->param('started_on');
61 my $ended_on = $input->param('ended_on');
62 my $notes = $input->param('notes');
69 started_on => $started_on,
70 ended_on => $ended_on,
74 push @messages, { type => 'message', code => 'success_on_update' };
76 push @messages, { type => 'error', code => 'error_on_update' };
80 Koha::Acquisition::Bookseller::Issue->new(
82 vendor_id => $booksellerid,
84 started_on => $started_on,
85 ended_on => $ended_on,
89 push @messages, { type => 'message', code => 'success_on_insert' };
91 push @messages, { type => 'error', code => 'error_on_insert' };
95 } elsif ( $op eq 'delete_confirm' ) {
96 $template->param( issue => $issue );
97 } elsif ( $op eq 'delete_confirmed' ) {
100 push @messages, { type => 'message', code => 'success_on_delete' };
102 push @messages, { type => 'error', code => 'error_on_delete' };
107 if ( $op eq 'list' ) {
108 $template->param( issues_count => $vendor->issues->search->count );
112 messages => \@messages,
115 booksellerid => $vendor->id, # Used by vendor-menu.inc
118 output_html_with_http_headers $input, $cookie, $template->output;