Merge branch 'master' of github.com:kivitendo/kivitendo-erp
authorSven Schöling <s.schoeling@linet-services.de>
Thu, 27 Jun 2013 14:29:25 +0000 (16:29 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 27 Jun 2013 14:29:25 +0000 (16:29 +0200)
.gitignore
sql/Pg-upgrade2/custom_variable_configs_column_type_text.pl [new file with mode: 0644]
sql/Pg-upgrade2/custom_variable_configs_column_type_text.sql [deleted file]
sql/Pg-upgrade2/defaults_feature.pl [new file with mode: 0644]
templates/webpages/client_config/_features.html [new file with mode: 0644]

index b372c4f..941e1c7 100644 (file)
@@ -6,6 +6,7 @@ crm
 /users/pid/
 /users/.cache/
 /users/kivitendo-print*
+users/.openoffice.org2/
 /config/lx_office.conf
 /config/kivitendo.conf
 /doc/online/*/*.html
diff --git a/sql/Pg-upgrade2/custom_variable_configs_column_type_text.pl b/sql/Pg-upgrade2/custom_variable_configs_column_type_text.pl
new file mode 100644 (file)
index 0000000..2f75f88
--- /dev/null
@@ -0,0 +1,70 @@
+# @tag: custom_variable_configs_column_type_text
+# @description: Spaltentypen in 'custom_varialbe_configs' anpassen & schärfere Restriktionen
+# @depends: release_3_0_0
+package SL::DBUpgrade2::custom_variable_configs_column_type_text;
+
+use utf8;
+use strict;
+
+use parent qw(SL::DBUpgrade2::Base);
+
+sub run {
+  my ($self) = @_;
+
+  # Fix 'sortkey' column to not contain NULLs
+  my $q_update = qq|UPDATE custom_variable_configs SET sortkey = ? WHERE id = ?|;
+  my $h_update = $self->dbh->prepare($q_update) || die $self->dbh->errstr;
+
+  my $q_select = <<SQL;
+    SELECT id, module
+    FROM custom_variable_configs
+    ORDER BY module ASC, sortkey ASC NULLS LAST, id ASC
+SQL
+
+  my $previous_module = '';
+  my $sortkey         = 0;
+  foreach my $entry (@{ $self->dbh->selectall_arrayref($q_select) }) {
+    $sortkey         = $previous_module eq $entry->[1] ? $sortkey + 1 : 1;
+    $previous_module = $entry->[1];
+
+    $h_update->execute($sortkey, $entry->[0]) || die $self->dbh->errstr;
+  }
+
+  $h_update->finish;
+
+  # Apply structure upgrade
+  my @statements = (
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN type   TYPE TEXT|,
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN module TYPE TEXT|,
+
+    qq|UPDATE custom_variable_configs SET searchable          = FALSE WHERE searchable          IS NULL|,
+    qq|UPDATE custom_variable_configs SET includeable         = FALSE WHERE includeable         IS NULL|,
+    qq|UPDATE custom_variable_configs SET included_by_default = FALSE WHERE included_by_default IS NULL|,
+
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN searchable          SET NOT NULL|,
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN includeable         SET NOT NULL|,
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN included_by_default SET NOT NULL|,
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN name                SET NOT NULL|,
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN description         SET NOT NULL|,
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN type                SET NOT NULL|,
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN module              SET NOT NULL|,
+    qq|ALTER TABLE custom_variable_configs ALTER COLUMN sortkey             SET NOT NULL|,
+
+    qq|ALTER TABLE custom_variable_configs
+       ADD CONSTRAINT custom_variable_configs_name_description_type_module_not_empty
+       CHECK (    type        <> ''
+              AND module      <> ''
+              AND name        <> ''
+              AND description <> '')|,
+
+    qq|ALTER TABLE custom_variable_configs
+       ADD CONSTRAINT custom_variable_configs_options_not_empty_for_select
+       CHECK ((type <> 'select') OR (COALESCE(options, '') <> ''))|,
+  );
+
+  $self->db_query($_) for @statements;
+
+  return 1;
+}
+
+1;
diff --git a/sql/Pg-upgrade2/custom_variable_configs_column_type_text.sql b/sql/Pg-upgrade2/custom_variable_configs_column_type_text.sql
deleted file mode 100644 (file)
index 98ebbbc..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
--- @tag: custom_variable_configs_column_type_text
--- @description: Spaltentypen in 'custom_varialbe_configs' anpassen & schärfere Restriktionen
--- @depends: release_3_0_0
--- @charset: utf-8
-ALTER TABLE custom_variable_configs ALTER COLUMN type   TYPE TEXT;
-ALTER TABLE custom_variable_configs ALTER COLUMN module TYPE TEXT;
-
-UPDATE custom_variable_configs SET searchable          = FALSE WHERE searchable          IS NULL;
-UPDATE custom_variable_configs SET includeable         = FALSE WHERE includeable         IS NULL;
-UPDATE custom_variable_configs SET included_by_default = FALSE WHERE included_by_default IS NULL;
-
-ALTER TABLE custom_variable_configs ALTER COLUMN searchable          SET NOT NULL;
-ALTER TABLE custom_variable_configs ALTER COLUMN includeable         SET NOT NULL;
-ALTER TABLE custom_variable_configs ALTER COLUMN included_by_default SET NOT NULL;
-ALTER TABLE custom_variable_configs ALTER COLUMN name                SET NOT NULL;
-ALTER TABLE custom_variable_configs ALTER COLUMN description         SET NOT NULL;
-ALTER TABLE custom_variable_configs ALTER COLUMN type                SET NOT NULL;
-ALTER TABLE custom_variable_configs ALTER COLUMN module              SET NOT NULL;
-ALTER TABLE custom_variable_configs ALTER COLUMN sortkey             SET NOT NULL;
-
-ALTER TABLE custom_variable_configs
-ADD CONSTRAINT custom_variable_configs_name_description_type_module_not_empty
-CHECK (    type        <> ''
-       AND module      <> ''
-       AND name        <> ''
-       AND description <> '');
-
-ALTER TABLE custom_variable_configs
-ADD CONSTRAINT custom_variable_configs_options_not_empty_for_select
-CHECK ((type <> 'select') OR (COALESCE(options, '') <> ''));
diff --git a/sql/Pg-upgrade2/defaults_feature.pl b/sql/Pg-upgrade2/defaults_feature.pl
new file mode 100644 (file)
index 0000000..c46ff3a
--- /dev/null
@@ -0,0 +1,36 @@
+# @tag: defaults_feature
+# @description: Einstellen der Feature vom Config-File in die DB verlagern.
+# @depends: release_3_0_0
+package SL::DBUpgrade2::defaults_feature;
+
+use utf8;
+
+use parent qw(SL::DBUpgrade2::Base);
+use strict;
+
+sub run {
+  my ($self) = @_;
+
+  # this query will fail if column already exist (new database)
+  $self->db_query(qq|ALTER TABLE defaults ADD COLUMN webdav              boolean DEFAULT false|);
+  $self->db_query(qq|ALTER TABLE defaults ADD COLUMN webdav_documents    boolean DEFAULT false|);
+  $self->db_query(qq|ALTER TABLE defaults ADD COLUMN vertreter           boolean DEFAULT false|);
+  $self->db_query(qq|ALTER TABLE defaults ADD COLUMN parts_show_image    boolean DEFAULT true|);
+  $self->db_query(qq|ALTER TABLE defaults ADD COLUMN parts_listing_image boolean DEFAULT true|);
+  $self->db_query(qq|ALTER TABLE defaults ADD COLUMN parts_image_css     text    DEFAULT 'border:0;float:left;max-width:250px;margin-top:20px:margin-right:10px;margin-left:10px;'|);
+
+  # check current configuration and set default variables accordingly, so that
+  # kivitendo's behaviour isn't changed by this update
+  # if checks are not set in config set it to true
+  foreach my $check (qw(webdav vertreter parts_show_image parts_listing_image)) {
+    my $check_set = $::lx_office_conf{features}->{$check} ? 1 : 0;
+    $self->db_query("UPDATE defaults SET $check = ?", bind => [ $check_set ]);
+  }
+
+  my $update_column = "UPDATE defaults SET parts_image_css = ?";
+  $self->db_query($update_column, bind => [ $::lx_office_conf{features}->{parts_image_css} ]);
+
+  return 1;
+}
+
+1;
diff --git a/templates/webpages/client_config/_features.html b/templates/webpages/client_config/_features.html
new file mode 100644 (file)
index 0000000..0b71500
--- /dev/null
@@ -0,0 +1,35 @@
+[%- USE LxERP -%][%- USE L -%]
+<div id="features">
+ <table>
+  <tr>
+   <td align="right">[% LxERP.t8('Webdav') %]</td>
+   <td>[% L.yes_no_tag('defaults.webdav', SELF.defaults.webdav) %]</td>
+   <td>[% LxERP.t8('Use Webdav Repository') %]</td>
+  </tr>
+  <tr>
+   <td align="right">[% LxERP.t8('Webdav save documents') %]</td>
+   <td>[% L.yes_no_tag('defaults.webdav_documents', SELF.defaults.webdav_documents) %]</td>
+   <td>[% LxERP.t8('Save document in webdav repository') %]</td>
+  </tr>
+  <tr>
+   <td align="right">[% LxERP.t8('Vertreter') %]</td>
+   <td>[% L.yes_no_tag('defaults.vertreter', SELF.defaults.vertreter) %]</td>
+   <td>[% LxERP.t8('Representative for Customer') %]</td>
+  </tr>
+  <tr>
+   <td align="right">[% LxERP.t8('Pictures for parts') %]</td>
+   <td>[% L.yes_no_tag('defaults.parts_show_image', SELF.defaults.parts_show_image) %]</td>
+   <td>[% LxERP.t8('Show the picture in the part form') %]</td>
+  </tr>
+  <tr>
+   <td align="right">[% LxERP.t8('Pictures for search parts') %]</td>
+   <td>[% L.yes_no_tag('defaults.parts_listing_image', SELF.defaults.parts_listing_image) %]</td>
+   <td>[% LxERP.t8('Show the pictures in the result for search parts') %]</td>
+  </tr>
+  <tr>
+   <td align="right">[% LxERP.t8('CSS style for pictures') %]</td>
+   <td>   [% L.input_tag('defaults.parts_image_css', SELF.defaults.parts_image_css, style=style) %]</td>
+   <td>[% LxERP.t8('Style the picture with the following CSS code') %]</td>
+  </tr>
+ </table>
+</div>