[freeside-commits] branch master updated. 8f89376bceb710bceb8d2d3b9dd7fe24e7d47cf3

Ivan ivan at 420.am
Wed Jul 4 18:49:05 PDT 2012


The branch, master has been updated
       via  8f89376bceb710bceb8d2d3b9dd7fe24e7d47cf3 (commit)
      from  e185be2238bfd1fb2ca6f36b80c9ad93281fe635 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8f89376bceb710bceb8d2d3b9dd7fe24e7d47cf3
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jul 4 18:49:00 2012 -0700

    quotations, RT#16996

diff --git a/httemplate/elements/order_pkg_link.html b/httemplate/elements/order_pkg_link.html
new file mode 100644
index 0000000..d8aa8fd
--- /dev/null
+++ b/httemplate/elements/order_pkg_link.html
@@ -0,0 +1,26 @@
+<& /elements/popup_link-cust_main.html,
+          'action'        => $p. 'misc/order_pkg.html',
+          'label'         => $opt{'label'}       || emt('Order new package'),
+          'actionlabel'   => $opt{'actionlabel'} || emt('Order new package'),
+          'color'         => '#333399',
+          'cust_main'     => $opt{cust_main},
+          'prospect_main' => $opt{prospect_main},
+          'custnum'       => $opt{custnum},
+          'prospectnum'   => $opt{prospectnum},
+          'closetext'     => emt('Close'),
+          'width'         => 960, #763,
+          'height'        => $height,
+          %optional,
+&>
+<%init>
+
+my(%opt) = @_;
+
+my %optional =
+  map { $_ => $opt{$_} }
+    grep $opt{$_},
+      qw( lock_pkgpart lock_locationnum qualnum quotationnum svcpart );
+
+my $height = $opt{'lock_locationnum'} ? 336 : 576;
+
+</%init>
diff --git a/httemplate/elements/popup_link-cust_main.html b/httemplate/elements/popup_link-cust_main.html
index 1413785..541bb58 100644
--- a/httemplate/elements/popup_link-cust_main.html
+++ b/httemplate/elements/popup_link-cust_main.html
@@ -22,7 +22,7 @@ Example:
   )
 
 </%doc>
-% if ( $params->{'cust_main'} ) {
+% if ( $custnum || $prospectnum ) {
 <% include('/elements/popup_link.html', $params ) %>\
 % }
 <%init>
@@ -34,13 +34,26 @@ if (ref($_[0]) eq 'HASH') {
 } else {
   $params = { %$params, @_ };
 }
+
+my $custnum = $params->{'cust_main'}
+                ? $params->{'cust_main'}->custnum
+                : $params->{'custnum'};
+
+$params->{'action'} .= ( $params->{'action'} =~ /\?/ ? ';' : '?' ).
+                       "custnum=$custnum"
+  if $custnum;
+
+#(maybe i should be called popup_link-cust_or_prospect_main.html now)
+my $prospectnum = $params->{'prospect_main'}
+                    ? $params->{'prospect_main'}->prospectnum
+                    : $params->{'prospectnum'};
  
-$params->{'action'} .=
-  ( $params->{'action'} =~ /\?/ ? ';' : '?' ).
-  'custnum='. $params->{'cust_main'}->custnum;
+$params->{'action'} .= ( $params->{'action'} =~ /\?/ ? ';' : '?' ).
+                       "prospectnum=$prospectnum"
+  if $prospectnum;
 
 $params->{'action'} .= ";$_=".$params->{$_}
   foreach grep $params->{$_},
-    qw( lock_pkgpart lock_locationnum qualnum svcpart );
+    qw( lock_pkgpart lock_locationnum qualnum quotationnum svcpart );
 
 </%init>
diff --git a/httemplate/elements/select-cust-part_pkg.html b/httemplate/elements/select-cust-part_pkg.html
index 731beae..2d4cd18 100644
--- a/httemplate/elements/select-cust-part_pkg.html
+++ b/httemplate/elements/select-cust-part_pkg.html
@@ -27,9 +27,9 @@ Example:
 
 my( %opt ) = @_;
 
-my $cust_main = $opt{'cust_main'}
-  or die "cust_main not specified";
+my $cust_or_prospect_main = $opt{'cust_main'} || $opt{'prospect_main'}
+  or die "neither cust_main nor prospect_main specified";
 
-$opt{'extra_sql'} .= ' AND '. FS::part_pkg->agent_pkgs_sql( $cust_main->agent );
+$opt{'extra_sql'} .= ' AND '. FS::part_pkg->agent_pkgs_sql( $cust_or_prospect_main->agent );
 
 </%init>
diff --git a/httemplate/elements/tr-select-cust-part_pkg.html b/httemplate/elements/tr-select-cust-part_pkg.html
index 767d232..848ab0a 100644
--- a/httemplate/elements/tr-select-cust-part_pkg.html
+++ b/httemplate/elements/tr-select-cust-part_pkg.html
@@ -51,8 +51,11 @@
 
       }
 
-      get_part_pkg( <% $cust_main->custnum %>, classnum, update_part_pkg );
-    
+      get_part_pkg( <% $cust_main     ? $cust_main->custnum         : '0' %>,
+                    <% $prospect_main ? $prospect_main->prospectnum : '0' %>,
+                    classnum,
+                    update_part_pkg
+                  );
     }
 
   </SCRIPT>
@@ -74,10 +77,11 @@
   <TH ALIGN="right"><% mt('Package') |h %></TH>
   <TD COLSPAN=7>
     <& /elements/select-cust-part_pkg.html,
-                 'curr_value' => $opt{'curr_value'}, #$pkgpart
-                 'classnum'   => $opt{'classnum'},
-                 'cust_main'  => $opt{'cust_main'},  #$cust_main
-                 'onchange'   => 'pkg_changed',
+                 'curr_value'    => $opt{'curr_value'}, #$pkgpart
+                 'classnum'      => $opt{'classnum'},
+                 'cust_main'     => $opt{'cust_main'},  #$cust_main
+                 'prospect_main' => $opt{'prospect_main'},  #$prospect_main
+                 'onchange'      => 'pkg_changed',
     &>
   </TD>
 </TR>
@@ -91,8 +95,13 @@ my %opt = @_;
 my $pre_label = $opt{'pre_label'} || '';
 $pre_label .= ' ' if length($pre_label) && $pre_label =~ /\S$/;
 
-my $cust_main = $opt{'cust_main'}
-  or die "cust_main not specified";
+my $cust_main = $opt{'cust_main'};
+my $prospect_main = $opt{'prospect_main'};
+
+die "neither cust_main nor prospect_main specified"
+  unless $cust_main || $prospect_main;
+
+my $agent = $cust_main ? $cust_main->agent : $prospect_main->agent;
 
 #"normal" part_pkg agent virtualization (agentnum or type)
 my @part_pkg = qsearch({
@@ -101,7 +110,7 @@ my @part_pkg = qsearch({
   'hashref'   => { 'disabled' => '' },
   'extra_sql' =>
     ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql( 'null'=>1 ).
-    ' AND '. FS::part_pkg->agent_pkgs_sql( $opt{'cust_main'}->agent ),
+    ' AND '. FS::part_pkg->agent_pkgs_sql( $agent ),
 });
 
 my @pkg_class =
diff --git a/httemplate/misc/cust-part_pkg.cgi b/httemplate/misc/cust-part_pkg.cgi
index dcd033f..a277ba4 100644
--- a/httemplate/misc/cust-part_pkg.cgi
+++ b/httemplate/misc/cust-part_pkg.cgi
@@ -1,11 +1,19 @@
 <% objToJson( \@return ) %>
 <%init>
 
-my( $custnum, $classnum ) = $cgi->param('arg');
+my( $custnum, $prospectnum, $classnum ) = $cgi->param('arg');
 
-#XXX i guess i should be agent-virtualized.  cause "packages a customer can
-#order" is such a huge deal
-my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+
+my $agent;
+if ( $custnum ) {
+  my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+    or die 'unknown custnum';
+  $agent = $cust_main->agent;
+} else {
+  my $prospect_main = qsearchs('prospect_main', {'prospectnum'=>$prospectnum} )
+    or die 'unknown prospectnum';
+  $agent = $prospect_main->agent;
+}
 
 my %hash = ( 'disabled' => '' );
 if ( $classnum > 0 ) {
@@ -19,7 +27,7 @@ my @part_pkg = qsearch({
   'hashref'   => \%hash,
   'extra_sql' =>
     ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql( 'null'=>1 ).
-    ' AND '. FS::part_pkg->agent_pkgs_sql( $cust_main->agent ),
+    ' AND '. FS::part_pkg->agent_pkgs_sql( $agent ),
   'order_by'  => 'ORDER BY pkg',
 });
 
diff --git a/httemplate/view/cust_main/order_pkg_link.html b/httemplate/view/cust_main/order_pkg_link.html
deleted file mode 100644
index 7bc5eef..0000000
--- a/httemplate/view/cust_main/order_pkg_link.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<& /elements/popup_link-cust_main.html,
-          'action'      => $p. 'misc/order_pkg.html',
-          'label'       => $opt{'label'} || emt('Order new package'),
-          'actionlabel' => emt('Order new package'),
-          'color'       => '#333399',
-          'cust_main'   => $cust_main,
-          'closetext'   => emt('Close'),
-          'width'       => 960, #763,
-          'height'      => $height,
-          %optional,
-&>
-<%init>
-
-my($cust_main, %opt) = @_;
-
-my %optional = map { $_ => $opt{$_} }
-                 grep $opt{$_},
-                   qw( lock_pkgpart lock_locationnum qualnum svcpart );
-
-my $height = $opt{'lock_locationnum'} ? 336 : 576;
-
-</%init>
diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html
index e16b2c1..7d79306 100755
--- a/httemplate/view/cust_main/packages.html
+++ b/httemplate/view/cust_main/packages.html
@@ -7,7 +7,7 @@
 
 % if ( $curuser->access_right('Order customer package') ) { 
   <% $s++ ? ' | ' : '' %>
-  <& order_pkg_link.html, $cust_main &>
+  <& /elements/order_pkg_link.html, 'cust_main'=>$cust_main &>
 % } 
 
 % if ( $curuser->access_right('One-time charge')
diff --git a/httemplate/view/prospect_main.html b/httemplate/view/prospect_main.html
index 801d64b..6c4595d 100644
--- a/httemplate/view/prospect_main.html
+++ b/httemplate/view/prospect_main.html
@@ -78,9 +78,16 @@
         <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
       </TR>
 %     foreach my $quotation (@quotations) {
+%       if ( $bgcolor eq $bgcolor1 ) {
+%         $bgcolor = $bgcolor2;
+%       } else {
+%         $bgcolor = $bgcolor1;
+%       }
+%       my $a = qq(<A HREF="$p/view/quotation.html?quotationnum=). #"
+%               $quotation->quotationnum. '">';
         <TR>
-          <TD CLASS="grid" BGCOLOR="#cccccc"><% $quotation->quotationnum %></TD>
-          <TD CLASS="grid" BGCOLOR="#cccccc"><% time2str($date_format, $quotation->_date) |h %></TD>
+          <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% $quotation->quotationnum %></A></TD>
+          <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $a %><% time2str($date_format, $quotation->_date) |h %></A></TD>
         </TR>
 %     }
     </TABLE>
diff --git a/httemplate/view/qual.cgi b/httemplate/view/qual.cgi
index 5c15ec0..56c2b61 100644
--- a/httemplate/view/qual.cgi
+++ b/httemplate/view/qual.cgi
@@ -59,8 +59,10 @@
 %               $opt{'svcpart'} = $pkg_svc->svcpart if $pkg_svc;
 %             }
 
-              <% include('/view/cust_main/order_pkg_link.html',
-                           $cust_or_prospect, %opt) %>
+              <& /elements/order_pkg_link.html,
+                   'cust_main' => $cust_or_prospect,
+                   %opt
+              &>
 
 %           } elsif ($cust_or_prospect->prospectnum) {
 
diff --git a/httemplate/view/quotation.html b/httemplate/view/quotation.html
index 866ade2..461b5df 100755
--- a/httemplate/view/quotation.html
+++ b/httemplate/view/quotation.html
@@ -24,9 +24,16 @@ XXX resending quotations
 
 </%doc>
 
-% if ( $conf->exists('quotation_latex') ) { 
+% if ( $curuser->access_right('Order customer package') ) {
+  <& /elements/order_pkg_link.html,
+       'label'       => emt('Add package'),
+       'actionlabel' => emt('Add package'),
+       map { $_ => $quotation->$_ } qw( quotationnum custnum prospectnum )
+  &>
+% }
 
-  <A HREF="<% $p %>view/quotation-pdf.cgi?<% $link %>"><% mt('View typeset quotation PDF') |h %></A>
+% if ( $conf->exists('quotation_latex') ) { 
+  | <A HREF="<% $p %>view/quotation-pdf.cgi?<% $link %>"><% mt('View typeset quotation PDF') |h %></A>
   <BR><BR>
 % } 
 

-----------------------------------------------------------------------

Summary of changes:
 httemplate/elements/order_pkg_link.html          |   26 +++++++++++++++++++++
 httemplate/elements/popup_link-cust_main.html    |   23 ++++++++++++++----
 httemplate/elements/select-cust-part_pkg.html    |    6 ++--
 httemplate/elements/tr-select-cust-part_pkg.html |   27 ++++++++++++++-------
 httemplate/misc/cust-part_pkg.cgi                |   18 ++++++++++----
 httemplate/view/cust_main/order_pkg_link.html    |   22 -----------------
 httemplate/view/cust_main/packages.html          |    2 +-
 httemplate/view/prospect_main.html               |   11 +++++++-
 httemplate/view/qual.cgi                         |    6 +++-
 httemplate/view/quotation.html                   |   11 +++++++-
 10 files changed, 101 insertions(+), 51 deletions(-)
 create mode 100644 httemplate/elements/order_pkg_link.html
 delete mode 100644 httemplate/view/cust_main/order_pkg_link.html




More information about the freeside-commits mailing list