6 unless ($::form->{login}) {
10 return $::form->{login};
14 my %users = $::auth->read_all_users;
17 print $::form->parse_html_template('admin_printer/login', {
18 users => [ values %users ],
22 sub printer_dispatcher {
23 for my $action (qw(get_login_form list_printers add_printer edit_printer save_printer delete_printer list_users)) {
24 if ($::form->{$action}) {
25 ::call_sub($::locale->findsub($action));
29 die "cannot find sub";
32 sub printer_management {
37 $::lxdebug->enter_sub;
39 my $login = get_login();
40 my %users = $::auth->read_all_users;
43 print $::form->parse_html_template('admin_printer/edit', {
44 title => $::locale->text("Add Printer"),
46 users => [ values %users ],
53 $::lxdebug->enter_sub;
55 my $login = get_login();
56 my $id = $::form->{id} or $::form->{printer}{id} or &add_printer;
57 my %users = $::auth->read_all_users;
59 my $printer = SL::Printer->get_printer(id => $id, login => $login);
62 print $::form->parse_html_template('admin_printer/edit', {
63 title => $::locale->text("Edit Printer"),
65 users => [ values %users ],
68 $::lxdebug->leave_sub;
72 $::lxdebug->enter_sub;
74 my $login = get_login();
75 my $printers = SL::Printer->all_printers(login => $login);
76 my %users = $::auth->read_all_users;
79 print $::form->parse_html_template('admin_printer/list', {
80 title => $::locale->text('Printer'),
81 all_printers => $printers,
82 edit_link => build_std_url("login=$login", 'action=edit_printer', 'id='),
83 users => [ values %users ],
86 $::lxdebug->leave_sub;
91 $::lxdebug->enter_sub;
93 my $login = get_login();
94 my $printer = $::form->{printer} || die 'no printer to save';
96 $::form->error($::locale->text('Description missing!')) unless $printer->{printer_description};
97 $::form->error($::locale->text('Printer Command missing!')) unless $printer->{printer_command};
99 SL::Printer->save_printer(%$::form);
102 $::lxdebug->leave_sub;
106 $::lxdebug->enter_sub;
108 my $login = get_login();
109 my $printer = $::form->{printer} || die 'no printer to delete';
111 SL::Printer->delete_printer(%$::form);
114 $::lxdebug->leave_sub;