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 <SCRIPT TYPE="text/javascript">
13 var submit_fields = [];
14 function confirm_changes() {
16 var querystring = 'pkgnum=<%$pkgnum%>';
17 var f = document.forms.formname;
18 for(i = 0; i < submit_fields.length; i++) {
22 + encodeURIComponent(f.elements[submit_fields[i] + '_text'].value);
26 '<%$p%>/misc/confirm-cust_pkg-edit_dates.html?' + querystring,
27 576, 576, 'confirm_popup'
29 CAPTION, 'Package date changes', STICKY, AUTOSTATUSCAP, CLOSETEXT, '',
30 MIDX, 0, MIDY, 0, DRAGGABLE, BGCOLOR, '#333399', CGCOLOR, '#333399',
35 <FORM NAME="formname" ACTION="process/REAL_cust_pkg.cgi" METHOD="POST">
36 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
38 % if ($contract_only) {
39 <INPUT TYPE="hidden" ID="contract_only_text" NAME="contract_only" VALUE="1">
40 <SCRIPT>submit_fields.push('contract_only');</SCRIPT>
43 % # raw error from below
45 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
47 % #or, regular error handler
48 <% include('/elements/error.html') %>
50 <% ntable("#cccccc",2) %>
53 <TD ALIGN="right">Package number</TD>
54 <TD BGCOLOR="#ffffff"><% $cust_pkg->pkgnum %></TD>
58 <TD ALIGN="right">Package</TD>
59 <TD BGCOLOR="#ffffff"><% $part_pkg->pkg %></TD>
62 % if ( $cust_pkg->main_pkgnum ) {
63 % my $main_pkg = $cust_pkg->main_pkg;
65 <TD ALIGN="right">Supplemental to</TD>
66 <TD BGCOLOR="#ffffff">Package #<% $cust_pkg->main_pkgnum%>: \
67 <% $main_pkg->part_pkg->pkg %></TD>
72 <TD ALIGN="right">Custom</TD>
73 <TD BGCOLOR="#ffffff"><% $part_pkg->custom %></TD>
77 <TD ALIGN="right">Comment</TD>
78 <TD BGCOLOR="#ffffff"><% $part_pkg->comment |h %></TD>
82 <TD ALIGN="right">Order taker</TD>
83 <TD BGCOLOR="#ffffff"><% $cust_pkg->otaker %></TD>
86 <& .row_display, cust_pkg=>$cust_pkg, column=>'order_date', label=>'Order' &>
87 % if ( $cust_pkg->setup && ! $cust_pkg->start_date ) {
88 <& .row_display, cust_pkg=>$cust_pkg, column=>'start_date', label=>'Start' &>
90 <& .row_edit, cust_pkg=>$cust_pkg, column=>'start_date', label=>'Start', if_primary=>1 &>
93 <& .row_edit, cust_pkg=>$cust_pkg, column=>'setup', label=>'Setup', if_primary=>1 &>
94 <& .row_edit, cust_pkg=>$cust_pkg, column=>'last_bill', label=>$last_bill_or_renewed &>
95 <& .row_edit, cust_pkg=>$cust_pkg, column=>'bill', label=>$next_bill_or_prepaid_until &>
96 %#if ( $cust_pkg->contract_end or $part_pkg->option('contract_end_months',1) ) {
97 <& .row_edit, cust_pkg=>$cust_pkg, column=>'contract_end',label=>'Contract end', if_primary=>1 &>
99 <& .row_display, cust_pkg=>$cust_pkg, column=>'adjourn', label=>'Adjournment', note=>'(will <b>suspend</b> this package when the date is reached)' &>
100 <& .row_display, cust_pkg=>$cust_pkg, column=>'susp', label=>'Suspension' &>
101 <& .row_display, cust_pkg=>$cust_pkg, column=>'resume', label=>'Resumption', note=> '(will <b>unsuspend</b> this package when the date is reached' &>
103 % if ( $cust_pkg->change_to_pkgnum ) {
104 % my $change_to_pkg = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
106 % if ( $change_to_pkg->pkgpart != $cust_pkg->pkgpart ) {
107 % $desc = '<b>change package</b> to '.$change_to_pkg->part_pkg->pkg;
109 % if ( $change_to_pkg->locationnum != $cust_pkg->locationnum ) {
110 % $desc .= ' and ' if $desc;
111 % $desc .= '<b>change location</b> to "'.
112 % $change_to_pkg->cust_location->line . '"';
114 <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Change package', note=>"(will $desc when the date is reached)" &>
116 <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Expiration', note=>'(will <b>cancel</b> this package when the date is reached)' &>
118 <& .row_display, cust_pkg=>$cust_pkg, column=>'cancel', label=>'Cancellation' &>
129 % my $value = $cust_pkg->get($column);
130 % $value = $value ? time2str($format, $value) : "";
132 % if ($contract_only and $column ne 'contract_end') {
133 <& .row_display, %ARGS &>
134 % # if_primary for the dates that can't be edited on supplemental packages
135 % } elsif ($if_primary and $cust_pkg->main_pkgnum) {
136 <INPUT TYPE="hidden" ID="<%$column%>_text" VALUE="<% $cust_pkg->get($column) %>">
137 <SCRIPT>submit_fields.push('<%$column%>');</SCRIPT>
138 <& .row_display, %ARGS &>
141 <TD ALIGN="right"><% $label %> date</TD>
144 NAME = "<% $column %>"
146 ID = "<% $column %>_text"
147 VALUE = "<% $value %>"
149 <IMG SRC = "../images/calendar.png"
150 ID = "<% $column %>_button"
151 STYLE = "cursor: pointer"
152 TITLE = "Select date"
155 <BR><FONT SIZE=-1><% $note %></FONT>
160 <SCRIPT TYPE="text/javascript">
162 inputField: "<% $column %>_text",
163 ifFormat: "<% $date_format %>",
164 button: "<% $column %>_button",
168 submit_fields.push('<%$column%>');
180 $is_primary => 0 #ignored
182 % if ( $cust_pkg->get($column) ) {
184 <TD ALIGN="right"><% $label %> date</TD>
185 <TD BGCOLOR="#ffffff"><% time2str($format,$cust_pkg->get($column)) %>
187 <BR><FONT SIZE=-1><% $note %></FONT>
197 <INPUT TYPE="button" VALUE="<% mt('Apply changes') |h %>" onclick="confirm_changes()">
200 <% include('/elements/footer.html') %>
203 my $conf = new FS::Conf;
204 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
206 my $format = $date_format. ' %T'; # %z (%Z)';
208 my $contract_only = $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates') ? 0 : 1;
213 # see $contract_only in shared block above
215 unless $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates')
216 or $FS::CurrentUser::CurrentUser->access_right('Change package contract end date');
219 my( $pkgnum, $cust_pkg );
221 if ( $cgi->param('error') ) {
223 $pkgnum = $cgi->param('pkgnum');
225 if ( $cgi->param('error') =~ /^_/ ) {
228 my %errors = map { $_=>1 } split(',', $cgi->param('error'));
229 $cgi->param('error', '');
230 $error = join('<BR><BR>', @errors );
235 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
236 die "No package!" unless $cust_pkg;
238 foreach my $col (qw( start_date setup last_bill bill )) {
239 my $value = $cgi->param($col);
240 $cust_pkg->set( $col, $value ? parse_datetime($value) : '' );
245 my($query) = $cgi->keywords;
246 $query =~ /^(\d+)$/ or die "no pkgnum";
250 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
251 die "No package!" unless $cust_pkg;
255 my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $cust_pkg->pkgpart } );
257 my( $last_bill_or_renewed, $next_bill_or_prepaid_until );
258 unless ( $part_pkg->is_prepaid ) {
259 #$billed_or_prepaid = 'billed';
260 $last_bill_or_renewed = 'Last bill';
261 $next_bill_or_prepaid_until = 'Next bill';
263 #$billed_or_prepaid = 'prepaid';
264 $last_bill_or_renewed = 'Renewed';
265 $next_bill_or_prepaid_until = 'Prepaid until';