|
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 |
- |
|
|