<%doc> Creates a jquery dialog box that opens when javascript function insertImageDialog is called, allows user to select an image and specify attributes for it, then passes img tag with base64 encoded data url to a callback javascript function. Accepts the following options: callback - pass the html for the selected img to this javascript function; if omitted, will only include fields for viewing/uploading image url - to redirect to after upload, otherwise just refreshes dialog window <% include('/elements/xmlhttp.html', 'url' => $fsurl.'misc/xmlhttp-template_image.cgi', 'subs' => [ 'get_template_image' ], ) %>
% if ($opt{'callback'}) { % } # if $opt{'callback'}
<% &ntable("#cccccc", 2) %>
Image
Width
Height
Align
Alt Text
% if ($canedit) {

<% emt('Upload New Image') %>

<% include('/elements/form-file_upload.html', 'name' => 'TemplateImageUploadForm', 'id' => 'TemplateImageUploadForm', 'action' => $fsurl.'misc/process/template_image-upload.cgi', 'num_files' => 1, 'fields' => [ 'name', 'agentnum' ], 'url' => $opt{'url'} || 'javascript:refreshImageList(1)', ) %> <% &ntable("#cccccc", 2) %> <% include( '/elements/tr-input-text.html', 'field' => 'name', 'label' => 'Name', 'required' => 1, 'id' => 'upload_form_name', ) %> <% include( '/elements/tr-select-agent.html', 'label' => "Agent", 'empty_label' => '(global)', 'agent_virt' => 1, 'agent_null_right' => 'Edit global templates', ) %> <% include( '/elements/tr-file-upload.html', 'field' => 'file', 'label' => 'File', ) %> % } #if canedit

<% emt('Image Preview') %>

(<% emt('Loading image...') %>)
<%init> my %opt = @_; my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right([ 'View templates', 'View global templates', 'Edit templates', 'Edit global templates', ]); my $canedit = $curuser->access_right([ 'Edit templates', 'Edit global templates' ]);