1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
#!/usr/bin/perl -Tw
#
# $Id: cust_pkg.cgi,v 1.11 1999-04-09 04:22:34 ivan Exp $
#
# Usage: cust_pkg.cgi pkgnum
# http://server.name/path/cust_pkg.cgi?pkgnum
#
# ivan@voicenet.com 96-dec-15
#
# services section needs to be cleaned up, needs to display extraneous
# entries in cust_pkg!
# ivan@voicenet.com 96-dec-31
#
# added navigation bar
# ivan@voicenet.com 97-jan-30
#
# changed and fixed up suspension and cancel stuff, now you can't add
# services to a cancelled package
# ivan@voicenet.com 97-feb-27
#
# rewrote for new API, still needs to be cleaned up!
# ivan@voicenet.com 97-jul-29
#
# no FS::Search ivan@sisd.com 98-mar-7
#
# $Log: cust_pkg.cgi,v $
# Revision 1.11 1999-04-09 04:22:34 ivan
# also table()
#
# Revision 1.10 1999/04/09 03:52:55 ivan
# explicit & for table/itable/ntable
#
# Revision 1.9 1999/04/08 12:00:19 ivan
# aesthetic update
#
# Revision 1.8 1999/02/28 00:04:01 ivan
# removed misleading comments
#
# Revision 1.7 1999/01/19 05:14:20 ivan
# for mod_perl: no more top-level my() variables; use vars instead
# also the last s/create/new/;
#
# Revision 1.6 1999/01/18 09:41:44 ivan
# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
# (good idea anyway)
#
# Revision 1.5 1998/12/23 03:11:40 ivan
# *** empty log message ***
#
# Revision 1.3 1998/12/17 09:57:22 ivan
# s/CGI::(Base|Request)/CGI.pm/;
#
# Revision 1.2 1998/11/13 09:56:49 ivan
# change configuration file layout to support multiple distinct databases (with
# own set of config files, export, etc.)
#
use strict;
use vars qw ( $cgi %uiview %uiadd $part_svc $query $pkgnum $cust_pkg $part_pkg
$custnum $susp $cancel $expire $pkg $comment $setup $bill
$otaker );
use Date::Format;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use FS::UID qw(cgisuidsetup);
use FS::CGI qw(popurl header menubar ntable table);
use FS::Record qw(qsearch qsearchs);
use FS::part_svc;
use FS::cust_pkg;
use FS::part_pkg;
use FS::pkg_svc;
use FS::cust_svc;
$cgi = new CGI;
cgisuidsetup($cgi);
foreach $part_svc ( qsearch('part_svc',{}) ) {
$uiview{$part_svc->svcpart} = popurl(2). "view/". $part_svc->svcdb . ".cgi";
$uiadd{$part_svc->svcpart}= popurl(2). "edit/". $part_svc->svcdb . ".cgi";
}
($query) = $cgi->keywords;
$query =~ /^(\d+)$/;
$pkgnum = $1;
#get package record
$cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
die "No package!" unless $cust_pkg;
$part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')});
$custnum = $cust_pkg->getfield('custnum');
print $cgi->header( '-expires' => 'now' ), header('Package View', menubar(
"View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum",
'Main Menu' => popurl(2)
));
#print info
($susp,$cancel,$expire)=(
$cust_pkg->getfield('susp'),
$cust_pkg->getfield('cancel'),
$cust_pkg->getfield('expire'),
);
($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment'));
($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill'));
$otaker = $cust_pkg->getfield('otaker');
print "Package information";
print ' (<A HREF="'. popurl(2). 'misc/unsusp_pkg.cgi?'. $pkgnum.
'">unsuspend</A>)' if ( $susp && ! $cancel );
print ' (<A HREF="'. popurl(2). 'misc/susp_pkg.cgi?'. $pkgnum.
'">suspend</A>)' unless ( $susp || $cancel );
print ' (<A HREF="'. popurl(2). 'misc/cancel_pkg.cgi?'. $pkgnum.
'">cancel</A>)' unless $cancel;
print &ntable("#c0c0c0"), '<TR><TD>', &ntable("#c0c0c0",2),
'<TR><TD ALIGN="right">Package number</TD><TD BGCOLOR="#ffffff">',
$pkgnum, '</TD></TR>',
'<TR><TD ALIGN="right">Package</TD><TD BGCOLOR="#ffffff">',
$pkg, '</TD></TR>',
'<TR><TD ALIGN="right">Comment</TD><TD BGCOLOR="#ffffff">',
$comment, '</TD></TR>',
'<TR><TD ALIGN="right">Setup date</TD><TD BGCOLOR="#ffffff">',
( $setup ? time2str("%D",$setup) : "(Not setup)" ), '</TD></TR>',
'<TR><TD ALIGN="right">Next bill date</TD><TD BGCOLOR="#ffffff">',
( $bill ? time2str("%D",$bill) : " " ), '</TD></TR>',
;
print '<TR><TD ALIGN="right">Suspension date</TD><TD BGCOLOR="#ffffff">',
time2str("%D",$susp), '</TD></TR>' if $susp;
print '<TR><TD ALIGN="right">Expiration date</TD><TD BGCOLOR="#ffffff">',
time2str("%D",$expire), '</TD></TR>' if $expire;
print '<TR><TD ALIGN="right">Cancellation date</TD><TD BGCOLOR="#ffffff">',
time2str("%D",$cancel), '</TD></TR>' if $cancel;
print '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">',
$otaker, '</TD></TR>',
'</TABLE></TD></TR></TABLE>'
;
# print <<END;
#<FORM ACTION="../misc/expire_pkg.cgi" METHOD="post">
#<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
#Expire (date): <INPUT TYPE="text" NAME="date" VALUE="" >
#<INPUT TYPE="submit" VALUE="Cancel later">
#END
unless ($cancel) {
#services
print '<BR>Service Information', &table();
#list of services this pkgpart includes
my $pkg_svc;
my %pkg_svc = ();
foreach $pkg_svc ( qsearch('pkg_svc',{'pkgpart'=> $cust_pkg->pkgpart }) ) {
$pkg_svc{$pkg_svc->svcpart} = $pkg_svc->quantity if $pkg_svc->quantity;
}
#list of records from cust_svc
my $svcpart;
foreach $svcpart (sort {$a <=> $b} keys %pkg_svc) {
my($svc)=qsearchs('part_svc',{'svcpart'=>$svcpart})->getfield('svc');
my(@cust_svc)=qsearch('cust_svc',{'pkgnum'=>$pkgnum,
'svcpart'=>$svcpart,
});
my($enum);
for $enum ( 1 .. $pkg_svc{$svcpart} ) {
my($cust_svc);
if ( $cust_svc=shift @cust_svc ) {
my($svcnum)=$cust_svc->svcnum;
my($label, $value, $svcdb) = $cust_svc->label;
print <<END;
<TR><TD><A HREF="$uiview{$svcpart}?$svcnum">(View) $svc: $value<A></TD></TR>
END
} else {
print <<END;
<TR>
<TD><A HREF="$uiadd{$svcpart}?pkgnum$pkgnum-svcpart$svcpart">
(Add) $svc</A>
or <A HREF="../misc/link.cgi?pkgnum$pkgnum-svcpart$svcpart">
(Link to existing) $svc</A>
</TD>
</TR>
END
}
}
warn "WARNING: Leftover services pkgnum $pkgnum!" if @cust_svc;;
}
print "</TABLE><FONT SIZE=-1>",
"Choose (View) to view or edit an existing service<BR>",
"Choose (Add) to setup a new service<BR>",
"Choose (Link to existing) to link to a legacy (pre-Freeside) service",
"</FONT>"
;
}
#formatting
print <<END;
</BODY>
</HTML>
END
|