From 5c5c1eef2ef26aa166f612d0718770488809b74b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 14 Jan 2013 12:35:58 +0100 Subject: [PATCH] =?utf8?q?Projekt:=20neue=20Spalten=20(Kunde,=20Typ,=20g?= =?utf8?q?=C3=BCltig)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/MetaSetup/Project.pm | 10 ++++++ SL/Projects.pm | 31 ++++++++++++++++--- bin/mozilla/projects.pl | 13 ++++++-- locale/de/all | 6 ++-- .../project_customer_type_valid.sql | 12 +++++++ templates/webpages/projects/project_form.html | 24 ++++++++++---- templates/webpages/projects/search.html | 26 +++++++++++++++- 7 files changed, 103 insertions(+), 19 deletions(-) create mode 100644 sql/Pg-upgrade2/project_customer_type_valid.sql diff --git a/SL/DB/MetaSetup/Project.pm b/SL/DB/MetaSetup/Project.pm index 6b3ab9105..a492b46ca 100644 --- a/SL/DB/MetaSetup/Project.pm +++ b/SL/DB/MetaSetup/Project.pm @@ -16,6 +16,9 @@ __PACKAGE__->meta->setup( itime => { type => 'timestamp', default => 'now()' }, mtime => { type => 'timestamp' }, active => { type => 'boolean', default => 'true' }, + customer_id => { type => 'integer' }, + type => { type => 'text' }, + valid => { type => 'boolean', default => 'true' }, ], primary_key_columns => [ 'id' ], @@ -23,6 +26,13 @@ __PACKAGE__->meta->setup( unique_key => [ 'projectnumber' ], allow_inline_column_values => 1, + + foreign_keys => [ + customer => { + class => 'SL::DB::Customer', + key_columns => { customer_id => 'id' }, + }, + ], ); 1; diff --git a/SL/Projects.pm b/SL/Projects.pm index d3df51fdd..4c145bb57 100644 --- a/SL/Projects.pm +++ b/SL/Projects.pm @@ -94,6 +94,23 @@ sub search_projects { push @filters, 'NOT COALESCE(p.active, FALSE)'; } + if ($params{valid} eq "valid") { + push @filters, 'p.valid'; + + } elsif ($params{valid} eq "invalid") { + push @filters, 'NOT COALESCE(p.valid, FALSE)'; + } + + if ($params{customer}) { + push @filters, 'c.name ILIKE ?'; + push @values, '%' . $params{customer} . '%'; + } + + if ($params{type}) { + push @filters, 'p.type ILIKE ?'; + push @values, '%' . $params{type} . '%'; + } + my ($cvar_where, @cvar_values) = CVar->build_filter_query('module' => 'Projects', 'trans_id_field' => 'p.id', 'filter' => $form); @@ -108,8 +125,10 @@ sub search_projects { my $sortorder = $params{sort} ? $params{sort} : "projectnumber"; $sortorder =~ s/[^a-z_]//g; - my $query = qq|SELECT p.id, p.projectnumber, p.description, p.active + my $query = qq|SELECT p.id, p.projectnumber, p.description, p.active, p.valid, p.type, + c.name AS customer FROM project p + LEFT JOIN customer c ON (p.customer_id = c.id) $where ORDER BY $sortorder|; @@ -180,10 +199,13 @@ sub save_project { $params{active} = 1; } - my $query = qq|UPDATE project SET projectnumber = ?, description = ?, active = ? - WHERE id = ?|; + my $query = <save_custom_variables('dbh' => $dbh, @@ -220,4 +242,3 @@ sub delete_project { } 1; - diff --git a/bin/mozilla/projects.pl b/bin/mozilla/projects.pl index bda1c6d96..c1b8b7d6e 100644 --- a/bin/mozilla/projects.pl +++ b/bin/mozilla/projects.pl @@ -118,7 +118,7 @@ sub project_report { my $report = SL::ReportGenerator->new(\%myconfig, $form); - my @columns = qw(projectnumber description active); + my @columns = qw(projectnumber description customer type active valid); my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs }; my @searchable_custom_variables = grep { $_->{searchable} } @{ $cvar_configs }; @@ -144,11 +144,14 @@ sub project_report { my %column_defs = ( 'projectnumber' => { 'text' => $locale->text('Number'), }, 'description' => { 'text' => $locale->text('Description'), }, + 'customer' => { 'text' => $locale->text('Customer'), }, + 'type' => { 'text' => $locale->text('Type'), }, 'active' => { 'text' => $locale->text('Active'), 'visible' => 'both' eq $filter->{active}, }, + 'valid' => { 'text' => $locale->text('Valid'), 'visible' => 'both' eq $filter->{active}, }, %column_defs_cvars, ); - foreach (qw(projectnumber description)) { + foreach (qw(projectnumber description customer type)) { $column_defs{$_}->{link} = $href . "&sort=$_"; $column_defs{$_}->{visible} = 1; } @@ -171,7 +174,9 @@ sub project_report { push @options, $locale->text('All') if ($filter->{all}); push @options, $locale->text('Orphaned') if ($filter->{orphaned}); push @options, $locale->text('Project Number') . " : $filter->{projectnumber}" if ($filter->{projectnumber}); - push @options, $locale->text('Description') . " : $filter->{description}" if ($filter->{description}); + push @options, $locale->text('Description') . " : $filter->{description}" if ($filter->{description}); + push @options, $locale->text('Customer') . " : $filter->{customer}" if ($filter->{customer}); + push @options, $locale->text('Type') . " : $filter->{type}" if ($filter->{type}); push @options, $locale->text('Active') if ($filter->{active} eq 'active'); push @options, $locale->text('Inactive') if ($filter->{active} eq 'inactive'); push @options, $locale->text('Orphaned') if ($filter->{status} eq 'orphaned'); @@ -197,6 +202,7 @@ sub project_report { foreach my $project (@{ $form->{project_list} }) { $project->{active} = $project->{active} ? $locale->text('Yes') : $locale->text('No'); + $project->{valid} = $project->{valid} ? $locale->text('Yes') : $locale->text('No'); my $row = { map { $_ => { 'data' => $project->{$_} } } keys %{ $project } }; @@ -222,6 +228,7 @@ sub display_project_form { $form->{title} = $form->{project}->{id} ? $locale->text("Edit Project") : $locale->text("Add Project"); + $form->{ALL_CUSTOMERS} = SL::DB::Manager::Customer->get_all_sorted(where => [ or => [ obsolete => 0, obsolete => undef, id => $form->{project}->{customer_id} ]]); $form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'Projects', 'trans_id' => $form->{project}->{id}); # $main::lxdebug->dump(0, "cv", $form->{CUSTOM_VARIABLES}); CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}) if (scalar @{ $form->{CUSTOM_VARIABLES} }); diff --git a/locale/de/all b/locale/de/all index 627fbffe7..ebafe70ef 100644 --- a/locale/de/all +++ b/locale/de/all @@ -417,7 +417,6 @@ $self->{texts} = { 'Client Configuration saved!' => 'Mandantenkonfiguration gespeichert!', 'Close' => 'Übernehmen', 'Close Books up to' => 'Die Bücher abschließen bis zum', - 'Close Dialog' => 'Schließen', 'Close Flash' => 'Schließen', 'Close SEPA exports' => 'SEPA-Export abschließen', 'Close Window' => 'Fenster Schließen', @@ -1018,7 +1017,7 @@ $self->{texts} = { 'Introduction of Buchungsgruppen' => 'Einführung von Buchungsgruppen', 'Introduction of units' => 'Einführung von Einheiten', 'Inv. Duedate' => 'Rg. Fälligkeit', - 'Invalid' => 'Ungültig', + 'Invalid' => 'Ungültig', 'Invalid follow-up ID.' => 'Ungültige Wiedervorlage-ID.', 'Invalid quantity.' => 'Die Mengenangabe ist ungültig.', 'Invdate' => 'Rechnungsdatum', @@ -1432,7 +1431,6 @@ $self->{texts} = { 'Please select the source bank account for the transfers:' => 'Bitte wählen Sie das Bankkonto als Quelle für die Überweisungen aus:', 'Please seletct the dataset you want to delete:' => 'Bitte wählen Sie die zu löschende Datenbank aus:', 'Please specify a description for the warehouse designated for these goods.' => 'Bitte geben Sie den Namen des Ziellagers für die übernommenen Daten ein.', - 'Please wait...' => 'Bitte warten...', 'Plural' => 'Plural', 'Port' => 'Port', 'Portrait' => 'Hochformat', @@ -2181,6 +2179,7 @@ $self->{texts} = { 'Username' => 'Benutzername', 'Users in this group' => 'BenutzerInnen in dieser Gruppe', 'Ust-IDNr' => 'USt-IdNr.', + 'Valid' => 'Gültig', 'Valid from' => 'Gültig ab', 'Valid until' => 'gültig bis', 'Value' => 'Wert', @@ -2391,7 +2390,6 @@ $self->{texts} = { 'list_of_payments' => 'zahlungsausgaenge', 'list_of_receipts' => 'zahlungseingaenge', 'list_of_transactions' => 'buchungsliste', - 'loading' => 'wird geladen', 'logout' => 'abmelden', 'male' => 'männlich', 'mark as paid' => 'als bezahlt markieren', diff --git a/sql/Pg-upgrade2/project_customer_type_valid.sql b/sql/Pg-upgrade2/project_customer_type_valid.sql new file mode 100644 index 000000000..f77820ac9 --- /dev/null +++ b/sql/Pg-upgrade2/project_customer_type_valid.sql @@ -0,0 +1,12 @@ +-- @tag: project_customer_type_valid +-- @description: Projekt: Spalten "Kunde", "Typ", "Gültig" +-- @depends: release_3_0_0 +-- @charset: utf-8 +ALTER TABLE project ADD COLUMN customer_id INTEGER; +ALTER TABLE project ADD COLUMN type TEXT; +ALTER TABLE project ADD COLUMN valid BOOLEAN; +ALTER TABLE project ALTER COLUMN valid SET DEFAULT TRUE; + +ALTER TABLE project ADD FOREIGN KEY (customer_id) REFERENCES customer (id); + +UPDATE project SET valid = TRUE; diff --git a/templates/webpages/projects/project_form.html b/templates/webpages/projects/project_form.html index 24256cf3d..3b6f7f45a 100644 --- a/templates/webpages/projects/project_form.html +++ b/templates/webpages/projects/project_form.html @@ -29,7 +29,7 @@ - + @@ -44,13 +44,25 @@ + + + + + + + + + + + + + + + [%- IF project.id %] - - + + [%- END %]
[% 'Number' | $T8 %]
[% 'Type' | $T8 %][% L.input_tag('project.type', project.type, size=60) %]
[% 'Customer' | $T8 %][% L.select_tag('project.customer_id', ALL_CUSTOMERS, default=project.customer_id, title_key='name', style='width: 300px') %]
[% 'Valid' | $T8 %][% L.select_tag('project.valid', [ [ 1, LxERP.t8('Valid') ], [ 0, LxERP.t8('Invalid') ] ], default=project.valid, style='width: 300px') %]
  - - - [% 'Active' | $T8 %][% L.select_tag('project.active', [ [ 1, LxERP.t8('Active') ], [ 0, LxERP.t8('Inactive') ] ], default=project.valid, style='width: 300px') %]
diff --git a/templates/webpages/projects/search.html b/templates/webpages/projects/search.html index f2718a1a7..5eafb4024 100644 --- a/templates/webpages/projects/search.html +++ b/templates/webpages/projects/search.html @@ -16,6 +16,16 @@ + + [% 'Customer' | $T8 %] + + + + + [% 'Type' | $T8 %] + + + [% CUSTOM_VARIABLES_FILTER_CODE %] @@ -37,6 +47,21 @@ + + + + + + + + + + + + + + + @@ -64,4 +89,3 @@

- -- 2.20.1