From 1600ef672b02029ef3bb2ab940c0954820ef47b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 3 May 2013 17:58:33 +0200 Subject: [PATCH] Projekte: Templates und get_linked_records etwas entzerrt --- SL/Controller/Project.pm | 23 ++++--- templates/webpages/project/_basic_data.html | 45 +++++++++++++ templates/webpages/project/_cvars.html | 9 +++ .../webpages/project/_linked_records.html | 2 + templates/webpages/project/form.html | 63 +++---------------- 5 files changed, 77 insertions(+), 65 deletions(-) create mode 100644 templates/webpages/project/_basic_data.html create mode 100644 templates/webpages/project/_cvars.html create mode 100644 templates/webpages/project/_linked_records.html diff --git a/SL/Controller/Project.pm b/SL/Controller/Project.pm index d6a63759d..64e33a036 100644 --- a/SL/Controller/Project.pm +++ b/SL/Controller/Project.pm @@ -71,15 +71,7 @@ sub action_new { sub action_edit { my ($self) = @_; - $self->linked_records([ - map { @{ $_ } } - grep { $_ } ( - SL::DB::Manager::Order-> get_all(where => [ globalproject_id => $self->project->id ], with_objects => [ 'customer', 'vendor' ], sort_by => 'transdate ASC'), - SL::DB::Manager::DeliveryOrder-> get_all(where => [ globalproject_id => $self->project->id ], with_objects => [ 'customer', 'vendor' ], sort_by => 'transdate ASC'), - SL::DB::Manager::Invoice-> get_all(where => [ globalproject_id => $self->project->id ], with_objects => [ 'customer' ], sort_by => 'transdate ASC'), - SL::DB::Manager::PurchaseInvoice->get_all(where => [ globalproject_id => $self->project->id ], with_objects => [ 'vendor' ], sort_by => 'transdate ASC'), - )]); - + $self->get_linked_records; $self->display_form(title => $::locale->text('Edit project #1', $self->project->projectnumber), callback => $::form->{callback} || $self->url_for(action => 'edit', id => $self->project->id)); } @@ -176,6 +168,19 @@ sub load_project { $self->project(SL::DB::Project->new(id => $::form->{id})->load); } +sub get_linked_records { + my ($self) = @_; + + $self->linked_records([ + map { @{ $_ } } + grep { $_ } ( + SL::DB::Manager::Order-> get_all(where => [ globalproject_id => $self->project->id ], with_objects => [ 'customer', 'vendor' ], sort_by => 'transdate ASC'), + SL::DB::Manager::DeliveryOrder-> get_all(where => [ globalproject_id => $self->project->id ], with_objects => [ 'customer', 'vendor' ], sort_by => 'transdate ASC'), + SL::DB::Manager::Invoice-> get_all(where => [ globalproject_id => $self->project->id ], with_objects => [ 'customer' ], sort_by => 'transdate ASC'), + SL::DB::Manager::PurchaseInvoice->get_all(where => [ globalproject_id => $self->project->id ], with_objects => [ 'vendor' ], sort_by => 'transdate ASC'), + )]); +} + sub setup_db_args_from_filter { my ($self) = @_; diff --git a/templates/webpages/project/_basic_data.html b/templates/webpages/project/_basic_data.html new file mode 100644 index 000000000..a278356a7 --- /dev/null +++ b/templates/webpages/project/_basic_data.html @@ -0,0 +1,45 @@ +[%- USE T8 %] +[%- USE L %] +[%- USE P %] +[%- USE HTML %] +[%- USE LxERP %] + + + + + + + + + + + + + + + + + + + + + + + + + + + [%- IF SELF.project.id %] + + + + + [%- END %] +
[% 'Number' | $T8 %][% L.input_tag("project.projectnumber", SELF.project.projectnumber, size=60, class="initial_focus") %]
[% 'Description' | $T8 %] + [%- SET rows = LxERP.numtextrows(SELF.project.description, 60) %] + [%- IF rows > 1 %] + [%- L.textarea_tag("project.description", SELF.project.description, rows=row, size=60, style="width: 100%", wrap="soft") %] + [%- ELSE %] + [%- L.input_tag("project.description", SELF.project.description, size=60) %] + [%- END %] +
[% 'Project Type' | $T8 %][% L.select_tag('project.project_type_id', ALL_PROJECT_TYPES, default=SELF.project.project_type_id, title_key='description', style='width: 300px') %]
[% 'Customer' | $T8 %][% L.select_tag('project.customer_id', ALL_CUSTOMERS, default=SELF.project.customer_id, title_key='name', with_empty=1, style='width: 300px') %]
[% 'Valid' | $T8 %][% L.select_tag('project.valid', [ [ 1, LxERP.t8('Valid') ], [ 0, LxERP.t8('Invalid') ] ], default=SELF.project.valid, style='width: 300px') %]
[% 'Active' | $T8 %][% L.select_tag('project.active', [ [ 1, LxERP.t8('Active') ], [ 0, LxERP.t8('Inactive') ] ], default=SELF.project.active, style='width: 300px') %]
diff --git a/templates/webpages/project/_cvars.html b/templates/webpages/project/_cvars.html new file mode 100644 index 000000000..5533b0e52 --- /dev/null +++ b/templates/webpages/project/_cvars.html @@ -0,0 +1,9 @@ +[%- USE HTML %] + +[%- FOREACH var = CUSTOM_VARIABLES %] + + + + +[%- END %] +
[% HTML.escape(var.description) %][% var.HTML_CODE %]
diff --git a/templates/webpages/project/_linked_records.html b/templates/webpages/project/_linked_records.html new file mode 100644 index 000000000..e7057ac17 --- /dev/null +++ b/templates/webpages/project/_linked_records.html @@ -0,0 +1,2 @@ +[%- USE P %] + [% P.grouped_record_list(records) %] diff --git a/templates/webpages/project/form.html b/templates/webpages/project/form.html index 52cd78221..c93a768c7 100644 --- a/templates/webpages/project/form.html +++ b/templates/webpages/project/form.html @@ -1,7 +1,8 @@ [%- USE T8 %] -[%- USE L %][%- USE P %] -[%- USE HTML %][%- USE LxERP %] - +[%- USE L %] +[%- USE P %] +[%- USE HTML %] +[%- USE LxERP %]

[% title %]

[%- INCLUDE 'common/flash.html' %] @@ -22,68 +23,18 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - [%- IF SELF.project.id %] - - - - - [%- END %] -
[% 'Number' | $T8 %][% L.input_tag("project.projectnumber", SELF.project.projectnumber, size=60, class='initial_focus') %]
[% 'Description' | $T8 %] - [%- SET rows = LxERP.numtextrows(SELF.project.description, 60) %] - [%- IF rows > 1 %] - [%- L.textarea_tag("project.description", SELF.project.description, rows=row, size=60, style="width: 100%", wrap="soft") %] - [%- ELSE %] - [%- L.input_tag("project.description", SELF.project.description, size=60) %] - [%- END %] -
[% 'Project Type' | $T8 %][% L.select_tag('project.project_type_id', ALL_PROJECT_TYPES, default=SELF.project.project_type_id, title_key='description', style='width: 300px') %]
[% 'Customer' | $T8 %][% L.select_tag('project.customer_id', ALL_CUSTOMERS, default=SELF.project.customer_id, title_key='name', with_empty=1, style='width: 300px') %]
[% 'Valid' | $T8 %][% L.select_tag('project.valid', [ [ 1, LxERP.t8('Valid') ], [ 0, LxERP.t8('Invalid') ] ], default=SELF.project.valid, style='width: 300px') %]
[% 'Active' | $T8 %][% L.select_tag('project.active', [ [ 1, LxERP.t8('Active') ], [ 0, LxERP.t8('Inactive') ] ], default=SELF.project.active, style='width: 300px') %]
+ [%- PROCESS 'project/_basic_data.html' %]
[%- IF CUSTOM_VARIABLES.size %]
- -

- - [%- FOREACH var = CUSTOM_VARIABLES %] - - - - - [%- END %] -
[% HTML.escape(var.description) %][% var.HTML_CODE %]
-

+ [%- PROCESS 'project/_cvars.html' %]
[%- END %] [%- IF SELF.project.id %]
- [% P.grouped_record_list(SELF.linked_records) %] + [%- PROCESS 'project/_linked_records.html' records=SELF.linked_records %]
[%- END %] -- 2.20.1