1 %my $debug=0; # toggle debug
2 %my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_external );
3 %my @field_descriptions = ( 'prev date', 'curr date', 'prev reading',
4 % 'curr reading', 'tdsp', 'meter mult',
5 % 'total usage', 'measured demand', 'billed demand',
6 % 'svcnum', 'entry date', 'meter number' );
7 %my @field_name = qw / prev_date curr_date prev_read curr_read tdsp
8 % meter_multiplier total_usage measured_demand
9 % billed_demand svcnum _date meter_number /;
10 %my $date_exception = '(prev_date|curr_date|_date)';
12 %if ( $cgi->param('error') ) {
13 % ### handle error call
14 % $svcnum = $cgi->param('svcnum');
18 % my($query) = $cgi->keywords;
19 % $query =~ /^(\d+)$/ or die "unparsable svcnum";
24 %# this is sample data for print in case no previous record of usage_elec
25 %my @sample_data = ( '20070201', '20070228', '10000', '100100', '76.50',
26 % '5', '500', '179', '220', "$svcnum", 'NA', '030234972LM');
28 %### this is where i start
30 %### let gather all the info from usage_elec for the particular 'svcnum'
34 %print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
36 % if $cgi->param('error');
38 %print qq!<FORM ACTION="${p1}process/usage_elec_manual_input.cgi" METHOD=POST>!;
41 %print header("Manually Adding Record to usage_elec Table", '');
49 % # change getting previous 10 record to 13 so we can see at least 1 year
50 % # worth of transaction
51 % # get the previous 13 usage_elec items
52 % my @usage_obj = FS::usage_elec::query_usage($svcnum, 13);
55 % print "<TR bgcolor=#88b2ce class='maintitle'>"
56 % . join("\n", map("<TH>" . $_ . "</TH>", @field_descriptions))
60 % foreach my $usage (@usage_obj) {
61 % # fill @usage_ele with data order by @field_name
63 % foreach my $field (@field_name) {
64 % if ( $field =~ /$date_exception/ ) {
65 % # exception handling of converting time to string
66 % push(@usage_ele,time2str("%Y%m%d",$usage->$field));
69 %#debug: field= <% $field %> = <% $usage->$field %><BR>
70 % push(@usage_ele, $usage->$field);
74 % print "<TR bgcolor=#e8e8ea class='mainbody'>"
75 % . join("\n", map("<TD>" . $_ . "</TD>", @usage_ele))
81 % ### gathering pre-filled information
84 % my ($h_prev_date, $h_prev_read, $h_tdsp, $h_meter_multiplier,
85 % $h_measured_demand, $h_billed_demand, $h_svcnum, $h_meter_number);
88 % # fill in all the history data
89 % my $lindex = $#usage_obj;
90 % $h_prev_date = time2str("%Y%m%d",$usage_obj[$lindex]->curr_date);
91 % $h_prev_read = $usage_obj[$lindex]->curr_read;
92 % $h_tdsp = $usage_obj[$lindex]->tdsp;
93 % $h_meter_multiplier = $usage_obj[$lindex]->meter_multiplier;
94 % $h_measured_demand = $usage_obj[$lindex]->measured_demand;
95 % $h_billed_demand = $usage_obj[$lindex]->billed_demand;
96 % $h_svcnum = $usage_obj[$lindex]->svcnum;
97 % $h_meter_number = $usage_obj[$lindex]->meter_number;
100 % # this hash store info to configure the table with text box for input
101 % # size - [int] how big textbox
102 % # value - [alpha numeric] default value of the text box
103 % # extra - [alpha numeric] other option for text box. I.E. READONLY
104 % # mean the text box is a readonly
108 % 'value' => $h_prev_date,
110 % curr_date => { 'size' => '8' },
113 % 'value' => $h_prev_read,
115 % curr_read => { 'size' => '8' },
118 % 'value' => $h_tdsp,
120 % meter_multiplier => {
122 % 'value' => $h_meter_multiplier,
124 % total_usage => { 'size' => '6' },
125 % measured_demand => {
127 % 'value' => $h_measured_demand,
131 % 'value' => $h_billed_demand,
135 % 'value' => $svcnum,
136 % 'extra' => 'READONLY'
141 % 'extra' => 'READONLY'
145 % 'value' => $h_meter_number,
150 % # input box for entry
151 % print qq !<TR bgcolor=#e8e8ea class='mainbody'>!;
152 % my $input_style = 'STYLE="color:#000000; background-color: #FFFFCC;"';
153 % foreach my $field (@field_name) {
155 % $txt .= ' SIZE=' . $field_info{$field}->{'size'}
156 % if (exists($field_info{$field}->{'size'}));
157 % $txt .= ' VALUE="' . $field_info{$field}->{'value'} . '"'
158 % if (exists($field_info{$field}->{'value'}));
159 % $txt .= ' ' . $field_info{$field}->{'extra'}
160 % if (exists($field_info{$field}->{'extra'}));
161 % if ($field eq 'meter_multiplier') {
166 % <INPUT TYPE="text" $input_style NAME="$field" $txt>
169 % <INPUT TYPE="checkbox" NAME="ignore_meter_multiplier">Ignore<P>
178 % <INPUT TYPE="text" $input_style NAME="$field" $txt>
187 %print "<BR>measured demand = ",$h_measured_demand,"\n<BR>" if ($debug);
189 <INPUT TYPE="submit" VALUE="Submit">
190 <INPUT TYPE="Reset" VALUE="Clear">
191 <INPUT TYPE=BUTTON OnClick="$cgi->redirect(popurl(2)."view/svc_external.cgi?$svcnum")"
196 % prev_date, curr_date -
197 % 8 digit in format of yyyymmdd (y-year m-month d-date)<br>
198 % prev_read, curr_read - positive interger. Also, curr_read > prev_read
199 % Unless meter multiplier ignore value is set. In
200 % this case, this condition will be ignore.<br>
201 % tdsp - an dollar amount w/wo cent<br>
202 % meter_multiplier - positive integer<br>
204 % should equal (total_usage = (prev_read-curr_read) * meter_multiplier)
205 % unless meter multiplier ignore value is set<br>
206 % measured_demand - positive integer<br>
207 % billed_demand - positive integer<br>