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 <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Expiration', note=>'(will <b>cancel</b> this package when the date is reached)' &>
99 <& .row_display, cust_pkg=>$cust_pkg, column=>'cancel', label=>'Cancellation' &>
110 % my $value = $cust_pkg->get($column);
111 % $value = $value ? time2str($format, $value) : "";
113 % # if_primary for the dates that can't be edited on supplemental packages
114 % if ($if_primary and $cust_pkg->main_pkgnum) {
115 <INPUT TYPE="hidden" ID="<%$column%>_text" VALUE="<% $cust_pkg->get($column) %>">
116 <SCRIPT>submit_fields.push('<%$column%>');</SCRIPT>
117 <& .row_display, %ARGS &>
120 <TD ALIGN="right"><% $label %> date</TD>
123 NAME = "<% $column %>"
125 ID = "<% $column %>_text"
126 VALUE = "<% $value %>"
128 <IMG SRC = "../images/calendar.png"
129 ID = "<% $column %>_button"
130 STYLE = "cursor: pointer"
131 TITLE = "Select date"
134 <BR><FONT SIZE=-1><% $note %></FONT>
139 <SCRIPT TYPE="text/javascript">
141 inputField: "<% $column %>_text",
142 ifFormat: "<% $date_format %>",
143 button: "<% $column %>_button",
147 submit_fields.push('<%$column%>');
159 $is_primary => 0 #ignored
161 % if ( $cust_pkg->get($column) ) {
163 <TD ALIGN="right"><% $label %> date</TD>
164 <TD BGCOLOR="#ffffff"><% time2str($format,$cust_pkg->get($column)) %>
166 <BR><FONT SIZE=-1><% $note %></FONT>
176 <INPUT TYPE="button" VALUE="<% mt('Apply changes') |h %>" onclick="confirm_changes()">
179 <% include('/elements/footer.html') %>
182 my $conf = new FS::Conf;
183 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
185 my $format = $date_format. ' %T'; # %z (%Z)';
191 unless $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates');
195 my( $pkgnum, $cust_pkg );
197 if ( $cgi->param('error') ) {
199 $pkgnum = $cgi->param('pkgnum');
201 if ( $cgi->param('error') =~ /^_/ ) {
204 my %errors = map { $_=>1 } split(',', $cgi->param('error'));
205 $cgi->param('error', '');
206 $error = join('<BR><BR>', @errors );
211 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
212 die "No package!" unless $cust_pkg;
214 foreach my $col (qw( start_date setup last_bill bill )) {
215 my $value = $cgi->param($col);
216 $cust_pkg->set( $col, $value ? parse_datetime($value) : '' );
221 my($query) = $cgi->keywords;
222 $query =~ /^(\d+)$/ or die "no pkgnum";
226 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
227 die "No package!" unless $cust_pkg;
231 my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $cust_pkg->pkgpart } );
233 my( $last_bill_or_renewed, $next_bill_or_prepaid_until );
234 unless ( $part_pkg->is_prepaid ) {
235 #$billed_or_prepaid = 'billed';
236 $last_bill_or_renewed = 'Last bill';
237 $next_bill_or_prepaid_until = 'Next bill';
239 #$billed_or_prepaid = 'prepaid';
240 $last_bill_or_renewed = 'Renewed';
241 $next_bill_or_prepaid_until = 'Prepaid until';