summaryrefslogtreecommitdiff
path: root/scripts/menu.pl
blob: 3b2748a133490003713ff9de313cbcd25c7f4020 (plain)
  1. #!/usr/bin/perl
  2. # This file is copyright (C) 2007the LedgerSMB core team and licensed under
  3. # the GNU General Public License. For more information please see the included
  4. # LICENSE and COPYRIGHT files
  5. package LedgerSMB::Scripts::menu;
  6. our $VERSION = '0.1';
  7. $menufile = "menu.ini";
  8. use LedgerSMB::Menu;
  9. use LedgerSMB::Template;
  10. use strict;
  11. sub display {
  12. my ($request) = @_;
  13. my $template;
  14. if (!$request->{menubar}){
  15. $request->{main} = "splash.html" if $request->{main} eq 'company_logo';
  16. $request->{main} = "am.pl?action=recurring_transactions"
  17. if $request->{main} eq 'recurring_transactions';
  18. $template = LedgerSMB::Template->new(
  19. user =>$request->{_user},
  20. locale => $request->{_locale},
  21. path => 'UI',
  22. template => 'frameset',
  23. format => 'HTML'
  24. );
  25. } else {
  26. # TODO: Create Lynx Initial Menu
  27. }
  28. $template->render($request);
  29. }
  30. sub expanding_menu {
  31. my ($request) = @_;
  32. my $menu = new LedgerSMB::Menu({base => $request});
  33. $menu->generate();
  34. my $template = LedgerSMB::Template->new(
  35. user => $request->{_user},
  36. locale => $request->{_locale},
  37. path => 'UI',
  38. template => 'menu_expand',
  39. format => 'HTML',
  40. );
  41. $request->{subs} = [];
  42. $menu->debug({file => '/tmp/debug-menu'});
  43. $request->debug({file => '/tmp/debug'});
  44. $template->render($menu);
  45. }
  46. sub _attach_references {
  47. no strict qw(refs);
  48. my ($args) = @_;
  49. my ($source, $dest, $path)
  50. = ($args->{source}, $args->{dest}, $args->{path});
  51. my %hash;
  52. if ($path and $source->{id}){
  53. for (sort keys %$source){
  54. next if $_ eq 'subs';
  55. $hash{$_} = $source->{$_};
  56. }
  57. $hash{path} = $path;
  58. push @{$dest}, \%hash;
  59. foreach (sort keys %{$source->{subs}}) {
  60. _attach_references({
  61. source => $source->{subs}->{$_},
  62. dest => $dest,
  63. path => "$path--$_",
  64. });
  65. }
  66. } else {
  67. foreach (sort keys %$source){
  68. _attach_references({
  69. source => $source->{$_},
  70. dest => $dest,
  71. path => "$_",
  72. });
  73. }
  74. }
  75. }
  76. 1;