#=====================================================================
# SQL-Ledger Accounting
-# Copyright (c) 2002
+# Copyright (c) 2003
#
# Author: Dieter Simader
# Email: dsimader@sql-ledger.org
sub check_name {
- my ($name) = @_;
+ my ($name, $msg) = @_;
my ($new_name, $new_id) = split /--/, $form->{$name};
my $i = 0;
if ($form->{"old$name"} ne $form->{$name}) {
# this is needed for is, ir and oe
map { delete $form->{"${_}_rate"} } (split / /, $form->{taxaccounts});
-
+
# for credit calculations
$form->{oldinvtotal} = 0;
$form->{oldtotalpaid} = 0;
+ $form->{calctax} = 1;
$form->{"${name}_id"} = $new_id;
- $form->{"old$name"} = "$new_name--$new_id";
-
IS->get_customer(\%myconfig, \%$form) if ($name eq 'customer');
IR->get_vendor(\%myconfig, \%$form) if ($name eq 'vendor');
+ $form->{$name} = $form->{"old$name"} = "$new_name--$new_id";
+
+ # put employee together if there is a new employee_id
+ $form->{employee} = "$form->{employee}--$form->{employee_id}" if $form->{employee_id};
+
$i = 1;
}
} else {
# for credit calculations
$form->{oldinvtotal} = 0;
$form->{oldtotalpaid} = 0;
+ $form->{calctax} = 1;
# return one name or a list of names in $form->{name_list}
if (($i = $form->get_name(\%myconfig, $name)) > 1) {
IS->get_customer(\%myconfig, \%$form) if ($name eq 'customer');
IR->get_vendor(\%myconfig, \%$form) if ($name eq 'vendor');
+ # put employee together if there is a new employee_id
+ $form->{employee} = "$form->{employee}--$form->{employee_id}" if $form->{employee_id};
+
} else {
- # name is not on file
- $msg = ucfirst $name . " not on file!";
+ # name is not on file or no outstanding invoice
+ $msg = ucfirst $name . " not on file!" unless $msg;
$form->error($locale->text($msg));
}
}
$label = ucfirst $table;
$column_data{ndx} = qq|<th> </th>|;
- $column_data{name} = qq|<th>|.$locale->text($label).qq|</th>|;
- $column_data{address} = qq|<th>|.$locale->text('Address').qq|</th>|;
+ $column_data{name} = qq|<th class=listheading>|.$locale->text($label).qq|</th>|;
+ $column_data{address} = qq|<th class=listheading>|.$locale->text('Address').qq|</th>|;
# list items with radio button on a form
$form->header;
foreach $ref (@{ $form->{name_list} }) {
$checked = ($i++) ? "" : "checked";
- $ref->{name} =~ s/"/"/g;
+ $ref->{name} = $form->quote($ref->{name});
$column_data{ndx} = qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
$column_data{name} = qq|<td><input name="new_name_$i" type=hidden value="$ref->{name}">$ref->{name}</td>|;
- $column_data{address} = qq|<td>$ref->{address}</td>|;
+ $column_data{address} = qq|<td>$ref->{address1} $ref->{address2} $ref->{city} $ref->{state} $ref->{zipcode} $ref->{country}</td>|;
$j++; $j %= 2;
print qq|
|;
- # delete action variable
- delete $form->{action};
- delete $form->{name_list};
-
- # save all other form variables
- foreach $key (keys %${form}) {
- $form->{$key} =~ s/"/"/g;
- print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
- }
+ # delete variables
+ map { delete $form->{$_} } qw(action name_list header);
+
+ $form->hide_form();
print qq|
<input type=hidden name=nextsub value=name_selected>
IS->get_customer(\%myconfig, \%$form) if ($form->{vc} eq 'customer');
IR->get_vendor(\%myconfig, \%$form) if ($form->{vc} eq 'vendor');
+ # put employee together if there is a new employee_id
+ $form->{employee} = "$form->{employee}--$form->{employee_id}" if $form->{employee_id};
+
&update(1);
}
$form->{callback} = $form->escape($form->{callback},1);
map { $argv .= "$_=$form->{$_}&" } keys %$form;
- exec ("perl", "$module.pl", $argv);
+ $form->{callback} = "$module.pl?$argv";
+ $form->redirect;
+
}
# not on file
$form->error($locale->text('Project not on file!'));
}
+ } else {
+ $form->{"oldprojectnumber_$i"} = "";
}
}
}
foreach $ref (@{ $form->{project_list} }) {
$checked = ($i++) ? "" : "checked";
- $ref->{name} =~ s/"/"/g;
+ $ref->{name} = $form->quote($ref->{name});
$column_data{ndx} = qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
$column_data{projectnumber} = qq|<td><input name="new_projectnumber_$i" type=hidden value="$ref->{projectnumber}">$ref->{projectnumber}</td>|;
|;
# delete action variable
- delete $form->{action};
- delete $form->{project_list};
-
- # save all other form variables
- foreach $key (keys %${form}) {
- $form->{$key} =~ s/"/"/g;
- print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
- }
+ map { delete $form->{$_} } qw(action project_list header);
+
+ $form->hide_form();
print qq|
<input type=hidden name=nextsub value=project_selected>
map { delete $form->{$_} } qw(ndx lastndx nextsub);
- &update;
+ if ($form->{update}) {
+ &{ $form->{update} };
+ } else {
+ &update;
+ }
}
sub gl_transaction { &add };
sub ar_transaction { &add_transaction(ar) };
sub ap_transaction { &add_transaction(ap) };
-sub sales_invoice { &add_transaction(is) };
-sub vendor_invoice { &add_transaction(ir) };
+sub sales_invoice_ { &add_transaction(is) };
+sub vendor_invoice_ { &add_transaction(ir) };