Im Vertretermodus auch ungültige Vertreter in Vertreterauswahl anzeigen
[kivitendo-erp.git] / bin / mozilla / ct.pl
index 0130a46..b6526b9 100644 (file)
@@ -156,7 +156,7 @@ sub list_names {
   my %column_defs = (
     'id'                => { 'text' => $locale->text('ID'), },
     "$form->{db}number" => { 'text' => $locale->text('Number'), },
-    'name'              => { 'text' => $locale->text('Name'), },
+    'name'              => { 'text' => $form->{IS_CUSTOMER} ? $::locale->text('Customer Name') : $::locale->text('Vendor Name'), },
     'contact'           => { 'text' => $locale->text('Contact'), },
     'phone'             => { 'text' => $locale->text('Phone'), },
     'fax'               => { 'text' => $locale->text('Fax'), },
@@ -285,11 +285,12 @@ sub form_header {
   my %myconfig = %main::myconfig;
   my $locale   = $main::locale;
 
-  $form->get_lists(employees      => "ALL_EMPLOYEES",
-                   taxzones       => "ALL_TAXZONES",
-                   business_types => { key => 'ALL_SALESMAN_BUSINESSES', salesman => 1 });
+  $form->get_lists(employees => "ALL_EMPLOYEES",
+                   taxzones  => "ALL_TAXZONES");
   $form->get_pricegroup(\%myconfig, { all => 1 });
 
+  $form->get_lists(customers => { key => "ALL_SALESMAN_CUSTOMERS", business_is_salesman => 1, with_obsolete => 1 }) if $::vertreter;
+
   $form->{ALL_SALESMEN}   = $form->{ALL_EMPLOYEES};
   $form->{taxincluded}    = ($form->{taxincluded}) ? "checked" : "";
   $form->{is_admin}       = $myconfig{role} eq 'admin';
@@ -349,7 +350,7 @@ sub add_transaction {
 #  # saving the history
 #  if(!exists $form->{addition}) {
 #    $form->{addition} = "ADD TRANSACTION";
-#    $form->save_history($form->dbconnect(\%myconfig));
+#    $form->save_history;
 #  }
 #  # /saving the history
 
@@ -383,7 +384,7 @@ sub save_and_ap_transaction {
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
     $form->{addition} = "SAVED";
-    $form->save_history($form->dbconnect(\%myconfig));
+    $form->save_history;
   }
   # /saving the history
   &add_transaction;
@@ -403,7 +404,7 @@ sub save_and_ar_transaction {
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
     $form->{addition} = "SAVED";
-    $form->save_history($form->dbconnect(\%myconfig));
+    $form->save_history;
   }
   # /saving the history
   &add_transaction;
@@ -428,7 +429,7 @@ sub save_and_invoice {
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
     $form->{addition} = "SAVED";
-    $form->save_history($form->dbconnect(\%myconfig));
+    $form->save_history;
   }
   # /saving the history
   &add_transaction;
@@ -449,7 +450,7 @@ sub save_and_rfq {
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
     $form->{addition} = "SAVED";
-    $form->save_history($form->dbconnect(\%myconfig));
+    $form->save_history;
   }
   # /saving the history
   &add_transaction;
@@ -470,7 +471,7 @@ sub save_and_quotation {
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
     $form->{addition} = "SAVED";
-    $form->save_history($form->dbconnect(\%myconfig));
+    $form->save_history;
   }
   # /saving the history
   &add_transaction;
@@ -496,7 +497,7 @@ sub save_and_order {
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
     $form->{addition} = "SAVED";
-    $form->save_history($form->dbconnect(\%myconfig));
+    $form->save_history;
   }
   # /saving the history
   &add_transaction;
@@ -529,7 +530,7 @@ sub save_and_close {
   if(!exists $form->{addition}) {
     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
     $form->{addition} = "SAVED";
-    $form->save_history($form->dbconnect(\%myconfig));
+    $form->save_history;
   }
   # /saving the history
   $form->redirect($locale->text($msg));
@@ -569,12 +570,13 @@ sub save {
   if(!exists $form->{addition}) {
     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
     $form->{addition} = "SAVED";
-    $form->save_history($form->dbconnect(\%myconfig));
+    $form->save_history;
   }
   # /saving the history
   &edit;
-  exit;
+
   $main::lxdebug->leave_sub();
+  ::end_of_request();
 }
 
 sub delete {
@@ -594,7 +596,7 @@ sub delete {
   if(!exists $form->{addition}) {
     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
     $form->{addition} = "DELETED";
-    $form->save_history($form->dbconnect(\%myconfig));
+    $form->save_history;
   }
   # /saving the history
   $form->redirect($locale->text($msg));
@@ -653,8 +655,7 @@ sub get_shipto {
   my %myconfig = %main::myconfig;
 
   CT->get_shipto(\%myconfig, \%$form);
-  print $form->ajax_response_header(),  join '__pjx__', map $form->{"shipto$_"},
-    qw(name department_1 department_2 street zipcode city country contact phone fax email used);
+  print $form->ajax_response_header(), join('__pjx__', map($form->{"shipto$_"}, qw(name department_1 department_2 street zipcode city country contact phone fax email used)));
   $main::lxdebug->leave_sub();
 
 }