3 # $Id: cust_pkg.cgi,v 1.10 1999-04-09 03:52:55 ivan Exp $
5 # Usage: cust_pkg.cgi pkgnum
6 # http://server.name/path/cust_pkg.cgi?pkgnum
8 # ivan@voicenet.com 96-dec-15
10 # services section needs to be cleaned up, needs to display extraneous
11 # entries in cust_pkg!
12 # ivan@voicenet.com 96-dec-31
14 # added navigation bar
15 # ivan@voicenet.com 97-jan-30
17 # changed and fixed up suspension and cancel stuff, now you can't add
18 # services to a cancelled package
19 # ivan@voicenet.com 97-feb-27
21 # rewrote for new API, still needs to be cleaned up!
22 # ivan@voicenet.com 97-jul-29
24 # no FS::Search ivan@sisd.com 98-mar-7
26 # $Log: cust_pkg.cgi,v $
27 # Revision 1.10 1999-04-09 03:52:55 ivan
28 # explicit & for table/itable/ntable
30 # Revision 1.9 1999/04/08 12:00:19 ivan
33 # Revision 1.8 1999/02/28 00:04:01 ivan
34 # removed misleading comments
36 # Revision 1.7 1999/01/19 05:14:20 ivan
37 # for mod_perl: no more top-level my() variables; use vars instead
38 # also the last s/create/new/;
40 # Revision 1.6 1999/01/18 09:41:44 ivan
41 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
44 # Revision 1.5 1998/12/23 03:11:40 ivan
45 # *** empty log message ***
47 # Revision 1.3 1998/12/17 09:57:22 ivan
48 # s/CGI::(Base|Request)/CGI.pm/;
50 # Revision 1.2 1998/11/13 09:56:49 ivan
51 # change configuration file layout to support multiple distinct databases (with
52 # own set of config files, export, etc.)
56 use vars qw ( $cgi %uiview %uiadd $part_svc $query $pkgnum $cust_pkg $part_pkg
57 $custnum $susp $cancel $expire $pkg $comment $setup $bill
61 use CGI::Carp qw(fatalsToBrowser);
62 use FS::UID qw(cgisuidsetup);
63 use FS::CGI qw(popurl header menubar ntable table);
64 use FS::Record qw(qsearch qsearchs);
74 foreach $part_svc ( qsearch('part_svc',{}) ) {
75 $uiview{$part_svc->svcpart} = popurl(2). "view/". $part_svc->svcdb . ".cgi";
76 $uiadd{$part_svc->svcpart}= popurl(2). "edit/". $part_svc->svcdb . ".cgi";
79 ($query) = $cgi->keywords;
84 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
85 die "No package!" unless $cust_pkg;
86 $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')});
88 $custnum = $cust_pkg->getfield('custnum');
89 print $cgi->header( '-expires' => 'now' ), header('Package View', menubar(
90 "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum",
91 'Main Menu' => popurl(2)
95 ($susp,$cancel,$expire)=(
96 $cust_pkg->getfield('susp'),
97 $cust_pkg->getfield('cancel'),
98 $cust_pkg->getfield('expire'),
100 ($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment'));
101 ($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill'));
102 $otaker = $cust_pkg->getfield('otaker');
104 print "Package information";
105 print ' (<A HREF="'. popurl(2). 'misc/unsusp_pkg.cgi?'. $pkgnum.
106 '">unsuspend</A>)' if ( $susp && ! $cancel );
107 print ' (<A HREF="'. popurl(2). 'misc/susp_pkg.cgi?'. $pkgnum.
108 '">suspend</A>)' unless ( $susp || $cancel );
109 print ' (<A HREF="'. popurl(2). 'misc/cancel_pkg.cgi?'. $pkgnum.
110 '">cancel</A>)' unless $cancel;
112 print &ntable("#c0c0c0"), '<TR><TD>', &ntable("#c0c0c0",2),
113 '<TR><TD ALIGN="right">Package number</TD><TD BGCOLOR="#ffffff">',
114 $pkgnum, '</TD></TR>',
115 '<TR><TD ALIGN="right">Package</TD><TD BGCOLOR="#ffffff">',
117 '<TR><TD ALIGN="right">Comment</TD><TD BGCOLOR="#ffffff">',
118 $comment, '</TD></TR>',
119 '<TR><TD ALIGN="right">Setup date</TD><TD BGCOLOR="#ffffff">',
120 ( $setup ? time2str("%D",$setup) : "(Not setup)" ), '</TD></TR>',
121 '<TR><TD ALIGN="right">Next bill date</TD><TD BGCOLOR="#ffffff">',
122 ( $bill ? time2str("%D",$bill) : " " ), '</TD></TR>',
124 print '<TR><TD ALIGN="right">Suspension date</TD><TD BGCOLOR="#ffffff">',
125 time2str("%D",$susp), '</TD></TR>' if $susp;
126 print '<TR><TD ALIGN="right">Expiration date</TD><TD BGCOLOR="#ffffff">',
127 time2str("%D",$expire), '</TD></TR>' if $expire;
128 print '<TR><TD ALIGN="right">Cancellation date</TD><TD BGCOLOR="#ffffff">',
129 time2str("%D",$cancel), '</TD></TR>' if $cancel;
130 print '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">',
131 $otaker, '</TD></TR>',
132 '</TABLE></TD></TR></TABLE>'
136 #<FORM ACTION="../misc/expire_pkg.cgi" METHOD="post">
137 #<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
138 #Expire (date): <INPUT TYPE="text" NAME="date" VALUE="" >
139 #<INPUT TYPE="submit" VALUE="Cancel later">
145 print '<BR>Service Information', &table,
148 #list of services this pkgpart includes
151 foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $cust_pkg->pkgpart }) ) {
152 $pkg_svc{$pkg_svc->svcpart} = $pkg_svc->quantity if $pkg_svc->quantity;
155 #list of records from cust_svc
157 foreach $svcpart (sort {$a <=> $b} keys %pkg_svc) {
159 my($svc)=qsearchs('part_svc',{'svcpart'=>$svcpart})->getfield('svc');
161 my(@cust_svc)=qsearch('cust_svc',{'pkgnum'=>$pkgnum,
166 for $enum ( 1 .. $pkg_svc{$svcpart} ) {
169 if ( $cust_svc=shift @cust_svc ) {
170 my($svcnum)=$cust_svc->svcnum;
171 my($label, $value, $svcdb) = $cust_svc->label;
173 <TR><TD><A HREF="$uiview{$svcpart}?$svcnum">(View) $svc: $value<A></TD></TR>
178 <TD><A HREF="$uiadd{$svcpart}?pkgnum$pkgnum-svcpart$svcpart">
180 or <A HREF="../misc/link.cgi?pkgnum$pkgnum-svcpart$svcpart">
181 (Link to existing) $svc</A>
188 warn "WARNING: Leftover services pkgnum $pkgnum!" if @cust_svc;;
191 print "</TABLE><FONT SIZE=-1>",
192 "Choose (View) to view or edit an existing service<BR>",
193 "Choose (Add) to setup a new service<BR>",
194 "Choose (Link to existing) to link to a legacy (pre-Freeside) service",