|;
- &print_options;
+ print_options();
print qq|
|
@@ -1151,7 +1140,6 @@ sub form_footer {
-{path}>
{login}>
{password}>
@@ -1171,9 +1159,17 @@ sub update {
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
qw(exchangerate creditlimit creditremaining);
$form->{update} = 1;
-
+
+ if($form->{payment_id}) {
+ $payment_id = $form->{payment_id};
+ }
+
&check_name($form->{vc});
-
+
+ if($form->{payment_id} eq "") {
+ $form->{payment_id} = $payment_id;
+ }
+
$buysell = 'buy';
$buysell = 'sell' if ($form->{vc} eq 'vendor');
$form->{exchangerate} = $exchangerate
@@ -1340,27 +1336,13 @@ sub search {
$form->all_vc(\%myconfig, $form->{vc},
($form->{vc} eq 'customer') ? "AR" : "AP");
- map { $vc .= "\n";
map {
$form->{selectdepartment} .=
- "$_->{description}--$_->{id}\n"
+ "$_->{description}--$_->{id}\n"
} (@{ $form->{all_departments} });
}
@@ -1385,37 +1367,30 @@ sub search {
}
# use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
+ $form->{jsscript} = 1;
$jsscript = "";
- if ($form->{jsscript}) {
-
- # with JavaScript Calendar
- $button1 = qq|
-
- text('button') . qq|> |
- |;
- $button2 = qq|
-
- text('button') . qq|> |
- |;
-
- #write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
- "transdateto", "BL", "trigger4");
- } else {
- # without JavaScript Calendar
- $button1 = qq|
- | |;
- $button2 = qq|
- | |;
- }
+ $button1 = qq|
+
+ text('button') . qq|> |
+ |;
+ $button2 = qq|
+
+ text('button') . qq|> |
+ |;
+
+ #write Trigger
+ $jsscript =
+ Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
+ "transdateto", "BL", "trigger4");
+
+ my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
$form->get_lists("projects" => { "key" => "ALL_PROJECTS",
- "all" => 1 });
+ "all" => 1 },
+ $vc => "ALL_" . uc($vc));
my %labels = ();
my @values = ("");
@@ -1427,6 +1402,24 @@ sub search {
NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
'-labels' => \%labels));
+ %labels = ();
+ @values = ("");
+
+ foreach my $item (@{ $form->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) {
+ push(@values, $item->{name}.qq|--|.$item->{"id"});
+ $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
+ }
+
+ my $vc_label = $form->{vc} eq "customer" ? $locale->text('Customer') : $locale->text('Vendor');
+ $vc =
+ $myconfig{vclimit} <= scalar(@values)
+ ? qq|{vc}"}) . qq|" name="$form->{vc}">|
+ : NTI($cgi->popup_menu('-name' => "$form->{vc}",
+ '-default' => $form->{"old$form->{vc}"},
+ '-onChange' => 'document.getElementById(\'update_button\').click();',
+ '-values' => \@values,
+ '-labels' => \%labels));
+
$form->header;
print qq|
@@ -1443,7 +1436,7 @@ sub search {
- $vclabel |
+ $vc_label |
$vc |
$department
@@ -1451,6 +1444,10 @@ sub search {
$ordlabel |
|
+
+ | . $locale->text('Transaction description') . qq| |
+ |
+
| . $locale->text("Project Number") . qq| |
$projectnumber |
@@ -1483,7 +1480,7 @@ sub search {
. $locale->text('Required by') . qq|
- $vclabel |
+ ucfirst($form->{vc}) |
$employee |
|
. $locale->text('Ship via') . qq| |
@@ -1496,8 +1493,12 @@ sub search {
. $locale->text('Tax') . qq|
|
. $locale->text('Total') . qq| |
+
+
|
. $locale->text('Project Number') . qq| |
+ |
+ . $locale->text('Transaction description') . qq| |
|
@@ -1516,7 +1517,6 @@ $jsscript
-{path}>
{login}>
{password}>
{vc}>
@@ -1536,35 +1536,35 @@ $jsscript
sub orders {
$lxdebug->enter_sub();
- # split vendor / customer
- ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
- split(/--/, $form->{ $form->{vc} });
-
- OE->transactions(\%myconfig, \%$form);
-
$ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
- $number = $form->escape($form->{$ordnumber});
- $name = $form->escape($form->{ $form->{vc} });
- $department = $form->escape($form->{department});
-
# construct href
- $href =
- "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department";
+ my @fields =
+ qw(type vc login password transdatefrom transdateto
+ open closed notdelivered delivered department
+ transaction_description);
+ push @fields, $form->{vc};
+ $href = "$form->{script}?action=orders&"
+ . join("&", map { "${_}=" . E($form->{$_}) } @fields)
+ . "&${ordnumber}=" . E($form->{$ordnumber});
+ $callback = $href;
- # construct callback
- $number = $form->escape($form->{$ordnumber}, 1);
- $name = $form->escape($form->{ $form->{vc} }, 1);
- $department = $form->escape($form->{department}, 1);
+ # split vendor / customer
+ ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
+ split(/--/, $form->{ $form->{vc} });
- $callback =
- "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department";
+ OE->transactions(\%myconfig, \%$form);
- @columns =
- $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
- "name", "netamount", "tax", "amount",
- "curr", "employee", "shipvia", "globalprojectnumber",
- "open", "closed", "delivered");
+ @columns = (
+ "transdate", "reqdate",
+ "id", "$ordnumber",
+ "name", "netamount",
+ "tax", "amount",
+ "curr", "employee",
+ "shipvia", "globalprojectnumber",
+ "transaction_description", "open",
+ "closed", "delivered"
+ );
$form->{l_open} = $form->{l_closed} = "Y"
if ($form->{open} && $form->{closed});
@@ -1658,6 +1658,9 @@ sub orders {
$column_header{employee} =
qq| | $employee | |;
+ $column_header{transaction_description} =
+ qq||
+ . $locale->text("Transaction description") . qq| | |;
$column_header{ids} = qq| | |;
@@ -1760,7 +1763,7 @@ sub orders {
$column_data{reqdate} = "$oe->{reqdate} | ";
$column_data{$ordnumber} =
- "{path}&action=$action&type=$form->{type}&id=$oe->{id}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber} | ";
+ "{type}&id=$oe->{id}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber} | ";
$column_data{name} = "$oe->{name} | ";
$column_data{employee} = "$oe->{employee} | ";
@@ -1777,6 +1780,7 @@ sub orders {
$column_data{"delivered"} = "" .
($oe->{"delivered"} ? $locale->text("Yes") : $locale->text("No")) .
" | ";
+ $column_data{transaction_description} = "" . H($oe->{transaction_description}) . " | ";
$i++;
$i %= 2;
@@ -1828,7 +1832,6 @@ sub orders {
if ($form->{type} =~ /sales_order/) {
print qq|
-
@@ -1851,7 +1854,6 @@ sub orders {
{type}>
{vc}>
-{path}>
{login}>
{password}>
@@ -1906,6 +1908,10 @@ sub save_and_close {
$form->isblank("transdate", $locale->text('Quotation Date missing!'));
}
+ my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
+ $form->{$idx} =~ s/^\s*//g;
+ $form->{$idx} =~ s/\s*$//g;
+
$msg = ucfirst $form->{vc};
$form->isblank($form->{vc}, $locale->text($msg . " missing!"));
@@ -1916,9 +1922,16 @@ sub save_and_close {
if ($form->{currency} ne $form->{defaultcurrency});
&validate_items;
-
+
+ if($form->{payment_id}) {
+ $payment_id = $form->{payment_id};
+ }
+
# if the name changed get new values
if (&check_name($form->{vc})) {
+ if($form->{payment_id} eq "") {
+ $form->{payment_id} = $payment_id;
+ }
&update;
exit;
}
@@ -1969,6 +1982,7 @@ sub save_and_close {
# saving the history
if(!exists $form->{addition}) {
+ $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{addition} = "SAVED";
$form->save_history($form->dbconnect(\%myconfig));
}
@@ -1989,6 +2003,10 @@ sub save {
$form->isblank("transdate", $locale->text('Quotation Date missing!'));
}
+ my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
+ $form->{$idx} =~ s/^\s*//g;
+ $form->{$idx} =~ s/\s*$//g;
+
$msg = ucfirst $form->{vc};
$form->isblank($form->{vc}, $locale->text($msg . " missing!"));
@@ -1999,9 +2017,16 @@ sub save {
if ($form->{currency} ne $form->{defaultcurrency});
&validate_items;
-
+
+ if($form->{payment_id}) {
+ $payment_id = $form->{payment_id};
+ }
+
# if the name changed get new values
if (&check_name($form->{vc})) {
+ if($form->{payment_id} eq "") {
+ $form->{payment_id} = $payment_id;
+ }
&update;
exit;
}
@@ -2050,6 +2075,7 @@ sub save {
# saving the history
if(!exists $form->{addition}) {
+ $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{addition} = "SAVED";
$form->save_history($form->dbconnect(\%myconfig));
}
@@ -2121,6 +2147,7 @@ sub yes {
$form->redirect($msg);
# saving the history
if(!exists $form->{addition}) {
+ $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{addition} = "DELETED";
$form->save_history($form->dbconnect(\%myconfig));
}
@@ -2152,9 +2179,16 @@ sub invoice {
$form->{ordnumber} = "";
$form->{quodate} = $form->{transdate};
}
-
+
+ if($form->{payment_id}) {
+ $payment_id = $form->{payment_id};
+ }
+
# if the name changed get new values
if (&check_name($form->{vc})) {
+ if($form->{payment_id} eq "") {
+ $form->{payment_id} = $payment_id;
+ }
&update;
exit;
}
@@ -2234,7 +2268,7 @@ sub invoice {
# locale messages
$locale = new Locale "$myconfig{countrycode}", "$script";
- require "$form->{path}/$form->{script}";
+ require "bin/mozilla/$form->{script}";
map { $form->{"select$_"} = "" } ($form->{vc}, currency);
@@ -2315,7 +2349,6 @@ sub backorder_exchangerate {
print qq|
-{path}>
{login}>
{password}>
@@ -2451,6 +2484,8 @@ sub save_as_new {
# Let Lx-Office assign a new order number if the user hasn't changed the
# previous one. If it has been changed manually then use it as-is.
my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
+ $form->{$idx} =~ s/^\s*//g;
+ $form->{$idx} =~ s/\s*$//g;
if ($form->{saved_xyznumber} &&
($form->{saved_xyznumber} eq $form->{$idx})) {
delete($form->{$idx});
@@ -2469,6 +2504,10 @@ sub purchase_order {
OE->close_order(\%myconfig, \%$form);
}
+ if ($form->{type} =~ /^sales_/) {
+ delete($form->{ordnumber});
+ }
+
$form->{cp_id} *= 1;
$form->{title} = $locale->text('Add Purchase Order');
@@ -2488,6 +2527,10 @@ sub sales_order {
OE->close_order(\%myconfig, $form);
}
+ if ($form->{type} eq "purchase_order") {
+ delete($form->{ordnumber});
+ }
+
$form->{cp_id} *= 1;
$form->{title} = $locale->text('Add Sales Order');
@@ -2541,9 +2584,20 @@ sub e_mail {
$form->{print_and_save} = 1;
- &save;
+ if (!$form->{id}) {
+ $print_post = 1;
+
+ my $saved_form = save_form();
+
+ save();
+
+ my %saved_vars;
+ map({ $saved_vars{$_} = $form->{$_}; } qw(id ordnumber quonumber));
+ restore_form($saved_form);
+ map({ $form->{$_} = $saved_vars{$_}; } qw(id ordnumber quonumber));
+ }
- &edit_e_mail;
+ edit_e_mail();
$lxdebug->leave_sub();
}
|