summaryrefslogtreecommitdiff
path: root/httemplate/elements/tr-select-invoice.html
blob: d35813fc5aaf3f35f26ffb8f1ce39ef8ab5530ea (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
<%doc>

Example:

  include( '/elements/tr-select-invoice.html',

    #opt - most get used in /elements/tr-amount-fee
    'cust_main'            => $cust_main,     # cust_main,
    'status'               => 'open' # type of invoices to show.  Possible values are:
                                     # open - shows only open invoices
                                     # void - shows only voided invoices
                                     # all  - shows all invoices, this is default if no status is set.
    'prefix'               => 'pre', # prefix to fields and row ID's
  )

</%doc>

  <TR ID="invoice_row" STYLE="display:none;">
    <TH ALIGN="right"><% mt('Open invoices') |h %></TH>
    <TD>
     <SELECT
  	  ID       = "<% $opt{prefix} %>invoice"
  	  NAME     = "<% $opt{prefix} %>invoice"
  	  onChange = "<% $opt{prefix} %>invoice_select_changed(this)"
	>
  		<OPTION VALUE="select">Select an invoice to pay</OPTION>
%         foreach my $record (@invoices) {
%            my $read_date = time2str("%b %o, %Y", $record->_date);
%             $hidden .= '<INPUT TYPE="hidden" ID="inv'.$record->invnum.'" NAME="inv'.$record->invnum.'" VALUE="'.$record->owed.'">';
            <OPTION VALUE="<% $record->invnum %>"><% $record->invnum %> (<% $read_date %>) - <% $record->owed %></OPTION>
%         }

	</SELECT>

  <% $hidden %>

    </TD>
  </TR>

<%init>

my %opt = @_;
my $status = $opt{'status'} ? $opt{'status'} : 'all';
my $hidden;

my @invoices;
if ($status eq "all") { @invoices = $opt{'cust_main'}->cust_bill; }
elsif ($status eq "open") { @invoices = $opt{'cust_main'}->open_cust_bill; }
elsif ($status eq "void") { @invoices = $opt{'cust_main'}->cust_bill_void; }

</%init>