use POSIX qw(strftime);
use SL::CT;
+use SL::CVar;
use SL::ReportGenerator;
require "bin/mozilla/common.pl";
sub add {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
$form->{title} = "Add";
$form->{callback} =
- "$form->{script}?action=add&db=$form->{db}&login=$form->{login}&password=$form->{password}"
+ "$form->{script}?action=add&db=$form->{db}"
unless $form->{callback};
CT->populate_drop_down_boxes(\%myconfig, \%$form);
sub search {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
$form->{IS_CUSTOMER} = $form->{db} eq 'customer';
$form->get_lists("business_types" => "ALL_BUSINESS_TYPES");
$form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
- $form->{title} = $form->{IS_CUSTOMER} ? $locale->text('Customers') : $locale->text('Vendors');
- $form->{fokus} = 'Form.name';
+ $form->{CUSTOM_VARIABLES} = CVar->get_configs('module' => 'CT');
+ ($form->{CUSTOM_VARIABLES_FILTER_CODE},
+ $form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables' => $form->{CUSTOM_VARIABLES},
+ 'include_prefix' => 'l_',
+ 'include_value' => 'Y');
+
+ $form->{jsscript} = 1;
+ $form->{title} = $form->{IS_CUSTOMER} ? $locale->text('Customers') : $locale->text('Vendors');
+ $form->{fokus} = 'Form.name';
$form->header();
print $form->parse_html_template('ct/search');
sub list_names {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
$form->{IS_CUSTOMER} = $form->{db} eq 'customer';
CT->search(\%myconfig, \%$form);
+ my $cvar_configs = CVar->get_configs('module' => 'CT');
+
my @options;
if ($form->{status} eq 'all') {
push @options, $locale->text('All');
'ordnumber', 'quonumber'
);
+ my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
+ my %column_defs_cvars = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables;
+
+ push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables;
+
my %column_defs = (
'id' => { 'text' => $locale->text('ID'), },
"$form->{db}number" => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Customer Number') : $locale->text('Vendor Number'), },
'invnumber' => { 'text' => $locale->text('Invoice'), },
'ordnumber' => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Sales Order') : $locale->text('Purchase Order'), },
'quonumber' => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Quotation') : $locale->text('Request for Quotation'), },
+ %column_defs_cvars,
);
map { $column_defs{$_}->{visible} = $form->{"l_$_"} eq 'Y' } @columns;
$report->set_sort_indicator($form->{sort}, 1);
+ CVar->add_custom_variables_to_report('module' => 'CT',
+ 'trans_id_field' => 'id',
+ 'configs' => $cvar_configs,
+ 'column_defs' => \%column_defs,
+ 'data' => $form->{CT});
+
my $previous_id;
foreach my $ref (@{ $form->{CT} }) {
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
sub form_header {
$lxdebug->enter_sub();
- $form->get_lists("employees" => "ALL_SALESMEN",
+ $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';
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_$_" )
+ new CGI::Ajax( "get_$_" => "$form->{script}?action=get_$_" )
} qw(shipto contact delivery);
$form->{title} = $form->{title_save}
map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(TITLES GREETINGS COMPANY_GREETINGS DEPARTMENT);
## /LINET
+ $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');
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');
+
# # saving the history
# if(!exists $form->{addition}) {
# $form->{addition} = "ADD TRANSACTION";
$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->{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();
sub save_and_ap_transaction {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit & general_ledger');
+
$form->{script} = "ap.pl";
# saving the history
if(!exists $form->{addition}) {
sub save_and_ar_transaction {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit & general_ledger');
+
$form->{script} = "ar.pl";
# saving the history
if(!exists $form->{addition}) {
sub save_and_invoice {
$lxdebug->enter_sub();
+ if ($form->{db} eq 'customer') {
+ $auth->assert('customer_vendor_edit & invoice_edit');
+ } else {
+ $auth->assert('customer_vendor_edit & vendor_invoice_edit');
+ }
+
$form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
$form->{type} = "invoice";
# saving the history
sub save_and_rfq {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit & request_quotation_edit');
+
$form->{script} = "oe.pl";
$form->{type} = "request_quotation";
# saving the history
sub save_and_quotation {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit & sales_quotation_edit');
+
$form->{script} = "oe.pl";
$form->{type} = "sales_quotation";
# saving the history
sub save_and_order {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit & sales_order_edit');
+
$form->{script} = "oe.pl";
$form->{type} =
($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
sub save_and_close {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
# $locale->text('Customer saved!')
# $locale->text('Vendor saved!')
sub save {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
# $locale->text('Customer saved!')
# $locale->text('Vendor saved!')
sub delete {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
# $locale->text('Customer deleted!')
# $locale->text('Cannot delete customer!')
# $locale->text('Vendor deleted!')
sub display {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
&form_header();
&form_footer();
sub update {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
&display();
$lxdebug->leave_sub();
}
sub get_contact {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
CT->get_contact(\%myconfig, \%$form);
my $q = new CGI;
sub get_shipto {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
CT->get_shipto(\%myconfig, \%$form);
my $q = new CGI;
sub get_delivery {
$lxdebug->enter_sub();
+ $auth->assert('customer_vendor_edit');
+
CT->get_delivery(\%myconfig, \%$form );
print CGI->new->header();