Will things ever be the same again?
[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,$cancel,$expire)=(
54 %  $cust_pkg->getfield('susp'),
55 %  $cust_pkg->getfield('cancel'),
56 %  $cust_pkg->getfield('expire'),
57 %);
58 %my($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment'));
59 %my($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill'));
60 %my $otaker = $cust_pkg->getfield('otaker');
61 %
62 %
63
64
65 <FORM NAME="formname" ACTION="process/REAL_cust_pkg.cgi" METHOD="POST">
66 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
67 % if ( $error ) { 
68
69   <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
70 % } 
71 %
72 %
73 %#my $format = "%c %z (%Z)";
74 %my $format = "%m/%d/%Y %T %z (%Z)";
75 %
76 %#false laziness w/view/cust_main/packages.html
77 %#my( $billed_or_prepaid,
78 %my( $last_bill_or_renewed, $next_bill_or_prepaid_until );
79 %unless ( $part_pkg->is_prepaid ) {
80 %  #$billed_or_prepaid = 'billed';
81 %  $last_bill_or_renewed = 'Last bill';
82 %  $next_bill_or_prepaid_until = 'Next bill';
83 %} else {
84 %  #$billed_or_prepaid = 'prepaid';
85 %  $last_bill_or_renewed = 'Renewed';
86 %  $next_bill_or_prepaid_until = 'Prepaid until';
87 %}
88 %
89 %
90
91
92 <% ntable("#cccccc",2) %>
93
94   <TR>
95     <TD ALIGN="right">Package number</TD>
96     <TD BGCOLOR="#ffffff"><% $pkgnum %></TD>
97   </TR>
98
99   <TR>
100     <TD ALIGN="right">Package</TD>
101     <TD BGCOLOR="#ffffff"><% $pkg %></TD>
102   </TR>
103
104   <TR>
105     <TD ALIGN="right">Comment</TD>
106     <TD BGCOLOR="#ffffff"><% $comment %></TD>
107   </TR>
108
109   <TR>
110     <TD ALIGN="right">Order taker</TD>
111     <TD BGCOLOR="#ffffff"><% $otaker %></TD>
112   </TR>
113
114   <TR>
115     <TD ALIGN="right">Setup date</TD>
116     <TD>
117       <INPUT TYPE="text" NAME="setup" SIZE=32 ID="setup_text" VALUE="<% ( $setup ? time2str($format, $setup) : "" ) %>">
118       <IMG SRC="../images/calendar.png" ID="setup_button" STYLE="cursor: pointer" TITLE="Select date">
119     </TD>
120   </TR>
121
122   <TR>
123     <TD ALIGN="right"><% $last_bill_or_renewed %> date</TD>
124     <TD>
125       <INPUT TYPE="text" NAME="last_bill" SIZE=32 ID="last_bill_text" VALUE="<% ( $cust_pkg->last_bill ? time2str($format, $cust_pkg->last_bill) : "" ) %>">
126       <IMG SRC="../images/calendar.png" ID="last_bill_button" STYLE="cursor: pointer" TITLE="Select date">
127     </TD>
128   </TR>
129
130   <TR>
131     <TD ALIGN="right"><% $next_bill_or_prepaid_until %> date</TD>
132     <TD>
133       <INPUT TYPE="text" NAME="bill" SIZE=32 ID="bill_text" VALUE="<% ( $bill ? time2str($format, $bill) : "" ) %>">
134       <IMG SRC="../images/calendar.png" ID="bill_button" STYLE="cursor: pointer" TITLE="Select date">
135     </TD>
136   </TR>
137 % if ( $susp ) { 
138
139     <TR>
140       <TD ALIGN="right">Suspension date</TD>
141       <TD BGCOLOR="#ffffff"><% time2str($format, $susp) %></TD>
142     </TR>
143 % } 
144
145
146   <TR>
147     <TD ALIGN="right">Expiration date</TD>
148     <TD>
149       <INPUT TYPE="text" NAME="expire" SIZE=32 ID="expire_text" VALUE="<% ( $expire ? time2str($format, $expire) : "" ) %>">
150       <IMG SRC="../images/calendar.png" ID="expire_button" STYLE="cursor: pointer" TITLE="Select date">
151       <BR><FONT SIZE=-1>(will <b>cancel</b> this package when the date is reached)</FONT>
152     </TD>
153   </TR>
154 % if ( $cancel ) { 
155
156     <TR>
157       <TD ALIGN="right">Cancellation date</TD>
158       <TD BGCOLOR="#ffffff"><% time2str($format, $cancel) %></TD>
159     </TR>
160 % } 
161
162
163 </TABLE>
164
165 <SCRIPT TYPE="text/javascript">
166 %
167 %  my @cal = qw( setup bill expire );
168 %  push @cal, 'last_bill'
169 %    if $cust_pkg->dbdef_table->column('last_bill');
170 %  foreach my $cal (@cal) {
171 %
172
173   Calendar.setup({
174     inputField: "<% $cal %>_text",
175     ifFormat:   "%m/%d/%Y",
176     button:     "<% $cal %>_button",
177     align:      "BR"
178   });
179 % } 
180
181 </SCRIPT>
182 <BR><INPUT TYPE="submit" VALUE="Apply Changes">
183 </FORM>
184 </BODY>
185 </HTML>