X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fmsg_template.html;h=941554532f6b48b9a3f9e027f155aa5396807a0f;hb=7aef2e455fe8a4722036f231ee8609ac63b2a9c9;hp=67eae185d905d24cdad4529eea30f3fa9980aa0d;hpb=a95bfdb0174c66cbf8444967efcd04cb638d727c;p=freeside.git diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html index 67eae185d..941554532 100644 --- a/httemplate/edit/msg_template.html +++ b/httemplate/edit/msg_template.html @@ -1,26 +1,47 @@ <% include( 'elements/edit.html', - 'html_init' => '$sidebar
', - 'name_singular' => 'template', - 'table' => 'msg_template', - 'viewall_dir' => 'browse', - 'agent_virt' => 1, - 'agent_null' => 1, - 'agent_null_right' => 'Edit global templates', - - 'fields' => [ 'msgname', - 'subject', - 'from_addr', - { field=>'body', type=>'htmlarea', width=>763 }, - ], - 'labels' => { 'msgnum' => 'Template', - 'msgname' => 'Template name', - 'from_addr' => 'Return address', - 'subject' => 'Message subject', - 'body' => 'Message template', - }, - 'html_foot' => "
", - ) -%> + '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'], + + 'fields' => [ + { field => 'agentnum', + type => 'select-agent', + }, + { field => 'msgname', size=>60, }, + { field => 'from_addr', size=>60, }, + { field => 'bcc_addr', size=>60, }, + { type => 'tablebreak-tabs', + include_opt_callback => \&menubar_opt_callback, + }, + # template_content fields + { field => 'locale', type => 'hidden' }, + { field => 'subject', size=>60, }, + { field => 'body', + type => 'htmlarea', + width => 763 + }, + ], + '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> die "access denied" @@ -28,6 +49,95 @@ die "access denied" || $FS::CurrentUser::CurrentUser->access_right('Edit global templates') || $FS::CurrentUser::CurrentUser->access_right('Configuration'); +my $body_etc = ''; +$body_etc = q!onload="document.getElementById('locale').onchange()"! + if $cgi->param('locale') eq 'new'; + +sub new_callback { + my ($cgi, $object, $fields_listref, $opt_hashref) = @_; + my $template_content = new FS::template_content { 'locale' => '' }; + $object->{'Hash'} = { $object->hash, $template_content->hash }; +} + +sub edit_callback { + my ($cgi, $object, $fields_listref, $opt_hashref) = @_; + $cgi->param('locale') =~ /^(\w*)$/ or die 'bad locale '.$cgi->param('locale'); + my $locale = $1; + + # fetch the content object and merge its fields + my %args = ( + 'msgnum' => $object->msgnum, + 'locale' => $locale + ); + my $template_content = qsearchs('template_content', \%args) + || new FS::template_content( { %args }); + $object->{'Hash'} = { $object->hash, $template_content->hash }; + + # set up the locale selector if this is a new content + if ( $locale eq 'new' ) { + + # make a list of available locales + my $content_locales = $object->content_locales; + my @locales = grep { !exists($content_locales->{$_}) } FS::Locales->locales; + my %labels; + foreach (@locales) { + my %info = FS::Locales->locale_info($_); + $labels{$_} = $info{'name'}; # ignoring country for now + } + unshift @locales, 'new'; + $labels{'new'} = 'Select language'; + + # insert a field def + my $i = 0; + $i++ until ( $fields_listref->[$i]->{'field'} eq 'locale' ); + my $locale_field = $fields_listref->[$i]; + + my $onchange_locale = "document.getElementById('submit').disabled = + (this.options[this.selectedIndex].value == 'new');"; + + %$locale_field = ( + field => 'locale', + type => 'select', + options => \@locales, + labels => \%labels, + curr_value => 'new', + onchange => $onchange_locale, + ); + } # else it's already set up correctly +} + +sub menubar_opt_callback { + my $object = shift; + # generate no tabs for new msg_templates. + my $msgnum = $object->msgnum or return; + my (@tabs, @options, %labels); + push @tabs, mt('Default'), ''; + my $display_new = 0; + my $selected = ''; + foreach my $l (FS::Locales->locales) { + if ( exists $object->content_locales->{$l} ) { + my %info = FS::Locales->locale_info($l); + push @tabs, + $info{'name'}, + ';locale='.$l; + $selected = $info{'name'} if $object->locale eq $l; + } + else { + $display_new = 1; # there is at least one unused locale left + } + } + push @tabs, mt('New'), ';locale=new' if $display_new; + $selected = mt('New') if $object->locale eq 'new'; + $selected ||= mt('Default'); + ( + 'url_base' => $p.'edit/msg_template.html?msgnum='.$msgnum, + 'selected' => $selected, + 'tabs' => \@tabs + ); +} + +my $onchange_locale = ''; + # Create hints pane my %substitutions = ( @@ -46,11 +156,14 @@ my %substitutions = ( '$classname' => 'Customer class', '$categoryname' => 'Customer category', '$balance' => 'Current balance', + '$credit_limit' => 'Credit limit', '$invoicing_list_emailonly' => 'Billing email address', '$cust_status' => 'Status', '$ucfirst_cust_status' => 'Status, capitalized', '$cust_statuscolor' => 'Status color code', '$company_name' => 'Our company name', + '$company_address'=> 'Our company address', + '$company_phonenum' => 'Our phone number', ], 'contact' => [ # duplicate this for shipping '$name' => 'Company and contact name', @@ -76,8 +189,8 @@ my %substitutions = ( ], 'cust_pkg' => [ '$pkgnum' => 'Package#', - '$pkg_label' => 'Package label (short)', - '$pkg_label_long' => 'Package label (long)', + '$pkg' => 'Package description', + '$pkg_label' => 'Description + comment', '$status' => 'Status', '$statuscolor' => 'Status color code', '$start_ymd' => 'Start date', @@ -92,8 +205,29 @@ my %substitutions = ( '$location_label' => 'Service location', ], 'svc_acct' => [ + '$svcnum' => 'Service#', '$username' => 'Login name', '$password' => 'Password', + '$domain' => 'Domain name', + ], + 'svc_domain' => [ + '$svcnum' => 'Service#', + '$domain' => 'Domain name', + '$registrar' => 'Registrar name', + '$catchall' => 'Catchall email', + ], + 'svc_phone' => [ + '$svcnum' => 'Service#', + '$phonenum' => 'Phone number', + '$countrycode' => 'Country code', + '$domain' => 'Domain name' + ], + 'svc_broadband' => [ + '$svcnum' => 'Service#', + '$ip_addr' => 'IP address', + '$mac_addr' => 'MAC address', + '$speed_up' => 'Upstream speed', + '$speed_down' => 'Downstream speed', ], 'cust_pay' => [ '$paynum' => 'Payment#', @@ -101,6 +235,7 @@ my %substitutions = ( '$payby' => 'Payment method', '$date' => 'Payment date', '$payinfo' => 'Card/account# (masked)', + '$error' => 'Decline reason', ], ); my @c = @{ $substitutions{'contact'} }; @@ -117,6 +252,9 @@ tie my %sections, 'Tie::IxHash', ( 'cust_bill' => 'Invoice fields', 'cust_pay' => 'Payment fields', 'svc_acct' => 'Login service fields', +'svc_domain'=> 'Domain service fields', +'svc_phone' => 'Phone service fields', +'svc_broadband' => 'Broadband service fields', ); my $widget = new HTML::Widgets::SelectLayers(