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

index ef3109f..46b25ea 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -66,8 +66,6 @@ sub _post_transaction {
   $form->{defaultcurrency} = $form->get_default_currency($myconfig);
   $form->{taxincluded} = 0 unless $form->{taxincluded};
 
-  ($null, $form->{department_id}) = split(/--/, $form->{department});
-
   if ($form->{currency} eq $form->{defaultcurrency}) {
     $form->{exchangerate} = 1;
   } else {
@@ -463,13 +461,9 @@ sub ap_transactions {
     $where .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
     push(@values, (like($form->{"cp_name"}))x2);
   }
-  if ($form->{department}) {
-    # ähnlich wie commit 0bbfb33b6aa8e38bb6c81d1684ab7d08e5b5c5af abteilung
-    # wird so nicht mehr als zeichenkette zusammengebaut
-    # hätte zu ee9f9f9aa4c3b9d5d20ab10a45c12bcaa6aa78d0 auffallen können ;-) jan
-    #my ($null, $department_id) = split /--/, $form->{department};
+  if ($form->{department_id}) {
     $where .= " AND a.department_id = ?";
-    push(@values, $form->{department});
+    push(@values, $form->{department_id});
   }
   if ($form->{invnumber}) {
     $where .= " AND a.invnumber ILIKE ?";
index 4ceb128..3440f93 100644 (file)
@@ -100,6 +100,7 @@ sub add {
   $form->{initial_transdate} = $form->{transdate};
   create_links(dont_save => 1);
   $form->{transdate} = $form->{initial_transdate};
+
   &display_form;
 
   $main::lxdebug->leave_sub();
@@ -187,11 +188,7 @@ sub create_links {
       (@{ $form->{all_vendor} });
   }
 
-  # departments
-  if (@{ $form->{all_departments} || [] }) {
-    $form->{department}       = "$form->{department}--$form->{department_id}";
-    $form->{selectdepartment} = "<option>\n" . join('', map { my $quoted = H("$_->{description}--$_->{id}"); "<option value=\"${quoted}\">${quoted}\n"} @{ $form->{all_departments} || [] });
-  }
+  $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
 
   $form->{employee} = "$form->{employee}--$form->{employee_id}";
 
@@ -242,7 +239,7 @@ sub form_header {
   # type=submit $locale->text('Edit Accounts Payables Transaction')
 
   # set option selected
-  foreach my $item (qw(vendor currency department)) {
+  foreach my $item (qw(vendor currency)) {
     my $to_replace         =  H($form->{$item});
     $form->{"select$item"} =~ s/ selected//;
     $form->{"select$item"} =~ s/>\Q${to_replace}\E/ selected>${to_replace}/;
@@ -297,6 +294,8 @@ sub form_header {
     @{ $form->{ALL_CHARTS} }
   );
 
+  $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
+
   my %project_labels = ();
   foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
     $project_labels{$item->{id}} = $item->{projectnumber};
@@ -675,7 +674,7 @@ sub post {
   $form->isblank("vendor",    $locale->text('Vendor missing!'));
   $form->isblank("invnumber", $locale->text('Invoice Number 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;
@@ -887,9 +886,9 @@ sub search {
   $form->{title}    = $locale->text('AP Transactions');
 
   $form->get_lists("projects"     => { "key" => "ALL_PROJECTS", "all" => 1 },
-                   "departments"  => "ALL_DEPARTMENTS",
                    "vendors"      => "ALL_VC");
 
+  $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
   # constants and subs for template
   $form->{vc_keys}   = sub { "$_[0]->{name}--$_[0]->{id}" };
 
@@ -945,7 +944,7 @@ sub ap_transactions {
        vendornumber country ustid taxzone payment_terms charts direct_debit);
 
   my @hidden_variables = map { "l_${_}" } @columns;
-  push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id transdatefrom transdateto department
+  push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id transdatefrom transdateto
                                            parts_partnumber parts_description);
 
   my $href = build_std_url('action=ap_transactions', grep { $form->{$_} } @hidden_variables);
@@ -997,7 +996,7 @@ sub ap_transactions {
   my @options;
   push @options, $locale->text('Vendor')                  . " : $form->{vendor}"                         if ($form->{vendor});
   push @options, $locale->text('Contact Person')          . " : $form->{cp_name}"                        if ($form->{cp_name});
-  push @options, $locale->text('Department')              . " : " . (split /--/, $form->{department})[0] if ($form->{department});
+  push @options, $locale->text('Department')              . " : $form->{department}"                     if ($form->{department});
   push @options, $locale->text('Invoice Number')          . " : $form->{invnumber}"                      if ($form->{invnumber});
   push @options, $locale->text('Order Number')            . " : $form->{ordnumber}"                      if ($form->{ordnumber});
   push @options, $locale->text('Notes')                   . " : $form->{notes}"                          if ($form->{notes});
index 56abcb7..169a5e0 100644 (file)
@@ -28,7 +28,6 @@
 <form method="post" action="[% script | html %]">
 
 <input type="hidden" name="selectvendor" value="[% selectvendor | html %]">
-<input type="hidden" name="selectdepartment" value="[% selectdepartment | html %]">
 <input type="hidden" name="selectcurrency" value="[% selectcurrency | html %]">
 
 <input type="hidden" name="oldvendor" value="[% oldvendor | html %]">
 
               </tr>
 
-              [% IF ( selectdepartment ) %]
+              [% IF ALL_DEPARTMENTS %]
                 <tr>
                   <th align="right" nowrap>[% 'Department' | $T8 %]</th>
-                  <td colspan="3">
-                    <select name="department">[% selectdepartment %]</select>
-                  </td>
+                  <td colspan=3>[% L.select_tag('department_id', ALL_DEPARTMENTS, default = department_id, title_key = 'description', with_empty = 1) %]</td>
                 </tr>
               [% END %]
 
index 0f69244..67d2b82 100644 (file)
     </tr>
      <tr>
       <th align=right nowrap>[% 'Department' | $T8 %]</th>
-      <td>
-            [%- INCLUDE 'generic/multibox.html'
-                 name          = 'department',
-                 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>