- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $form->{script} = "oe.pl";
- $form->{type} = "sales_quotation";
- # saving the history
- if(!exists $form->{addition}) {
- $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
- $form->{addition} = "SAVED";
- $form->save_history;
- }
- # /saving the history
- &add_transaction;
- $main::lxdebug->leave_sub();
-}
-
-sub save_and_order {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- if ($form->{db} eq 'customer') {
- $main::auth->assert('customer_vendor_edit & sales_order_edit');
- } else {
- $main::auth->assert('customer_vendor_edit & purchase_order_edit');
- }
-
- $form->{script} = "oe.pl";
- $form->{type} =
- ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
- # saving the history
- if(!exists $form->{addition}) {
- $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
- $form->{addition} = "SAVED";
- $form->save_history;
- }
- # /saving the history
- &add_transaction;
- $main::lxdebug->leave_sub();
-}
-
-sub save_and_close {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('customer_vendor_edit');
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- my $msg = ucfirst $form->{db};
- $msg .= " saved!";
-
- _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;
- }
- # /saving the history
- $form->redirect($locale->text($msg));
-
- $main::lxdebug->leave_sub();
-}
-
-sub save {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('customer_vendor_edit');
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- my $msg = ucfirst $form->{db};
- $msg .= " saved!";
-
- _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;
- }
- # /saving the history
- &edit;
-
- $main::lxdebug->leave_sub();
- ::end_of_request();
-}
-
-sub delete {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('customer_vendor_edit');
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- CT->delete(\%myconfig, \%$form);
-
- my $msg = ucfirst $form->{db};
- $msg .= " deleted!";
- # saving the history
- if(!exists $form->{addition}) {
- $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
- $form->{addition} = "DELETED";
- $form->save_history;
- }
- # /saving the history
- $form->redirect($locale->text($msg));
-
- $main::lxdebug->leave_sub();
-}
-
-sub display {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('customer_vendor_edit');
-
- my $form = $main::form;
-
- &form_header();
- &form_footer();
-
- $main::lxdebug->leave_sub();
-}
-
-sub update {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('customer_vendor_edit');
-
- my $form = $main::form;
-
- &display();
- $main::lxdebug->leave_sub();
-}
-
-sub get_contact {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('customer_vendor_edit');
-
- CT->populate_drop_down_boxes(\%::myconfig, $::form);
- CT->query_titles_and_greetings(\%::myconfig, $::form);
- CT->get_contact(\%::myconfig, $::form) if $::form->{cp_id};
-
- $::form->{CUSTOM_VARIABLES}{Contacts} = CVar->get_custom_variables(module => 'Contacts', trans_id => $::form->{cp_id});
- CVar->render_inputs(variables => $::form->{CUSTOM_VARIABLES}{Contacts}, name_prefix => 'cp')
- if scalar @{ $::form->{CUSTOM_VARIABLES}->{Contacts} };
-
- $::form->{contacts_label} = \&_contacts_label;
-
- print $::form->ajax_response_header(), $::form->parse_html_template('ct/_contact');
-
- $main::lxdebug->leave_sub();
-}
-
-sub get_shipto {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('customer_vendor_edit');
-
- CT->populate_drop_down_boxes(\%::myconfig, $::form);
- CT->get_shipto(\%::myconfig, $::form) if $::form->{shipto_id};
-
- $::form->{shipto_label} = \&_shipto_label;
-
- print $::form->ajax_response_header(), $::form->parse_html_template('ct/_shipto');
-
- $main::lxdebug->leave_sub();
-}
-
-sub get_delivery {
- $::lxdebug->enter_sub;
-
- $::auth->assert('customer_vendor_edit');
- $::auth->assert('sales_all_edit');
-
- CT->get_delivery(\%::myconfig, $::form );
-
- print $::form->ajax_response_header,
- $::form->parse_html_template('ct/get_delivery', {
- is_customer => $::form->{db} eq 'customer',
- });
-
- $::lxdebug->leave_sub;
-}
-
-sub delete_shipto {
- $::lxdebug->enter_sub;
- $::auth->assert('customer_vendor_edit');
-
- if (!$::form->{shipto_id}) {
- flash('error', $::locale->text('No shipto selected to delete'));
- } else {
-
- CT->get_shipto(\%::myconfig, $::form);
-
- my $shipto = SL::DB::Manager::Shipto->find_by(shipto_id => $::form->{shipto_id});
-
- if ($shipto->used) {
- $shipto->detach->save;
- flash('info', $::locale->text('Shipto is in use and was flagged invalid.'));
- } else {
- $shipto->delete;
- flash('info', $::locale->text('Shipto deleted.'));
- }
- delete $::form->{$_} for grep /^shipto/, keys %$::form;
- }
-
- edit();
-
- $::lxdebug->leave_sub;
-}
-
-sub delete_contact {
- $::lxdebug->enter_sub;
- $::auth->assert('customer_vendor_edit');
-
- if (!$::form->{cp_id}) {
- flash('error', $::locale->text('No contact selected to delete'));
- } else {
-
- CT->get_contact(\%::myconfig, $::form);
-
- my $contact = SL::DB::Manager::Contact->find_by(cp_id => $::form->{cp_id});
-
- if ($contact->used) {
- $contact->detach->save;
- flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
- } else {
- $contact->delete;
- flash('info', $::locale->text('Contact deleted.'));
- }
- delete $::form->{$_} for grep /^cp_/, keys %$::form;