- $lxdebug->leave_sub();
-}
-
-sub edit {
- $lxdebug->enter_sub();
-
- $auth->assert('customer_vendor_edit');
-
- # show history button
- $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
- #/show hhistory button
-
- CT->get_tuple(\%myconfig, \%$form);
- CT->populate_drop_down_boxes(\%myconfig, \%$form);
-
- $form->{title} = "Edit";
-
- # format discount
- $form->{discount} *= 100;
-
- &form_header;
- &form_footer;
-
- $lxdebug->leave_sub();
-}
-
-sub form_header {
- $lxdebug->enter_sub();
-
- $auth->assert('customer_vendor_edit');
-
- $form->get_lists("employees" => "ALL_EMPLOYEES",
- "taxzones" => "ALL_TAXZONES");
- $form->get_pricegroup(\%myconfig, { all => 1 });
-
- $form->{ALL_SALESMEN} = $form->{ALL_EMPLOYEES};
- $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 { my $s = shift(@_); join('; ', grep { $_ } map { $s->{"shipto$_"} } qw(name department_1 street city)) || ' ' };
- $form->{contacts_label} = sub { join ", ", grep { $_ } $_[0]->{cp_name}, $_[0]->{cp_givenname} };
- $form->{taxzone_id} = 0 if !$form->{id};
- $form->{jsscript} = 1;
- $form->{fokus} = "ct.greeting";
- $form->{AJAX} = [ new CGI::Ajax( map {; "get_$_" => "$form->{script}?action=get_$_" } qw(shipto contact delivery) ) ];
-
- unshift @{ $form->{SHIPTO} }, +{ shipto_id => '0', shiptoname => '' }, +{ shipto_id => '0', shiptoname => 'Alle' };
- unshift @{ $form->{CONTACTS} }, +{ cp_id => '0', cp_name => $locale->text('New contact') };
-
- $form->{title} = $form->{title_save}
- || $locale->text("$form->{title} " . ucfirst $form->{db}) . ($form->{title} eq "Edit" ? " $form->{name}" : '');
-
- CT->query_titles_and_greetings(\%myconfig, \%$form);
- map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(TITLES GREETINGS COMPANY_GREETINGS DEPARTMENT);
-
- $form->{NOTES} ||= [ ];
-
- $form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'CT', 'trans_id' => $form->{id});
-
- CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}) if (scalar @{ $form->{CUSTOM_VARIABLES} });
-
- $form->header;
- print $form->parse_html_template('ct/form_header');
-
- $lxdebug->leave_sub();
-}
-
-sub form_footer {
- $lxdebug->enter_sub();
-
- $auth->assert('customer_vendor_edit');
-
- 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();
-
- $auth->assert('customer_vendor_edit & ' .
- '(general_ledger | invoice_edit | vendor_invoice_edit | ' .
- ' request_quotation_edit | sales_quotation_edit | sales_order_edit | purchase_order_edit)');
-
-# # 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}?action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}";
- $form->redirect;
-
- $lxdebug->leave_sub();