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

(-)a/admin/edi_ean_accounts.pl (-52 / +34 lines)
Lines 37-48 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
37
);
37
);
38
38
39
my $schema = Koha::Database->new()->schema();
39
my $schema = Koha::Database->new()->schema();
40
my $op     = $input->param('op');
40
41
$op ||= 'display';
41
my $id = scalar $input->param('id');
42
my $op = scalar $input->param('op') || 'display';
42
43
43
if ( $op eq 'ean_form' ) {
44
if ( $op eq 'ean_form' ) {
44
    show_ean();
45
    my $e        = $schema->resultset('EdifactEan')->find($id);
45
    $template->param( ean_form => 1 );
46
    my @branches = $schema->resultset('Branch')->search(
46
    my @branches = $schema->resultset('Branch')->search(
47
        undef,
47
        undef,
48
        {
48
        {
Lines 50-73 if ( $op eq 'ean_form' ) { Link Here
50
            order_by => 'branchname',
50
            order_by => 'branchname',
51
        }
51
        }
52
    );
52
    );
53
    $template->param( branches => \@branches );
53
    $template->param(
54
        ean_form => 1,
55
        branches => \@branches,
56
        ean      => $e,
57
    );
54
}
58
}
55
elsif ( $op eq 'delete_confirm' ) {
59
elsif ( $op eq 'delete_confirm' ) {
56
    show_ean();
60
    my $e = $schema->resultset('EdifactEan')->find($id);
57
    $template->param( delete_confirm => 1 );
61
    $template->param(
62
        delete_confirm => 1,
63
        ean            => $e,
64
    );
58
}
65
}
59
else {
66
else {
60
    if ( $op eq 'save' ) {
67
    if ( $op eq 'save' ) {
61
        my $change = $input->param('id');
68
        my $change = $id;
62
        if ($change) {
69
        if ($change) {
63
            editsubmit();
70
            $schema->resultset('EdifactEan')->find($id)->update(
71
                {
72
                    branchcode        => $input->param('branchcode'),
73
                    description       => $input->param('description'),
74
                    ean               => $input->param('ean'),
75
                    id_code_qualifier => $input->param('id_code_qualifier'),
76
                }
77
            );
64
        }
78
        }
65
        else {
79
        else {
66
            addsubmit();
80
            my $new_ean = $schema->resultset('EdifactEan')->new(
81
                {
82
                    branchcode        => $input->param('branchcode'),
83
                    description       => $input->param('description'),
84
                    ean               => $input->param('ean'),
85
                    id_code_qualifier => $input->param('id_code_qualifier'),
86
                }
87
            );
88
            $new_ean->insert();
67
        }
89
        }
68
    }
90
    }
69
    elsif ( $op eq 'delete_confirmed' ) {
91
    elsif ( $op eq 'delete_confirmed' ) {
70
        delsubmit();
92
        my $e = $schema->resultset('EdifactEan')->find($id);
93
        $e->delete if $e;
71
    }
94
    }
72
    my @eans = $schema->resultset('EdifactEan')->search(
95
    my @eans = $schema->resultset('EdifactEan')->search(
73
        {},
96
        {},
Lines 101-143 $template->param( Link Here
101
);
124
);
102
125
103
output_html_with_http_headers( $input, $cookie, $template->output );
126
output_html_with_http_headers( $input, $cookie, $template->output );
104
105
sub delsubmit {
106
    my $id = $input->param('id');
107
    my $e = $schema->resultset('EdifactEan')->find( $id );
108
    $e->delete if $e;
109
    return;
110
}
111
112
sub addsubmit {
113
114
    my $new_ean = $schema->resultset('EdifactEan')->new(
115
        {
116
            branchcode        => $input->param('branchcode'),
117
            description       => $input->param('description'),
118
            ean               => $input->param('ean'),
119
            id_code_qualifier => $input->param('id_code_qualifier'),
120
        }
121
    );
122
    $new_ean->insert();
123
    return;
124
}
125
126
sub editsubmit {
127
    $schema->resultset('EdifactEan')->find( $input->param('id') )->update(
128
        {
129
            branchcode        => $input->param('branchcode'),
130
            description       => $input->param('description'),
131
            ean               => $input->param('ean'),
132
            id_code_qualifier => $input->param('id_code_qualifier'),
133
        }
134
    );
135
    return;
136
}
137
138
sub show_ean {
139
    my $id = $input->param('id');
140
    my $e = $schema->resultset('EdifactEan')->find( $id );
141
    $template->param( ean => $e );
142
    return;
143
}
144
- 

Return to bug 17692