Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c904f865

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID c904f865b0f9d1da094f2ca5198796829277d8e4
  • Vorgänger f4800c43
  • Nachfolger 6d6c50b4

SL/Printer.pm wird nicht mehr benötigt

Unterschiede anzeigen:

SL/Printer.pm
1
package SL::Printer;
2

  
3
use strict;
4

  
5
use SL::DBUtils;
6

  
7
sub all_printers {
8
  $::lxdebug->enter_sub;
9

  
10
  my ($self, %params) = @_;
11

  
12
  my $dbh = $::auth->get_user_dbh($params{login});
13

  
14
  my $query = qq|SELECT * FROM printers ORDER BY printer_description|;
15
  my @printers = selectall_hashref_query($::form, $dbh, $query);
16

  
17
  $dbh->disconnect;
18

  
19
  $::lxdebug->leave_sub;
20

  
21
  return wantarray ? @printers : \@printers;
22
}
23

  
24
sub get_printer {
25
  $::lxdebug->enter_sub;
26

  
27
  my ($self, %params) = @_;
28

  
29
  my $dbh = $::auth->get_user_dbh($params{login});
30

  
31
  my $query = qq|SELECT * FROM printers WHERE id = ?|;
32
  my ($printer) = selectfirst_hashref_query($::form, $dbh, $query, $params{id});
33

  
34
  $dbh->disconnect;
35

  
36
  $::lxdebug->leave_sub;
37

  
38
  return $printer;
39
}
40

  
41
sub save_printer {
42
  $main::lxdebug->enter_sub();
43

  
44
  my ($self, %params) = @_;
45

  
46
  # connect to database
47
  my $dbh = $::auth->get_user_dbh($params{login});
48
  my $printer = $params{printer};
49

  
50
  unless ($printer->{id}) {
51
    ($printer->{id}) = selectfirst_array_query($::form, $dbh, "SELECT nextval('id'::text)");
52
    do_query($::form, $dbh, "INSERT INTO printers (id, printer_description) VALUES (?, '')", $printer->{id});
53
  }
54

  
55
  my $query = <<SQL;
56
    UPDATE printers SET
57
      printer_description = ?,
58
      template_code = ?,
59
      printer_command = ?
60
    WHERE id = ?
61
SQL
62
  do_query($::form, $dbh, $query,
63
    $printer->{printer_description},
64
    $printer->{template_code},
65
    $printer->{printer_command},
66
    $printer->{id},
67
  );
68

  
69
  $dbh->commit;
70
  $dbh->disconnect;
71

  
72
  $::lxdebug->leave_sub;
73
}
74

  
75
sub delete_printer {
76
  $::lxdebug->enter_sub;
77

  
78
  my ($self, %params) = @_;
79

  
80
  my $dbh = $::auth->get_user_dbh($params{login});
81

  
82
  my $query = qq|DELETE FROM printers WHERE id = ?|;
83
  do_query($::form, $dbh, $query, $params{id});
84

  
85
  $dbh->commit;
86
  $dbh->disconnect;
87

  
88
  $::lxdebug->leave_sub;
89
}
90

  
91
1;
bin/mozilla/am.pl
42 42
use SL::USTVA;
43 43
use SL::Iconv;
44 44
use SL::TODO;
45
use SL::Printer;
45
use SL::DB::Printer;
46 46
use CGI;
47 47

  
48 48
require "bin/mozilla/common.pl";
......
1059 1059
    { 'name' => $locale->text('Queue'),   'value' => 'queue',   'selected' => $selected{queue}, },
1060 1060
    ];
1061 1061

  
1062
  $form->{PRINTERS} = [ SL::Printer->all_printers(%::myconfig) ];
1062
  $form->{PRINTERS} = SL::DB::Manager::Printer->get_all_sorted;
1063 1063

  
1064 1064
  my %countrycodes = User->country_codes;
1065 1065

  

Auch abrufbar als: Unified diff