suspend later just like expire (#1487)
[freeside.git] / httemplate / edit / REAL_cust_pkg.cgi
1 %
2 %
3 %my $error ='';
4 %my $pkgnum = '';
5 %if ( $cgi->param('error') ) {
6 %  $error = $cgi->param('error');
7 %  $pkgnum = $cgi->param('pkgnum');
8 %  if ( $error eq '_bill_areyousure' ) {
9 %    my $bill = $cgi->param('bill');
10 %    $error = "You are attempting to set the next bill date to $bill, which is
11 %              in the past.  This will charge the customer for the interval
12 %              from $bill until now.  Are you sure you want to do this? ".
13 %           '<INPUT TYPE="checkbox" NAME="bill_areyousure" VALUE="1">';
14 %  }
15 %} else {
16 %  my($query) = $cgi->keywords;
17 %  $query =~ /^(\d+)$/ or die "no pkgnum";
18 %  $pkgnum = $1;
19 %}
20 %
21 %#get package record
22 %my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
23 %die "No package!" unless $cust_pkg;
24 %my $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')});
25 %
26 %if ( $error ) {
27 %  #$cust_pkg->$_(str2time($cgi->param($_)) foreach qw(setup bill);
28 %  $cust_pkg->setup(str2time($cgi->param('setup')));
29 %  $cust_pkg->bill(str2time($cgi->param('bill')));
30 %  $cust_pkg->last_bill(str2time($cgi->param('last_bill')));
31 %}
32 %
33 %#my $custnum = $cust_pkg->getfield('custnum');
34 %
35
36
37 <% include("/elements/header.html",'Customer package - Edit dates') %>
38 %
39 %#, menubar(
40 %#  "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum",
41 %#  'Main Menu' => popurl(2)
42 %#));
43 %
44
45
46 <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
47 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
48 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
49 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
50 %
51 %
52 %#print info
53 %my($susp,$adjourn,$cancel,$expire)=(
54 %  $cust_pkg->getfield('susp'),
55 %  $cust_pkg->getfield('adjourn'),
56 %  $cust_pkg->getfield('cancel'),
57 %  $cust_pkg->getfield('expire'),
58 %);
59 %my($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment'));
60 %my($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill'));
61 %my $otaker = $cust_pkg->getfield('otaker');
62 %
63 %
64
65
66 <FORM NAME="formname" ACTION="process/REAL_cust_pkg.cgi" METHOD="POST">
67 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
68 % if ( $error ) { 
69
70   <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
71 % } 
72 %
73 %
74 %#my $format = "%c %z (%Z)";
75 %my $format = "%m/%d/%Y %T %z (%Z)";
76 %
77 %#false laziness w/view/cust_main/packages.html
78 %#my( $billed_or_prepaid,
79 %my( $last_bill_or_renewed, $next_bill_or_prepaid_until );
80 %unless ( $part_pkg->is_prepaid ) {
81 %  #$billed_or_prepaid = 'billed';
82 %  $last_bill_or_renewed = 'Last bill';
83 %  $next_bill_or_prepaid_until = 'Next bill';
84 %} else {
85 %  #$billed_or_prepaid = 'prepaid';
86 %  $last_bill_or_renewed = 'Renewed';
87 %  $next_bill_or_prepaid_until = 'Prepaid until';
88 %}
89 %
90 %
91
92
93 <% ntable("#cccccc",2) %>
94
95   <TR>
96     <TD ALIGN="right">Package number</TD>
97     <TD BGCOLOR="#ffffff"><% $pkgnum %></TD>
98   </TR>
99
100   <TR>
101     <TD ALIGN="right">Package</TD>
102     <TD BGCOLOR="#ffffff"><% $pkg %></TD>
103   </TR>
104
105   <TR>
106     <TD ALIGN="right">Comment</TD>
107     <TD BGCOLOR="#ffffff"><% $comment %></TD>
108   </TR>
109
110   <TR>
111     <TD ALIGN="right">Order taker</TD>
112     <TD BGCOLOR="#ffffff"><% $otaker %></TD>
113   </TR>
114
115   <TR>
116     <TD ALIGN="right">Setup date</TD>
117     <TD>
118       <INPUT TYPE="text" NAME="setup" SIZE=32 ID="setup_text" VALUE="<% ( $setup ? time2str($format, $setup) : "" ) %>">
119       <IMG SRC="../images/calendar.png" ID="setup_button" STYLE="cursor: pointer" TITLE="Select date">
120     </TD>
121   </TR>
122
123   <TR>
124     <TD ALIGN="right"><% $last_bill_or_renewed %> date</TD>
125     <TD>
126       <INPUT TYPE="text" NAME="last_bill" SIZE=32 ID="last_bill_text" VALUE="<% ( $cust_pkg->last_bill ? time2str($format, $cust_pkg->last_bill) : "" ) %>">
127       <IMG SRC="../images/calendar.png" ID="last_bill_button" STYLE="cursor: pointer" TITLE="Select date">
128     </TD>
129   </TR>
130
131   <TR>
132     <TD ALIGN="right"><% $next_bill_or_prepaid_until %> date</TD>
133     <TD>
134       <INPUT TYPE="text" NAME="bill" SIZE=32 ID="bill_text" VALUE="<% ( $bill ? time2str($format, $bill) : "" ) %>">
135       <IMG SRC="../images/calendar.png" ID="bill_button" STYLE="cursor: pointer" TITLE="Select date">
136     </TD>
137   </TR>
138   <TR>
139     <TD ALIGN="right">Adjournment date</TD>
140     <TD>
141       <INPUT TYPE="text" NAME="adjourn" SIZE=32 ID="adjourn_text" VALUE="<% ( $adjourn ? time2str($format, $adjourn) : "" ) %>">
142       <IMG SRC="../images/calendar.png" ID="adjourn_button" STYLE="cursor: pointer" TITLE="Select date">
143       <BR><FONT SIZE=-1>(will <b>suspend</b> this package when the date is reached)</FONT>
144     </TD>
145   </TR>
146 % if ( $susp ) { 
147
148     <TR>
149       <TD ALIGN="right">Suspension date</TD>
150       <TD BGCOLOR="#ffffff"><% time2str($format, $susp) %></TD>
151     </TR>
152 % } 
153
154
155   <TR>
156     <TD ALIGN="right">Expiration date</TD>
157     <TD>
158       <INPUT TYPE="text" NAME="expire" SIZE=32 ID="expire_text" VALUE="<% ( $expire ? time2str($format, $expire) : "" ) %>">
159       <IMG SRC="../images/calendar.png" ID="expire_button" STYLE="cursor: pointer" TITLE="Select date">
160       <BR><FONT SIZE=-1>(will <b>cancel</b> this package when the date is reached)</FONT>
161     </TD>
162   </TR>
163 % if ( $cancel ) { 
164
165     <TR>
166       <TD ALIGN="right">Cancellation date</TD>
167       <TD BGCOLOR="#ffffff"><% time2str($format, $cancel) %></TD>
168     </TR>
169 % } 
170
171
172 </TABLE>
173
174 <SCRIPT TYPE="text/javascript">
175 %
176 %  my @cal = qw( setup bill expire );
177 %  push @cal, 'last_bill'
178 %    if $cust_pkg->dbdef_table->column('last_bill');
179 %  foreach my $cal (@cal) {
180 %
181
182   Calendar.setup({
183     inputField: "<% $cal %>_text",
184     ifFormat:   "%m/%d/%Y",
185     button:     "<% $cal %>_button",
186     align:      "BR"
187   });
188 % } 
189
190 </SCRIPT>
191 <BR><INPUT TYPE="submit" VALUE="Apply Changes">
192 </FORM>
193 </BODY>
194 </HTML>