X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fct.pl;h=07a6d2ec86e537dd6e3b510aa489f62905bc14c2;hb=cb3274d509066b4c39866e809a5b3e854c82226c;hp=c2d3b9069ed1be5195c0233aebb9452fc4922e9f;hpb=6156d51ea0360382df95007e10a874f24f4dd81a;p=kivitendo-erp.git diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index c2d3b9069..07a6d2ec8 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -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 }) if $::vertreter; + $form->{ALL_SALESMEN} = $form->{ALL_EMPLOYEES}; $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; $form->{is_admin} = $myconfig{role} eq 'admin'; @@ -335,6 +336,29 @@ sub form_footer { $main::lxdebug->leave_sub(); } +sub _do_save { + $main::auth->assert('customer_vendor_edit & ' . + '(general_ledger | invoice_edit | vendor_invoice_edit | ' . + ' request_quotation_edit | sales_quotation_edit | sales_order_edit | purchase_order_edit)'); + + $::form->isblank("name", $::locale->text("Name missing!")); + + if ($::form->{new_salesman_id} && $::vertreter) { + $::form->{salesman_id} = $::form->{new_salesman_id}; + delete $::form->{new_salesman_id}; + } + + my $res = $::form->{db} eq 'customer' ? CT->save_customer(\%::myconfig, $::form) : CT->save_vendor(\%::myconfig, $::form); + + if (3 == $res) { + if ($::form->{"db"} eq "customer") { + $::form->error($::locale->text('This customer number is already in use.')); + } else { + $::form->error($::locale->text('This vendor number is already in use.')); + } + } +} + sub add_transaction { $main::lxdebug->enter_sub(); @@ -349,16 +373,11 @@ 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 - $form->isblank("name", $locale->text("Name missing!")); - if ($form->{"db"} eq "customer") { - CT->save_customer(\%myconfig, \%$form); - } else { - CT->save_vendor(\%myconfig, \%$form); - } + _do_save(); $form->{callback} = $form->escape($form->{callback}, 1); my $name = $form->escape("$form->{name}", 1); @@ -383,7 +402,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 +422,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 +447,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 +468,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 +489,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 +515,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; @@ -515,21 +534,13 @@ sub save_and_close { my $msg = ucfirst $form->{db}; $msg .= " saved!"; - $form->isblank("name", $locale->text("Name missing!")); - my $rc; - if ($form->{"db"} eq "customer") { - $rc = CT->save_customer(\%myconfig, \%$form); - } else { - $rc = CT->save_vendor(\%myconfig, \%$form); - } - if ($rc == 3) { - $form->error($locale->text('customernumber not unique!')); - } + _do_save(); + # saving the history 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)); @@ -549,32 +560,19 @@ sub save { my $msg = ucfirst $form->{db}; $msg .= " saved!"; - $form->isblank("name", $locale->text("Name missing!")); + _do_save(); - my $res; - if ($form->{"db"} eq "customer") { - $res = CT->save_customer(\%myconfig, \%$form); - } else { - $res = CT->save_vendor(\%myconfig, \%$form); - } - - if (3 == $res) { - if ($form->{"db"} eq "customer") { - $form->error($locale->text('This customer number is already in use.')); - } else { - $form->error($locale->text('This vendor number is already in use.')); - } - } # saving the history 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 +592,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 +651,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(); }