]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Projekttypen verwaltbar gemacht
authorSven Schöling <s.schoeling@linet-services.de>
Tue, 17 Dec 2013 13:23:57 +0000 (14:23 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Tue, 17 Dec 2013 13:23:57 +0000 (14:23 +0100)
18 files changed:
SL/Controller/FinancialControllingReport.pm
SL/Controller/Project.pm
SL/Controller/ProjectType.pm [new file with mode: 0644]
SL/DB/Helper/ALL.pm
SL/DB/Helper/Mappings.pm
SL/DB/Manager/Order.pm
SL/DB/Manager/Project.pm
SL/DB/Manager/ProjectType.pm [new file with mode: 0644]
SL/DB/MetaSetup/Project.pm
SL/DB/MetaSetup/ProjectType.pm [new file with mode: 0644]
SL/DB/ProjectType.pm [new file with mode: 0644]
locale/de/all
menus/erp.ini
sql/Pg-upgrade2/project_types.sql [new file with mode: 0644]
templates/webpages/project/form.html
templates/webpages/project/search.html
templates/webpages/project_type/form.html [new file with mode: 0755]
templates/webpages/project_type/list.html [new file with mode: 0644]

index d4492c1d977859f23441c718e6feb9cf78cb4a9c..d44936d6726d9666747bcad9ec5f537dea99133b 100644 (file)
@@ -6,6 +6,7 @@ use parent qw(SL::Controller::Base);
 use List::Util qw(sum);
 
 use SL::DB::Order;
+use SL::DB::ProjectType;
 use SL::Controller::Helper::GetModels;
 use SL::Controller::Helper::Paginated;
 use SL::Controller::Helper::Sorted;
@@ -37,6 +38,7 @@ __PACKAGE__->make_sorted(
   customer                => t8('Customer'),
   transaction_description => t8('Transaction description'),
   globalprojectnumber     => t8('Project'),
+  globalproject_type      => t8('Project Type'),
   netamount               => t8('Order amount'),
 );
 
@@ -62,7 +64,7 @@ sub setup_db_args_for_list {
   my ($self) = @_;
 
   $self->{filter} = {};
-  my %args     = ( parse_filter($::form->{filter}, with_objects => [ 'customer', 'globalproject' ], launder_to => $self->{filter}));
+  my %args     = ( parse_filter($::form->{filter}, with_objects => [ 'customer', 'globalproject', 'globalproject.project_type' ], launder_to => $self->{filter}));
   $args{query} = [
     @{ $args{query} || [] },
     SL::DB::Manager::Order->type_filter('sales_order'),
@@ -77,9 +79,9 @@ sub prepare_report {
   my $report      = SL::ReportGenerator->new(\%::myconfig, $::form);
   $self->{report} = $report;
 
-  my @columns     = qw(customer globalprojectnumber project_type ordnumber netamount delivered_amount delivered_amount_p billed_amount billed_amount_p paid_amount paid_amount_p
+  my @columns     = qw(customer globalprojectnumber globalproject_type ordnumber netamount delivered_amount delivered_amount_p billed_amount billed_amount_p paid_amount paid_amount_p
                        billable_amount billable_amount_p other_amount);
-  my @sortable    = qw(ordnumber transdate customer netamount globalprojectnumber);
+  my @sortable    = qw(ordnumber transdate customer netamount globalprojectnumber globalproject_type);
   $self->{number_columns} = [ qw(netamount billed_amount billed_amount_p delivered_amount delivered_amount_p paid_amount paid_amount_p other_amount billable_amount billable_amount_p) ];
 
   my %column_defs           = (
@@ -97,8 +99,8 @@ sub prepare_report {
     customer                => {      sub => sub { $_[0]->customer->name                                              },
                                  obj_link => sub { $self->link_to($_[0]->customer)                                    }  },
     globalprojectnumber     => {      sub => sub { $_[0]->globalproject_id ? $_[0]->globalproject->projectnumber : '' }  },
-    project_type            => { text     => $::locale->text('Project type'),
-                                 sub      => sub { $_[0]->globalproject_id ? $_[0]->globalproject->type          : '' }  },
+    globalproject_type      => { text     => $::locale->text('Project type'),
+                                 sub      => sub { $_[0]->globalproject_id ? $_[0]->globalproject->project_type->description : '' }  },
   );
 
   map { $column_defs{$_}->{text} ||= $::locale->text( $self->get_sort_spec->{$_}->{title} ) } keys %column_defs;
index a5793b85ad5bb332f2b209274e8ce426690e0517..23e5228adeb673ea15745d808986ec1c7fea72bd 100644 (file)
@@ -16,6 +16,7 @@ use SL::DB::Invoice;
 use SL::DB::Order;
 use SL::DB::Project;
 use SL::DB::PurchaseInvoice;
+use SL::DB::ProjectType;
 use SL::Helper::Flash;
 use SL::Locale::String;
 
@@ -26,7 +27,7 @@ use Rose::Object::MakeMethods::Generic
 );
 
 __PACKAGE__->run_before('check_auth');
-__PACKAGE__->run_before('load_project', only => [ qw(edit update destroy) ]);
+__PACKAGE__->run_before('load_project',       only => [ qw(edit update destroy) ]);
 
 #
 # actions
@@ -37,7 +38,8 @@ sub action_search {
 
   my %params;
 
-  $params{CUSTOM_VARIABLES} = CVar->get_configs(module => 'Projects');
+  $params{ALL_PROJECT_TYPES} = SL::DB::Manager::ProjectType->get_all_sorted;
+  $params{CUSTOM_VARIABLES}  = CVar->get_configs(module => 'Projects');
   ($params{CUSTOM_VARIABLES_FILTER_CODE}, $params{CUSTOM_VARIABLES_INCLUSION_CODE})
     = CVar->render_search_options(variables      => $params{CUSTOM_VARIABLES},
                                   include_prefix => 'l_',
@@ -121,8 +123,9 @@ sub check_auth {
 sub display_form {
   my ($self, %params) = @_;
 
-  $params{ALL_CUSTOMERS}    = SL::DB::Manager::Customer->get_all_sorted(where => [ or => [ obsolete => 0, obsolete => undef, id => $self->project->customer_id ]]);
-  $params{CUSTOM_VARIABLES} = CVar->get_custom_variables(module => 'Projects', trans_id => $self->project->id);
+  $params{ALL_CUSTOMERS}     = SL::DB::Manager::Customer->get_all_sorted(where => [ or => [ obsolete => 0, obsolete => undef, id => $self->project->customer_id ]]);
+  $params{ALL_PROJECT_TYPES} = SL::DB::Manager::ProjectType->get_all_sorted;
+  $params{CUSTOM_VARIABLES}  = CVar->get_custom_variables(module => 'Projects', trans_id => $self->project->id);
   CVar->render_inputs(variables => $params{CUSTOM_VARIABLES}) if @{ $params{CUSTOM_VARIABLES} };
 
   $self->render('project/form', %params);
@@ -171,7 +174,7 @@ sub setup_db_args_from_filter {
   $self->{filter} = {};
   my %args = parse_filter(
     $self->_pre_parse_filter($::form->{filter}, $self->{filter}),
-    with_objects => [ 'customer' ],
+    with_objects => [ 'customer', 'project_type' ],
     launder_to   => $self->{filter},
   );
 
@@ -186,13 +189,13 @@ sub prepare_report {
   my $report      = SL::ReportGenerator->new(\%::myconfig, $::form);
   $self->{report} = $report;
 
-  my @columns     = qw(projectnumber description customer active valid type);
-  my @sortable    = qw(projectnumber description customer              type);
+  my @columns     = qw(projectnumber description customer active valid project_type);
+  my @sortable    = qw(projectnumber description customer              project_type);
 
   my %column_defs = (
     projectnumber => { obj_link => sub { $self->url_for(action => 'edit', id => $_[0]->id, callback => $callback) } },
     description   => { obj_link => sub { $self->url_for(action => 'edit', id => $_[0]->id, callback => $callback) } },
-    type          => { },
+    project_type  => { sub  => sub { $_[0]->project_type->description } },
     customer      => { sub  => sub { $_[0]->customer ? $_[0]->customer->name     : '' } },
     active        => { sub  => sub { $_[0]->active   ? $::locale->text('Active') : $::locale->text('Inactive') },
                        text => $::locale->text('Active') },
@@ -235,7 +238,7 @@ sub init_models {
       customer      => t8('Customer'),
       description   => t8('Description'),
       projectnumber => t8('Project Number'),
-      type          => t8('Type'),
+      project_type  => t8('Project Type'),
     },
     with_objects => [ 'customer' ],
   );
diff --git a/SL/Controller/ProjectType.pm b/SL/Controller/ProjectType.pm
new file mode 100644 (file)
index 0000000..facf1a8
--- /dev/null
@@ -0,0 +1,117 @@
+package SL::Controller::ProjectType;
+
+use strict;
+
+use parent qw(SL::Controller::Base);
+
+use SL::DB::ProjectType;
+use SL::Helper::Flash;
+
+use Rose::Object::MakeMethods::Generic
+(
+ scalar => [ qw(project_type) ],
+);
+
+__PACKAGE__->run_before('check_auth');
+__PACKAGE__->run_before('load_project_type', only => [ qw(edit update destroy) ]);
+
+#
+# actions
+#
+
+sub action_list {
+  my ($self) = @_;
+
+  $self->render('project_type/list',
+                title         => $::locale->text('Project Types'),
+                PROJECT_TYPES => SL::DB::Manager::ProjectType->get_all_sorted);
+}
+
+sub action_new {
+  my ($self) = @_;
+
+  $self->{project_type} = SL::DB::ProjectType->new;
+  $self->render('project_type/form', title => $::locale->text('Create a new project type'));
+}
+
+sub action_edit {
+  my ($self) = @_;
+  $self->render('project_type/form', title => $::locale->text('Edit project type'));
+}
+
+sub action_create {
+  my ($self) = @_;
+
+  $self->{project_type} = SL::DB::ProjectType->new;
+  $self->create_or_update;
+}
+
+sub action_update {
+  my ($self) = @_;
+  $self->create_or_update;
+}
+
+sub action_destroy {
+  my ($self) = @_;
+
+  if (eval { $self->{project_type}->delete; 1; }) {
+    flash_later('info',  $::locale->text('The project type has been deleted.'));
+  } else {
+    flash_later('error', $::locale->text('The project type is in use and cannot be deleted.'));
+  }
+
+  $self->redirect_to(action => 'list');
+}
+
+sub action_reorder {
+  my ($self) = @_;
+
+  my @ids = @{ $::form->{project_type_id} || [] };
+  my $result = SL::DB::ProjectType->new->db->do_transaction(sub {
+    foreach my $idx (0 .. scalar(@ids) - 1) {
+      SL::DB::ProjectType->new(id => $ids[$idx])->load->update_attributes(position => $idx + 1);
+    }
+  });
+
+  $self->render('1;', { type => 'js', inline => 1 });
+}
+
+#
+# filters
+#
+
+sub check_auth {
+  $::auth->assert('config');
+}
+
+#
+# helpers
+#
+
+sub create_or_update {
+  my $self   = shift;
+  my $is_new = !$self->{project_type}->id;
+  my $params = delete($::form->{project_type}) || { };
+
+  $self->{project_type}->assign_attributes(%{ $params });
+
+  my @errors = $self->{project_type}->validate;
+
+  if (@errors) {
+    flash('error', @errors);
+    $self->render('project_type/form', title => $is_new ? $::locale->text('Create a new project type') : $::locale->text('Edit project type'));
+    return;
+  }
+
+  $self->{project_type}->save;
+
+  flash_later('info', $is_new ? $::locale->text('The project type has been created.') : $::locale->text('The project type has been saved.'));
+  $self->redirect_to(action => 'list');
+}
+
+sub load_project_type {
+  my ($self) = @_;
+  $self->{project_type} = SL::DB::ProjectType->new(id => $::form->{id})->load;
+}
+
+1;
index 446356775337b555d247d152c56f4c55f80c3cf2..498583f0a952a8db247e5845dd189d9bdedc0e8b 100644 (file)
@@ -70,6 +70,7 @@ use SL::DB::Pricegroup;
 use SL::DB::Price;
 use SL::DB::Printer;
 use SL::DB::Project;
+use SL::DB::ProjectType;
 use SL::DB::PurchaseInvoice;
 use SL::DB::RecordLink;
 use SL::DB::SchemaInfo;
index 35d601d602c90e4e72faf30d38dc6c5aae9b193f..633a067935d81006e8ad238166802867b5d91e4a 100644 (file)
@@ -151,6 +151,7 @@ my %kivitendo_package_names = (
   pricegroup                     => 'pricegroup',
   printers                       => 'printer',
   project                        => 'project',
+  project_types                  => 'ProjectType',
   record_links                   => 'record_link',
   sepa_export                    => 'sepa_export',
   sepa_export_items              => 'sepa_export_item',
index 69aa266791300a75bd2de019ae7b2368681e7cec..e03386d0441beba4a0913db38d79d2bf6cc3acb9 100644 (file)
@@ -38,6 +38,13 @@ sub _sort_spec {
       customer                => 'customer.name',
       vendor                  => 'vendor.name',
       globalprojectnumber     => 'lower(globalproject.projectnumber)',
+
+      # Bug in Rose::DB::Object: the next should be
+      # "globalproject.project_type.description". This workaround will
+      # only work if no other table with "project_type" is visible in
+      # the current query
+      globalproject_type      => 'lower(project_type.description)',
+
       map { ( $_ => "lower(oe.$_)" ) } qw(ordnumber quonumber cusordnumber shippingpoint shipvia notes intnotes transaction_description),
     });
 }
index 6c5563fe7f2d441b83e6e11b72c2c5c72da8661c..f6ff1271ba42074b2bb728fa61075d2d02602d1b 100644 (file)
@@ -43,10 +43,11 @@ our @tables_with_project_id_cols = qw(acc_trans ap ar delivery_order_items deliv
 
 sub _sort_spec {
   return (
-    default    => [ 'projectnumber', 1 ],
-    columns    => {
-      SIMPLE   => 'ALL',
-      customer => 'customer.name',
+    default        => [ 'projectnumber', 1 ],
+    columns        => {
+      SIMPLE       => 'ALL',
+      customer     => 'customer.name',
+      project_type => 'project_type.description',
     });
 }
 
diff --git a/SL/DB/Manager/ProjectType.pm b/SL/DB/Manager/ProjectType.pm
new file mode 100644 (file)
index 0000000..3fa990f
--- /dev/null
@@ -0,0 +1,51 @@
+package SL::DB::Manager::ProjectType;
+
+use strict;
+
+use parent qw(SL::DB::Helper::Manager);
+
+use SL::DB::Helper::Paginated;
+use SL::DB::Helper::Sorted;
+
+sub object_class { 'SL::DB::ProjectType' }
+
+__PACKAGE__->make_manager_methods;
+
+sub _sort_spec {
+  return (
+    default       => [ 'position', 1 ],
+    columns       => {
+      SIMPLE      => 'ALL',
+      description => 'lower(project_types.description)',
+    });
+}
+
+1;
+__END__
+
+=pod
+
+=encoding utf8
+
+=head1 NAME
+
+SL::DB::Manager::ProjectType - Manager for models for the 'project_types' table
+
+=head1 SYNOPSIS
+
+This is a standard Rose::DB::Manager based model manager and can be
+used as such.
+
+=head1 FUNCTIONS
+
+None yet.
+
+=head1 BUGS
+
+Nothing here yet.
+
+=head1 AUTHOR
+
+Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
+
+=cut
index 4805568abca2a9212cbab00a43e50dadc3cd2145..0524fb679a306085091c644bea9dc9c2dad0713c 100644 (file)
@@ -9,15 +9,16 @@ use base qw(SL::DB::Object);
 __PACKAGE__->meta->table('project');
 
 __PACKAGE__->meta->columns(
-  active        => { type => 'boolean', default => 'true' },
-  customer_id   => { type => 'integer' },
-  description   => { type => 'text' },
-  id            => { type => 'integer', not_null => 1, sequence => 'id' },
-  itime         => { type => 'timestamp', default => 'now()' },
-  mtime         => { type => 'timestamp' },
-  projectnumber => { type => 'text' },
-  type          => { type => 'text' },
-  valid         => { type => 'boolean', default => 'true' },
+  active          => { type => 'boolean', default => 'true' },
+  customer_id     => { type => 'integer' },
+  description     => { type => 'text' },
+  id              => { type => 'integer', not_null => 1, sequence => 'id' },
+  itime           => { type => 'timestamp', default => 'now()' },
+  mtime           => { type => 'timestamp' },
+  project_type_id => { type => 'integer', not_null => 1 },
+  projectnumber   => { type => 'text' },
+  type            => { type => 'text' },
+  valid           => { type => 'boolean', default => 'true' },
 );
 
 __PACKAGE__->meta->primary_key_columns([ 'id' ]);
@@ -31,6 +32,11 @@ __PACKAGE__->meta->foreign_keys(
     class       => 'SL::DB::Customer',
     key_columns => { customer_id => 'id' },
   },
+
+  project_type => {
+    class       => 'SL::DB::ProjectType',
+    key_columns => { project_type_id => 'id' },
+  },
 );
 
 1;
diff --git a/SL/DB/MetaSetup/ProjectType.pm b/SL/DB/MetaSetup/ProjectType.pm
new file mode 100644 (file)
index 0000000..5608f29
--- /dev/null
@@ -0,0 +1,22 @@
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::ProjectType;
+
+use strict;
+
+use base qw(SL::DB::Object);
+
+__PACKAGE__->meta->setup(
+  table   => 'project_types',
+
+  columns => [
+    id          => { type => 'serial', not_null => 1 },
+    position    => { type => 'integer', not_null => 1 },
+    description => { type => 'text' },
+  ],
+
+  primary_key_columns => [ 'id' ],
+);
+
+1;
+;
diff --git a/SL/DB/ProjectType.pm b/SL/DB/ProjectType.pm
new file mode 100644 (file)
index 0000000..6fec148
--- /dev/null
@@ -0,0 +1,29 @@
+package SL::DB::ProjectType;
+
+use strict;
+
+use SL::DB::MetaSetup::ProjectType;
+use SL::DB::Manager::ProjectType;
+
+use SL::DB::Helper::ActsAsList;
+
+__PACKAGE__->meta->add_relationship(
+  projects => {
+    type         => 'many to one',
+    class        => 'SL::DB::Project',
+    column_map   => { id => 'project_type_id' },
+  },
+);
+
+__PACKAGE__->meta->initialize;
+
+sub validate {
+  my ($self) = @_;
+
+  my @errors;
+  push @errors, $::locale->text('The description is missing.') if !$self->description;
+
+  return @errors;
+}
+
+1;
index dff08c87565777c21757c777efce8f56de8e6ceb..710a92bbff6dfd91c49777430c7913887880058e 100755 (executable)
@@ -516,8 +516,10 @@ $self->{texts} = {
   'Create a new payment term'   => 'Neue Zahlungsbedingungen anlegen',
   'Create a new printer'        => 'Einen neuen Drucker anlegen',
   'Create a new project'        => 'Neues Projekt anlegen',
+  'Create a new project type'   => 'Einen neuen Projekttypen anlegen',
   'Create a new user'           => 'Einen neuen Benutzer anlegen',
   'Create a new user group'     => 'Eine neue Benutzergruppe erfassen',
+  'Create a standard group'     => 'Eine Standard-Benutzergruppe anlegen',
   'Create and edit RFQs'        => 'Lieferantenanfragen erfassen und bearbeiten',
   'Create and edit dunnings'    => 'Mahnungen erfassen und bearbeiten',
   'Create and edit invoices and credit notes' => 'Rechnungen und Gutschriften erfassen und bearbeiten',
@@ -544,6 +546,7 @@ $self->{texts} = {
   'Create new department'       => 'Neue Abteilung erfassen',
   'Create new payment term'     => 'Neue Zahlungsbedingung anlegen',
   'Create new templates from master templates' => 'Neue Druckvorlagen aus Vorlagensatz erstellen',
+  'Create new project type'     => 'Neuen Projekttypen anlegen',
   'Create tables'               => 'Tabellen anlegen',
   'Created by'                  => 'Erstellt von',
   'Created for'                 => 'Erstellt f&uuml;r',
@@ -852,6 +855,7 @@ $self->{texts} = {
   'Edit prices and discount (if not used, textfield is ONLY set readonly)' => 'Preise und Rabatt in Formularen frei anpassen (falls deaktiviert, wird allerdings NUR das textfield auf READONLY gesetzt / kann je nach Browserversion und technischen Fähigkeiten des Anwenders noch umgangen werden)',
   'Edit project'                => 'Projekt bearbeiten',
   'Edit project #1'             => 'Projekt #1 bearbeiten',
+  'Edit project type'           => 'Projekttypen bearbeiten',
   'Edit templates'              => 'Vorlagen bearbeiten',
   'Edit the Delivery Order'     => 'Lieferschein bearbeiten',
   'Edit the configuration for periodic invoices' => 'Konfiguration für wiederkehrende Rechnungen bearbeiten',
@@ -1394,6 +1398,7 @@ $self->{texts} = {
   'No print templates have been created for this client yet. Please do so in the client configuration.' => 'Für diesen Mandanten wurden noch keine Druckvorlagen angelegt. Bitte holen Sie dies in der Mandantenkonfiguration nach.',
   'No printers have been created yet.' => 'Es wurden noch keine Drucker angelegt.',
   'No problems were recognized.' => 'Es wurden keine Probleme gefunden.',
+  'No project type has been created yet.' => 'Es wurden noch keine Projekttypen angelegt.',
   'No report with id #1'        => 'Es gibt keinen Report mit der Id #1',
   'No shipto selected to delete' => 'Keine Lieferadresse zum Löschen ausgewählt',
   'No summary account'          => 'Kein Sammelkonto',
@@ -1662,6 +1667,8 @@ $self->{texts} = {
   'Project Number'              => 'Projektnummer',
   'Project Numbers'             => 'Projektnummern',
   'Project Transactions'        => 'Projektbuchungen',
+  'Project Type'                => 'Projekttyp',
+  'Project Types'               => 'Projekttypen',
   'Project type'                => 'Projekttyp',
   'Projects'                    => 'Projekte',
   'Projecttransactions'         => 'Projektbuchungen',
@@ -2211,6 +2218,10 @@ $self->{texts} = {
   'The project is in use and cannot be deleted.' => 'Das Projekt ist in Verwendung und kann nicht gelöscht werden.',
   'The project number is already in use.' => 'Die Projektnummer wird bereits verwendet.',
   'The project number is missing.' => 'Die Projektnummer fehlt.',
+  'The project type has been created.' => 'Der Projekttyp wurde angelegt.',
+  'The project type has been deleted.' => 'Der Projekttyp wurde gelöscht.',
+  'The project type has been saved.' => 'Der Projekttyp wurde gespeichert.',
+  'The project type is in use and cannot be deleted.' => 'Der Projekttyp wird verwendet und kann nicht gelöscht werden.',
   'The second reason is that kivitendo allowed the user to enter the tax amount manually regardless of the taxkey used.' => 'Der zweite Grund war, dass kivitendo zuließ, dass die Benutzer beliebige, von den tatsächlichen Steuerschlüsseln unabhängige Steuerbeträge eintrugen.',
   'The second way is to use Perl\'s CPAN module and let it download and install the module for you.' => 'Die zweite Variante besteht darin, Perls CPAN-Modul zu benutzen und es das Modul f&uuml;r Sie installieren zu lassen.',
   'The selected bank account does not exist anymore.' => 'Das ausgewählte Bankkonto existiert nicht mehr.',
index c3793e6364e7a7c8a6517003f145ed3af3fd0802..a096dc6efcd36d16500c70c98c1eccf168e91f5e 100644 (file)
@@ -581,6 +581,10 @@ action=Business/list
 module=am.pl
 action=list_lead
 
+[System--Project Types]
+module=controller.pl
+action=ProjectType/list
+
 [System--Languages and translations]
 module=menu.pl
 action=acc_menu
diff --git a/sql/Pg-upgrade2/project_types.sql b/sql/Pg-upgrade2/project_types.sql
new file mode 100644 (file)
index 0000000..7d2c319
--- /dev/null
@@ -0,0 +1,25 @@
+-- @tag: project_types
+-- @description: Tabelle für Projekttypen
+-- @depends: release_3_0_0
+-- @charset: utf-8
+CREATE TABLE project_types (
+       id                       SERIAL,
+       position                 INTEGER NOT NULL,
+       description              TEXT,
+
+       PRIMARY KEY (id)
+);
+
+INSERT INTO project_types (position, description) VALUES (1, 'Standard');
+INSERT INTO project_types (position, description) VALUES (2, 'Festpreis');
+INSERT INTO project_types (position, description) VALUES (3, 'Support');
+
+ALTER TABLE project ADD COLUMN project_type_id INTEGER;
+ALTER TABLE project ADD FOREIGN KEY (project_type_id) REFERENCES project_types (id);
+
+UPDATE project SET project_type_id = (SELECT id FROM project_types WHERE description = 'Festpreis') WHERE type = 'Festpreis';
+UPDATE project SET project_type_id = (SELECT id FROM project_types WHERE description = 'Support')   WHERE type = 'Support';
+UPDATE project SET project_type_id = (SELECT id FROM project_types WHERE description = 'Standard')  WHERE project_type_id IS NULL;
+
+ALTER TABLE project ALTER COLUMN project_type_id SET NOT NULL;
+ALTER TABLE project DROP COLUMN type;
index d243afd5a889701356b8753a3c6ba662482d986a..9ec39e06f06daffcd965553f3e05c3fb37f7f1da 100644 (file)
@@ -42,8 +42,8 @@
      </tr>
 
      <tr>
-      <th align="right">[% 'Type' | $T8 %]</th>
-      <td>[% L.input_tag('project.type', SELF.project.type, size=60) %]</td>
+      <th align="right">[% 'Project Type' | $T8 %]</th>
+      <td>[% L.select_tag('project.project_type_id', ALL_PROJECT_TYPES, default=SELF.project.project_type_id, title_key='description', style='width: 300px') %]</td>
      </tr>
 
      <tr>
index 44bf0d850c209527d4a749c694dbe2f6d69b5f74..1f3e33b3d3091fdefd86869504af8df2e3cd29f2 100644 (file)
@@ -27,8 +27,8 @@
     </tr>
 
     <tr>
-     <th align="right">[% 'Type' | $T8 %]</th>
-     <td>[% L.input_tag('filter.type:substr::ilike', filter.type_substr__ilike, size=20) %]</td>
+     <th align="right">[% 'Project Type' | $T8 %]</th>
+     <td>[% L.select_tag('filter.project_type_id', ALL_PROJECT_TYPES, default=filter.project_type_id, title_key='description', with_empty=1) %]</td>
     </tr>
 
     [% CUSTOM_VARIABLES_FILTER_CODE %]
diff --git a/templates/webpages/project_type/form.html b/templates/webpages/project_type/form.html
new file mode 100755 (executable)
index 0000000..692cb4a
--- /dev/null
@@ -0,0 +1,25 @@
+[% USE HTML %][% USE L %][% USE LxERP %]
+
+ <form method="post" action="controller.pl">
+  <div class="listtop">[% FORM.title %]</div>
+
+[%- INCLUDE 'common/flash.html' %]
+
+  <table>
+   <tr>
+    <td>[% LxERP.t8('Description') %]</td>
+    <td>[% L.input_tag("project_type.description" SELF.project_type.description) %]</td>
+   </tr>
+  </table>
+
+  <p>
+   [% L.hidden_tag("id", SELF.project_type.id) %]
+   [% L.hidden_tag("action", "ProjectType/dispatch") %]
+   [% L.submit_tag("action_" _ (SELF.project_type.id ? 'update' : 'create'), LxERP.t8('Save')) %]
+   [%- IF SELF.project_type.id %]
+    [% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Do you really want to delete this object?')) %]
+   [%- END %]
+   <a href="[% SELF.url_for(action => 'list') %]">[% LxERP.t8('Abort') %]</a>
+  </p>
+
+ </form>
diff --git a/templates/webpages/project_type/list.html b/templates/webpages/project_type/list.html
new file mode 100644 (file)
index 0000000..fc45c0d
--- /dev/null
@@ -0,0 +1,42 @@
+[% USE HTML %][% USE T8 %][% USE L %][% USE LxERP %]
+
+ <div class="listtop">[% FORM.title %]</div>
+
+[%- INCLUDE 'common/flash.html' %]
+
+ <form method="post" action="controller.pl">
+  [% IF !PROJECT_TYPES.size %]
+   <p>
+    [%- 'No project type has been created yet.' | $T8 %]
+   </p>
+
+  [%- ELSE %]
+   <table id="project_type_list">
+    <thead>
+    <tr class="listheading">
+     <th align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></th>
+     <th>[%- 'Description' | $T8 %]</th>
+    </tr>
+    </thead>
+
+    <tbody>
+    [%- FOREACH project_type = PROJECT_TYPES %]
+    <tr class="listrow[% loop.count % 2 %]" id="project_type_id_[% project_type.id %]">
+     <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
+     <td>
+      <a href="[% SELF.url_for(action => 'edit', id => project_type.id) %]">
+       [%- HTML.escape(project_type.description) %]
+      </a>
+     </td>
+    </tr>
+    [%- END %]
+    </tbody>
+   </table>
+  [%- END %]
+
+  <p>
+   <a href="[% SELF.url_for(action => 'new') %]">[%- 'Create new project type' | $T8 %]</a>
+  </p>
+ </form>
+
+ [% L.sortable_element('#project_type_list tbody', url => 'controller.pl?action=ProjectType/reorder', with => 'project_type_id') %]