3 # $Id: cust_pkg.cgi,v 1.9 1999-04-08 12:00:19 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.9 1999-04-08 12:00:19 ivan
30 # Revision 1.8 1999/02/28 00:04:01 ivan
31 # removed misleading comments
33 # Revision 1.7 1999/01/19 05:14:20 ivan
34 # for mod_perl: no more top-level my() variables; use vars instead
35 # also the last s/create/new/;
37 # Revision 1.6 1999/01/18 09:41:44 ivan
38 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
41 # Revision 1.5 1998/12/23 03:11:40 ivan
42 # *** empty log message ***
44 # Revision 1.3 1998/12/17 09:57:22 ivan
45 # s/CGI::(Base|Request)/CGI.pm/;
47 # Revision 1.2 1998/11/13 09:56:49 ivan
48 # change configuration file layout to support multiple distinct databases (with
49 # own set of config files, export, etc.)
53 use vars qw ( $cgi %uiview %uiadd $part_svc $query $pkgnum $cust_pkg $part_pkg
54 $custnum $susp $cancel $expire $pkg $comment $setup $bill
58 use CGI::Carp qw(fatalsToBrowser);
59 use FS::UID qw(cgisuidsetup);
60 use FS::CGI qw(popurl header menubar ntable table);
61 use FS::Record qw(qsearch qsearchs);
71 foreach $part_svc ( qsearch('part_svc',{}) ) {
72 $uiview{$part_svc->svcpart} = popurl(2). "view/". $part_svc->svcdb . ".cgi";
73 $uiadd{$part_svc->svcpart}= popurl(2). "edit/". $part_svc->svcdb . ".cgi";
76 ($query) = $cgi->keywords;
81 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
82 die "No package!" unless $cust_pkg;
83 $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')});
85 $custnum = $cust_pkg->getfield('custnum');
86 print $cgi->header( '-expires' => 'now' ), header('Package View', menubar(
87 "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum",
88 'Main Menu' => popurl(2)
92 ($susp,$cancel,$expire)=(
93 $cust_pkg->getfield('susp'),
94 $cust_pkg->getfield('cancel'),
95 $cust_pkg->getfield('expire'),
97 ($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment'));
98 ($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill'));
99 $otaker = $cust_pkg->getfield('otaker');
101 print "Package information";
102 print ' (<A HREF="'. popurl(2). 'misc/unsusp_pkg.cgi?'. $pkgnum.
103 '">unsuspend</A>)' if ( $susp && ! $cancel );
104 print ' (<A HREF="'. popurl(2). 'misc/susp_pkg.cgi?'. $pkgnum.
105 '">suspend</A>)' unless ( $susp || $cancel );
106 print ' (<A HREF="'. popurl(2). 'misc/cancel_pkg.cgi?'. $pkgnum.
107 '">cancel</A>)' unless $cancel;
109 print ntable("#c0c0c0"), '<TR><TD>', ntable("#c0c0c0",2),
110 '<TR><TD ALIGN="right">Package number</TD><TD BGCOLOR="#ffffff">',
111 $pkgnum, '</TD></TR>',
112 '<TR><TD ALIGN="right">Package</TD><TD BGCOLOR="#ffffff">',
114 '<TR><TD ALIGN="right">Comment</TD><TD BGCOLOR="#ffffff">',
115 $comment, '</TD></TR>',
116 '<TR><TD ALIGN="right">Setup date</TD><TD BGCOLOR="#ffffff">',
117 ( $setup ? time2str("%D",$setup) : "(Not setup)" ), '</TD></TR>',
118 '<TR><TD ALIGN="right">Next bill date</TD><TD BGCOLOR="#ffffff">',
119 ( $bill ? time2str("%D",$bill) : " " ), '</TD></TR>',
121 print '<TR><TD ALIGN="right">Suspension date</TD><TD BGCOLOR="#ffffff">',
122 time2str("%D",$susp), '</TD></TR>' if $susp;
123 print '<TR><TD ALIGN="right">Expiration date</TD><TD BGCOLOR="#ffffff">',
124 time2str("%D",$expire), '</TD></TR>' if $expire;
125 print '<TR><TD ALIGN="right">Cancellation date</TD><TD BGCOLOR="#ffffff">',
126 time2str("%D",$cancel), '</TD></TR>' if $cancel;
127 print '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">',
128 $otaker, '</TD></TR>',
129 '</TABLE></TD></TR></TABLE>'
133 #<FORM ACTION="../misc/expire_pkg.cgi" METHOD="post">
134 #<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
135 #Expire (date): <INPUT TYPE="text" NAME="date" VALUE="" >
136 #<INPUT TYPE="submit" VALUE="Cancel later">
142 print '<BR>Service Information', table,
145 #list of services this pkgpart includes
148 foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $cust_pkg->pkgpart }) ) {
149 $pkg_svc{$pkg_svc->svcpart} = $pkg_svc->quantity if $pkg_svc->quantity;
152 #list of records from cust_svc
154 foreach $svcpart (sort {$a <=> $b} keys %pkg_svc) {
156 my($svc)=qsearchs('part_svc',{'svcpart'=>$svcpart})->getfield('svc');
158 my(@cust_svc)=qsearch('cust_svc',{'pkgnum'=>$pkgnum,
163 for $enum ( 1 .. $pkg_svc{$svcpart} ) {
166 if ( $cust_svc=shift @cust_svc ) {
167 my($svcnum)=$cust_svc->svcnum;
168 my($label, $value, $svcdb) = $cust_svc->label;
170 <TR><TD><A HREF="$uiview{$svcpart}?$svcnum">(View) $svc: $value<A></TD></TR>
175 <TD><A HREF="$uiadd{$svcpart}?pkgnum$pkgnum-svcpart$svcpart">
177 or <A HREF="../misc/link.cgi?pkgnum$pkgnum-svcpart$svcpart">
178 (Link to existing) $svc</A>
185 warn "WARNING: Leftover services pkgnum $pkgnum!" if @cust_svc;;
188 print "</TABLE><FONT SIZE=-1>",
189 "Choose (View) to view or edit an existing service<BR>",
190 "Choose (Add) to setup a new service<BR>",
191 "Choose (Link to existing) to link to a legacy (pre-Freeside) service",