Im Vertretermodus auch ungültige Vertreter in Vertreterauswahl anzeigen
[kivitendo-erp.git] / bin / mozilla / ct.pl
index 8abe73a..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,10 +285,12 @@ sub form_header {
   my %myconfig = %main::myconfig;
   my $locale   = $main::locale;
 
-  $form->get_lists("employees" => "ALL_EMPLOYEES",
-                   "taxzones"  => "ALL_TAXZONES");
+  $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';
@@ -348,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
 
@@ -382,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;
@@ -402,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;
@@ -427,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;
@@ -448,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;
@@ -469,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;
@@ -495,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;
@@ -528,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));
@@ -568,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 {
@@ -593,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));
@@ -652,27 +655,25 @@ 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();
 
 }
 
 sub get_delivery {
-  $main::lxdebug->enter_sub();
+  $::lxdebug->enter_sub;
 
-  $main::auth->assert('customer_vendor_edit');
-  $main::auth->assert('sales_all_edit');
+  $::auth->assert('customer_vendor_edit');
+  $::auth->assert('sales_all_edit');
 
-  my $form     = $main::form;
-  my %myconfig = %main::myconfig;
-
-  CT->get_delivery(\%myconfig, \%$form );
-  $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
+  CT->get_delivery(\%::myconfig, $::form );
 
-  print $form->ajax_response_header(), $form->parse_html_template('ct/get_delivery');
+  print $::form->ajax_response_header,
+        $::form->parse_html_template('ct/get_delivery', {
+          is_customer =>  $::form->{db} eq 'customer',
+        });
 
-  $main::lxdebug->leave_sub();
+  $::lxdebug->leave_sub;
 }
 
 sub delete_shipto {