1 <% include('/elements/init_overlib.html') %>
3 <% include( 'elements/browse.html',
4 'title' => 'Template images',
5 'name_singular' => 'image',
6 'menubar' => \@menubar,
7 'query' => { 'table' => 'template_image', },
8 'count_query' => 'SELECT COUNT(*) FROM template_image',
10 'agent_null_right' => ['View global templates','Edit global templates'],
12 'header' => [ 'Name', '', '' ],
13 'fields' => [ 'name', $tag, $delete_text ],
14 'links' => [ '', '', '' ],
15 'cell_style' => [ '', '', '' ],
19 <% include('/elements/template_image-dialog.html',
20 'url' => $p.'browse/template_image.html'
24 use FS::template_image;
26 my $curuser = $FS::CurrentUser::CurrentUser;
29 unless $curuser->access_right([ 'View templates', 'View global templates',
30 'Edit templates', 'Edit global templates', ]);
32 my $canedit = $curuser->access_right(['Edit templates', 'Edit global templates']);
36 push @menubar, 'Upload a new image' => 'javascript:insertImageDialog(\'upload\')';
38 push @menubar, ( 'View message templates' => $p.'browse/msg_template.html' );
40 my $tag = sub { qq!<A HREF="javascript:insertImageDialog(! . $_[0]->imgnum . qq!)">view</A>! };
42 my $delete_text = $canedit ? sub {
44 my $imgnum = $image->imgnum;
45 unless ($image->agentnum) {
46 unless ($FS::CurrentUser::CurrentUser->access_right('Edit global templates')) {
51 <FORM name="delete_template_image_$imgnum">
52 <INPUT TYPE="hidden" name="imgnum" value="$imgnum">
55 $out .= include('/elements/progress-init.html',
56 "delete_template_image_$imgnum",
58 $p.'misc/process/template_image-delete.cgi',
59 $p.'browse/template_image.html',
62 my $onclick = 'if ( confirm(\'';
63 $onclick .= emt('Are you sure you want to delete template image ') . $imgnum;
64 $onclick .= '\') ) { imgnum' . $imgnum . 'process() }';
65 return $out . '<A HREF="javascript:void(0)" ONCLICK="' . $onclick . '">delete</A>';