1 <% include("/elements/header.html",'Customer package - Edit dates') %>
4 %# "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum",
7 <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
8 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
9 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
10 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
12 <FORM NAME="formname" ACTION="process/REAL_cust_pkg.cgi" METHOD="POST">
13 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
15 % # raw error from below
17 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
19 % #or, regular error handler
20 <% include('/elements/error.html') %>
22 <% ntable("#cccccc",2) %>
25 <TD ALIGN="right">Package number</TD>
26 <TD BGCOLOR="#ffffff"><% $cust_pkg->pkgnum %></TD>
30 <TD ALIGN="right">Package</TD>
31 <TD BGCOLOR="#ffffff"><% $part_pkg->pkg %></TD>
35 <TD ALIGN="right">Custom</TD>
36 <TD BGCOLOR="#ffffff"><% $part_pkg->custom %></TD>
40 <TD ALIGN="right">Comment</TD>
41 <TD BGCOLOR="#ffffff"><% $part_pkg->comment %></TD>
45 <TD ALIGN="right">Order taker</TD>
46 <TD BGCOLOR="#ffffff"><% $cust_pkg->otaker %></TD>
49 % if ( $cust_pkg->setup && ! $cust_pkg->start_date ) {
50 <& .row_display, cust_pkg=>$cust_pkg, column=>'start_date', label=>'Start' &>
52 <& .row_edit, cust_pkg=>$cust_pkg, column=>'start_date', label=>'Start' &>
55 <& .row_edit, cust_pkg=>$cust_pkg, column=>'setup', label=>'Setup' &>
56 <& .row_edit, cust_pkg=>$cust_pkg, column=>'last_bill', label=>$last_bill_or_renewed &>
57 <& .row_edit, cust_pkg=>$cust_pkg, column=>'bill', label=>$next_bill_or_prepaid_until &>
58 <& .row_display, cust_pkg=>$cust_pkg, column=>'adjourn', label=>'Adjournment', note=>'(will <b>suspend</b> this package when the date is reached)' &>
59 <& .row_display, cust_pkg=>$cust_pkg, column=>'susp', label=>'Suspension' &>
61 <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Expiration', note=>'(will <b>cancel</b> this package when the date is reached)' &>
62 <& .row_display, cust_pkg=>$cust_pkg, column=>'cancel', label=>'Cancellation' &>
71 % my $value = $cust_pkg->get($column);
72 % $value = $value ? time2str($format, $value) : "";
75 <TD ALIGN="right"><% $label %> date</TD>
78 NAME = "<% $column %>"
80 ID = "<% $column %>_text"
81 VALUE = "<% $value %>"
83 <IMG SRC = "../images/calendar.png"
84 ID = "<% $column %>_button"
85 STYLE = "cursor: pointer"
89 <BR><FONT SIZE=-1><% $note %></FONT>
94 <SCRIPT TYPE="text/javascript">
96 inputField: "<% $column %>_text",
98 button: "<% $column %>_button",
112 % if ( $cust_pkg->get($column) ) {
114 <TD ALIGN="right"><% $label %> date</TD>
115 <TD BGCOLOR="#ffffff"><% time2str($format,$cust_pkg->get($column)) %>
117 <BR><FONT SIZE=-1><% $note %></FONT>
127 <INPUT TYPE="submit" VALUE="Apply Changes">
130 <% include('/elements/footer.html') %>
134 #my $format = "%c %z (%Z)";
135 my $format = "%m/%d/%Y %T %z (%Z)";
137 #false laziness w/view/cust_main/packages.html
138 #my( $billed_or_prepaid,
144 unless $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates');
147 my( $pkgnum, $cust_pkg );
149 if ( $cgi->param('error') ) {
151 $pkgnum = $cgi->param('pkgnum');
153 if ( $cgi->param('error') =~ /^_/ ) {
156 my %errors = map { $_=>1 } split(',', $cgi->param('error'));
157 $cgi->param('error', '');
159 if ( $errors{'_bill_areyousure'} ) {
160 if ( $cgi->param('bill') =~ /^([\s\d\/\:\-\(\w\)]*)$/ ) {
163 "You are attempting to set the next bill date to $bill, which is
164 in the past. This will charge the customer for the interval
165 from $bill until now. Are you sure you want to do this? ".
166 '<INPUT TYPE="checkbox" NAME="bill_areyousure" VALUE="1">';
170 if ( $errors{'_setup_areyousure'} ) {
172 "You are attempting to remove the setup date. This will re-charge the
173 customer for the setup fee. Are you sure you want to do this? ".
174 '<INPUT TYPE="checkbox" NAME="setup_areyousure" VALUE="1">';
177 if ( $errors{'_start'} ) {
179 "You are attempting to add a start date to a package that has already
183 $error = join('<BR><BR>', @errors );
188 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
189 die "No package!" unless $cust_pkg;
191 foreach my $col (qw( setup last_bill bill adjourn expire )) {
192 my $value = $cgi->param($col);
193 $cust_pkg->set( $col, $value ? str2time($value) : '' );
198 my($query) = $cgi->keywords;
199 $query =~ /^(\d+)$/ or die "no pkgnum";
203 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
204 die "No package!" unless $cust_pkg;
208 my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $cust_pkg->pkgpart } );
210 my( $last_bill_or_renewed, $next_bill_or_prepaid_until );
211 unless ( $part_pkg->is_prepaid ) {
212 #$billed_or_prepaid = 'billed';
213 $last_bill_or_renewed = 'Last bill';
214 $next_bill_or_prepaid_until = 'Next bill';
216 #$billed_or_prepaid = 'prepaid';
217 $last_bill_or_renewed = 'Renewed';
218 $next_bill_or_prepaid_until = 'Prepaid until';