popup view for collapsed packages, #25130, #27305
authorMark Wells <mark@freeside.biz>
Tue, 12 Aug 2014 23:01:28 +0000 (16:01 -0700)
committerMark Wells <mark@freeside.biz>
Tue, 12 Aug 2014 23:52:59 +0000 (16:52 -0700)
httemplate/view/cust_main/packages/contact.html
httemplate/view/cust_main/packages/hidden.html [new file with mode: 0644]
httemplate/view/cust_main/packages/section.html
httemplate/view/cust_pkg-popup.html [new file with mode: 0644]

index 0f0cde7..10c584c 100644 (file)
           (&nbsp;<%pkg_detach_link($cust_pkg)%>&nbsp;)
         </FONT>
 %    }
+    <BR>
 % } elsif ( $show_contact_link && ! $opt{no_links} ) {
     <FONT SIZE=-1>
       (&nbsp;<%pkg_add_contact_link($cust_pkg)%>&nbsp;)
     </FONT>
+    <BR>
 % }
 <%init>
 
diff --git a/httemplate/view/cust_main/packages/hidden.html b/httemplate/view/cust_main/packages/hidden.html
new file mode 100644 (file)
index 0000000..35eda8c
--- /dev/null
@@ -0,0 +1,65 @@
+% if (!$iopt{noframe}) {
+%   # then start the block here, and assign a suitable ID (cust_pkgX_block)
+<TABLE CLASS="hiddenrows" STYLE="display: none" ID="<% $id %>_block">
+% }
+  <TR ID="<% $id %>">
+    <TD>
+      <A NAME="<% $id %>"/>
+      <% $pkgnum %>
+    </TD>
+    <TD>
+%     if ( $pkgpart_change and $location_change ) {
+      Package type and location change
+%     } elsif ( $pkgpart_change ) {
+      Package type change
+%     } elsif ( $location_change ) {
+      Location change
+%     } # or else what?
+      <B><% time2str('%b %o, %Y', $cust_pkg->get('cancel')) %></B>
+    </TD><TD>
+%     if ( $pkgpart_change ) {
+      from <% $popup_link |n %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->custom_comment |h %></A>
+%     }
+%     if ( $pkgpart_change and $location_change ) {
+      <BR>
+%     }
+%     if ( $location_change ) {
+      from <I><% $popup_link |n %><% $cust_pkg->location_label %></A></I>
+%     }
+    </TD>
+  </TR>
+% if ( $cust_pkg->get('changed_from_pkg') ) {
+<& hidden.html, $cust_pkg->get('changed_from_pkg'),
+                %iopt,
+                'next_pkg' => $cust_pkg,
+                'noframe' => 1
+&>
+% }
+% if ( !$iopt{noframe} ) {
+</TABLE>
+% }
+<%init>
+my $cust_pkg = shift;
+my $part_pkg = $cust_pkg->part_pkg;
+my %iopt = @_;
+my $next = delete($iopt{'next_pkg'});
+my $curuser = $FS::CurrentUser::CurrentUser;
+my $pkgnum = $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '';
+
+my $id = "cust_pkg".$cust_pkg->pkgnum;
+
+my $pkgpart_change = ($next->pkgpart != $cust_pkg->pkgpart);
+my $location_change = ($next->locationnum != $cust_pkg->locationnum);
+my $both_change = $pkgpart_change && $location_change;
+
+my $onclick =
+  include('/elements/popup_link_onclick.html',
+    'action'      => $fsurl.'view/cust_pkg-popup.html?' . $cust_pkg->pkgnum,
+    'actionlabel' => 'Package #'.$cust_pkg->pkgnum,
+    'width'       => '1000',
+    'height'      => '310',
+    'color'       => $cust_pkg->statuscolor,
+  );
+my $popup_link = qq(<A HREF="#" onclick="$onclick">);
+
+</%init>
index 11928ec..217e8c5 100755 (executable)
@@ -4,17 +4,22 @@
   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Package') |h %></TH>
   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Contact/Location') |h %></TH>
+% if (!$opt{no_services}) {
   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Services') |h %></TH>
+% }
 </TR>
 
 % #$FS::cust_pkg::DEBUG = 2;
 %   foreach my $cust_pkg (@$packages) {
+%    # if requested, this can override cust_pkg-group_by_location
     <& .packagerow, $cust_pkg,
+        %conf_opt,
         ( map { $_ => $opt{$_} } qw(
             cust_main bgcolor no_links cust_location_cache
             before_pkg_callback before_svc_callback after_svc_callback
+            cust_pkg-group_by_location
+            no_services
         )),
-        %conf_opt
     &>
 %   }
 % } else { # there are no packages
     <& package.html, %iopt &>
     <& status.html,  %iopt &>
     <TD CLASS="inv" BGCOLOR="<% $iopt{bgcolor} %>" WIDTH="20%" VALIGN="top">
-      <& contact.html, %iopt &><BR>
+      <& contact.html, %iopt &>
       <& location.html, %iopt &>
     </TD>
+%   if (!$iopt{no_services}) {
     <& services.html, %iopt &>
+%   }
+  </TR>
+% # insert hidden predecessors to this package, if any
+% # and a rolldown button to show them
+% # (we'll make it do something later)
+% if ( $cust_pkg->get('changed_from_pkg') ) {
+  <TR CLASS="row<% $row % 2 %>">
+    <TD COLSPAN=4>
+    <BUTTON CLASS="rolldown_button"
+            ID="rolldown_<% $cust_pkg->change_pkgnum %>">
+      History &#x2b07;
+    </BUTTON>
+% # the hidden block here has ID="cust_pkgX" where X is the first pkgnum
+% # it contains.
+    <& hidden.html, $cust_pkg->get('changed_from_pkg'),
+       %iopt,
+       'next_pkg' => $cust_pkg,
+    &>
+    </TD>
   </TR>
+% }
 % $row++;
 % # show the change target, if there is one
 % if ( $cust_pkg->change_to_pkg ) {
diff --git a/httemplate/view/cust_pkg-popup.html b/httemplate/view/cust_pkg-popup.html
new file mode 100644 (file)
index 0000000..96956c7
--- /dev/null
@@ -0,0 +1,27 @@
+<& /elements/header-popup.html &>
+<TABLE STYLE="width: 100%">
+<& cust_main/packages/section.html,
+  'cust_main' => $cust_main,
+  'packages'  => [ $cust_pkg ],
+  'cust_pkg-group_by_location' => 0,
+  'no_services' => 1,
+&>
+</TABLE>
+</BODY>
+</HTML>
+<%init>
+my $curuser = $FS::CurrentUser::CurrentUser;
+my ($pkgnum) = $cgi->keywords;
+$pkgnum =~ /^\d+$/ or die "bad pkgnum $pkgnum";
+
+my $cust_pkg = qsearchs({
+  'table'     => 'cust_pkg',
+  'addl_from' => 'JOIN cust_main USING (custnum)',
+  'hashref'   => { 'pkgnum' => $pkgnum },
+  'extra_sql' => ' AND '.$curuser->agentnums_sql,
+});
+die "Package not found" unless $cust_pkg;
+my $cust_main = $cust_pkg->cust_main;
+
+my $title = mt('Package [_1]', $pkgnum);
+</%init>