2 Returns JSON encoded array of objects with details about FS::template_image
3 objects. Attributes in each returned object are imgnum, name, and src.
5 Accepts the following options:
7 imgnum - only return object for this imgnum
9 no_src - do not include the src field
12 <% encode_json(\@result) %>\
14 use FS::template_image;
16 my $curuser = $FS::CurrentUser::CurrentUser;
19 unless $curuser->access_right([ 'View templates', 'View global templates',
20 'Edit templates', 'Edit global templates', ]);
22 my %arg = $cgi->param('arg');
25 'table' => 'template_image',
29 my $imgnum = $arg{'imgnum'} || '';
30 die "Bad imgnum" unless $imgnum =~ /^\d*$/;
31 $search->{'hashref'}->{'imgnum'} = $imgnum if $imgnum;
33 $search->{'select'} = 'imgnum, name' if $arg{'no_src'};
35 $search->{'extra_sql'} = ($imgnum ? ' AND ' : ' WHERE ')
36 . $curuser->agentnums_sql(
37 'null_right' => ['View global templates','Edit global templates']
40 my @images = qsearch($search); #needs agent virtualization
43 'imgnum' => $_->imgnum,
45 'src' => $arg{'no_src'} ? '' : $_->src,