report on contract end dates, #71964
[freeside.git] / httemplate / elements / menu.html
index b4fff22..51ec263 100644 (file)
@@ -89,10 +89,16 @@ my $curuser = $FS::CurrentUser::CurrentUser;
 
 #XXX Active tickets not assigned to a customer
 
-tie my %report_prospects, 'Tie::IxHash',
-  'List prospects' => [ $fsurl. 'search/prospect_main.html', '' ],
-  'Advanced prospect reports' => [ $fsurl. 'search/report_prospect_main.html', '' ],
-;
+tie my %report_prospects, 'Tie::IxHash';
+if ( $curuser->access_right('List prospects') ) {
+  $report_prospects{'List prospects'} = [ $fsurl. 'search/prospect_main.html', '' ];
+  $report_prospects{'Advanced prospect reports'} = [ $fsurl. 'search/report_prospect_main.html', '' ];
+}
+$report_prospects{'separator'} = ''
+  if $curuser->access_right('List prospects')
+  && $curuser->access_right('List contacts');
+$report_prospects{'Prospect contacts'} = [ $fsurl. 'search/report_contact.html?link=prospect_main', '' ]
+  if $curuser->access_right('List contacts');
 
 tie my %report_quotations, 'Tie::IxHash',
   'List quotations' => [ $fsurl. 'search/quotation.html', '' ],
@@ -113,9 +119,16 @@ tie my %report_customers, 'Tie::IxHash';
 $report_customers{'List customers'} = [ \%report_customers_lists, 'List customers' ]
   if $curuser->access_right('List all customers');
 $report_customers{'Zip code distribution'}     = [ $fsurl. 'search/report_cust_main-zip.html', 'Zip codes by number of customers' ];
-$report_customers{'Customer signup report'}       = [ $fsurl. 'graph/report_cust_signup.html', 'New customer signups by date' ],
-$report_customers{'Advanced customer reports'} = [ $fsurl. 'search/report_cust_main.html', 'by status, signup date, agent, etc.' ]
+$report_customers{'Customer signup report'}    = [ $fsurl. 'graph/report_cust_signup.html',    'New customer signups by date' ];
+$report_customers{'Customer churn report'} =  [ $fsurl.'graph/report_cust_churn.html', 'New customers, suspensions, and cancellations summary' ];
+$report_customers{'Signup date report'}        = [ $fsurl. 'graph/report_signupdate.html',     'Signup date report (by date of signup)' ];
+$report_customers{'Advanced customer reports'} = [ $fsurl. 'search/report_cust_main.html',     'by status, signup date, agent, etc.' ]
   if $curuser->access_right('Advanced customer search');
+if ( $curuser->access_right('List contacts') ) {
+  $report_customers{'separator'} = '';
+  $report_customers{'Customer contacts'} = [ $fsurl. 'search/report_contact.html?link=cust_main' ];
+  $report_customers{'Customer stored payment information'} = [ $fsurl. 'search/report_cust_payby.html' ];
+}
 
 tie my %report_invoices_open, 'Tie::IxHash',
   'All open invoices' => [ $fsurl.'search/cust_bill.html?OPEN_date', 'All invoices with an unpaid balance' ],
@@ -132,6 +145,9 @@ tie my %report_invoices, 'Tie::IxHash',
   'Advanced invoice reports' => [ $fsurl.'search/report_cust_bill.html', 'by agent, date range, etc.' ],
   'separator'     => '',
   'Line items'    => [ $fsurl. 'search/report_cust_bill_pkg.html', 'Individual line item detail' ],
+  'separator'     => '',
+  'Voided invoices' => [ $fsurl.'search/report_cust_bill_void.html', 'Search for voided invoices' ],
+
 ;
 
 tie my %report_discounts, 'Tie::IxHash',
@@ -211,10 +227,12 @@ foreach my $svcdb ( FS::part_svc->svc_tables() ) {
       ];
   }
 
-  $report_svc{"Advanced $lcsname reports"} = 
+  if ( $curuser->access_right("Services: $name: Advanced search")
+    && $svcdb =~ /^svc_(acct|broadband|hardware|phone|fiber)$/ ) {
+
+    $report_svc{"Advanced $lcsname reports"} = 
       [ $fsurl."search/report_$svcdb.html", '' ]
-    if $svcdb =~ /^svc_(acct|broadband|hardware|phone)$/
-    && $curuser->access_right("Services: $name: Advanced search");
+  }
 
   if ( $svcdb eq 'svc_phone' ) {
 
@@ -255,8 +273,9 @@ $report_packages{'Suspended customer packages'} =  [ $fsurl.'search/cust_pkg.cgi
 $report_packages{'Suspension summary'} = [ $fsurl.'search/cust_pkg_susp.html', 'Show suspension activity', ]
   if $curuser->access_right('Summarize packages');
 $report_packages{'Customer packages with unconfigured services'} =  [ $fsurl.'search/cust_pkg.cgi?APKG_pkgnum', 'List packages which have provisionable services' ];
-$report_packages{'FCC Form 477 packages'} =  [ $fsurl.'search/report_477.html', 'Summarize packages by census tract for particular types' ]
-  if $conf->exists('cust_main-require_censustract');
+$report_packages{'FCC Form 477'} =  [ $fsurl.'search/report_477.html' ]
+  if $conf->exists('part_pkg-show_fcc_options');
+$report_packages{'Contract end dates'} = [ $fsurl.'search/cust_pkg-date.html?date=contract_end', 'Show packages by contract end date' ];
 $report_packages{'Advanced package reports'} =  [ $fsurl.'search/report_cust_pkg.html', 'by agent, date range, status, package definition' ];
 
 tie my %report_inventory, 'Tie::IxHash',
@@ -273,9 +292,12 @@ $report_rating{'Call Detail Records (CDRs)'} = [ $fsurl.'search/report_cdr.html'
   if $curuser->access_right("Usage: Call Detail Records (CDRs)");
 $report_rating{'Unrateable CDRs'} = [ $fsurl.'search/cdr.html?freesidestatus=failed;cdrbatchnum=_ALL_' ]
   if $curuser->access_right("Usage: Unrateable CDRs");
+$report_rating{'Customer CDRs Profit/Loss'} = [ $fsurl.'search/report_customer_cdr_profit.html', 'Profit/loss from customer CDRs' ]
+  if $curuser->access_right('Financial reports');
 if ( $curuser->access_right("Usage: Time worked") ) {
   $report_rating{'Time worked'} = [ $fsurl.'search/report_rt_transaction.html', '' ];
-  $report_rating{'Time worked summary'} = [ $fsurl.'search/report_rt_ticket.html', '' ];
+  $report_rating{'Time worked summary per ticket'} = [ $fsurl.'search/report_rt_ticket.html', '' ];
+  $report_rating{'Time worked summary per customer'} = [ $fsurl.'search/report_rt_cust.html', '' ];
 }
 
 tie my %report_ticketing_statistics, 'Tie::IxHash',
@@ -298,28 +320,19 @@ tie my %report_ticketing, 'Tie::IxHash',
   'Advanced ticket reports' => [ $fsurl.'rt/Search/Build.html?NewQuery=1', 'List tickets by any criteria' ],
 ;
 
-tie my %report_employees, 'Tie::IxHash';
-$report_employees{'Employee Commission Report'} = [ $fsurl.'search/report_employee_commission.html', '' ]
-  if $curuser->access_right('Employees: Commission Report');
-$report_employees{'Employee Audit Report'} = [ $fsurl.'search/report_employee_audit.html', 'Employee audit report' ]
-  if $curuser->access_right('Employees: Audit Report');
-;
-
 tie my %report_bill_event, 'Tie::IxHash',
-  'All billing events' => [ $fsurl.'search/report_cust_event.html', 'All billing events for a date range' ],
   'Billing event errors' => [ $fsurl.'search/report_cust_event.html?failed=1', 'Failed credit cards, processor or printer problems, etc.' ],
-#  'All invoice events' => [ $fsurl.'search/cust_bill_event.html', 'Reports on deprecated, old-style invoice events for a date range' ],
-#  'Invoice event errors' => [ $fsurl.'search/cust_bill_event.html?failed=1', 'Reports on deprecated, old-style events for failed credit cards, processor or printer problems, etc.' ],
 ;
 
 tie my %report_payments, 'Tie::IxHash',
-    'Payments' => [ $fsurl.'search/report_cust_pay.html', 'Payment report (by type and/or date range)' ],
+  'Payments' => [ $fsurl.'search/report_cust_pay.html', 'Payment report (by type and/or date range)' ],
+  'Payment application detail' => [ $fsurl.'search/report_cust_bill_pay_pkg.html', 'Line item application detail' ],
 ;
 $report_payments{'Pending Payments'} = [ $fsurl.'search/cust_pay_pending.html?magic=_date;statusNOT=done', 'Pending real-time payments' ]
   if $curuser->access_right('View customer pending payments');
+$report_payments{'Unapplied Payments'} = [ $fsurl.'search/report_cust_pay.html?unapplied=1', 'Unapplied payment report (by type and/or date range)' ];
 $report_payments{'Voided Payments'} = [ $fsurl.'search/report_cust_pay.html?void=1', 'Voided payment report (by type and/or date range)' ]
   if $curuser->access_right('View customer pending payments');
-$report_payments{'Unapplied Payments'} = [ $fsurl.'search/report_cust_pay.html?unapplied=1', 'Unapplied payment report (by type and/or date range)' ];
 $report_payments{'Payment Batches'} = [ $fsurl.'search/pay_batch.html', 'Payment batches (by status and/or date range)' ]
   if $conf->exists('batch-enable') || $conf->config('batch-enable_payby');
 $report_payments{'Unapplied Payment Aging'} = [ $fsurl.'search/report_unapplied_cust_pay.html', 'Unapplied payment aging report' ];
@@ -328,8 +341,10 @@ $report_payments{'Deleted Payments / Payment history table'} = [ $fsurl.'search/
 
 tie my %report_credits, 'Tie::IxHash',
   'Credit Report' => [ $fsurl.'search/report_cust_credit.html', 'Credit report (by employee and/or date range)' ],
+  'Credit package source detail' => [ $fsurl.'search/report_cust_credit_source_bill_pkg.html', 'Line-item detail for triggered package credits' ],
   'Credit application detail' => [ $fsurl.'search/report_cust_credit_bill_pkg.html', 'Line item application detail' ],
   'Unapplied Credits' => [ $fsurl.'search/report_cust_credit.html?unapplied=1', 'Unapplied credit report (by type and/or date range)' ],
+  'Voided Credits' => [ $fsurl.'search/report_cust_credit_void.html', 'Voided credit report (by employee and/or date range)' ],
 ;
 
 tie my %report_refunds, 'Tie::IxHash',
@@ -343,26 +358,36 @@ tie my %report_sales, 'Tie::IxHash',
   'Sales Report' => [ $fsurl.'graph/report_cust_bill_pkg.html', 'Sales report and graph (by agent, package class and/or date range)' ],
   'Rated Call Sales Report' => [ $fsurl.'graph/report_cust_bill_pkg_detail.html', 'Sales report and graph (by agent, package class, usage class and/or date range)' ],
   'Sales with Advertising Source' => [ $fsurl.'search/report_cust_bill_pkg_referral.html' ],
-  'Agent Commissions' => [ $fsurl.'search/report_agent_commission.html' ],
-  'Sales Person Commissions' => [ $fsurl.'search/report_sales_commission.html' ],
+;
+
+tie my %report_commissions, 'Tie::IxHash',
+  'Agent' => [ $fsurl.'search/report_agent_commission.html' ],
+  'Agent per package' => [ $fsurl.'search/report_agent_commission_pkg.html' ],
+  'Sales Person' => [ $fsurl.'search/report_sales_commission.html' ],
+  'Sales Person per package' => [ $fsurl.'search/report_sales_commission_pkg.html' ],
+  'Employee' => [ $fsurl.'search/report_employee_commission.html', '' ],
+  'Agent Credits and Payments' => [ $fsurl.'search/report_agent_credit_payment.html' ],
 ;
 
 tie my %report_financial, 'Tie::IxHash';
 if( $curuser->access_right('Financial reports') ) {
 
   %report_financial = (
-    'Sales' => [ \%report_sales, 'Sales reports', ],
-    'Credits' => [ \%report_credits, 'Credit reports', ],
-    'Refunds' => [ \%report_refunds, 'Refund reports', ],
+    'Sales'       => [ \%report_sales, 'Sales reports', ],
+    'Commissions' => [ \%report_commissions, 'Commission reports', ],
+    'Credits'     => [ \%report_credits, 'Credit reports', ],
+    'Refunds'     => [ \%report_refunds, 'Refund reports', ],
   );
   $report_financial{'A/R Aging'} = [ $fsurl.'search/report_receivables.html', 'Accounts Receivable Aging report' ];
   $report_financial{'Prepaid Income'} = [ $fsurl.'search/report_prepaid_income.html', 'Prepaid income (unearned revenue)  report' ];
 
-  my $taxproducts = $conf->exists('enable_taxproducts');
+  my $taxproducts = $conf->config('tax_data_vendor');
   $report_financial{'Tax Liability'. ($taxproducts ? ' (internal tax data)' : '')} = [ $fsurl.'search/report_tax.html', 'Tax liability report (internal tax data)' ];
   $report_financial{'Tax Liability (vendor tax data)'} = [ $fsurl.'search/report_newtax.html', 'Tax liability report (vendor tax data)' ]
     if $taxproducts;
 
+  $report_financial{'Monthly Sales and Taxes'} = [$fsurl.'search/tax_sales.html', 'Monthly sales and taxes report'];
+
   # most sites don't need this but there isn't really a config to enable it
   $report_financial{'E911 Fee Summary'} = [ $fsurl.'search/report_e911.html', 'E911 fee summary' ];
 
@@ -375,24 +400,33 @@ if( $curuser->access_right('Financial reports') ) {
 } # else $report_financial contains nothing.
 
 tie my %report_payable, 'Tie::IxHash',
-  'Payables' => [ $fsurl. 'search/report_vend_bill.html' ],
+  'Payables summary' => [ $fsurl. 'search/report_vend_main.html', 'Payables summary by vendor' ],
+  'Payables detail' => [ $fsurl. 'search/report_vend_bill.html' ],
 ;
 
 tie my %report_logs, 'Tie::IxHash';
-  $report_logs{'System log'} = [ $fsurl.'search/log.html', 'View system events and debugging information.' ],
+$report_logs{'Billing events'} =  [ $fsurl.'search/report_cust_event.html', 'Search billing events by date and status' ]
+  if $curuser->access_right('Billing event reports');
+$report_logs{'Credit limit incidents'} = [ $fsurl.'search/report_cust_main_credit_limit.html', '' ]
+  if $curuser->access_right('List rating data');
+$report_logs{'Employee activity'} = [ $fsurl.'search/report_employee_audit.html', '' ]
+  if $curuser->access_right('Employees: Audit Report');
+$report_logs{'System log'} = [ $fsurl.'search/log.html', 'View system events and debugging information.' ],
   if $curuser->access_right('View system logs')
   || $curuser->access_right('Configuration');
-  $report_logs{'Outgoing messages'} = [ $fsurl.'search/cust_msg.html', 'View outgoing message log' ]
+$report_logs{'Outgoing messages'} = [ $fsurl.'search/cust_msg.html', 'View outgoing message log' ]
   if $curuser->access_right('View email logs')
   || $curuser->access_right('Configuration');
 
 tie my %report_menu, 'Tie::IxHash';
 $report_menu{'Prospects'}      = [ \%report_prospects, 'Prospect reports' ]
-  if $curuser->access_right('List prospects');
+  if $curuser->access_right('List prospects')
+  || $curuser->access_right('List contacts');
 $report_menu{'Quotations'}     = [ \%report_quotations, 'Quotation reports' ]
   if $curuser->access_right('List quotations');
 $report_menu{'Customers'}      = [ \%report_customers, 'Customer reports'  ]
-  if $curuser->access_right('List customers');
+  if $curuser->access_right('List customers')
+  || $curuser->access_right('List contacts');
 $report_menu{'Invoices'}       =  [ \%report_invoices,  'Invoice reports'   ]
   if $curuser->access_right('List invoices');
 $report_menu{'Discounts'}      =  [ \%report_discounts, 'Discount reports'  ]
@@ -410,10 +444,6 @@ $report_menu{'Usage'}          =  [ \%report_rating,    'Usage reports'  ]
 $report_menu{'Tickets'}        = [ \%report_ticketing, 'Ticket reports' ]
   if $conf->config('ticket_system')
   ;#&& FS::TicketSystem->access_right(\%session, 'Something');
-$report_menu{'Employees'}      =  [ \%report_employees, 'Employee reports'  ]
-  if keys %report_employees;
-$report_menu{'Billing events'} =  [ \%report_bill_event, 'Billing events' ]
-  if $curuser->access_right('Billing event reports');
 $report_menu{'Financial (Receivables)'} = [ \%report_financial, 'Financial reports (Receivables)' ]
   if $curuser->access_right('Financial reports') 
   or $curuser->access_right('Receivables report');
@@ -425,16 +455,38 @@ $report_menu{'Logs'}           = [ \%report_logs, 'System and email logs' ]
 $report_menu{'SQL Query'}      = [ $fsurl.'search/report_sql.html', 'SQL Query']
   if $curuser->access_right('Raw SQL');
 
+tie my %tools_customers, 'Tie::IxHash', ();
+$tools_customers{'Appointments'} = [ $fsurl.'rt/Search/Schedule.html?LengthMin=0', 'View appointment schedule' ]
+  if $curuser->access_right('View appointments');
+$tools_customers{'Attachments'} = [ $fsurl.'browse/cust_attachment.html', 'View customer attachments' ]
+  if !$conf->config('disable_cust_attachment') and $curuser->access_right('View attachments') and $curuser->access_right('Browse attachments');
+$tools_customers{'Customer email settings'} = [ $fsurl.'misc/manage_cust_email.html' ]
+  if $curuser->access_right('Edit customer');
+
+tie my %tools_billing, 'Tie::IxHash', ();
+$tools_billing{'Quick payment entry'} =  [ $fsurl.'misc/batch-cust_pay.html', 'Enter multiple payments in a batch' ]
+  if $curuser->access_right('Post payment batch');
+$tools_billing{'Process payment batches'} = [ $fsurl.'search/pay_batch.cgi?magic=_date;open=1;intransit=1', 'Process credit card and electronic check batches' ]
+  if ( $conf->exists('batch-enable') || $conf->config('batch-enable_payby') )
+     && $curuser->access_right('Process batches');
+$tools_billing{'Download invoice batches'} = [ $fsurl.'search/bill_batch.cgi' ]
+  if $curuser->access_right('Process invoice batches')
+  || $curuser->access_right('Process global invoice batches')
+  || $curuser->access_right('Configuration'); #XXX remove in 2.5
+  #now there's a standalone event#if $conf->exists('invoice_print_pdf');
+
 tie my %tools_importing, 'Tie::IxHash',
-  'Customers' => [ $fsurl.'misc/cust_main-import.cgi', '' ],
-  'Customer packages' => [ $fsurl.'misc/cust_pkg-import.html', '' ],
-  'Customer comments from CSV file' => [ $fsurl.'misc/cust_main_note-import.html', '' ],
-  'One-time charges from CSV file' => [ $fsurl.'misc/cust_main-import_charges.cgi', '' ],
-  'Payments from CSV file' => [ $fsurl.'misc/cust_pay-import.cgi', '' ],
+  'Customers'            => [ $fsurl.'misc/cust_main-import.cgi', '' ],
+  'Package definitions'  => [ $fsurl.'misc/part_pkg-import.html', '' ],
+  'Customer packages'    => [ $fsurl.'misc/cust_pkg-import.html', '' ],
+  'Customer comments'    => [ $fsurl.'misc/cust_main_note-import.html', '' ],
+  'One-time charges'     => [ $fsurl.'misc/cust_main-import_charges.cgi', '' ],
+  'Payments'             => [ $fsurl.'misc/cust_pay-import.cgi', '' ],
+  'Credits'              => [ $fsurl.'misc/cust_credit-import.html', '' ],
   'Phone numbers (DIDs)' => [ $fsurl.'misc/phone_avail-import.html', '' ],
   'Call Detail Records (CDRs)' => [ $fsurl.'misc/cdr-import.html', '' ],
 ;
-if ( $conf->exists('enable_taxproducts') ) {
+if ( $conf->config('tax_data_vendor') eq 'cch' ) {
   if ( $conf->exists('taxdatadirectdownload') ) {
       $tools_importing{'Tax rates from vendor site'} =
       [ $fsurl.'misc/tax-fetch_and_import.cgi', '' ];
@@ -444,9 +496,17 @@ if ( $conf->exists('enable_taxproducts') ) {
   }
 }
 
-tie my %tools_exporting, 'Tie::IxHash',
-  'Download database dump' => [ $fsurl. 'misc/dump.cgi', '' ],
-;
+tie my %tools_misc, 'Tie::IxHash', ();
+$tools_misc{'Bulk DID Orders'} =  [ $fsurl.'browse/did_order.html', 'View/manage bulk DID orders' ]
+  if $curuser->access_right('Import');
+$tools_misc{'Business card scan'} = [ $fsurl.'edit/prospect_main-upload.html' ]
+  if $curuser->access_right('New prospect');
+$tools_misc{'Time Queue'} =  [ $fsurl.'search/report_timeworked.html', 'View pending support time' ]
+  if $curuser->access_right('Time queue');
+
+#tie my %tools_exporting, 'Tie::IxHash',
+#  'Download database dump' => [ $fsurl. 'misc/dump.cgi', '' ],
+#;
 
 tie my %tools_ticketing_articles, 'Tie::IxHash',
   'Overview' => [ $fsurl.'rt/Articles/index.html', '' ],
@@ -464,39 +524,34 @@ tie my %tools_ticketing, 'Tie::IxHash',
 $tools_ticketing{'Cron Tool'} = [ $fsurl.'rt/Developer/CronTool/', '' ]
   if $conf->exists('rt-crontool');
 
-tie my %tools_menu, 'Tie::IxHash', ();
-$tools_menu{'Quick payment entry'} =  [ $fsurl.'misc/batch-cust_pay.html', 'Enter multiple payments in a batch' ]
-  if $curuser->access_right('Post payment batch');
-$tools_menu{'Process payment batches'} = [ $fsurl.'search/pay_batch.cgi?magic=_date;open=1;intransit=1', 'Process credit card and electronic check batches' ]
-  if ( $conf->exists('batch-enable') || $conf->config('batch-enable_payby') )
-     && $curuser->access_right('Process batches');
-$tools_menu{'Download invoice batches'} = [ $fsurl.'search/bill_batch.cgi' ]
-  if $curuser->access_right('Process invoice batches')
-  || $curuser->access_right('Process global invoice batches')
-  || $curuser->access_right('Configuration'); #XXX remove in 2.5
-  #now there's a standalone event#if $conf->exists('invoice_print_pdf');
-$tools_menu{'Bulk DID Orders'} =  [ $fsurl.'browse/did_order.html', 'View/manage bulk DID orders' ]
-  if $curuser->access_right('Import');
-$tools_menu{'Job Queue'} =  [ $fsurl.'search/queue.html', 'View pending job queue' ]
+tie my %tools_system, 'Tie::IxHash', ();
+$tools_system{'Status'} = [ $fsurl.'view/Status.html', 'System status' ]
+  if $curuser->access_right('Configuration'); # 'View system status');
+$tools_system{'Job Queue'} =  [ $fsurl.'search/queue.html', 'View pending job queue' ]
   if $curuser->access_right('Job queue');
+$tools_system{'Access log statistics'} = [ $fsurl.'search/report_access_user_log.html?group_by=path', '' ]
+  if $curuser->access_right('Configuration'); # 'View profiling data');
+
+tie my %tools_menu, 'Tie::IxHash', ();
+$tools_menu{'Customers'} = [ \%tools_customers, 'Customer tools' ]
+  if keys %tools_customers;
+$tools_menu{'Billing'} = [ \%tools_billing, 'Payment and invoice tools' ]
+  if keys %tools_billing;
 $tools_menu{'Ticketing'} = [ \%tools_ticketing, 'Ticketing tools' ]
   if $conf->config('ticket_system');
-$tools_menu{'Customer email settings'} = [ $fsurl.'misc/manage_cust_email.html' ]
-  if $curuser->access_right('Edit customer');
-$tools_menu{'Business card scan'} = [ $fsurl.'edit/prospect_main-upload.html' ]
-  if $curuser->access_right('New prospect');
-$tools_menu{'Time Queue'} =  [ $fsurl.'search/report_timeworked.html', 'View pending support time' ]
-  if $curuser->access_right('Time queue');
-$tools_menu{'Attachments'} = [ $fsurl.'browse/cust_attachment.html', 'View customer attachments' ]
-  if !$conf->config('disable_cust_attachment') and $curuser->access_right('View attachments') and $curuser->access_right('Browse attachments');
+$tools_menu{'Miscellaneous'} = [ \%tools_misc, '' ]
+  if keys %tools_misc;
 $tools_menu{'Importing'} =  [ \%tools_importing, 'Import tools' ]
   if $curuser->access_right('Import');
-$tools_menu{'Exporting'} =  [ \%tools_exporting, 'Export tools' ]
-  if $curuser->access_right('Export');
+#$tools_menu{'Exporting'} =  [ \%tools_exporting, 'Export tools' ]
+#  if $curuser->access_right('Export');
+$tools_menu{'System'} = [ \%tools_system, 'System tools' ]
+  if keys %tools_menu;
 
 tie my %config_employees, 'Tie::IxHash',
   'Employees' => [ $fsurl.'browse/access_user.html', 'Setup internal users' ],
   'Employee groups' => [ $fsurl.'browse/access_group.html', 'Employee groups allow you to control access to the backend' ],
+  'Installer availability' => [ $fsurl.'browse/sched_item.html', 'Installer availability' ],
 ;
 
 tie my %config_dialup, 'Tie::IxHash',
@@ -508,6 +563,10 @@ tie my %config_broadband, 'Tie::IxHash',
   'Routers'        => [ $fsurl.'browse/router.cgi', 'Broadband access routers' ],
   'Address blocks' => [ $fsurl.'browse/addr_block.cgi', 'Manage address blocks and block assignments to broadband routers' ],
 ;
+if ( $curuser->access_right('Broadband global configuration') ) {
+  $config_broadband{'Address ranges'} = 
+                      [ $fsurl.'browse/addr_range.html', 'Designate special address ranges' ];
+}
 
 tie my %config_phone, 'Tie::IxHash',
   'View/Edit phone device types' => [ $fsurl.'browse/part_device.html', 'Phone device types' ],
@@ -531,10 +590,26 @@ tie my %config_alarm, 'Tie::IxHash',
   'Alarm central stations' => [ $fsurl.'browse/alarm_station.html', '' ],
 ;
 
+tie my %config_conferencing, 'Tie::IxHash',
+  'Conferencing types' => [ $fsurl.'browse/conferencing_type.html', '' ],
+  'Quality levels'     => [ $fsurl.'browse/conferencing_quality.html', '' ],
+;
+
+tie my %config_circuit, 'Tie::IxHash',
+  'Circuit types'     => [ $fsurl.'browse/circuit_type.html',         '' ],
+  'Circuit providers' => [ $fsurl.'browse/circuit_provider.html',     '' ],
+  'Termination types' => [ $fsurl.'browse/circuit_termination.html',  '' ],
+;
+
+tie my %config_fiber, 'Tie::IxHash',
+  'OLTs' => [ $fsurl.'browse/fiber_olt.html', '' ],
+;
+
 tie my %config_export_svc, 'Tie::IxHash', ();
 if ( $curuser->access_right('Configuration') ) {
   $config_export_svc{'Service definitions'} = [ $fsurl.'browse/part_svc.cgi', 'Services are items you offer to your customers' ];
   $config_export_svc{'Service classes'} = [ $fsurl.'browse/part_svc_class.html', 'Services classes are user-defined, informational types for services' ];
+  $config_export_svc{'Service dependencies'} = [ $fsurl.'browse/part_svc_link.html', 'Services depencies define rules between service definitions' ];
   $config_export_svc{'Provisioning exports'} = [ $fsurl.'browse/part_export.cgi', 'Provisioning services to external machines, databases and APIs' ];
 }
 $config_export_svc{'Dialup'}  = [ \%config_dialup, ''    ]
@@ -547,16 +622,20 @@ $config_export_svc{'RADIUS'} = [ \%config_radius, '' ]
   if $curuser->access_right('Configuration');
 $config_export_svc{'Cable'} = [ \%config_cable, '' ]
   if $curuser->access_right('Configuration');
+$config_export_svc{'Conferencing'} = [ \%config_conferencing, '' ]
+  if $curuser->access_right('Configuration');
 $config_export_svc{'Alarm'} = [ \%config_alarm, '' ]
   if $curuser->access_right(['Alarm configuration', 'Alarm global configuration']);
+$config_export_svc{'Circuits'} = [ \%config_circuit, '' ]
+  if $curuser->access_right('Configuration');
+$config_export_svc{'Fiber'} = [ \%config_fiber, '' ]
+  if $curuser->access_right('Configuration');
 $config_export_svc{'Hardware types'} = [ $fsurl.'browse/hardware_class.html', 'Set up hardware type catalog' ]
   if $curuser->access_right('Configuration');
 
 tie my %config_pkg_reason, 'Tie::IxHash',
-  'Cancel reasons' => [ $fsurl.'browse/reason.html?class=C', 'Cancel reasons explain why a service was cancelled.' ],
-  'Cancel reason types' => [ $fsurl.'browse/reason_type.html?class=C', 'Cancel reason types define groups of reasons.' ],
-  'Suspend reasons' => [ $fsurl.'browse/reason.html?class=S', 'Suspend reasons explain why a service was suspended.' ],
-  'Suspend reason types' => [ $fsurl.'browse/reason_type.html?class=S', 'Suspend reason types define groups of reasons.' ],
+  'Cancel reasons' => [ $fsurl.'browse/reason_type.html?class=C', 'Cancel reasons explain why a service was cancelled.' ],
+  'Suspend reasons' => [ $fsurl.'browse/reason_type.html?class=S', 'Suspend reasons explain why a service was suspended.' ],
 ;
 
 tie my %config_pkg, 'Tie::IxHash', ();
@@ -571,6 +650,10 @@ if ( $curuser->access_right('Configuration') ) {
   $config_pkg{'Package report classes'} =  [ $fsurl.'browse/part_pkg_report_option.html', 'Package classes define optional groups of packages for reporting only.' ];
   #eo package grouping sub-menu
 
+  if ( $curuser->access_right([ 'Edit fee definitions',
+                                'Edit global fee definitions' ]) ) {
+    $config_pkg{'Fees'} = [ $fsurl.'browse/part_fee.html', '' ];
+  }
   $config_pkg{'Discounts'} = [ $fsurl.'browse/discount.html', '' ];
   $config_pkg{'Discount classes'} = [ $fsurl.'browse/discount_class.html', '' ];
   $config_pkg{'Cancel/Suspend Reasons'} = [ \%config_pkg_reason, '' ];
@@ -590,22 +673,29 @@ $config_cust{'Note classes'} = [ $fsurl.'browse/cust_note_class.html', 'Note cla
 tie my %config_agent, 'Tie::IxHash',
   'Agent types' => [ $fsurl.'browse/agent_type.cgi', 'Agent types define groups of package definitions that you can then assign to particular agents' ],
   'Agents'      => [ $fsurl.'browse/agent.cgi', 'Agents are resellers of your service. Agents may be limited to a subset of your full offerings (via their type)' ],
-  'Agent payment gateways'         => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors for agent overrides' ];
+  'Agent payment gateways'         => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors for agent overrides' ],
+  'separator' => '',
+  'Commission schedules' => [ $fsurl.'browse/commission_schedule.html',
+    'Commission schedules for consecutive billing periods' ],
 ;
 
 tie my %config_sales, 'Tie::IxHash',
   'Sales People' => [ $fsurl.'browse/sales.html', 'Sales people bring in new business.' ],
 ;
 
-tie my %config_billing_rates, 'Tie::IxHash',
-  'Rate plans' => [ $fsurl.'browse/rate.cgi', 'Manage rate plans' ],
-  'Regions and prefixes' => [ $fsurl.'browse/rate_region.html', 'Manage regions and prefixes' ],
-  'Usage classes'  => [ $fsurl.'browse/usage_class.html', 'Usage classes define groups of usage for taxation.' ],
-  'Time periods' => [ $fsurl.'browse/rate_time.html', 'Time periods define days and hours for rate plans' ],
-  'Edit rates with Excel' => [ $fsurl.'misc/rate_edit_excel.html', 'Download and edit rates with Excel, then upload changes.' ], #"Edit with Excel" ?
-  'separator'     => '', #its a separator!
-  'Tiering plans' => [ $fsurl.'browse/rate_tier.html', 'Rating tiers' ],
-;
+tie my %config_billing_rates, 'Tie::IxHash';
+$config_billing_rates{'Rate plans'} = [ $fsurl.'browse/rate.cgi', 'Manage rate plans' ]
+  if $curuser->access_right('Edit CDR rates')
+  #|| $curuser->access_right('Edit global CDR rates')
+  || $curuser->access_right('Configuration');
+if ( $curuser->access_right('Configuration') ) {
+  $config_billing_rates{'Regions and prefixes'} = [ $fsurl.'browse/rate_region.html', 'Manage regions and prefixes' ];
+  $config_billing_rates{'Usage classes'} = [ $fsurl.'browse/usage_class.html', 'Usage classes define groups of usage for taxation.' ];
+  $config_billing_rates{'Time periods'} = [ $fsurl.'browse/rate_time.html', 'Time periods define days and hours for rate plans' ];
+  $config_billing_rates{'Edit rates with Excel'} = [ $fsurl.'misc/rate_edit_excel.html', 'Download and edit rates with Excel, then upload changes.' ]; #"Edit with Excel" ?
+  $config_billing_rates{'separator'} = ''; #its a separator!
+  $config_billing_rates{'Tiering plans'} = [ $fsurl.'browse/rate_tier.html', 'Rating tiers' ];
+}
 
 tie my %config_billing, 'Tie::IxHash';
 #  'Payment gateways'         => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors' ];
@@ -613,22 +703,24 @@ $config_billing{'Billing events'} = [ $fsurl.'browse/part_event.html', 'Billing
     if $curuser->access_right('Edit billing events')
     || $curuser->access_right('Edit global billing events');
 if ( $curuser->access_right('Configuration') ) {
-  #$config_billing{'Invoice events'}         = [ $fsurl.'browse/part_bill_event.cgi', 'Deprecated, old-style actions for overdue invoices' ];
   $config_billing{'Invoice configurations'}      = [ $fsurl.'browse/invoice_conf.html', 'Adjust invoice settings for special-purpose notices' ];
   $config_billing{'Invoice templates'}      = [ $fsurl.'browse/invoice_template.html', 'Edit templates for HTML, plaintext and typeset invoices' ];
   $config_billing{'separator'} = ''; #its a separator!
   $config_billing{'Prepaid cards'}          = [ $fsurl.'search/prepay_credit.html', 'View outstanding cards, generate new cards' ];
-  $config_billing{'Call rates and regions'} = [ \%config_billing_rates, 'Manage rate plans, regions and prefixes for VoIP and call billing' ];
+}
+$config_billing{'Call rates and regions'} = [ \%config_billing_rates, 'Manage rate plans, regions and prefixes for VoIP and call billing' ]
+  if keys %config_billing_rates;
+if ( $curuser->access_right('Configuration') ) {
   $config_billing{'separator2'} = ''; #its a separator!
 
   my $config_taxes_name = 'Locales and tax rates'.
-                          ( $conf->exists('enable_taxproducts')
+                          ( $conf->config('tax_data_vendor')
                             ? ' (internal tax class system)'
                             : ''
                           );
   $config_billing{$config_taxes_name}  = [ $fsurl.'browse/cust_main_county.cgi', 'Change tax rates, or break down a country into states, or a state into counties and assign different tax rates to each' ];
   $config_billing{'Tax rates (vendor data tax products system)'}  = [ $fsurl.'browse/tax_rate.cgi', 'Edit tax rates for the vendor data tax products system' ]
-     if $conf->exists('enable_taxproducts');
+     if $conf->config('tax_data_vendor');
   $config_billing{'Tax classes'} = [ $fsurl. 'browse/part_pkg_taxclass.html', 'Tax classes' ];
 
   if ( $conf->config('currencies') ) {
@@ -637,8 +729,13 @@ if ( $curuser->access_right('Configuration') ) {
   }
 
   $config_billing{'separator4'} = ''; #its a separator!
-  $config_billing{'Credit reasons'}  = [ $fsurl.'browse/reason.html?class=R', 'Credit reasons explain why a credit was issued.' ];
-  $config_billing{'Credit reason types'}  = [ $fsurl.'browse/reason_type.html?class=R', 'Credit reason types define groups of reasons.' ];
+  $config_billing{'Credit reasons'}  = [ $fsurl.'browse/reason_type.html?class=R', 'Credit reasons explain why a credit was issued.' ];
+  
+  $config_billing{'Refund reasons'}  = [ $fsurl.'browse/reason_type.html?class=F', 'Refund reasons explain why a refund was issued.' ];
+
+  $config_billing{'Invoice void reasons'}  = [ $fsurl.'browse/reason_type.html?class=I', 'Invoice void reasons explain why an invoice was voided.' ];
+  $config_billing{'Payment void reasons'}  = [ $fsurl.'browse/reason_type.html?class=P', 'Payment void reasons explain why a payment was voided.' ];
+  $config_billing{'Credit void reasons'}  = [ $fsurl.'browse/reason_type.html?class=X', 'Credit void reasons explain why a credit was voided.' ];
 }
 
 #XXX also to be unified
@@ -687,16 +784,16 @@ tie my %config_nms, 'Tie::IxHash',
 ;
 
 tie my %config_misc, 'Tie::IxHash';
-$config_misc{'Message templates'} = [ $fsurl.'browse/msg_template.html', 'Templates for customer notices' ]
+$config_misc{'Message templates'} = [ $fsurl.'browse/msg_template/email.html', 'Templates for customer notices' ]
   if $curuser->access_right(['View templates', 'View global templates',
                              'Edit templates', 'Edit global templates', ]);
 $config_misc{'Advertising sources'} = [ $fsurl.'browse/part_referral.html', 'Where a customer heard about your service.' ]
   if $curuser->access_right('Edit advertising sources')
   || $curuser->access_right('Edit global advertising sources');
-if ( $curuser->access_right('Configuration') ) {
-  $config_misc{'Custom fields'} = [ $fsurl.'browse/part_virtual_field.html', 'Locally defined fields', ];
-  $config_misc{'Translation strings'} = [ $fsurl.'browse/msgcat.html', 'Translations and other customizable labels for each locale' ];
-}
+$config_misc{'Custom fields'} = [ $fsurl.'browse/part_virtual_field.html', 'Locally defined fields', ]
+  if $curuser->access_right('Edit custom fields');
+$config_misc{'Translation strings'} = [ $fsurl.'browse/msgcat.html', 'Translations and other customizable labels for each locale' ]
+  if $curuser->access_right('Configuration');
 $config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ]
   if $curuser->access_right('Edit inventory')
   || $curuser->access_right('Edit global inventory')
@@ -705,6 +802,10 @@ $config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/inventory_cla
 $config_misc{'Upload targets'} = [ $fsurl.'browse/upload_target.html', 'Billing and payment upload destinations' ]
   if $curuser->access_right('Configuration');
 
+$config_misc{'System log emails'} = [ $fsurl.'browse/log_email.html', 'Configure conditions for sending email when logging' ]
+  if $curuser->access_right('View system logs')
+  || $curuser->access_right('Configuration');
+
 tie my %config_menu, 'Tie::IxHash';
 if ( $curuser->access_right('Configuration' ) ) {
   %config_menu = (
@@ -745,8 +846,7 @@ if ( $curuser->access_right('Configuration') ) {
 }
 
 $config_menu{'Billing'} = [ \%config_billing, '' ]
-  if $curuser->access_right('Edit billing events')
-  || $curuser->access_right('Edit global billing events');
+  if keys %config_billing;
 $config_menu{'Ticketing'} = [ \%config_ticketing, '' ]
   if $conf->config('ticket_system')
   && FS::TicketSystem->access_right(\%session, 'ShowConfigTab');
@@ -754,11 +854,14 @@ $config_menu{'Network Monitoring'} = [ \%config_nms, '' ]
   if $curuser->access_right('Configure network monitoring')
   && $conf->config('network_monitoring_system') eq 'Torrus_Internal';
 
-if (   $curuser->access_right('Configuration' )
-     || $curuser->access_right('Edit advertising sources')
-     || $curuser->access_right('Edit global advertising sources')
+if ( $curuser->access_right([ 'Configuration',
+                              'View templates',
+                              'View global templates',
+                              'Edit templates',
+                              'Edit global templates',
+                           ])
    ) {
-  $config_menu{separator9} = '';
+  $config_menu{separator9} = '' if keys %config_menu;
   $config_menu{'Miscellaneous'} = [ \%config_misc, ''    ];
 }