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