460f4dcc2f74b77f97e32ef4a1661203a81b01ee
[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',
9
10               'fields' => [ 'msgname',
11                             'subject',
12                             'from_addr',
13                             'bcc_addr',
14                             { field=>'body', type=>'htmlarea', width=>763 },
15                           ],
16               'labels' => { 'msgnum'    => 'Template',
17                             'msgname'   => 'Template name',
18                             'from_addr' => 'Return address',
19                             'bcc_addr'  => 'Bcc address (optional)',
20                             'subject'   => 'Message 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     '$invoicing_list_emailonly' => 'Billing email address',
52     '$cust_status'    => 'Status',
53     '$ucfirst_cust_status'  => 'Status, capitalized',
54     '$cust_statuscolor'     => 'Status color code',
55     '$company_name'   => 'Our company name',
56     '$company_address'=> 'Our company address',
57   ],
58   'contact' => [ # duplicate this for shipping
59     '$name'           => 'Company and contact name',
60     '$name_short'     => 'Company or contact name',
61     '$company'        => 'Company name',
62     '$contact'        => 'Contact name (last, first)',
63     '$contact_firstlast'=> 'Contact name (first last)',
64     '$first'          => 'First name',
65     '$last'           => 'Last name',
66     '$address1'       => 'Address line 1',
67     '$address2'       => 'Address line 2',
68     '$city'           => 'City',
69     '$county'         => 'County',
70     '$state'          => 'State',
71     '$zip'            => 'Zip',
72     '$country'        => 'Country',
73     '$daytime'        => 'Day phone',
74     '$night'          => 'Night phone',
75     '$fax'            => 'Fax',
76   ],
77   'cust_bill' => [
78     '$invnum'         => 'Invoice#',
79   ],
80   'cust_pkg' => [
81     '$pkgnum'         => 'Package#',
82     '$pkg_label'      => 'Package label (short)',
83     '$pkg_label_long' => 'Package label (long)',
84     '$status'         => 'Status',
85     '$statuscolor'    => 'Status color code',
86     '$start_ymd'      => 'Start date',
87     '$setup_ymd'      => 'Setup date',
88     '$last_bill_ymd'  => 'Last bill date',
89     '$next_bill_ymd'  => 'Next bill date',
90     '$susp_ymd'       => 'Suspended on date',
91     '$cancel_ymd'     => 'Canceled on date',
92     '$adjourn_ymd'    => 'Adjournment date',
93     '$expire_ymd'     => 'Expiration date',
94     '$labels_short'   => 'Service labels',
95     '$location_label' => 'Service location',
96   ],
97   'svc_acct'  => [
98     '$username'       => 'Login name',
99     '$password'       => 'Password',
100   ],
101   'cust_pay'  => [
102     '$paynum'         => 'Payment#',
103     '$paid'           => 'Amount',
104     '$payby'          => 'Payment method',
105     '$date'           => 'Payment date',
106     '$payinfo'        => 'Card/account# (masked)',
107     '$error'          => 'Decline reason',
108   ],
109 );
110 my @c = @{ $substitutions{'contact'} };
111 for (my $i=0; $i<scalar(@c); $i += 2) {
112   $c[$i] =~ s/\$(.*)/\$ship_$1/;
113 }
114 $substitutions{'shipping'} = \@c;
115
116 tie my %sections, 'Tie::IxHash', (
117 'contact'   => 'Name and contact info (billing)',
118 'shipping'  => 'Name and contact info (shipping)',
119 'cust_main' => 'Customer status and payment info',
120 'cust_pkg'  => 'Package fields',
121 'cust_bill' => 'Invoice fields',
122 'cust_pay'  => 'Payment fields',
123 'svc_acct'  => 'Login service fields',
124 );
125
126 my $widget = new HTML::Widgets::SelectLayers(
127   'options'   => \%sections,
128   'form_name' => 'dummy',
129   'html_between'=>'</FORM><FONT SIZE=-1>',
130   'selected_layer'=>(keys(%sections))[0],
131   'layer_callback' => sub {
132     my $section = shift;
133     my $html = include('/elements/table-grid.html');
134     my @hints = @{ $substitutions{$section} };
135     while(@hints) {
136       my $key = shift @hints;
137       $html .= qq!\n<TR><TD><A href="javascript:insertHtml('{$key}')">$key</A></TD>!;
138       $html .= "\n<TD>".shift(@hints).'</TD></TR>';
139     }
140     $html .= "\n</TABLE>";
141     return $html;
142   },
143 );
144
145 my $sidebar = '
146 <SCRIPT TYPE="text/javascript">
147 function insertHtml(what) {
148   var oEditor = FCKeditorAPI.GetInstance("body");
149   oEditor.InsertHtml(what);
150 };
151 </SCRIPT>
152 <TD valign="top"><FORM name="dummy">
153 Substitutions: '
154 . $widget->html .
155 '<BR>Click links to insert.
156 <BR>Enclose substitutions and other Perl expressions in braces:
157 <BR>{ $name } = ExampleCo (Smith, John)
158 <BR>{ time2str("%D", time) } = '.time2str("%D", time).'
159 </FONT></TD>
160 ';
161
162 </%init>