import torrus 1.0.9
[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   ],
59   'contact' => [ # duplicate this for shipping
60     '$name'           => 'Company and contact name',
61     '$name_short'     => 'Company or contact name',
62     '$company'        => 'Company name',
63     '$contact'        => 'Contact name (last, first)',
64     '$contact_firstlast'=> 'Contact name (first last)',
65     '$first'          => 'First name',
66     '$last'           => 'Last name',
67     '$address1'       => 'Address line 1',
68     '$address2'       => 'Address line 2',
69     '$city'           => 'City',
70     '$county'         => 'County',
71     '$state'          => 'State',
72     '$zip'            => 'Zip',
73     '$country'        => 'Country',
74     '$daytime'        => 'Day phone',
75     '$night'          => 'Night phone',
76     '$fax'            => 'Fax',
77   ],
78   'cust_bill' => [
79     '$invnum'         => 'Invoice#',
80   ],
81   'cust_pkg' => [
82     '$pkgnum'         => 'Package#',
83     '$pkg'            => 'Package description',
84     '$pkg_label'      => 'Description + comment',
85     '$status'         => 'Status',
86     '$statuscolor'    => 'Status color code',
87     '$start_ymd'      => 'Start date',
88     '$setup_ymd'      => 'Setup date',
89     '$last_bill_ymd'  => 'Last bill date',
90     '$next_bill_ymd'  => 'Next bill date',
91     '$susp_ymd'       => 'Suspended on date',
92     '$cancel_ymd'     => 'Canceled on date',
93     '$adjourn_ymd'    => 'Adjournment date',
94     '$expire_ymd'     => 'Expiration date',
95     '$labels_short'   => 'Service labels',
96     '$location_label' => 'Service location',
97   ],
98   'svc_acct'  => [
99     '$svcnum'         => 'Service#',
100     '$username'       => 'Login name',
101     '$password'       => 'Password',
102     '$domain'         => 'Domain name',
103   ],
104   'svc_domain' => [
105     '$svcnum'         => 'Service#',
106     '$domain'         => 'Domain name',
107     '$registrar'      => 'Registrar name',
108     '$catchall'       => 'Catchall email',
109   ],
110   'svc_phone' => [
111     '$svcnum'         => 'Service#',
112     '$phonenum'       => 'Phone number',
113     '$countrycode'    => 'Country code',
114     '$domain'         => 'Domain name'
115   ],
116   'svc_broadband' => [
117     '$svcnum'         => 'Service#',
118     '$ip_addr'        => 'IP address',
119     '$mac_addr'       => 'MAC address',
120     '$speed_up'       => 'Upstream speed',
121     '$speed_down'     => 'Downstream speed',
122   ],
123   'cust_pay'  => [
124     '$paynum'         => 'Payment#',
125     '$paid'           => 'Amount',
126     '$payby'          => 'Payment method',
127     '$date'           => 'Payment date',
128     '$payinfo'        => 'Card/account# (masked)',
129     '$error'          => 'Decline reason',
130   ],
131 );
132 my @c = @{ $substitutions{'contact'} };
133 for (my $i=0; $i<scalar(@c); $i += 2) {
134   $c[$i] =~ s/\$(.*)/\$ship_$1/;
135 }
136 $substitutions{'shipping'} = \@c;
137
138 tie my %sections, 'Tie::IxHash', (
139 'contact'   => 'Name and contact info (billing)',
140 'shipping'  => 'Name and contact info (shipping)',
141 'cust_main' => 'Customer status and payment info',
142 'cust_pkg'  => 'Package fields',
143 'cust_bill' => 'Invoice fields',
144 'cust_pay'  => 'Payment fields',
145 'svc_acct'  => 'Login service fields',
146 'svc_domain'=> 'Domain service fields',
147 'svc_phone' => 'Phone service fields',
148 'svc_broadband' => 'Broadband service fields',
149 );
150
151 my $widget = new HTML::Widgets::SelectLayers(
152   'options'   => \%sections,
153   'form_name' => 'dummy',
154   'html_between'=>'</FORM><FONT SIZE=-1>',
155   'selected_layer'=>(keys(%sections))[0],
156   'layer_callback' => sub {
157     my $section = shift;
158     my $html = include('/elements/table-grid.html');
159     my @hints = @{ $substitutions{$section} };
160     while(@hints) {
161       my $key = shift @hints;
162       $html .= qq!\n<TR><TD><A href="javascript:insertHtml('{$key}')">$key</A></TD>!;
163       $html .= "\n<TD>".shift(@hints).'</TD></TR>';
164     }
165     $html .= "\n</TABLE>";
166     return $html;
167   },
168 );
169
170 my $sidebar = '
171 <SCRIPT TYPE="text/javascript">
172 function insertHtml(what) {
173   var oEditor = FCKeditorAPI.GetInstance("body");
174   oEditor.InsertHtml(what);
175 };
176 </SCRIPT>
177 <TD valign="top"><FORM name="dummy">
178 Substitutions: '
179 . $widget->html .
180 '<BR>Click links to insert.
181 <BR>Enclose substitutions and other Perl expressions in braces:
182 <BR>{ $name } = ExampleCo (Smith, John)
183 <BR>{ time2str("%D", time) } = '.time2str("%D", time).'
184 </FONT></TD>
185 ';
186
187 </%init>