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 % # raw error from below
40 <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
42 % #or, regular error handler
43 <% include('/elements/error.html') %>
45 <% ntable("#cccccc",2) %>
48 <TD ALIGN="right">Package number</TD>
49 <TD BGCOLOR="#ffffff"><% $cust_pkg->pkgnum %></TD>
53 <TD ALIGN="right">Package</TD>
54 <TD BGCOLOR="#ffffff"><% $part_pkg->pkg %></TD>
57 % if ( $cust_pkg->main_pkgnum ) {
58 % my $main_pkg = $cust_pkg->main_pkg;
60 <TD ALIGN="right">Supplemental to</TD>
61 <TD BGCOLOR="#ffffff">Package #<% $cust_pkg->main_pkgnum%>: \
62 <% $main_pkg->part_pkg->pkg %></TD>
67 <TD ALIGN="right">Custom</TD>
68 <TD BGCOLOR="#ffffff"><% $part_pkg->custom %></TD>
72 <TD ALIGN="right">Comment</TD>
73 <TD BGCOLOR="#ffffff"><% $part_pkg->comment |h %></TD>
77 <TD ALIGN="right">Order taker</TD>
78 <TD BGCOLOR="#ffffff"><% $cust_pkg->otaker %></TD>
81 <& .row_display, cust_pkg=>$cust_pkg, column=>'order_date', label=>'Order' &>
82 % if ( $cust_pkg->setup && ! $cust_pkg->start_date ) {
83 <& .row_display, cust_pkg=>$cust_pkg, column=>'start_date', label=>'Start' &>
85 <& .row_edit, cust_pkg=>$cust_pkg, column=>'start_date', label=>'Start', if_primary=>1 &>
88 <& .row_edit, cust_pkg=>$cust_pkg, column=>'setup', label=>'Setup', if_primary=>1 &>
89 <& .row_edit, cust_pkg=>$cust_pkg, column=>'last_bill', label=>$last_bill_or_renewed &>
90 <& .row_edit, cust_pkg=>$cust_pkg, column=>'bill', label=>$next_bill_or_prepaid_until &>
91 %#if ( $cust_pkg->contract_end or $part_pkg->option('contract_end_months',1) ) {
92 <& .row_edit, cust_pkg=>$cust_pkg, column=>'contract_end',label=>'Contract end', if_primary=>1 &>
94 <& .row_display, cust_pkg=>$cust_pkg, column=>'adjourn', label=>'Adjournment', note=>'(will <b>suspend</b> this package when the date is reached)' &>
95 <& .row_display, cust_pkg=>$cust_pkg, column=>'susp', label=>'Suspension' &>
96 <& .row_display, cust_pkg=>$cust_pkg, column=>'resume', label=>'Resumption', note=> '(will <b>unsuspend</b> this package when the date is reached' &>
98 % if ( $cust_pkg->change_to_pkgnum ) {
99 % my $change_to_pkg = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
101 % if ( $change_to_pkg->pkgpart != $cust_pkg->pkgpart ) {
102 % $desc = '<b>change package</b> to '.$change_to_pkg->part_pkg->pkg;
104 % if ( $change_to_pkg->locationnum != $cust_pkg->locationnum ) {
105 % $desc .= ' and ' if $desc;
106 % $desc .= '<b>change location</b> to "'.
107 % $change_to_pkg->cust_location->line . '"';
109 <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Change package', note=>"(will $desc when the date is reached)" &>
111 <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Expiration', note=>'(will <b>cancel</b> this package when the date is reached)' &>
113 <& .row_display, cust_pkg=>$cust_pkg, column=>'cancel', label=>'Cancellation' &>
124 % my $value = $cust_pkg->get($column);
125 % $value = $value ? time2str($format, $value) : "";
127 % # if_primary for the dates that can't be edited on supplemental packages
128 % if ($if_primary and $cust_pkg->main_pkgnum) {
129 <INPUT TYPE="hidden" ID="<%$column%>_text" VALUE="<% $cust_pkg->get($column) %>">
130 <SCRIPT>submit_fields.push('<%$column%>');</SCRIPT>
131 <& .row_display, %ARGS &>
134 <TD ALIGN="right"><% $label %> date</TD>
137 NAME = "<% $column %>"
139 ID = "<% $column %>_text"
140 VALUE = "<% $value %>"
142 <IMG SRC = "../images/calendar.png"
143 ID = "<% $column %>_button"
144 STYLE = "cursor: pointer"
145 TITLE = "Select date"
148 <BR><FONT SIZE=-1><% $note %></FONT>
153 <SCRIPT TYPE="text/javascript">
155 inputField: "<% $column %>_text",
156 ifFormat: "<% $date_format %>",
157 button: "<% $column %>_button",
161 submit_fields.push('<%$column%>');
173 $is_primary => 0 #ignored
175 % if ( $cust_pkg->get($column) ) {
177 <TD ALIGN="right"><% $label %> date</TD>
178 <TD BGCOLOR="#ffffff"><% time2str($format,$cust_pkg->get($column)) %>
180 <BR><FONT SIZE=-1><% $note %></FONT>
190 <INPUT TYPE="button" VALUE="<% mt('Apply changes') |h %>" onclick="confirm_changes()">
193 <% include('/elements/footer.html') %>
196 my $conf = new FS::Conf;
197 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
199 my $format = $date_format. ' %T'; # %z (%Z)';
205 unless $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates');
209 my( $pkgnum, $cust_pkg );
211 if ( $cgi->param('error') ) {
213 $pkgnum = $cgi->param('pkgnum');
215 if ( $cgi->param('error') =~ /^_/ ) {
218 my %errors = map { $_=>1 } split(',', $cgi->param('error'));
219 $cgi->param('error', '');
220 $error = join('<BR><BR>', @errors );
225 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
226 die "No package!" unless $cust_pkg;
228 foreach my $col (qw( start_date setup last_bill bill )) {
229 my $value = $cgi->param($col);
230 $cust_pkg->set( $col, $value ? parse_datetime($value) : '' );
235 my($query) = $cgi->keywords;
236 $query =~ /^(\d+)$/ or die "no pkgnum";
240 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
241 die "No package!" unless $cust_pkg;
245 my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $cust_pkg->pkgpart } );
247 my( $last_bill_or_renewed, $next_bill_or_prepaid_until );
248 unless ( $part_pkg->is_prepaid ) {
249 #$billed_or_prepaid = 'billed';
250 $last_bill_or_renewed = 'Last bill';
251 $next_bill_or_prepaid_until = 'Next bill';
253 #$billed_or_prepaid = 'prepaid';
254 $last_bill_or_renewed = 'Renewed';
255 $next_bill_or_prepaid_until = 'Prepaid until';