X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Fcustomer-table.html;h=12b192e8cb4bf95154fcbe1576890496b9f33980;hb=25386efd0e3f725d6cef005eba729840d3b4b3cb;hp=b49bf0290069fb58afc9754038e69a95b0ab3c3e;hpb=05364e1a107233d35792a76bf6d23d00dd5611cf;p=freeside.git
diff --git a/httemplate/elements/customer-table.html b/httemplate/elements/customer-table.html
index b49bf0290..12b192e8c 100644
--- a/httemplate/elements/customer-table.html
+++ b/httemplate/elements/customer-table.html
@@ -25,7 +25,7 @@ Example:
'custnum_update_callback' => 'name_of_js_callback' #passed a rownum
#listrefs
- 'types' => ['immutable', ''], # immutable or ''/text
+ 'type' => ['immutable', ''], # immutable, checkbox, date or ''/text
'align' => [ 'c', 'l', 'r', '' ],
'size' => [], # sizes ignored for immutable
'color' => [],
@@ -37,10 +37,43 @@ Example:
)
-%doc>
+Some incomplete notes for javascript programmers:
+
+On page load, existing rows are initialized by passing values to addRow
+based on existing cgi values. An empty row (marked with the 'emptyrow'
+attribute) is created by invoking addRow without values. After that,
+to keep the non-empty row count (totalrows) accurate, use newEmptyRow to
+create the next row. There should only be one empty row at a time.
+
+Global vars:
+total_el - element for displaying total number of rows
+totalrows - total number of non-empty rows
+rownum - really more of a "next row" value, used by addRow
+allrows - array of tr elements, one for each row
+
+Don't confuse the global rownum with the element attribute rownum
+that is set as a reference point on some of the elements generated
+by this script. They have different values.
+Some of the functions:
+updateTotalRow() - updates total_el based on value of totalrows
+addDeleteButton(searchrow) - adds delete button to searchrow
+newEmptyRow() - replaces old empty row
+deleteRow() - removes the row specified by this.rownum
+addRow(values) - adds a new row (marked as empty if values aren't specified)
+
+This mason element is currently only used by misc/batch-cust_pay.html,
+and probably should be cleaned up more before being used by anything else.
+
+%doc>
+
+
+
+
+ var total_el, rownum, totalrows, allrows;
+
+ function addDeleteButton (searchrow) {
+ var td_delete = document.getElementById('delete'+searchrow);
+ var button_delete = document.createElement('INPUT');
+ button_delete.setAttribute('rownum', searchrow);
+ button_delete.setAttribute('type', 'button');
+ button_delete.setAttribute('value', 'X');
+ button_delete.onclick = deleteRow;
+ button_delete.style.color = '#ff0000';
+ button_delete.style.fontWeight = 'bold';
+ button_delete.style.paddingLeft = '2px';
+ button_delete.style.paddingRight = '2px';
+ td_delete.appendChild(button_delete);
+ }
-
+ function newEmptyRow (searchrow) {
+ // add delete button to current row
+ addDeleteButton(searchrow);
+ // mark current row as non-empty
+ var oldemptyrow = document.getElementById('row'+searchrow);
+ oldemptyrow.emptyrow = false;
+ // update totalrows
+ totalrows++
+ updateTotalRow();
+ // add a new empty row
+ addRow();
+ }
-
-
Inv #
-
Cust #
-
Status
-
Customer
-
Balance
-% foreach my $header ( @{$opt{header}} ) {
-
<% $header %>
+ function deleteRow() {
+ var thisrownum = this.getAttribute('rownum');
+% if ( $opt{delete_row_callback} ) {
+ // callback
+ <% $opt{delete_row_callback} %>(thisrownum);
% }
-
-% my $row = 0;
-% for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) {
-
-