diff options
Diffstat (limited to 'httemplate/elements')
-rw-r--r-- | httemplate/elements/bill.html | 2 | ||||
-rw-r--r-- | httemplate/elements/city.html | 5 | ||||
-rw-r--r-- | httemplate/elements/columnstart.html | 2 | ||||
-rw-r--r-- | httemplate/elements/create_uri_query | 2 | ||||
-rw-r--r-- | httemplate/elements/customer-statement.html | 45 | ||||
-rw-r--r-- | httemplate/elements/customer-table.html | 595 | ||||
-rw-r--r-- | httemplate/elements/freeside.css | 18 | ||||
-rw-r--r-- | httemplate/elements/input-fcc_options.html | 2 | ||||
-rw-r--r-- | httemplate/elements/location.html | 8 | ||||
-rw-r--r-- | httemplate/elements/menu.html | 11 | ||||
-rw-r--r-- | httemplate/elements/pickcolor.html | 2 | ||||
-rw-r--r-- | httemplate/elements/popup_link_onclick.html | 2 | ||||
-rw-r--r-- | httemplate/elements/progress-init.html | 2 | ||||
-rw-r--r-- | httemplate/elements/select.html | 3 | ||||
-rw-r--r-- | httemplate/elements/standardize_locations.js | 4 | ||||
-rw-r--r-- | httemplate/elements/tr-input-mask.html | 2 | ||||
-rw-r--r-- | httemplate/elements/tr-pkg_svc.html | 13 |
17 files changed, 401 insertions, 317 deletions
diff --git a/httemplate/elements/bill.html b/httemplate/elements/bill.html index 64a1a6d2c..420a7489b 100644 --- a/httemplate/elements/bill.html +++ b/httemplate/elements/bill.html @@ -45,7 +45,7 @@ my $label = $opt{'label'}; # formname no longer needs to be passed from outside, but we still # need one and it needs to be unique my $formname = $opt{'formname'} || - 'bill'.sprintf('%04d',int(rand(10000))).$custnum; + 'bill'.sprintf('%04d',random_id(4)).$custnum; my $url = $opt{'url'} || ''; my $message = $opt{'message'} || 'Finished!'; my $bill_opts = $opt{'bill_opts'} || {}; diff --git a/httemplate/elements/city.html b/httemplate/elements/city.html index 5f4d4e09e..4e9a60940 100644 --- a/httemplate/elements/city.html +++ b/httemplate/elements/city.html @@ -159,6 +159,11 @@ my $disable_select = 1 if $conf->config('tax_district_method'); $opt{'disable_empty'} = 1 unless exists($opt{'disable_empty'}); +if ($conf->exists('cust_main-no_city_in_address')) { + $opt{'disable_text'} = 1; + $disable_select = 1; +} + my $text_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : []; my $select_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : []; diff --git a/httemplate/elements/columnstart.html b/httemplate/elements/columnstart.html index 1ffbcb9e8..245c308a7 100644 --- a/httemplate/elements/columnstart.html +++ b/httemplate/elements/columnstart.html @@ -10,7 +10,7 @@ Pass 'aligned' => 1 to have corresponding rows in the columns line up. </%doc> -% my $id = sprintf('table%08d', rand(100000000)); +% my $id = sprintf('table%08d', random_id(8)); <TR> <TD CLASS="background" COLSPAN=99> <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 id="<%$id%>"> diff --git a/httemplate/elements/create_uri_query b/httemplate/elements/create_uri_query index ce6249e0e..414d53ba4 100644 --- a/httemplate/elements/create_uri_query +++ b/httemplate/elements/create_uri_query @@ -18,7 +18,7 @@ my $query = $cgi->query_string; if ( length($query) > 1920 || $opt{secure} ) { #stupid IE 2083 URL limit - my $session = int(rand(4294967296)); #XXX + my $session = random_id(9); my $pref = new FS::access_user_pref({ 'usernum' => $FS::CurrentUser::CurrentUser->usernum, 'prefname' => "redirect$session", diff --git a/httemplate/elements/customer-statement.html b/httemplate/elements/customer-statement.html new file mode 100644 index 000000000..63c21cba3 --- /dev/null +++ b/httemplate/elements/customer-statement.html @@ -0,0 +1,45 @@ +<%doc> + +Formats customer payment history into a table. + + include('/elements/customer-statement.html', + 'history' => \@history + ); + +Option 'history' should be of the form returned by $cust_main->payment_history. +This element might be used directly by selfservice, so it does not (and should not) +pull data from the database. + +</%doc> + +% my $style = 'text-align: left; margin: 0; padding: 0 1em 0 0;'; +% my $moneystyle = 'text-align: right; margin: 0; padding: 0 1em 0 0;'; + +<TABLE STYLE="margin: 0;" CELLSPACING="0"> + <TR> + <TH STYLE="<% $style %> background: #ff9999;">Date</TH> + <TH STYLE="<% $style %> background: #ff9999;">Description</TH> + <TH STYLE="<% $moneystyle %> background: #ff9999;">Amount</TH> + <TH STYLE="<% $moneystyle %> background: #ff9999;">Balance</TH> + </TR> + +% my $col1 = "#ffffff"; +% my $col2 = "#dddddd"; +% my $col = $col1; +% foreach my $item (@{$opt{'history'}}) { + <TR> + <TD STYLE="<% $style %> background: <% $col %>;"><% $$item{'date_pretty'} %></TD> + <TD STYLE="<% $style %> background: <% $col %>;"><% $$item{'description'} %></TD> + <TD STYLE="<% $moneystyle %> background: <% $col %>;"><% $$item{'amount_pretty'} %></TD> + <TD STYLE="<% $moneystyle %> background: <% $col %>;"><% $$item{'balance_pretty'} %></TD> + </TR> +% $col = $col eq $col1 ? $col2 : $col1; +% } + +</TABLE> + +<%init> +my %opt = @_; + +die "Invalid type for history" unless ref($opt{'history'}) eq 'ARRAY'; +</%init> diff --git a/httemplate/elements/customer-table.html b/httemplate/elements/customer-table.html index 83abad010..76a7f12f6 100644 --- a/httemplate/elements/customer-table.html +++ b/httemplate/elements/customer-table.html @@ -37,6 +37,34 @@ Example: ) +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> <SCRIPT TYPE="text/javascript"> @@ -112,7 +140,7 @@ Example: } } - function <% $opt{prefix} %>search_invnum() { + function search_invnum() { this.style.color = '#000000' @@ -128,8 +156,8 @@ Example: return; } - if ( ( <% $opt{prefix} %>rownum - searchrow ) == 1 ) { - <% $opt{prefix} %>addRow(); + if ( document.getElementById('row'+searchrow).emptyrow ) { + newEmptyRow(searchrow); } var customer = document.getElementById('customer'+searchrow); customer.value = 'searching...'; @@ -153,7 +181,7 @@ Example: update_customer(searchrow, customerArray); % if ( $opt{invnum_update_callback} ) { - <% $opt{invnum_update_callback} %>(searchrow, '<% $opt{prefix} %>') + <% $opt{invnum_update_callback} %>(searchrow) % } } @@ -162,7 +190,7 @@ Example: } - function <% $opt{prefix} %>search_custnum() { + function search_custnum() { this.style.color = '#000000' @@ -179,8 +207,8 @@ Example: return; } - if ( ( <% $opt{prefix} %>rownum - searchrow ) == 1 ) { - <% $opt{prefix} %>addRow(); + if ( document.getElementById('row'+searchrow).emptyrow ) { + newEmptyRow(searchrow); } var customer_obj = document.getElementById('customer'+searchrow); @@ -214,7 +242,7 @@ Example: update_customer(searchrow, customerArrayArray[0]); % if ( $opt{custnum_update_callback} ) { - <% $opt{custnum_update_callback} %>(searchrow, '<% $opt{prefix} %>') + <% $opt{custnum_update_callback} %>(searchrow) % } } else { @@ -248,7 +276,7 @@ Example: } - function <% $opt{prefix} %>search_customer() { + function search_customer() { var customer_obj = this; var searchrow = this.getAttribute('rownum'); @@ -262,8 +290,8 @@ Example: return; } - if ( ( <% $opt{prefix} %>rownum - searchrow ) == 1 ) { - <% $opt{prefix} %>addRow(); + if ( document.getElementById('row'+searchrow).emptyrow ) { + newEmptyRow(searchrow); } var invnum = document.getElementById('invnum'+searchrow); @@ -292,7 +320,7 @@ Example: update_customer(searchrow, customerArrayArray[0]); % if ( $opt{custnum_update_callback} ) { - <% $opt{custnum_update_callback} %>(searchrow, '<% $opt{prefix} %>') + <% $opt{custnum_update_callback} %>(searchrow) % } } else { @@ -355,7 +383,7 @@ Example: update_customer(searchrow, JSON.parse(custnum_balance_status)); % if ( $opt{custnum_update_callback} ) { - <% $opt{custnum_update_callback} %>(searchrow, '<% $opt{prefix} %>') + <% $opt{custnum_update_callback} %>(searchrow) % } } @@ -385,255 +413,104 @@ Example: } function update_num_open(rownum, newval) { + document.getElementById('num_open'+rownum).value = newval; num_open_invoices[rownum] = newval; } + // updates display of total rows based on value of totalrows + function updateTotalRow () { + if ( totalrows == 1 ) { + total_el.innerHTML = + 'Total ' + + totalrows + + ' <% $opt{name_singular} || 'customer' %>'; + } else { + total_el.innerHTML = + 'Total ' + + totalrows + + ' <% PL($opt{name_singular} || 'customer') %>'; + } + } -</SCRIPT> - -<TABLE ID="<% $opt{prefix} %>OneTrueTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0> - -<TR> - <TH>Inv #</TH> - <TH>Cust #</TH> - <TH>Status</TH> - <TH>Customer</TH> - <TH>Balance</TH> -% foreach my $header ( @{$opt{header}} ) { - <TH><% $header %></TH> -% } -</TR> -% my $row = 0; -% for ( $row = 0; exists($param->{"custnum$row"}); $row++ ) { - - <TR id="row<%$row%>" rownum="<%$row%>"> - <TD> - <INPUT TYPE = "text" - NAME = "invnum<% $row %>" - ID = "invnum<% $row %>" - SIZE = 8 - MAXLENGTH = 12 - STYLE = "text-align:right;" - VALUE = "<% $param->{"invnum$row"} %>" - rownum = "<% $row %>" - > - <SCRIPT TYPE="text/javascript"> - var invnum_input<% $row %> = document.getElementById("invnum<% $row %>"); - invnum_input<% $row %>.onfocus = clearhint_invnum; - invnum_input<% $row %>.onchange = <% $opt{prefix} %>search_invnum; - </SCRIPT> - </TD> - - <TD> - <INPUT TYPE = "text" - NAME = "display_custnum<% $row %>" - ID = "display_custnum<% $row %>" - SIZE = 8 - MAXLENGTH = 12 - STYLE = "text-align:right;" - VALUE = "<% $param->{"display_custnum$row"} %>" - rownum = "<% $row %>" - > - <INPUT TYPE = "hidden" - NAME = "custnum<% $row %>" - ID = "custnum<% $row %>" - VALUE = "<% $param->{"custnum$row"} %>" - rownum = "<% $row %>" - > - <SCRIPT TYPE="text/javascript"> - var custnum_input<% $row %> = document.getElementById("display_custnum<% $row %>"); - custnum_input<% $row %>.onfocus = clearhint_custnum; - custnum_input<% $row %>.onchange = <% $opt{prefix} %>search_custnum; - </SCRIPT> - </TD> - - <TD STYLE="text-align: center"> - <SPAN - ID = "status<% $row %>_text" - rownum = "<% $row %>" - STYLE = "font-weight: bold; - color: <%$param->{"statuscolor$row"} || '#000000'%>" - - ><% $param->{"status$row"} %></SPAN> - <INPUT TYPE = "hidden" - NAME = "status<% $row %>" - ID = "status<% $row %>" - VALUE = "<% $param->{"status$row"} %>" - rownum = "<% $row %>" - > - <INPUT TYPE = "hidden" - NAME = "statuscolor<% $row %>" - ID = "statuscolor<% $row %>" - VALUE = "<% $param->{"statuscolor$row"} %>" - rownum = "<% $row %>" - > - </TD> - - <TD> - <INPUT TYPE="text" NAME="customer<% $row %>" ID="customer<% $row %>" SIZE=64 VALUE="<% $param->{"customer$row"} %>" rownum="<% $row %>"> - <SCRIPT TYPE="text/javascript"> - var customer_input<% $row %> = document.getElementById("customer<% $row %>"); - customer_input<% $row %>.onfocus = clearhint_customer; - customer_input<% $row %>.onclick = clearhint_customer; - customer_input<% $row %>.onchange = <% $opt{prefix} %>search_customer; - </SCRIPT> - <SELECT NAME="cust_select<% $row %>" ID="cust_select<% $row %>" rownum="<% $row %>" STYLE="color:#ff0000; display:none"> - </SELECT> - <SCRIPT TYPE="text/javascript"> - var customer_select<% $row %> = document.getElementById("cust_select<% $row %>"); - customer_select<% $row %>.onchange = select_customer; - </SCRIPT> - </TD> - - <TD STYLE="text-align:right"> - <% $money_char %> - <SPAN - ID = "balance<% $row %>_text" - rownum = "<% $row %>" - ><% $param->{"balance$row"} %></SPAN> - - <INPUT TYPE = "hidden" - NAME = "balance<% $row %>" - ID = "balance<% $row %>" - VALUE = "<% $param->{"balance$row"} %>" - rownum = "<% $row %>" - > - </TD> + 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); + } -% my $col = 0; -% foreach my $field ( @{$opt{fields}} ) { -% my $value; -% if ( ref($field) eq 'CODE' ) { -% $value = &{$field}($row,$param); -% } else { -% $value = $param->{"$field$row"}; -% } -% my $name = (ref($field) eq 'CODE') ? "column${col}_$row" : "$field$row"; -% my $align = $align{ $opt{align}->[$col] || 'l' }; -% my $size = $sizes->[$col] || 10; -% my $color = $opt{color}->[$col]; -% my $font = $color ? qq(<FONT COLOR="$color">) : ''; -% my $onchange = ''; -% if ( $opt{onchange}->[$col] ) { -% $onchange = 'onchange="'.$opt{onchange}->[$col].'"'; -% } -% elsif ( $opt{footer}->[$col] eq '_TOTAL' ) { -% $total[$col] += $value; -% $onchange = $opt{prefix}. "calc_total$col();"; -% $onchange = qq(onchange="$onchange" onkeyup="$onchange"); -% } - <TD ALIGN="<% $align %>"> -% my $type = $types->[$col] || 'text'; -% if ($type eq 'text' or $type eq 'checkbox') { - <INPUT TYPE = "<% $type %>" - NAME = "<% $name %>" - ID = "<% $name %>" - SIZE = "<% $size %>" - STYLE = "text-align: <% $align %>;" - VALUE = "<% $value %>" - rownum = "<% $row %>" - <% $onchange %> - > -% } elsif ($types->[$col] eq 'immutable') { - <% $font %><% $value %><% $font ? '</FONT>' : '' %> - <INPUT TYPE="hidden" ID="<% $name %>" NAME="<% $name %>" VALUE="<% $value %>" > -% } else { - Cannot represent unknown type: <% $types->[$col] %> -% } - </TD> -% $col++; -% } - </TR> -% } + 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(); + } -<TR id="row_total"> - <TH COLSPAN=5 ID="<% $opt{'prefix'} %>_TOTAL_TOTAL"> - Total <% $row ? $row-1 : 0 %> - <% PL($opt{name_singular} || 'customer', ( $row ? $row-1 : 0 ) ) %> - </TH> -% my $col = 0; -% foreach my $footer ( @{$opt{footer}} ) { -% my $align = $align{ $opt{'footer_align'}->[$col] || 'c' }; -% if ($footer eq '_TOTAL' ) { -% my $id = $opt{'fields'}->[$col]; -% $id = ref($id) ? "column${col}_TOTAL" : "${id}_TOTAL"; - <TH ALIGN="<% $align %>" ID="<% $id %>"> <% sprintf('%.2f', $total[$col] ) %></TH> -% } else { - <TH ALIGN="<% $align %>"><% $footer %></TH> -% } -% $col++; + function deleteRow() { + var thisrownum = this.getAttribute('rownum'); +% if ( $opt{delete_row_callback} ) { + // callback + <% $opt{delete_row_callback} %>(thisrownum); % } -</TR> - -</TABLE> - -<SCRIPT TYPE="text/javascript"> + // remove the actual row + var thisrow = document.getElementById('row'+thisrownum); + thisrow.parentNode.removeChild(thisrow); + // remove row from tally of all rows + var newrows = []; + for (i = 0; i < allrows.length; i++) { + if (allrows[i] == thisrownum) continue; + newrows.push(allrows[i]); + } + allrows = newrows; + totalrows--; // should never be deleting empty rows + updateTotalRow(); + // recalculate column totals, if any % my $col = 0; % foreach my $footer ( @{$opt{footer}} ) { % if ($footer eq '_TOTAL' ) { -% my $name = $opt{fields}->[$col]; -% $name = ref($name) ? "column$col" : $name; - var <% $opt{prefix}.$name %>_CACHE = new Array (); - var <% $opt{prefix} %>th_el = document.getElementById("<%$name%>_TOTAL"); - function <% $opt{prefix} %>calc_total<% $col %>() { - var row = 0; - var total = 0; - for ( var row = 0; - - ( <% $opt{prefix}.$name%>_CACHE[row] = - <% $opt{prefix}.$name%>_CACHE[row] - || document.getElementById("<%$name%>"+row) - ) != null; - - row++ - ) - { - var value = <%$name%>_CACHE[row].value; - value = parseFloat(value); - if ( ! isNaN(value) ) { - total = total + value; - } - } - <% $opt{prefix} %>th_el.innerHTML = ' ' + total.toFixed(2); - - } + calc_total<% $col %>() % } % $col++; % } -</SCRIPT> - -<% include('/elements/xmlhttp.html', - 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi', - 'subs' => [qw( custnum_search smart_search invnum_search )], - ) -%> - -<SCRIPT TYPE="text/javascript"> - - var <% $opt{prefix} %>total_el = - document.getElementById("<% $opt{'prefix'} %>_TOTAL_TOTAL"); - - var <% $opt{prefix} %>rownum = <% $row %>; + } - function <% $opt{prefix} %>addRow() { + function addRow(values) { - var table = document.getElementById('<% $opt{prefix} %>OneTrueTable'); + var table = document.getElementById('OneTrueTable'); var tablebody = table.getElementsByTagName('tbody').item(0); var row = table.insertRow(table.rows.length - 1); - row.setAttribute('id', 'row'+rownum); + var thisrownum = values ? values.rownum : rownum; + row.setAttribute('id', 'row'+thisrownum); + row.emptyrow = values ? false : true; var invnum_cell = document.createElement('TD'); var invnum_input = document.createElement('INPUT'); - invnum_input.setAttribute('name', 'invnum'+<% $opt{prefix} %>rownum); - invnum_input.setAttribute('id', 'invnum'+<% $opt{prefix} %>rownum); + invnum_input.setAttribute('name', 'invnum'+thisrownum); + invnum_input.setAttribute('id', 'invnum'+thisrownum); invnum_input.style.textAlign = 'right'; invnum_input.setAttribute('size', 8); invnum_input.setAttribute('maxlength', 12); - invnum_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + invnum_input.setAttribute('rownum', thisrownum); + invnum_input.value = values ? values.invnum : ''; invnum_input.onfocus = clearhint_invnum; - invnum_input.onchange = <% $opt{prefix} %>search_invnum; + invnum_input.onchange = search_invnum; invnum_cell.appendChild(invnum_input); row.appendChild(invnum_cell); @@ -641,21 +518,23 @@ Example: var custnum_cell = document.createElement('TD'); var display_custnum_input = document.createElement('INPUT'); - display_custnum_input.setAttribute('name', 'display_custnum'+<% $opt{prefix} %>rownum); - display_custnum_input.setAttribute('id', 'display_custnum'+<% $opt{prefix} %>rownum); + display_custnum_input.setAttribute('name', 'display_custnum'+thisrownum); + display_custnum_input.setAttribute('id', 'display_custnum'+thisrownum); display_custnum_input.style.textAlign = 'right'; display_custnum_input.setAttribute('size', 8); display_custnum_input.setAttribute('maxlength', 12); - display_custnum_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + display_custnum_input.setAttribute('rownum', thisrownum); + display_custnum_input.value = values ? values.custnum : ''; display_custnum_input.onfocus = clearhint_custnum; - display_custnum_input.onchange = <% $opt{prefix} %>search_custnum; + display_custnum_input.onchange = search_custnum; custnum_cell.appendChild(display_custnum_input); var custnum_input = document.createElement('INPUT'); custnum_input.type = 'hidden'; - custnum_input.setAttribute('name', 'custnum'+<% $opt{prefix} %>rownum); - custnum_input.setAttribute('id', 'custnum'+<% $opt{prefix} %>rownum); - custnum_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + custnum_input.setAttribute('name', 'custnum'+thisrownum); + custnum_input.setAttribute('id', 'custnum'+thisrownum); + custnum_input.setAttribute('rownum', thisrownum); + custnum_input.value = values ? values.custnum : ''; custnum_cell.appendChild(custnum_input); row.appendChild(custnum_cell); @@ -664,23 +543,29 @@ Example: status_cell.style.textAlign = 'center'; var status_span = document.createElement('SPAN'); - status_span.setAttribute('id', 'status'+<% $opt{prefix} %>rownum+'_text'); + status_span.setAttribute('id', 'status'+thisrownum+'_text'); status_span.style.fontWeight = 'bold'; - status_span.setAttribute('rownum', <% $opt{prefix} %>rownum); + status_span.style.color = values ? values.statuscolor : ''; + status_span.setAttribute('rownum', thisrownum); + status_span.appendChild( + document.createTextNode(values ? values.status : '') + ); status_cell.appendChild(status_span); var status_input = document.createElement('INPUT'); status_input.setAttribute('type', 'hidden'); - status_input.setAttribute('name', 'status'+<% $opt{prefix} %>rownum); - status_input.setAttribute('id', 'status'+<% $opt{prefix} %>rownum); - status_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + status_input.setAttribute('name', 'status'+thisrownum); + status_input.setAttribute('id', 'status'+thisrownum); + status_input.setAttribute('rownum', thisrownum); + status_input.value = values ? values.status : ''; status_cell.appendChild(status_input); var statuscolor_input = document.createElement('INPUT'); statuscolor_input.setAttribute('type', 'hidden'); - statuscolor_input.setAttribute('name', 'statuscolor'+<% $opt{prefix} %>rownum); - statuscolor_input.setAttribute('id', 'statuscolor'+<% $opt{prefix} %>rownum); - statuscolor_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + statuscolor_input.setAttribute('name', 'statuscolor'+thisrownum); + statuscolor_input.setAttribute('id', 'statuscolor'+thisrownum); + statuscolor_input.setAttribute('rownum', thisrownum); + statuscolor_input.value = values ? values.statuscolor : ''; status_cell.appendChild(statuscolor_input); row.appendChild(status_cell); @@ -688,20 +573,21 @@ Example: var customer_cell = document.createElement('TD'); var customer_input = document.createElement('INPUT'); - customer_input.setAttribute('name', 'customer'+<% $opt{prefix} %>rownum); - customer_input.setAttribute('id', 'customer'+<% $opt{prefix} %>rownum); + customer_input.setAttribute('name', 'customer'+thisrownum); + customer_input.setAttribute('id', 'customer'+thisrownum); customer_input.setAttribute('size', 64); customer_input.setAttribute('value', '(last name or company)' ); - customer_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + customer_input.setAttribute('rownum', thisrownum); + customer_input.value = values ? values.customer : ''; customer_input.onfocus = clearhint_customer; customer_input.onclick = clearhint_customer; - customer_input.onchange = <% $opt{prefix} %>search_customer; + customer_input.onchange = search_customer; customer_cell.appendChild(customer_input); var customer_select = document.createElement('SELECT'); - customer_select.setAttribute('name', 'cust_select'+<% $opt{prefix} %>rownum); - customer_select.setAttribute('id', 'cust_select'+<% $opt{prefix} %>rownum); - customer_select.setAttribute('rownum', <% $opt{prefix} %>rownum); + customer_select.setAttribute('name', 'cust_select'+thisrownum); + customer_select.setAttribute('id', 'cust_select'+thisrownum); + customer_select.setAttribute('rownum', thisrownum); customer_select.style.color = '#ff0000'; customer_select.style.display = 'none'; customer_select.onchange = select_customer; @@ -715,21 +601,29 @@ Example: balance_cell.appendChild(document.createTextNode('<%$money_char%>')); var balance_span = document.createElement('SPAN'); - balance_span.setAttribute('id', 'balance'+<% $opt{prefix} %>rownum+'_text'); - balance_span.setAttribute('rownum', <% $opt{prefix} %>rownum); + balance_span.setAttribute('id', 'balance'+thisrownum+'_text'); + balance_span.setAttribute('rownum', thisrownum); balance_cell.appendChild(balance_span); balance_cell.appendChild( - document.createTextNode(String.fromCharCode(160)) // + document.createTextNode(String.fromCharCode(160) + (values ? values.balance : '')) // ); var balance_input = document.createElement('INPUT'); balance_input.setAttribute('type', 'hidden'); - balance_input.setAttribute('name', 'balance'+<% $opt{prefix} %>rownum); - balance_input.setAttribute('id', 'balance'+<% $opt{prefix} %>rownum); - balance_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + balance_input.setAttribute('name', 'balance'+thisrownum); + balance_input.setAttribute('id', 'balance'+thisrownum); + balance_input.setAttribute('rownum', thisrownum); + balance_input.value = values ? values.balance : ''; balance_cell.appendChild(balance_input); + var num_open_input = document.createElement('INPUT'); + num_open_input.setAttribute('type', 'hidden'); + num_open_input.setAttribute('name', 'num_open'+thisrownum); + num_open_input.setAttribute('id', 'num_open'+thisrownum); + num_open_input.setAttribute('rownum', thisrownum); + balance_cell.appendChild(num_open_input); + row.appendChild(balance_cell); % my $col = 0; @@ -737,37 +631,35 @@ Example: var my_cell = document.createElement('TD'); my_cell.setAttribute('align', '<% $align{ $opt{align}->[$col] || 'l' } %>'); +% if ($opt{'color'}->[$col]) { + my_cell.style.color = '<% $opt{color}->[$col] %>'; +% } % if ($types->[$col] eq 'immutable') { -% my $value; -% if ( ref($field) eq 'CODE' ) { -% $value = &{$field}($row,$param); -% } else { -% $value = $param->{"$field$row"}; -% } - var my_text = document.createTextNode(<% $value |js_string %>); + var my_text = document.createTextNode(values ? values.<% $field %> : ''); my_cell.appendChild(my_text); % } % my $name = (ref($field) eq 'CODE') ? "column${col}_" : $field; var my_input = document.createElement('INPUT'); - my_input.setAttribute('name', '<% $name %>'+<% $opt{prefix} %>rownum); - my_input.setAttribute('id', '<% $name %>'+<% $opt{prefix} %>rownum); + my_input.setAttribute('name', '<% $name %>'+thisrownum); + my_input.setAttribute('id', '<% $name %>'+thisrownum); my_input.style.textAlign = '<% $align{ $opt{align}->[$col] || 'l' } %>'; my_input.setAttribute('size', <% $sizes->[$col] || 10 %>); - my_input.setAttribute('rownum', <% $opt{prefix} %>rownum); + my_input.setAttribute('rownum', thisrownum); % if ( $types->[$col] eq 'immutable' ) { - my_input.setAttribute('type', 'hidden'); -% } -% elsif ( $types->[$col] eq 'checkbox' ) { - my_input.setAttribute('type', 'checkbox'); + my_input.setAttribute('type', 'hidden'); +% } elsif ( $types->[$col] eq 'checkbox' ) { + my_input.setAttribute('type', 'checkbox'); + my_input.checked = (values && values.<% $field %>) ? true : false; % } + my_input.value = (values && values.<% $field %>) || ''; % if ( $opt{onchange}->[$col] ) { my_input.onchange = <% $opt{onchange}->[$col] %>; % } % elsif ( $opt{footer}->[$col] eq '_TOTAL' ) { - my_input.onchange = <% $opt{prefix} %>calc_total<%$col%>; - my_input.onkeyup = <% $opt{prefix} %>calc_total<%$col%>; + my_input.onchange = calc_total<%$col%>; + my_input.onkeyup = calc_total<%$col%>; % } my_cell.appendChild(my_input); @@ -776,41 +668,144 @@ Example: % $col++; % } - //update the total # of rows display - if ( <% $opt{prefix} %>rownum == 1 ) { - <% $opt{prefix} %>total_el.innerHTML = - 'Total ' - + <% $opt{prefix} %>rownum - + ' <% $opt{name_singular} || 'customer' %>'; - } else { - <% $opt{prefix} %>total_el.innerHTML = - 'Total ' - + <% $opt{prefix} %>rownum - + ' <% PL($opt{name_singular} || 'customer') %>'; + var td_delete = document.createElement('TD'); + td_delete.setAttribute('id', 'delete'+thisrownum); + row.appendChild(td_delete); + if (values) { + addDeleteButton(thisrownum); } + update_num_open(thisrownum, (values ? values.num_open : '0')); + % if ( $opt{add_row_callback} ) { - <% $opt{add_row_callback} %>(<% $opt{prefix} %>rownum, - '<% $opt{prefix} %>'); + <% $opt{add_row_callback} %>(thisrownum, values); % } - <% $opt{prefix} %>rownum++; + // update the total number of rows display + allrows.push(thisrownum); + if (values) totalrows++; + updateTotalRow(); - } + // update the next available row number + if (thisrownum >= rownum) { + rownum = thisrownum + 1; + } + + } // end of addRow + + +</SCRIPT> + +<TABLE ID="OneTrueTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0> -% unless ($cgi->param('error')) { - <% $opt{prefix} %>addRow(); +<TR> + <TH>Inv #</TH> + <TH>Cust #</TH> + <TH>Status</TH> + <TH>Customer</TH> + <TH>Balance</TH> +% foreach my $header ( @{$opt{header}} ) { + <TH><% $header %></TH> +% } +</TR> + +% my @rownums = sort { $a <=> $b } map /^custnum(\d+)$/, keys %$param; +<TR id="row_total"> + <TH COLSPAN=5 ID="_TOTAL_TOTAL"> + Total <% @rownums || 0 %> + <% PL($opt{name_singular} || 'customer', ( @rownums || 0 ) ) %> + </TH> +% my $col = 0; +% foreach my $footer ( @{$opt{footer}} ) { +% my $align = $align{ $opt{'footer_align'}->[$col] || 'c' }; +% if ($footer eq '_TOTAL' ) { +% my $id = $opt{'fields'}->[$col]; +% $id = ref($id) ? "column${col}_TOTAL" : "${id}_TOTAL"; + <TH ALIGN="<% $align %>" ID="<% $id %>"> <% sprintf('%.2f', $total[$col] ) %></TH> +% } else { + <TH ALIGN="<% $align %>"><% $footer %></TH> +% } +% $col++; +% } +</TR> + +</TABLE> + +<SCRIPT TYPE="text/javascript"> + +total_el = + document.getElementById("_TOTAL_TOTAL"); + +rownum = 1; // really more of a "next row", used by addrow +totalrows = 0; // will not include empty rows +allrows = []; // will include empty rows + +% foreach my $row ( @rownums ) { +% if ( grep($param->{$_.$row},qw(invnum display_custnum custnum status statuscolor customer balance),@{$opt{fields}} ) ) { + +addRow({ + rownum:<% $row %>, + num_open:<% $param->{"num_open$row"} |js_string %>, + invnum:<% $param->{"invnum$row"} |js_string %>, + display_custnum:<% $param->{"display_custnum$row"} |js_string %>, + custnum:<% $param->{"custnum$row"} |js_string %>, + status:<% $param->{"status$row"} |js_string %>, + statuscolor:<% $param->{"statuscolor$row"} |js_string %>, + customer:<% $param->{"customer$row"} |js_string %>, + balance:<% $param->{"balance$row"} |js_string %>, +% my $col = 0; +% foreach my $field ( @{$opt{fields}} ) { +% my $value; +% if ( ref($field) eq 'CODE' ) { +% $value = &{$field}($row,$param) || ''; +% } else { +% $value = $param->{"$field$row"} || ''; +% } +% my $name = (ref($field) eq 'CODE') ? "column${col}" : "$field"; + <% $name %>:<% $value |js_string %>, +% $col++; +% } +}); +% } +% } + +addRow(); + +% my $col = 0; +% foreach my $footer ( @{$opt{footer}} ) { +% if ($footer eq '_TOTAL' ) { +% my $name = $opt{fields}->[$col]; +% $name = ref($name) ? "column$col" : $name; + var th_el = document.getElementById("<%$name%>_TOTAL"); + function calc_total<% $col %>() { + var row = 0; + var total = 0; + for (i = 0; i < allrows.length; i++) { + var value = document.getElementById("<%$name%>"+allrows[i]).value; + value = parseFloat(value); + if ( ! isNaN(value) ) { + total = total + value; + } + } + th_el.innerHTML = ' ' + total.toFixed(2); + } + calc_total<% $col %>() +% } +% $col++; % } </SCRIPT> +<% include('/elements/xmlhttp.html', + 'url' => $p. 'misc/xmlhttp-cust_main-search.cgi', + 'subs' => [qw( custnum_search smart_search invnum_search )], + ) +%> + <%init> my(%opt) = @_; my $conf = new FS::Conf; -$opt{prefix} = '' unless defined $opt{prefix}; -$opt{prefix} .= '_' if $opt{prefix}; - my $types = $opt{'type'} ? [ @{$opt{'type'}} ] : []; my $sizes = $opt{'size'} ? [ @{$opt{'size'}} ] : []; diff --git a/httemplate/elements/freeside.css b/httemplate/elements/freeside.css index 4ba0f3f7d..f6d73c2de 100644 --- a/httemplate/elements/freeside.css +++ b/httemplate/elements/freeside.css @@ -278,6 +278,24 @@ td.grid { empty-cells: show; } +tr.row0 { + background-color: #eeeeee; +} + +tr.row1 { + background-color: #ffffff; +} + +.grid tfoot tr { + background-color: #dddddd; + font-style: italic; +} + +/* border at the top of the footer, but not between footer rows */ +.grid tfoot tr:first-child td { + border-top: 1px dashed black; +} + table.inv { border: none } th.inv { border: none } td.inv { border: none } diff --git a/httemplate/elements/input-fcc_options.html b/httemplate/elements/input-fcc_options.html index 064c647fc..080b40f88 100644 --- a/httemplate/elements/input-fcc_options.html +++ b/httemplate/elements/input-fcc_options.html @@ -9,7 +9,7 @@ % } % unless ($opt{html_only}) { % my $popup = $fsurl.'misc/part_pkg_fcc_options.html?id='; -% my $popup_name = 'popup-'.time. "-$$-". rand() * 2**32; +% my $popup_name = 'popup-'.random_id(); <SCRIPT TYPE="text/javascript"> function edit_fcc_options() { var id = this.dataset['target']; diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html index 214a7d5f2..b50509aea 100644 --- a/httemplate/elements/location.html +++ b/httemplate/elements/location.html @@ -169,7 +169,11 @@ Example: <TR> - <<%$th%> ALIGN="right"><%$r%><% mt('City') |h %></<%$th%>> + <<%$th%> ALIGN="right"> +% unless ($conf->exists('cust_main-no_city_in_address')) { + <% $r %><% mt('City') |h %> +% } + </<%$th%>> <TD WIDTH="1"><% include('/elements/city.html', %select_hash, 'text_style' => \@style ) %></TD> <<%$th%> ALIGN="right" WIDTH="1" ID="<%$pre%>countylabel" <%$county_style%>><%$r%>County</<%$th%>> <TD WIDTH="1"><% include('/elements/select-county.html', %select_hash ) %></TD> @@ -285,7 +289,7 @@ Example: var clear_coords_on_change = [ '<%$pre%>address1', '<%$pre%>address2', - '<%$pre%>city', + <% $conf->exists('cust_main-no_city_in_address') ? '' : qq('${pre}city',) %> '<%$pre%>state', '<%$pre%>zip', '<%$pre%>country' diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 34bba7e8c..f96c05ea5 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -290,7 +290,8 @@ $report_rating{'Unrateable CDRs'} = [ $fsurl.'search/cdr.html?freesidestatus=fai if $curuser->access_right("Usage: Unrateable CDRs"); if ( $curuser->access_right("Usage: Time worked") ) { $report_rating{'Time worked'} = [ $fsurl.'search/report_rt_transaction.html', '' ]; - $report_rating{'Time worked summary'} = [ $fsurl.'search/report_rt_ticket.html', '' ]; + $report_rating{'Time worked summary per ticket'} = [ $fsurl.'search/report_rt_ticket.html', '' ]; + $report_rating{'Time worked summary per customer'} = [ $fsurl.'search/report_rt_cust.html', '' ]; } tie my %report_ticketing_statistics, 'Tie::IxHash', @@ -737,10 +738,10 @@ $config_misc{'Message templates'} = [ $fsurl.'browse/msg_template.html', 'Templa $config_misc{'Advertising sources'} = [ $fsurl.'browse/part_referral.html', 'Where a customer heard about your service.' ] if $curuser->access_right('Edit advertising sources') || $curuser->access_right('Edit global advertising sources'); -if ( $curuser->access_right('Configuration') ) { - $config_misc{'Custom fields'} = [ $fsurl.'browse/part_virtual_field.html', 'Locally defined fields', ]; - $config_misc{'Translation strings'} = [ $fsurl.'browse/msgcat.html', 'Translations and other customizable labels for each locale' ]; -} +$config_misc{'Custom fields'} = [ $fsurl.'browse/part_virtual_field.html', 'Locally defined fields', ] + if $curuser->access_right('Edit custom fields'); +$config_misc{'Translation strings'} = [ $fsurl.'browse/msgcat.html', 'Translations and other customizable labels for each locale' ] + if $curuser->access_right('Configuration'); $config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ] if $curuser->access_right('Edit inventory') || $curuser->access_right('Edit global inventory') diff --git a/httemplate/elements/pickcolor.html b/httemplate/elements/pickcolor.html index d410ebfc7..2b0647fbf 100644 --- a/httemplate/elements/pickcolor.html +++ b/httemplate/elements/pickcolor.html @@ -38,7 +38,7 @@ my %opt = @_; my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value}; -my $unum = int(rand(100000)); +my $unum = random_id(5); my $id = $opt{'id'} || $opt{'field'}.$unum; diff --git a/httemplate/elements/popup_link_onclick.html b/httemplate/elements/popup_link_onclick.html index 5173115a5..09ce93e7a 100644 --- a/httemplate/elements/popup_link_onclick.html +++ b/httemplate/elements/popup_link_onclick.html @@ -62,7 +62,7 @@ $scrolling = $params->{'scrolling'} if exists $params->{'scrolling'}; #stupid safari is caching the "location" of popup iframs, and submitting them #instead of displaying them. this should prevent that. -my $popup_name = 'popup-'.time. "-$$-". rand() * 2**32; +my $popup_name = 'popup-'.random_id(); my $onclick = "overlib( OLiframeContent($action, $width, $height, '$popup_name', 0, '$scrolling' ), ". diff --git a/httemplate/elements/progress-init.html b/httemplate/elements/progress-init.html index 5b42aa1a8..2728240ef 100644 --- a/httemplate/elements/progress-init.html +++ b/httemplate/elements/progress-init.html @@ -170,6 +170,6 @@ $progress_url->query_form( #stupid safari is caching the "location" of popup iframs, and submitting them #instead of displaying them. this should prevent that. -my $popup_name = 'popup-'.time. "-$$-". rand() * 2**32; +my $popup_name = 'popup-'.random_id(); </%init> diff --git a/httemplate/elements/select.html b/httemplate/elements/select.html index 67ef51418..4492681de 100644 --- a/httemplate/elements/select.html +++ b/httemplate/elements/select.html @@ -4,6 +4,7 @@ ID = "<% $opt{id} %>" previousValue = "<% $curr_value %>" previousText = "<% $labels->{$curr_value} || $curr_value %>" + <% $multiple %> <% $size %> <% $style %> <% $opt{disabled} %> @@ -74,4 +75,6 @@ my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : ''; my $size = $opt{'size'} ? 'SIZE='.$opt{'size'} : ''; +my $multiple = $opt{'multiple'} ? 'MULTIPLE' : ''; + </%init> diff --git a/httemplate/elements/standardize_locations.js b/httemplate/elements/standardize_locations.js index f114e341c..56b2be990 100644 --- a/httemplate/elements/standardize_locations.js +++ b/httemplate/elements/standardize_locations.js @@ -13,7 +13,7 @@ function form_address_info() { % } % for my $pre (@prefixes) { % # normal case -% for my $field (qw(address1 address2 city state zip country)) { +% for my $field (qw(address1 address2 state zip country), ($conf->exists('cust_main-no_city_in_address') ? () : 'city')) { returnobj['<% $pre %><% $field %>'] = cf.elements['<% $pre %><% $field %>'].value; % } #for $field % if ( $withcensus ) { @@ -145,7 +145,7 @@ function replace_address() { var clean = newaddr['<% $pre %>addr_clean'] == 'Y'; var error = newaddr['<% $pre %>error']; if ( clean ) { -% foreach my $field (qw(address1 address2 city state zip addr_clean )) { +% foreach my $field (qw(address1 address2 state zip addr_clean ),($conf->exists('cust_main-no_city_in_address') ? () : 'city')) { cf.elements['<% $pre %><% $field %>'].value = newaddr['<% $pre %><% $field %>']; % } #foreach $field diff --git a/httemplate/elements/tr-input-mask.html b/httemplate/elements/tr-input-mask.html index fdd20962d..93e322c6c 100644 --- a/httemplate/elements/tr-input-mask.html +++ b/httemplate/elements/tr-input-mask.html @@ -68,7 +68,7 @@ my $init = 0; <%init> my %opt = @_; # must have a DOM id -my $id = $opt{id} || sprintf('input%04d',int(rand(10000))); +my $id = $opt{id} || sprintf('input%04d',random_id(4)); my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value} || ''; my $clipboard_hack = $FS::CurrentUser::CurrentUser->option('enable_mask_clipboard_hack'); diff --git a/httemplate/elements/tr-pkg_svc.html b/httemplate/elements/tr-pkg_svc.html index 8acbca118..b3bf80212 100644 --- a/httemplate/elements/tr-pkg_svc.html +++ b/httemplate/elements/tr-pkg_svc.html @@ -32,6 +32,13 @@ % $quan = $pkg_svc->quantity; % } % +% my $provision_hold = ''; +% if ( grep { $_ eq "provision_hold$svcpart" } $cgi->param ) { +% $provision_hold = $cgi->param("hidden_svc$svcpart"); +% } else { +% $provision_hold = $pkg_svc->provision_hold; +% } +% % my @exports = $pkg_svc->part_svc->part_export; % foreach my $export ( @exports ) { % push @possible_exports, $export if $export->can('external_pkg_map'); @@ -53,6 +60,11 @@ <TD> <INPUT TYPE="checkbox" NAME="hidden<% $svcpart %>" VALUE="Y"<% $pkg_svc->hidden =~ /^Y/i ? ' CHECKED' : ''%>> </TD> + + <TD ALIGN="center"> + <INPUT TYPE="checkbox" NAME="provision_hold<% $svcpart %>" VALUE="Y"<% $provision_hold =~ /^Y/i ? ' CHECKED' : ''%>> + </TD> + </TR> % foreach ( 1 .. $columns-1 ) { % if ( $count == int( $_ * scalar(@part_svc) / $columns ) ) { @@ -106,6 +118,7 @@ my $thead = "\n\n". ntable('#cccccc', 2). '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-2>Primary</FONT></TH>'. '<TH BGCOLOR="#dcdcdc">Service</TH>'. '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Hide</FONT></TH>'. + '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Hold<BR>Until<BR>Provision</FONT></TH>'. '</TR>'; my $part_pkg = $opt{'object'}; |