v4 style
[freeside.git] / httemplate / elements / popup_link-cust_main.html
index 3b1363f..541bb58 100644 (file)
@@ -2,10 +2,9 @@
 
 Example:
 
-  <SCRIPT TYPE="text/javascript" SRC="overlibmws.js"></SCRIPT>
-  <SCRIPT TYPE="text/javascript" SRC="iframecontentmws.js"></SCRIPT>
+  include('/elements/init_overlib.html')
 
-  include( '/elements/cust_popup_link.html', {
+  include( '/elements/popup_link-cust_main.html', { #hashref or a list, either way
 
     #required
     'action'         => 'content.html', # uri for content of popup which should
@@ -23,34 +22,38 @@ Example:
   )
 
 </%doc>
+% if ( $custnum || $prospectnum ) {
+<% include('/elements/popup_link.html', $params ) %>\
+% }
 <%init>
-my($params, $action, $label, $actionlabel, $color, $cust_main, $width);
-my $closetext = '';
-if (ref(@_[0]) eq 'HASH') {
-  $params = shift;
-  foreach (qw(action label actionlabel width color)) {
-    $action      = $params->{'action'}      if exists $params->{'action'};
-    $label       = $params->{'label'}       if exists $params->{'label'};
-    $actionlabel = $params->{'actionlabel'} if exists $params->{'actionlabel'};
-    $width       = $params->{'width'}       if exists $params->{'width'};
-    $color       = $params->{'color'}       if exists $params->{'color'};
-    $closetext   = $params->{'closetext'}   if exists $params->{'closetext'};
-    $cust_main   = $params->{'cust_main'}   if exists $params->{'cust_main'};
-  }
-}else{  # deprecated
-  ($action, $label, $actionlabel, $color, $cust_main) = @_;
+
+my $params = { 'closetext' => emt('Close') };
+
+if (ref($_[0]) eq 'HASH') {
+  $params = { %$params, %{ $_[0] } };
+} else {
+  $params = { %$params, @_ };
 }
 
-$action .= '?'. $cust_main->custnum;
+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'} =~ /\?/ ? ';' : '?' ).
+                       "prospectnum=$prospectnum"
+  if $prospectnum;
+
+$params->{'action'} .= ";$_=".$params->{$_}
+  foreach grep $params->{$_},
+    qw( lock_pkgpart lock_locationnum qualnum quotationnum svcpart );
 
 </%init>
-<% $cust_main 
-   ? include('/elements/popup_link.html', { 'action'       => $action,
-                                            'label'        => $label,
-                                            'actionlabel'  => $actionlabel,
-                                            'color'        => $color,
-                                            'closetext'    => $closetext,
-                                          }
-            )
-   : ''
-%>