don't show invoice resend and payment posting links if you can't do that anyway
[freeside.git] / httemplate / search / cust_bill.html
index e23785a..2860f7a 100755 (executable)
@@ -159,7 +159,8 @@ if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) {
                      FS::cust_bill->owed_sql. ' AS owed',
                      FS::cust_bill->net_sql.  ' AS net',
                    ),
-    'extra_sql' => "$extra_sql $orderby"
+    'extra_sql' => $extra_sql,
+    'order_by'  => $orderby,
   };
 
 }
@@ -187,18 +188,43 @@ my $html_init = join("\n", map {
  qq!<FORM NAME="${_}form">!,
  ( map qq!<INPUT TYPE="hidden" NAME="$_" VALUE="$search{$_}">!, keys %search ),
  qq!</FORM>!
-} qw( print_ email_ fax_ ) );
-
-my $menubar =  [
-                'Main menu' => $p,
-                'Print these invoices' =>
-                  "javascript:print_process()",
-                'Email these invoices' =>
-                  "javascript:email_process()",
-              ];
-
-push @$menubar, 'Fax these invoices' =>
-                 "javascript:fax_process()"
- if $conf->exists('hylafax');
+} qw( print_ email_ fax_ ) ). 
+
+'<SCRIPT TYPE="text/javascript">
+
+function confirm_print_process() {
+  if ( ! confirm("Are you sure you want to reprint these invoices?") ) {
+    return;
+  }
+  print_process();
+}
+function confirm_email_process() {
+  if ( ! confirm("Are you sure you want to re-email these invoices?") ) {
+    return;
+  }
+  email_process();
+}
+function confirm_fax_process() {
+  if ( ! confirm("Are you sure you want to re-fax these invoices?") ) {
+    return;
+  }
+  fax_process();
+}
+
+</SCRIPT>';
+
+my $menubar = [];
+
+if ( $FS::CurrentUser::CurrentUser->access_right('Resend invoices') ) {
+
+  push @$menubar, 'Print these invoices' =>
+                    "javascript:confirm_print_process()",
+                  'Email these invoices' =>
+                    "javascript:confirm_email_process()";
+
+  push @$menubar, 'Fax these invoices' =>
+                    "javascript:confirm_fax_process()"
+    if $conf->exists('hylafax');
+}
 
 </%init>