cust_main fields only
[freeside.git] / httemplate / elements / tr-select-invoice.html
index 03625b6..434042c 100644 (file)
@@ -1,15 +1,30 @@
+<%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 COLSPAN=7>
+    <TD>
      <SELECT
          ID       = "<% $opt{prefix} %>invoice"
          NAME     = "<% $opt{prefix} %>invoice"
          onChange = "<% $opt{prefix} %>invoice_select_changed(this)"
-         <% $opt{disabled} %>
        >
                <OPTION VALUE="select">Select an invoice to pay</OPTION>
-%         foreach my $record (@records) {
+%         foreach my $record (@invoices) {
 %            my $read_date = time2str("%b %o, %Y", $record->_date);
             <OPTION VALUE="<% $record->charged %>"><% $record->invnum %> (<% $read_date %>) - <% $record->charged %></OPTION>  
 %         }
 <%init>
 
 my %opt = @_;
+my $status = $opt{'status'} ? $opt{'status'} : 'all';
+
+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>