From 0a3b346806615bd893048d2a5c26f8d126a12f4b Mon Sep 17 00:00:00 2001 From: jeff Date: Mon, 2 Aug 2010 19:49:26 +0000 Subject: add svc_elec_features merged from reference code RT#7643 --- httemplate/misc/usage_elec_prefilled_input.cgi | 245 +++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100755 httemplate/misc/usage_elec_prefilled_input.cgi (limited to 'httemplate/misc/usage_elec_prefilled_input.cgi') diff --git a/httemplate/misc/usage_elec_prefilled_input.cgi b/httemplate/misc/usage_elec_prefilled_input.cgi new file mode 100755 index 000000000..43b45d0d0 --- /dev/null +++ b/httemplate/misc/usage_elec_prefilled_input.cgi @@ -0,0 +1,245 @@ +%my $debug=0; # toggle debug +%my ($svcnum, $p_prev_date, $p_curr_date, $p_prev_reading, $p_curr_reading, +% $p_tdsp, $p_meter_mult, $p_total_usage, $p_measured_demand, +% $p_billed_demand, $p_svcnum, $p_entry_date, $p_meter_number, +% $p_first, $p_last, $p_balance, $p_last_billed); +%my ($pkgnum, $svcpart, $svc_external ); +%my @field_descriptions = ( 'prev date', 'curr date', 'prev reading', +% 'curr reading', 'tdsp', 'meter mult', +% 'total usage', 'measured demand', 'billed demand', +% 'svcnum', 'entry date', 'meter number' ); +%my @field_name = qw / prev_date curr_date prev_read curr_read tdsp +% meter_multiplier total_usage measured_demand +% billed_demand svcnum _date meter_number /; +%my $date_exception = '(prev_date|curr_date|_date)'; +% +%if ( $cgi->param('error') ) { +% ### handle error call +% $svcnum = $cgi->param('svcnum'); +%} +%else { +% +% my($query) = $cgi->keywords; +%# $query =~ /^(\d+)$/ or die "unparsable svcnum"; +% #$svcnum=$1; +% +% $p_prev_date = $cgi->param('p_prev_date'); +% $p_curr_date = $cgi->param('p_curr_date'); +% $p_prev_reading = $cgi->param('p_prev_reading'); +% $p_curr_reading = $cgi->param('p_curr_reading'); +% $p_tdsp = $cgi->param('p_tdsp'); +% $p_meter_mult = $cgi->param('p_meter_mult'); +% $p_total_usage = $cgi->param('p_total_usage'); +% $p_measured_demand = $cgi->param('p_measured_demand'); +% $p_billed_demand = $cgi->param('p_billed_demand'); +% $p_svcnum = $svcnum = $cgi->param('p_svcnum'); +% $p_first = $cgi->param('p_first'); +% $p_last = $cgi->param('p_last'); +% $p_balance = $cgi->param('p_balance'); +% $p_last_billed = $cgi->param('p_last_billed'); +% #$svcnum = $cgi->param('p_meter_number'); +%} +% +%# this is sample data for print in case no previous record of usage_elec +%my @sample_data = ( '20070201', '20070228', '10000', '100100', '76.50', +% '5', '500', '179', '220', "$svcnum", 'NA', '030234972LM'); +% +%### this is where i start +%### +%### let gather all the info from usage_elec for the particular 'svcnum' +%### +%my $p1 = popurl(1); +% +%print qq!Error: !, $cgi->param('error'), +% "" +% if $cgi->param('error'); +% +%print qq!
!; +% +%# print header +%#print header("Manually Adding Record to usage_elec Table", ''); +%print header("NAME: ${p_first} ${p_last}", ''); +%print header("BALANCE: \$${p_balance} LAST BILLED: ${p_last_billed}", ''); +% +%#display +%# +%# + +% +% # -ctran 04/10/08 +% # change getting previous 10 record to 13 so we can see at least 1 year +% # worth of transaction +% # get the previous 13 usage_elec items +% my @usage_obj = FS::usage_elec::query_usage($svcnum, 13); +% +% # print the heading +% print "" +% . join("\n", map("", @field_descriptions)) +% . "\n"; +% +% if (@usage_obj) { +% foreach my $usage (@usage_obj) { +% # fill @usage_ele with data order by @field_name +% my @usage_ele = (); +% foreach my $field (@field_name) { +% if ( $field =~ /$date_exception/ ) { +% # exception handling of converting time to string +% push(@usage_ele,time2str("%Y%m%d",$usage->$field)); +% } +% else { +%#debug: field= <% $field %> = <% $usage->$field %>
+% push(@usage_ele, $usage->$field); +% } +% } +% +% print "" +% . join("\n", map("", @usage_ele)) +% . "\n"; +% } +% } +% +% ### +% ### gathering pre-filled information +% ### +% +% my ($h_prev_date, $h_prev_read, $h_tdsp, $h_meter_multiplier, +% $h_measured_demand, $h_billed_demand, $h_svcnum, $h_meter_number); +% +% if (@usage_obj) { +% # fill in all the history data +% my $lindex = $#usage_obj; +% $h_prev_date = time2str("%Y%m%d",$usage_obj[$lindex]->curr_date); +% $h_prev_read = $usage_obj[$lindex]->curr_read; +% $h_tdsp = $usage_obj[$lindex]->tdsp; +% $h_meter_multiplier = $usage_obj[$lindex]->meter_multiplier; +% $h_measured_demand = $usage_obj[$lindex]->measured_demand; +% $h_billed_demand = $usage_obj[$lindex]->billed_demand; +% $h_svcnum = $usage_obj[$lindex]->svcnum; +% $h_meter_number = $usage_obj[$lindex]->meter_number; +% } +% +% # let figure out if tdsp is charge or not (only charge for BUSINESS) +% my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$p_svcnum}); +% my $part_svc = qsearchs('part_svc',{'svcpart' => $cust_svc->svcpart}); +% $p_tdsp = '0.00' if ($part_svc->svc !~ /BUSINESS/i); +% +% # this hash store info to configure the table with text box for input +% # size - [int] how big textbox +% # value - [alpha numeric] default value of the text box +% # extra - [alpha numeric] other option for text box. I.E. READONLY +% # mean the text box is a readonly +% my %field_info = ( +% prev_date => { +% 'size' => '8', +% 'value' => $p_prev_date, +% }, +% curr_date => { 'size' => '8', +% 'value' => $p_curr_date, +% }, +% prev_read => { +% 'size' => '8', +% 'value' => $p_prev_reading, +% }, +% curr_read => { 'size' => '8', +% 'value' => $p_curr_reading, +% }, +% tdsp => { +% 'size' => '8', +% 'value' => $p_tdsp/100, +% }, +% meter_multiplier => { +% 'size' => '4', +% 'value' => $p_meter_mult, +% }, +% total_usage => { 'size' => '6', +% 'value' => $p_total_usage, +% }, +% measured_demand => { +% 'size' => '4', +% 'value' => $p_measured_demand, +% }, +% billed_demand => { +% 'size' => '4', +% 'value' => $p_billed_demand, +% }, +% svcnum => { +% 'size' => '6', +% 'value' => $p_svcnum, +% 'extra' => 'READONLY' +% }, +% _date => { +% 'size' => '8', +% 'value' => 'N/A', +% 'extra' => 'READONLY' +% }, +% meter_number => { +% 'size' => '14', +% 'value' => $h_meter_number, +% }, +% ); +% +% +% # input box for entry +% print qq !!; +% my $input_style = 'STYLE="color:#000000; background-color: #FFFFCC;"'; +% foreach my $field (@field_name) { +% my $txt = ''; +% $txt .= ' SIZE=' . $field_info{$field}->{'size'} +% if (exists($field_info{$field}->{'size'})); +% $txt .= ' VALUE="' . $field_info{$field}->{'value'} . '"' +% if (exists($field_info{$field}->{'value'})); +% $txt .= ' ' . $field_info{$field}->{'extra'} +% if (exists($field_info{$field}->{'extra'})); +% if ($field eq 'meter_multiplier') { +% print qq ! +% +% !; +% } +% else { +% print qq ! +% +% !; +% } +% } +% print "\n"; +% + +
" . $_ . "
" . $_ . "
+% +% +% +%
+% +% +% Ignore

+%

+%
+% +%

+%print "
measured demand = ",$h_measured_demand,"\n
" if ($debug); +% + + + +% +% print qq ! +%

+% prev_date, curr_date - +% 8 digit in format of yyyymmdd (y-year m-month d-date)
+% prev_read, curr_read - positive interger. Also, curr_read > prev_read +% Unless meter multiplier ignore value is set. In +% this case, this condition will be ignore.
+% tdsp - an dollar amount w/wo cent
+% meter_multiplier - positive integer
+% total_usage - +% should equal (total_usage = (prev_read-curr_read) * meter_multiplier) +% unless meter multiplier ignore value is set
+% measured_demand - positive integer
+% billed_demand - positive integer
+% !; +% +
+ + + -- cgit v1.2.1