-my $cust_main = shift or return undef;
-
-my @packages = ();
-
-foreach my $cust_pkg (($conf->exists('hidecancelledpackages') ? ($cust_main->ncancelled_pkgs)
- : ($cust_main->all_pkgs))) {
-
- my $part_pkg = $cust_pkg->part_pkg;
-
- my %pkg = ();
- $pkg{pkgnum} = $cust_pkg->pkgnum;
- $pkg{pkg} = $part_pkg->pkg;
- $pkg{pkgpart} = $part_pkg->pkgpart;
- $pkg{comment} = $part_pkg->getfield('comment');
- $pkg{freq} = $part_pkg->freq;
- $pkg{setup} = $cust_pkg->getfield('setup');
- $pkg{last_bill} = $cust_pkg->getfield('last_bill');
- $pkg{next_bill} = $cust_pkg->getfield('bill');
- $pkg{susp} = $cust_pkg->getfield('susp');
- $pkg{expire} = $cust_pkg->getfield('expire');
- $pkg{cancel} = $cust_pkg->getfield('cancel');
-
- $pkg{svcparts} = [];
-
- foreach my $pkg_svc (qsearch('pkg_svc', { 'pkgpart' => $part_pkg->pkgpart })) {
-
- next if ($pkg_svc->quantity == 0);
-
- my $part_svc = qsearchs('part_svc', { 'svcpart' => $pkg_svc->svcpart });
-
- my $svcpart = {};
- $svcpart->{svcpart} = $part_svc->svcpart;
- $svcpart->{svc} = $part_svc->svc;
- $svcpart->{svcdb} = $part_svc->svcdb;
- $svcpart->{quantity} = $pkg_svc->quantity;
- $svcpart->{count} = 0;
+ foreach my $pkg_svc (
+ qsearch('pkg_svc', { 'pkgpart' => $part_pkg->pkgpart })
+ ) {
+
+ next if ($pkg_svc->quantity == 0);
+
+ my $part_svc = qsearchs('part_svc', { 'svcpart' => $pkg_svc->svcpart });
+
+ my $svcpart = {};
+ $svcpart->{svcpart} = $part_svc->svcpart;
+ $svcpart->{svc} = $part_svc->svc;
+ $svcpart->{svcdb} = $part_svc->svcdb;
+ $svcpart->{quantity} = $pkg_svc->quantity;
+ $svcpart->{count} = 0;
+
+ $svcpart->{services} = [];