add progressbar to service definition add - duplicate checking can take a while,...
[freeside.git] / httemplate / edit / REAL_cust_pkg.cgi
1 <!-- mason kludge -->
2 <%
3 # <!-- $Id: REAL_cust_pkg.cgi,v 1.8 2004-12-22 14:06:45 ivan Exp $ -->
4
5 my $error ='';
6 my $pkgnum = '';
7 if ( $cgi->param('error') ) {
8   $error = $cgi->param('error');
9   $pkgnum = $cgi->param('pkgnum');
10   if ( $error eq '_bill_areyousure' ) {
11     my $bill = $cgi->param('bill');
12     $error = "You are attempting to set the next bill date to $bill, which is
13               in the past.  This will charge the customer for the interval
14               from $bill until now.  Are you sure you want to do this? ".
15            '<INPUT TYPE="checkbox" NAME="bill_areyousure" VALUE="1">';
16   }
17 } else {
18   my($query) = $cgi->keywords;
19   $query =~ /^(\d+)$/ or die "no pkgnum";
20   $pkgnum = $1;
21 }
22
23 #get package record
24 my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
25 die "No package!" unless $cust_pkg;
26 my $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')});
27
28 if ( $error ) {
29   #$cust_pkg->$_(str2time($cgi->param($_)) foreach qw(setup bill);
30   $cust_pkg->setup(str2time($cgi->param('setup')));
31   $cust_pkg->bill(str2time($cgi->param('bill')));
32 }
33
34 #my $custnum = $cust_pkg->getfield('custnum');
35 print header('Package Edit'); #, menubar(
36 #  "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum",
37 #  'Main Menu' => popurl(2)
38 #));
39
40 %>
41
42     <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
43     <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
44     <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
45     <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
46
47 <%
48
49 #print info
50 my($susp,$cancel,$expire)=(
51   $cust_pkg->getfield('susp'),
52   $cust_pkg->getfield('cancel'),
53   $cust_pkg->getfield('expire'),
54 );
55 my($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment'));
56 my($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill'));
57 my $otaker = $cust_pkg->getfield('otaker');
58
59 print '<FORM NAME="formname" ACTION="process/REAL_cust_pkg.cgi" METHOD="POST">',      qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!;
60
61 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: $error</FONT>!
62   if $error;
63
64 #my $format = "%c %z (%Z)";
65 my $format = "%m/%d/%Y %T %z (%Z)";
66
67 print ntable("#cccccc",2),
68       '<TR><TD ALIGN="right">Package number</TD><TD BGCOLOR="#ffffff">',
69       $pkgnum, '</TD></TR>',
70       '<TR><TD ALIGN="right">Package</TD><TD BGCOLOR="#ffffff">',
71       $pkg,  '</TD></TR>',
72       '<TR><TD ALIGN="right">Comment</TD><TD BGCOLOR="#ffffff">',
73       $comment,  '</TD></TR>',
74       '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">',
75       $otaker,  '</TD></TR>',
76       '<TR><TD ALIGN="right">Setup date</TD><TD>'.
77       '<INPUT TYPE="text" NAME="setup" SIZE=32 ID="setup_text" VALUE="',
78       ( $setup ? time2str($format, $setup) : "" ), '">'.
79       ' <IMG SRC="../images/calendar.png" ID="setup_button" STYLE="cursor: pointer" TITLE="Select date">'.
80       '</TD></TR>';
81
82 print '<TR><TD ALIGN="right">Last bill date</TD><TD>',
83       '<INPUT TYPE="text" NAME="last_bill" SIZE=32 ID="last_bill_text" VALUE="',
84       ( $cust_pkg->last_bill
85         ? time2str($format, $cust_pkg->last_bill)
86         : ""                                          ),
87       '">'.
88       ' <IMG SRC="../images/calendar.png" ID="last_bill_button" STYLE="cursor: pointer" TITLE="Select date">'.
89       '</TD></TR>'
90   if $cust_pkg->dbdef_table->column('last_bill');
91
92 print '<TR><TD ALIGN="right">Next bill date</TD><TD>',
93       '<INPUT TYPE="text" NAME="bill" SIZE=32 ID="bill_text" VALUE="',
94       ( $bill ? time2str($format, $bill) : "" ), '">'.
95       ' <IMG SRC="../images/calendar.png" ID="bill_button" STYLE="cursor: pointer" TITLE="Select date">'.
96       '</TD></TR>';
97
98 print '<TR><TD ALIGN="right">Suspension date</TD><TD BGCOLOR="#ffffff">',
99        time2str($format, $susp), '</TD></TR>'
100   if $susp;
101
102 #print '<TR><TD ALIGN="right">Expiration date</TD><TD BGCOLOR="#ffffff">',
103 #       time2str("%D",$expire), '</TD></TR>'
104 #  if $expire;
105 print '<TR><TD ALIGN="right">Expiration date'.
106       '</TD><TD>',
107       '<INPUT TYPE="text" NAME="expire" SIZE=32 ID="expire_text" VALUE="',
108       ( $expire ? time2str($format, $expire) : "" ), '">'.
109       ' <IMG SRC="../images/calendar.png" ID="expire_button" STYLE="cursor: pointer" TITLE="Select date">'.
110       '<BR><FONT SIZE=-1>(will <b>cancel</b> this package'.
111       ' when the date is reached)</FONT>'.
112       '</TD></TR>';
113
114 print '<TR><TD ALIGN="right">Cancellation date</TD><TD BGCOLOR="#ffffff">',
115        time2str($format, $cancel), '</TD></TR>'
116   if $cancel;
117
118 %>
119 </TABLE>
120 <SCRIPT TYPE="text/javascript">
121 <%
122   my @cal = qw( setup bill expire );
123   push @cal, 'last_bill'
124     if $cust_pkg->dbdef_table->column('last_bill');
125   foreach my $cal (@cal) {
126 %>
127   Calendar.setup({
128     inputField: "<%= $cal %>_text",
129     ifFormat:   "%m/%d/%Y",
130     button:     "<%= $cal %>_button",
131     align:      "BR"
132   });
133 <% } %>
134 </SCRIPT>
135 <BR><INPUT TYPE="submit" VALUE="Apply Changes">
136 </FORM>
137 </BODY>
138 </HTML>