summaryrefslogtreecommitdiff
path: root/httemplate/browse/invoice_template.html
blob: 0bbfb2452ba4635427c94ef29fef7df76ec4360d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<% include("/elements/header.html", 'Invoice templates') %>

<% include('/elements/table-grid.html') %>
% my $bgcolor1 = '#eeeeee';
%   my $bgcolor2 = '#ffffff';
%   my $bgcolor = '';

<TR>
  <TH CLASS="grid" BGCOLOR="#cccccc">Template</TH>
  <TH CLASS="grid" BGCOLOR="#cccccc">HTML</TH>
  <TH CLASS="grid" BGCOLOR="#cccccc">Print/PDF (typeset)</TH>
  <TH CLASS="grid" BGCOLOR="#cccccc">Plaintext</TH>
</TR>

% foreach my $templatename ( '', @templatenames ) {
%   my $tname = length($templatename) ? "_$templatename" : '';
%
%   if ( $bgcolor eq $bgcolor1 ) {
%     $bgcolor = $bgcolor2;
%   } else {
%     $bgcolor = $bgcolor1;
%   }
%
%   my $display = length($templatename) ? $templatename : '<i>(Default)</i>';

    <TR>

      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
        <% $display %>
      </TD>

      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">

%       my( $logo_label, $logo_link_label)= length( $templatename )
%                                             ? labels("logo_$templatename.png")
%                                             : ( '', 'edit' );
        <% $logo_label %> Logo
        (<A HREF="<% $p %>edit/invoice_logo.html?type=png;name=<% $templatename %>"><% $logo_link_label %></A>)
        <BR>

%       foreach my $suffix (qw( returnaddress notes footer), '' ) {
%         my $file = "invoice_html$suffix$tname";
%         my($label, $link_label) = length($templatename)
%                                     ? labels($file)
%                                     : ( '', 'edit' );

          <% $label %> <% $suffix2name{$suffix} %>
          (<A HREF="<% $p %>edit/invoice_template.html?type=html;suffix=<% $suffix %>;name=<% $templatename %>"><% $link_label %></A>)
          <BR>

%       }

      </TD>

      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">

%       my( $logo_label, $logo_link_label)= length( $templatename )
%                                             ? labels("logo_$templatename.eps")
%                                             : ( '', 'edit' );
        <% $logo_label %> Logo
        (<A HREF="<% $p %>edit/invoice_logo.html?type=eps;name=<% $templatename %>"><% $logo_link_label %></A>)
        <BR>

%       foreach my $suffix (qw( returnaddress notes footer smallfooter), '' ) {
%         my $file = "invoice_latex$suffix$tname";
%         my($label, $link_label) = length($templatename)
%                                     ? labels($file)
%                                     : ( '', 'edit' );

          <% $label %> <% $suffix2name{$suffix} %>
          (<A HREF="<% $p %>edit/invoice_template.html?type=latex;suffix=<% $suffix %>;name=<% $templatename %>"><% $link_label %></A>)
          <BR>

%       }

      </TD>

      <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">

%       my( $txt_label, $txtlink_label)=
%         length( $templatename )
%           ? labels("invoice_template_$templatename.png")
%           : ( 'Main template', 'edit' );
        <% $txt_label %> 
        (<A HREF="<% $p %>edit/invoice_template.html?type=text;name=<% $templatename %>"><% $txtlink_label %></A>)

      </TD>

    </TR>

% }

<% include("/elements/footer.html") %>

<%once>

my %suffix2name = (
  'returnaddress' => 'Return address',
  'notes'         => 'Notes',
  'footer'        => 'Footer',
  'smallfooter'   => 'Small footer',
  ''              => 'Main template',
);

my $conf = new FS::Conf;

sub labels {
  my $filename = shift;
  if ( $conf->exists($filename) ) {
    ( 'Custom', 'edit' );
  } else {
    ( 'Standard', 'customize' );
  }
}

</%once>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my @templatenames = $conf->invoice_templatenames;

</%init>