]> wagnertech.de Git - kivitendo-erp.git/commitdiff
CSV-Import: Projekte
authorThomas Heck <theck@linet-services.de>
Tue, 21 Aug 2012 08:15:38 +0000 (10:15 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Wed, 22 Aug 2012 11:32:15 +0000 (13:32 +0200)
implementiert #1907

SL/Controller/CsvImport.pm
SL/Controller/CsvImport/Project.pm [new file with mode: 0644]
SL/DB/Project.pm
locale/de/all
menu.ini

index e603faa407023b7b25b55eabfc60769c9a65b73f..d924f07d98c80de81a85d7aff5aef48be1165126 100644 (file)
@@ -11,6 +11,7 @@ use SL::Controller::CsvImport::Contact;
 use SL::Controller::CsvImport::CustomerVendor;
 use SL::Controller::CsvImport::Part;
 use SL::Controller::CsvImport::Shipto;
+use SL::Controller::CsvImport::Project;
 
 use List::MoreUtils qw(none);
 
@@ -99,7 +100,7 @@ sub check_auth {
 sub check_type {
   my ($self) = @_;
 
-  die "Invalid CSV import type" if none { $_ eq $::form->{profile}->{type} } qw(parts customers_vendors addresses contacts);
+  die "Invalid CSV import type" if none { $_ eq $::form->{profile}->{type} } qw(parts customers_vendors addresses contacts projects);
   $self->type($::form->{profile}->{type});
 }
 
@@ -141,6 +142,7 @@ sub render_inputs {
             : $self->type eq 'addresses'         ? $::locale->text('CSV import: shipping addresses')
             : $self->type eq 'contacts'          ? $::locale->text('CSV import: contacts')
             : $self->type eq 'parts'             ? $::locale->text('CSV import: parts and services')
+            : $self->type eq 'projects'          ? $::locale->text('CSV import: projects')
             : die;
 
   if ($self->{type} eq 'parts') {
@@ -258,6 +260,7 @@ sub create_worker {
        : $self->{type} eq 'contacts'          ? SL::Controller::CsvImport::Contact->new(       controller => $self, file => $file)
        : $self->{type} eq 'addresses'         ? SL::Controller::CsvImport::Shipto->new(        controller => $self, file => $file)
        : $self->{type} eq 'parts'             ? SL::Controller::CsvImport::Part->new(          controller => $self, file => $file)
+       : $self->{type} eq 'projects'          ? SL::Controller::CsvImport::Project->new(       controller => $self, file => $file)
        :                                        die "Program logic error";
 }
 
diff --git a/SL/Controller/CsvImport/Project.pm b/SL/Controller/CsvImport/Project.pm
new file mode 100644 (file)
index 0000000..8367fbe
--- /dev/null
@@ -0,0 +1,76 @@
+package SL::Controller::CsvImport::Project;
+
+use strict;
+
+use SL::Helper::Csv;
+use SL::DB::CustomVariable;
+use SL::DB::CustomVariableConfig;
+
+use parent qw(SL::Controller::CsvImport::Base);
+
+use Rose::Object::MakeMethods::Generic
+(
+ scalar => [ qw(table) ],
+);
+
+sub init_class {
+  my ($self) = @_;
+  $self->class('SL::DB::Project');
+}
+
+sub init_all_cvar_configs {
+  my ($self) = @_;
+
+  return SL::DB::Manager::CustomVariableConfig->get_all(where => [ module => 'Projects' ]);
+}
+
+sub check_objects {
+  my ($self) = @_;
+
+  foreach my $entry (@{ $self->controller->data }) {
+    $self->handle_cvars($entry);
+  }
+
+  $self->add_cvar_raw_data_columns;
+}
+
+sub check_duplicates {
+  my $self = shift;
+
+  my %duplicates_by_number;
+
+  if ( $self->controller->profile->get('duplicates') eq 'check_db' ) {
+    foreach my $object (@{$self->existing_objects}) {
+      $duplicates_by_number{$object->{projectnumber}} = 'db';
+    }
+  }
+
+  foreach my $entry (@{ $self->controller->data }) {
+
+    my $object = $entry->{object};
+
+    if ( $duplicates_by_number{$object->projectnumber()} )
+    {
+      push( @{$entry->{errors}},
+            $duplicates_by_number{$object->projectnumber()} eq 'db' ? $::locale->text('Duplicate in database') : $::locale->text('Duplicate in CSV file')
+      );
+    } else {
+      $duplicates_by_number{$object->projectnumber()} = 'csv';
+    }
+
+  }
+}
+
+sub setup_displayable_columns {
+  my ($self) = @_;
+
+  $self->SUPER::setup_displayable_columns;
+  $self->add_cvar_columns_to_displayable_columns;
+
+  $self->add_displayable_columns({ name => 'projectnumber', description => $::locale->text('number') },
+                                 { name => 'description',   description => $::locale->text('Description') },
+                                 { name => 'active',        description => $::locale->text('Active') },
+                                );
+}
+
+1;
index 4b93c5ac70e4522137a4230df8cad58fc2c59fe7..1d1f1c4a8ec537da9d00f21a13424cfd474c53a0 100644 (file)
@@ -4,7 +4,13 @@ use strict;
 
 use SL::DB::MetaSetup::Project;
 
+use SL::DB::Helper::CustomVariables(
+  module      => 'Project',
+  cvars_alias => 1,
+);
+
 __PACKAGE__->meta->make_manager_class;
+__PACKAGE__->meta->initialize;
 
 1;
 
index 394de3295a1ccd8710f7e540c9d0f6798ce8c0da..8060572edfa3bdcaf19898dc9f31d2c3550933b5 100644 (file)
@@ -333,6 +333,7 @@ $self->{texts} = {
   'CSV import: contacts'        => 'CSV-Import: Ansprechpersonen',
   'CSV import: customers and vendors' => 'CSV-Import: Kunden und Lieferanten',
   'CSV import: parts and services' => 'CSV-Import: Waren und Dienstleistungen',
+  'CSV import: projects'        => 'CSV-Import: Projekte',
   'CSV import: shipping addresses' => 'CSV-Import: Lieferadressen',
   'Calculate'                   => 'Berechnen',
   'Calendar'                    => 'Kalender',
@@ -941,8 +942,6 @@ $self->{texts} = {
   'If you select a base unit then you also have to enter a factor.' => 'Wenn Sie eine Basiseinheit auswählen, dann müssen Sie auch einen Faktor eingeben.',
   'If you want to change any of these parameters then press the &quot;Back&quot; button, edit the file &quot;config/lx_office.conf&quot; and login into the admin module again.' => 'Wenn Sie einen der Parameter &auml;ndern wollen, so dr&uuml;cken Sie auf den &quot;Zur&uuml;ck&quot;-Button, bearbeiten Sie die Datei &quot;config/lx_office.conf&quot;, und melden Sie sich erneut im Administrationsbereich an.',
   'If you want to delete such a dataset you have to edit the user(s) that are using the dataset in question and have them use another dataset.' => 'Wenn Sie eine solche Datenbank l&ouml;schen wollen, so m&uuml;ssen Sie zuerst die Benutzer bearbeiten, die die fragliche Datenbank benutzen, und sie so &auml;ndern, dass sie eine andere Datenbank benutzen.',
-  'If you want to set up the authentication database yourself then log in to the administration panel. kivitendo will then create the database and tables for you.' => 'Wenn Sie die Authentifizierungsdatenbank selber einrichten wollen, so melden Sie sich an der Administrationsoberfl&auml;che an. kivitendo wird dann die Datenbank und die Tabellen f&uuml;r Sie anlegen.',
-  'If you yourself want to upgrade the installation then please read the file &quot;doc/UPGRADE&quot; and follow the steps outlined in this file.' => 'Wenn Sie selber die Aktualisierung bzw. Einrichtung &uuml;bernehmen wollen, so lesen Sie bitte die Datei &quot;doc/UPGRADE&quot; und folgen Sie den dort beschriebenen Schritten.',
   'Image'                       => 'Grafik',
   'Import'                      => 'Import',
   'Import CSV'                  => 'CSV-Import',
@@ -969,6 +968,7 @@ $self->{texts} = {
   'Incoming Payments'           => 'Zahlungseingänge',
   'Incoming invoice number'     => 'Eingangsrechnungsnummer',
   'Incorrect Password!'         => 'Ungültiges Passwort!',
+  'Incorrect password!'         => '',
   'Incorrect username or password!' => 'Ungültiger Benutzername oder falsches Passwort!',
   'Increase'                    => 'Erhöhen',
   'Individual Items'            => 'Einzelteile',
@@ -1798,8 +1798,6 @@ $self->{texts} = {
   'The application "#1" was not found on the system.' => 'Die Anwendung "#1" wurde auf dem System nicht gefunden.',
   'The assembly has been created.' => 'Das Erzeugnis wurde hergestellt.',
   'The assistant could not find anything wrong with #1. Maybe the problem has been solved in the meantime.' => 'Der Korrekturassistent konnte kein Problem bei #1 feststellen. Eventuell wurde das Problem in der Zwischenzeit bereits behoben.',
-  'The authentication configuration file &quot;config/lx_office.conf&quot; does not exist. This kivitendo installation has probably not been updated correctly yet. Please contact your administrator.' => '',
-  'The authentication database is not reachable at the moment. Either it hasn\'t been set up yet or the database server might be down. Please contact your administrator.' => 'Die Authentifizierungsdatenbank kann momentan nicht erreicht werden. Entweder wurde sie noch nicht eingerichtet, oder der Datenbankserver antwortet nicht. Bitte wenden Sie sich an Ihren Administrator.',
   'The available options depend on the varibale type:' => 'Die verf&uuml;gbaren Optionen h&auml;ngen vom Variablentypen ab:',
   'The backup you upload here has to be a file created with &quot;pg_dump -o -Ft&quot;.' => 'Die von Ihnen hochzuladende Sicherungsdatei muss mit dem Programm und den Parametern &quot;pg_dump -o -Ft&quot; erstellt worden sein.',
   'The bank information must not be empty.' => 'Die Bankinformationen müssen vollständig ausgefüllt werden.',
@@ -2148,7 +2146,6 @@ $self->{texts} = {
   'You cannot continue until all unknown units have been mapped to known ones.' => 'Sie k&ouml;nnen nicht fortfahren, bis alle unbekannten Einheiten in neue Einheiten umgewandelt wurden.',
   'You cannot create an invoice for delivery orders for different customers.' => 'Sie können keine Rechnung zu Lieferscheinen für verschiedene Kunden erstellen.',
   'You cannot create an invoice for delivery orders from different vendors.' => 'Sie können keine Rechnung aus Lieferscheinen von verschiedenen Lieferanten erstellen.',
-  'You did not enter a name!'   => 'Sie haben keinen Namen eingegeben!',
   'You do not have the permissions to access this function.' => 'Sie verf&uuml;gen nicht &uuml;ber die notwendigen Rechte, um auf diese Funktion zuzugreifen.',
   'You have entered or selected the following shipping address for this customer:' => 'Sie haben die folgende Lieferadresse eingegeben oder ausgew&auml;hlt:',
   'You have not added bank accounts yet.' => 'Sie haben noch keine Bankkonten angelegt.',
index 587376bf30752e3790ae597ff10a1a73dfdf41f4..0f8a3e453334b0da9ea200293df5fc08eb515b9e 100644 (file)
--- a/menu.ini
+++ b/menu.ini
@@ -758,6 +758,10 @@ module=controller.pl
 action=CsvImport/new
 profile.type=parts
 
+[System--Import CSV--Projects]
+module=controller.pl
+action=CsvImport/new
+profile.type=projects
 
 [System--Templates]
 ACCESS=admin