- # format " into "
- map { $form->{$_} =~ s/\"/"/g } keys %$form;
-
- $form->{title} = "Edit";
-
- # format discount
- $form->{discount} *= 100;
-
- &form_header;
- &form_footer;
-
- $lxdebug->leave_sub();
-}
-
-sub form_header {
- $lxdebug->enter_sub();
-
- $form->get_lists("employees" => "ALL_SALESMEN",
- "taxzones" => "ALL_TAXZONES");
- $form->get_pricegroup(\%myconfig, { all => 1 });
-
- $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
- $form->{is_admin} = $myconfig{role} eq 'admin';
- $form->{is_customer} = $form->{db} eq 'customer';
- $form->{salesman_label} = sub { $_[0]->{name} ne "" ? $_[0]->{name} : $_[0]->{login} };
- $form->{shipto_label} = sub { "$_[0]->{shiptoname} $_[0]->{shiptodepartment_1}" };
- $form->{taxzone_id} = 0 if !$form->{id};
- $form->{jsscript} = 1;
- $form->{fokus} = "ct.greeting";
-
- unshift @{ $form->{SHIPTO} }, +{ shipto_id => '0', shiptoname => '' }, +{ shipto_id => '0', shiptoname => 'Alle' };
- unshift @{ $form->{CONTACTS} }, +{ cp_id => '0', cp_name => $locale->text('New contact') };
-
- push @{ $form->{AJAX} }, map {
- new CGI::Ajax( "get_$_" => "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_$_" )
- } qw(shipto contact delivery);
-
- $form->{title} = $form->{title_save}
- || $locale->text("$form->{title} " . ucfirst $form->{db}) . ($form->{title} eq "Edit" ? " $form->{name}" : '');
-
-## LINET: Create a drop-down box with all prior titles and greetings.
- CT->query_titles_and_greetings(\%myconfig, \%$form);
- map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(TITLES GREETINGS COMPANY_GREETINGS DEPARTMENT);
-## /LINET
-
- $form->header;
- print $form->parse_html_template('ct/form_header');
-
- $lxdebug->leave_sub();
-}
-
-sub form_footer {
- $lxdebug->enter_sub();
-
- print $form->parse_html_template('ct/form_footer', { is_orphaned => $form->{status} eq 'orphaned',
- is_customer => $form->{db} eq 'customer' });
- $lxdebug->leave_sub();
-}
-
-sub add_transaction {
- $lxdebug->enter_sub();
-
-# # saving the history
-# if(!exists $form->{addition}) {
-# $form->{addition} = "ADD TRANSACTION";
-# $form->save_history($form->dbconnect(\%myconfig));
-# }
-# # /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);
- }
-
- $form->{callback} = $form->escape($form->{callback}, 1);
- $name = $form->escape("$form->{name}", 1);
-
- $form->{callback} =
- "$form->{script}?login=$form->{login}&password=$form->{password}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}";
- $form->redirect;
-
- $lxdebug->leave_sub();
-}
-
-sub save_and_ap_transaction {
- $lxdebug->enter_sub();
-
- $form->{script} = "ap.pl";
- # saving the history
- if(!exists $form->{addition}) {
- $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
- $form->{addition} = "SAVED";
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
- &add_transaction;
- $lxdebug->leave_sub();
-}
-
-sub save_and_ar_transaction {
- $lxdebug->enter_sub();
-
- $form->{script} = "ar.pl";
- # saving the history
- if(!exists $form->{addition}) {
- $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
- $form->{addition} = "SAVED";
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
- &add_transaction;
- $lxdebug->leave_sub();
-}
-
-sub save_and_invoice {
- $lxdebug->enter_sub();
-
- $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
- $form->{type} = "invoice";
- # saving the history
- if(!exists $form->{addition}) {
- $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
- $form->{addition} = "SAVED";
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
- &add_transaction;
- $lxdebug->leave_sub();
-}
-
-sub save_and_rfq {
- $lxdebug->enter_sub();
-
- $form->{script} = "oe.pl";
- $form->{type} = "request_quotation";
- # saving the history
- if(!exists $form->{addition}) {
- $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
- $form->{addition} = "SAVED";
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
- &add_transaction;
- $lxdebug->leave_sub();
-}
-
-sub save_and_quotation {
- $lxdebug->enter_sub();