]> wagnertech.de Git - mfinanz.git/commitdiff
Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorJan Büren <jan@lx-office-hosting.de>
Thu, 17 Nov 2011 08:44:02 +0000 (09:44 +0100)
committerJan Büren <jan@lx-office-hosting.de>
Thu, 17 Nov 2011 08:44:02 +0000 (09:44 +0100)
SL/Auth.pm
bin/mozilla/io.pl
templates/webpages/io/select_item.html

index 37586b8fffd1ffc3cf0f42b9676becf9533bd0ef..7e46c125ef088c2dcfc2ae091edce64cd3bf8360 100644 (file)
@@ -525,10 +525,24 @@ sub restore_session {
 
   $form   = $main::form;
 
-  $dbh    = $self->dbconnect();
+  # Don't fail if the auth DB doesn't yet.
+  if (!( $dbh = $self->dbconnect(1) )) {
+    $::lxdebug->leave_sub;
+    return SESSION_NONE;
+  }
+
+  # Don't fail if the "auth" schema doesn't exist yet, e.g. if the
+  # admin is creating the session tables at the moment.
   $query  = qq|SELECT *, (mtime < (now() - '$self->{session_timeout}m'::interval)) AS is_expired FROM auth.session WHERE id = ?|;
 
-  $cookie = selectfirst_hashref_query($form, $dbh, $query, $session_id);
+  if (!($sth = $dbh->prepare($query)) || !$sth->execute($session_id)) {
+    $sth->finish if $sth;
+    $::lxdebug->leave_sub;
+    return SESSION_NONE;
+  }
+
+  $cookie = $sth->fetchrow_hashref;
+  $sth->finish;
 
   if (!$cookie || $cookie->{is_expired} || ($cookie->{ip_address} ne $ENV{REMOTE_ADDR})) {
     $self->destroy_session();
@@ -703,7 +717,13 @@ sub save_session {
 
   $dbh->begin_work unless $provided_dbh;
 
-  do_query($::form, $dbh, qq|LOCK auth.session_content|);
+  # If this fails then the "auth" schema might not exist yet, e.g. if
+  # the admin is just trying to create the auth database.
+  if (!$dbh->do(qq|LOCK auth.session_content|)) {
+    $dbh->rollback unless $provided_dbh;
+    $::lxdebug->leave_sub;
+    return;
+  }
 
   my @unfetched_keys = map     { $_->{key}        }
                        grep    { ! $_->{fetched}  }
index 62cdfdd7ea7eb802b419b767d2d5aaa907b7186f..c569ef8a53fcefb93e9537052cd3810dd8842103 100644 (file)
@@ -1343,7 +1343,7 @@ sub print_form {
 
   # Store the output number format so that the template modules know
   # how to parse the amounts back if requested.
-  $myconfig{output_numberformat} = $output_numberformat;
+  $myconfig{output_numberformat} = $output_numberformat || $myconfig{numberformat};
 
   ($form->{employee}) = split /--/, $form->{employee};
 
index 2e3c91d32f39cce67abea54ffa4d859182544537..f57ef775078975f5401ba477a732ea1305aaeaf9 100644 (file)
     <td><input name="select_item_id" class="radio" type="radio" value="[% HTML.escape(item.id) %]"[% IF loop.first %] checked[% END %]></td>
     <td>[% HTML.escape(item.partnumber) %]</td>
     <td>[% HTML.escape(item.description) %]</td>
+    <td align="right">[% LxERP.format_amount(item.display_sellprice, 2) %]</td>
     [%- IF IS_PURCHASE %]
      <td align="right">[% LxERP.format_amount(item.rop, '') %]</td>
     [%- END %]
-    <td align="right">[% LxERP.format_amount(item.display_sellprice, 2) %]</td>
     <td align="right">[% LxERP.format_amount(item.onhand, '') %]</td>
     <td>[% HTML.escape(item.unit) %]</td>
    </tr>