434042c9b31c251712f206a932a6bbb3b61f781c
[freeside.git] / httemplate / elements / tr-select-invoice.html
1 <%doc>
2
3 Example:
4
5   include( '/elements/tr-select-invoice.html',
6
7     #opt - most get used in /elements/tr-amount-fee
8     'cust_main'            => $cust_main,     # cust_main,
9     'status'               => 'open' # type of invoices to show.  Possible values are:
10                                      # open - shows only open invoices
11                                      # void - shows only voided invoices
12                                      # all  - shows all invoices, this is default if no status is set.
13     'prefix'               => 'pre', # prefix to fields and row ID's
14   )
15
16 </%doc>
17
18   <TR ID="invoice_row" STYLE="display:none;">
19     <TH ALIGN="right"><% mt('Open invoices') |h %></TH>
20     <TD>
21      <SELECT
22           ID       = "<% $opt{prefix} %>invoice"
23           NAME     = "<% $opt{prefix} %>invoice"
24           onChange = "<% $opt{prefix} %>invoice_select_changed(this)"
25         >
26                 <OPTION VALUE="select">Select an invoice to pay</OPTION>
27 %         foreach my $record (@invoices) {
28 %            my $read_date = time2str("%b %o, %Y", $record->_date);
29             <OPTION VALUE="<% $record->charged %>"><% $record->invnum %> (<% $read_date %>) - <% $record->charged %></OPTION>   
30 %         }
31
32         </SELECT>       
33     </TD>
34   </TR>
35
36 <%init>
37
38 my %opt = @_;
39 my $status = $opt{'status'} ? $opt{'status'} : 'all';
40
41 my @invoices;
42 if ($status eq "all") { @invoices = $opt{'cust_main'}->cust_bill; }
43 elsif ($status eq "open") { @invoices = $opt{'cust_main'}->open_cust_bill; }
44 elsif ($status eq "void") { @invoices = $opt{'cust_main'}->cust_bill_void; }
45
46 </%init>