@@ -776,24 +775,15 @@ sub form_header {
|
$taxincluded
@@ -1049,14 +1043,12 @@ sub form_footer {
print $webdav_list;
}
- print qq|
-{jscalendar}>
-|;
+
print qq|
|
|;
- &print_options;
+ print_options();
print qq|
|
@@ -1151,7 +1143,6 @@ sub form_footer {
-{path}>
{login}>
{password}>
@@ -1171,9 +1162,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 +1339,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 +1370,31 @@ 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 },
+ "employees" => "ALL_EMPLOYEES",
+ $vc => "ALL_" . uc($vc));
my %labels = ();
my @values = ("");
@@ -1427,6 +1406,41 @@ sub search {
NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
'-labels' => \%labels));
+ #employees
+ %labels = ();
+ @values = ("");
+ foreach my $item (@{ $form->{"ALL_EMPLOYEES"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"name"} ne "" ? $item->{"name"} : $item->{"login"};
+ }
+
+ my $employee_block = qq|
+
+ | . $locale->text('Employee') . qq| |
+ | .
+ NTI($cgi->popup_menu('-name' => 'employee_id',
+ '-values' => \@values,
+ '-labels' => \%labels)) . qq|
+ |
+
|;
+
+ %labels = ();
+ @values = ("");
+
+ foreach my $item (@{ $form->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) {
+ push(@values, $item->{name}.qq|--|.$item->{"id"});
+ $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
+ }
+
+ 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 +1457,7 @@ sub search {
- $vclabel |
+ $vc_label |
$vc |
$department
@@ -1451,6 +1465,11 @@ sub search {
$ordlabel |
|
+ $employee_block
+
+ | . $locale->text('Transaction description') . qq| |
+ |
+
| . $locale->text("Project Number") . qq| |
$projectnumber |
@@ -1483,7 +1502,7 @@ sub search {
. $locale->text('Required by') . qq|
- $vclabel |
+ $vc_label |
$employee |
|
. $locale->text('Ship via') . qq| |
@@ -1496,8 +1515,12 @@ sub search {
. $locale->text('Tax') . qq|
|
. $locale->text('Total') . qq| |
+
+
|
. $locale->text('Project Number') . qq| |
+ |
+ . $locale->text('Transaction description') . qq| |
|
@@ -1516,7 +1539,6 @@ $jsscript
-{path}>
{login}>
{password}>
{vc}>
@@ -1536,35 +1558,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 +1680,9 @@ sub orders {
$column_header{employee} =
qq| | $employee | |;
+ $column_header{transaction_description} =
+ qq||
+ . $locale->text("Transaction description") . qq| | |;
$column_header{ids} = qq| | |;
@@ -1760,7 +1785,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 +1802,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 +1854,6 @@ sub orders {
if ($form->{type} =~ /sales_order/) {
print qq|
-
@@ -1851,7 +1876,6 @@ sub orders {
{type}>
{vc}>
-{path}>
{login}>
{password}>
@@ -1906,6 +1930,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 +1944,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 +2004,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 +2025,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 +2039,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 +2097,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));
}
@@ -2096,8 +2144,11 @@ sub delete {
$msg $form->{$ordnumber}
+
+
@@ -2107,7 +2158,7 @@ sub delete {
$lxdebug->leave_sub();
}
-sub yes {
+sub delete_order_quotation {
$lxdebug->enter_sub();
if ($form->{type} =~ /_order$/) {
@@ -2118,13 +2169,15 @@ sub yes {
$err = $locale->text('Cannot delete quotation!');
}
if (OE->delete(\%myconfig, \%$form, $spool)){
- $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));
}
# /saving the history
+ $form->info($msg);
+ exit();
}
$form->error($err);
@@ -2134,6 +2187,9 @@ sub yes {
sub invoice {
$lxdebug->enter_sub();
+ $form->{old_employee_id} = $form->{employee_id};
+ $form->{old_salesman_id} = $form->{salesman_id};
+
if ($form->{type} =~ /_order$/) {
# these checks only apply if the items don't bring their own ordnumbers/transdates.
@@ -2152,9 +2208,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;
}
@@ -2178,6 +2241,7 @@ sub invoice {
$exchangerate =
$form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
$buysell);
+ print(STDERR "CURRENCY $form->{currency} DEFAULT: $form->{defaultcurrency} EXCHANGE $exchangerate\n");
if (!$exchangerate) {
&backorder_exchangerate($orddate, $buysell);
@@ -2234,7 +2298,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 +2379,6 @@ sub backorder_exchangerate {
print qq|
-{path}>
{login}>
{password}>
@@ -2451,6 +2514,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});
@@ -2461,14 +2526,70 @@ sub save_as_new {
$lxdebug->leave_sub();
}
+sub check_for_direct_delivery_yes {
+ $lxdebug->enter_sub();
+
+ $form->{direct_delivery_checked} = 1;
+ delete @{$form}{grep /^shipto/, keys %{ $form }};
+ map { s/^CFDD_//; $form->{$_} = $form->{"CFDD_${_}"} } grep /^CFDD_/, keys %{ $form };
+ $form->{shipto} = 1;
+ purchase_order();
+ $lxdebug->leave_sub();
+}
+
+sub check_for_direct_delivery_no {
+ $lxdebug->enter_sub();
+
+ $form->{direct_delivery_checked} = 1;
+ delete @{$form}{grep /^shipto/, keys %{ $form }};
+ purchase_order();
+
+ $lxdebug->leave_sub();
+}
+
+sub check_for_direct_delivery {
+ $lxdebug->enter_sub();
+
+ if ($form->{direct_delivery_checked}
+ || (!$form->{shiptoname} && !$form->{shiptostreet} && !$form->{shipto_id})) {
+ $lxdebug->leave_sub();
+ return;
+ }
+
+ if ($form->{shipto_id}) {
+ Common->get_shipto_by_id(\%myconfig, $form, $form->{shipto_id}, "CFDD_");
+
+ } else {
+ map { $form->{"CFDD_${_}"} = $form->{$_ } } grep /^shipto/, keys %{ $form };
+ }
+
+ delete $form->{action};
+ $form->{VARIABLES} = [ map { { "key" => $_, "value" => $form->{$_} } } grep { ref $_ eq "" } keys %{ $form } ];
+
+ $form->header();
+ print $form->parse_html_template("oe/check_for_direct_delivery");
+
+ $lxdebug->leave_sub();
+
+ exit 0;
+}
+
sub purchase_order {
$lxdebug->enter_sub();
+ if ($form->{type} eq 'sales_order') {
+ check_for_direct_delivery();
+ }
+
if ( $form->{type} eq 'sales_quotation'
|| $form->{type} eq 'request_quotation') {
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 +2609,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');
@@ -2507,6 +2632,9 @@ sub poso {
$form->{closed} = 0;
+ $form->{old_employee_id} = $form->{employee_id};
+ $form->{old_salesman_id} = $form->{salesman_id};
+
# reset
map { delete $form->{$_} }
qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
@@ -2541,10 +2669,28 @@ sub e_mail {
$form->{print_and_save} = 1;
- &save;
+ if (!$form->{id}) {
+ $print_post = 1;
+
+ my $saved_form = save_form();
- &edit_e_mail;
+ 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();
$lxdebug->leave_sub();
}
+sub yes {
+ call_sub($form->{yes_nextsub});
+}
+
+sub no {
+ call_sub($form->{no_nextsub});
+}
|