This commit was manufactured by cvs2svn to create branch
[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                             { field=>'body', type=>'htmlarea', width=>763 },
14                           ],
15               'labels' => { 'msgnum'    => 'Template',
16                             'msgname'   => 'Template name',
17                             'from_addr' => 'Return address',
18                             'subject'   => 'Message subject',
19                             'body'      => 'Message template',
20                           },
21               'html_foot' => "</TD>$sidebar</TR></TABLE>",
22           )
23 %>
24 <%init>
25
26 die "access denied"
27   unless $FS::CurrentUser::CurrentUser->access_right('Edit templates')
28   ||     $FS::CurrentUser::CurrentUser->access_right('Edit global templates')
29   ||     $FS::CurrentUser::CurrentUser->access_right('Configuration');
30
31 # Create hints pane
32
33 my %substitutions = (
34   'cust_main' => [
35     '$display_custnum'=> 'Customer#',
36     '$agentnum'       => 'Agent#',
37     '$agent_name'     => 'Agent name',
38     '$payby'          => 'Payment method',
39     '$paymask'        => 'Card/account# (masked)',
40     '$payname'        => 'Name on card/bank name',
41     '$paytype'        => 'Account type',
42     '$payip'          => 'IP address used to submit payment info',
43     '$num_ncancelled_pkgs'  => '# of active packages',
44     '$num_cancelled_pkgs'   => '# of cancelled packages',
45     '$num_pkgs'       => '# of packages',
46     '$classname'      => 'Customer class',
47     '$categoryname'   => 'Customer category',
48     '$balance'        => 'Current balance',
49     '$invoicing_list_emailonly' => 'Billing email address',
50     '$cust_status'    => 'Status',
51     '$ucfirst_cust_status'  => 'Status, capitalized',
52     '$cust_statuscolor'     => 'Status color code',
53     '$company_name'   => 'Our company name',
54   ],
55   'contact' => [ # duplicate this for shipping
56     '$name'           => 'Company and contact name',
57     '$name_short'     => 'Company or contact name',
58     '$company'        => 'Company name',
59     '$contact'        => 'Contact name (last, first)',
60     '$contact_firstlast'=> 'Contact name (first last)',
61     '$first'          => 'First name',
62     '$last'           => 'Last name',
63     '$address1'       => 'Address line 1',
64     '$address2'       => 'Address line 2',
65     '$city'           => 'City',
66     '$county'         => 'County',
67     '$state'          => 'State',
68     '$zip'            => 'Zip',
69     '$country'        => 'Country',
70     '$daytime'        => 'Day phone',
71     '$night'          => 'Night phone',
72     '$fax'            => 'Fax',
73   ],
74   'cust_bill' => [
75     '$invnum'         => 'Invoice#',
76   ],
77   'cust_pkg' => [
78     '$pkgnum'         => 'Package#',
79     '$pkg_label'      => 'Package label (short)',
80     '$pkg_label_long' => 'Package label (long)',
81     '$status'         => 'Status',
82     '$statuscolor'    => 'Status color code',
83     '$start_ymd'      => 'Start date',
84     '$setup_ymd'      => 'Setup date',
85     '$last_bill_ymd'  => 'Last bill date',
86     '$next_bill_ymd'  => 'Next bill date',
87     '$susp_ymd'       => 'Suspended on date',
88     '$cancel_ymd'     => 'Canceled on date',
89     '$adjourn_ymd'    => 'Adjournment date',
90     '$expire_ymd'     => 'Expiration date',
91     '$labels_short'   => 'Service labels',
92     '$location_label' => 'Service location',
93   ],
94   'svc_acct'  => [
95     '$username'       => 'Login name',
96     '$password'       => 'Password',
97   ],
98   'cust_pay'  => [
99     '$paynum'         => 'Payment#',
100     '$paid'           => 'Amount',
101     '$payby'          => 'Payment method',
102     '$date'           => 'Payment date',
103     '$payinfo'        => 'Card/account# (masked)',
104   ],
105 );
106 my @c = @{ $substitutions{'contact'} };
107 for (my $i=0; $i<scalar(@c); $i += 2) {
108   $c[$i] =~ s/\$(.*)/\$ship_$1/;
109 }
110 $substitutions{'shipping'} = \@c;
111
112 tie my %sections, 'Tie::IxHash', (
113 'contact'   => 'Name and contact info (billing)',
114 'shipping'  => 'Name and contact info (shipping)',
115 'cust_main' => 'Customer status and payment info',
116 'cust_pkg'  => 'Package fields',
117 'cust_bill' => 'Invoice fields',
118 'cust_pay'  => 'Payment fields',
119 'svc_acct'  => 'Login service fields',
120 );
121
122 my $widget = new HTML::Widgets::SelectLayers(
123   'options'   => \%sections,
124   'form_name' => 'dummy',
125   'html_between'=>'</FORM><FONT SIZE=-1>',
126   'selected_layer'=>(keys(%sections))[0],
127   'layer_callback' => sub {
128     my $section = shift;
129     my $html = include('/elements/table-grid.html');
130     my @hints = @{ $substitutions{$section} };
131     while(@hints) {
132       my $key = shift @hints;
133       $html .= qq!\n<TR><TD><A href="javascript:insertHtml('{$key}')">$key</A></TD>!;
134       $html .= "\n<TD>".shift(@hints).'</TD></TR>';
135     }
136     $html .= "\n</TABLE>";
137     return $html;
138   },
139 );
140
141 my $sidebar = '
142 <SCRIPT TYPE="text/javascript">
143 function insertHtml(what) {
144   var oEditor = FCKeditorAPI.GetInstance("body");
145   oEditor.InsertHtml(what);
146 };
147 </SCRIPT>
148 <TD valign="top"><FORM name="dummy">
149 Substitutions: '
150 . $widget->html .
151 '<BR>Click links to insert.
152 <BR>Enclose substitutions and other Perl expressions in braces:
153 <BR>{ $name } = ExampleCo (Smith, John)
154 <BR>{ time2str("%D", time) } = '.time2str("%D", time).'
155 </FONT></TD>
156 ';
157
158 </%init>