From: Sven Schöling Date: Thu, 17 Oct 2013 11:53:38 +0000 (+0200) Subject: Projektstatus Controller X-Git-Tag: release-3.2.0beta~467^2~62 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=aaa2cd9291719d6a8f327606fc5aeeeb172b7ecb;p=kivitendo-erp.git Projektstatus Controller --- diff --git a/SL/Controller/ProjectStatus.pm b/SL/Controller/ProjectStatus.pm new file mode 100644 index 000000000..686f75c0b --- /dev/null +++ b/SL/Controller/ProjectStatus.pm @@ -0,0 +1,112 @@ +package SL::Controller::ProjectStatus; + +use strict; + +use parent qw(SL::Controller::Base); + +use SL::DB::ProjectStatus; +use SL::Helper::Flash; + +use Rose::Object::MakeMethods::Generic +( + scalar => [ qw(project_status) ], +); + +__PACKAGE__->run_before('check_auth'); +__PACKAGE__->run_before('load_project_status', only => [ qw(edit update destroy) ]); + +# +# actions +# + +sub action_list { + my ($self) = @_; + + $self->render('project_status/list', + title => $::locale->text('Project Status'), + PROJECT_STATUS => SL::DB::Manager::ProjectStatus->get_all_sorted); +} + +sub action_new { + my ($self) = @_; + + $self->{project_status} = SL::DB::ProjectStatus->new; + $self->render('project_status/form', title => $::locale->text('Create a new project status')); +} + +sub action_edit { + my ($self) = @_; + $self->render('project_status/form', title => $::locale->text('Edit project status')); +} + +sub action_create { + my ($self) = @_; + + $self->{project_status} = SL::DB::ProjectStatus->new; + $self->create_or_update; +} + +sub action_update { + my ($self) = @_; + $self->create_or_update; +} + +sub action_destroy { + my ($self) = @_; + + if (eval { $self->{project_status}->delete; 1; }) { + flash_later('info', $::locale->text('The project status has been deleted.')); + } else { + flash_later('error', $::locale->text('The project status is in use and cannot be deleted.')); + } + + $self->redirect_to(action => 'list'); +} + +sub action_reorder { + my ($self) = @_; + + SL::DB::ProjectStatus->reorder_list(@{ $::form->{project_status_id} || [] }); + + $self->render(\'', { type => 'json' }); +} + +# +# filters +# + +sub check_auth { + $::auth->assert('config'); +} + +# +# helpers +# + +sub create_or_update { + my $self = shift; + my $is_new = !$self->{project_status}->id; + my $params = delete($::form->{project_status}) || { }; + + $self->{project_status}->assign_attributes(%{ $params }); + + my @errors = $self->{project_status}->validate; + + if (@errors) { + flash('error', @errors); + $self->render('project_status/form', title => $is_new ? $::locale->text('Create a new project status') : $::locale->text('Edit project status')); + return; + } + + $self->{project_status}->save; + + flash_later('info', $is_new ? $::locale->text('The project status has been created.') : $::locale->text('The project status has been saved.')); + $self->redirect_to(action => 'list'); +} + +sub load_project_status { + my ($self) = @_; + $self->{project_status} = SL::DB::ProjectStatus->new(id => $::form->{id})->load; +} + +1; diff --git a/locale/de/all b/locale/de/all index 1fd0ad6da..b69fff843 100755 --- a/locale/de/all +++ b/locale/de/all @@ -562,6 +562,7 @@ $self->{texts} = { 'Create a new predefined text' => 'Einen neuen vordefinierten Textblock anlegen', 'Create a new printer' => 'Einen neuen Drucker anlegen', 'Create a new project' => 'Neues Projekt anlegen', + 'Create a new project status' => 'Einen neuen Projektstatus anlegen', 'Create a new project type' => 'Einen neuen Projekttypen anlegen', 'Create a new requirement spec' => 'Ein neues Pflichtenheft anlegen', 'Create a new requirement spec status' => 'Einen neuen Pflichtenheftstatus anlegen', @@ -933,6 +934,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 status' => 'Projektstatus bearbeiten', 'Edit project type' => 'Projekttypen bearbeiten', 'Edit requirement spec' => 'Pflichtenheft bearbeiten', 'Edit requirement spec status' => 'Pflichtenheftstatus bearbeiten', @@ -1510,6 +1512,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 status has been created yet.' => 'Es wurde noch kein Projektstatus angelegt.', 'No project type has been created yet.' => 'Es wurden noch keine Projekttypen angelegt.', 'No quotations or orders have been created yet.' => 'Es wurden noch keine Angebote oder Aufträge angelegt.', 'No report with id #1' => 'Es gibt keinen Report mit der Id #1', @@ -2427,6 +2430,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 status has been created.' => 'Der Projektstatus wurde angelegt.', + 'The project status has been deleted.' => 'Der Projektstatus wurde gelöscht.', + 'The project status has been saved.' => 'Der Projektstatus wurde gespeichert.', + 'The project status is in use and cannot be deleted.' => 'Der Projektstatus wird verwendet und kann nicht gelöscht werden.', '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.', diff --git a/menus/erp.ini b/menus/erp.ini index 5a1c33d2b..b700dd6a1 100644 --- a/menus/erp.ini +++ b/menus/erp.ini @@ -606,6 +606,10 @@ action=list_lead module=controller.pl action=ProjectType/list +[System--Project Status] +module=controller.pl +action=ProjectStatus/list + [System--Requirement specs] module=menu.pl action=acc_menu diff --git a/templates/webpages/project_status/form.html b/templates/webpages/project_status/form.html new file mode 100644 index 000000000..c331fba99 --- /dev/null +++ b/templates/webpages/project_status/form.html @@ -0,0 +1,29 @@ +[% USE HTML %][% USE L %][% USE LxERP %] + +
+
[% FORM.title %]
+ +[%- INCLUDE 'common/flash.html' %] + + + + + + + + + + +
[% LxERP.t8('Name') %][% L.input_tag("project_status.name" SELF.project_status.name) %]
[% LxERP.t8('Description') %][% L.input_tag("project_status.description" SELF.project_status.description) %]
+ +

+ [% L.hidden_tag("id", SELF.project_status.id) %] + [% L.hidden_tag("action", "ProjectStatus/dispatch") %] + [% L.submit_tag("action_" _ (SELF.project_status.id ? 'update' : 'create'), LxERP.t8('Save')) %] + [%- IF SELF.project_status.id %] + [% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Do you really want to delete this object?')) %] + [%- END %] + [% LxERP.t8('Abort') %] +

+ +
diff --git a/templates/webpages/project_status/list.html b/templates/webpages/project_status/list.html new file mode 100644 index 000000000..d8fd7461d --- /dev/null +++ b/templates/webpages/project_status/list.html @@ -0,0 +1,40 @@ +[% USE HTML %][% USE T8 %][% USE L %][% USE LxERP %] + +
[% FORM.title %]
+ +[%- INCLUDE 'common/flash.html' %] + +
+ [% IF !PROJECT_STATUS.size %] +

+ [%- 'No project status has been created yet.' | $T8 %] +

+ + [%- ELSE %] + + + + + + + + + + + [%- FOREACH project_status = PROJECT_STATUS %] + + + + + + [%- END %] + +
[ LxERP.t8('reorder item') %][%- 'Name' | $T8 %][%- 'Description' | $T8 %]
[ LxERP.t8('reorder item') %][% project_status.name | html %][% project_status.description | html %]
+ [%- END %] + +

+ [%- 'Create a new project status' | $T8 %] +

+
+ + [% L.sortable_element('#project_status_list tbody', url => 'controller.pl?action=ProjectStatus/reorder', with => 'project_status_id') %]