This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / httemplate / edit / msg_template.html
1 <% include( 'elements/edit.html',  
2               'html_init'     => '<TABLE id="outerTable"><TR><TD>',
3               'name_singular' => 'template',
4               'table'         => 'msg_template',
5               'viewall_dir'   => 'browse',
6               'agent_virt'    => 1,
7               'agent_null'    => 1,
8               'agent_null_right' => ['Edit global templates', 'Configuration'],
9
10               'fields' => [ 'msgname',
11                             { field=>'from_addr', size=>60, },
12                             { field=>'bcc_addr',  size=>60, },
13                             { field=>'subject',   size=>80, },
14                             { field=>'body', type=>'htmlarea', width=>763 },
15                           ],
16               'labels' => { 'msgnum'    => 'Template',
17                             'msgname'   => 'Template name',
18                             'from_addr' => 'From: ',
19                             'bcc_addr'  => 'Bcc: ',
20                             'subject'   => 'Subject: ',
21                             'body'      => 'Message template',
22                           },
23               'html_foot' => "</TD>$sidebar</TR></TABLE>",
24           )
25 %>
26 <%init>
27
28 die "access denied"
29   unless $FS::CurrentUser::CurrentUser->access_right('Edit templates')
30   ||     $FS::CurrentUser::CurrentUser->access_right('Edit global templates')
31   ||     $FS::CurrentUser::CurrentUser->access_right('Configuration');
32
33 # Create hints pane
34
35 my %substitutions = (
36   'cust_main' => [
37     '$display_custnum'=> 'Customer#',
38     '$agentnum'       => 'Agent#',
39     '$agent_name'     => 'Agent name',
40     '$payby'          => 'Payment method',
41     '$paymask'        => 'Card/account# (masked)',
42     '$payname'        => 'Name on card/bank name',
43     '$paytype'        => 'Account type',
44     '$payip'          => 'IP address used to submit payment info',
45     '$num_ncancelled_pkgs'  => '# of active packages',
46     '$num_cancelled_pkgs'   => '# of cancelled packages',
47     '$num_pkgs'       => '# of packages',
48     '$classname'      => 'Customer class',
49     '$categoryname'   => 'Customer category',
50     '$balance'        => 'Current balance',
51     '$credit_limit'   => 'Credit limit',
52     '$invoicing_list_emailonly' => 'Billing email address',
53     '$cust_status'    => 'Status',
54     '$ucfirst_cust_status'  => 'Status, capitalized',
55     '$cust_statuscolor'     => 'Status color code',
56     '$company_name'   => 'Our company name',
57     '$company_address'=> 'Our company address',
58     '$company_phonenum' => 'Our phone number',
59   ],
60   'contact' => [ # duplicate this for shipping
61     '$name'           => 'Company and contact name',
62     '$name_short'     => 'Company or contact name',
63     '$company'        => 'Company name',
64     '$contact'        => 'Contact name (last, first)',
65     '$contact_firstlast'=> 'Contact name (first last)',
66     '$first'          => 'First name',
67     '$last'           => 'Last name',
68     '$address1'       => 'Address line 1',
69     '$address2'       => 'Address line 2',
70     '$city'           => 'City',
71     '$county'         => 'County',
72     '$state'          => 'State',
73     '$zip'            => 'Zip',
74     '$country'        => 'Country',
75     '$daytime'        => 'Day phone',
76     '$night'          => 'Night phone',
77     '$fax'            => 'Fax',
78   ],
79   'cust_bill' => [
80     '$invnum'         => 'Invoice#',
81   ],
82   'cust_pkg' => [
83     '$pkgnum'         => 'Package#',
84     '$pkg'            => 'Package description',
85     '$pkg_label'      => 'Description + comment',
86     '$status'         => 'Status',
87     '$statuscolor'    => 'Status color code',
88     '$start_ymd'      => 'Start date',
89     '$setup_ymd'      => 'Setup date',
90     '$last_bill_ymd'  => 'Last bill date',
91     '$next_bill_ymd'  => 'Next bill date',
92     '$susp_ymd'       => 'Suspended on date',
93     '$cancel_ymd'     => 'Canceled on date',
94     '$adjourn_ymd'    => 'Adjournment date',
95     '$expire_ymd'     => 'Expiration date',
96     '$labels_short'   => 'Service labels',
97     '$location_label' => 'Service location',
98   ],
99   'svc_acct'  => [
100     '$svcnum'         => 'Service#',
101     '$username'       => 'Login name',
102     '$password'       => 'Password',
103     '$domain'         => 'Domain name',
104   ],
105   'svc_domain' => [
106     '$svcnum'         => 'Service#',
107     '$domain'         => 'Domain name',
108     '$registrar'      => 'Registrar name',
109     '$catchall'       => 'Catchall email',
110   ],
111   'svc_phone' => [
112     '$svcnum'         => 'Service#',
113     '$phonenum'       => 'Phone number',
114     '$countrycode'    => 'Country code',
115     '$domain'         => 'Domain name'
116   ],
117   'svc_broadband' => [
118     '$svcnum'         => 'Service#',
119     '$ip_addr'        => 'IP address',
120     '$mac_addr'       => 'MAC address',
121     '$speed_up'       => 'Upstream speed',
122     '$speed_down'     => 'Downstream speed',
123   ],
124   'cust_pay'  => [
125     '$paynum'         => 'Payment#',
126     '$paid'           => 'Amount',
127     '$payby'          => 'Payment method',
128     '$date'           => 'Payment date',
129     '$payinfo'        => 'Card/account# (masked)',
130     '$error'          => 'Decline reason',
131   ],
132 );
133 my @c = @{ $substitutions{'contact'} };
134 for (my $i=0; $i<scalar(@c); $i += 2) {
135   $c[$i] =~ s/\$(.*)/\$ship_$1/;
136 }
137 $substitutions{'shipping'} = \@c;
138
139 tie my %sections, 'Tie::IxHash', (
140 'contact'   => 'Name and contact info (billing)',
141 'shipping'  => 'Name and contact info (shipping)',
142 'cust_main' => 'Customer status and payment info',
143 'cust_pkg'  => 'Package fields',
144 'cust_bill' => 'Invoice fields',
145 'cust_pay'  => 'Payment fields',
146 'svc_acct'  => 'Login service fields',
147 'svc_domain'=> 'Domain service fields',
148 'svc_phone' => 'Phone service fields',
149 'svc_broadband' => 'Broadband service fields',
150 );
151
152 my $widget = new HTML::Widgets::SelectLayers(
153   'options'   => \%sections,
154   'form_name' => 'dummy',
155   'html_between'=>'</FORM><FONT SIZE=-1>',
156   'selected_layer'=>(keys(%sections))[0],
157   'layer_callback' => sub {
158     my $section = shift;
159     my $html = include('/elements/table-grid.html');
160     my @hints = @{ $substitutions{$section} };
161     while(@hints) {
162       my $key = shift @hints;
163       $html .= qq!\n<TR><TD><A href="javascript:insertHtml('{$key}')">$key</A></TD>!;
164       $html .= "\n<TD>".shift(@hints).'</TD></TR>';
165     }
166     $html .= "\n</TABLE>";
167     return $html;
168   },
169 );
170
171 my $sidebar = '
172 <SCRIPT TYPE="text/javascript">
173 function insertHtml(what) {
174   var oEditor = FCKeditorAPI.GetInstance("body");
175   oEditor.InsertHtml(what);
176 };
177 </SCRIPT>
178 <TD valign="top"><FORM name="dummy">
179 Substitutions: '
180 . $widget->html .
181 '<BR>Click links to insert.
182 <BR>Enclose substitutions and other Perl expressions in braces:
183 <BR>{ $name } = ExampleCo (Smith, John)
184 <BR>{ time2str("%D", time) } = '.time2str("%D", time).'
185 </FONT></TD>
186 ';
187
188 </%init>