Debitorenbuchung - Abteilung nutzt immer L.select_tag als Dropdown
authorG. Richardson <information@kivitendo-premium.de>
Fri, 23 Dec 2016 08:15:25 +0000 (09:15 +0100)
committerG. Richardson <information@kivitendo-premium.de>
Tue, 27 Dec 2016 12:02:24 +0000 (13:02 +0100)
SL/AR.pm
bin/mozilla/ar.pl
templates/webpages/ar/form_header.html
templates/webpages/ar/search.html

index e5ae896..5f7fadd 100644 (file)
--- a/SL/AR.pm
+++ b/SL/AR.pm
@@ -125,9 +125,6 @@ sub _post_transaction {
     }
   }
 
-  # update department
-  ($null, $form->{department_id}) = split(/--/, $form->{department});
-
   # amount for AR account
   $form->{receivables} = $form->round_amount($form->{amount}, 2) * -1;
 
@@ -533,14 +530,8 @@ sub ar_transactions {
     push(@values, $business_id);
   }
   if ($form->{department_id}) {
-    my $department_id = $form->{department_id};
     $where .= " AND a.department_id = ?";
-    push(@values, $department_id);
-  }
-  if ($form->{department}) {
-    my $department = like($form->{department});
-    $where .= " AND d.description ILIKE ?";
-    push(@values, $department);
+    push(@values, $form->{department_id});
   }
   foreach my $column (qw(invnumber ordnumber cusordnumber notes transaction_description)) {
     if ($form->{$column}) {
index 3b94d81..7456cd5 100644 (file)
@@ -181,16 +181,7 @@ sub create_links {
       (@{ $form->{all_customer} });
   }
 
-  # departments
-  if (@{ $form->{all_departments} || [] }) {
-    $form->{selectdepartment} = "<option>\n";
-    $form->{department}       = "$form->{department}--$form->{department_id}";
-
-    map {
-      $form->{selectdepartment} .=
-        "<option>$_->{description}--$_->{id}\n"
-    } (@{ $form->{all_departments} || [] });
-  }
+  $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
 
   $form->{employee} = "$form->{employee}--$form->{employee_id}";
 
@@ -226,7 +217,7 @@ sub form_header {
   $form->{invoice_obj} = _retrieve_invoice_object();
 
   my ($title, $readonly, $exchangerate, $rows);
-  my ($notes, $department, $customer, $employee, $amount, $project);
+  my ($notes, $customer, $employee, $amount, $project);
   my ($ARselected);
 
 
@@ -265,7 +256,7 @@ sub form_header {
   $readonly = ($form->{radier}) ? "" : $readonly;
 
   # set option selected
-  foreach my $item (qw(customer currency department employee)) {
+  foreach my $item (qw(customer currency employee)) {
     $form->{"select$item"} =~ s/ selected//;
     $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
   }
@@ -288,6 +279,8 @@ sub form_header {
                    "taxcharts" => { "key"       => "ALL_TAXCHARTS",
                                     "module"    => "AR" },);
 
+  $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
+
   $_->{link_split} = { map { $_ => 1 } split/:/, $_->{link} } for @{ $form->{ALL_CHARTS} };
 
   my %project_labels = map { $_->{id} => $_->{projectnumber} } @{ $form->{"ALL_PROJECTS"} };
@@ -700,7 +693,7 @@ sub post {
   $form->isblank("duedate",   $locale->text('Due Date missing!'));
   $form->isblank("customer",  $locale->text('Customer missing!'));
 
-  if ($myconfig{mandatory_departments} && !$form->{department}) {
+  if ($myconfig{mandatory_departments} && !$form->{department_id}) {
     $form->{saved_message} = $::locale->text('You have to specify a department.');
     update();
     exit;
@@ -890,10 +883,10 @@ sub search {
 
   # Auch in Rechnungsübersicht nach Kundentyp filtern - jan
   $form->get_lists("projects"       => { "key" => "ALL_PROJECTS", "all" => 1 },
-                   "departments"    => "ALL_DEPARTMENTS",
                    "customers"      => "ALL_VC",
                    "business_types" => "ALL_BUSINESS_TYPES");
   $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
+  $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
   $form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
 
   $form->{CT_CUSTOM_VARIABLES}                  = CVar->get_configs('module' => 'CT');
@@ -1044,21 +1037,9 @@ sub ar_transactions {
     push @options, $locale->text('Contact Person') . " : $form->{cp_name}";
   }
 
-  # $form->{department} seems to never be filled, and showing the department_id
-  # at the top of the report doesn't make much sense.
-  # So determine the department name from the id whenever we have a filter for
-  # department
-  if ($form->{department}) {
-    my ($department) = split /--/, $form->{department};
-    push @options, $locale->text('Department') . " : $department";
-  }
   if ($form->{department_id}) {
-    # push @options, $locale->text('Department Id') . " : $form->{department_id}";
-    unless ($form->{department}) {
-      require SL::DB::Department;
-      my $department = SL::DB::Manager::Department->find_by(id => $::form->{department_id});
-      push @options, $locale->text('Department') . " : " . $department->description if $department;
-    }
+    my $department = SL::DB::Manager::Department->find_by( id => $form->{department_id} );
+    push @options, $locale->text('Department') . " : " . $department->description;
   }
   if ($form->{invnumber}) {
     push @options, $locale->text('Invoice Number') . " : $form->{invnumber}";
index 285ee67..bcae2be 100644 (file)
                    <td>[%- IF forex %][% L.hidden_tag('exchangerate', LxERP.format_amount(exchangerate, 5)) %][% LxERP.format_amount(exchangerate, 5) %][%- ELSE %][% L.input_tag('exchangerate', LxERP.format_amount(exchangerate, 5), size=10) %][%- END %]</td>
                 [% END %]
               </tr>
-              [% department_html %]
-              [%- IF selectdepartment %]
-              <tr>
-                <th align="right" nowrap>[% 'Department' | $T8 %]</th>
-                <td colspan=3><select name=department>[% selectdepartment %]</select>
-                <input type=hidden name=selectdepartment value="[% selectdepartment | html %]">
-                </td>
-              </tr>
-              [%- END %]
+              [% IF ALL_DEPARTMENTS %]
+                <tr>
+                  <th align="right" nowrap>[% 'Department' | $T8 %]</th>
+                  <td colspan=3>[% L.select_tag('department_id', ALL_DEPARTMENTS, default = department_id, title_key = 'description', with_empty = 1) %]</td>
+                </tr>
+              [% END %]
               <tr>
                 <td align=right>[% L.checkbox_tag('taxincluded', checked=taxincluded) %]</td>
                 <th align="left" nowrap><label for="taxincluded">[% 'Tax Included' | $T8 %]</label></th>
index 3944d01..fffbd9c 100644 (file)
     </tr>
      <tr>
       <th align=right nowrap>[% 'Department' | $T8 %]</th>
-      <td>
-            [%- INCLUDE 'generic/multibox.html'
-                 name          = 'department',
-                 select_name   = 'department_id',
-                 style         = 'width: 250px',
-                 DATA          = ALL_DEPARTMENTS,
-                 id_key        = 'id',
-                 label_key     = 'description',
-                 show_empty    = 1,
-                 allow_textbox = 0,
-            -%]
-      </td>
+      <td colspan=3>[% L.select_tag('department_id', ALL_DEPARTMENTS, title_key = 'description', with_empty = 1, style="width: 200px") %]</td>
      </tr>
      <tr>
       <th align=right nowrap>[% 'Invoice Number' | $T8 %]</th>