Merge branch 'master' of ssh://lx-office/~/lx-office-erp
authorHolger Lindemann <hli@lx-system.de>
Wed, 29 Sep 2010 12:12:22 +0000 (14:12 +0200)
committerHolger Lindemann <hli@lx-system.de>
Wed, 29 Sep 2010 12:12:22 +0000 (14:12 +0200)
18 files changed:
SL/AM.pm
SL/Auth.pm
SL/Form.pm
SL/Printer.pm [new file with mode: 0644]
SL/Template/LaTeX.pm
bin/mozilla/admin.pl
bin/mozilla/admin_printer.pl [new file with mode: 0644]
bin/mozilla/am.pl
bin/mozilla/kopf.pl
bin/mozilla/menu.pl
js/switchmenuframe.js
locale/de/all
menu.ini
templates/webpages/admin/list_users.html
templates/webpages/admin_printer/_login_form.html [new file with mode: 0644]
templates/webpages/admin_printer/edit.html [new file with mode: 0644]
templates/webpages/admin_printer/list.html [new file with mode: 0644]
templates/webpages/admin_printer/login.html [new file with mode: 0644]

index f5736f1..d637e2a 100644 (file)
--- a/SL/AM.pm
+++ b/SL/AM.pm
@@ -1108,106 +1108,6 @@ sub swap_sortkeys {
   $main::lxdebug->leave_sub();
 }
 
-sub printer {
-  $main::lxdebug->enter_sub();
-
-  my ($self, $myconfig, $form) = @_;
-
-  # connect to database
-  my $dbh = $form->dbconnect($myconfig);
-
-  my $query = qq|SELECT id, printer_description, template_code, printer_command
-                 FROM printers
-                 ORDER BY 2|;
-
-  my $sth = $dbh->prepare($query);
-  $sth->execute || $form->dberror($query);
-
-  $form->{"ALL"} = [];
-  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
-    push @{ $form->{ALL} }, $ref;
-  }
-
-  $sth->finish;
-  $dbh->disconnect;
-
-  $main::lxdebug->leave_sub();
-}
-
-sub get_printer {
-  $main::lxdebug->enter_sub();
-
-  my ($self, $myconfig, $form) = @_;
-
-  # connect to database
-  my $dbh = $form->dbconnect($myconfig);
-
-  my $query =
-    qq|SELECT p.printer_description, p.template_code, p.printer_command
-       FROM printers p
-       WHERE p.id = ?|;
-  my $sth = $dbh->prepare($query);
-  $sth->execute($form->{id}) || $form->dberror($query . " ($form->{id})");
-
-  my $ref = $sth->fetchrow_hashref("NAME_lc");
-
-  map { $form->{$_} = $ref->{$_} } keys %$ref;
-
-  $sth->finish;
-
-  $dbh->disconnect;
-
-  $main::lxdebug->leave_sub();
-}
-
-sub save_printer {
-  $main::lxdebug->enter_sub();
-
-  my ($self, $myconfig, $form) = @_;
-  my $query;
-
-  # connect to database
-  my $dbh = $form->dbconnect($myconfig);
-
-  my @values = ($form->{printer_description},
-                $form->{template_code},
-                $form->{printer_command});
-
-  # id is the old record
-  if ($form->{id}) {
-    $query = qq|UPDATE printers SET
-                printer_description = ?, template_code = ?, printer_command = ?
-                WHERE id = ?|;
-    push(@values, $form->{id});
-  } else {
-    $query = qq|INSERT INTO printers
-                (printer_description, template_code, printer_command)
-                VALUES (?, ?, ?)|;
-  }
-  do_query($form, $dbh, $query, @values);
-
-  $dbh->disconnect;
-
-  $main::lxdebug->leave_sub();
-}
-
-sub delete_printer {
-  $main::lxdebug->enter_sub();
-
-  my ($self, $myconfig, $form) = @_;
-
-  # connect to database
-  my $dbh = $form->dbconnect($myconfig);
-
-  my $query = qq|DELETE FROM printers
-              WHERE id = ?|;
-  do_query($form, $dbh, $query, $form->{id});
-
-  $dbh->disconnect;
-
-  $main::lxdebug->leave_sub();
-}
-
 sub payment {
   $main::lxdebug->enter_sub();
 
index bf2a6a8..eb5a780 100644 (file)
@@ -33,6 +33,26 @@ sub new {
   return $self;
 }
 
+sub get_user_dbh {
+  my ($self, $login) = @_;
+  my %user = $self->read_user($login);
+  my $dbh  = DBI->connect(
+    $user{dbconnect},
+    $user{dbuser},
+    $user{dbpasswd},
+    {
+      pg_enable_utf8 => $::locale->is_utf8,
+      AutoCommit     => 0
+    }
+  ) or $::form->dberror;
+
+  if ($user{dboptions}) {
+    $dbh->do($user{dboptions}) or $::form->dberror($user{dboptions});
+  }
+
+  return $dbh;
+}
+
 sub DESTROY {
   my $self = shift;
 
index 2647cec..fad6e8e 100644 (file)
@@ -268,7 +268,7 @@ sub new {
   #$self->{version} =  "2.6.1";                 # Old hardcoded but secure style
   open VERSION_FILE, "VERSION";                 # New but flexible code reads version from VERSION-file
   $self->{version} =  <VERSION_FILE>;
-  close VERSION_FILE;                                                  
+  close VERSION_FILE;
   $self->{version}  =~ s/[^0-9A-Za-z\.\_\-]//g; # only allow numbers, letters, points, underscores and dashes. Prevents injecting of malicious code.
 
   $main::lxdebug->leave_sub();
@@ -475,7 +475,7 @@ sub info {
 
     print qq|
     <p class="message_ok"><b>$msg</b></p>
-    
+
     <script type="text/javascript">
     <!--
     // If JavaScript is enabled, the whole thing will be reloaded.
@@ -484,7 +484,7 @@ sub info {
     setTimeout("top.frames.location.href='login.pl'",500);
     //-->
     </script>
-    
+
 </body>
     |;
 
@@ -672,9 +672,9 @@ sub header {
     </script>
     | if $self->{"fokus"};
 
-  # if there is a title, we put some JavaScript in to the page, wich writes a 
+  # if there is a title, we put some JavaScript in to the page, wich writes a
   # meaningful title-tag for our frameset.
-    my $title_hack;          
+    my $title_hack;
     if ($self->{"title"}){
                $title_hack = qq|
                <script type="text/javascript">
@@ -685,7 +685,7 @@ sub header {
                </script>
                |;
        }
-    
+
     #Set Calendar
     my $jsscript = "";
     if ($self->{jsscript} == 1) {
@@ -723,7 +723,7 @@ sub header {
   $ajax
   $fokus
   $title_hack
-  
+
   <link rel="stylesheet" href="css/jquery.autocomplete.css" type="text/css" />
 
   <meta name="robots" content="noindex,nofollow" />
diff --git a/SL/Printer.pm b/SL/Printer.pm
new file mode 100644 (file)
index 0000000..346d734
--- /dev/null
@@ -0,0 +1,83 @@
+package SL::Printer;
+
+use SL::DBUtils;
+
+sub all_printers {
+  $::lxdebug->enter_sub;
+
+  my ($self, %params) = @_;
+
+  my $dbh = $::auth->get_user_dbh($params{login});
+
+  my $query = qq|SELECT * FROM printers ORDER BY printer_description|;
+  my @printers = selectall_hashref_query($::form, $dbh, $query);
+
+  $::lxdebug->leave_sub;
+
+  return wantarray ? @printers : \@printers;
+}
+
+sub get_printer {
+  $::lxdebug->enter_sub;
+
+  my ($self, %params) = @_;
+
+  my $dbh = $::auth->get_user_dbh($params{login});
+
+  my $query = qq|SELECT * FROM printers WHERE id = ?|;
+  my ($printer) = selectfirst_hashref_query($::form, $dbh, $query, $params{id});
+
+  $::lxdebug->leave_sub;
+
+  return $printer;
+}
+
+sub save_printer {
+  $main::lxdebug->enter_sub();
+
+  my ($self, %params) = @_;
+
+  # connect to database
+  my $dbh = $::auth->get_user_dbh($params{login});
+  my $printer = $params{printer};
+
+  unless ($printer->{id}) {
+    ($printer->{id}) = selectfirst_array_query($::form, $dbh, "SELECT nextval('id'::text)");
+    do_query($::form, $dbh, "INSERT INTO printers (id, printer_description) VALUES (?, '')", $printer->{id});
+  }
+
+  my $query = <<SQL;
+    UPDATE printers SET
+      printer_description = ?,
+      template_code = ?,
+      printer_command = ?
+    WHERE id = ?
+SQL
+  do_query($::form, $dbh, $query,
+    $printer->{printer_description},
+    $printer->{template_code},
+    $printer->{printer_command},
+    $printer->{id},
+  );
+
+  $dbh->commit;
+
+  $::lxdebug->leave_sub;
+}
+
+sub delete_printer {
+  $::lxdebug->enter_sub;
+
+  my ($self, %params) = @_;
+
+  my $dbh = $::auth->get_user_dbh($params{login});
+
+  my $query = qq|DELETE FROM printers WHERE id = ?|;
+  do_query($::form, $dbh, $query, $params{id});
+
+  $dbh->commit;
+
+  $::lxdebug->leave_sub;
+}
+
+1;
index 4377b6d..c515187 100644 (file)
@@ -320,6 +320,7 @@ sub parse {
     $self->{"error"} = "$!";
     return 0;
   }
+  binmode IN, ":utf8" if $::locale->is_utf8;
   my @lines = <IN>;
   close(IN);
 
@@ -346,6 +347,7 @@ sub parse {
     return 0;
   }
 
+  binmode OUT, ":utf8" if $::locale->is_utf8;
   print(OUT $new_contents);
 
   if ($form->{"format"} =~ /postscript/i) {
index ebf01c6..3a5e810 100755 (executable)
@@ -52,6 +52,7 @@ use SL::DBUtils;
 
 require "bin/mozilla/common.pl";
 require "bin/mozilla/admin_groups.pl";
+require "bin/mozilla/admin_printer.pl";
 
 use strict;
 
diff --git a/bin/mozilla/admin_printer.pl b/bin/mozilla/admin_printer.pl
new file mode 100644 (file)
index 0000000..bc62332
--- /dev/null
@@ -0,0 +1,118 @@
+use strict;
+
+use SL::Printer;
+
+sub get_login {
+  unless ($::form->{login}) {
+    get_login_form();
+    ::end_of_request();
+  }
+  return $::form->{login};
+}
+
+sub get_login_form {
+  my %users = $::auth->read_all_users;
+
+  $::form->header;
+  print $::form->parse_html_template('admin_printer/login', {
+    users => [ values %users ],
+  });
+}
+
+sub printer_dispatcher {
+      $::lxdebug->dump(0,  "testing", $::form);
+  for (qw(get_login_form list_printers add_printer edit_printer save_printer delete_printer list_users)) {
+    if ($::form->{$_}) {
+      ::call_sub($::locale->findsub($_));
+      ::end_of_request()
+    }
+  }
+  die "cannot find sub";
+}
+
+sub printer_management {
+  &list_printers;
+}
+
+sub add_printer {
+  $::lxdebug->enter_sub;
+
+  my $login   = get_login();
+  my %users   = $::auth->read_all_users;
+
+  $::form->header;
+  print $::form->parse_html_template('admin_printer/edit', {
+    title   => $::locale->text("Add Printer"),
+    printer => { },
+    users   => [ values %users ],
+  });
+
+  $::lxdebug->leave_sub
+}
+
+sub edit_printer {
+  $::lxdebug->enter_sub;
+
+  my $login = get_login();
+  my $id    = $::form->{id} or $::form->{printer}{id} or &add_printer;
+  my %users   = $::auth->read_all_users;
+
+  my $printer = SL::Printer->get_printer(id => $id, login => $login);
+
+  $::form->header;
+  print $::form->parse_html_template('admin_printer/edit', {
+    title   => $::locale->text("Edit Printer"),
+    printer => $printer,
+    users   => [ values %users ],
+  });
+
+  $::lxdebug->leave_sub;
+}
+
+sub list_printers {
+  $::lxdebug->enter_sub;
+
+  my $login    = get_login();
+  my $printers = SL::Printer->all_printers(login => $login);
+  my %users   = $::auth->read_all_users;
+
+  $::form->header;
+  print $::form->parse_html_template('admin_printer/list', {
+    title        => $::locale->text('Printer'),
+    all_printers => $printers,
+    edit_link    => build_std_url("login=$login", 'action=edit_printer', 'id='),
+    users        => [ values %users ],
+  });
+
+  $::lxdebug->leave_sub;
+}
+
+
+sub save_printer {
+  $::lxdebug->enter_sub;
+
+  my $login   = get_login();
+  my $printer = $::form->{printer} || die 'no printer to save';
+
+  $::form->error($::locale->text('Description missing!'))     unless $printer->{printer_description};
+  $::form->error($::locale->text('Printer Command missing!')) unless $printer->{printer_command};
+
+  SL::Printer->save_printer(%$::form);
+
+  list_printers();
+  $::lxdebug->leave_sub;
+}
+
+sub delete_printer {
+  $::lxdebug->enter_sub;
+
+  my $login   = get_login();
+  my $printer = $::form->{printer} || die 'no printer to delete';
+
+  SL::Printer->delete_printer(%$::form);
+  list_printers();
+
+  $::lxdebug->leave_sub;
+}
+
+1;
index 4a78402..d9d4842 100644 (file)
@@ -2014,234 +2014,6 @@ sub swap_buchungsgruppen {
   $main::lxdebug->leave_sub();
 }
 
-
-sub add_printer {
-  $main::lxdebug->enter_sub();
-
-  my $form     = $main::form;
-
-  $main::auth->assert('config');
-
-  $form->{title} = "Add";
-
-  $form->{callback} = "am.pl?action=add_printer" unless $form->{callback};
-
-  &printer_header;
-  &form_footer;
-
-  $main::lxdebug->leave_sub();
-}
-
-sub edit_printer {
-  $main::lxdebug->enter_sub();
-
-  my $form     = $main::form;
-  my %myconfig = %main::myconfig;
-
-  $main::auth->assert('config');
-
-  $form->{title} = "Edit";
-
-  AM->get_printer(\%myconfig, \%$form);
-
-  &printer_header;
-
-  $form->{orphaned} = 1;
-  &form_footer;
-
-  $main::lxdebug->leave_sub();
-}
-
-sub list_printer {
-  $main::lxdebug->enter_sub();
-
-  my $form     = $main::form;
-  my %myconfig = %main::myconfig;
-  my $locale   = $main::locale;
-
-  $main::auth->assert('config');
-
-  AM->printer(\%myconfig, \%$form);
-
-  $form->{callback} = "am.pl?action=list_printer";
-
-  my $callback = $form->escape($form->{callback});
-
-  $form->{title} = $locale->text('Printer');
-
-  my @column_index = qw(printer_description printer_command template_code);
-  my %column_header;
-  $column_header{printer_description} =
-      qq|<th class=listheading width=60%>|
-    . $locale->text('Printer Description')
-    . qq|</th>|;
-  $column_header{printer_command} =
-      qq|<th class=listheading width=10%>|
-    . $locale->text('Printer Command')
-    . qq|</th>|;
-  $column_header{template_code} =
-      qq|<th class=listheading>|
-    . $locale->text('Template Code')
-    . qq|</th>|;
-
-  $form->header;
-
-  print qq|
-<body>
-
-<table width=100%>
-  <tr>
-    <th class=listtop>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr>
-    <td>
-      <table width=100%>
-        <tr class=listheading>
-|;
-
-  map { print "$column_header{$_}\n" } @column_index;
-
-  print qq|
-        </tr>
-|;
-
-  my ($i, %column_data);
-  foreach my $ref (@{ $form->{ALL} }) {
-
-    $i++;
-    $i %= 2;
-
-    print qq|
-        <tr valign=top class=listrow$i>
-|;
-
-
-    $column_data{printer_description} = qq|<td><a href="am.pl?action=edit_printer&id=$ref->{id}&callback=$callback">$ref->{printer_description}</td>|;
-    $column_data{printer_command}           = qq|<td align=right>$ref->{printer_command}</td>|;
-    $column_data{template_code} =
-      qq|<td align=right>$ref->{template_code}</td>|;
-
-    map { print "$column_data{$_}\n" } @column_index;
-
-    print qq|
-        </tr>
-|;
-  }
-
-  print qq|
-      </table>
-    </td>
-  </tr>
-  <tr>
-  <td><hr size=3 noshade></td>
-  </tr>
-</table>
-
-<br>
-<form method=post action=am.pl>
-
-<input name=callback type=hidden value="$form->{callback}">
-
-<input type=hidden name=type value=printer>
-
-<input class=submit type=submit name=action value="|
-    . $locale->text('Add') . qq|">
-
-  </form>
-
-  </body>
-  </html>
-|;
-
-  $main::lxdebug->leave_sub();
-}
-
-sub printer_header {
-  $main::lxdebug->enter_sub();
-
-  my $form     = $main::form;
-  my $locale   = $main::locale;
-
-  $main::auth->assert('config');
-
-  $form->{title}    = $locale->text("$form->{title} Printer");
-
-  # $locale->text('Add Printer')
-  # $locale->text('Edit Printer')
-
-  $form->{printer_description} =~ s/\"/&quot;/g;
-  $form->{template_code} =~ s/\"/&quot;/g;
-  $form->{printer_command} =~ s/\"/&quot;/g;
-
-
-  $form->header;
-
-  print qq|
-<body>
-
-<form method=post action=am.pl>
-
-<input type=hidden name=id value=$form->{id}>
-<input type=hidden name=type value=printer>
-
-<table width=100%>
-  <tr>
-    <th class=listtop colspan=2>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr>
-    <th align=right>| . $locale->text('Printer') . qq|</th>
-    <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
-  <tr>
-  <tr>
-    <th align=right>| . $locale->text('Printer Command') . qq|</th>
-    <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
-  </tr>
-  <tr>
-    <th align=right>| . $locale->text('Template Code') . qq|</th>
-    <td><input name=template_code size=5 value="$form->{template_code}"></td>
-  </tr>
-  <td colspan=2><hr size=3 noshade></td>
-  </tr>
-</table>
-|;
-
-  $main::lxdebug->leave_sub();
-}
-
-sub save_printer {
-  $main::lxdebug->enter_sub();
-
-  my $form     = $main::form;
-  my %myconfig = %main::myconfig;
-  my $locale   = $main::locale;
-
-  $main::auth->assert('config');
-
-  $form->isblank("printer_description", $locale->text('Description missing!'));
-  $form->isblank("printer_command", $locale->text('Printer Command missing!'));
-  AM->save_printer(\%myconfig, \%$form);
-  $form->redirect($locale->text('Printer saved!'));
-
-  $main::lxdebug->leave_sub();
-}
-
-sub delete_printer {
-  $main::lxdebug->enter_sub();
-
-  my $form     = $main::form;
-  my %myconfig = %main::myconfig;
-  my $locale   = $main::locale;
-
-  $main::auth->assert('config');
-
-  AM->delete_printer(\%myconfig, \%$form);
-  $form->redirect($locale->text('Printer deleted!'));
-
-  $main::lxdebug->leave_sub();
-}
-
 sub add_payment {
   $main::lxdebug->enter_sub();
 
@@ -2722,10 +2494,8 @@ sub config {
     { 'name' => $locale->text('Queue'),   'value' => 'queue',   'selected' => $selected{queue}, },
     ];
 
-  AM->printer(\%myconfig, $form);
-
   $form->{PRINTERS} = [];
-  foreach my $printer (@{$form->{"ALL"}}) {
+  foreach my $printer (SL::Printer->all_printers(%::myconfig)) {
     push @{ $form->{PRINTERS} }, {
       'name'     => $printer->{printer_description},
       'value'    => $printer->{id},
index ac3935d..ed11e52 100644 (file)
@@ -107,23 +107,22 @@ window.onload=clockon
 </script>
 |;
 
-#
-my $framesize = _calc_framesize(); # framesize calculation as in menu.pl is only a quick and dirty hack here
-                                   # it would be better to use a global or config variable
-
 print qq|
 <body bgcolor="#ffffff" text="#ffffff" link="#ffffff" vlink="#ffffff" alink="#ffffff" topmargin="0" leftmargin="0"  marginwidth="0" marginheight="0" style="background-image: url('image/fade.png'); background-repeat:repeat-x;">
 <script language='JavaScript' src='js/switchmenuframe.js'></script>
 <table border="0" width="100%" background="image/bg_titel.gif" cellpadding="0" cellspacing="0">
-  <tr>
-    <td  style="color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap>
-      [<a href="JavaScript:Switch_Menu(|.$framesize.qq|);" title="| . $locale->text('Switch Menu on / off') . qq|">| . $locale->text('Menu') . qq|</a>]
-      &nbsp;[<a HREF="login.pl" target="_blank" title="| . $locale->text('Open a further Lx-Office Window or Tab') . qq|">| . $locale->text('New Win/Tab') . qq|</a>]
-      &nbsp;[<a href="JavaScript:top.main_window.print();" title="| . $locale->text('Hardcopy') . qq|">| . $locale->text('Print') . qq|</a>]
-      &nbsp;[<a href="Javascript:top.main_window.history.back();" title="| . $locale->text('Go one step back') . qq|">| . $locale->text('Back') . qq|</a>]
-      &nbsp;[<a href="Javascript:top.main_window.history.forward();" title="| . $locale->text('Go one step forward') . qq|">| . $locale->text('Fwd') . qq|</a>]
-      <!-- is there any better solution for Back? Possibly with the callback variable? -->
-    </td>
+  <tr>|;
+   if ( !($ENV{HTTP_USER_AGENT} =~ /links/i) ) {    # do not show the the links in case of "links" in HTTP_USER_AGENT
+      print qq|
+       <td  style="color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap>
+       [<a href="JavaScript:Switch_Menu();" title="| . $locale->text('Switch Menu on / off') . qq|">| . $locale->text('Menu') . qq|</a>]
+       &nbsp;[<a HREF="login.pl" target="_blank" title="| . $locale->text('Open a further Lx-Office Window or Tab') . qq|">| . $locale->text('New Win/Tab') . qq|</a>]
+       &nbsp;[<a href="JavaScript:top.main_window.print();" title="| . $locale->text('Hardcopy') . qq|">| . $locale->text('Print') . qq|</a>]
+       &nbsp;[<a href="Javascript:top.main_window.history.back();" title="| . $locale->text('Go one step back') . qq|">| . $locale->text('Back') . qq|</a>]
+       &nbsp;[<a href="Javascript:top.main_window.history.forward();" title="| . $locale->text('Go one step forward') . qq|">| . $locale->text('Fwd') . qq|</a>]
+      </td>|;
+   }
+   print qq|
     <td align="right" style="vertical-align:middle; color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap>|
   . $login . $datum . qq| <script>writeclock()</script>&nbsp;
     </td>
@@ -132,17 +131,6 @@ print qq|
 </body>
 </html>
 |;
-
-sub _calc_framesize {
-  my $is_lynx_browser   = $ENV{HTTP_USER_AGENT} =~ /links/i;
-  my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
-  my $is_mobile_style   = $::form->{stylesheet} =~ /mobile/i;
-
-  return  $is_mobile_browser && $is_mobile_style ?  130
-        : $is_lynx_browser                       ?  240
-        :                                           180;
-}
-
 }
 
 1;
index 115880d..b119d7a 100644 (file)
@@ -33,7 +33,7 @@
 # CHANGE LOG:
 #   DS. 2002-03-25  Created
 #  2004-12-14 - New Optik - Marco Welter <mawe@linux-studio.de>
-#  2010-08-19 - Icons for sub entries and one click 
+#  2010-08-19 - Icons for sub entries and single click behavior, unlike XUL-Menu
 #               JS switchable HTML-menu - Sven Donath <lxo@dexo.de>
 #######################################################################
 
@@ -51,12 +51,12 @@ my $mainlevel;
 sub display {
   $main::lxdebug->enter_sub();
 
-  my $form     = $main::form;
+  my $form      = $main::form;
 
-  my $callback   = $form->unescape($form->{callback});
-  $callback      = URI->new($callback)->rel($callback) if $callback;
-  $callback      = "login.pl?action=company_logo"      if $callback =~ /^(\.\/)?$/;
-  my $framesize  = _calc_framesize();
+  my $callback  = $form->unescape($form->{callback});
+  $callback     = URI->new($callback)->rel($callback) if $callback;
+  $callback     = "login.pl?action=company_logo"      if $callback =~ /^(\.\/)?$/;
+  my $framesize = _calc_framesize();
 
   $form->header;
 
@@ -82,7 +82,7 @@ sub acc_menu {
 
   my $form      = $main::form;
   my $locale    = $main::locale;
-  my $framesize = _calc_framesize(); # how to get it into kopf.pl or vice versa?
+  my $framesize = _calc_framesize();
 
   $mainlevel = $form->{level};
   $mainlevel =~ s/\Q$mainlevel\E--//g;
@@ -94,10 +94,10 @@ sub acc_menu {
 
   print qq|
 <body class="menu">
-
-|;
+|; 
   print qq|<div align="left">\n<table width="|
-    . $framesize
+    . ($framesize-2)
     . qq|" border="0">\n|;
 
   &section_menu($menu);
@@ -115,9 +115,11 @@ sub section_menu {
   $main::lxdebug->enter_sub();
   my ($menu, $level) = @_;
 
-  my $form     = $main::form;
-  my %myconfig = %main::myconfig;
-  my $locale   = $main::locale;
+  my $form      = $main::form;
+  my %myconfig  = %main::myconfig;
+  my $locale    = $main::locale;
+  my $is_links_browser = 1;
+  if ( _calc_framesize() eq 240) { $is_links_browser = 0; }
 
   my $zeige;
 
@@ -199,18 +201,20 @@ sub section_menu {
           if ($zeige) {
             if (scalar @chunks <= 1) {
               print
-                qq|<tr><td class="hover" height="16" >$spacer| 
+                qq|<tr><td class="hover" height="16" >$spacer|
                 . $menu->menuitem(\%myconfig, \%$form, $item, $level) ;
-              
-            if (-f "image/icons/16x16/$label_icon")
-             { print 
-                qq|<img src="image/icons/16x16/$label_icon" border="0" style="vertical-align:text-top" title="| 
-                . $label 
-                . qq|">&nbsp;&nbsp;| } 
+
+            if (-f "image/icons/16x16/$label_icon" && ($is_links_browser))
+             { print
+                qq|<img src="image/icons/16x16/$label_icon" border="0" style="vertical-align:text-top" title="|
+                . $label
+                . qq|">&nbsp;&nbsp;| }
             else {
-               print qq|<img src="image/unterpunkt.png" border="0" style="vertical-align:text-top">|;   
+                   if ($is_links_browser) {
+                    print qq|<img src="image/unterpunkt.png" border="0" style="vertical-align:text-top">|;
+                   }
                 }
-                
+
                print
                  qq|$label</a></td></tr>\n|;
             } else {
@@ -231,7 +235,12 @@ sub section_menu {
       } else {
         my $ml_ = $form->escape($ml);
         print
-          qq|<tr><td class="bg" height="24" align="left" valign="middle"><a href="menu.pl?action=acc_menu&level=$ml_" class="nohover" title="$label"><img src="image/icons/24x24/$item.png" border="0" style="vertical-align:middle" title="$label">&nbsp;$label</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>\n|;
+          qq|<tr><td class="bg" height="24" align="left" valign="middle">
+          <a href="menu.pl?action=acc_menu&level=$ml_" class="nohover" title="$label">|;
+              if ($is_links_browser) {
+                  print qq|<img src="image/icons/24x24/$item.png" border="0" style="vertical-align:middle" title="$label">|;
+              }
+          print qq|&nbsp;$label</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>\n|;
         &section_menu($menu, $item);
 
         print qq|\n|;
@@ -248,7 +257,7 @@ sub _calc_framesize {
 
   return  $is_mobile_browser && $is_mobile_style ?  130
         : $is_lynx_browser                       ?  240
-        :                                           180;
+        :                                           200;
 }
 
 1;
index 0399a2e..d0bf2ac 100644 (file)
@@ -1,20 +1,20 @@
-/* This is used in bin/mozilla/kopf.pl to switch the HTML sidemenu on/off
+/* This is used in bin/mozilla/kopf.pl to switch the HTML side menu on/off
    2010, Sven Donath, lxo@dexo.de  */
 
 var vSwitch_Menu = 1;
+var FrameSize = (parent.document.getElementById('menuframe').cols);
 
-function Switch_Menu(framesize)
+function Switch_Menu()
 {
-       if (vSwitch_Menu)
-       {
-               vSwitch_Menu=false;
-                parent.document.getElementById('menuframe').setAttribute('cols','30,*')
-       }
-       else
-       {
-               vSwitch_Menu=true;
-                               framesize = framesize + ',*';
-                parent.document.getElementById('menuframe').setAttribute('cols',framesize);
+    if (vSwitch_Menu)
+    {
+        vSwitch_Menu=false;
+                parent.document.getElementById('menuframe').setAttribute('cols','30,*');
     }
-       return;
+    else
+    {
+        vSwitch_Menu=true;
+                parent.document.getElementById('menuframe').setAttribute('cols',FrameSize);
+    }
+    return;
 }
index c256452..18b6d39 100644 (file)
@@ -1206,6 +1206,7 @@ $self->{texts} = {
   'Please read the file'        => 'Bitte lesen Sie die Datei',
   'Please select a customer from the list below.' => 'Bitte einen Endkunden aus der Liste auswählen',
   'Please select a part from the list below.' => 'Bitte w&auml;hlen Sie einen Artikel aus der Liste aus.',
+  'Please select a user'        => 'Bitte wählen Sie einen Benutzer aus',
   'Please select a vendor from the list below.' => 'Bitte einen Händler aus der Liste auswählen',
   'Please select the chart of accounts this installation is using from the list below.' => 'Bitte w&auml;hlen Sie den Kontenrahmen aus, der bei dieser Installation verwendet wird.',
   'Please select the database you want to backup' => 'Bitte w&auml;hlen Sie die zu sichernde Datenbank gefunden',
@@ -1249,9 +1250,8 @@ $self->{texts} = {
   'Printer'                     => 'Drucker',
   'Printer Command'             => 'Druckbefehl',
   'Printer Command missing!'    => 'Druckbefehl fehlt',
-  'Printer Description'         => 'Druckerbeschreibung',
-  'Printer deleted!'            => 'Drucker gelöscht!',
-  'Printer saved!'              => 'Drucker gespeichert!',
+  'Printer Management'          => 'Druckeradministration',
+  'Printers are created for a user database. Please select a user. The associated database will be edited.' => 'Drucker werden für eine Benutzerdatenbank erzeugt. Bitte wählen Sie einen Benutzer aus. Die Drucker werden in der verknüpften Datenbank angelegt.',
   'Printing ... '               => 'Es wird gedruckt.',
   'Prior to Lx-Office v2.4.0 the user could enter arbitrary strings as units for parts, services and in invoices, sales quotations etc.' => 'Vor Lx-Office 2.4.0 konnte der Benutzer bei Artikeln, Dienstleistungen und Rechnungen, Angeboten etc beliebige Einheiten angeben.',
   'Prior to Lx-Office v2.4.0 the user had to chose the accounts for each part and service.' => 'Vor Lx-Office 2.4.0 musste der Benutzer die Konten bei jeder Ware und jeder Dienstleistung einzeln ausw&auml;hlen.',
index 643a4e9..310c7b5 100644 (file)
--- a/menu.ini
+++ b/menu.ini
@@ -667,20 +667,6 @@ module=generictranslations.pl
 action=edit_greetings
 
 
-[System--Printer]
-module=menu.pl
-action=acc_menu
-target=acc_menu
-submenu=1
-
-[System--Printer--Add Printer]
-module=am.pl
-action=add_printer
-
-[System--Printer--List Printer]
-module=am.pl
-action=list_printer
-
 [System--Payment Terms]
 module=menu.pl
 action=acc_menu
index 7d66002..e201190 100644 (file)
@@ -36,6 +36,7 @@
 
   <input type="submit" class="submit" name="action" value="[% 'Add User' | $T8 %]">
   <input type="submit" class="submit" name="action" value="[% 'Edit groups' | $T8 %]">
+  <input type="submit" class="submit" name="action" value="[% 'Printer Management' | $T8 %]">
   <input type="submit" class="submit" name="action" value="[% 'Pg Database Administration' | $T8 %]">
   [% IF LOCKED %]
    <input type="submit" class="submit" name="action" value="[% 'Unlock System' | $T8 %]">
diff --git a/templates/webpages/admin_printer/_login_form.html b/templates/webpages/admin_printer/_login_form.html
new file mode 100644 (file)
index 0000000..411661c
--- /dev/null
@@ -0,0 +1,4 @@
+[%- USE T8 %]
+[%- USE L %]
+<p>[% 'Please select a user' | $T8 %]: [% L.select_tag('login', L.options_for_select(users, value => 'login', title => 'login', default => login)) %]</p>
+
diff --git a/templates/webpages/admin_printer/edit.html b/templates/webpages/admin_printer/edit.html
new file mode 100644 (file)
index 0000000..d158702
--- /dev/null
@@ -0,0 +1,41 @@
+[%- USE T8 %]
+<body>
+
+<form method=post>
+
+<h1 class=listtop colspan=2>[% title %]</h1>
+
+[%- PROCESS 'admin_printer/_login_form.html' %]
+
+<input type=hidden name="printer.id" value="[% printer.id | html %]">
+<table width=100%>
+  <tr height="5"></tr>
+  <tr>
+    <th align=right>[% 'Printer' | $T8 %]</th>
+    <td><input name="printer.printer_description" size=30 value="[% printer.printer_description | html %]"></td>
+  <tr>
+  <tr>
+    <th align=right>[% 'Printer Command' | $T8 %]</th>
+    <td><input name="printer.printer_command" size=30 value="[% printer.printer_command | html %]"></td>
+  </tr>
+  <tr>
+    <th align=right>[% 'Template Code' | $T8 %]</th>
+    <td><input name="printer.template_code" size=5 value="[% printer.template_code | html %]"></td>
+  </tr>
+  <td colspan=2><hr size=3 noshade></td>
+  </tr>
+</table>
+
+<br>
+<input type=hidden name=action value="printer_dispatcher">
+<input type=submit class=submit name=save_printer value="[% 'Save' | $T8 %]">
+
+[%- IF id %]
+<input type=submit class=submit name=delete_printer value="[% 'Delete' | $T8 %]">
+[%- END %]
+<input type=submit class=submit name=list_printers value="[% 'Back' | $T8 %]">
+
+</form>
+
+</body>
+</html>
diff --git a/templates/webpages/admin_printer/list.html b/templates/webpages/admin_printer/list.html
new file mode 100644 (file)
index 0000000..6dd2361
--- /dev/null
@@ -0,0 +1,44 @@
+[%- USE T8 %]
+
+<body>
+<form method='post'>
+
+<h1 class=listtop>[% title %]</h1>
+
+[%- PROCESS 'admin_printer/_login_form.html' %]
+
+<table width=100%>
+  <tr>
+    <td>
+      <table width=100%>
+        <tr class=listheading>
+          <th>[% 'Description' | $T8 %]</th>
+          <th>[% 'Printer Command' | $T8 %]</th>
+          <th>[% 'Template Code' | $T8 %]</th>
+        </tr>
+[%- IF all_printers.size %]
+[%- FOREACH row = all_printers %]
+        <tr valign=top class="listrow[% loop.count % 2 %]">
+          <td><a href="[% edit_link %][% row.id %]">[% row.printer_description %]</a></td>
+          <td align=right>[% row.printer_command | html %]</td>
+          <td align=right>[% row.template_code | html %]</td>
+        </tr>
+[%- END %]
+[%- ELSE %]
+        <tr><td colspan='3'>[% 'No data was found.' | $T8 %]</td></tr>
+[%- END %]
+      </table>
+    </td>
+  </tr>
+  <tr>
+  <td><hr size=3 noshade></td>
+  </tr>
+</table>
+
+<br>
+ <input type="hidden" name="action" value="printer_dispatcher">
+ <input type="submit" name="add_printer" value ="[% 'Add' | $T8 %]">
+ <input type="submit" name='get_login_form' value="[% 'Back' | $T8 %]">
+</form>
+</body>
+</html>
diff --git a/templates/webpages/admin_printer/login.html b/templates/webpages/admin_printer/login.html
new file mode 100644 (file)
index 0000000..d45f1ce
--- /dev/null
@@ -0,0 +1,16 @@
+[% USE T8 %]
+[% USE L %]
+
+<h1 class=listtop>[% 'Printer Management' | $T8 %]</h1>
+<form method='post'>
+<p>[% 'Printers are created for a user database. Please select a user. The associated database will be edited.' | $T8 %]</p>
+
+[%- PROCESS 'admin_printer/_login_form.html' %]
+
+<input type='hidden' name='action' value='printer_dispatcher'>
+<p>
+<input type='submit' name='list_printers' value='[% 'Continue' | $T8 %]'>
+<input type='submit' name='list_users' value='[% 'Back' | $T8 %]'>
+</p>
+
+</form>