X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fmsg_template.html;h=a1026fed30d3f6d7c3b90623e677afcaad6ae8c1;hb=0be0b02db98ed06dabe51805fe45b2e9704327b8;hp=941554532f6b48b9a3f9e027f155aa5396807a0f;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html index 941554532..a1026fed3 100644 --- a/httemplate/edit/msg_template.html +++ b/httemplate/edit/msg_template.html @@ -1,14 +1,58 @@ -<% include( 'elements/edit.html', - 'html_init' => '$sidebar
', - 'body_etc' => $body_etc, - 'name_singular' => 'template', - 'table' => 'msg_template', - 'viewall_dir' => 'browse', - 'agent_virt' => 1, - 'agent_null' => 1, - 'agent_null_right' => ['Edit global templates', 'Configuration'], +<& elements/edit.html, + 'html_init' => '$sidebar
', + 'body_etc' => $body_etc, + 'name_singular' => 'template', + 'table' => 'msg_template', + 'viewall_dir' => 'browse', + 'agent_virt' => 1, + 'agent_null' => 1, + 'agent_null_right' => [ 'View global templates', 'Edit global templates' ], - 'fields' => [ + 'fields' => \@fields, + 'labels' => { + 'msgnum' => 'Template', + 'agentnum' => 'Agent', + 'msgname' => 'Template name', + 'from_addr' => 'From: ', + 'bcc_addr' => 'Bcc: ', + 'locale' => 'Locale', + 'subject' => 'Subject: ', + 'body' => 'Message body', + }, + 'edit_callback' => \&edit_callback, + 'error_callback' => \&edit_callback, + 'html_bottom' => '', + 'html_table_bottom'=> \&html_table_bottom, + 'html_foot' => ( $no_submit ? '' : "
" ), + 'no_submit' => $no_submit, +&> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right([ 'View templates', 'View global templates', + 'Edit templates', 'Edit global templates', + ]); + +my $body_etc = ''; +$body_etc = q!onload="document.getElementById('locale').onchange()"! + if $cgi->param('locale') eq 'new'; + +my $msgnum = $cgi->param('msgnum'); +my $msg_template = $msgnum ? qsearchs('msg_template', {msgnum=>$msgnum}) : ''; + +my $no_submit = 0; +my @fields = (); +if ( $curuser->access_right('Edit global templates') + || ( $curuser->access_right('Edit templates') + && $msg_template + && $msg_template->agentnum + && $curuser->agentnums_href->{$msg_template->agentnum} + ) + ) +{ + push @fields, { field => 'agentnum', type => 'select-agent', }, @@ -23,35 +67,35 @@ { field => 'subject', size=>60, }, { field => 'body', type => 'htmlarea', - width => 763 + width => 763, + config=> { extraPlugins => 'blockprotect' }, }, - ], - 'labels' => { - 'msgnum' => 'Template', - 'agentnum' => 'Agent', - 'msgname' => 'Template name', - 'from_addr' => 'From: ', - 'bcc_addr' => 'Bcc: ', - 'locale' => 'Language', - 'subject' => 'Subject: ', - 'body' => 'Message body', - }, - 'edit_callback' => \&edit_callback, - 'error_callback' => \&edit_callback, - 'html_bottom' => '', - 'html_foot' => "
", - ) - %> -<%init> + ; +} else { #readonly -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Edit templates') - || $FS::CurrentUser::CurrentUser->access_right('Edit global templates') - || $FS::CurrentUser::CurrentUser->access_right('Configuration'); + $no_submit = 1; -my $body_etc = ''; -$body_etc = q!onload="document.getElementById('locale').onchange()"! - if $cgi->param('locale') eq 'new'; + push @fields, + { field => 'agentnum', + type => 'select-agent', + fixed => 1, + }, + { field => 'msgname', type => 'fixed', }, + { field => 'from_addr', type => 'fixed', }, + { field => 'bcc_addr', type => 'fixed', }, + { type => 'tablebreak-tabs', + include_opt_callback => \&menubar_opt_callback, + }, + # template_content fields + { field => 'locale', type => 'hidden' }, + { field => 'subject', type => 'fixed', }, + { field => 'body', + type => 'fixed', + noescape => 1, + }, + ; + +} sub new_callback { my ($cgi, $object, $fields_listref, $opt_hashref) = @_; @@ -78,11 +122,12 @@ sub edit_callback { # make a list of available locales my $content_locales = $object->content_locales; - my @locales = grep { !exists($content_locales->{$_}) } FS::Locales->locales; + my @locales = grep { !exists($content_locales->{$_}) } + FS::Conf->new->config('available-locales'); my %labels; foreach (@locales) { my %info = FS::Locales->locale_info($_); - $labels{$_} = $info{'name'}; # ignoring country for now + $labels{$_} = $info{'label'}; } unshift @locales, 'new'; $labels{'new'} = 'Select language'; @@ -103,7 +148,7 @@ sub edit_callback { curr_value => 'new', onchange => $onchange_locale, ); - } # else it's already set up correctly + } } sub menubar_opt_callback { @@ -117,10 +162,10 @@ sub menubar_opt_callback { foreach my $l (FS::Locales->locales) { if ( exists $object->content_locales->{$l} ) { my %info = FS::Locales->locale_info($l); - push @tabs, - $info{'name'}, + push @tabs, + $info{'label'}, ';locale='.$l; - $selected = $info{'name'} if $object->locale eq $l; + $selected = $info{'label'} if $object->locale eq $l; } else { $display_new = 1; # there is at least one unused locale left @@ -164,6 +209,8 @@ my %substitutions = ( '$company_name' => 'Our company name', '$company_address'=> 'Our company address', '$company_phonenum' => 'Our phone number', + '$selfservice_server_base_url' => 'Base URL of customer self-service', + '$payment_history' => 'List of invoices/payments/credits/refunds', ], 'contact' => [ # duplicate this for shipping '$name' => 'Company and contact name', @@ -182,10 +229,23 @@ my %substitutions = ( '$country' => 'Country', '$daytime' => 'Day phone', '$night' => 'Night phone', + '$mobile' => 'Mobile phone', '$fax' => 'Fax', ], + 'service' => [ + '$ship_address1' => 'Address line 1', + '$ship_address2' => 'Address line 2', + '$ship_city' => 'City', + '$ship_county' => 'County', + '$ship_state' => 'State', + '$ship_zip' => 'Zip', + '$ship_country' => 'Country', + ], 'cust_bill' => [ '$invnum' => 'Invoice#', + '$_date_pretty' => 'Invoice date', + '$due_date' => 'Invoice due date (timestamp)', + '$due_date2str' => 'Invoice due date (human readable)', ], 'cust_pkg' => [ '$pkgnum' => 'Package#', @@ -238,15 +298,10 @@ my %substitutions = ( '$error' => 'Decline reason', ], ); -my @c = @{ $substitutions{'contact'} }; -for (my $i=0; $i 'Name and contact info (billing)', -'shipping' => 'Name and contact info (shipping)', +'service' => 'Service address', 'cust_main' => 'Customer status and payment info', 'cust_pkg' => 'Package fields', 'cust_bill' => 'Invoice fields', @@ -268,7 +323,7 @@ my $widget = new HTML::Widgets::SelectLayers( my @hints = @{ $substitutions{$section} }; while(@hints) { my $key = shift @hints; - $html .= qq!\n$key!; + $html .= qq!\n$key!; $html .= "\n".shift(@hints).''; } $html .= "\n"; @@ -279,9 +334,14 @@ my $widget = new HTML::Widgets::SelectLayers( my $sidebar = '
Substitutions: ' @@ -293,4 +353,22 @@ Substitutions: ' '; +sub html_table_bottom { + my $object = shift; + $cgi->param('locale') =~ /^(\w+)$/; + my $locale = $1; + my $html; + if ( $locale and $locale ne 'new' ) { + # set up a delete link + my $msgnum = $object->msgnum; + my $url = $p."misc/delete-template_content.html?msgnum=$msgnum;locale=$1"; + my $link = qq!! . + 'Delete this template' . + ''; + $html = qq! + $link!; + } + $html; +} +