Projekte: Templates und get_linked_records etwas entzerrt
authorSven Schöling <s.schoeling@linet-services.de>
Fri, 3 May 2013 15:58:33 +0000 (17:58 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 1 Apr 2014 11:03:20 +0000 (13:03 +0200)
SL/Controller/Project.pm
templates/webpages/project/_basic_data.html [new file with mode: 0644]
templates/webpages/project/_cvars.html [new file with mode: 0644]
templates/webpages/project/_linked_records.html [new file with mode: 0644]
templates/webpages/project/form.html

index d6a6375..64e33a0 100644 (file)
@@ -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 (file)
index 0000000..a278356
--- /dev/null
@@ -0,0 +1,45 @@
+[%- USE T8 %]
+[%- USE L %]
+[%- USE P %]
+[%- USE HTML %]
+[%- USE LxERP %]
+<table>
+ <tr>
+  <th align="right">[% 'Number' | $T8 %]</th>
+  <td>[% L.input_tag("project.projectnumber", SELF.project.projectnumber, size=60, class="initial_focus") %]</td>
+ </tr>
+
+ <tr>
+  <th align="right">[% 'Description' | $T8 %]</th>
+  <td>
+   [%- 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 %]
+  </td>
+ </tr>
+
+ <tr>
+  <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>
+  <th align="right">[% 'Customer' | $T8 %]</th>
+  <td>[% L.select_tag('project.customer_id', ALL_CUSTOMERS, default=SELF.project.customer_id, title_key='name', with_empty=1, style='width: 300px') %]</td>
+ </tr>
+
+ <tr>
+  <th align="right">[% 'Valid' | $T8 %]</th>
+  <td>[% L.select_tag('project.valid', [ [ 1, LxERP.t8('Valid') ], [ 0, LxERP.t8('Invalid') ] ], default=SELF.project.valid, style='width: 300px') %]</td>
+ </tr>
+
+ [%- IF SELF.project.id %]
+ <tr>
+  <th align="right">[% 'Active' | $T8 %]</th>
+  <td>[% L.select_tag('project.active', [ [ 1, LxERP.t8('Active') ], [ 0, LxERP.t8('Inactive') ] ], default=SELF.project.active, style='width: 300px') %]</td>
+ </tr>
+ [%- END %]
+</table>
diff --git a/templates/webpages/project/_cvars.html b/templates/webpages/project/_cvars.html
new file mode 100644 (file)
index 0000000..5533b0e
--- /dev/null
@@ -0,0 +1,9 @@
+[%- USE HTML  %]
+<table>
+[%- FOREACH var = CUSTOM_VARIABLES %]
+<tr>
+ <td align="right" valign="top">[% HTML.escape(var.description) %]</td>
+ <td valign="top">[% var.HTML_CODE %]</td>
+</tr>
+[%- END %]
+</table>
diff --git a/templates/webpages/project/_linked_records.html b/templates/webpages/project/_linked_records.html
new file mode 100644 (file)
index 0000000..e7057ac
--- /dev/null
@@ -0,0 +1,2 @@
+[%- USE P %]
+ [% P.grouped_record_list(records) %]
index 52cd782..c93a768 100644 (file)
@@ -1,7 +1,8 @@
 [%- USE T8 %]
-[%- USE L %][%- USE P %]
-[%- USE HTML %][%- USE LxERP %]
-
+[%- USE L %]
+[%- USE P %]
+[%- USE HTML %]
+[%- USE LxERP %]
 <h1>[% title %]</h1>
 
 [%- INCLUDE 'common/flash.html' %]
    </ul>
 
    <div id="basic_data">
-
-    <table>
-     <tr>
-      <th align="right">[% 'Number' | $T8 %]</th>
-      <td>[% L.input_tag("project.projectnumber", SELF.project.projectnumber, size=60, class='initial_focus') %]</td>
-     </tr>
-
-     <tr>
-      <th align="right">[% 'Description' | $T8 %]</th>
-      <td>
-       [%- 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 %]
-      </td>
-     </tr>
-
-     <tr>
-      <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>
-      <th align="right">[% 'Customer' | $T8 %]</th>
-      <td>[% L.select_tag('project.customer_id', ALL_CUSTOMERS, default=SELF.project.customer_id, title_key='name', with_empty=1, style='width: 300px') %]</td>
-     </tr>
-
-     <tr>
-      <th align="right">[% 'Valid' | $T8 %]</th>
-      <td>[% L.select_tag('project.valid', [ [ 1, LxERP.t8('Valid') ], [ 0, LxERP.t8('Invalid') ] ], default=SELF.project.valid, style='width: 300px') %]</td>
-     </tr>
-
-     [%- IF SELF.project.id %]
-     <tr>
-      <th align="right">[% 'Active' | $T8 %]</th>
-      <td>[% L.select_tag('project.active', [ [ 1, LxERP.t8('Active') ], [ 0, LxERP.t8('Inactive') ] ], default=SELF.project.active, style='width: 300px') %]</td>
-     </tr>
-     [%- END %]
-    </table>
+   [%- PROCESS 'project/_basic_data.html' %]
    </div>
 
    [%- IF CUSTOM_VARIABLES.size %]
    <div id="custom_variables">
-
-    <p>
-     <table>
-      [%- FOREACH var = CUSTOM_VARIABLES %]
-      <tr>
-       <td align="right" valign="top">[% HTML.escape(var.description) %]</td>
-       <td valign="top">[% var.HTML_CODE %]</td>
-      </tr>
-      [%- END %]
-     </table>
-    </p>
+   [%- PROCESS 'project/_cvars.html' %]
    </div>
    [%- END %]
 
    [%- IF SELF.project.id %]
    <div id="linked_records">
-    [% P.grouped_record_list(SELF.linked_records) %]
+   [%- PROCESS 'project/_linked_records.html' records=SELF.linked_records %]
    </div>
    [%- END %]