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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt (-2 / +2 lines)
Lines 174-184 Link Here
174
                var ajaxData = {
174
                var ajaxData = {
175
                    'newdescription': newdescription,
175
                    'newdescription': newdescription,
176
                    'batch_id': batch_id,
176
                    'batch_id': batch_id,
177
                    'card_element': "batch",
177
                    'creator': "label",
178
                    };
178
                    };
179
179
180
                $.ajax({
180
                $.ajax({
181
                    url: '/cgi-bin/koha/svc/patroncards',
181
                    url: '/cgi-bin/koha/svc/creator_batches',
182
                    type: 'POST',
182
                    type: 'POST',
183
                    dataType: 'json',
183
                    dataType: 'json',
184
                    data: ajaxData,
184
                    data: ajaxData,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt (-2 / +2 lines)
Lines 163-173 Link Here
163
                var ajaxData = {
163
                var ajaxData = {
164
                    'newdescription': newdescription,
164
                    'newdescription': newdescription,
165
                    'batch_id': batch_id,
165
                    'batch_id': batch_id,
166
                    'card_element': "batch",
166
                    'creator': "patroncard",
167
                };
167
                };
168
168
169
                $.ajax({
169
                $.ajax({
170
                    url: '/cgi-bin/koha/svc/patroncards',
170
                    url: '/cgi-bin/koha/svc/creator_batches',
171
                    type: 'POST',
171
                    type: 'POST',
172
                    dataType: 'json',
172
                    dataType: 'json',
173
                    data: ajaxData,
173
                    data: ajaxData,
(-)a/svc/patroncards (-17 / +21 lines)
Lines 26-36 use C4::Context; Link Here
26
use C4::Auth qw /check_cookie_auth/;
26
use C4::Auth qw /check_cookie_auth/;
27
use C4::Output qw(:DEFAULT :ajax);
27
use C4::Output qw(:DEFAULT :ajax);
28
use C4::Patroncards::Batch;
28
use C4::Patroncards::Batch;
29
use Data::Dumper;
29
use C4::Labels::Batch;
30
30
31
=head1 NAME
31
=head1 NAME
32
32
33
svc/patroncards - Web service for managing AJAX functionality for patroncards
33
svc/creator_batches - Web service for managing AJAX functionality for patroncard batches and label batches
34
34
35
=head1 DESCRIPTION
35
=head1 DESCRIPTION
36
36
Lines 44-67 if ( $auth_status ne "ok" ) { Link Here
44
    exit 0;
44
    exit 0;
45
}
45
}
46
if ($is_ajax) {
46
if ($is_ajax) {
47
    my $card_element = $cgi->param('card_element');
47
    my $batch_id = $cgi->param('batch_id');
48
    if ( $card_element eq 'batch' ) {
48
    my $description = $cgi->param('newdescription');
49
        my $batch_id = $cgi->param('batch_id');
49
    my $status = '';
50
        my $description = $cgi->param('newdescription');
50
    my $dbh = C4::Context->dbh;
51
        my $status = '';
51
    my $query = "UPDATE creator_batches SET description = ? WHERE batch_id = ?";
52
        my $dbh = C4::Context->dbh;
52
    my $sth = $dbh->prepare($query);
53
        my $query = "UPDATE creator_batches SET description = ? WHERE batch_id = ?";
53
    $sth->execute($description, $batch_id);
54
        my $sth = $dbh->prepare($query);
55
        $sth->execute($description, $batch_id);
56
54
57
        # Check for success
55
    # Check for success
56
    my $creator = $cgi->param('creator');
57
    if ( $creator eq 'patroncard' ) {
58
        my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
58
        my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
59
        if ( $batch->{description} eq $description ) {
59
        if ( $batch->{description} eq $description ) {
60
            $status = 'success';
60
            $status = 'success';
61
        }
61
        }
62
62
    } elsif ( $creator eq 'label' ) {
63
        my $json = to_json ( { status => $status, newdesc => $description } );
63
        my $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
64
        output_with_http_headers $cgi, undef, $json, 'js';
64
        if ( $batch->{description} eq $description ) {
65
        exit;
65
            $status = 'success';
66
        }
66
    }
67
    }
68
69
    my $json = to_json ( { status => $status, newdesc => $description } );
70
    output_with_http_headers $cgi, undef, $json, 'js';
71
    exit;
67
}
72
}
68
- 

Return to bug 15766