Einkaufsrechnungen: Abteilungs- & Projektauswahl nicht über Multibox
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 20 Jan 2017 16:34:01 +0000 (17:34 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 23 Jan 2017 10:54:23 +0000 (11:54 +0100)
SL/IS.pm
bin/mozilla/ir.pl
templates/webpages/ir/form_header.html

index 6d1e843..6018634 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -1339,9 +1339,6 @@ SQL
   # need the current dbh to get the not yet committed mtime
   $form->new_lastmtime('ar', $provided_dbh);
 
-  $form->{name} = $form->{customer};
-  $form->{name} =~ s/--\Q$form->{customer_id}\E//;
-
   # add shipto
   if (!$form->{shipto_id}) {
     $form->add_shipto($dbh, $form->{id}, "AR");
index 593d290..71d7d73 100644 (file)
@@ -36,6 +36,7 @@ use SL::FU;
 use SL::IR;
 use SL::IS;
 use SL::DB::Default;
+use SL::DB::Department;
 use SL::DB::PurchaseInvoice;
 use List::Util qw(max sum);
 use List::UtilsBy qw(sort_by);
@@ -140,17 +141,6 @@ sub invoice_links {
     $form->{vendor}         = qq|$form->{vendor}--$form->{vendor_id}|;
   }
 
-  # 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} || [] });
-  }
-
   # forex
   $form->{forex} = $form->{exchangerate};
   my $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
@@ -267,15 +257,12 @@ sub form_header {
   my @old_project_ids = ($form->{"globalproject_id"});
   map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
 
-  $form->get_lists("projects"      => { "key"    => "ALL_PROJECTS",
-                                        "all"    => 0,
-                                        "old_id" => \@old_project_ids },
-                   "taxzones"      => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
+  $form->get_lists("taxzones"      => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
                    "currencies"    => "ALL_CURRENCIES",
                    "vendors"       => "ALL_VENDORS",
-                   "departments"   => "all_departments",
                    "price_factors" => "ALL_PRICE_FACTORS");
 
+  $TMPL_VAR{ALL_DEPARTMENTS}       = SL::DB::Manager::Department->get_all_sorted;
   $TMPL_VAR{ALL_EMPLOYEES}         = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{employee_id},  deleted => 0 ] ]);
   $TMPL_VAR{ALL_CONTACTS}          = SL::DB::Manager::Contact->get_all_sorted(query => [
     or => [
@@ -286,7 +273,6 @@ sub form_header {
       ]
     ]
   ]);
-  $TMPL_VAR{department_labels}     = sub { "$_[0]->{description}--$_[0]->{id}" };
 
   # customer
   $TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
@@ -341,7 +327,7 @@ sub form_header {
   $TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice();
   $form->{duedate}             = $TMPL_VAR{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{due_due})->to_kivitendo if $TMPL_VAR{payment_terms_obj};
 
-  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part client_js));
+  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part autocomplete_project client_js));
 
   $form->header();
 
index 427e570..b75cbda 100644 (file)
@@ -1,7 +1,7 @@
 [%- USE T8 %]
 [%- USE HTML %]
 [%- USE LxERP %]
-[%- USE L %]
+[%- USE L %][%- USE P -%]
 <h1>[% title %]</h1>
 
 [%- SET follow_up_trans_info = invnumber _ ' (' _ vendor_name _ ')' %]
           <input type='hidden' name='taxzone_id' value='[% taxzone_id %]'>
   [%- END %]
         </tr>
-[%- IF all_departments %]
+[%- IF ALL_DEPARTMENTS.as_list.size %]
         <tr>
           <th align="right" nowrap>[% 'Department' | $T8 %]</th>
-          <td colspan="3">
-            [%- INCLUDE 'generic/multibox.html'
-                 name       = 'department_id',
-                 style      = 'width: 250px',
-                 DATA       = all_departments,
-                 id_key     = 'id',
-                 label_sub  = 'department_labels',
-                 show_empty = 1 -%]
-          </td>
+          <td colspan="3">[% P.select_tag("department_id", ALL_DEPARTMENTS, with_empty=1, default=department_id, title_key="description", style="width: 250px") %]</td>
         </tr>
 [%- END %]
 [%- IF currencies %]
         </tr>
         <tr>
           <th align="right" nowrap>[% 'Project Number' | $T8 %]</th>
-          <td>
-            [%- INCLUDE 'generic/multibox.html'
-                 name       = 'globalproject_id',
-                 DATA       = ALL_PROJECTS,
-                 id_key     = 'id',
-                 label_key  = 'projectnumber',
-                 show_empty = 1,
-                 onChange   = "document.getElementById('update_button').click();" -%]
-          </td>
+          <td>[% P.project_picker('globalproject_id', globalproject_id) %]</td>
         </tr>
       </table>
     </td>