|
Lines 1-5
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
# Copyright 2009 SARL BibLibre |
2 |
# Copyright 2009 SARL BibLibre |
|
|
3 |
# Copyright 2017 Koha Development Team |
| 3 |
# |
4 |
# |
| 4 |
# This file is part of Koha. |
5 |
# This file is part of Koha. |
| 5 |
# |
6 |
# |
|
Lines 16-30
Link Here
|
| 16 |
# You should have received a copy of the GNU General Public License |
17 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 18 |
|
19 |
|
| 19 |
use strict; |
20 |
use Modern::Perl; |
| 20 |
use warnings; |
|
|
| 21 |
use CGI qw ( -utf8 ); |
21 |
use CGI qw ( -utf8 ); |
| 22 |
use C4::Auth; |
22 |
use C4::Auth; |
| 23 |
use C4::Biblio; |
23 |
use C4::Biblio; |
| 24 |
use C4::Koha; |
|
|
| 25 |
use C4::Output; |
24 |
use C4::Output; |
| 26 |
|
25 |
|
| 27 |
use Koha::BiblioFrameworks; |
26 |
use Koha::BiblioFrameworks; |
|
|
27 |
use Koha::FieldMappings; |
| 28 |
|
28 |
|
| 29 |
my $query = new CGI; |
29 |
my $query = new CGI; |
| 30 |
|
30 |
|
|
Lines 35-68
my $subfieldcode = $query->param('marcsubfield');
Link Here
|
| 35 |
my $op = $query->param('op') || q{}; |
35 |
my $op = $query->param('op') || q{}; |
| 36 |
my $id = $query->param('id'); |
36 |
my $id = $query->param('id'); |
| 37 |
|
37 |
|
| 38 |
my ($template, $loggedinuser, $cookie) |
38 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 39 |
= get_template_and_user({template_name => "admin/fieldmapping.tt", |
39 |
{ |
| 40 |
query => $query, |
40 |
template_name => "admin/fieldmapping.tt", |
| 41 |
type => "intranet", |
41 |
query => $query, |
| 42 |
authnotrequired => 0, |
42 |
type => "intranet", |
| 43 |
flagsrequired => {parameters => 'parameters_remaining_permissions'}, |
43 |
authnotrequired => 0, |
| 44 |
debug => 1, |
44 |
flagsrequired => { parameters => 'parameters_remaining_permissions' }, |
| 45 |
}); |
45 |
debug => 1, |
| 46 |
|
46 |
} |
| 47 |
if($op eq "delete" and $id){ |
47 |
); |
| 48 |
DeleteFieldMapping($id); |
|
|
| 49 |
print $query->redirect("/cgi-bin/koha/admin/fieldmapping.pl?framework=".$frameworkcode); |
| 50 |
exit; |
| 51 |
} |
| 52 |
|
48 |
|
| 53 |
# insert operation |
49 |
# FIXME Add exceptions |
| 54 |
if($field and $fieldcode){ |
50 |
if ( $op eq "delete" and $id ) { |
| 55 |
SetFieldMapping($frameworkcode, $field, $fieldcode, $subfieldcode); |
51 |
Koha::FieldMappings->find($id)->delete; |
|
|
52 |
} elsif ( $field and $fieldcode ) { |
| 53 |
my $params = { frameworkcode => $frameworkcode, field => $field, fieldcode => $fieldcode, subfieldcode => $subfieldcode }; |
| 54 |
my $exists = Koha::FieldMappings->search( $params )->count;; |
| 55 |
unless ( $exists ) { |
| 56 |
Koha::FieldMapping->new( $params )->store; |
| 57 |
} |
| 56 |
} |
58 |
} |
| 57 |
|
59 |
|
| 58 |
my $fieldloop = GetFieldMapping($frameworkcode); |
60 |
my $fields = Koha::FieldMappings->search({ frameworkcode => $frameworkcode }); |
| 59 |
|
61 |
|
| 60 |
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); |
62 |
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); |
| 61 |
my $framework = $frameworks->search( { frameworkcode => $frameworkcode } )->next; |
63 |
my $framework = $frameworks->search( { frameworkcode => $frameworkcode } )->next; |
| 62 |
$template->param( |
64 |
$template->param( |
| 63 |
frameworks => $frameworks, |
65 |
frameworks => $frameworks, |
| 64 |
framework => $framework, |
66 |
framework => $framework, |
| 65 |
fields => $fieldloop, |
67 |
fields => $fields, |
| 66 |
); |
68 |
); |
| 67 |
|
69 |
|
| 68 |
output_html_with_http_headers $query, $cookie, $template->output; |
70 |
output_html_with_http_headers $query, $cookie, $template->output; |