Will things ever be the same again?
[freeside.git] / httemplate / elements / menu.html
1 %
2 %  my( %opt ) = @_;
3 %  my $conf = new FS::Conf;
4 %  my $fsurl = $opt{'freeside_baseurl'};
5 %
6 %  my $curuser = $FS::CurrentUser::CurrentUser;
7 %
8 %  #Active tickets not assigned to a customer
9 %
10 %  tie my %report_customers_lists, 'Tie::IxHash',
11 %    'by customer number' => [ $fsurl. 'search/cust_main.cgi?browse=custnum', '' ],
12 %    'by last name' => [ $fsurl. 'search/cust_main.cgi?browse=last', '' ],
13 %    'by company name' => [ $fsurl. 'search/cust_main.cgi?browse=company', '' ],
14 %    'by active trouble tickets' => [ $fsurl. 'search/cust_main.cgi?browse=tickets', '' ],
15 %  ;
16 %
17 %  tie my %report_customers_search, 'Tie::IxHash',
18 %    'by ordering employee' => [ $fsurl. 'search/cust_main-otaker.cgi' ],
19 %  ;
20 %
21 %  tie my %report_customers, 'Tie::IxHash',
22 %    'List customers' => [ \%report_customers_lists, 'List customers' ],
23 %    'Search customers' => [ \%report_customers_search, 'Search customers' ],
24 %    'Zip code distribution' => [ $fsurl.'search/report_cust_main-zip.html', 'Zip codes by number of customers' ],
25 %  ;
26 %
27 %  tie my %report_invoices_open, 'Tie::IxHash',
28 %    'All open invoices' => [ $fsurl.'search/cust_bill.html?OPEN_date', 'All invoices with an unpaid balance' ],
29 %    '15 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN15_date', 'Invoices 15 days or older with an unpaid balance' ],
30 %    '30 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN30_date', 'Invoices 30 days or older with an unpaid balance' ],
31 %    '60 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN60_date', 'Invoices 60 days or older with an unpaid balance' ],
32 %    '90 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN90_date', 'Invoices 90 days or older with an unpaid balance' ],
33 %    '120 day open invoices' => [ $fsurl.'search/cust_bill.html?OPEN120_date', 'Invoices 120 days or older with an unpaid balance' ],
34 %  ;
35 %
36 %  tie my %report_invoices, 'Tie::IxHash',
37 %    'Open invoices' => [ \%report_invoices_open, 'Open invoices' ],
38 %    'All invoices'  => [ $fsurl. 'search/cust_bill.html?date', 'List all invoices' ],
39 %    'Advanced invoice reports' => [ $fsurl.'search/report_cust_bill.html', 'by agent, date range, etc.' ],
40 %  ;
41 %
42 %  tie my %report_services_acct, 'Tie::IxHash',
43 %    'All accounts by username' => [ $fsurl.'search/svc_acct.cgi?username', '' ],
44 %    'All accounts by UID'      => [ $fsurl.'search/svc_acct.cgi?uid', '' ],
45 %  ;
46 %  $report_services_acct{'Unlinked accounts'} = [ $fsurl.'search/svc_acct.cgi?UN_uid', 'Pre-Freeside accounts without a customer record' ]
47 %    if $curuser->access_right('View/link unlinked services');
48 %
49 %  tie my %report_services_domain, 'Tie::IxHash',
50 %    'All domains'      => [ $fsurl.'search/svc_domain.cgi?domain', '' ],
51 %  ;
52 %  $report_services_domain{'Unlinked domains'} = [ $fsurl.'search/svc_domain.cgi?UN_domain', 'Pre-Freeside domains without a customer record' ]
53 %    if $curuser->access_right('View/link unlinked services');
54 %
55 %  tie my %report_services_forward, 'Tie::IxHash',
56 %    'All mail forwards'      => [ $fsurl.'search/svc_forward.cgi?svcnum', '' ],
57 %  ;
58 %  $report_services_forward{'Unlinked mail forwards'} = [ $fsurl.'search/svc_forward.cgi?UN_svcnum', 'Pre-Freeside mail forwards without a customer record' ]
59 %    if $curuser->access_right('View/link unlinked services');
60 %
61 %  tie my %report_services_www, 'Tie::IxHash',
62 %    'All virtual hosts'     => [ $fsurl.'search/svc_www.cgi?svcnum', '' ],
63 %  ;
64 %  $report_services_www{'Unlinked virtual hosts'} = [ $fsurl.'search/svc_www.cgi?UN_svcnum', 'Pre-Freeside virtual hosts without a customer record' ]
65 %    if $curuser->access_right('View/link unlinked services');
66 %
67 %  tie my %report_services_broadband, 'Tie::IxHash',
68 %    'All broadband services' => [ $fsurl.'search/svc_broadband.cgi?svcnum', '' ],
69 %    #'Unlinked domain' => [ $fsurl.'search/svc_acct.cgi?UN_uid', 'Pre-Freeside domains without a customer record' ],
70 %  ;
71 %
72 %  tie my %report_services_phone, 'Tie::IxHash',
73 %    'All phone numbers' => [ $fsurl.'search/svc_phone.cgi?svcnum', '' ],
74 %  ;
75 %
76 %  tie my %report_services_external, 'Tie::IxHash',
77 %    'All external services' => [ $fsurl.'search/svc_external.cgi?id', '' ],
78 %  ;
79 %  $report_services_external{'Unlinked external services'} = [ $fsurl.'search/svc_external.cgi?UN_id', 'Pre-Freeside domains without a customer record' ]
80 %    if $curuser->access_right('View/link unlinked services');
81 %
82 %  tie my %report_services, 'Tie::IxHash';
83 %  if ( $curuser->access_right('Configuration') ) {
84 %    $report_services{'Service definitions'} =  [ $fsurl.'browse/part_svc.cgi?orderby=active', 'Service definitions by number of active packages' ];
85 %    $report_services{'separator'} =  '';
86 %  }
87 %  $report_services{'Accounts'} =  [ \%report_services_acct, 'Access accounts and mailboxes' ];
88 %  $report_services{'Domains'} =  [ \%report_services_domain, 'Domains', ];
89 %  $report_services{'Mail forwards'} =  [ \%report_services_forward, 'Mail forwards', ];
90 %  $report_services{'Virtual hosts'} =  [ \%report_services_www, 'Virtual hosting', ];
91 %  $report_services{'Broadband services'} =  [ \%report_services_broadband, 'Fixed (username-less) broadband services', ];
92 %  $report_services{'Phone numbers'} =  [ \%report_services_phone, 'Telephone numbers', ];
93 %  $report_services{'External services'} =  [ \%report_services_external, 'External services', ];
94 %
95 %  tie my %report_packages, 'Tie::IxHash';
96 %  if ( $curuser->access_right('Configuration') ) {
97 %    $report_packages{'Package definitions'} =  [ $fsurl.'browse/part_pkg.cgi?active=1', 'Package definitions by number of active packages' ];
98 %    $report_packages{'separator'} =  '';
99 %  }
100 %  $report_packages{'All customer packages'} =  [ $fsurl.'search/cust_pkg.cgi?pkgnum', 'List all customer packages', ];
101 %  $report_packages{'Suspended customer packages'} =  [ $fsurl.'search/cust_pkg.cgi?magic=suspended', 'List suspended packages' ];
102 %  $report_packages{'Customer packages with unconfigured services'} =  [ $fsurl.'search/cust_pkg.cgi?APKG_pkgnum', 'List packages which have provisionable services' ];
103 %  $report_packages{'Advanced package reports'} =  [ $fsurl.'search/report_cust_pkg.html', 'by agent, date range, status, package definition' ];
104 %
105 %  tie my %report_rating, 'Tie::IxHash',
106 %    'Call Detail Records (CDRs)' => [ $fsurl.'search/report_cdr.html', '' ],
107 %  ;
108 %
109 %  tie my %report_financial, 'Tie::IxHash', 
110 %    'Sales, Credits and Receipts' => [ $fsurl.'graph/report_money_time.html', 'Sales, credits and receipts summary graph' ],
111 %    'Sales Report' => [ $fsurl.'graph/report_cust_bill_pkg.html', 'Sales report and graph (by agent, package class and/or date range)' ],
112 %    'Credit Report' => [ $fsurl.'search/report_cust_credit.html', 'Credit report (by employee and/or date range)' ],
113 %    'Payment Report' => [ $fsurl.'search/report_cust_pay.html', 'Credit report (by type and/or date range)' ],
114 %    'A/R Aging' => [ $fsurl.'search/report_receivables.html', 'Accounts Receivable Aging report' ],
115 %    'Prepaid Income' => [ $fsurl.'search/report_prepaid_income.html', 'Prepaid income (unearned revenue)  report' ],
116 %    'Sales Tax Liability' => [ $fsurl.'search/report_tax.html', 'Sales tax liability report' ],
117 %  ;
118 %
119 %  tie my %report_menu, 'Tie::IxHash';
120 %  $report_menu{'Customers'}   = [ \%report_customers, 'Customer reports'  ]
121 %    if $curuser->access_right('List customers');
122 %  $report_menu{'Invoices'}    =  [ \%report_invoices,  'Invoice reports'   ]
123 %    if $curuser->access_right('List invoices');
124 %  $report_menu{'Packages'}    =  [ \%report_packages,  'Package reports'   ]
125 %    if $curuser->access_right('List packages');
126 %  $report_menu{'Services'}    =  [ \%report_services,  'Services reports'  ]
127 %    if $curuser->access_right('List services');
128 %  $report_menu{'Rating data'} =  [ \%report_rating,    'Rating reports'  ]
129 %    if $curuser->access_right('List rating data');
130 %  $report_menu{'Financial'}  = [ \%report_financial, 'Financial reports' ]
131 %    if $curuser->access_right('Financial reports');
132 %
133 %  tie my %tools_importing, 'Tie::IxHash',
134 %    'Import customers from CSV file' => [ $fsurl.'misc/cust_main-import.cgi', '' ],
135 %    'Import one-time charges from CSV file' => [ $fsurl.'misc/cust_main-import_charges.cgi', '' ],
136 %    'Import Call Detail Records (CDRs) from CSV file' => [ $fsurl.'misc/cdr-import.html', '' ],
137 %  ;
138 %
139 %  tie my %tools_exporting, 'Tie::IxHash',
140 %    'Download database dump' => [ $fsurl. 'misc/dump.cgi', '' ],
141 %  ;
142 %  
143 %  #    <!-- <BR>View active NAS ports: 
144 %  #      <A HREF="browse/nas.cgi">session server</A> -->
145 %  #      <!-- or <A HREF="browse/nas-sqlradius.cgi">RADIUS</A>
146 %  #    <BR> -->
147 %
148 %  tie my %tools_menu, 'Tie::IxHash', ();
149 %  $tools_menu{'Quick payment entry'} =  [ $fsurl.'misc/batch-cust_pay.html', 'Enter multiple payments in a batch' ]
150 %    if $curuser->access_right('Post payment batch');
151 %  $tools_menu{'Job Queue'} =  [ $fsurl.'search/queue.html', 'View pending job queue' ]
152 %    if $curuser->access_right('Job queue');
153 %  $tools_menu{'Importing'} =  [ \%tools_importing, 'Import tools' ]
154 %    if $curuser->access_right('Import');
155 %  $tools_menu{'Exporting'} =  [ \%tools_exporting, 'Export tools' ]
156 %    if $curuser->access_right('Export');
157 %
158 %  tie my %config_employees, 'Tie::IxHash',
159 %    'View/Edit employees' => [ $fsurl.'browse/access_user.html', 'Setup internal users' ],
160 %    'View/Edit employee groups' => [ $fsurl.'browse/access_group.html', 'Employee groups allow you to control access to the backend' ],
161 %  ;
162 %
163 %  tie my %config_export_svc_pkg, 'Tie::IxHash',
164 %    'View/Edit exports'             => [ $fsurl.'browse/part_export.cgi', 'Provisioning services to external machines, databases and APIs' ],
165 %    'View/Edit service definitions' => [ $fsurl.'browse/part_svc.cgi', 'Services are items you offer to your customers' ],
166 %    'View/Edit package definitions' => [ $fsurl.'browse/part_pkg.cgi', 'One or more services are grouped together into a package and given pricing information. Customers purchase packages, not services' ],
167 %    'View/Edit package classes'     => [ $fsurl.'browse/pkg_class.html', 'Package classes define groups of packages, for reporting and convenience purposes.' ],
168 %  ;
169 %
170 %  tie my %config_agent, 'Tie::IxHash',
171 %    'View/Edit agent types' => [ $fsurl.'browse/agent_type.cgi', 'Agent types define groups of package definitions that you can then assign to particular agents' ],
172 %    'View/Edit 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)' ],
173 %  ;
174 %
175 %  tie my %config_billing, 'Tie::IxHash',
176 %    'View/Edit payment gateways'         => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors' ],
177 %    'View/Edit invoice events'           => [ $fsurl.'browse/part_bill_event.cgi', 'Actions for overdue invoices' ],
178 %    'View/Edit prepaid cards'            => [ $fsurl.'search/prepay_credit.html', 'View outstanding cards, generate new cards' ],
179 %    'View/Edit call rates and regions'   => [ $fsurl.'browse/rate.cgi', 'Manage rate plans, regions and prefixes for VoIP and call billing' ],
180 %    'View/Edit locales and tax rates'    => [ $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' ],
181 %  ;
182 %
183 %  tie my %config_dialup, 'Tie::IxHash',
184 %    'View/Edit access numbers' => [ $fsurl.'browse/svc_acct_pop.cgi', 'Points of Presence' ],
185 %  ;
186 %
187 %  tie my %config_broadband, 'Tie::IxHash',
188 %    'View/Edit routers'        => [ $fsurl.'browse/router.cgi', 'Broadband access routers' ],
189 %    'View/Edit address blocks' => [ $fsurl.'browse/addr_block.cgi', 'Manage address blocks and block assignments to broadband routers' ],
190 %  ;
191 %
192 %  tie my %config_misc, 'Tie::IxHash';
193 %  $config_misc{'View/Edit advertising sources'} = [ $fsurl.'browse/part_referral.html', 'Where a customer heard about your service.  Tracked for informational purposes' ]
194 %    if $curuser->access_right('Configuration')
195 %    || $curuser->access_right('Edit advertising sources')
196 %    || $curuser->access_right('Edit global advertising sources');
197 %  if ( $curuser->access_right('Configuration') ) {
198 %    $config_misc{'View/Edit virtual fields'} = [ $fsurl.'browse/part_virtual_field.cgi', 'Locally defined fields', ];
199 %    $config_misc{'View/Edit message catalog'} = [ $fsurl.'browse/msgcat.cgi', 'Change error messages and other customizable labels' ];
200 %    $config_misc{'View/Edit inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ];
201 %  }
202 %
203 %  tie my %config_menu, 'Tie::IxHash';
204 %  if ( $curuser->access_right('Configuration' ) ) {
205 %    %config_menu = (
206 %      'Settings'      => [ $fsurl.'config/config-view.cgi', '' ],
207 %      'separator'     => '', #its a separator!
208 %      'Employees'     => [ \%config_employees, '' ],
209 %      'Provisioning, services and packages'
210 %                      => [ \%config_export_svc_pkg, ''    ],
211 %      'Resellers'     => [ \%config_agent, ''    ],
212 %      'Billing'       => [ \%config_billing, ''    ],
213 %      'Dialup'        => [ \%config_dialup, ''    ],
214 %      'Fixed (username-less) broadband'
215 %                      => [ \%config_broadband, ''    ],
216 %    );
217 %  }
218 %  $config_menu{'Miscellaneous'} = [ \%config_misc, ''    ]
219 %    if $curuser->access_right('Configuration')
220 %    || $curuser->access_right('Edit advertising sources')
221 %    || $curuser->access_right('Edit global advertising sources');
222 %
223 %  tie my %menu, 'Tie::IxHash',
224 %    'Billing Main'   => [ $fsurl, 'Billing start page', ],
225 %    'Ticketing Main' => [ 
226 %                          ( $conf->config('ticket_system') eq 'RT_External'
227 %                            ? FS::TicketSystem->baseurl()
228 %                            : $fsurl.'rt/'
229 %                          ),
230 %                          'Ticketing start page',
231 %                        ],
232 %  ;
233 %  $menu{'Reports'} = [ \%report_menu, 'Lists, reporting and graphing' ]
234 %    if keys %report_menu;
235 %  $menu{'Tools'} = [ \%tools_menu, 'Tools' ]
236 %    if keys %tools_menu;
237 %  $menu{'Configuration'} = [ \%config_menu, 'Configuraiton and setup' ]
238 %    if $curuser->access_right('Configuration')
239 %    || $curuser->access_right('Edit advertising sources')
240 %    || $curuser->access_right('Edit global advertising sources');
241 %
242 %  use vars qw($gmenunum);
243 %  $gmenunum = 0;
244 %
245 %  sub submenu {
246 %    my($submenu, $title) = @_;
247 %    my $menunum = $gmenunum++;
248 %
249 %    #return two args: html, menuname
250 %
251 %    "var myMenu$menunum = new WebFXMenu;\n".
252 %    #"myMenu$menunum.useAutoPosition = true;\n".
253 %    "myMenu$menunum.emptyText = '$title';\n".
254 %
255 %    (
256 %      join("\n", map {
257 %
258 %        if ( !ref( $submenu->{$_} ) ) {
259 %
260 %          "myMenu$menunum.add(new WebFXMenuSeparator());";
261 %
262 %        } else {
263 %
264 %          my($url_or_submenu, $tooltip ) = @{ $submenu->{$_} };
265 %          if ( ref($url_or_submenu) ) {
266 %
267 %            my($subhtml, $submenuname ) = submenu($url_or_submenu, $_); #mmm, recursion
268 %
269 %            "$subhtml\n".
270 %            "myMenu$menunum.add(new WebFXMenuItem(\"$_\", null, \"$tooltip\", $submenuname ));";
271 %
272 %          } else {
273 %
274 %            "myMenu$menunum.add(new WebFXMenuItem(\"$_\", \"$url_or_submenu\", \"$tooltip\" ));";
275 %
276 %          }
277 %
278 %        }
279 %
280 %      } keys %$submenu )
281 %    ). "\n".
282 %    "myMenu$menunum.width = 224\n",
283 %
284 %    "myMenu$menunum";
285 %
286 %  }
287 %
288 %
289
290
291 <script type="text/javascript" src="<%$fsurl%>elements/cssexpr.js"></script>
292 <script type="text/javascript" src="<%$fsurl%>elements/xmenu.js"></script>
293 <link href="<%$fsurl%>elements/xmenu.css" type="text/css" rel="stylesheet">
294 <link href="<%$fsurl%>elements/freeside.css" type="text/css" rel="stylesheet">
295
296 <SCRIPT TYPE="text/javascript">
297
298   webfxMenuImagePath      = "<%$fsurl%>images/";
299   webfxMenuUseHover       = 1;
300   webfxMenuShowTime       = 300;
301   webfxMenuHideTime       = 300;
302
303   var myBar = new WebFXMenuBar;
304 % foreach my $item ( keys %menu ) {
305 %
306 %       my( $url_or_submenu, $tooltip ) = @{ $menu{$item} };
307 %
308 %       if ( ref($url_or_submenu) ) {
309 %
310 %         #warn $item;
311 %
312 %         my( $subhtml, $submenuname ) = submenu($url_or_submenu, $item);
313 %
314 %  
315
316
317          <% $subhtml %>
318          myBar.add(new WebFXMenuButton("<% $item %>", null, "<% $tooltip %>", <% $submenuname %> ));
319 %   } else { 
320
321     
322          myBar.add(new WebFXMenuButton("<% $item %>", "<% $url_or_submenu %>", "<% $tooltip %>" ));
323 %   }
324 %
325 %    }
326 %  
327
328
329   myBar.show( null, 'vertical' );
330   //myBar.show( null, 'horizontal' );
331
332   //var myMenu = new WebFXMenu;
333   //myMenu.add(new WebFXMenuItem("Menu Item 1", "http://www.domain.com", "Tool tip to show"));
334   //myMenu.add(new WebFXMenuSeparator());
335   //myMenu.add(new WebFXMenuItem("Menu Item 2", "http://www.domain.com", "Tool tip to show"));
336   
337   //var mySubMenu = new WebFXMenu;
338   //mySubMenu.add(new WebFXMenuItem("Menu Item 3", "http://www.domain.com", "Tool tip to show"));
339   //myMenu.add(new WebFXMenuItem("Menu Item 4 with sub menu", null, "Tool tip to show", mySubMenu));
340
341   myBar.width = 154;
342
343 </SCRIPT>