remove
[freeside.git] / httemplate / view / cust_pkg.cgi
index 5e73322..0e67737 100755 (executable)
+<!-- $Id: cust_pkg.cgi,v 1.6 2002-01-30 14:18:09 ivan Exp $ -->
 <%
-#
-# $Id: cust_pkg.cgi,v 1.1 2001-07-30 07:36:04 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.1  2001-07-30 07:36:04  ivan
-# templates!!!
-#
-# 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',{}) ) {
+
+my %uiview = ();
+my %uiadd = ();
+foreach my $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;
+my ($query) = $cgi->keywords;
 $query =~ /^(\d+)$/;
-$pkgnum = $1;
+my $pkgnum = $1;
 
 #get package record
-$cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
+my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
 die "No package!" unless $cust_pkg;
-$part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')});
+my $part_pkg = qsearchs('part_pkg',{'pkgpart'=>$cust_pkg->getfield('pkgpart')});
 
-$custnum = $cust_pkg->getfield('custnum');
-print $cgi->header( '-expires' => 'now' ), header('Package View', menubar(
+my $custnum = $cust_pkg->getfield('custnum');
+print header('Package View', menubar(
   "View this customer (#$custnum)" => popurl(2). "view/cust_main.cgi?$custnum",
   'Main Menu' => popurl(2)
 ));
 
 #print info
-($susp,$cancel,$expire)=(
+my ($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');
+my($pkg,$comment)=($part_pkg->getfield('pkg'),$part_pkg->getfield('comment'));
+my($setup,$bill)=($cust_pkg->getfield('setup'),$cust_pkg->getfield('bill'));
+my $otaker = $cust_pkg->getfield('otaker');
+
+print <<END;
+<SCRIPT>
+function areyousure(href) {
+    if (confirm("Permanantly delete included services and cancel this package?") == true)
+        window.location.href = href;
+}
+</SCRIPT>
+END
 
 print "Package information";
 print ' (<A HREF="'. popurl(2). 'misc/unsusp_pkg.cgi?'. $pkgnum.
-      '">unsuspend</A>)' if ( $susp && ! $cancel );
+      '">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;
+      '">suspend</A>)'
+  unless ( $susp || $cancel );
+
+print ' (<A HREF="javascript:areyousure(\''. popurl(2). 'misc/cancel_pkg.cgi?'.
+      $pkgnum.  '\')">cancel</A>)'
+  unless $cancel;
+
+print ' (<A HREF="'. popurl(2). 'edit/REAL_cust_pkg.cgi?'. $pkgnum.
+      '">edit dates</A>)';
 
 print &ntable("#cccccc"), '<TR><TD>', &ntable("#cccccc",2),
       '<TR><TD ALIGN="right">Package number</TD><TD BGCOLOR="#ffffff">',